Documentation of 'CH.ifa.draw.contrib.PolygonFigure' Java class
PolygonFigure
CH.ifa.draw.contrib

Class PolygonFigure

  • All Implemented Interfaces:
    Figure, Storable, java.io.Serializable, java.lang.Cloneable


    public class PolygonFigure
    extends AttributeFigure
    A scalable, rotatable polygon with an arbitrary number of points
    See Also:
    Serialized Form
    • Constructor Detail

      • PolygonFigure

        public PolygonFigure()
      • PolygonFigure

        public PolygonFigure(int x,
                             int y)
      • PolygonFigure

        public PolygonFigure(java.awt.Polygon p)
    • Method Detail

      • handles

        public java.util.Vector handles()
        Description copied from class: AbstractFigure
        Returns the handles of a Figure that can be used to manipulate some of its attributes.
        Specified by:
        handles in interface Figure
        Specified by:
        handles in class AbstractFigure
        Returns:
        a Vector of handles
        See Also:
        Handle
      • getPolygon

        public java.awt.Polygon getPolygon()
        return a copy of the raw polygon
      • center

        public java.awt.Point center()
        Description copied from class: AbstractFigure
        Gets the center of a figure. A convenice method that is rarely overridden.
        Specified by:
        center in interface Figure
        Overrides:
        center in class AbstractFigure
      • points

        public java.util.Enumeration points()
      • pointCount

        public int pointCount()
      • basicMoveBy

        public void basicMoveBy(int dx,
                                int dy)
        Description copied from class: AbstractFigure
        Moves the figure. This is the method that subclassers override. Clients usually call displayBox.
        See Also:
        AbstractFigure.moveBy(int, int)
      • addPoint

        public void addPoint(int x,
                             int y)
        Adds a node to the list of points.
      • setPointAt

        public void setPointAt(java.awt.Point p,
                               int i)
        Changes the position of a node.
      • insertPointAt

        public void insertPointAt(java.awt.Point p,
                                  int i)
        Insert a node at the given point.
      • removePointAt

        public void removePointAt(int i)
      • scaleRotate

        public void scaleRotate(java.awt.Point anchor,
                                java.awt.Polygon originalPolygon,
                                java.awt.Point p)
        Scale and rotate relative to anchor
      • smoothPoints

        public void smoothPoints()
        Remove points that are nearly colinear with others
      • 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.
      • pointAt

        public java.awt.Point pointAt(int i)
      • outermostPoint

        public java.awt.Point outermostPoint()
        Return the point on the polygon that is furthest from the center
      • 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.
      • chop

        public java.awt.Point chop(java.awt.Point p)
      • locator

        public static Locator locator(int pointIndex)
        Creates a locator for the point with the given index.
      • 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
      • bounds

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

        public static java.awt.Point center(java.awt.Polygon p)
      • chop

        public static java.awt.Point chop(java.awt.Polygon poly,
                                          java.awt.Point p)

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.