auc.simulator.simitems
Class SimItemAdapter

java.lang.Object
  |
  +--auc.simulator.simitems.SimItemAdapter
All Implemented Interfaces:
SimItem
Direct Known Subclasses:
SimField, SimImplement, SimManager, SimOperator, SimPlatform

public abstract class SimItemAdapter
extends java.lang.Object
implements SimItem

The base class for the simulated items.


Field Summary
protected  javax.swing.Action mAction
          Action to be performed when user double clicks on the object in the simulator.
protected  java.awt.Shape mBounds
          Bounding region of the simulated item.
protected  CoordManageable mCoordProvider
          Component on which the simulator item has to be drawn.
protected  boolean mDraggable
          Flag indicating whether this object can be dragged.
protected  java.lang.String mName
          The title name of the item.
protected  java.awt.Point mSelectionPoint
          If the item was selected with a mouse, the mouse press point is savded in this variable.
 
Constructor Summary
SimItemAdapter(CoordManageable coordProvider, java.lang.String name, java.awt.Shape bounds)
          Construction.
 
Method Summary
 java.awt.Shape getBounds()
          Returns the region bounds of this item.
protected  java.awt.Point getCenterPoint()
          Returns center point in absolute coordinates.
 CoordManager getCoordManager()
          Returns the coordinate manager for drawing.
 java.lang.String getName()
          Returns the title name of the item.
protected  java.awt.Rectangle getSelectionBounds()
          Return bounds of selecting rectangle.
 boolean isDraggable()
          Checks whether this object can be dragged in the simulator.
 boolean isSelected()
          Status of item selection on GUI.
abstract  void paint(java.awt.Graphics g)
          Painting of the item has to be overriden with subclasses.
 void paintSelection(java.awt.Graphics g)
          Default selection painting for simulated items (draws a stroked rectangle over the bounds of the item).
 void performAction()
          Perform action associated with this object.
 void selectSubItem()
          Called when a selection occurs to select any sub-items the item has.
 void setAction(javax.swing.Action action)
          Change the action associated with this object.
 void setBounds(java.awt.Shape bounds)
          Sets the region bounds of this item.
 void setDraggable(boolean drag)
          Set wether this object can be dragged in the simulator.
 void setName(java.lang.String name)
          Sets the title name of the item.
 void setSelected(boolean selected)
          Sets the status of item selection on GUI.
 void setSelected(boolean mSelected, java.awt.Point selectionPoint)
          Sets the selection status (from the mouse).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBounds

protected java.awt.Shape mBounds
Bounding region of the simulated item.

mCoordProvider

protected CoordManageable mCoordProvider
Component on which the simulator item has to be drawn.

mName

protected java.lang.String mName
The title name of the item.

mSelectionPoint

protected java.awt.Point mSelectionPoint
If the item was selected with a mouse, the mouse press point is savded in this variable.

mDraggable

protected boolean mDraggable
Flag indicating whether this object can be dragged. By default all objects are draggable.

mAction

protected javax.swing.Action mAction
Action to be performed when user double clicks on the object in the simulator.
Constructor Detail

SimItemAdapter

public SimItemAdapter(CoordManageable coordProvider,
                      java.lang.String name,
                      java.awt.Shape bounds)
Construction.
Parameters:
coordProvider - component on which this item has to be drawn.
name - the title name of the item.
bounds - bounding region of the item on the drawing area.
Method Detail

getBounds

public java.awt.Shape getBounds()
Returns the region bounds of this item.
Specified by:
getBounds in interface SimItem
Returns:
the shape bounding the region of the item.

setBounds

public void setBounds(java.awt.Shape bounds)
Sets the region bounds of this item.
Specified by:
setBounds in interface SimItem
Parameters:
bounds - the shape bounding the region of the item.

getName

public java.lang.String getName()
Returns the title name of the item.
Specified by:
getName in interface SimItem
Returns:
the title name of the item.

setName

public void setName(java.lang.String name)
Sets the title name of the item.
Specified by:
setName in interface SimItem
Parameters:
name - the title name of the item.

getCoordManager

public CoordManager getCoordManager()
Returns the coordinate manager for drawing.
Returns:
coordinate manager for drawing.

isSelected

public boolean isSelected()
Status of item selection on GUI.
Specified by:
isSelected in interface SimItem
Returns:
selection status.

setSelected

public void setSelected(boolean selected)
Sets the status of item selection on GUI.
Specified by:
setSelected in interface SimItem
Parameters:
selected - selection status.

setSelected

public void setSelected(boolean mSelected,
                        java.awt.Point selectionPoint)
Sets the selection status (from the mouse).
Specified by:
setSelected in interface SimItem
Parameters:
selectionPoint - the mouse press event point that selected this item.

paint

public abstract void paint(java.awt.Graphics g)
Painting of the item has to be overriden with subclasses.
Specified by:
paint in interface SimItem
Parameters:
g - the graphics context for drawing.

paintSelection

public void paintSelection(java.awt.Graphics g)
Default selection painting for simulated items (draws a stroked rectangle over the bounds of the item).
Specified by:
paintSelection in interface SimItem
Parameters:
g - the graphics context for drawing.

getSelectionBounds

protected java.awt.Rectangle getSelectionBounds()
Return bounds of selecting rectangle. Rectangle vertex coordinates have ablsolute values.

getCenterPoint

protected java.awt.Point getCenterPoint()
Returns center point in absolute coordinates.

selectSubItem

public void selectSubItem()
Called when a selection occurs to select any sub-items the item has. Should be overriden by subclasses that have sub-items in them.
Specified by:
selectSubItem in interface SimItem

isDraggable

public boolean isDraggable()
Checks whether this object can be dragged in the simulator. Object are draggable by default.
Specified by:
isDraggable in interface SimItem
Returns:
true, if this object can be dragged to another location; false otherwise.

setDraggable

public void setDraggable(boolean drag)
Set wether this object can be dragged in the simulator.
Specified by:
setDraggable in interface SimItem
Parameters:
drag - true, if boject can dragged, false otherwise.

performAction

public void performAction()
Perform action associated with this object.
Specified by:
performAction in interface SimItem

setAction

public void setAction(javax.swing.Action action)
Change the action associated with this object. Tha action is performed when user double clicks on the object in the simulator.
Specified by:
setAction in interface SimItem
Parameters:
action - new action.