org.knime.base.node.mine.decisiontree2.view.graph
Class HierarchicalGraphView<K>

java.lang.Object
  extended by org.knime.base.node.mine.decisiontree2.view.graph.HierarchicalGraphView<K>
Type Parameters:
K - The type of the nodes user objects
Direct Known Subclasses:
DecTreeGraphView

public abstract class HierarchicalGraphView<K>
extends Object

A widget for a tree.

Author:
Heiko Hofer

Nested Class Summary
static class HierarchicalGraphView.Align
          The alignment of the graph.
(package private) static class HierarchicalGraphView.LayoutSettings
          Constants for the layout.
 
Constructor Summary
HierarchicalGraphView(K root)
          Create a new instance.
HierarchicalGraphView(K root, HierarchicalGraphView.Align alignment)
          Create a new instance.
 
Method Summary
(package private)  void addGraphListener(GraphListener listener)
          Registers a graph listener.
 void clearHilite()
          Unhilite all nodes.
 JComponent createOutlineView()
          Creates an outline view, which is a birds eye view on the graph.
protected  Set<K> getCollapsed()
          Returns the collapsed nodes.
(package private)  HierarchicalGraphView.LayoutSettings getLayoutSettings()
          Return an object width constants used for layout the graph.
abstract  NodeWidgetFactory<K> getNodeWidgetFactory()
          Get the NodeWidgetFactory for this Graph.
protected  int getNodeWidth()
          The common widht of the visible nodes.
protected  DefaultMutableTreeNode getRoot()
          The root node.
 K getRootNode()
          Get the root.
 float getScaleFactor()
          Set the scale factor.
 K getSelected()
          Get the selected node.
 String getToolTipText(MouseEvent event)
          Returns the string to be used as the tooltip for event.
(package private)  Map<K,DefaultMutableTreeNode> getTreeMap()
          The keys are retrieved from getNodeWidgetFactory().getChildren(...).
 JComponent getView()
          Returns the JComponent for the HierarchicalGraphView.
protected  Map<K,Rectangle> getVisible()
          Returns the visible nodes and their bounds.
 Map<K,NodeWidget<K>> getWidgets()
          Returns the widgets for the nodes returned by getVisible() and getCollapsed().
 void hiLite(Set<K> toHiLite)
          HiLite the given nodes.
protected  void layoutGraph()
          Re-layout the graph.
 void mouseClicked(MouseEvent e)
          Handler for the mouse clicked event.
 void mousePressed(MouseEvent e)
          Handler for the mouse pressed event.
 void mouseReleased(MouseEvent e)
          Handler for the mouse released event.
 K nodeAtPoint(Point p)
          Returns the node at a certain point.
(package private)  void paint(Component c, Graphics2D g, int x, int y, int width, int height)
          Paints the nodes, the connectors and the labels on the connectors to the given graphics object.
(package private)  void removeGraphListener(GraphListener listener)
          Unregisters a graph listener.
protected  void setNodeWidth(int nodeWidth)
          Changes the common width of the visible nodes.
 void setRootNode(K root)
          Replace the root which is the model for this view.
 void setScaleFactor(float scale)
          Get the scale factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchicalGraphView

public HierarchicalGraphView(K root)
Create a new instance.

Parameters:
root - the root of the graph

HierarchicalGraphView

public HierarchicalGraphView(K root,
                             HierarchicalGraphView.Align alignment)
Create a new instance.

Parameters:
root - the root of the tree
alignment - the alignment of the graph
Method Detail

getScaleFactor

public float getScaleFactor()
Set the scale factor.

Returns:
the scale factor

setScaleFactor

public void setScaleFactor(float scale)
Get the scale factor.

Parameters:
scale - the scale factor to set

setRootNode

public void setRootNode(K root)
Replace the root which is the model for this view.

Parameters:
root - the root

getRootNode

public K getRootNode()
Get the root.

Returns:
the root

getNodeWidgetFactory

