Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

phoebe
Class PNodeView  view PNodeView download PNodeView.java

java.lang.Object
  extended byPPath
      extended byphoebe.PNodeView
All Implemented Interfaces:
java.util.EventListener, giny.view.NodeView, java.beans.PropertyChangeListener

public class PNodeView
extends PPath
implements giny.view.NodeView, java.beans.PropertyChangeListener

This Class is the BasicPNodeView. It has very limited support. Go look at plain old @see PNodeView. If you are going to make your own NodeView then you might be in the in the right place. Because we are using Piccolo, it becomes both appropriate and necessary to add only "PNode" Objects to the SceneGraph. At this point, if you are not familiar with Piccolo, become that way, possibly by reading on. So PNode is the Base class in Piccolo, and every viewable object inherits from it. There are a number of very useful Piccolo provided nodes, like PClip, P3DRect, PPath, PText, PImage and PLens. The phoebe default class, PNodeView is in fact a PClip. So, to role your own node, you have two options: 1. Extend this class and overide the paint( PPaintContext ) method. You will find the PPaintContext is REALLY cool. It provides a lot of information about the scene being displayed, in addition to the Graphics2D Object. Other methods of note are the animate* methods and the layout methods. As a note, the "DataRose" plugin that PShannon wrote, should be "just work" by extending this class instead of the Y-Files one. Don't forget that any number of child nodes can be added onto this node, and they will by default move and scale and get painted and all that goodeness at the same time as this one. This should make it really easy to add complex displays, and is one of the reasons why I really think that Piccolo is a good fit for the Cytoscape Project. 2. If you want to use one of the above mentioned Piccolo provided nodes, then it will be necessary to extend from that node, and not this one. Multiple inheritance might solve the problem, but in the meantime, by simple copying all of the code from this class into your new class, it should just work(tm). Since that is what I did to get the PNodeView class. Any and all questions should be directed to me.


Field Summary
protected  phoebe.util.PLabel label
          Our label TODO: more extendable
protected  boolean notUpdated
          A boolean that tells us if we are updated to the current position, i.e.
protected  int rootGraphIndex
          The index of this node in the RootGraph note that this is always a negative number.
protected  boolean selected
          Our Selection toggle
protected  PGraphView view
          The View to which we belong.
protected  boolean visible
          Our Visibility
 
Fields inherited from interface giny.view.NodeView
DIAMOND, ELLIPSE, HEXAGON, OCTAGON, PARALELLOGRAM, RECTANGLE, TRIANGLE
 
Constructor Summary
PNodeView(int node_index, PGraphView view)
           
PNodeView(int node_index, PGraphView view, double x_positon, double y_positon, int shape, java.awt.Paint paint, java.awt.Paint selection_paint, java.awt.Paint border_paint, float border_width, double width, double height, java.lang.String label)
          Create a new PNodeView with the given physical attributes.
 
Method Summary
 java.awt.Stroke getBorder()
           
 java.awt.Paint getBorderPaint()
           
 float getBorderWidth()
           
 int getDegree()
           
 java.util.List getEdgeViewsList(giny.view.NodeView otherNode)
           
 int getGraphPerspectiveIndex()
           
 giny.view.GraphView getGraphView()
           
 double getHeight()
          TODO: Reconcile with Border Methods
 int getIndex()
           
 java.lang.String getLabel()
           
 java.lang.String getLabelText()
          Deprecated.  
 giny.model.Node getNode()
           
 java.awt.Paint getSelectedPaint()
           
 int getShape()
          Shape is currently defined via predefined variables in the NodeView interface.
 java.awt.Paint getUnselectedPaint()
           
 double getWidth()
          TODO: Reconcile with Border Methods
 double getXPosition()
           
 double getYPosition()
           
protected  void initializeNodeView()
           
 boolean isSelected()
           
 void moveBy(double dx, double dy)
          Deprecated.  
 void offset(double dx, double dy)
          Move this node relative to its current location
