jdraw.graphicobjects
Class GraphicObject

java.lang.Object
  |
  +--jdraw.graphicobjects.GraphicObject
Direct Known Subclasses:
Point, SizedGraphicObject, TextArea

public abstract class GraphicObject
extends Object

The abstract parent class of all graphic objects.


Field Summary
private  Color color
          The color of this object.
private  int x
          The abscissa of this object.
private  int y
          The ordinate of this object.
 
Constructor Summary
protected GraphicObject(int x, int y, Color color)
          Creates a new GraphicObject with specified position and color.
 
Method Summary
abstract  Rectangle getBoundingBox()
          Returns the bounding box of this object.
 Color getColor()
          Returns the color of this object.
abstract  Cursor getCursor()
          Returns the mouse cursor for this object.
 int getDistance(Point point)
          Returns the minimal distance between this object and the specified point.
static int getDistanceSq(double x1, double y1, double x2, double y2)
          Returns the square of the distance between two points, stated by their coordinates (doubles).
static int getDistanceSq(int x1, int y1, int x2, int y2)
          Returns the square of the distance between two points, stated by their coordinates (integers).
abstract  int getDistanceSq(Point point)
          Returns the square of the minimal distance between this object and the specified point.
abstract  String getFriendlyName()
          Returns the friendly name of this object.
 int getX()
          Returns the abscissa of this object.
 int getY()
          Returns the ordinate of this object.
abstract  void paint(Graphics g)
          Paints this object.
 void updateCachedData()
          Invoked when cached data have to be updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

private int x
The abscissa of this object.


y

private int y
The ordinate of this object.


color

private Color color
The color of this object.

Constructor Detail

GraphicObject

protected GraphicObject(int x,
                        int y,
                        Color color)
Creates a new GraphicObject with specified position and color.

Method Detail

getBoundingBox

public abstract Rectangle getBoundingBox()
Returns the bounding box of this object.


getCursor

public abstract Cursor getCursor()
Returns the mouse cursor for this object.


getFriendlyName

public abstract String getFriendlyName()
Returns the friendly name of this object.


paint

public abstract void paint(Graphics g)
Paints this object.


getDistance

public int getDistance(Point point)
Returns the minimal distance between this object and the specified point.


getDistanceSq

public abstract int getDistanceSq(Point point)
Returns the square of the minimal distance between this object and the specified point.


getDistanceSq

public static int getDistanceSq(int x1,
                                int y1,
                                int x2,
                                int y2)
Returns the square of the distance between two points, stated by their coordinates (integers).

Parameters:
x1 - the abscissa of the first point
y1 - the ordinate of the first point
x2 - the abscissa of the second point
y2 - the ordinate of the second point

getDistanceSq

public static int getDistanceSq(double x1,
                                double y1,
                                double x2,
                                double y2)
Returns the square of the distance between two points, stated by their coordinates (doubles).

Parameters:
x1 - the abscissa of the first point
y1 - the ordinate of the first point
x2 - the abscissa of the second point
y2 - the ordinate of the second point

getX

public int getX()
Returns the abscissa of this object.


getY

public int getY()
Returns the ordinate of this object.


getColor

public Color getColor()
Returns the color of this object.


updateCachedData

public void updateCachedData()
Invoked when cached data have to be updated.