com.sun.electric.database.geometry
Class Poly

java.lang.Object
  extended by com.sun.electric.database.geometry.PolyBase
      extended by com.sun.electric.database.geometry.Poly
All Implemented Interfaces:
PolyNodeMerge, java.awt.Shape

public class Poly
extends PolyBase

Class to define a polygon of points.


Nested Class Summary
static class Poly.Builder
          This class builds shapes of nodes and arcs in lambda units as Poly arrays.
static class Poly.Type
          Type is a typesafe enum class that describes the nature of a Poly.
 
Nested classes/interfaces inherited from class com.sun.electric.database.geometry.PolyBase
PolyBase.PolyBaseTree
 
Field Summary
static Poly[] NULL_ARRAY
           
 
Fields inherited from class com.sun.electric.database.geometry.PolyBase
bounds, points, X, XY, Y, Z
 
Constructor Summary
Poly(double cX, double cY, double width, double height)
          The constructor creates a new Poly that describes a rectangle.
Poly(java.awt.geom.Point2D[] points)
          The constructor creates a new Poly given an array of points.
Poly(java.awt.geom.Rectangle2D rect)
          The constructor creates a new Poly that describes a rectangle.
 
Method Summary
 DisplayedText getDisplayedText()
          Method to return the DisplayedText associated with this Poly.
static double getExtendFactor(double width, int extend)
          Method to return the amount that an arc end should extend, given its width and extension factor.
 EGraphics getGraphicsOverride()
          Method to return the EGraphics which overrides default EGraphics for Poly's Layer.
 java.lang.String getString()
          Method to return the String associated with this Poly.
 TextDescriptor getTextDescriptor()
          Method to return the Text Descriptor associated with this Poly.
static Poly makeEndPointPoly(double len, double wid, int angle, java.awt.geom.Point2D endH, double extendH, java.awt.geom.Point2D endT, double extendT, Poly.Type style)
          Method to construct a Poly for an arc with a given length, width, angle, endpoint, and extension.
static Poly.Builder newGridBuilder()
          Returns new instance of Poly builder to build shapes in grid units.
static Poly.Builder newLambdaBuilder()
          Returns new instance of Poly builder to build shapes in lambda units.
 void setDisplayedText(DisplayedText dt)
          Method to set the DisplayedText associated with this Poly.
 boolean setExactTextBounds(EditWindow0 wnd, ElectricObject eObj)
          Method to convert text Polys to their precise bounds in a given window.
 void setGraphicsOverride(EGraphics graphics)
          Method to set the EGraphics which overrides default EGraphics for Poly's Layer.
 void setString(java.lang.String string)
          Method to set the String associated with this Poly.
 void setTextDescriptor(TextDescriptor descript)
          Method to set the Text Descriptor associated with this Poly.
static Poly.Builder threadLocalLambdaBuilder()
          Returns thread local instance of Poly builder to build shapes in lambda units.
 void transform(java.awt.geom.AffineTransform af)
          Method to transformed the points in this Poly.
 
Methods inherited from class com.sun.electric.database.geometry.PolyBase
clipArc, closestPoint, compare, contains, contains, contains, contains, cropBox, cropBoxComplete, getArea, getBounds, getBounds2D, getBox, getCenter, getCenterX, getCenterY, getLayer, getLayerOrPseudoLayer, getLoopsFromArea, getMaxLength, getMaxSize, getMinSize, getPathIterator, getPathIterator, getPerimeter, getPoints, getPointsInArea, getPolygon, getPolyTrees, getPort, getStyle, getTextScale, getTreesFromLoops, gridToLambda, halfCropBox, intersects, intersects, intersects, isInside, isInside, isPointOnCorner, isPseudoLayer, lambdaToGrid, makePoints, makePoints, polyDistance, polyDistance, polySame, reducePortPoly, rotateType, roundPoints, separation, separationBox, setLayer, setPoint, setPort, setStyle, unRotateType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_ARRAY

public static final Poly[] NULL_ARRAY
Constructor Detail

Poly

public Poly(java.awt.geom.Point2D[] points)
The constructor creates a new Poly given an array of points.

Parameters:
points - the array of coordinates.

Poly

public Poly(double cX,
            double cY,
            double width,
            double height)
