edu.mit.sketch.geom
Class Point

java.lang.Object
  |
  +--java.awt.geom.Point2D
        |
        +--java.awt.Point
              |
              +--edu.mit.sketch.geom.Point
All Implemented Interfaces:
Cloneable, GeometricObject, Paintable, Serializable, Terminal, Translatable
Direct Known Subclasses:
Vertex

public class Point
extends Point
implements GeometricObject, Serializable

This class represents a Point described by a java.awt.geom.Line2D.Double

See Also:
Serialized Form

Inner classes inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
 
Field Summary
 Graphics graphics
          Graphics context for this Geometric object.
 long time_stamp
          Time stamp of this object.
 
Fields inherited from class java.awt.Point
x, y
 
Fields inherited from interface edu.mit.sketch.geom.GeometricObject
CIRCLE, ELLIPSE, LINE, POINT, POLYGON, RECTANGLE, SQUARE
 
Constructor Summary
Point()
          The constructor.
Point(int x, int y)
          The constructor.
Point(int x, int y, long time_stamp)
          The constructor.
Point(Point point)
          The constructor.
Point(Point point, long time_stamp)
          The constructor.
 
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.
 double distance(Point p)
          Return distance from this point to input.
 Polygon getDataPoints()
          This method is used to get the original data points that forms this GeometricObject
 Polygon getPolygonalBounds()
          This method should return a polygon that corresponds to this object.
 Rectangle getRectangularBounds()
          Supplied for completeness.
 long getTimeStamp()
          Returns the time stamp of the current Terminal
 String getType()
          Implement GeometricObject
 double magnitude()
          Return distance from origin.
 void paint()
          Draw the object
 void paint(Graphics g)
          Draw the object
static void paint(Point[] points, Graphics g)
          paint points.
 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 this point.
 boolean pointIsOnOriginal(Point p, int radius)
          Returns true if the point is within +-radius distance from the original curve defining the object.
 void rotate(double radians)
          Rotate about the origin by radians amount.
 void scale(double scale)
          Multiply the x and y fields by the scale.
 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
 int spatialRelation(GeometricObject object)
          This method should return the spatial relation of the input parameter with respect to this object.
 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.awt.Point
equals, getLocation, getX, getY, move, setLocation, setLocation, setLocation, translate
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

time_stamp

public long time_stamp
Time stamp of this object.

graphics

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

Point

public Point()
The constructor.

Point

public Point(Point point)
The constructor.

Point

public Point(int x,
             int y)
The constructor.

Point

public Point(Point point,
             long time_stamp)
The constructor.

Point

public Point(int x,
             int y,
             long time_stamp)
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 Point

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

paint

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

pointIsOn

public boolean pointIsOn(Point point,
                         int radius)
Returns true if the point is within +-radius distance from this point. 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

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

getRectangularBounds

public Rectangle getRectangularBounds()
Supplied for completeness.
Specified by:
getRectangularBounds 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

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

rotate

public void rotate(double radians)
Rotate about the origin by radians amount.

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

scale

public void scale(double scale)
Multiply the x and y fields by the scale.

magnitude

public double magnitude()
Return distance from origin.

distance

public double distance(Point p)
Return distance from this point to input.

paint

public static void paint(Point[] points,
                         Graphics g)
paint points.