JHotDraw 7.3.1

org.jhotdraw.samples.odg.geom
Class EnhancedPath

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<EnhancedPath.Segment>
              extended by org.jhotdraw.samples.odg.geom.EnhancedPath
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<EnhancedPath.Segment>, java.util.Collection<EnhancedPath.Segment>, java.util.List<EnhancedPath.Segment>, java.util.RandomAccess

public class EnhancedPath
extends java.util.ArrayList<EnhancedPath.Segment>
implements java.awt.Shape

Represents an ODG Enhanced Path.

The coordinates of a EnhancedPath.Segment can reference a formula or a modifier.

Version:
$Id: EnhancedPath.java 527 2009-06-07 14:28:19Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
static class EnhancedPath.Segment
          Defines a vertex (node) of the bezier path.
static class EnhancedPath.SegType
           
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EnhancedPath()
           
 
Method Summary
 void arcTo(java.lang.Object x1, java.lang.Object y1, java.lang.Object x2, java.lang.Object y2, java.lang.Object x3, java.lang.Object y3, java.lang.Object x4, java.lang.Object y4)
          (x1, y1) and (x2, y2) is defining the bounding box of a ellipse.
 void clockwiseArcTo(java.lang.Object x1, java.lang.Object y1, java.lang.Object x2, java.lang.Object y2, java.lang.Object x3, java.lang.Object y3, java.lang.Object x4, java.lang.Object y4)
           
 void close()
          Closes the current path segment.
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
 void curveTo(java.lang.Object x1, java.lang.Object y1, java.lang.Object x2, java.lang.Object y2, java.lang.Object x3, java.lang.Object y3)
          Adds a cubic curve to the current path segment.
 void ellipseTo(java.lang.Object x, java.lang.Object y, java.lang.Object w, java.lang.Object h, java.lang.Object t0, java.lang.Object t1)
          Draws a segment of an ellipse.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
 int getWindingRule()
          Gets winding rule for filling the bezier path.
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 void invalidatePath()
          This must be called after the EnhancedPath has been changed.
 void lineTo(java.lang.Object x1, java.lang.Object y1)
          Adds a line to the current path segment.
 void moveTo(java.lang.Object xm1, java.lang.Object ym1)
          Opens a new path segment at the specified position.
 void quadrantXTo(java.lang.Object x, java.lang.Object y)
           
 void quadrantYTo(java.lang.Object x, java.lang.Object y)
           
 void quadTo(java.lang.Object x1, java.lang.Object y1, java.lang.Object x2, java.lang.Object y2)
          Adds a quadratic curve to the current path segment.
 void setWindingRule(int newValue)
          Sets winding rule for filling the bezier path.
 java.awt.geom.GeneralPath toGeneralPath()
          Converts the EnhancedPath into a GeneralPath.
 void validatePath()
          Recomputes the EnhancedPath, if it is invalid.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

EnhancedPath

public EnhancedPath()
Method Detail

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D p)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Specified by:
intersects in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape

validatePath

public void validatePath()
Recomputes the EnhancedPath, if it is invalid.


invalidatePath

public void invalidatePath()
This must be called after the EnhancedPath has been changed.


toGeneralPath

public java.awt.geom.GeneralPath toGeneralPath()
Converts the EnhancedPath into a GeneralPath.


moveTo

public void moveTo(java.lang.Object xm1,
                   java.lang.Object ym1)
Opens a new path segment at the specified position.


lineTo

public void lineTo(java.lang.Object x1,
                   java.lang.Object y1)
Adds a line to the current path segment. This is only allowed, when the current path segment is open.


close

public void close()
Closes the current path segment. This is only allowed, when the current path segment is open.


quadTo

public void quadTo(java.lang.Object x1,
                   java.lang.Object y1,
                   java.lang.Object x2,
                   java.lang.Object y2)
Adds a quadratic curve to the current path segment. This is only allowed, when the current path segment is open.


curveTo

public void curveTo(java.lang.Object x1,
                    java.lang.Object y1,
                    java.lang.Object x2,
                    java.lang.Object y2,
                    java.lang.Object x3,
                    java.lang.Object y3)
Adds a cubic curve to the current path segment. This is only allowed, when the current path segment is open.


arcTo

public void arcTo(java.lang.Object x1,
                  java.lang.Object y1,
                  java.lang.Object x2,
                  java.lang.Object y2,
                  java.lang.Object x3,
                  java.lang.Object y3,
                  java.lang.Object x4,
                  java.lang.Object y4)
(x1, y1) and (x2, y2) is defining the bounding box of a ellipse. A line is then drawn from the current point to the start angle of the arc that is specified by the radial vector of point (x3, y3) and then counter clockwise to the end-angle that is specified by point (x4, y4).


clockwiseArcTo

public void clockwiseArcTo(java.lang.Object x1,
                           java.lang.Object y1,
                           java.lang.Object x2,
                           java.lang.Object y2,
                           java.lang.Object x3,
                           java.lang.Object y3,
                           java.lang.Object x4,
                           java.lang.Object y4)

ellipseTo

public void ellipseTo(java.lang.Object x,
                      java.lang.Object y,
                      java.lang.Object w,
                      java.lang.Object h,
                      java.lang.Object t0,
                      java.lang.Object t1)
Draws a segment of an ellipse. The ellipse is specified by the center(x, y), the size(w, h) and the start-angle t0 and end-angle t1.


quadrantXTo

public void quadrantXTo(java.lang.Object x,
                        java.lang.Object y)

quadrantYTo

public void quadrantYTo(java.lang.Object x,
                        java.lang.Object y)

setWindingRule

public void setWindingRule(int newValue)
Sets winding rule for filling the bezier path.

Parameters:
newValue - Must be GeneralPath.WIND_EVEN_ODD or GeneralPath.WIND_NON_ZERO.

getWindingRule

public int getWindingRule()
Gets winding rule for filling the bezier path.

Returns:
GeneralPath.WIND_EVEN_ODD or GeneralPath.WIND_NON_ZERO.

Copyright 1996-2009 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.