diva.canvas.interactor
Class PathGeometry

java.lang.Object
  extended by diva.canvas.interactor.PathGeometry
All Implemented Interfaces:
Geometry

public class PathGeometry
extends java.lang.Object
implements Geometry

PathGeometry represents a path. Actually, any shape. Its defining shape is any instance of Shape, although generally this class is most useful for shapes that are instances of GeneralPath, since any modification to any of the will cause the shape returned by getShape() to be changed into an instance of GeneralPath.

PathGeometry provides sites for the vertices of the path, and for the control point for those segments that are quadratic or cubic curves.

Version:
$Id: PathGeometry.java 57040 2010-01-27 20:52:32Z cxh $
Author:
John Reekie, Nick Zamora

Nested Class Summary
 class PathGeometry.CloseSegment
          CloseSegment is a special type of Vertex, that closes a sub-path.
 class PathGeometry.Vertex
          Vertex is the site that represents vertexes of the path.
 
Field Summary
private  int _coordCount
          The number of coordinates in the path
private  float[] _coordinate
          The array of coordinates of vertices and control points, in the same format as for GeneralPath
private  boolean _geometryValid
          A flag that says whether the geometry arrays are up-to-date
private  int[] _index
          The array of indexes into the coordinate array, indexed by vertex number
private  Figure _parentFigure
          The figure to which the sites are attached
private  java.awt.Shape _path
          The defining path
private  int[] _type
          The array of vertex type, using the fields defined in GeneralPath and returned by PathIterator.
private  java.awt.geom.AffineTransform _unitTransform
          Needed for getPathIterator
private  int _vertexCount
          The number of vertices in the path
private  PathGeometry.Vertex[] _vertices
          The vertex sites.
 
Constructor Summary
PathGeometry(Figure figure, java.awt.Shape shape)
          Create a new geometry object on the given figure and with the given initial shape.
 
Method Summary
 Figure getFigure()
          Get the figure to which this geometry object is attached.
 java.awt.Shape getShape()
          Get the shape that defines this geometry object.
 Site getVertex(int number)
          Get the site on the given vertex.
 int getVertexCount()
          Get the number of vertices of this shape.
private  void invalidateGeometry()
           
 void setShape(java.awt.Shape shape)
          Set the shape that defines this geometry object.
 void translate(double x, double y)
          Translate the geometry object
private  void updateGeometry()
           
 java.util.Iterator vertices()
          Return an iteration over the vertices in this geometry object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_parentFigure

private Figure _parentFigure
The figure to which the sites are attached


_path

private java.awt.Shape _path
The defining path


_vertices

private PathGeometry.Vertex[] _vertices
The vertex sites. Other sites are referenced by these sites


_geometryValid

private boolean _geometryValid
A flag that says whether the geometry arrays are up-to-date


_vertexCount

private int _vertexCount
The number of vertices in the path


_coordCount

private int _coordCount
The number of coordinates in the path


_coordinate

private float[] _coordinate
The array of coordinates of vertices and control points, in the same format as for GeneralPath


_type

private int[] _type
The array of vertex type, using the fields defined in GeneralPath and returned by PathIterator.


_index

private int[] _index
The array of indexes into the coordinate array, indexed by vertex number


_unitTransform

private java.awt.geom.AffineTransform _unitTransform
Needed for getPathIterator

Constructor Detail

PathGeometry

public PathGeometry(Figure figure,
                    java.awt.Shape shape)
Create a new geometry object on the given figure and with the given initial shape.

Method Detail

getFigure

public Figure getFigure()
Get the figure to which this geometry object is attached. Returns null if there isn't one.

Specified by:
getFigure in interface Geometry

getShape

public java.awt.Shape getShape()
Get the shape that defines this geometry object. If any of the sites have been translated since this shape was set, a new shape will be produced and returned.

Specified by:
getShape in interface Geometry

getVertex

public Site getVertex(int number)
Get the site on the given vertex.


getVertexCount

public int getVertexCount()
Get the number of vertices of this shape. This number includes all "Close" segments.


setShape

public void setShape(java.awt.Shape shape)
Set the shape that defines this geometry object.

Specified by:
setShape in interface Geometry

translate

public void translate(double x,
                      double y)
Translate the geometry object

Specified by:
translate in interface Geometry

vertices

public java.util.Iterator vertices()
Return an iteration over the vertices in this geometry object.


invalidateGeometry

private void invalidateGeometry()

updateGeometry

private void updateGeometry()