edu.mit.sketch.geom
Class GeneralPath

java.lang.Object
  |
  +--edu.mit.sketch.geom.GeneralPath
All Implemented Interfaces:
GeometricObject, Paintable, Serializable, Shape, Terminal, Translatable

public class GeneralPath
extends Object
implements Serializable, GeometricObject, Shape

This class represents the GeneralPath object. This is a wrapper class for enabling Serialization and extension.

See Also:
Serialized Form

Field Summary
protected  GeneralPath general_path
          The general path
 Graphics2D graphics
          Graphics context for this Geometric object.
 long time_stamp
          Time stamp of this object.
 
Fields inherited from interface edu.mit.sketch.geom.GeometricObject
CIRCLE, ELLIPSE, LINE, POINT, POLYGON, RECTANGLE, SQUARE
 
Constructor Summary
GeneralPath()
          The constructor.
GeneralPath(GeneralPath general_path)
          The constructor.
GeneralPath(int rule)
          The constructor.
GeneralPath(int rule, int initial_capacity)
          The constructor.
GeneralPath(Shape shape)
          The constructor.
 
Method Summary
 void append(PathIterator pi, boolean connect)
          Implement methods for extension of java.awt.geom.GeneralPath
 void append(Shape s, boolean connect)
          Implement methods for extension of java.awt.geom.GeneralPath
 Object clone()
          Implement methods for extension of java.awt.geom.GeneralPath
 void closePath()
          Implement methods for extension of java.awt.geom.GeneralPath
 void combineEndPoints(double error)
          Combines the ends of the polygon if they are sufficiently close.
 boolean contains(double x, double y)
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean contains(double x, double y, double w, double h)
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean contains(Point2D p)
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean contains(Rectangle2D r)
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean containsGeometricObject(GeometricObject object)
          Returns false if the argument is not completely inside this object.
 boolean containsGeometricObjects(GeometricObject[] objects)
          Returns false if the objects in the input array are completely inside this object.
 Shape createTransformedShape(AffineTransform at)
          Implement methods for extension of java.awt.geom.GeneralPath
 void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
          Implement methods for extension of java.awt.geom.GeneralPath
 Vertex[] flatten(double flatness, int limit)
          Return an array of vertices corresponding to the flattened version of this GeneralPath
 double getAngle()
          Returns the angle of the object WRT the x axis in radians.
 Rectangle getBounds()
          Implement methods for extension of java.awt.geom.GeneralPath
 Rectangle2D getBounds2D()
          Implement methods for extension of java.awt.geom.GeneralPath
 double getCartesianAngle()
          Returns the angle of the object WRT the x axis in radians.
 Point2D getCurrentPoint()
          Implement methods for extension of java.awt.geom.GeneralPath
 Polygon getDataPoints()
          This method is used to get the original data points that forms this GeometricObject
 Range[] getGeneralPathRanges(StrokeData data)
          getGeneralPathRanges.
 double getLSQEror(StrokeData data, Range[] ranges)
          Get the LSQE for the general path by measuring the distance to the vertices in the StrokeData.
 PathIterator getPathIterator(AffineTransform at)
          Implement methods for extension of java.awt.geom.GeneralPath
 PathIterator getPathIterator(AffineTransform at, double flatness)
          Implement methods for extension of java.awt.geom.GeneralPath
 Polygon getPolygonalBounds()
          This method should return a polygon that fully contains the current object.
 Rectangle getRectangularBounds()
          Supplied for completeness.
 int getSegmentCount()
          Return the number of segments in a java.awt.GeneralPath object.
 Point getStartPosition()
          Return the beginning the position.
 long getTimeStamp()
          Returns the time stamp of the current Terminal
 String getType()
          Implement GeometricObject
 int getWindingRule()
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean intersects(double x, double y, double w, double h)
          Implement methods for extension of java.awt.geom.GeneralPath
 boolean intersects(Rectangle2D r)
          Implement methods for extension of java.awt.geom.GeneralPath
 void lineTo(float x, float y)
          Implement methods for extension of java.awt.geom.GeneralPath
 void moveTo(float x, float y)
          Implement methods for extension of java.awt.geom.GeneralPath
 void paint()
          Draw the object
 void paint(Graphics g2D)
          Paint the general path
 void paintConvexHulls(Graphics2D g2D)
          Show convex hulls for the curves
 void paintInSegments(Graphics2D g2D)
          Paint the general path in segments
 void paintOriginal(Graphics g)
          This method is used to paint the original data points that forms this GeometricObject
 boolean pointIsOn(Point point, int radius)
          Returns true if the point is within +-radius distance from the curve defining the object.
 boolean pointIsOnOriginal(Point p, int radius)
          Returns true if the point is within +-radius distance from the original curve defining the object.
 void quadTo(float x1, float y1, float x2, float y2)
          Implement methods for extension of java.awt.geom.GeneralPath
 void reset()
          Implement methods for extension of java.awt.geom.GeneralPath
 void setDataPoints(Polygon points)
          This method is used to set the original data points that forms this GeometricObject
 void setGraphicsContext(Graphics g)
          Set graphics context for this Geometric object.
 void setTimeStamp(long time_stamp)
          Sets the time stamp of the current Terminal
 void setWindingRule(int rule)
          Implement methods for extension of java.awt.geom.GeneralPath
 int spatialRelation(GeometricObject object)
          This method should return the spatial relation of the input parameter with respect to this object.
 Polygon toPolygon()
          This method is used to get the original data points that forms this GeometricObject
 String toString()
          Override toString
 boolean touches(GeometricObject object)
          This method should return true if the input objects touch.
 void transform(AffineTransform at)
          Implement methods for extension of java.awt.geom.GeneralPath
 void translate(double dx, double dy)
          Add the arguments to the position of the object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

