com.rolemodelsoft.drawlet.shapes.lines
Class ConnectingLine

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractPaintable
        |
        +--com.rolemodelsoft.drawlet.basics.AbstractFigure
              |
              +--com.rolemodelsoft.drawlet.shapes.AbstractShape
                    |
                    +--com.rolemodelsoft.drawlet.shapes.lines.LinearShape
                          |
                          +--com.rolemodelsoft.drawlet.shapes.lines.Line
                                |
                                +--com.rolemodelsoft.drawlet.shapes.lines.ConnectingLine
Direct Known Subclasses:
AdornedLine

public class ConnectingLine
extends Line
implements RelatedLocationListener

This provides a basic implementation of Lines that can connect to other figures. Note that there can be any number of Locators that make up a Line and that those Locators may be tied to Figures. When they are, the Line will become a dependent of the Figure and will assume it is moved when the Figure is moved/reshaped in any way.

See Also:
Serialized Form

Field Summary
protected  boolean mustConnect
          A boolean defining whether this line must be connected.
 
Fields inherited from class com.rolemodelsoft.drawlet.shapes.lines.Line
points, polygon
 
Fields inherited from class com.rolemodelsoft.drawlet.shapes.lines.LinearShape
lineColor
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
listeners, locationListeners
 
Constructor Summary
ConnectingLine(int beginX, int beginY, int endX, int endY)
          Constructs and initializes a new instance of a connecting line.
ConnectingLine(int beginX, int beginY, int endX, int endY, boolean mustConnect)
          Constructs and initializes a new instance of a connecting line.
ConnectingLine(Locator begin, Locator end)
          Constructs and initializes a new instance of a connecting line.
ConnectingLine(Locator begin, Locator end, boolean mustConnect)
          Constructs and initializes a new instance of a connecting line.
 
Method Summary
protected  void basicSetLocator(int index, Locator locator)
          Set the locator at the appropriate position.
protected  boolean defaultConnectState()
          Answer the default state for connectedness.
 void disconnect()
          Clean up as appropriate if the receiver is no longer valid.
protected  void freeFromFigure(Figure figure)
          Remove any dependence on the figure.
 Handle[] getHandles()
          Answer the handles associated with the receiver.
protected  boolean isListening(Figure figure)
          Answers whether the receiver is listening to the figure directly or indirectly (via chain of listeners)
 boolean isObsolete()
          Answers whether the receiver is obsolete.
 void locationChanged(java.beans.PropertyChangeEvent event)
          Update because the location of something we depend on has changed.
 void relationChanged(java.beans.PropertyChangeEvent event)
          Update because the relationship of something we depend on has changed.
 Locator requestConnection(Figure requestor, int x, int y)
          Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other figure.
 void shapeChanged(java.beans.PropertyChangeEvent event)
          Update because the shape of something we depend on has changed.
 void sizeChanged(java.beans.PropertyChangeEvent event)
          Update because the size of something we depend on has changed.
protected  void updateShape()
          Assume our location has changed due to some movement/reshaping of something we depend on.
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.lines.Line
basicAddLocator, basicRemoveLocator, basicReshape, basicTranslate, contains, duplicateIn, estimatedDuplicateSize, getBounds, getLocator, getNumberOfPoints, getPolygon, intersects, paint, postDuplicate, resetBoundsCache, resetLocationCache, resetSizeCache
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.lines.LinearShape
addLocator, addLocator, defaultLineColor, getLineColor, getStyle, insideSegment, insideTolerance, insideTolerance, locatorAt, removeLocator, setLineColor, setLocator, setStyle
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.AbstractShape
basicResize, reshapedPolygon, reshapedPolygon, setBounds, setSize
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
addPropertyChangeListener, addRelatedLocationListener, basicMove, changedLocation, changedShape, changedSize, contains, contains, deleteLocationListeners, duplicate, editTool, figureFromLocator, fireLocationChange, firePropertyChange, firePropertyChange, fireRelationChange, fireShapeChange, fireSizeChange, getLocation, getLocator, intersects, isWithin, isWithin, move, move, relatedLocationListeners, removePropertyChangeListener, removeRelatedLocationListener, setSize, translate
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable
getBottom, getHeight, getLeft, getRight, getSize, getTop, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mustConnect

