uk.ac.ic.doc.automed.p2p.gui.graph
Class GraphComponent

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.gui.graph.GShape
      extended by uk.ac.ic.doc.automed.p2p.gui.graph.GraphComponent
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, GVisualisable
Direct Known Subclasses:
EclipseAndANodeComponent, FreePathComponent, GConstraint, GScriptedShape, HubComponent, PathComponent, PolygonComponent, SemiPolygonComponent, SimpleGraphComponent, TableComponent

public abstract class GraphComponent
extends GShape
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  GShape atShape
           
private  java.util.Vector edges
           
protected  boolean grouped
           
private  java.util.Vector nodes
           
protected  java.awt.Point prevPoint
           
private static long serialVersionUID
           
 
Fields inherited from class uk.ac.ic.doc.automed.p2p.gui.graph.GShape
altDrawer, altDrawing, AUTO_COUNT, bound, brPoint, centrePoint, changed, color, cshape, data, defBound, displayScript, displayShape, enabled, handler, highlighted, hshape, icon, id, label, lblPoint, movable, name, onClick, PREFIX_CTRL, PREFIX_HIL, props, refresh, selectable, tlPoint, type, visible, visibleOnHighlighted, ZEROX
 
Constructor Summary
protected GraphComponent()
           
protected GraphComponent(java.lang.String label)
           
  GraphComponent(java.lang.String label, GShape atShape, java.awt.Dimension bound, GNode[] nodes, java.util.Properties props)
           
  GraphComponent(java.lang.String label, GShape atShape, java.awt.Dimension bound, java.util.Properties props)
           
  GraphComponent(java.lang.String label, java.awt.Point tlPoint, java.awt.Dimension bound, GNode[] nodes, java.util.Properties props)
           
  GraphComponent(java.lang.String label, java.awt.Point atPoint, java.awt.Dimension bound, java.util.Properties props)
           
  GraphComponent(java.lang.String label, java.util.Properties props)
           
 
Method Summary
 void addEdge(GEdge ge)
          Add an edge to this component
 void addNode(GNode gn)
          Add a node to this component
 void addNodes(GNode[] nodes, java.awt.Graphics g)
          Add some more nodes to this component
 boolean contains(GShape shape)
          Check that this component contains this shape
protected  void drawAfter(java.awt.Graphics g)
          Other drawing after the main drawing is performed
 void drawAt(GNode atNode, java.awt.Graphics g)
          Draw this component at a given node on the graph
protected  void drawBefore(java.awt.Graphics g)
          Drawings that are performed before the main drawing
protected  void drawBound(java.awt.Graphics g, java.util.Collection nodes, double boundWidth)
          Draw a transparent layer which is bounded by a set of nodes
protected  void drawMain(java.awt.Graphics g)
          The main body of the drawing method
protected  void drawOverlay(java.awt.Graphics g, int[] xs, int[] ys)
          Draw a transparent layer which is bounded by a set of nodes
 void drawTo(java.awt.Graphics g, GShape targetShape)
          This method works similar to the native drawMain() except that it operates with the nodes, edges and properties of a different shape rather than those of its own.
 boolean equals(java.lang.Object otherShape)
          Compare two shapes based on their type and coordinate and bounding box
protected  java.awt.Point getBaseCenterPoint()
          Return the centre point of the base shape (if one was specified)
protected  java.awt.Point getBasePoint()
          Return the top-left corner of the base shape (if one was specified)
 boolean getBooleanProperty(java.lang.String name)
           
 java.awt.Dimension getBound()
          The bounding box
 java.util.Vector getEdges()
           
 GEdge[] getEdges(GNode n)
          Return edges that are linked to a given node
 GEdge[] getEdgesArray()
          Return all edges
 boolean getIsGrouped()
           
 java.util.Vector getNodes()
           
 GNode[] getNodesArray()
           
 double getNumericProperty(java.lang.String name)
           
 java.lang.String getProperty(java.lang.String name)
           
 java.util.Collection getShapes()
           
 GShape[] getShapesArray()
          Return all shapes that are contained in this component
protected  java.util.Collection getShapesForUpdate()
           