general_path

protected transient GeneralPath general_path
The general path

time_stamp

public long time_stamp
Time stamp of this object.

graphics

public transient Graphics2D graphics
Graphics context for this Geometric object.
Constructor Detail

GeneralPath

public GeneralPath()
The constructor.

GeneralPath

public GeneralPath(Shape shape)
The constructor.

GeneralPath

public GeneralPath(int rule)
The constructor.

GeneralPath

public GeneralPath(int rule,
                   int initial_capacity)
The constructor.

GeneralPath

public GeneralPath(GeneralPath general_path)
The constructor.
Method Detail

getType

public String getType()
Implement GeometricObject
Specified by:
getType in interface Paintable

toString

public String toString()
Override toString
Overrides:
toString in class Object

paint

public void paint(Graphics g2D)
Paint the general path
Specified by:
paint in interface Paintable

paintInSegments

public void paintInSegments(Graphics2D g2D)
Paint the general path in segments

paintConvexHulls

public void paintConvexHulls(Graphics2D g2D)
Show convex hulls for the curves

paint

public void paint()
Draw the object
Specified by:
paint in interface Paintable

paintOriginal

public void paintOriginal(Graphics g)
This method is used to paint the original data points that forms this GeometricObject
Specified by:
paintOriginal in interface Paintable

pointIsOn

public boolean pointIsOn(Point point,
                         int radius)
Returns true if the point is within +-radius distance from the curve defining the object. Returns false o/w.
Specified by:
pointIsOn in interface Translatable

pointIsOnOriginal

public boolean pointIsOnOriginal(Point p,
                                 int radius)
Returns true if the point is within +-radius distance from the original curve defining the object. Returns false o/w.
Specified by:
pointIsOnOriginal in interface Translatable

setGraphicsContext

public void setGraphicsContext(Graphics g)
Set graphics context for this Geometric object. Must be set at least once before doing any drawing.
Specified by:
setGraphicsContext in interface Paintable

touches

public boolean touches(GeometricObject object)
This method should return true if the input objects touch. It should be optimized making use of the object type information.
Specified by:
touches in interface GeometricObject

getRectangularBounds

public Rectangle getRectangularBounds()
Supplied for completeness.
Specified by:
getRectangularBounds in interface GeometricObject

containsGeometricObject

public boolean containsGeometricObject(GeometricObject object)
Returns false if the argument is not completely inside this object. Return true O/W.
Specified by:
containsGeometricObject in interface GeometricObject

getPolygonalBounds

public Polygon getPolygonalBounds()
This method should return a polygon that fully contains the current object. The polygon is implicity closed and the last point doesn't necessarily have to be the same as the first (zeroth) point.
Specified by:
getPolygonalBounds in interface GeometricObject

spatialRelation

public int spatialRelation(GeometricObject object)
This method should return the spatial relation of the input parameter with respect to this object. see the SpatialRelation class for a detailed list of possible spatial relations. Another version of this method should be implemented for handling spatial relations where a rotated coordinate system is to be used.
Specified by:
spatialRelation in interface GeometricObject