public abstract NodeWidgetFactory<K> getNodeWidgetFactory()
Get the NodeWidgetFactory for this Graph.

Returns:
the NodeWidgetFactory

addGraphListener

final void addGraphListener(GraphListener listener)
Registers a graph listener. Currently only used by the OutlineView

Parameters:
listener - the graph listener

removeGraphListener

final void removeGraphListener(GraphListener listener)
Unregisters a graph listener. Currently only used by the OutlineView

Parameters:
listener - the graph listener

getView

public final JComponent getView()
Returns the JComponent for the HierarchicalGraphView. This method returns always the same instance.

Returns:
the created view

createOutlineView

public final JComponent createOutlineView()
Creates an outline view, which is a birds eye view on the graph.

Returns:
the outline view

layoutGraph

protected void layoutGraph()
Re-layout the graph.


paint

void paint(Component c,
           Graphics2D g,
           int x,
           int y,
           int width,
           int height)
Paints the nodes, the connectors and the labels on the connectors to the given graphics object. Nodes are painted with different background or border whether they are selected or hilited.

Parameters:
c - the component to paint on
g - the graphics object
x - the x value of the top left corner
y - the y value of the top left corner
width - The width to be paint
height - The height to be paint

getToolTipText

public String getToolTipText(MouseEvent event)
Returns the string to be used as the tooltip for event.

Parameters:
event - the mouse event
Returns:
the tooltip

mouseClicked

public void mouseClicked(MouseEvent e)
Handler for the mouse clicked event.

Parameters:
e - the mouse event

mouseReleased

public void mouseReleased(MouseEvent e)
Handler for the mouse released event.

Parameters:
e - the mouse event

mousePressed

public void mousePressed(MouseEvent e)
Handler for the mouse pressed event.

Parameters:
e - the mouse event

getSelected

public K getSelected()
Get the selected node.

Returns:
the selected node

hiLite

public void hiLite(Set<K> toHiLite)
HiLite the given nodes.

Parameters:
toHiLite - the nodes to HiLite

clearHilite

public void clearHilite()
Unhilite all nodes.


nodeAtPoint

public K nodeAtPoint(Point p)
Returns the node at a certain point.

Parameters:
p - the point on screen
Returns:
the node at the given point

getWidgets

public Map<K,NodeWidget<K>> getWidgets()
Returns the widgets for the nodes returned by getVisible() and getCollapsed().

Returns:
the widgets for visible and collapsed nodes

getVisible

protected Map<K,Rectangle> getVisible()
Returns the visible nodes and their bounds.

Returns:
the visible the visible nodes and their bounds.

getCollapsed

protected Set<K> getCollapsed()
Returns the collapsed nodes. When a branch is collapsed, all visible nodes of that branch are moved to this set. When a branch is expanded, all collapsed nodes of that branch will be made visible. If there are no collapsed nodes the first level of the expanded branch will be made visible. Visible nodes can be retrieved by getVisible().

Returns:
the collapsed

setNodeWidth

protected void setNodeWidth(int nodeWidth)
Changes the common width of the visible nodes. This method does not trigger repaint. Call following method for a relayout and a repaint: layoutGraph(); getView().revalidate(); getView().repaint();

Parameters:
nodeWidth - the nodeWidth to set

getNodeWidth

protected int getNodeWidth()
The common widht of the visible nodes.

Returns:
the nodeWidth

getRoot

protected DefaultMutableTreeNode getRoot()
The root node. getRoot().getUserObject() returns the node given in the constructor and the node provided by set RootNode, respectivly.

Returns:
the root

getTreeMap

Map<K,DefaultMutableTreeNode> getTreeMap()
The keys are retrieved from getNodeWidgetFactory().getChildren(...). Calling getTreeMap(key).getUserObject() returns key.

Returns:
a dictionary of all nodes in the decision tree

getLayoutSettings

HierarchicalGraphView.LayoutSettings getLayoutSettings()
Return an object width constants used for layout the graph.

Returns:
the layoutSettings


Copyright, 2003 - 2012. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.