com.rolemodelsoft.drawlet.basics
Class EdgeLocator

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

public class EdgeLocator
extends AbstractLocator
implements RelativeLocator

This class implements Locator by providing x and y coordinates that are at the intersection of the figure and the line defined by the 2 locators.

See Also:
Serialized Form

Field Summary
protected  int endX
           
protected  int endY
           
protected  Figure figure
          The figure to which the line is connected.
protected  Locator inside
          The locator that is assumed to be inside a figure.
protected  Locator outside
          The locator that is assumed to be outside a figure.
protected  int startX
           
protected  int startY
           
protected  int x
           
protected  int y
           
 
Constructor Summary
EdgeLocator(Locator inside, Locator outside)
          Creates a new EdgeLocator initialized with the given values.
 
Method Summary
protected  void computeIntersection()
           
protected  void computeMiddlePoint(int startX, int startY, int endX, int endY)
           
protected  boolean differenceIsOneOrNone(int x, int y)
           
static Figure figureFromLocator(Locator aLocator)
          Answer the figure, if any, associated with the locator.
 Locator getBase()
          Answer the base concrete locator of the receiver.
 int x()
          Answer the x coordinate.
 int y()
          Answer the y coordinate.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractLocator
duplicate, duplicateIn, postDuplicate, r, theta, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inside

protected Locator inside
The locator that is assumed to be inside a figure.

figure

protected Figure figure
The figure to which the line is connected.

outside

protected Locator outside
The locator that is assumed to be outside a figure.

x

protected int x

y

protected int y

startX

protected int startX

startY

protected int startY

endX

protected int endX

endY

protected int endY
Constructor Detail

EdgeLocator

public EdgeLocator(Locator inside,
                   Locator outside)
Creates a new EdgeLocator initialized with the given values.
Parameters:
inside - a Locator representing the end of a line inside a figure.
outside - a Locator representing the end of a line outside a figure.
figure - the figure at the inside Locator.
Method Detail

computeIntersection

protected void computeIntersection()

computeMiddlePoint

protected void computeMiddlePoint(int startX,
                                  int startY,
                                  int endX,
                                  int endY)
Returns:
com.rolemodelsoft.drawlet.basics.DrawingPoint

differenceIsOneOrNone

protected boolean differenceIsOneOrNone(int x,
                                        int y)

figureFromLocator

public static Figure figureFromLocator(Locator aLocator)
Answer the figure, if any, associated with the locator. This can be a useful utility to determine whether or not a particular locator is tied to some figure.
Parameters:
aLocator - the Locator to mine for figures
Returns:
the Figure associated with the locator, or null if none

getBase

public Locator getBase()
Answer the base concrete locator of the receiver.
Specified by:
getBase in interface RelativeLocator
Returns:
the base concrete Locator of the receiver

x

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

y

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