net.sourceforge.swtlayeredgraph
Class SwtLayeredGraph

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.widgets.Canvas
                      extended by net.sourceforge.swtlayeredgraph.SwtLayeredGraph
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class SwtLayeredGraph
extends org.eclipse.swt.widgets.Canvas


Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
SwtLayeredGraph(org.eclipse.swt.widgets.Composite parent)
          Builds a new SwtLayeredGraph with the specified parent and SWT style.
SwtLayeredGraph(org.eclipse.swt.widgets.Composite parent, java.lang.Boolean useScrollBars)
           
 
Method Summary
 void addLayer(GraphLayer layer)
          Adds the specified layer to the graph.
 void addMouseMoveListener(GraphMouseListener listener)
          Adds a subscriber to the list of subscribers notified when the mouse is moved in the graph.
 GraphLayer createLayer(java.lang.String layerName)
          Creates a new layer with the specified name and adds it to the graph.
protected  void drawLayers(org.eclipse.swt.events.PaintEvent pe)
          Draws the individual layers.
 CoordinateType getCoordinateType()
           
 IGraphCursor getGraphCursor()
          Gets the current cursor for the canvas.
 IGraphGridLayer getGrid()
          Gets the current grid layer.
 LayerDrawable getItem(java.lang.String... paths)
          Gets the item specified by the path.
 GraphLayer getLayer(java.lang.String layerName)
          Gets the layer with the specified name.
 LayerContainer<GraphLayer> getLayerContainer()
          Gets the graph container.
 java.util.List<java.lang.String> getLayerNames()
          Gets the list of the name of all of the layers.
 java.util.List<GraphLayer> getLayers()
          Gets a copy of the list of layers.
 java.util.List<LayerDrawable> getSelectedItems()
          Gets a list of currently selected items.
 java.lang.Double getXScaleFactor()
          Gets the X scale factor.
 java.lang.Double getYScaleFactor()
          Gets the Y scale factor.
 void removeLayer(GraphLayer layer)
          Removes the specified layer.
 void removeLayer(java.lang.String layerName)
          Removes the specified layer.
 void removeMouseMoveListener(GraphMouseListener listener)
          Removes a subscriber from the list of subscribers notified when the mouse is moved in the graph.
 void setCoordinateType(CoordinateType newType)
           
 void setGraphCursor(IGraphCursor cursor)
          Sets the cursor to use on the canvas.
 void setGrid(IGraphGridLayer grid)
          Sets the current grid layer to the specified grid.
 void setScrollBarEnable(java.lang.Boolean enabled)
           
 void setXScaleFactor(java.lang.Double factor)
          Sets the X scale factor with 1.0 being 100%.
 void setYScaleFactor(java.lang.Double factor)
          Sets the Y scale factor with 1.0 being 100%.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwtLayeredGraph

public SwtLayeredGraph(org.eclipse.swt.widgets.Composite parent)
Builds a new SwtLayeredGraph with the specified parent and SWT style.

Parameters:
parent - Parent of this object.
style - SWT Style info.

SwtLayeredGraph

public SwtLayeredGraph(org.eclipse.swt.widgets.Composite parent,
                       java.lang.Boolean useScrollBars)
Method Detail

addLayer

public void addLayer(GraphLayer layer)
Adds the specified layer to the graph.

Parameters:
layer - Layer to add to the graph.
Throws:
java.lang.IllegalArgumentException - If layer is null.
DuplicateItemException - If a layer of the same name exists. Note that name comparisons are case sensitive.

createLayer

public GraphLayer createLayer(java.lang.String layerName)
Creates a new layer with the specified name and adds it to the graph.

Parameters:
layerName - Name of new layer.
Returns:
Returns new layer object that was created.
Throws:
java.lang.IllegalArgumentException - If layerName is empty or null.
DuplicateItemException - If a layer with the same name exists. Note that comparisons are case sensitive.

getLayer

public GraphLayer getLayer(java.lang.String layerName)
Gets the layer with the specified name.

