edu.stanford.hci.dtools.deviceeditor.components
Class DeviceModel

java.lang.Object
  extended by edu.stanford.hci.dtools.statechart.model.ModelElement
      extended by edu.stanford.hci.dtools.deviceeditor.components.DeviceModel
All Implemented Interfaces:
java.io.Serializable, org.eclipse.ui.views.properties.IPropertySource

public class DeviceModel
extends ModelElement

The component (=model) for a device in the DeviceEditor

This software is distributed under the BSD License.

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

Field Summary
static java.lang.String IMAGE_PROP
          ID for the image property value (used for by the corresponding property descriptor).
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.
 
Constructor Summary
DeviceModel()
           
DeviceModel(DeviceModel copy)
           
 
Method Summary
 DeviceDiagramModel getDiagramComponent()
          Retrieve the DiagramModel that this shape is a child of.
 org.eclipse.swt.graphics.Image getIcon()
          Icon for the tree
 java.lang.String getImageFilename()
           
 org.eclipse.draw2d.geometry.Point getLocation()
           
 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()
           
 void setDiagramComponent(DeviceDiagramModel newDiagram)
          Sets the diagram associated with this shape.
 void setImageFilename(java.lang.String filename)
          Set the image file in the background of the device
 void setLocation(org.eclipse.draw2d.geometry.Point newLoc)
          Set the location (X,Y) of the device outline
 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.
 java.lang.String toString()
           
 
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, wait, wait, wait
 

Field Detail

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

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

IMAGE_PROP

public static final java.lang.String IMAGE_PROP
ID for the image property value (used for by the corresponding property descriptor).

See Also:
Constant Field Values
Constructor Detail

DeviceModel

public DeviceModel()

DeviceModel

public DeviceModel(DeviceModel copy)
Method Detail

setImageFilename

public void setImageFilename(java.lang.String filename)
Set the image file in the background of the device

Parameters:
newFile -

getImageFilename

public java.lang.String getImageFilename()

getIcon

public org.eclipse.swt.graphics.Image getIcon()
Icon for the tree

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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

getSize

public org.eclipse.draw2d.geometry.Dimension getSize()

getLocation

public org.eclipse.draw2d.geometry.Point getLocation()

setLocation

public void setLocation(org.eclipse.draw2d.geometry.Point newLoc)
Set the location (X,Y) of the device outline

Parameters:
newLoc -

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()

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()

getDiagramComponent

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

Returns:

setDiagramComponent

public void setDiagramComponent(DeviceDiagramModel 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.