protected  void init()
          Initialise data for this component
 void redraw(java.awt.Graphics g)
          Redraw a graph component at repaint
protected  void redrawMain(java.awt.Graphics g)
          The main body of redraw
 java.util.Collection removeShape(GShape shape)
           
 void setEdges(java.util.Collection edges)
           
protected  void setEdgesArray(GEdge[] edges)
           
 void setIsChanged(boolean changed)
          For a graph component, when it is changed we also set the change status of all of its children
 void setIsGrouped(boolean grouped)
           
 void setIsVisible(boolean visible)
           
 void setNodes(java.util.Collection nodes)
           
 void setNodesArray(GNode[] nodes)
           
protected  void setUp(java.awt.Graphics g, GShape shape)
          Set up the nodes and edges of this shape.
protected  void update()
          Update the coordinates of all children shapes when a bases shape is moved
protected  void updateBound()
           
protected  void updateControl()
           
protected  void updateHighlighted()
           
 
Methods inherited from class uk.ac.ic.doc.automed.p2p.gui.graph.GShape
clear, clear, contains, contains, contains, contains, copyProperties, cos, dcos, draw, drawAlternative, drawControl, drawHighlighted, dsin, dtan, getAutoID, getBounds, getBounds2D, getBrPoint, getCenter, getColor, getData, getDefaultBound, getDrawerInstance, getHandlerObject, getID, getIDShape, getIsVisible, getIsVisibleOnHighlighted, getLabel, getLabelBounds, getLabelPoint, getName, getPathIterator, getPathIterator, getPoint, getProperties, getProperty, getPropertyObject, getPropertyObjects, getStringBounds, getType, hashCode, highlightLabel, highlightLabel, intersects, intersects, isActive, isAltDrawing, isChanged, isEnabled, isHighlighted, isMovable, isMutableColor, isOnClick, isRefresh, isSelectable, newDrawerInstance, paintBlank, preDraw, preDraw, redrawAfter, redrawBefore, refresh, setBound, setBound, setColorProperty, setColorProperty, setColorProperty, setEnabled, setHandlerObject, setIsAltDrawing, setIsHighlighted, setIsMovable, setIsOnClick, setIsRefresh, setIsSelectable, setLabel, setName, setProperties, setProperty, setPropertyObject, setStrokeStyle, setTLPoint, setTLPoint, setType, setUpHighlightedShape, setVisibleOnHighlighted, sin, tan, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

nodes

private java.util.Vector nodes

edges

private java.util.Vector edges

atShape

protected GShape atShape

prevPoint

protected java.awt.Point prevPoint

grouped

protected boolean grouped
Constructor Detail

GraphComponent

protected GraphComponent()

GraphComponent

protected GraphComponent(java.lang.String label)

GraphComponent

public GraphComponent(java.lang.String label,
                      java.util.Properties props)

GraphComponent

public GraphComponent(java.lang.String label,
                      java.awt.Point atPoint,
                      java.awt.Dimension bound,
                      java.util.Properties props)

GraphComponent

public GraphComponent(java.lang.String label,
                      GShape atShape,
                      java.awt.Dimension bound,
                      GNode[] nodes,
                      java.util.Properties props)

GraphComponent

public GraphComponent(java.lang.String label,
                      GShape atShape,
                      java.awt.Dimension bound,
                      java.util.Properties props)

GraphComponent

public GraphComponent(java.lang.String label,
                      java.awt.Point tlPoint,
                      java.awt.Dimension bound,
                      GNode[] nodes,
                      java.util.Properties props)
Method Detail

setIsGrouped

public void setIsGrouped(boolean grouped)

getIsGrouped

public boolean getIsGrouped()

getBasePoint

protected java.awt.Point getBasePoint()
Return the top-left corner of the base shape (if one was specified)

Returns:

getBaseCenterPoint

protected java.awt.Point getBaseCenterPoint()
Return the centre point of the base shape (if one was specified)

Returns:

init

protected void init()
Initialise data for this component


drawAt

public void drawAt(GNode atNode,
                   java.awt.Graphics g)
Draw this component at a given node on the graph

Parameters:
atNode -
g -

getProperty

public java.lang.String getProperty(java.lang.String name)
Overrides:
getProperty in class GShape

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)

