org.wilmascope.view
Class GraphElementView

java.lang.Object
  extended by org.wilmascope.patterns.Prototype
      extended by org.wilmascope.view.GraphElementView
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Viewable
Direct Known Subclasses:
EdgeView, NodeView

public abstract class GraphElementView
extends Prototype
implements Viewable

GraphElementView defines the methods and interfaces required for Edge and Node views that implement this to be registered as prototypes in the ViewManager

See Also:
Serialized Form

Field Summary
protected  javax.media.j3d.Transform3D t3d
           
 
Constructor Summary
GraphElementView()
           
 
Method Summary
protected  void addLabel(java.lang.String text, double scale, javax.vecmath.Point3f originPosition, javax.vecmath.Vector3f vTranslation, javax.media.j3d.Appearance apText)
          add a label to the element
protected  void addLiveBranch(javax.media.j3d.BranchGroup b)
           
 void addPickingClient(PickingClient client)
          Register a PickingClient whose PickingClient.callback(java.awt.event.MouseEvent)method will be called when the element is clicked
protected  void addShape(javax.media.j3d.Shape3D shape)
          Add a visible Shape3D to this Graph Element.
 void addTransformGroupChild(javax.media.j3d.Node node)
          add a scene graph node to this graph element's transform group
 void defaultColour()
           
 void delete()
          Make it go away, for the last time!
 javax.media.j3d.Appearance getAppearance()
           
static javax.vecmath.AxisAngle4f getAxisAngle4f(javax.vecmath.Vector3f init, javax.vecmath.Vector3f target)
           
 javax.media.j3d.BranchGroup getBranchGroup()
           
 javax.vecmath.Color3f getColor3f()
           
 java.awt.Color getColour()
           
 java.awt.Color getDefaultColour()
           
 GraphCanvas getGraphCanvas()
           
abstract  javax.swing.ImageIcon getIcon()
           
 java.lang.String getLabel()
           
 java.util.Properties getProperties()
           
 javax.media.j3d.TransformGroup getTransformGroup()
           
 java.lang.Object getUserData()
           
 void hide()
           
 void highlightColour()
           
protected abstract  void init()
          you must over-ride the following method to create the 3D Shapes which will represent your graph elements
 void initGraphElement()
           
 boolean isDefaultColour()
           
 void makePickable(javax.media.j3d.Shape3D shape)
          Make a given shape a pick target for this GraphElement
 boolean picked(java.awt.event.MouseEvent e)
           
 void removeLabel()
           
 void removePickingClient(PickingClient client)
           
 void setColour(java.awt.Color colour)
           
 void setColour(javax.vecmath.Color3f diffuse)
           
 void setColour(float red, float green, float blue)
           
protected  void setFullTransform(javax.vecmath.Vector3d scale, javax.vecmath.Vector3f translation, javax.vecmath.AxisAngle4f rotation)
          set up for a full transform with scale, translation and rotation components
protected  void setFullTransform(javax.vecmath.Vector3d scale, javax.vecmath.Vector3f translation, javax.vecmath.Quat4f orientation)
          set up for a full transform with scale, translation and rotation components
 void setLabel(java.lang.String text)
           
 void setLabel(java.lang.String[] labelLines)
          sets a multiline label...
protected  void setLabel(javax.media.j3d.TransformGroup label)
           
 void setPickable(boolean pickable)
           
 void setProperties(java.util.Properties p)
           
protected  void setResizeTranslateTransform(javax.vecmath.Vector3d scale, javax.vecmath.Vector3f translation)
          set up for a transform with scale and translation components
protected  void setTransformGroupTransform(javax.media.j3d.Transform3D transform)
          set the transform for this graph element's transform group
protected  void setTranslation(javax.vecmath.Vector3f v)
          set up for a translation transform
 void setTransparencyAttributes(javax.media.j3d.TransparencyAttributes ta)
           
protected  void setupDefaultAppearance(javax.media.j3d.Material defaultMaterial)
           
protected abstract  void setupDefaultMaterial()
          Sets the default material for graph elements You must over-ride this abstract method stub with: setupDefaultAppearance(myDefaultMaterial);
protected  void setupHighlightAppearance(javax.media.j3d.Material highlightMaterial)
           
protected abstract  void setupHighlightMaterial()
          You must over-ride this method with: setupHighlightAppearance(myHighLightedMaterial)
 void setUserData(java.lang.Object data)
           
 void show(GraphCanvas graphCanvas)
           
protected abstract  void showLabel(java.lang.String text)
           
 void transform(javax.vecmath.Vector3f v)
           
 
Methods inherited from class org.wilmascope.patterns.Prototype
clone, getTypeName, setTypeName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wilmascope.graph.Viewable
draw
 

Field Detail

t3d

protected javax.media.j3d.Transform3D t3d
Constructor Detail

GraphElementView

public GraphElementView()
Method Detail

initGraphElement

public void initGraphElement()

setTransparencyAttributes

public void setTransparencyAttributes(javax.media.j3d.TransparencyAttributes ta)

setupDefaultMaterial

