public class Orientation
extends java.lang.Object
implements java.io.Serializable
Orientation
represents 2D affine transform which is composition of rotation and possible flip.
The C code used an angle (in tenth-degrees) and a "transpose" factor
which would flip the object along the major diagonal after rotation.
The Java code uses the same angle (in tenth-degrees) but has two mirror
options: Mirror X and Mirror Y.Modifier and Type | Field and Description |
---|---|
static Orientation |
IDENT
Identical Orientation
|
static Orientation |
R |
static Orientation |
RR |
static Orientation |
RRR |
static Orientation |
X |
static Orientation |
XR |
static Orientation |
XRR |
static Orientation |
XRRR |
static Orientation |
XY |
static Orientation |
XYR |
static Orientation |
XYRR |
static Orientation |
XYRRR |
static Orientation |
Y |
static Orientation |
YR |
static Orientation |
YRR |
static Orientation |
YRRR |
Modifier and Type | Method and Description |
---|---|
Orientation |
canonic()
Return canonic Orientation to this Orientation.
|
Orientation |
concatenate(Orientation that)
Concatenates this Orientation with other Orientation.
|
static Orientation |
fromAngle(int angle)
Get Orientation by the angle without mirrors.
|
static Orientation |
fromC(int cAngle,
boolean cTranspose)
Get Orientation by the old C style parameters.
|
static Orientation |
fromJava(int jAngle,
boolean jMirrorX,
boolean jMirrorY)
Get Orientation by the new Java style parameters.
|
int |
getAngle()
Method to return the new Java style angle value.
|
int |
getCAngle()
Method to return the old C style angle value.
|
Orientation |
inverse()
Return inverse Orientation to this Orientation.
|
boolean |
isCTranspose()
Method to return the old C style transpose factor.
|
boolean |
isManhattan()
Returns true if orientation is one of Manhattan orientations.
|
boolean |
isXMirrored()
Method to return the new Java style Mirror X factor.
|
boolean |
isYMirrored()
Method to return the new Java style Mirror Y factor.
|
java.awt.geom.AffineTransform |
pureRotate()
Method to return a transformation that rotates an object.
|
void |
rectangleBounds(double xl,
double yl,
double xh,
double yh,
double cx,
double cy,
java.awt.geom.Rectangle2D dst)
Calculate bounds of rectangle transformed by this Orientation.
|
void |
rectangleBounds(int[] coords)
Calculate bounds of rectangle transformed by this Orientation.
|
java.awt.geom.AffineTransform |
rotateAbout(double cX,
double cY)
Method to return a transformation that rotates an object about a point.
|
java.awt.geom.AffineTransform |
rotateAbout(double aX,
double aY,
double bX,
double bY)
Method to return a transformation that translate an object then rotates
and the again translates.
|
java.awt.geom.AffineTransform |
rotateAbout(java.awt.geom.Point2D c)
Method to return a transformation that rotates an object about a point.
|
java.lang.String |
toJelibString()
Returns string which represents this Orientation in JELIB format.
|
java.lang.String |
toString()
Returns text representation of this Orientation.
|
int |
transformAngle(int angle)
Method to transform direction by the Orientation.
|
void |
transformPoints(int numPoints,
int[] coords)
Calculate bounds of rectangle transformed by this Orientation.
|
public static final Orientation IDENT
public static final Orientation R
public static final Orientation RR
public static final Orientation RRR
public static final Orientation X
public static final Orientation XR
public static final Orientation XRR
public static final Orientation XRRR
public static final Orientation Y
public static final Orientation YR
public static final Orientation YRR
public static final Orientation YRRR
public static final Orientation XY
public static final Orientation XYR
public static final Orientation XYRR
public static final Orientation XYRRR
public static Orientation fromJava(int jAngle, boolean jMirrorX, boolean jMirrorY)
jAngle
- the angle of rotation (in tenth-degrees)jMirrorX
- if true, object is flipped over the vertical (mirror in X).jMirrorY
- if true, object is flipped over the horizontal (mirror in Y).public static Orientation fromC(int cAngle, boolean cTranspose)
cAngle
- the angle of rotation (in tenth-degrees)cTranspose
- if true, object is flipped over the major diagonal after rotation.public static Orientation fromAngle(int angle)
angle
- the angle of rotation (in tenth-degrees)public Orientation inverse()
public Orientation canonic()
public Orientation concatenate(Orientation that)
that
- other Orienation.public int getCAngle()
public boolean isCTranspose()
public int getAngle()
public boolean isXMirrored()
public boolean isYMirrored()
public boolean isManhattan()
public java.awt.geom.AffineTransform pureRotate()
public java.awt.geom.AffineTransform rotateAbout(java.awt.geom.Point2D c)
c
- the center point about which to rotate.public java.awt.geom.AffineTransform rotateAbout(double cX, double cY)
cX
- the center X coordinate about which to rotate.cY
- the center Y coordinate about which to rotate.public java.awt.geom.AffineTransform rotateAbout(double aX, double aY, double bX, double bY)
aX
- the center X coordinate to translate after rotation.aY
- the center Y coordinate to translate afrer rotation.bX
- the center X coordinate to translate before rotation.bY
- the center Y coordinate to translate before rotation.public int transformAngle(int angle)
angle
- the angle of initial direction in tenth-degrees.public void transformPoints(int numPoints, int[] coords)
numPoints
- coords
- coordinates x, y of points.public void rectangleBounds(double xl, double yl, double xh, double yh, double cx, double cy, java.awt.geom.Rectangle2D dst)
xl
- lower x coordinate.yl
- lower y coordinate.xh
- higher x coordinate.yh
- higher y coordinate.cx
- additional x shiftcy
- additional y shift.dst
- destination rectangle.public void rectangleBounds(int[] coords)
coords
- coordinates xl, yl, xh, yh.public java.lang.String toJelibString()
public java.lang.String toString()
toString
in class java.lang.Object