protected  void paint(PPaintContext paintContext)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
          We want to be able to hear when a Node changes a property, like its identifier or selected state.
 void select()
          This draws us as selected
 void setBorder(java.awt.Stroke stroke)
           
 void setBorderPaint(java.awt.Paint b_paint)
           
 void setBorderWidth(float border_width)
           
 boolean setBounds(double x, double y, double width, double height)
          Overridden method so that this node is aware of its bounds being changed so that it can tell its label and edges to change their position accordingly.
 void setCenter(double x, double y)
          Deprecated.  
 void setFont(java.awt.Font font)
           
 void setHeight(double height)
          TODO: Reconcile with Border Methods
 void setLabel(java.lang.String label)
           
 void setLabelText(java.lang.String newL)
          Deprecated.  
 void setLocation(double x, double y)
          Deprecated.  
 void setNodePosition(boolean animate)
          moves this node to its stored x and y locations.
 void setOffset(double x, double y)
          Set the location of this node
 void setOffset(java.awt.geom.Point2D point)
          Set the location of this node
 boolean setSelected(boolean selected)
           
 void setSelectedPaint(java.awt.Paint paint)
          This sets the Paint that will be used by this node when it is painted as selected.
 void setShape(int shape)
          Set a new shape for the Node, based on one of the pre-defined shapes Note: calling setPathTo( Shape ), allows one to define their own java.awt.Shape ( i.e.
 void setShape(int shape, double width, double height)
          Set the new shape of the node, with a given new height and width
 void setSize(double w, double h)
          Deprecated.  
 void setToolTip(java.lang.String tip)
           
 void setUnselectedPaint(java.awt.Paint paint)
          Set the deafult paint of this node
 void setWidth(double width)
          TODO: Reconcile with Border Methods
 void setXPosition(double new_x_position)
           
 void setXPosition(double new_x_position, boolean update)
          Set udpdate to false in order to do a layout, and then call updateNode on all the nodes..
 void setYPosition(double new_y_position)
           
 void setYPosition(double new_y_position, boolean update)
          Set udpdate to false in order to do a layout, and then call updateNode on all the nodes..
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void unselect()
          This draws us as unselected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface giny.view.NodeView
getOffset
 

Field Detail

rootGraphIndex

protected int rootGraphIndex
The index of this node in the RootGraph note that this is always a negative number.


view

protected PGraphView view
The View to which we belong.


label

protected phoebe.util.PLabel label
Our label TODO: more extendable


selected

protected boolean selected
Our Selection toggle


visible

protected boolean visible
Our Visibility


notUpdated

protected boolean notUpdated
A boolean that tells us if we are updated to the current position, i.e. after a layout

Constructor Detail

PNodeView

public PNodeView(int node_index,
                 PGraphView view)

PNodeView

public PNodeView(int node_index,
                 PGraphView view,
                 double x_positon,
                 double y_positon,
                 int shape,
                 java.awt.Paint paint,
                 java.awt.Paint selection_paint,
                 java.awt.Paint border_paint,
                 float border_width,
                 double width,
                 double height,
                 java.lang.String label)
Create a new PNodeView with the given physical attributes.

Method Detail

initializeNodeView

protected void initializeNodeView()

getIndex

public int getIndex()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


getGraphView

public giny.view.GraphView getGraphView()
Specified by:
getGraphView in interface giny.view.NodeView

getNode

public giny.model.Node getNode()
Specified by:
getNode in interface giny.view.NodeView

getGraphPerspectiveIndex

public int getGraphPerspectiveIndex()
Specified by:
getGraphPerspectiveIndex in interface giny.view.NodeView

getEdgeViewsList

public java.util.List getEdgeViewsList(giny.view.NodeView otherNode)
Specified by:
getEdgeViewsList in interface giny.view.NodeView

getShape

public int getShape()
Shape is currently defined via predefined variables in the NodeView interface. To get the actual java.awt.Shape use getPathReference()

Specified by:
getShape in interface giny.view.NodeView

setSelectedPaint

public void setSelectedPaint(java.awt.Paint paint)
This sets the Paint that will be used by this node when it is painted as selected.

Specified by:
setSelectedPaint in interface giny.view.NodeView

getSelectedPaint

public java.awt.Paint getSelectedPaint()
Specified by:
getSelectedPaint in interface giny.view.NodeView

setUnselectedPaint

public void setUnselectedPaint(java.awt.Paint paint)
Description copied from interface: giny.view.NodeView
Set the deafult paint of this node

Specified by:
setUnselectedPaint in interface giny.view.NodeView

getUnselectedPaint

public java.awt.Paint getUnselectedPaint()
Specified by:
getUnselectedPaint in interface giny.view.NodeView

setBorderPaint

public void setBorderPaint(java.awt.Paint b_paint)
Specified by:
setBorderPaint in interface giny.view.NodeView

getBorderPaint

public java.awt.Paint getBorderPaint()
Specified by:
getBorderPaint in interface giny.view.NodeView

setBorderWidth

public void setBorderWidth(float border_width)
Specified by:
setBorderWidth in interface giny.view.NodeView

getBorderWidth

public float getBorderWidth()
Specified by:
getBorderWidth in interface giny.view.NodeView

setBorder

public void setBorder(java.awt.Stroke stroke)
Specified by:
setBorder in interface giny.view.NodeView

getBorder

public java.awt.Stroke getBorder()
Specified by:
getBorder in interface giny.view.NodeView

setWidth

public void setWidth(double width)
TODO: Reconcile with Border Methods

Specified by:
setWidth in interface giny.view.NodeView

getWidth

public double getWidth()
TODO: Reconcile with Border Methods

Specified by:
getWidth in interface giny.view.NodeView

setHeight

public void setHeight(double height)
TODO: Reconcile with Border Methods

Specified by:
setHeight in interface giny.view.NodeView

getHeight

public double getHeight()
TODO: Reconcile with Border Methods

Specified by:
getHeight in interface giny.view.NodeView

setLabel

public void setLabel(java.lang.String label)
Specified by:
setLabel in interface giny.view.NodeView

getLabel

public java.lang.String getLabel()
Specified by:
getLabel in interface giny.view.NodeView

getDegree

public int getDegree()
Specified by:
getDegree in interface giny.view.NodeView

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
We want to be able to hear when a Node changes a property, like its identifier or selected state. If the identifier changes the Label chages to the new value If selection changes, this NodeView draws itself as selected.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setOffset

public void setOffset(double x,
                      double y)
Set the location of this node

Specified by:
setOffset in interface giny.view.NodeView

setOffset

public void setOffset(java.awt.geom.Point2D point)
Set the location of this node


offset

public void offset(double dx,
                   double dy)
Move this node relative to its current location


setXPosition

public void setXPosition(double new_x_position)
Specified by:
setXPosition in interface giny.view.NodeView

setXPosition

public void setXPosition(double new_x_position,
                         boolean update)
Set udpdate to false in order to do a layout, and then call updateNode on all the nodes.. // TODO -- HACKY

Specified by:
setXPosition in interface giny.view.NodeView

getXPosition

public double getXPosition()
Specified by:
getXPosition in interface giny.view.NodeView

setYPosition

public void setYPosition(double new_y_position)
Specified by:
setYPosition in interface giny.view.NodeView

setYPosition

public void setYPosition(double new_y_position,
                         boolean update)
Set udpdate to false in order to do a layout, and then call updateNode on all the nodes.. // TODO -- HACKY

Specified by:
setYPosition in interface giny.view.NodeView

getYPosition

public double getYPosition()
Specified by:
getYPosition in interface giny.view.NodeView

setNodePosition

public void setNodePosition(boolean animate)
moves this node to its stored x and y locations.

Specified by:
setNodePosition in interface giny.view.NodeView

select

public void select()
This draws us as selected

Specified by:
select in interface giny.view.NodeView

unselect

public void unselect()
This draws us as unselected

Specified by:
unselect in interface giny.view.NodeView

isSelected

public boolean isSelected()
Specified by:
isSelected in interface giny.view.NodeView

setSelected

public boolean setSelected(boolean selected)
Specified by:
setSelected in interface giny.view.NodeView

paint

protected void paint(PPaintContext paintContext)

setBounds

public boolean setBounds(double x,
                         double y,
                         double width,
                         double height)
Overridden method so that this node is aware of its bounds being changed so that it can tell its label and edges to change their position accordingly.


setShape

public void setShape(int shape)
Set a new shape for the Node, based on one of the pre-defined shapes Note: calling setPathTo( Shape ), allows one to define their own java.awt.Shape ( i.e. A picture of Johnny Cash )

Specified by:
setShape in interface giny.view.NodeView

setShape

public void setShape(int shape,
                     double width,
                     double height)
Set the new shape of the node, with a given new height and width


setFont

public void setFont(java.awt.Font font)

setToolTip

public void setToolTip(java.lang.String tip)

moveBy

public void moveBy(double dx,
                   double dy)
Deprecated.  


setCenter

public void setCenter(double x,
                      double y)
Deprecated.  


setLocation

public void setLocation(double x,
                        double y)
Deprecated.  


setSize

public void setSize(double w,
                    double h)
Deprecated.  


getLabelText

public java.lang.String getLabelText()
Deprecated.  


setLabelText

public void setLabelText(java.lang.String newL)
Deprecated.