net.sourceforge.swtlayeredgraph
Class LayerDrawable

java.lang.Object
  extended by net.sourceforge.swtlayeredgraph.LayerDrawable
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LayerGroup, SampleShape

public abstract class LayerDrawable
extends java.lang.Object
implements java.io.Serializable

Defines a base class for all objects that can be drawn on the layered graph. When creating your own shape, you need to make sure that you add the points that define the extents of your object. As long as you provide valid points, the extents will be automatically calculated for you.

Author:
davija
See Also:
Serialized Form

Field Summary
protected  LayerComponentType componentType
           
protected  java.util.List<GraphPoint> extentPointList
           
 
Constructor Summary
LayerDrawable()
          Default constructor.
LayerDrawable(java.lang.String name)
          Creates a new LayerDrawable object with the specified name.
 
Method Summary
 void addExtentChangeListener(ExtentChangeListener listener)
          Adds the specified listener to the list of those notified when an extent change happens.
 void addExtentPoint(GraphPoint point)
          Adds a point to the list used to calculate extents.
 void addNameChangeListner(NameChangeListener listener)
          Adds the specified listener to the list of those notified when a name change is requested.
 void clearExtents()
          Clears the list of points used for extent calculation.
abstract  void draw(GCTransformer transformer)
          Draws this object on the GC in the transformer.
abstract  void drawHover(GCTransformer transformer)
          Draws this object, as an object that has the mouse over it, on the GC in the transformer.
abstract  void drawSelected(GCTransformer transformer)
          Draws this object, as a selected object, on the GC in the transformer.
 GraphRectangle getExtents()
          Calculates the minimum GraphRectangle that fully contains this object.
 java.lang.String getName()
          Gets the name of this object.
 void handleMouseDoubleClick(org.eclipse.swt.widgets.Event e, GraphPoint point)
          Handles a mouse double click on this object.
 void handleMouseDown(org.eclipse.swt.widgets.Event e, GraphPoint graphPoint)
          Handles a mouse down event on this object.
 void handleMouseMove(org.eclipse.swt.widgets.Event e, GraphPoint point)
          Handles a mouse movement on this object.
 void handleMouseUp(org.eclipse.swt.widgets.Event e, GraphPoint point)
          Handles a mouse up event on this object.
 java.lang.Boolean isDirty()
          Checks if this object is dirty.
 java.lang.Boolean isDrawable()
          Checks if this item is a DRAWABLE.
 java.lang.Boolean isFocused()
          Checks if this object is currently focused or not.
 java.lang.Boolean isGroup()
          Checks if this item is a GROUP.
 java.lang.Boolean isLayer()
          Checks if this item is a LAYER.
 java.lang.Boolean isSelected()
          Checks if this object is selected or not.
 java.lang.Boolean isVisible()
          Checks if this object is visible.
abstract  void move(java.lang.Double dx, java.lang.Double dy, CoordinateType type)
          Moves the object by the specified x and y deltas.
protected  void recalculateExtents()
          Recalculates the extents based off of the point list.
 void removeExtentChangeListener(ExtentChangeListener listener)
          Removes the specified listener from the list of those notified when an extent change happens.
 void removeNameChangeListener(NameChangeListener listener)
          Removes the specified listener from the list of those notified when a name change is requested.
 void setDirty(java.lang.Boolean isDirty)
          Sets the dirty flag for this object.
 void setFocused(java.lang.Boolean focused)
          Sets the current focus status of this object.
 java.lang.Boolean setName(java.lang.String name)
          Sets the name of this object.
 void setSelected(java.lang.Boolean selected)
          Sets the selected flag on this object.
 void setVisible(java.lang.Boolean visible)
          Sets the visible flag on this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentType

protected LayerComponentType componentType

extentPointList

protected java.util.List<GraphPoint> extentPointList
Constructor Detail

LayerDrawable

public LayerDrawable()
Default constructor.


LayerDrawable

public LayerDrawable(java.lang.String name)
Creates a new LayerDrawable object with the specified name.

Parameters:
name - Name of this object.
Throws:
Throws - IllegalArgumentException when name is null.
Method Detail

draw

public abstract void draw(GCTransformer transformer)
Draws this object on the GC in the transformer.

Parameters:
transformer - GC Transformer for the device to draw on.
Throws:
Throws - IllegalArgumentException when transformer is null.

drawHover

public abstract void drawHover(GCTransformer transformer)
Draws this object, as an object that has the mouse over it, on the GC in the transformer.

Parameters:
transformer - GC Transformer for the device to draw on.
Throws:
Throws - IllegalArgumentException when transformer is null.

drawSelected

public abstract void drawSelected(GCTransformer transformer)
Draws this object, as a selected object, on the GC in the transformer.

Parameters:
transformer - GC Transformer for the device to draw on.
Throws:
Throws - IllegalArgumentException when transformer is null.

move

public abstract void move(java.lang.Double dx,
                          java.lang.Double dy,
                          CoordinateType type)
Moves the object by the specified x and y deltas. Deltas are passed in the coordinate system specified by type.