protected boolean mustConnect
A boolean defining whether this line must be connected.
Constructor Detail

ConnectingLine

public ConnectingLine(int beginX,
                      int beginY,
                      int endX,
                      int endY)
Constructs and initializes a new instance of a connecting line.
Parameters:
beginX - the x coordinate for the first point defining the line
beginY - the y coordinate for the first point defining the line
endX - the x coordinate for the second point defining the line
endY - the y coordinate for the second point defining the line

ConnectingLine

public ConnectingLine(int beginX,
                      int beginY,
                      int endX,
                      int endY,
                      boolean mustConnect)
Constructs and initializes a new instance of a connecting line.
Parameters:
beginX - the x coordinate for the first point defining the line
beginY - the y coordinate for the first point defining the line
endX - the x coordinate for the second point defining the line
endY - the y coordinate for the second point defining the line
mustConnect - specifies whether this line has to be connected in order to exist

ConnectingLine

public ConnectingLine(Locator begin,
                      Locator end)
Constructs and initializes a new instance of a connecting line.
Parameters:
begin - the locator which is the first point defining the line
end - the locator which is the second point defining the line

ConnectingLine

public ConnectingLine(Locator begin,
                      Locator end,
                      boolean mustConnect)
Constructs and initializes a new instance of a connecting line.
Parameters:
begin - the locator which is the first point defining the line
end - the locator which is the second point defining the line
mustConnect - specifies whether this line has to be connected in order to exist
Method Detail

basicSetLocator

protected void basicSetLocator(int index,
                               Locator locator)
Set the locator at the appropriate position.
Overrides:
basicSetLocator in class Line
Parameters:
index - the index of the locator desired.
locator - the new Locator.

defaultConnectState

protected boolean defaultConnectState()
Answer the default state for connectedness.
Returns:
a boolean representing whether this line must be connected to exist.

disconnect

public void disconnect()
Clean up as appropriate if the receiver is no longer valid.
Overrides:
disconnect in class AbstractFigure

freeFromFigure

protected void freeFromFigure(Figure figure)
Remove any dependence on the figure.
Parameters:
figure - the Figure to disassociate from.

getHandles

public Handle[] getHandles()
Answer the handles associated with the receiver.
Overrides:
getHandles in class LinearShape
Returns:
an array of the Handles associated with the receiver

isListening

protected boolean isListening(Figure figure)
Answers whether the receiver is listening to the figure directly or indirectly (via chain of listeners)
Parameters:
figure - the Figure to test
Returns:
boolean value of true if the receiver is listening to the figure directly or indirectly; false otherwise.

isObsolete

public boolean isObsolete()
Answers whether the receiver is obsolete.
Overrides:
isObsolete in class AbstractFigure
Returns:
boolean value of true if both ends are not connected to a figure; false otherwise.

locationChanged

public void locationChanged(java.beans.PropertyChangeEvent event)
Update because the location of something we depend on has changed.
Specified by:
locationChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

relationChanged

public void relationChanged(java.beans.PropertyChangeEvent event)
Update because the relationship of something we depend on has changed.
Specified by:
relationChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

requestConnection

public Locator requestConnection(Figure requestor,
                                 int x,
                                 int y)
Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other figure.
Overrides:
requestConnection in class LinearShape
Parameters:
requestor - the figure requesting the connection
x - the x coordinate of the requested locator
y - the y coordinate of the requested locator
Returns:
a Locator corresponding to a significant point on the receiver

shapeChanged

public void shapeChanged(java.beans.PropertyChangeEvent event)
Update because the shape of something we depend on has changed.
Specified by:
shapeChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

sizeChanged

public void sizeChanged(java.beans.PropertyChangeEvent event)
Update because the size of something we depend on has changed.
Specified by:
sizeChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

updateShape

protected void updateShape()
Assume our location has changed due to some movement/reshaping of something we depend on.