Parameters:
layerName - Name of layer to return. Note that this comparison is case sensitive.
Returns:
Returns the specified layer if found, null if not found.
Throws:
java.lang.IllegalArgumentException - If layerName is null or empty.

getLayers

public java.util.List<GraphLayer> getLayers()
Gets a copy of the list of layers. This is not the actual list, but a shallow copy.

Returns:
Returns a shallow copy of the layer list.

getLayerNames

public java.util.List<java.lang.String> getLayerNames()
Gets the list of the name of all of the layers. This list is NOT ordered.

Returns:
Returns an unordered list of all layer names.

removeLayer

public void removeLayer(GraphLayer layer)
Removes the specified layer.

Parameters:
layer - Layer to remove.
Throws:
java.lang.IllegalArgumentException - If layer is null.

removeLayer

public void removeLayer(java.lang.String layerName)
Removes the specified layer.

Parameters:
layerName - Name of layer to remove.
Throws:
java.lang.IllegalArgumentException - If layerName is null.

getLayerContainer

public LayerContainer<GraphLayer> getLayerContainer()
Gets the graph container.

Returns:
Returns the graph container.

drawLayers

protected void drawLayers(org.eclipse.swt.events.PaintEvent pe)
Draws the individual layers.

Parameters:
pe - Event that contains the GC to draw on.

getGrid

public IGraphGridLayer getGrid()
Gets the current grid layer.

Returns:
Returns the current grid layer.

setGrid

public void setGrid(IGraphGridLayer grid)
Sets the current grid layer to the specified grid.

Parameters:
grid - New grid layer.
Throws:
java.lang.IllegalArgumentException - If grid is null.

getXScaleFactor

public java.lang.Double getXScaleFactor()
Gets the X scale factor.

Returns:
Returns the X scale factor.

getYScaleFactor

public java.lang.Double getYScaleFactor()
Gets the Y scale factor.

Returns:
Returns the Y scale factor.

setXScaleFactor

public void setXScaleFactor(java.lang.Double factor)
Sets the X scale factor with 1.0 being 100%. Causes the graph to be redrawn.

Parameters:
factor - New X scale factor.
Throws:
java.lang.IllegalArgumentException - If factor is null.

setYScaleFactor

public void setYScaleFactor(java.lang.Double factor)
Sets the Y scale factor with 1.0 being 100%. Causes the graph to be redrawn.

Parameters:
factor - New Y scale factor.
Throws:
java.lang.IllegalArgumentException - If factor is null.

getSelectedItems

public java.util.List<LayerDrawable> getSelectedItems()
Gets a list of currently selected items.

Returns:
Returns the clone list of currently selected items.

addMouseMoveListener

public void addMouseMoveListener(GraphMouseListener listener)
Adds a subscriber to the list of subscribers notified when the mouse is moved in the graph.

Parameters:
listener - New listener to be called.
Throws:
java.lang.IllegalArgumentException - If listener is null.

removeMouseMoveListener

public void removeMouseMoveListener(GraphMouseListener listener)
Removes a subscriber from the list of subscribers notified when the mouse is moved in the graph.

Parameters:
listener - Listener to be removed.
Throws:
java.lang.IllegalArgumentException - If listener is null.

setScrollBarEnable

public void setScrollBarEnable(java.lang.Boolean enabled)

setGraphCursor

public void setGraphCursor(IGraphCursor cursor)
Sets the cursor to use on the canvas.

Parameters:
cursor - Cursor to use when in canvas. If cursor is null, default OS cursor will be used.

getGraphCursor

public IGraphCursor getGraphCursor()
Gets the current cursor for the canvas.

Returns:
Returns current cursor for canvas or null if no cursor is defined.

setCoordinateType

public void setCoordinateType(CoordinateType newType)

getCoordinateType

public CoordinateType getCoordinateType()

getItem

public LayerDrawable getItem(java.lang.String... paths)
Gets the item specified by the path.

Parameters:
paths - Path to the item
Returns:
Returns the item at the end of the specified path.
Throws:
InvalidItemPathException - When an item does not exist on the specified path, or if the path is invalid.


Copyright © 2009. All Rights Reserved.