gzz.util
Class GeomUtil
java.lang.Object
|
+--gzz.util.GeomUtil
- public final class GeomUtil
- extends java.lang.Object
Some geometric utilities.
Field Summary |
static java.lang.String |
rcsid
|
Method Summary |
static void |
fitRectangle(java.awt.Rectangle frame,
java.awt.Dimension d,
boolean maintainAspect)
Make a dimension fit the given framing rectangle by
reducing its size. |
static void |
placeRectangle(java.awt.Rectangle r,
java.awt.Dimension d,
java.awt.Point p,
java.awt.Rectangle out)
Place a rectangle with the given size into the given
rectangle with its center as close as possible to the given
point. |
static int |
sqDistance(java.awt.Rectangle r,
java.awt.Point p)
Calculate the minimum square distance between the
given rectangle and the given point. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
rcsid
public static final java.lang.String rcsid
- See Also:
- Constant Field Values
GeomUtil
public GeomUtil()
sqDistance
public static int sqDistance(java.awt.Rectangle r,
java.awt.Point p)
- Calculate the minimum square distance between the
given rectangle and the given point.
fitRectangle
public static void fitRectangle(java.awt.Rectangle frame,
java.awt.Dimension d,
boolean maintainAspect)
- Make a dimension fit the given framing rectangle by
reducing its size.
If the given dimensions do not fit, they are scaled while
maintaining aspect ratio.
- Parameters:
frame
- The containing rectangled
- The dimension to shrink.maintainAspect
- Whether the aspect ration of d should
be maintained.
placeRectangle
public static void placeRectangle(java.awt.Rectangle r,
java.awt.Dimension d,
java.awt.Point p,
java.awt.Rectangle out)
- Place a rectangle with the given size into the given
rectangle with its center as close as possible to the given
point.
It may be reasonable to call fitRectangle first on the dimension.
This function assumes that the dimension fits the rectangle.