|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.berkeley.guir.lib.satin.objects.GraphicalObjectLib
Handy utilities for manipulating GraphicalObjects.
This software is distributed under the Berkeley Software License.
Revisions: - SATIN-v1.0-1.0.0, Oct 06 1998, JH Created class - SATIN-v2.1-1.0.0, Aug 11 2000, JH Touched for SATIN release
Inner classes inherited from class edu.berkeley.guir.lib.satin.SatinConstants |
SatinConstants.ObjectPoolAffineTransform, SatinConstants.ObjectPoolPoint2D, SatinConstants.ObjectPoolPolygon2D, SatinConstants.ObjectPoolRectangle2D, SatinConstants.ObjectPoolStringBuffer, SatinConstants.UniqueAffineTransform, SatinConstants.UniquePoint2D, SatinConstants.UniquePolygon2D, SatinConstants.UniqueRectangle2D |
Constructor Summary | |
GraphicalObjectLib()
|
Method Summary | |
static Point2D |
absoluteToLocal(GraphicalObject gob,
Point2D ptIn)
Convert a coordinate from absolute coordinates to local coordinates. |
static Point2D |
absoluteToLocal(GraphicalObject gob,
Point2D ptIn,
Point2D ptReturn)
Convert a coordinate from absolute coordinates to local coordinates. |
static Rectangle2D |
absoluteToLocal(GraphicalObject gob,
Rectangle2D rectIn)
Convert a rectangle from absolute coordinates to local coordinates. |
static void |
animate(GraphicalObject gob,
AffineTransform[] txArray)
Given a set of transforms, animate this graphical object using those transforms. |
static boolean |
atBottom(GraphicalObject gobAA,
GraphicalObject gobBB)
Uses the SatinConstants.DEFAULT_SELECT_THRESHOLD . |
static boolean |
atBottom(GraphicalObject gobAA,
GraphicalObject gobBB,
double thresh)
Check if gobAA is at the bottom of gobBB within threshold dist. |
static boolean |
atLeft(GraphicalObject gobAA,
GraphicalObject gobBB)
Uses the SatinConstants.DEFAULT_SELECT_THRESHOLD . |
static boolean |
atLeft(GraphicalObject gobAA,
GraphicalObject gobBB,
double thresh)
Check if gobAA is at the left of gobBB within threshold dist. |
static boolean |
atRight(GraphicalObject gobAA,
GraphicalObject gobBB)
Uses the SatinConstants.DEFAULT_SELECT_THRESHOLD . |
static boolean |
atRight(GraphicalObject gobAA,
GraphicalObject gobBB,
double thresh)
Check if gobAA is at the right of gobBB within threshold dist. |
static boolean |
atTop(GraphicalObject gobAA,
GraphicalObject gobBB)
Uses the SatinConstants.DEFAULT_SELECT_THRESHOLD . |
static boolean |
atTop(GraphicalObject gobAA,
GraphicalObject gobBB,
double thresh)
Check if gobAA is at the top of gobBB within threshold dist. |
static int |
compareLayers(GraphicalObject gobA,
GraphicalObject gobB)
|
static int |
compareLayers(String gobA,
String gobB)
Compare two GraphicalObject layers to see which one is higher. |
static boolean |
contains(GraphicalObject gob,
Shape s)
Determine if the Graphical Object contains the specified shape. |
static boolean |
contains(Shape s,
GraphicalObject gob)
Determine if the Shape contains the specified Graphical Object. |
static boolean |
contains(Shape sAA,
Shape sBB)
Determine if s1 contains s2. |
static GraphicalObjectCollection |
flatten(GraphicalObjectCollection gobcol)
Given a hierarchy of GraphicalObjects, flatten it into a single Collection (without modifying the original). |
static GraphicalObject |
getBottommostBranch(GraphicalObjectCollection gobcol)
|
static GraphicalObject |
getBottommostGraphicalObject(GraphicalObjectCollection gobcol)
In a GraphicalObjectCollection, get the GraphicalObject nearest to the bottom. |
static GraphicalObject |
getBottommostLeaf(GraphicalObjectCollection gobcol)
|
static Point2D |
getCenterOfMass(GraphicalObject gob)
|
static Point2D |
getCenterOfMass(GraphicalObject gob,
Point2D pt)
|
static Rectangle |
getRenderBounds(GraphicalObject gob)
Given a GraphicalObject, get the bounds for its damage region, that is the region that needs to be repainted. |
static double |
getScaleFactor(int cdsys,
GraphicalObject gob)
Get the scale factor of this Graphical Object. |
static GraphicalObject |
getTopmostBranch(GraphicalObjectCollection gobcol)
|
static GraphicalObject |
getTopmostGraphicalObject(GraphicalObjectCollection gobcol)
In a GraphicalObjectCollection, get the GraphicalObject nearest to the top. |
static GraphicalObject |
getTopmostLeaf(GraphicalObjectCollection gobcol)
|
static int |
getUniqueID()
Get a (mostly) unique ID, as long as the system is running. |
static boolean |
intersects(GraphicalObject gob,
Shape s)
Determine if the Graphical Object contains the specified shape. |
static boolean |
intersects(Shape s,
GraphicalObject gob)
Determine if the Shape contains the specified Graphical Object. |
static boolean |
intersects(Shape sAA,
Shape sBB)
Determine if s1 intersects s2. |
static boolean |
isAnimating()
Are we trying to animate or not? |
static Point2D |
localToAbsolute(GraphicalObject gob,
Point2D ptIn)
Convert a coordinate from local coordinates to absolute coordinates. |
static Point2D |
localToAbsolute(GraphicalObject gob,
Point2D ptIn,
Point2D ptReturn)
Convert a coordinate from local coordinates to absolute coordinates. |
static Rectangle2D |
localToAbsolute(GraphicalObject gob,
Rectangle2D rectIn)
Convert a rectangle from local coordinates to absolute coordinates. |
static void |
main(String[] argv)
|
static GraphicalObjectCollection |
removeGraphicalObjectGroups(GraphicalObjectCollection gobcol)
Given a GraphicalObjectCollection, remove references to all of the GraphicalObjectGroups (and thus Patches too). |
static void |
setAnimating(boolean flag)
Set whether we are we trying to animate or not. |
static void |
toLocalCoordinates(GraphicalObject gobMove,
GraphicalObject gobCoord)
Shift a Graphical Object from its current coordinate system to that of the other specified Graphical Object. |
static Point2D |
toLocalCoordinates(GraphicalObject gobSrc,
Point2D pt,
GraphicalObject gobDst)
Convert a point from one GraphicalObject's local coordinate system to another. |
static Point2D |
toLocalCoordinates(GraphicalObject gobSrc,
Point2D ptSrc,
GraphicalObject gobDst,
Point2D ptDst)
Convert a point from one GraphicalObject's local coordinate system to another. |
static Rectangle2D |
toLocalCoordinates(GraphicalObject gobSrc,
Rectangle2D rectSrc,
GraphicalObject gobDst)
|
static Rectangle2D |
toLocalCoordinates(GraphicalObject gobSrc,
Rectangle2D rectSrc,
GraphicalObject gobDst,
Rectangle2D rectDst)
Convert a rectangle from one coordinate system to another. |
static double |
weightAtBottom(GraphicalObject gobAA,
GraphicalObject gobBB)
|
static double |
weightAtLeft(GraphicalObject gobAA,
GraphicalObject gobBB)
|
static double |
weightAtRight(GraphicalObject gobAA,
GraphicalObject gobBB)
|
static double |
weightAtTop(GraphicalObject gobAA,
GraphicalObject gobBB)
Compare the center of masses of the two GraphicalObjects. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GraphicalObjectLib()
Method Detail |
public static final int getUniqueID()
public static final boolean isAnimating()
public static final void setAnimating(boolean flag)
public static void animate(GraphicalObject gob, AffineTransform[] txArray)
gob
- is the GraphicalObject to animate.txArray
- is the array of AffineTransforms to use for transforms.
Each transform should undo the previous transform, so
we can just iteratively call
GraphicalObject.applyTransform(AffineTransform)
.
The array of AffineTransforms can be generated by calling
AffineTransformLib.interpolate(AffineTransform,
AffineTransform, Interpolation, int)
.public static Rectangle getRenderBounds(GraphicalObject gob)
gob
- is the GraphicalObject whose rendering bounds we want.public static void toLocalCoordinates(GraphicalObject gobMove, GraphicalObject gobCoord)
gobMove
- is the Graphical Object whose coordinate system we want
to change.gobCoord
- is the Graphical Object to whose coordinate system we
want to move to.public static Point2D toLocalCoordinates(GraphicalObject gobSrc, Point2D pt, GraphicalObject gobDst)
gobSrc
- is the source coordinate system.ptSrc
- is the point in the source coordinate system.gobDst
- is the destination coordinate system.toLocalCoordinates(GraphicalObject, Point2D,
GraphicalObject, Point2D)
public static Point2D toLocalCoordinates(GraphicalObject gobSrc, Point2D ptSrc, GraphicalObject gobDst, Point2D ptDst)
gobSrc
- is the source coordinate system.ptSrc
- is the point in the source coordinate system.gobDst
- is the destination coordinate system.ptDst
- is storage for the point in the destination coordinate
system. Use null and new storage will be created.public static Rectangle2D toLocalCoordinates(GraphicalObject gobSrc, Rectangle2D rectSrc, GraphicalObject gobDst)
toLocalCoordinates(GraphicalObject, Rectangle2D,
GraphicalObject, Rectangle2D)
public static Rectangle2D toLocalCoordinates(GraphicalObject gobSrc, Rectangle2D rectSrc, GraphicalObject gobDst, Rectangle2D rectDst)
gobSrc
- is the source coordinate system.rectSrc
- is the rectangle in the source coordinate system.gobDst
- is the destination coordinate system.rectDst
- is storage for the rectangle in the destination
coordinate system. Use null and new storage will
be created.public static Point2D localToAbsolute(GraphicalObject gob, Point2D ptIn)
gob
- is the owner of the local coordinate system.ptIn
- is the point to convert.public static Point2D localToAbsolute(GraphicalObject gob, Point2D ptIn, Point2D ptReturn)
gob
- is the owner of the local coordinate system.ptIn
- is the point to convert.ptReturn
- is the space to return the answer in. This can be
the same as ptIn. Use null for new storage.public static Rectangle2D localToAbsolute(GraphicalObject gob, Rectangle2D rectIn)
gob
- is the owner of the local coordinate system.rectIn
- is the point to convert.public static Point2D absoluteToLocal(GraphicalObject gob, Point2D ptIn)
gob
- is the owner of the local coordinate system.ptIn
- is the point to convert.public static Point2D absoluteToLocal(GraphicalObject gob, Point2D ptIn, Point2D ptReturn)
gob
- is the owner of the local coordinate system.ptIn
- is the point to convert.ptReturn
- is the space to return the answer in. This can be the
same as ptIn.public static Rectangle2D absoluteToLocal(GraphicalObject gob, Rectangle2D rectIn)
gob
- is the owner of the local coordinate system.rectIn
- is the point to convert.public static double getScaleFactor(int cdsys, GraphicalObject gob)
public static final int compareLayers(GraphicalObject gobA, GraphicalObject gobB)
gobA
- is one GraphicalObject to compare.gobB
- is one GraphicalObject to compare.compareLayers(String, String)
public static final int compareLayers(String gobA, String gobB) throws NumberFormatException
1.2 is above 2.1.14 1.2 is above 1.3 1.1 is above 1 1.2.1 is above 1.2The first two cases are easy to check but the third and fourth are tricky.
strA
- is the absolute layer of one GraphicalObject.strA
- is the absolute layer of another GraphicalObject.NumberFormatException
- if the Strings are misformatted.public static final GraphicalObject getTopmostLeaf(GraphicalObjectCollection gobcol)
public static final GraphicalObject getBottommostLeaf(GraphicalObjectCollection gobcol)
public static final GraphicalObject getTopmostBranch(GraphicalObjectCollection gobcol)
public static final GraphicalObject getBottommostBranch(GraphicalObjectCollection gobcol)
public static final GraphicalObject getTopmostGraphicalObject(GraphicalObjectCollection gobcol)
gobcol
- is the GraphicalObjectCollection to iterate over.public static final GraphicalObject getBottommostGraphicalObject(GraphicalObjectCollection gobcol)
gobcol
- is the GraphicalObjectCollection to iterate over.public static final GraphicalObjectCollection flatten(GraphicalObjectCollection gobcol)
gobcol
- is the tree to flatten.public static final GraphicalObjectCollection removeGraphicalObjectGroups(GraphicalObjectCollection gobcol)
gobcol
- is the Collection to remove GObGroups from. gobcol is not
modified in any way.public static final Point2D getCenterOfMass(GraphicalObject gob)
public static final Point2D getCenterOfMass(GraphicalObject gob, Point2D pt)
public static final double weightAtTop(GraphicalObject gobAA, GraphicalObject gobBB)
gobAA
- center of mass is used as the force point.gobBB
- center of mass is used as the fulcrum.public static final double weightAtBottom(GraphicalObject gobAA, GraphicalObject gobBB)
public static final double weightAtRight(GraphicalObject gobAA, GraphicalObject gobBB)
public static final double weightAtLeft(GraphicalObject gobAA, GraphicalObject gobBB)
public static final boolean atTop(GraphicalObject gobAA, GraphicalObject gobBB)
SatinConstants.DEFAULT_SELECT_THRESHOLD
.atTop(GraphicalObject, GraphicalObject, double)
public static final boolean atTop(GraphicalObject gobAA, GraphicalObject gobBB, double thresh)
* gobAA * * gobBB * * * *
public static final boolean atBottom(GraphicalObject gobAA, GraphicalObject gobBB)
SatinConstants.DEFAULT_SELECT_THRESHOLD
.atBottom(GraphicalObject, GraphicalObject, double)
public static final boolean atBottom(GraphicalObject gobAA, GraphicalObject gobBB, double thresh)
* * * * gobBB * * gobAA *
public static final boolean atRight(GraphicalObject gobAA, GraphicalObject gobBB)
SatinConstants.DEFAULT_SELECT_THRESHOLD
.atRight(GraphicalObject, GraphicalObject, double)
public static final boolean atRight(GraphicalObject gobAA, GraphicalObject gobBB, double thresh)
* * * * gobBB gobAA * * *
public static final boolean atLeft(GraphicalObject gobAA, GraphicalObject gobBB)
SatinConstants.DEFAULT_SELECT_THRESHOLD
.atLeft(GraphicalObject, GraphicalObject, double)
public static final boolean atLeft(GraphicalObject gobAA, GraphicalObject gobBB, double thresh)
* * * gobAA gobBB * * * *
public static final boolean contains(Shape sAA, Shape sBB)
s1,s2
- are in the same coordinate system.public static final boolean contains(GraphicalObject gob, Shape s)
gob
- is the Graphical Object.s
- is in absolute coordinates.public static final boolean contains(Shape s, GraphicalObject gob)
public static final boolean intersects(Shape sAA, Shape sBB)
public static final boolean intersects(GraphicalObject gob, Shape s)
public static final boolean intersects(Shape s, GraphicalObject gob)
public static void main(String[] argv) throws Exception
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |