Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.batik.ext.awt.geom
Class Polyline2D

    java.lang.Object
      org.apache.batik.ext.awt.geom.Polyline2D

All Implemented Interfaces:
  Shape, Serializable, Cloneable

    public class Polyline2D

extends Object
implements Shape, Cloneable, Serializable

This class has the same behavior than `Polygon2D`, except that the figure is not closed.

See Also:
  Serialized Form

Field Summary
`protected Rectangle2D` | `bounds` Bounds of the Polyline2D.
`int` | `npoints` The total number of points.
`float[]` | `xpoints` The array of x coordinates.
`float[]` | `ypoints` The array of x coordinates.

Constructor Summary
`Polyline2D()` Creates an empty Polyline2D.
`Polyline2D(float[] xpoints, float[] ypoints, int npoints)` Constructs and initializes a `Polyline2D` from the specified parameters.
`Polyline2D(int[] xpoints, int[] ypoints, int npoints)` Constructs and initializes a `Polyline2D` from the specified parameters.
`Polyline2D(Line2D line)`

Method Summary
`void` | `addPoint(float x, float y)` Appends the specified coordinates to this `Polyline2D`.
`void` | `addPoint(Point2D p)`
`Object` | `clone()`
`boolean` | `contains(double x, double y)` Determines if the specified coordinates are inside this `Polyline2D`.
`boolean` | `contains(double x, double y, double w, double h)` Tests if the interior of this `Polyline2D` entirely contains the specified set of rectangular coordinates.
`boolean` | `contains(int x, int y)` Determines whether the specified coordinates are inside this `Polyline2D`.
`boolean` | `contains(Point p)` Determines whether the specified `Point` is inside this `Polyline2D`.
`boolean` | `contains(Point2D p)` Tests if a specified `Point2D` is inside the boundary of this `Polyline2D`.
`boolean` | `contains(Rectangle2D r)` Tests if the interior of this `Polyline2D` entirely contains the specified `Rectangle2D`.
`Rectangle` | `getBounds()` Gets the bounding box of this `Polyline2D`.
`Rectangle2D` | `getBounds2D()` Returns the high precision bounding box of the `Shape`.
`PathIterator` | `getPathIterator(AffineTransform at)` Returns an iterator object that iterates along the boundary of this `Polygon` and provides access to the geometry of the outline of this `Polygon`.
`PathIterator` | `getPathIterator(AffineTransform at, double flatness)` Returns an iterator object that iterates along the boundary of the `Shape` and provides access to the geometry of the outline of the `Shape`.
`Polygon2D` | `getPolygon2D()`
`boolean` | `intersects(double x, double y, double w, double h)` Tests if the interior of this `Polygon` intersects the interior of a specified set of rectangular coordinates.
`boolean` | `intersects(Rectangle2D r)` Tests if the interior of this `Polygon` intersects the interior of a specified `Rectangle2D`.
`void` | `reset()` Resets this `Polyline2D` object to an empty polygon.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### npoints

    public int npoints

  The total number of points. The value of `npoints` represents the number of points in this `Polyline2D`.

### xpoints

    public float[] xpoints

  The array of x coordinates. The value of `npoints` is equal to the number of points in this `Polyline2D`.

### ypoints

    public float[] ypoints

  The array of x coordinates. The value of `npoints` is equal to the number of points in this `Polyline2D`.

### bounds

    protected Rectangle2D bounds

  Bounds of the Polyline2D.

  See Also:
    `getBounds()`

Constructor Detail

### Polyline2D

    public Polyline2D()

  Creates an empty Polyline2D.

### Polyline2D

    public Polyline2D(float[] xpoints,
                      float[] ypoints,
                      int npoints)

  Constructs and initializes a `Polyline2D` from the specified parameters.

  Parameters:
    `xpoints` - an array of x coordinates
    `ypoints` - an array of y coordinates
    `npoints` - the total number of points in the `Polyline2D`
  Throws:
    `NegativeArraySizeException` - if the value of `npoints` is negative.
    `IndexOutOfBoundsException` - if `npoints` is greater than the length of `xpoints` or the length of `ypoints`.
    `NullPointerException` - if `xpoints` or `ypoints` is `null`.

### Polyline2D

    public Polyline2D(int[] xpoints,
                      int[] ypoints,
                      int npoints)

  Constructs and initializes a `Polyline2D` from the specified parameters.

  Parameters:
    `xpoints` - an array of x coordinates
    `ypoints` - an array of y coordinates
    `npoints` - the total number of points in the `Polyline2D`
  Throws:
    `NegativeArraySizeException` - if the value of `npoints` is negative.
    `IndexOutOfBoundsException` - if `npoints` is greater than the length of `xpoints` or the length of `ypoints`.
    `NullPointerException` - if `xpoints` or `ypoints` is `null`.

### Polyline2D

    public Polyline2D(Line2D line)

Method Detail

### reset

    public void reset()

  Resets this `Polyline2D` object to an empty polygon. The coordinate arrays and the data in them are left untouched but the number of points is reset to zero to mark the old vertex data as invalid and to start accumulating new vertex data at the beginning. All internally-cached data relating to the old vertices are discarded. Note that since the coordinate arrays from before the reset are reused, creating a new empty `Polyline2D` might be more memory efficient than resetting the current one if the number of vertices in the new polyline data is significantly smaller than the number of vertices in the data from before the reset.

### clone

    public Object clone()

  Overrides:
    `clone` in class `Object`

### addPoint

    public void addPoint(Point2D p)

### addPoint

    public void addPoint(float x,
                         float y)

  Appends the specified coordinates to this `Polyline2D`.

  If an operation that calculates the bounding box of this `Polyline2D` has already been performed, such as `getBounds` or `contains`, then this method updates the bounding box.

  Parameters:
    `x` - the specified x coordinate
    `y` - the specified y coordinate
  See Also:
    `Polygon.getBounds()`, `Polygon.contains(double,double)`

### getBounds

    public Rectangle getBounds()

  Gets the bounding box of this `Polyline2D`. The bounding box is the smallest `Rectangle` whose sides are parallel to the x and y axes of the coordinate space, and can completely contain the `Polyline2D`.

  Specified by:
    `getBounds` in interface `Shape`
  Returns:
    a `Rectangle` that defines the bounds of this `Polyline2D`.

### contains

    public boolean contains(Point p)

  Determines whether the specified `Point` is inside this `Polyline2D`. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

### contains

    public boolean contains(double x,
                            double y)

  Determines if the specified coordinates are inside this `Polyline2D`. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

  Specified by:
    `contains` in interface `Shape`

### contains

    public boolean contains(int x,
                            int y)

  Determines whether the specified coordinates are inside this `Polyline2D`. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

### getBounds2D

    public Rectangle2D getBounds2D()

  Returns the high precision bounding box of the `Shape`.

  Specified by:
    `getBounds2D` in interface `Shape`
  Returns:
    a `Rectangle2D` that precisely bounds the `Shape`.

### contains

    public boolean contains(Point2D p)

  Tests if a specified `Point2D` is inside the boundary of this `Polyline2D`. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

  Specified by:
    `contains` in interface `Shape`

### intersects

    public boolean intersects(double x,
                              double y,
                              double w,
                              double h)

  Tests if the interior of this `Polygon` intersects the interior of a specified set of rectangular coordinates.

  Specified by:
    `intersects` in interface `Shape`
  Parameters:
    `x` - the x coordinate of the specified rectangular shape's top-left corner
    `y` - the y coordinate of the specified rectangular shape's top-left corner
    `w` - the width of the specified rectangular shape
    `h` - the height of the specified rectangular shape
  Returns:
    `true` if the interior of this `Polygon` and the interior of the specified set of rectangular coordinates intersect each other; `false` otherwise.

### intersects

    public boolean intersects(Rectangle2D r)

  Tests if the interior of this `Polygon` intersects the interior of a specified `Rectangle2D`.

  Specified by:
    `intersects` in interface `Shape`
  Parameters:
    `r` - a specified `Rectangle2D`
  Returns:
    `true` if this `Polygon` and the interior of the specified `Rectangle2D` intersect each other; `false` otherwise.

### contains

    public boolean contains(double x,
                            double y,
                            double w,
                            double h)

  Tests if the interior of this `Polyline2D` entirely contains the specified set of rectangular coordinates. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

  Specified by:
    `contains` in interface `Shape`

### contains

    public boolean contains(Rectangle2D r)

  Tests if the interior of this `Polyline2D` entirely contains the specified `Rectangle2D`. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

  Specified by:
    `contains` in interface `Shape`

### getPathIterator

    public PathIterator getPathIterator(AffineTransform at)

  Returns an iterator object that iterates along the boundary of this `Polygon` and provides access to the geometry of the outline of this `Polygon`. An optional `AffineTransform` can be specified so that the coordinates returned in the iteration are transformed accordingly.

  Specified by:
    `getPathIterator` in interface `Shape`
  Parameters:
    `at` - an optional `AffineTransform` to be applied to the coordinates as they are returned in the iteration, or `null` if untransformed coordinates are desired
  Returns:
    a `PathIterator` object that provides access to the geometry of this `Polygon`.

### getPolygon2D

    public Polygon2D getPolygon2D()

### getPathIterator

    public PathIterator getPathIterator(AffineTransform at,
                                        double flatness)

  Returns an iterator object that iterates along the boundary of the `Shape` and provides access to the geometry of the outline of the `Shape`. Only SEG_MOVETO and SEG_LINETO, point types are returned by the iterator. Since polylines are already flat, the `flatness` parameter is ignored.

  Specified by:
    `getPathIterator` in interface `Shape`
  Parameters:
    `at` - an optional `AffineTransform` to be applied to the coordinates as they are returned in the iteration, or `null` if untransformed coordinates are desired
    `flatness` - the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the endpoints. Since polygons are already flat the `flatness` parameter is ignored.
  Returns:
    a `PathIterator` object that provides access to the `Shape` object's geometry.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Apache Software Foundation. All Rights Reserved.