getCartesianAngle

public double getCartesianAngle()
Returns the angle of the object WRT the x axis in radians.

getAngle

public double getAngle()
Returns the angle of the object WRT the x axis in radians.

setTimeStamp

public void setTimeStamp(long time_stamp)
Sets the time stamp of the current Terminal
Specified by:
setTimeStamp in interface Terminal

getTimeStamp

public long getTimeStamp()
Returns the time stamp of the current Terminal
Specified by:
getTimeStamp in interface Terminal

setDataPoints

public void setDataPoints(Polygon points)
This method is used to set the original data points that forms this GeometricObject
Specified by:
setDataPoints in interface GeometricObject

getDataPoints

public Polygon getDataPoints()
This method is used to get the original data points that forms this GeometricObject
Specified by:
getDataPoints in interface GeometricObject

toPolygon

public Polygon toPolygon()
This method is used to get the original data points that forms this GeometricObject

containsGeometricObjects

public boolean containsGeometricObjects(GeometricObject[] objects)
Returns false if the objects in the input array are completely inside this object. Return true O/W.
Specified by:
containsGeometricObjects in interface GeometricObject

translate

public void translate(double dx,
                      double dy)
Add the arguments to the position of the object.
Specified by:
translate in interface Translatable

append

public void append(PathIterator pi,
                   boolean connect)
Implement methods for extension of java.awt.geom.GeneralPath

append

public void append(Shape s,
                   boolean connect)
Implement methods for extension of java.awt.geom.GeneralPath

clone

public Object clone()
Implement methods for extension of java.awt.geom.GeneralPath
Overrides:
clone in class Object

closePath

public void closePath()
Implement methods for extension of java.awt.geom.GeneralPath

contains

public boolean contains(double x,
                        double y)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
contains in interface Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
contains in interface Shape

contains

public boolean contains(Point2D p)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
contains in interface Shape

contains

public boolean contains(Rectangle2D r)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
contains in interface Shape

createTransformedShape

public Shape createTransformedShape(AffineTransform at)
Implement methods for extension of java.awt.geom.GeneralPath

curveTo

public void curveTo(float x1,
                    float y1,
                    float x2,
                    float y2,
                    float x3,
                    float y3)
Implement methods for extension of java.awt.geom.GeneralPath

getBounds

public Rectangle getBounds()
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
getBounds in interface Shape

getBounds2D

public Rectangle2D getBounds2D()
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
getBounds2D in interface Shape

getCurrentPoint

public Point2D getCurrentPoint()
Implement methods for extension of java.awt.geom.GeneralPath

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
getPathIterator in interface Shape

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
getPathIterator in interface Shape

getWindingRule

public int getWindingRule()
Implement methods for extension of java.awt.geom.GeneralPath

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
intersects in interface Shape

intersects

public boolean intersects(Rectangle2D r)
Implement methods for extension of java.awt.geom.GeneralPath
Specified by:
intersects in interface Shape

lineTo

public void lineTo(float x,
                   float y)
Implement methods for extension of java.awt.geom.GeneralPath

moveTo

public void moveTo(float x,
                   float y)
Implement methods for extension of java.awt.geom.GeneralPath

quadTo

public void quadTo(float x1,
                   float y1,
                   float x2,
                   float y2)
Implement methods for extension of java.awt.geom.GeneralPath

reset

public void reset()
Implement methods for extension of java.awt.geom.GeneralPath

setWindingRule

public void setWindingRule(int rule)
Implement methods for extension of java.awt.geom.GeneralPath

transform

public void transform(AffineTransform at)
Implement methods for extension of java.awt.geom.GeneralPath

getSegmentCount

public int getSegmentCount()
Return the number of segments in a java.awt.GeneralPath object.

flatten

public Vertex[] flatten(double flatness,
                        int limit)
Return an array of vertices corresponding to the flattened version of this GeneralPath

getStartPosition

public Point getStartPosition()
Return the beginning the position.

getLSQEror

public double getLSQEror(StrokeData data,
                         Range[] ranges)
Get the LSQE for the general path by measuring the distance to the vertices in the StrokeData. The ranges[] should correnspond to the beginning and ending indices for the vertices that correspond to the points forming the general path.

getGeneralPathRanges

public Range[] getGeneralPathRanges(StrokeData data)
getGeneralPathRanges.

combineEndPoints

public void combineEndPoints(double error)
Combines the ends of the polygon if they are sufficiently close. This is still not working right.