org.geotoolkit.display.shape
Class Arrow2D

Object
  extended by RectangularShape
      extended by Arrow2D
All Implemented Interfaces:
Shape, Serializable, Cloneable

public class Arrow2D
extends RectangularShape
implements Serializable

Arrow oriented toward positives x values (0° arithmetic). This shape doesn't have direct support for rotation. To rotate the arrow toward an other direction, use AffineTransform. See also the example documented in the TransformedShape class.

The following picture shows the default Arrow2D appearance. The relative size of the tail can be modified by setTailProportion(double, double, double).

Since:
1.0
Version:
3.00
Author:
Martin Desruisseaux (MPO, IRD)
See Also:
Serialized Form
Module:
display/geotk-display (download)    View source code for this class

Constructor Summary
Arrow2D()
          Creates a new arrow with a null surface.
Arrow2D(double x, double y, double width, double height)
          Creates new arrow in the specified frame.
 
Method Summary
 boolean contains(double x, double y)
          Tests if the specified point is inside this shape.
 boolean contains(double x, double y, double width, double height)
          Tests if the interior of this arrow entirely contains the specified rectangle.
 boolean equals(Object object)
          Compares this arrow with the specified object for equality.
 Rectangle2D getBounds2D()
          Returns the bounding box for this arrow.
 double getHeight()
          Returns the height of the smallest bounding box that contains fully this arrow.
 double getHeight(double x)
          Returns the arrow height at the given x ordinate.
 PathIterator getPathIterator(AffineTransform at)
          Returns an iterator for this arrow.
 PathIterator getPathIterator(AffineTransform at, double flatness)
          Returns an iterator for this arrow.
 double getTailLength()
          Returns the length of the arrow's tail.
 double getWidth()
          Returns the width of the smallest bounding box that contains fully this arrow.
 double getX()
          Returns the minimal x coordinate of the smallest bounding box that contains fully this arrow.
 double getY()
          Returns the minimal y coordinate of the smallest bounding box that contains fully this arrow.
 int hashCode()
          Returns a hash value for this arrow.
 boolean intersects(double x, double y, double width, double height)
          Tests if the interior of this arrow intersects the interior of the specified rectangle.
 boolean isEmpty()
          Determines whether the arrow is empty.
 void setFrame(double x, double y, double width, double height)
          Sets the location and size of the framing rectangle of this arrow to the specified rectangular values.
 void setTailProportion(double sx, double sy1, double sy0)
          Sets the tail width and height, relative to the arrow width and height.
 
Methods inherited from class RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Arrow2D

public Arrow2D()
Creates a new arrow with a null surface.


Arrow2D

public Arrow2D(double x,
               double y,
               double width,
               double height)
Creates new arrow in the specified frame.

Parameters:
x - Minimal x value.
y - Minimal y value.
width - The length in x direction.
height - The length in y direction.
Method Detail

setTailProportion

public void setTailProportion(double sx,
                              double sy1,
                              double sy0)
Sets the tail width and height, relative to the arrow width and height. All given number must be in the [0 … 1] range.

Parameters:
sx - The position where the arrow's head starts, relative to the total arrow's width.
sy1 - The height of the arrow's tail at the position where the head start (sx), relative to the arrow's height.
sy0 - The height of the arrow's tail at the leftmore position, relative to the arrow's height.

getTailLength

public double getTailLength()
Returns the length of the arrow's tail. This length is measured along the x axis.

Returns:
The length of the arrow's tail.

getX

public double getX()
Returns the minimal x coordinate of the smallest bounding box that contains fully this arrow.

Specified by:
getX in class RectangularShape

getY

public double getY()
Returns the minimal y coordinate of the smallest bounding box that contains fully this arrow.

Specified by:
getY in class RectangularShape

getWidth

public double getWidth()
Returns the width of the smallest bounding box that contains fully this arrow.

Specified by:
getWidth in class RectangularShape

getHeight

public double getHeight()
Returns the height of the smallest bounding box that contains fully this arrow.

Specified by:
getHeight in class RectangularShape

getHeight

public double getHeight(double x)
Returns the arrow height at the given x ordinate. If the given position is not between getMinX() and getMaxX(), then this method returns 0.

Parameters:
x - Ordinate x where to get the arrow height.
Returns:
The arrow height at the given x ordinate, as a number between 0 and getHeight().

isEmpty

public boolean isEmpty()
Determines whether the arrow is empty.

Specified by:
isEmpty in class RectangularShape

setFrame

public void setFrame(double x,
                     double y,
                     double width,
                     double height)
Sets the location and size of the framing rectangle of this arrow to the specified rectangular values.

Specified by:
setFrame in class RectangularShape
Parameters:
x - The minimal x value.
y - The minimal y value.
width - The length in x direction.
height - The length in y direction.

getBounds2D

public Rectangle2D getBounds2D()
Returns the bounding box for this arrow. This is the smallest rectangle that contains fully this arrow.

Specified by:
getBounds2D in interface Shape

contains

public boolean contains(double x,
                        double y)
Tests if the specified point is inside this shape.

Specified by:
contains in interface Shape
Parameters:
x - The x coordinate to test.
y - The y coordinate to test.

contains

public boolean contains(double x,
                        double y,
                        double width,
                        double height)
Tests if the interior of this arrow entirely contains the specified rectangle.

Specified by:
contains in interface Shape
Parameters:
x - The minimal x value.
y - The minimal y value.
width - The rectangle width.
height - The rectangle height.
Returns:
true if the interior of this arrow contains the rectangle.

intersects

public boolean intersects(double x,
                          double y,
                          double width,
                          double height)
Tests if the interior of this arrow intersects the interior of the specified rectangle.

Specified by:
intersects in interface Shape
Parameters:
x - The minimal x value.
y - The minimal y value.
width - The rectangle width.
height - The rectangle height.
Returns:
true if the interior of this arrow intersects the interior of the rectangle.

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Returns an iterator for this arrow. Because this shape is made only of straight segments, this method ignores the flatness argument and delegates to getPathIterator(at)

Specified by:
getPathIterator in interface Shape
Overrides:
getPathIterator in class RectangularShape
Parameters:
at - An optional affine transform to apply, or null if none.

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Returns an iterator for this arrow.

Specified by:
getPathIterator in interface Shape
Parameters:
at - An optional affine transform to apply, or null if none.

equals

public boolean equals(Object object)
Compares this arrow with the specified object for equality.

Overrides:
equals in class Object
Parameters:
object - The object to compare with this arrow for equality.
Returns:
true if the given object is equal to this arrow.

hashCode

public int hashCode()
Returns a hash value for this arrow.

Overrides:
hashCode in class Object


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.