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

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

public abstract class ShapeModel
extends ModelElement

Abstract prototype of a shape. Has a size (width and height), a location (x and y position) and a list of incoming and outgoing connections. Use subclasses to instantiate a specific shape.

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

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
, Serialized Form

Field Summary
static java.lang.String DIAGRAM_PROP
          Property ID to use when a Diagram Model is attached to this shape
static java.lang.String LOCATION_PROP
          Property ID to use when the location of this shape is modified.
static java.lang.String SIZE_PROP
          Property ID to use then the size of this shape is modified.
static java.lang.String SOURCE_CONNECTIONS_PROP
          Property ID to use when the list of outgoing connections is modified.
static java.lang.String TARGET_CONNECTIONS_PROP
          Property ID to use when the list of incoming connections is modified.
 
Constructor Summary
ShapeModel()
           
 
Method Summary
static org.eclipse.swt.graphics.Image createImage(java.lang.String name)
          How to get an image out of a local project directory
 DiagramModel getDiagramModel()
          Retrieve the DiagramModel that this shape is a child of.
abstract  org.eclipse.swt.graphics.Image getIcon()
          Return a pictogram (small icon) describing this model element.
 org.eclipse.draw2d.geometry.Point getLocation()
          Return the Location of this shape.
 org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
          Returns an array of IPropertyDescriptors for this shape.
 java.lang.Object getPropertyValue(java.lang.Object propertyId)
          Return the property value for the given propertyId, or null.
 org.eclipse.draw2d.geometry.Dimension getSize()
          Return the Size of this shape.
 java.util.List<ConnectionModel> getSourceConnections()
          Return a List of outgoing Connections.
 java.util.List<ConnectionModel> getTargetConnections()
          Return a List of incoming Connections.
 void setDiagramModel(DiagramModel newDiagram)
          Sets the diagram associated with this shape.
 void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
          Set the Location of this shape.
 void setPropertyValue(java.lang.Object propertyId, java.lang.Object value)
          Set the property value for the given property id.
 void setSize(org.eclipse.draw2d.geometry.Dimension newSize)
          Set the Size of this shape.
 
Methods inherited from class edu.stanford.hci.dtools.statechart.model.ModelElement
addPropertyChangeListener, getEditableValue, isPropertySet, removePropertyChangeListener, resetPropertyValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_PROP

public static final java.lang.String LOCATION_PROP
Property ID to use when the location of this shape is modified.

See Also:
Constant Field Values

SIZE_PROP

public static final java.lang.String SIZE_PROP
Property ID to use then the size of this shape is modified.

See Also:
Constant Field Values

DIAGRAM_PROP

public static final java.lang.String DIAGRAM_PROP
Property ID to use when a Diagram Model is attached to this shape

See Also:
Constant Field Values

SOURCE_CONNECTIONS_PROP

public static final java.lang.String SOURCE_CONNECTIONS_PROP
Property ID to use when the list of outgoing connections is modified.

See Also:
Constant Field Values

TARGET_CONNECTIONS_PROP

public static final java.lang.String TARGET_CONNECTIONS_PROP
Property ID to use when the list of incoming connections is modified.

See Also:
Constant Field Values
Constructor Detail

ShapeModel

public ShapeModel()
Method Detail

createImage

public static org.eclipse.swt.graphics.Image createImage(java.lang.String name)
How to get an image out of a local project directory


getIcon

public abstract org.eclipse.swt.graphics.Image getIcon()
Return a pictogram (small icon) describing this model element. Children should override this method and return an appropriate Image.

Returns:
a 16x16 Image or null

getLocation

public org.eclipse.draw2d.geometry.Point getLocation()
Return the Location of this shape.

Returns:
a non-null location instance

getPropertyDescriptors

public org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
Returns an array of IPropertyDescriptors for this shape.

The returned array is used to fill the property view, when the edit-part corresponding to this model element is selected.

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

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object propertyId)
Return the property value for the given propertyId, or null.

The property view uses the IDs from the IPropertyDescriptors array to obtain the value of the corresponding properties.

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

getSize

public org.eclipse.draw2d.geometry.Dimension getSize()
Return the Size of this shape.

Returns:
a non-null Dimension instance

getSourceConnections

public java.util.List<ConnectionModel> getSourceConnections()
Return a List of outgoing Connections.


getTargetConnections

public java.util.List<ConnectionModel> getTargetConnections()
Return a List of incoming Connections.


setLocation

public void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
Set the Location of this shape.

Parameters:
newLocation - a non-null Point instance
Throws:
java.lang.IllegalArgumentException - if the parameter is null

setPropertyValue

public void setPropertyValue(java.lang.Object propertyId,
                             java.lang.Object value)
Set the property value for the given property id. If no matching id is found, the call is forwarded to the superclass.

The property view uses the IDs from the IPropertyDescriptors array to set the values of the corresponding properties.

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

setSize

public void setSize(org.eclipse.draw2d.geometry.Dimension newSize)
Set the Size of this shape. Will not modify the size if newSize is null.

Parameters:
newSize - a non-null Dimension instance or null

getDiagramModel

public DiagramModel getDiagramModel()
Retrieve the DiagramModel that this shape is a child of.

Returns:

setDiagramModel

public void setDiagramModel(DiagramModel newDiagram)
Sets the diagram associated with this shape. Should only be called once, when creating the shape. Shapes should not jump around between diagram models.