org.glassbox.graphview
Class AbstractImageNodePainter

java.lang.Object
  extended by org.glassbox.graphview.AbstractImageNodePainter
All Implemented Interfaces:
NodePainter, ZoomableNodePainter
Direct Known Subclasses:
SimpleImageNodePainter, TransitionNodePainter2.TransitionImageNodePainter

public abstract class AbstractImageNodePainter
extends java.lang.Object
implements ZoomableNodePainter

An abstract implementation of a NodePainter which paints an image for each node. The size of the node ist determined by the according image. Only methods that have to be implemented are ImageIcon getImageForNode(Node) to decide which image should be painted for a node and Collection getAllImages() to receive all images used by this painter.


Constructor Summary
protected AbstractImageNodePainter(java.awt.Dimension imagesize, java.awt.Insets border)
          Constructor.
protected AbstractImageNodePainter(java.awt.Dimension imagesize, java.awt.Insets border, double zoomthreshold)
          Constructor.
 
Method Summary
protected abstract  javax.swing.ImageIcon getImageForNode(Node node)
          This method has to be implemented by subclasses to decide which image should be painted for a node.
 void getNodeScreenBounds(JGraphPane graphpane, Node node, java.awt.Rectangle nodebounds)
          Returns the outer rectangle of the node on screen.
 java.lang.String getToolTipText(JGraphPane graphpane, Node node, java.awt.Point point)
          Retruns the tool-tip for given point.
 boolean isInNode(JGraphPane graphpane, Node node, java.awt.Point point)
          Checks whether given point is inside the node.
 void paintNode(JGraphPane graphpane, java.awt.Graphics2D g, Node node)
          Paints the supplied node.
 void setZoomFactor(double zf)
          Set the zoom-factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractImageNodePainter

protected AbstractImageNodePainter(java.awt.Dimension imagesize,
                                   java.awt.Insets border)
Constructor. Uses 0 as threshold (images are always painted).

Parameters:
imagesize - The size of the images.
insets - The insets of this painter (empty space around the images).

AbstractImageNodePainter

protected AbstractImageNodePainter(java.awt.Dimension imagesize,
                                   java.awt.Insets border,
                                   double zoomthreshold)
Constructor.

Parameters:
imagesize - The size of the images.
insets - The insets of this painter (empty space around the images).
zoomthreshold - The minimum zoom value to paint images.
Method Detail

getImageForNode

protected abstract javax.swing.ImageIcon getImageForNode(Node node)
This method has to be implemented by subclasses to decide which image should be painted for a node.


setZoomFactor

public void setZoomFactor(double zf)
Description copied from interface: ZoomableNodePainter
Set the zoom-factor.

Specified by:
setZoomFactor in interface ZoomableNodePainter

paintNode

public void paintNode(JGraphPane graphpane,
                      java.awt.Graphics2D g,
                      Node node)
Description copied from interface: NodePainter
Paints the supplied node.

Specified by:
paintNode in interface NodePainter
Parameters:
graphpane - the graph pane
g - the graphics
node - the node to paint

isInNode

public boolean isInNode(JGraphPane graphpane,
                        Node node,
                        java.awt.Point point)
Description copied from interface: NodePainter
Checks whether given point is inside the node.

Specified by:
isInNode in interface NodePainter
Parameters:
graphpane - the graph pane
node - the node
point - the point
Returns:
true if the point is in the node

getNodeScreenBounds

public void getNodeScreenBounds(JGraphPane graphpane,
                                Node node,
                                java.awt.Rectangle nodebounds)
Description copied from interface: NodePainter
Returns the outer rectangle of the node on screen.

Specified by:
getNodeScreenBounds in interface NodePainter
Parameters:
graphpane - the graph pane
node - the node
nodebounds - the rectangle receiving the node's coordinates

getToolTipText

public java.lang.String getToolTipText(JGraphPane graphpane,
                                       Node node,
                                       java.awt.Point point)
Description copied from interface: NodePainter
Retruns the tool-tip for given point.

Specified by:
getToolTipText in interface NodePainter
Parameters:
graphpane - the graph pane
node - the node
point - the point
Returns:
the tool-tip at given point (or null)


Copyright © 2005-2010 The K-Wf Grid Consortium. All Rights Reserved.