protected abstract void setupDefaultMaterial()
Sets the default material for graph elements You must over-ride this abstract method stub with: setupDefaultAppearance(myDefaultMaterial);


setupHighlightMaterial

protected abstract void setupHighlightMaterial()
You must over-ride this method with: setupHighlightAppearance(myHighLightedMaterial)


init

protected abstract void init()
you must over-ride the following method to create the 3D Shapes which will represent your graph elements


delete

public void delete()
Make it go away, for the last time!

Specified by:
delete in interface Viewable

addTransformGroupChild

public void addTransformGroupChild(javax.media.j3d.Node node)
add a scene graph node to this graph element's transform group


setTransformGroupTransform

protected void setTransformGroupTransform(javax.media.j3d.Transform3D transform)
set the transform for this graph element's transform group


getTransformGroup

public javax.media.j3d.TransformGroup getTransformGroup()
Returns:
the transform group for this graph element

setTranslation

protected void setTranslation(javax.vecmath.Vector3f v)
set up for a translation transform


setResizeTranslateTransform

protected void setResizeTranslateTransform(javax.vecmath.Vector3d scale,
                                           javax.vecmath.Vector3f translation)
set up for a transform with scale and translation components


setFullTransform

protected void setFullTransform(javax.vecmath.Vector3d scale,
                                javax.vecmath.Vector3f translation,
                                javax.vecmath.AxisAngle4f rotation)
set up for a full transform with scale, translation and rotation components


setFullTransform

protected void setFullTransform(javax.vecmath.Vector3d scale,
                                javax.vecmath.Vector3f translation,
                                javax.vecmath.Quat4f orientation)
set up for a full transform with scale, translation and rotation components


transform

public void transform(javax.vecmath.Vector3f v)

picked

public boolean picked(java.awt.event.MouseEvent e)

setupDefaultAppearance

protected void setupDefaultAppearance(javax.media.j3d.Material defaultMaterial)

setupHighlightAppearance

protected void setupHighlightAppearance(javax.media.j3d.Material highlightMaterial)

getAppearance

public javax.media.j3d.Appearance getAppearance()

setColour

public void setColour(float red,
                      float green,
                      float blue)

setColour

public void setColour(javax.vecmath.Color3f diffuse)

setColour

public void setColour(java.awt.Color colour)

getColor3f

public javax.vecmath.Color3f getColor3f()

getColour

public java.awt.Color getColour()

getDefaultColour

public java.awt.Color getDefaultColour()

isDefaultColour

public boolean isDefaultColour()

defaultColour

public void defaultColour()

highlightColour

public void highlightColour()

setLabel

public void setLabel(java.lang.String text)

setLabel

public void setLabel(java.lang.String[] labelLines)
sets a multiline label... this may be implemented in different ways by different subclass views... The default is just to show the first line


getLabel

public java.lang.String getLabel()

addLabel

protected void addLabel(java.lang.String text,
                        double scale,
                        javax.vecmath.Point3f originPosition,
                        javax.vecmath.Vector3f vTranslation,
                        javax.media.j3d.Appearance apText)
add a label to the element

Parameters:
String - the text of the label
scale - factor to resize the text
Point3f - origin position of the centre of the label relative to the axis of the edge
Vector3f - Translation vector to position the label origin relative to centre of the edge
Appearance - for the label

removeLabel

public void removeLabel()

setLabel

protected void setLabel(javax.media.j3d.TransformGroup label)

addShape

protected void addShape(javax.media.j3d.Shape3D shape)
Add a visible Shape3D to this Graph Element. The shape will be made pickable, returning this GraphElement to the pick listener. Alternately add complex objects such as LODs yourself using addTransformGroupChild and then call makePickable on them.


makePickable

public void makePickable(javax.media.j3d.Shape3D shape)
Make a given shape a pick target for this GraphElement


hide

public void hide()
Specified by:
hide in interface Viewable

getGraphCanvas

public GraphCanvas getGraphCanvas()

show

public void show(GraphCanvas graphCanvas)
Specified by:
show in interface Viewable

addPickingClient

public void addPickingClient(PickingClient client)
Register a PickingClient whose PickingClient.callback(java.awt.event.MouseEvent)method will be called when the element is clicked


removePickingClient

public void removePickingClient(PickingClient client)

getBranchGroup

public javax.media.j3d.BranchGroup getBranchGroup()

getIcon

public abstract javax.swing.ImageIcon getIcon()

setPickable

public void setPickable(boolean pickable)
Specified by:
setPickable in interface Viewable

setUserData

public void setUserData(java.lang.Object data)

getUserData

public java.lang.Object getUserData()

addLiveBranch

protected void addLiveBranch(javax.media.j3d.BranchGroup b)

getProperties

public java.util.Properties getProperties()

setProperties

public void setProperties(java.util.Properties p)

getAxisAngle4f

public static javax.vecmath.AxisAngle4f getAxisAngle4f(javax.vecmath.Vector3f init,
                                                       javax.vecmath.Vector3f target)
Parameters:
init -
target -
Returns:
AxisAngle for rotation of init vector to be oriented with target vector

showLabel

protected abstract void showLabel(java.lang.String text)