jimm.datavision.field
Class Rectangle

java.lang.Object
  extended by java.util.Observable
      extended by jimm.datavision.field.Rectangle
All Implemented Interfaces:
Writeable

public class Rectangle
extends java.util.Observable
implements Writeable

A rectangle with double coordinates.

Author:
Jim Menard, jimm@io.com

Field Summary
 double height
          Warning: only read the height.
 double width
          Warning: only read the width.
 double x
          Warning: only read the x coordinate.
 double y
          Warning: only read the y coordinate.
 
Constructor Summary
Rectangle()
          Constructor.
Rectangle(double x, double y, double width, double height)
          Constructor.
Rectangle(java.awt.Rectangle r)
          Constructor.
Rectangle(Rectangle r)
          Constructor.
 
Method Summary
 double getHeight()
          Returns the height.
 double getWidth()
          Returns the width.
 double getX()
          Returns the x coordinate.
 double getY()
          Returns the y coordinate.
 void setBounds(double newX, double newY, double newWidth, double newHeight)
          Sets everything at once.
 void setBounds(Rectangle r)
          Sets everything at once.
 void setBounds(java.awt.Rectangle r)
          Sets everything at once.
 void setHeight(double newHeight)
          Sets the height.
 void setWidth(double newWidth)
          Sets the width.
 void setX(double newX)
          Sets the x coordinate.
 void setY(double newY)
          Sets the y coordinate.
 java.lang.String toString()
          Returns a string representation of this rectangle.
 void writeXML(XMLWriter out)
          Writes this rectangle as an XML tag.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
Warning: only read the x coordinate. When writing, make sure to use setter method so observers are notified.


y

public double y
Warning: only read the y coordinate. When writing, make sure to use setter method so observers are notified.


width

public double width
Warning: only read the width. When writing, make sure to use setter method so observers are notified.


height

public double height
Warning: only read the height. When writing, make sure to use setter method so observers are notified.

Constructor Detail

Rectangle

public Rectangle()
Constructor.


Rectangle

public Rectangle(java.awt.Rectangle r)
Constructor.

Parameters:
r - the other kind of rectangle

Rectangle

public Rectangle(Rectangle r)
Constructor.

Parameters:
r - another rectangle

Rectangle

public Rectangle(double x,
                 double y,
                 double width,
                 double height)
Constructor.

Parameters:
x - a double
y - a double
width - a double
height - a double
Method Detail

getX

public double getX()
Returns the x coordinate.

Returns:
the doubleing-point x coordinate

setX

public void setX(double newX)
Sets the x coordinate.

Parameters:
newX - the new x coordinate

getY

public double getY()
Returns the y coordinate.

Returns:
the doubleing-point y coordinate

setY

public void setY(double newY)
Sets the y coordinate.

Parameters:
newY - the new y coordinate

getWidth

public double getWidth()
Returns the width.

Returns:
the doubleing-point width

setWidth

public void setWidth(double newWidth)
Sets the width.

Parameters:
newWidth - the new width

getHeight

public double getHeight()
Returns the height.

Returns:
the doubleing-point height

setHeight

public void setHeight(double newHeight)
Sets the height.

Parameters:
newHeight - the new height

setBounds

public void setBounds(double newX,
                      double newY,
                      double newWidth,
                      double newHeight)
Sets everything at once.

Parameters:
newX - the new x coordinate
newY - the new y coordinate
newWidth - the new width
newHeight - the new height

setBounds

public void setBounds(Rectangle r)
Sets everything at once.

Parameters:
r - a jimm.datavision.Rectangle

setBounds

public void setBounds(java.awt.Rectangle r)
Sets everything at once.

Parameters:
r - a java.awt.Rectangle

toString

public java.lang.String toString()
Returns a string representation of this rectangle.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this rectangle

writeXML

public void writeXML(XMLWriter out)
Writes this rectangle as an XML tag.

Specified by:
writeXML in interface Writeable
Parameters:
out - a writer that knows how to write XML