y.view.hierarchy
Class GroupNodePainter

java.lang.Object
  extended by y.view.hierarchy.GroupNodePainter
All Implemented Interfaces:
GenericNodeRealizer.ContainsTest, GenericNodeRealizer.GenericMouseInputEditorProvider, GenericNodeRealizer.Initializer, GenericNodeRealizer.Painter

public class GroupNodePainter
extends Object
implements GenericNodeRealizer.Painter, GenericNodeRealizer.GenericMouseInputEditorProvider, GenericNodeRealizer.Initializer, GenericNodeRealizer.ContainsTest

This class is an implementation of GenericNodeRealizer.Painter for Group/Folder nodes. By default it internally uses a ShapeNodePainter to draw the Node itself. Furthermore it will paint a state label to show whether this node is opened or closed. This label can be clicked to toggle the node's state. One can set its own icon for this label using (javax.swing.Icon) and (javax.swing.Icon) or define its own label by overwriting method getStateLabel(y.view.NodeRealizer). An own implementation of GenericNodeRealizer.Painter can be handed over to this class that will be used to draw the node itself. By default a ShapeNodePainter is being used. Method setInnerGraphDisplayEnabled(boolean) can be used to determine whether the inner graph of the group node shall be painted or not. Method setGroupDepthFillColorEnabled(boolean) can be used to determine whether deeper nested graphs shall get darker fill colors for deeper nested group nodes to achieve a better outline.

 
Your browser does not support SVG content.

Constructor Summary
GroupNodePainter()
          Creates a new instance of GroupNodePainter that uses a ShapeNodePainter to paint the node itself.
GroupNodePainter(GenericNodeRealizer.Painter painterDelagate)
          Creates a new instance of GroupNodePainter that uses the given GenericNodeRealizer.Painter implementation to paint node itself and adds the state label and the ability to open/close this node to it.
 
Method Summary
 boolean contains(NodeRealizer context, double x, double y)
          Used as a callback for the GenericNodeRealizer.contains(double, double) method.
 MouseInputEditor findMouseInputEditor(NodeRealizer context, Graph2DView view, double x, double y, HitInfo hitInfo)
          Used as a callback for the GenericNodeRealizer.findMouseInputEditor(Graph2DView, double, double, HitInfo) method.
 Icon getClosedGroupIcon()
          Returns the icon that is used for the state label when the group is closed.
protected  HierarchyManager getHierarchyManager(Graph graph)
          Returns the hierarchy manager responsibly for managing the node represented by this realizer.
 Icon getOpenGroupIcon()
          Returns the icon that is used for the state label when the group is opened.
protected  NodeLabel getStateLabel(NodeRealizer context)
          Returns the state label of this realizer.
 void initialize(NodeRealizer context)
           
 boolean isGroupDepthFillColorEnabled()
          Whether or not the fill color of this node gets adapted to reflect the local group depth of this node within the graph hierarchy.
 boolean isInnerGraphDisplayEnabled()
          Returns whether or not the inner graph of a folder node should be displayed.
 void paint(NodeRealizer context, Graphics2D graphics)
          Used as a callback for the GenericNodeRealizer.paint(Graphics2D) method.
protected  void paintInnerGraph(NodeRealizer context, Graphics2D gfx)
          Used to paint the inner graph of a folder node when innerGraphDisplay is enabled.
 void paintSloppy(NodeRealizer context, Graphics2D graphics)
          Used as a callback for the GenericNodeRealizer.paintSloppy(Graphics2D) method.
 void setClosedGroupIcon(Icon icon)
          Sets the icon to be used for the state label when the group is closed.
 void setGroupDepthFillColorEnabled(boolean enabled)
          Whether or not the fill color of this node should be adapted to reflect the local group depth of this node within the graph hierarchy.
 void setInnerGraphDisplayEnabled(boolean innerGraphDisplayEnabled)
          Sets whether or not the inner graph of a folder node should be displayed.
 void setOpenGroupIcon(Icon icon)
          Sets the icon to be used for the state label when the group is open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupNodePainter

public GroupNodePainter()
Creates a new instance of GroupNodePainter that uses a ShapeNodePainter to paint the node itself.


GroupNodePainter

public GroupNodePainter(GenericNodeRealizer.Painter painterDelagate)
Creates a new instance of GroupNodePainter that uses the given GenericNodeRealizer.Painter implementation to paint node itself and adds the state label and the ability to open/close this node to it.