The constructor creates a new Poly that describes a rectangle.

Parameters:
cX - the center X coordinate of the rectangle.
cY - the center Y coordinate of the rectangle.
width - the width of the rectangle.
height - the height of the rectangle.

Poly

public Poly(java.awt.geom.Rectangle2D rect)
The constructor creates a new Poly that describes a rectangle.

Parameters:
rect - the Rectangle2D of the rectangle.
Method Detail

getGraphicsOverride

public EGraphics getGraphicsOverride()
Method to return the EGraphics which overrides default EGraphics for Poly's Layer. If null, use default Layer's graphics.

Returns:
the String associated with this Poly.

setGraphicsOverride

public void setGraphicsOverride(EGraphics graphics)
Method to set the EGraphics which overrides default EGraphics for Poly's Layer. If null, use default Layer's graphics.

Parameters:
graphics - graphics override

getString

public java.lang.String getString()
Method to return the String associated with this Poly. This only applies to text Polys which display a message.

Returns:
the String associated with this Poly.

setString

public void setString(java.lang.String string)
Method to set the String associated with this Poly. This only applies to text Polys which display a message.

Parameters:
string - the String associated with this Poly.

getTextDescriptor

public TextDescriptor getTextDescriptor()
Method to return the Text Descriptor associated with this Poly. This only applies to text Polys which display a message. Only the size, face, italic, bold, and underline fields are relevant.

Returns:
the Text Descriptor associated with this Poly.

setTextDescriptor

public void setTextDescriptor(TextDescriptor descript)
Method to set the Text Descriptor associated with this Poly. This only applies to text Polys which display a message. Only the size, face, italic, bold, and underline fields are relevant.

Parameters:
descript - the Text Descriptor associated with this Poly.

getDisplayedText

public DisplayedText getDisplayedText()
Method to return the DisplayedText associated with this Poly. This only applies to text Polys which display a message.

Returns:
the DisplayedText associated with this Poly.

setDisplayedText

public void setDisplayedText(DisplayedText dt)
Method to set the DisplayedText associated with this Poly. This only applies to text Polys which display a message.

Parameters:
dt - the DisplayedText associated with this Poly.

transform

public void transform(java.awt.geom.AffineTransform af)
Method to transformed the points in this Poly.

Overrides:
transform in class PolyBase
Parameters:
af - transformation to apply.

getExtendFactor

public static double getExtendFactor(double width,
                                     int extend)
Method to return the amount that an arc end should extend, given its width and extension factor.

Parameters:
width - the width of the arc.
extend - the extension factor (from 0 to 90).
Returns:
the extension (from 0 to half of the width).

makeEndPointPoly

public static Poly makeEndPointPoly(double len,
                                    double wid,
                                    int angle,
                                    java.awt.geom.Point2D endH,
                                    double extendH,
                                    java.awt.geom.Point2D endT,
                                    double extendT,
                                    Poly.Type style)
Method to construct a Poly for an arc with a given length, width, angle, endpoint, and extension.

Parameters:
len - the length of the arc.
wid - the width of the arc.
angle - the angle of the arc.
endH - the head end of the arc.
extendH - the head end extension distance of the arc.
endT - the tail end of the arc.
extendT - the tail end extension distance of the arc.
style - the style of the polygon (filled, opened, etc.)
Returns:
a Poly describing the outline of the arc.

setExactTextBounds

public boolean setExactTextBounds(EditWindow0 wnd,
                                  ElectricObject eObj)
Method to convert text Polys to their precise bounds in a given window.

Parameters:
wnd - the window.
eObj - the ElectricObject on which this text resides. If that ElectricObject is a NodeInst and the node is rotated, it affects the text anchor point.
Returns:
true if the text is too small to display.

newLambdaBuilder

public static Poly.Builder newLambdaBuilder()
Returns new instance of Poly builder to build shapes in lambda units.

Returns:
new instance of Poly builder.

newGridBuilder

public static Poly.Builder newGridBuilder()
Returns new instance of Poly builder to build shapes in grid units.

Returns:
new instance of Poly builder.

threadLocalLambdaBuilder

public static Poly.Builder threadLocalLambdaBuilder()
Returns thread local instance of Poly builder to build shapes in lambda units.

Returns:
thread local instance of Poly builder.