Class Polyline2D

  • All Implemented Interfaces:
    java.awt.Shape
    Direct Known Subclasses:
    Polyline2D.Double, Polyline2D.Float

    public abstract class Polyline2D
    extends java.lang.Object
    implements java.awt.Shape
    A polyline shape. This class implements java.awt.Shape, and consists of a series of straight-line segments. This class should be used instead of GeneralPath for shapes that consist only of straight-line segments (and that are no closed). It is more efficient than GeneralPath, and allows the coordinates of vertices to be modified. Following the convention set by the Java2D shape classes, the Polyline class is an abstract class, which contains two concrete inner classes, one storing floats and one storing doubles.
    Version:
    $Id$
    Author:
    John Reekie
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Polyline2D.Double
      The concrete Polyline class that stores coordinates internally as doubles.
      static class  Polyline2D.Float
      The concrete Polyline class that stores coordinates internally as floats.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int _coordCount
      The current number of coordinates
    • Constructor Summary

      Constructors 
      Constructor Description
      Polyline2D()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(double x, double y)
      Return false.
      boolean contains​(double x, double y, double w, double h)
      Return false.
      boolean contains​(java.awt.geom.Point2D p)
      Return false.
      boolean contains​(java.awt.geom.Rectangle2D r)
      Return false.
      java.awt.Rectangle getBounds()
      Get the integer bounds of the polyline.
      abstract java.awt.geom.Rectangle2D getBounds2D()
      Get the floating-point bounds of the polyline.
      java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at)
      Get a path iterator over the object.
      java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at, double flatness)
      Get a path iterator over the object.
      int getVertexCount()
      Get the number of vertices
      abstract double getX​(int index)
      Get the given X-coordinate
      abstract double getY​(int index)
      Get the given Y-coordinate
      boolean intersects​(double x, double y, double w, double h)
      Test if the polyline is intersected by the given rectangle.
      boolean intersects​(java.awt.geom.Rectangle2D r)
      Test if the polyline is intersected by the given rectangle.
      abstract void lineTo​(double x, double y)
      Add a new vertex to the end of the line.
      abstract void moveTo​(double x, double y)
      Move the start point of the vertex to the given position.
      void reset()
      Reset the polyline back to empty.
      abstract void setX​(int index, double x)
      Set the given X-coordinate.
      abstract void setY​(int index, double y)
      Set the given Y-coordinate
      java.lang.String toString()
      Return a string representing this object
      abstract void transform​(java.awt.geom.AffineTransform at)
      Transform the polyline with the given transform.
      abstract void translate​(double x, double y)
      Translate the polyline the given distance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _coordCount

        protected int _coordCount
        The current number of coordinates
    • Constructor Detail

      • Polyline2D

        public Polyline2D()
    • Method Detail

      • contains

        public boolean contains​(double x,
                                double y)
        Return false. A line never contains any point.
        Specified by:
        contains in interface java.awt.Shape
      • contains

        public boolean contains​(java.awt.geom.Point2D p)
        Return false. A line never contains any point.
        Specified by:
        contains in interface java.awt.Shape
      • contains

        public boolean contains​(java.awt.geom.Rectangle2D r)
        Return false. A line never contains a rectangle.
        Specified by:
        contains in interface java.awt.Shape
      • contains

        public boolean contains​(double x,
                                double y,
                                double w,
                                double h)
        Return false. A line never contains a rectangle.
        Specified by:
        contains in interface java.awt.Shape
      • getBounds

        public java.awt.Rectangle getBounds()
        Get the integer bounds of the polyline.
        Specified by:
        getBounds in interface java.awt.Shape
      • getBounds2D

        public abstract java.awt.geom.Rectangle2D getBounds2D()
        Get the floating-point bounds of the polyline.
        Specified by:
        getBounds2D in interface java.awt.Shape
      • getPathIterator

        public java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at,
                                                          double flatness)
        Get a path iterator over the object.
        Specified by:
        getPathIterator in interface java.awt.Shape
      • getPathIterator

        public java.awt.geom.PathIterator getPathIterator​(java.awt.geom.AffineTransform at)
        Get a path iterator over the object.
        Specified by:
        getPathIterator in interface java.awt.Shape
      • getVertexCount

        public int getVertexCount()
        Get the number of vertices
      • getX

        public abstract double getX​(int index)
        Get the given X-coordinate
        Throws:
        java.lang.IndexOutOfBoundsException - The index is out of bounds.
      • getY

        public abstract double getY​(int index)
        Get the given Y-coordinate
        Throws:
        java.lang.IndexOutOfBoundsException - The index is out of bounds.
      • intersects

        public boolean intersects​(java.awt.geom.Rectangle2D r)
        Test if the polyline is intersected by the given rectangle.
        Specified by:
        intersects in interface java.awt.Shape
      • intersects

        public boolean intersects​(double x,
                                  double y,
                                  double w,
                                  double h)
        Test if the polyline is intersected by the given rectangle.
        Specified by:
        intersects in interface java.awt.Shape
      • lineTo

        public abstract void lineTo​(double x,
                                    double y)
        Add a new vertex to the end of the line.
      • moveTo

        public abstract void moveTo​(double x,
                                    double y)
        Move the start point of the vertex to the given position. Throw an exception if the line already contains any vertices.
      • reset

        public void reset()
        Reset the polyline back to empty.
      • setX

        public abstract void setX​(int index,
                                  double x)
        Set the given X-coordinate.
        Throws:
        java.lang.IndexOutOfBoundsException - The index is out of bounds.
      • setY

        public abstract void setY​(int index,
                                  double y)
        Set the given Y-coordinate
        Throws:
        java.lang.IndexOutOfBoundsException - The index is out of bounds.
      • toString

        public java.lang.String toString()
        Return a string representing this object
        Overrides:
        toString in class java.lang.Object
      • transform

        public abstract void transform​(java.awt.geom.AffineTransform at)
        Transform the polyline with the given transform.
      • translate

        public abstract void translate​(double x,
                                       double y)
        Translate the polyline the given distance.