edu.stanford.hci.dtools.statechart.model
Class ConnectionModel

java.lang.Object
  extended by edu.stanford.hci.dtools.statechart.model.ModelElement
      extended by edu.stanford.hci.dtools.statechart.model.ConnectionModel
All Implemented Interfaces:
java.io.Serializable, org.eclipse.ui.views.properties.IPropertySource
Direct Known Subclasses:
ComponentConnectionModel, StateConnectionModel

public abstract class ConnectionModel
extends ModelElement

A connection between two distinct shapes.

This software is distributed under the BSD License.

This code is partially based on code that is copyright (c) 2004 Elias Volanakis. See License.txt

Author:
Elias Volanakis, Michael Bernstein ( mbernst(AT)stanford.edu ), Bjoern Hartmann ( bjoern(AT)stanford.edu )
See Also:
Serialized Form

Field Summary
static java.lang.Integer DASHED_CONNECTION
          Used for indicating that a ConnectionModel with dashed line style should be created.
static java.lang.String INPUT_PROP
           
static java.lang.String LINESTYLE_PROP
          Property ID to use when the line style of this connection is modified.
static java.lang.Integer SOLID_CONNECTION
          Used for indicating that a ConnectionModel with solid line style should be created.
 
Constructor Summary
ConnectionModel()
           
ConnectionModel(ShapeModel source, ShapeModel target)
           
 
Method Summary
 void disconnect()
          Disconnect this connection from the shapes it is attached to.
 int getLineStyle()
          Returns the line drawing style of this connection.
 org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
          Returns the descriptor for the lineStyle property
 ShapeModel getSource()
          Returns the source endpoint of this connection.
 ShapeModel getTarget()
          Returns the target endpoint of this connection.
 void reconnect()
          Reconnect this connection.
 void reconnect(ShapeModel newSource, ShapeModel newTarget)
          Reconnect to a different source and/or target shape.
 void setLineStyle(int lineStyle)
          Set the line drawing style of this connection.
 void setSource(ShapeModel newSource)
           
 void setTarget(ShapeModel newTarget)
           
 
Methods inherited from class edu.stanford.hci.dtools.statechart.model.ModelElement
addPropertyChangeListener, getEditableValue, getPropertyValue, isPropertySet, removePropertyChangeListener, resetPropertyValue, setPropertyValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOLID_CONNECTION

public static final java.lang.Integer SOLID_CONNECTION
Used for indicating that a ConnectionModel with solid line style should be created.

See Also:
ShapeEditPart.createEditPolicies()

DASHED_CONNECTION

public static final java.lang.Integer DASHED_CONNECTION
Used for indicating that a ConnectionModel with dashed line style should be created.

See Also:
ShapeEditPart.createEditPolicies()

LINESTYLE_PROP

public static final java.lang.String LINESTYLE_PROP
Property ID to use when the line style of this connection is modified.

See Also:
Constant Field Values

INPUT_PROP

public static final java.lang.String INPUT_PROP
See Also:
Constant Field Values
Constructor Detail

ConnectionModel

public ConnectionModel(ShapeModel source,
                       ShapeModel target)

ConnectionModel

public ConnectionModel()
Method Detail

disconnect

public void disconnect()
Disconnect this connection from the shapes it is attached to.


getLineStyle

public int getLineStyle()
Returns the line drawing style of this connection.

Returns:
an int value (Graphics.LINE_DASH or Graphics.LINE_SOLID)

getPropertyDescriptors

public org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
Returns the descriptor for the lineStyle property

Specified by:
getPropertyDescriptors in interface org.eclipse.ui.views.properties.IPropertySource
Overrides:
getPropertyDescriptors in class ModelElement
See Also:
IPropertySource.getPropertyDescriptors()

getSource

public ShapeModel getSource()
Returns the source endpoint of this connection.

Returns:
a non-null ShapeModel instance

setSource

public void setSource(ShapeModel newSource)

getTarget

public ShapeModel getTarget()
Returns the target endpoint of this connection.

Returns:
a non-null ShapeModel instance

setTarget

public void setTarget(ShapeModel newTarget)

reconnect

public void reconnect()
Reconnect this connection. The connection will reconnect with the shapes it was previously attached to.


reconnect

public void reconnect(ShapeModel newSource,
                      ShapeModel newTarget)
Reconnect to a different source and/or target shape. The connection will disconnect from its current attachments and reconnect to the new source and target.

Parameters:
newSource - a new source endpoint for this connection (non null)
newTarget - a new target endpoint for this connection (non null)
Throws:
java.lang.IllegalArgumentException - if any of the paramers are null or newSource == newTarget

setLineStyle

public void setLineStyle(int lineStyle)
Set the line drawing style of this connection.

Parameters:
lineStyle - one of following values: Graphics.LINE_DASH or Graphics.LINE_SOLID
Throws:
java.lang.IllegalArgumentException - if lineStyle does not have one of the above values
See Also:
Graphics.LINE_DASH, Graphics.LINE_SOLID