getNumericProperty

public double getNumericProperty(java.lang.String name)

getShapesForUpdate

protected java.util.Collection getShapesForUpdate()

getNodes

public java.util.Vector getNodes()

getNodesArray

public GNode[] getNodesArray()

getEdgesArray

public GEdge[] getEdgesArray()
Return all edges

Returns:

getEdges

public java.util.Vector getEdges()

setIsVisible

public void setIsVisible(boolean visible)
Overrides:
setIsVisible in class GShape

getEdges

public GEdge[] getEdges(GNode n)
Return edges that are linked to a given node

Parameters:
n -
Returns:

setEdges

public void setEdges(java.util.Collection edges)

setNodesArray

public void setNodesArray(GNode[] nodes)

setNodes

public void setNodes(java.util.Collection nodes)

setEdgesArray

protected void setEdgesArray(GEdge[] edges)

getShapes

public java.util.Collection getShapes()

getShapesArray

public GShape[] getShapesArray()
Return all shapes that are contained in this component

Returns:

setIsChanged

public void setIsChanged(boolean changed)
For a graph component, when it is changed we also set the change status of all of its children

Overrides:
setIsChanged in class GShape

getBound

public java.awt.Dimension getBound()
Description copied from class: GShape
The bounding box

Overrides:
getBound in class GShape

contains

public boolean contains(GShape shape)
Check that this component contains this shape

Parameters:
shape -
Returns:

removeShape

public java.util.Collection removeShape(GShape shape)

update

protected void update()
Update the coordinates of all children shapes when a bases shape is moved

Overrides:
update in class GShape

updateHighlighted

protected void updateHighlighted()
Overrides:
updateHighlighted in class GShape

updateControl

protected void updateControl()
Overrides:
updateControl in class GShape

updateBound

protected void updateBound()

redraw

public void redraw(java.awt.Graphics g)
Redraw a graph component at repaint

Overrides:
redraw in class GShape

drawBefore

protected void drawBefore(java.awt.Graphics g)
Drawings that are performed before the main drawing

Overrides:
drawBefore in class GShape
Parameters:
g -

drawMain

protected void drawMain(java.awt.Graphics g)
The main body of the drawing method

Overrides:
drawMain in class GShape
Parameters:
g -

redrawMain

protected void redrawMain(java.awt.Graphics g)
The main body of redraw

Overrides:
redrawMain in class GShape
Parameters:
g -

drawAfter

protected void drawAfter(java.awt.Graphics g)
Other drawing after the main drawing is performed

Overrides:
drawAfter in class GShape
Parameters:
g -

drawOverlay

protected void drawOverlay(java.awt.Graphics g,
                           int[] xs,
                           int[] ys)
Draw a transparent layer which is bounded by a set of nodes

Parameters:
g -
nodes -

drawBound

protected void drawBound(java.awt.Graphics g,
                         java.util.Collection nodes,
                         double boundWidth)
Draw a transparent layer which is bounded by a set of nodes

Parameters:
g -
nodes -

addNode

public void addNode(GNode gn)
Add a node to this component

Parameters:
nodes -
g -

addEdge

public void addEdge(GEdge ge)
Add an edge to this component

Parameters:
nodes -
g -

addNodes

public void addNodes(GNode[] nodes,
                     java.awt.Graphics g)
Add some more nodes to this component

Parameters:
nodes -
g -

drawTo

public void drawTo(java.awt.Graphics g,
                   GShape targetShape)
This method works similar to the native drawMain() except that it operates with the nodes, edges and properties of a different shape rather than those of its own.
This method therefore provides a way to 'export' the drawing technique of a given shape to be used for other shapes.

Overrides:
drawTo in class GShape
Parameters:
g -
targetShape -

setUp

protected void setUp(java.awt.Graphics g,
                     GShape shape)
Set up the nodes and edges of this shape. This method is called just before the actual rendering so that the coordinates of the shape elements can be determined and be made ready for drawing.

Parameters:
g -
shape -

equals

public boolean equals(java.lang.Object otherShape)
Description copied from class: GShape
Compare two shapes based on their type and coordinate and bounding box

Overrides:
equals in class GShape