edu.mit.sketch.geom
Class Arc

java.lang.Object
  extended by edu.mit.sketch.geom.Arc
All Implemented Interfaces:
GeometricObject, Translatable, Terminal, Paintable, Painter, java.io.Serializable

public class Arc
extends java.lang.Object
implements GeometricObject, java.io.Serializable

This class represents an arc described by its end-points p, q.

See Also:
Serialized Form

Field Summary
 double extent
          extent in radians
 java.awt.Graphics graphics
          Graphics context for this Geometric object.
 double start
          start angle in radians
 long time_stamp
          Time stamp of this object.
 
Constructor Summary
Arc(double start, double extent, double radius, Point center, boolean clockwise)
           
 
Method Summary
 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.
 GeometricObject copy()
          This method copies the geometric object (includeing the underlying data and returns it.
static Arc fitArc(StrokeData strokeData)
           
static Arc fitArc(Vertex[] vertices)
           
 java.awt.Rectangle getBounds()
          Get the bounding box of this object
 Point getCenter()
          returns center of the cirle that best matches this arc in a least squares sense
 boolean getClockwise()
           
 Polygon getDataPoints()
          This method is used to get the original data points that forms this GeometricObject
 double getExtent()
           
 Point getHeadPoint()
          returns the head point of the arc
 int getIntType()
          Returns the static descriptive type that it is;
 Vertex[] getOriginalVertices()
          This method is used to get the original data points that form the geometric object in their vertex form.
 Polygon getPolygonalBounds()
          This method should return a polygon that corresponds to this object.
 double getRadius()
          returns radius of the cirle that best matches this arc in a least squares sense
 Rectangle getRectangularBounds()
          Supplied for completeness.
 double getStart()
           
 Point getTailPoint()
          returns the tail point of the arc
 long getTimeStamp()
          Returns the time stamp of the current Terminal
 java.lang.String getType()
          Implement GeometricObject
 double leastSquaresError()
          Return the LSQ error.
 void paint()
          Draw the object
 void paint(java.awt.Graphics g)
          Draw the object
 void paintOriginal(java.awt.Graphics g)
          This method is used to paint the original data points that forms this GeometricObject
 boolean pointIsOn(Point p, double radius)
          Returns true if the point is within +-radius distance from the curve defining the object.
 boolean pointIsOnOriginal(Point p, double radius)
          Returns true if the point is within +-radius distance from the original curve defining the object.
 void setCenter(Point center)
           
 void setClockwise(boolean clockwise)
           
 void setDataPoints(Polygon points)
          This method is used to set the original data points that forms this GeometricObject
 void setExtent(double extent)
           
 void setGraphicsContext(java.awt.Graphics g)
          Set graphics context for this Geometric object.
 void setOriginalVertices(Vertex[] pts)
           
 void setRadius(double radius)
           
 void setStart(double start)
           
 void setTimeStamp(long time_stamp)
          Sets the time stamp of the current Terminal
 int spatialRelation(GeometricObject object)
          This method should return the spatial relation of the input parameter with respect to this object.
 java.lang.String toString()
          Override toString
 boolean touches(GeometricObject object)
          This method should return true if the input objects touch.
 void translate(double x, double y)
          Add the arguments to the (x, y) position of the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

start

public double start
start angle in radians


extent

public double extent
extent in radians


time_stamp

public long time_stamp
Time stamp of this object.


graphics

public transient java.awt.Graphics graphics
Graphics context for this Geometric object.

Constructor Detail

Arc

public Arc(double start,
           double extent,
           double radius,
           Point center,
           boolean clockwise)
Method Detail

fitArc

public static Arc fitArc(Vertex[] vertices)

fitArc

public static Arc fitArc(StrokeData strokeData)

getRadius

public double getRadius()
returns radius of the cirle that best matches this arc in a least squares sense


getCenter

public Point getCenter()
returns center of the cirle that best matches this arc in a least squares sense


getHeadPoint

public Point getHeadPoint()
returns the head point of the arc


getTailPoint

public Point getTailPoint()
returns the tail point of the arc


getClockwise

public boolean getClockwise()

getType

public java.lang.String getType()
Implement GeometricObject

Specified by:
getType in interface Paintable

toString

public java.lang.String toString()
Override toString

Overrides:
toString in class java.lang.Object

paint

public void paint()
Draw the object

Specified by:
paint in interface Paintable

paint

public void paint(java.awt.Graphics g)
Draw the object

Specified by:
paint in interface Paintable
Specified by:
paint in interface Painter

paintOriginal

public void paintOriginal(java.awt.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 p,
                         double 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,
                                 double 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(java.awt.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

getBounds

public java.awt.Rectangle getBounds()
Get the bounding box of this object

Specified by:
getBounds in interface GeometricObject
Specified by:
getBounds in interface Painter

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 corresponds to this object. The polygon is implicity closed and the last point doesn't necessarily have to be the same as the first (zeroth) point. The returned polygon is a liberal approximation to the real shape of the object. Known eksik: This should be refined to return a more conservative result.

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

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

setOriginalVertices

public void setOriginalVertices(Vertex[] pts)
Specified by:
setOriginalVertices in interface GeometricObject

getOriginalVertices

public Vertex[] getOriginalVertices()
Description copied from interface: GeometricObject
This method is used to get the original data points that form the geometric object in their vertex form.

Specified by:
getOriginalVertices in interface GeometricObject

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

translate

public void translate(double x,
                      double y)
Add the arguments to the (x, y) position of the object.

Specified by:
translate in interface Translatable

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

leastSquaresError

public double leastSquaresError()
Return the LSQ error.


copy

public final GeometricObject copy()
Description copied from interface: GeometricObject
This method copies the geometric object (includeing the underlying data and returns it.

Specified by:
copy in interface GeometricObject

getExtent

public double getExtent()

setExtent

public void setExtent(double extent)

getStart

public double getStart()

setStart

public void setStart(double start)

setCenter

public void setCenter(Point center)

setClockwise

public void setClockwise(boolean clockwise)

setRadius

public void setRadius(double radius)

getIntType

public int getIntType()
Description copied from interface: GeometricObject
Returns the static descriptive type that it is;

Specified by:
getIntType in interface GeometricObject
Returns:
the int value of the type