Parameters:
dx - X Delta
dy - Y Delta
type - Type of coordinate system for X & Y

recalculateExtents

protected void recalculateExtents()
Recalculates the extents based off of the point list. Also notifies listeners of the change.


getExtents

public GraphRectangle getExtents()
Calculates the minimum GraphRectangle that fully contains this object.

Returns:
Returns the minimal GraphRectangle that fully contains this object.

getName

public java.lang.String getName()
Gets the name of this object.

Returns:
Returns the name of this object.

setName

public java.lang.Boolean setName(java.lang.String name)
Sets the name of this object. Before the name is changed, it notifies all observers for validation. If an observer reports the name is invalid (returns false), the name change is aborted.

Parameters:
name - Name for this object.
Returns:
Returns true if changed, false otherwise.
Throws:
Throws - IllegalArgumentException when name is null.

addNameChangeListner

public void addNameChangeListner(NameChangeListener listener)
Adds the specified listener to the list of those notified when a name change is requested.

Parameters:
listener - Listener to call when name change request is made.
Throws:
java.lang.IllegalArgumentException - when listener is null.

removeNameChangeListener

public void removeNameChangeListener(NameChangeListener listener)
Removes the specified listener from the list of those notified when a name change is requested.

Parameters:
listener - Listener to remove.
Throws:
java.lang.IllegalArgumentException - When listener is null.

addExtentChangeListener

public void addExtentChangeListener(ExtentChangeListener listener)
Adds the specified listener to the list of those notified when an extent change happens.

Parameters:
listener - Listener to call when extents change.
Throws:
java.lang.IllegalArgumentException - When listener is null.

removeExtentChangeListener

public void removeExtentChangeListener(ExtentChangeListener listener)
Removes the specified listener from the list of those notified when an extent change happens.

Parameters:
listener - Listener to remove.
Throws:
java.lang.IllegalArgumentException - when listener is null.

isFocused

public java.lang.Boolean isFocused()
Checks if this object is currently focused or not.

Returns:
Returns true if focused, false otherwise.

setFocused

public void setFocused(java.lang.Boolean focused)
Sets the current focus status of this object.

Parameters:
focused - New focus value to set.
Throws:
java.lang.IllegalArgumentException - When focused is null.

isSelected

public java.lang.Boolean isSelected()
Checks if this object is selected or not.

Returns:
Returns true if selected, false otherwise.

setSelected

public void setSelected(java.lang.Boolean selected)
Sets the selected flag on this object.

Parameters:
selected - Value for selected flag.
Throws:
java.lang.IllegalArgumentException - When selected is null.

isVisible

public java.lang.Boolean isVisible()
Checks if this object is visible.

Returns:
Returns true if visible, false otherwise.

setVisible

public void setVisible(java.lang.Boolean visible)
Sets the visible flag on this object.

Parameters:
visible - Value for visible flag.
Throws:
java.lang.IllegalArgumentException - When visible is null.

isDrawable

public java.lang.Boolean isDrawable()
Checks if this item is a DRAWABLE.

Returns:
True if type is DRAWABLE, false otherwise.

isGroup

public java.lang.Boolean isGroup()
Checks if this item is a GROUP.

Returns:
True if type is GROUP, false otherwise.

isLayer

public java.lang.Boolean isLayer()
Checks if this item is a LAYER.

Returns:
True if type is LAYER, false otherwise.

handleMouseUp

public void handleMouseUp(org.eclipse.swt.widgets.Event e,
                          GraphPoint point)
Handles a mouse up event on this object.

Parameters:
e - SWT Event that was fired.
point - Location where mouse was as a GraphPoint.

handleMouseDown

public void handleMouseDown(org.eclipse.swt.widgets.Event e,
                            GraphPoint graphPoint)
Handles a mouse down event on this object.

Parameters:
e - SWT Event that was fired.
point - Location where mouse was as a GraphPoint.

handleMouseDoubleClick

public void handleMouseDoubleClick(org.eclipse.swt.widgets.Event e,
                                   GraphPoint point)
Handles a mouse double click on this object.

Parameters:
e - SWT Event that was fired.
point - Location where mouse was as a GraphPoint.

handleMouseMove

public void handleMouseMove(org.eclipse.swt.widgets.Event e,
                            GraphPoint point)
Handles a mouse movement on this object.

Parameters:
e - SWT Event that was fired.
point - Location where mouse was as a GraphPoint.

isDirty

public java.lang.Boolean isDirty()
Checks if this object is dirty.

Returns:
Returns true if dirty, false otherwise.

setDirty

public void setDirty(java.lang.Boolean isDirty)
Sets the dirty flag for this object.

Parameters:
isDirty - Value to set for dirty flag.

clearExtents

public void clearExtents()
Clears the list of points used for extent calculation.


addExtentPoint

public void addExtentPoint(GraphPoint point)
Adds a point to the list used to calculate extents.

Parameters:
point - Point to be used in extent calculation.
Throws:
java.lang.IllegalArgumentException - if point is null.


Copyright © 2009. All Rights Reserved.