com.sun.electric.database.geometry
Class Orientation

java.lang.Object
  extended by com.sun.electric.database.geometry.Orientation
All Implemented Interfaces:
java.io.Serializable

public class Orientation
extends java.lang.Object
implements java.io.Serializable

Class 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.

See Also:
Serialized Form

Field Summary
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
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENT

public static final Orientation IDENT
Identical Orientation


R

public static final Orientation R

RR

public static final Orientation RR

RRR

public static final Orientation RRR

X

public static final Orientation X

XR

public static final Orientation XR

XRR

public static final Orientation XRR

XRRR

public static final Orientation XRRR

Y

public static final Orientation Y

YR

public static final Orientation YR

YRR

public static final Orientation YRR

YRRR

public static final Orientation YRRR

XY

public static final Orientation XY

XYR

public static final Orientation XYR

XYRR

public static final Orientation XYRR

XYRRR

public static final Orientation XYRRR
Method Detail

fromJava

public static Orientation fromJava(int jAngle,
                                   boolean jMirrorX,
                                   boolean jMirrorY)
Get Orientation by the new Java style parameters.

Parameters:
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).
Returns:
the Orientation.

fromC

public static Orientation fromC(int cAngle,
                                boolean cTranspose)
Get Orientation by the old C style parameters.

Parameters:
cAngle - the angle of rotation (in tenth-degrees)
cTranspose - if true, object is flipped over the major diagonal after rotation.
Returns:
the Orientation.

fromAngle

public static Orientation fromAngle(int angle)
Get Orientation by the angle without mirrors.

Parameters:
angle - the angle of rotation (in tenth-degrees)
Returns:
the Orientation.

inverse

public Orientation inverse()
Return inverse Orientation to this Orientation.

Returns:
inverse Orientation.

canonic

public Orientation canonic()
Return canonic Orientation to this Orientation.

Returns:
canonic Orientation.

concatenate

public Orientation concatenate(Orientation that)
Concatenates this Orientation with other Orientation. In matrix notation returns this * that.

Parameters:
that - other Orienation.
Returns:
concatenation of this and other Orientations.

getCAngle

public int getCAngle()
Method to return the old C style angle value.

Returns:
the old C style angle value, in tenth-degrees.

isCTranspose

public boolean isCTranspose()
Method to return the old C style transpose factor.

Returns:
the old C style transpose factor: true to flip over the major diagonal after rotation.

getAngle

public int getAngle()
Method to return the new Java style angle value.

Returns:
the new Java style angle value, in tenth-degrees.

isXMirrored

public boolean isXMirrored()
Method to return the new Java style Mirror X factor.

Returns:
true to flip over the vertical axis (mirror in X).

isYMirrored

public boolean isYMirrored()
Method to return the new Java style Mirror Y factor.

Returns:
true to flip over the horizontal axis (mirror in Y).

isManhattan

public boolean isManhattan()
Returns true if orientation is one of Manhattan orientations.

Returns:
true if orientation is one of Manhattan orientations.

pureRotate

public java.awt.geom.AffineTransform pureRotate()
Method to return a transformation that rotates an object.

Returns:
a transformation that rotates by this Orinetation.

rotateAbout

public java.awt.geom.AffineTransform rotateAbout(java.awt.geom.Point2D c)
Method to return a transformation that rotates an object about a point.

Parameters:
c - the center point about which to rotate.
Returns:
a transformation that rotates about that point.

rotateAbout

public java.awt.geom.AffineTransform rotateAbout(double cX,
                                                 double cY)
Method to return a transformation that rotates an object about a point.

Parameters:
cX - the center X coordinate about which to rotate.
cY - the center Y coordinate about which to rotate.
Returns:
a transformation that rotates about that point.

rotateAbout

public 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.

Parameters:
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.
Returns:
a transformation that rotates about that point.

transformAngle

public int transformAngle(int angle)
Method to transform direction by the Orientation.

Parameters:
angle - the angle of initial direction in tenth-degrees.
Returns:
angle of transformed direction in tenth-degrees.

transformPoints

public void transformPoints(int numPoints,
                            int[] coords)
Calculate bounds of rectangle transformed by this Orientation.

Parameters:
numPoints -
coords - coordinates x, y of points.

rectangleBounds

public 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.

Parameters:
xl - lower x coordinate.
yl - lower y coordinate.
xh - higher x coordinate.
yh - higher y coordinate.
cx - additional x shift
cy - additional y shift.
dst - destination rectangle.

rectangleBounds

public void rectangleBounds(int[] coords)
Calculate bounds of rectangle transformed by this Orientation.

Parameters:
coords - coordinates xl, yl, xh, yh.

toJelibString

public java.lang.String toJelibString()
Returns string which represents this Orientation in JELIB format.

Returns:
string in JELIB format.

toString

public java.lang.String toString()
Returns text representation of this Orientation.

Overrides:
toString in class java.lang.Object
Returns:
text representation of this Orintation.