com.rolemodelsoft.drawlet.basics
Class RelativePoint

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractLocator
        |
        +--com.rolemodelsoft.drawlet.basics.RelativePoint

public class RelativePoint
extends AbstractLocator
implements MovableLocator, RelativeLocator

This class implements RelativeLocator and MovableLocator by providing movable x and y offsets to some base locator.

See Also:
Serialized Form

Field Summary
protected  Locator base
          The locator to which this is relative.
protected  int offsetX
          The x offset from the base locator.
protected  int offsetY
          The y offset from the base locator.
 
Constructor Summary
RelativePoint(Locator base, int x, int y)
          Constructs and initializes a RelativePoint with the specified parameters.
 
Method Summary
protected  int defaultOffsetX()
          Answer the default/initial value of offsetX.
protected  int defaultOffsetY()
          Answer the default/initial value of offsetY.
 java.lang.Object duplicate()
          Duplicates the receiver.
 java.lang.Object duplicateIn(java.util.Hashtable duplicates)
          Duplicates the receiver in the given Hashtable.
 Locator getBase()
          Answer the base concrete locator of the receiver.
 void move(int x, int y)
          Moves the receiver to the x and y coordinates
 void postDuplicate(java.util.Hashtable duplicates)
          After a series of Objects are duplicated, this can be sent to each of the duplicates to resolve any changes it might like to reconcile.
 void translate(int x, int y)
          Moves the receiver in the x and y direction.
 int x()
          Answer the x coordinate.
 void x(int x)
          Set the x coordinate.
 int y()
          Answer the y coordinate.
 void y(int y)
          Set the y coordinate.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractLocator
r, theta, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

base

protected Locator base
The locator to which this is relative.

offsetX

protected int offsetX
The x offset from the base locator.

offsetY

protected int offsetY
The y offset from the base locator.
Constructor Detail

RelativePoint

public RelativePoint(Locator base,
                     int x,
                     int y)
Constructs and initializes a RelativePoint with the specified parameters.
Parameters:
base - the Locator to which the constructed point is relative.
x - the x coordinate of the offset
y - the y coordinate of the offset
Method Detail

defaultOffsetX

protected int defaultOffsetX()
Answer the default/initial value of offsetX. Subclasses may wish to consider changing this from 0
Returns:
an integer representing the default/initial value of offsetX

defaultOffsetY

protected int defaultOffsetY()
Answer the default/initial value of offsetY. Subclasses may wish to consider changing this from 0
Returns:
an integer representing the default/initial value of offsetY

duplicate

public java.lang.Object duplicate()
Duplicates the receiver. This means duplicating the base.
Overrides:
duplicate in class AbstractLocator
Returns:
an Object which is a duplicate of the receiver

duplicateIn

public java.lang.Object duplicateIn(java.util.Hashtable duplicates)
Duplicates the receiver in the given Hashtable.
Overrides:
duplicateIn in class AbstractLocator
Parameters:
duplicates - the Hashtable to put the new duplicate in
Returns:
an Object which is a duplicate of the receiver

getBase

public Locator getBase()
Answer the base concrete locator of the receiver. This is a recursive operation to get to the real base in a potential chain of RelativeLocators
Specified by:
getBase in interface RelativeLocator
Returns:
the base concrete Locator of the receiver

move

public void move(int x,
                 int y)
Moves the receiver to the x and y coordinates
Specified by:
move in interface MovableLocator
Parameters:
x - the new x coordinate
y - the new x coordinate

postDuplicate

public void postDuplicate(java.util.Hashtable duplicates)
After a series of Objects are duplicated, this can be sent to each of the duplicates to resolve any changes it might like to reconcile. In this case, get the duplicate of the current figure if there is one. Keep the original if not.
Overrides:
postDuplicate in class AbstractLocator
Parameters:
duplicates - a Hashtable where originals as keys and duplicates as elements

translate

public void translate(int x,
                      int y)
Moves the receiver in the x and y direction.
Specified by:
translate in interface MovableLocator
Parameters:
x - amount to move in the x direction
y - amount to move in the y direction

x

public int x()
Answer the x coordinate.
Overrides:
x in class AbstractLocator
Returns:
an integer representing the x coordinate

x

public void x(int x)
Set the x coordinate.
Specified by:
x in interface MovableLocator
Parameters:
x - its new desired x coordinate.

y

public int y()
Answer the y coordinate.
Overrides:
y in class AbstractLocator
Returns:
an integer representing the y coordinate

y

public void y(int y)
Set the y coordinate.
Specified by:
y in interface MovableLocator
Parameters:
y - its new desired y coordinate.