Parameters:
painterDelagate - an implementation of GenericNodeRealizer.Painter that will be used for painting the node itself.
Method Detail

paint

public void paint(NodeRealizer context,
                  Graphics2D graphics)
Description copied from interface: GenericNodeRealizer.Painter
Used as a callback for the GenericNodeRealizer.paint(Graphics2D) method.

Specified by:
paint in interface GenericNodeRealizer.Painter

paintSloppy

public void paintSloppy(NodeRealizer context,
                        Graphics2D graphics)
Description copied from interface: GenericNodeRealizer.Painter
Used as a callback for the GenericNodeRealizer.paintSloppy(Graphics2D) method.

Specified by:
paintSloppy in interface GenericNodeRealizer.Painter

paintInnerGraph

protected void paintInnerGraph(NodeRealizer context,
                               Graphics2D gfx)
Used to paint the inner graph of a folder node when innerGraphDisplay is enabled.

Parameters:
context - the node realizer that this painter is associated with.
gfx - the graphics context to paint to.

getClosedGroupIcon

public Icon getClosedGroupIcon()
Returns the icon that is used for the state label when the group is closed.

Returns:
the icon used to illustrate a closed state.

setClosedGroupIcon

public void setClosedGroupIcon(Icon icon)
Sets the icon to be used for the state label when the group is closed.

Parameters:
icon - used to illustrate a closed state.

getOpenGroupIcon

public Icon getOpenGroupIcon()
Returns the icon that is used for the state label when the group is opened.

Returns:
the icon used to illustrate an open state.

setOpenGroupIcon

public void setOpenGroupIcon(Icon icon)
Sets the icon to be used for the state label when the group is open.

Parameters:
icon - used to illustrate an open state.

setGroupDepthFillColorEnabled

public void setGroupDepthFillColorEnabled(boolean enabled)
Whether or not the fill color of this node should be adapted to reflect the local group depth of this node within the graph hierarchy. By default this feature is enabled.

Parameters:
enabled - whether the group depth shall be reflected by the groups fill color. Default is true.

isGroupDepthFillColorEnabled

public boolean isGroupDepthFillColorEnabled()
Whether or not the fill color of this node gets adapted to reflect the local group depth of this node within the graph hierarchy.

Returns:
true whether deeper nested groups will have darker fill colors, false otherwise.
See Also:
setGroupDepthFillColorEnabled(boolean)

getStateLabel

protected NodeLabel getStateLabel(NodeRealizer context)
Returns the state label of this realizer.

Parameters:
context - the node realizer that this painter is associated with.
Returns:
the state label for the current state.

getHierarchyManager

protected HierarchyManager getHierarchyManager(Graph graph)
Returns the hierarchy manager responsibly for managing the node represented by this realizer.

Parameters:
graph - the graph for whom the HierarchyManager shall be returned.
Returns:
the HierarchyManager for the given graph.

isInnerGraphDisplayEnabled

public boolean isInnerGraphDisplayEnabled()
Returns whether or not the inner graph of a folder node should be displayed.

Returns:
whether or not the inner graph of a folder node should be displayed.

setInnerGraphDisplayEnabled

public void setInnerGraphDisplayEnabled(boolean innerGraphDisplayEnabled)
Sets whether or not the inner graph of a folder node should be displayed. The node represented by this painter must be a folder node in the graph hierarchy and the realizer must be in closed mode.

Parameters:
innerGraphDisplayEnabled - whether or not the inner graph of a folder node should be displayed.

findMouseInputEditor

public MouseInputEditor findMouseInputEditor(NodeRealizer context,
                                             Graph2DView view,
                                             double x,
                                             double y,
                                             HitInfo hitInfo)
Description copied from interface: GenericNodeRealizer.GenericMouseInputEditorProvider
Used as a callback for the GenericNodeRealizer.findMouseInputEditor(Graph2DView, double, double, HitInfo) method.

Specified by:
findMouseInputEditor in interface GenericNodeRealizer.GenericMouseInputEditorProvider
See Also:
MouseInputEditor, MouseInputEditorProvider

initialize

public void initialize(NodeRealizer context)
Specified by:
initialize in interface GenericNodeRealizer.Initializer

contains

public boolean contains(NodeRealizer context,
                        double x,
                        double y)
Description copied from interface: GenericNodeRealizer.ContainsTest
Used as a callback for the GenericNodeRealizer.contains(double, double) method.

Specified by:
contains in interface GenericNodeRealizer.ContainsTest

© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.