All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class CH.ifa.draw.contrib.PolygonFigure

java.lang.Object
   |
   +----CH.ifa.draw.standard.AbstractFigure
           |
           +----CH.ifa.draw.figures.AttributeFigure
                   |
                   +----CH.ifa.draw.contrib.PolygonFigure

public class PolygonFigure
extends AttributeFigure
A scalable, rotatable polygon with an arbitrary number of points


Variable Index

 o fPoly

Constructor Index

 o PolygonFigure()
 o PolygonFigure(int, int)
 o PolygonFigure(Polygon)

Method Index

 o addPoint(int, int)
Adds a node to the list of points.
 o basicDisplayBox(Point, Point)
Sets the display box of a figure.
 o basicMoveBy(int, int)
Moves the figure.
 o bounds(Polygon)
replacement for builtin Polygon.getBounds that doesn't always update?
 o center()
Gets the center of a figure.
 o center(Polygon)
 o chop(Point)
 o chop(Polygon, Point)
 o connectorAt(int, int)
Returns the Figures connector for the specified location.
 o containsPoint(int, int)
Checks if a point is inside the figure.
 o displayBox()
Gets the display box of a figure.
 o distanceFromLine(int, int, int, int, int, int)
compute distance of point from line segment, or Double.MAX_VALUE if perpendicular projection is outside segment; or If pts on line are same, return distance from point
 o drawBackground(Graphics)
Draws the background of the figure.
 o drawFrame(Graphics)
Draws the frame of the figure.
 o findSegment(int, int)
Gets the segment that is hit by the given point.
 o getPolygon()
return a copy of the raw polygon
 o handles()
Returns the handles of a Figure that can be used to manipulate some of its attributes.
 o insertPointAt(Point, int)
Insert a node at the given point.
 o isEmpty()
Checks if the figure is empty.
 o locator(int)
Creates a locator for the point with the given index.
 o outermostPoint()
Return the point on the polygon that is furthest from the center
 o pointAt(int)
 o pointCount()
 o points()
 o read(StorableInput)
Reads the Figure from a StorableInput.
 o removePointAt(int)
 o scaleRotate(Point, Polygon, Point)
Scale and rotate relative to anchor
 o setPointAt(Point, int)
Changes the position of a node.
 o smoothPoints()
Remove points that are nearly colinear with others
 o splitSegment(int, int)
Splits the segment at the given point if a segment was hit.
 o write(StorableOutput)
Stores the Figure to a StorableOutput.

Variables

 o fPoly
 protected Polygon fPoly

Constructors

 o PolygonFigure
 public PolygonFigure()
 o PolygonFigure
 public PolygonFigure(int x,
                      int y)
 o PolygonFigure
 public PolygonFigure(Polygon p)

Methods

 o displayBox
 public Rectangle displayBox()
Gets the display box of a figure.

Overrides:
displayBox in class AbstractFigure
 o isEmpty
 public boolean isEmpty()
Checks if the figure is empty.

Overrides:
isEmpty in class AbstractFigure
 o handles
 public Vector handles()
Returns the handles of a Figure that can be used to manipulate some of its attributes.

Overrides:
handles in class AbstractFigure
 o basicDisplayBox
 public void basicDisplayBox(Point origin,
                             Point corner)
Sets the display box of a figure.

Overrides:
basicDisplayBox in class AbstractFigure
 o getPolygon
 public Polygon getPolygon()
return a copy of the raw polygon

 o center
 public Point center()
Gets the center of a figure.

Overrides:
center in class AbstractFigure
 o points
 public Enumeration points()
 o pointCount
 public int pointCount()
 o basicMoveBy
 public void basicMoveBy(int dx,
                         int dy)
Moves the figure.

Overrides:
basicMoveBy in class AbstractFigure
 o drawBackground
 public void drawBackground(Graphics g)
Draws the background of the figure.

Overrides:
drawBackground in class AttributeFigure
 o drawFrame
 public void drawFrame(Graphics g)
Draws the frame of the figure.

Overrides:
drawFrame in class AttributeFigure
 o containsPoint
 public boolean containsPoint(int x,
                              int y)
Checks if a point is inside the figure.

Overrides:
containsPoint in class AbstractFigure
 o connectorAt
 public Connector connectorAt(int x,
                              int y)
Returns the Figures connector for the specified location.

Overrides:
connectorAt in class AbstractFigure
 o addPoint
 public void addPoint(int x,
                      int y)
Adds a node to the list of points.

 o setPointAt
 public void setPointAt(Point p,
                        int i)
Changes the position of a node.

 o insertPointAt
 public void insertPointAt(Point p,
                           int i)
Insert a node at the given point.

 o removePointAt
 public void removePointAt(int i)
 o scaleRotate
 public void scaleRotate(Point anchor,
                         Polygon originalPolygon,
                         Point p)
Scale and rotate relative to anchor

 o smoothPoints
 public void smoothPoints()
Remove points that are nearly colinear with others

 o splitSegment
 public int splitSegment(int x,
                         int y)
Splits the segment at the given point if a segment was hit.

Returns:
the index of the segment or -1 if no segment was hit.
 o pointAt
 public Point pointAt(int i)
 o outermostPoint
 public Point outermostPoint()
Return the point on the polygon that is furthest from the center

 o findSegment
 public int findSegment(int x,
                        int y)
Gets the segment that is hit by the given point.

Returns:
the index of the segment or -1 if no segment was hit.
 o chop
 public Point chop(Point p)
 o write
 public void write(StorableOutput dw)
Stores the Figure to a StorableOutput.

Overrides:
write in class AttributeFigure
 o read
 public void read(StorableInput dr) throws IOException
Reads the Figure from a StorableInput.

Overrides:
read in class AttributeFigure
 o locator
 public static Locator locator(int pointIndex)
Creates a locator for the point with the given index.

 o distanceFromLine
 public static double distanceFromLine(int xa,
                                       int ya,
                                       int xb,
                                       int yb,
                                       int xc,
                                       int yc)
compute distance of point from line segment, or Double.MAX_VALUE if perpendicular projection is outside segment; or If pts on line are same, return distance from point

 o bounds
 public static Rectangle bounds(Polygon p)
replacement for builtin Polygon.getBounds that doesn't always update?

 o center
 public static Point center(Polygon p)
 o chop
 public static Point chop(Polygon poly,
                          Point p)

All Packages  Class Hierarchy  This Package  Previous  Next  Index