|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.hierarchy.GroupNodePainter
public class GroupNodePainter
A decorator GenericNodeRealizer.Painter
for group/folder nodes
that adds a state label that display whether the node is an opened group node
or a closed folder node.
The state label can be clicked to toggle the
open/close state of the node if the decorator is registered as
GenericNodeRealizer.GenericMouseInputEditorProvider
.
The icons displayed by the state label can be exchanged using methods
setOpenGroupIcon(javax.swing.Icon)
and
setClosedGroupIcon(javax.swing.Icon)
.
Moreover, overwriting method getStateLabel(y.view.NodeRealizer)
allows for exhaustive customization of the state label.
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.
Nested Class Summary | |
---|---|
static class |
GroupNodePainter.GroupStateEditor
A MouseInputEditor implementation that closes group nodes and
opens folder nodes in response to state change gestures (that is a mouse
click at an appropriate location). |
static class |
GroupNodePainter.GroupStateStyle
A GroupStateStyle provides opacity information for painting
group state icons. |
Field Summary | |
---|---|
static java.lang.String |
GROUP_STATE_STYLE_ID
Style property key for style information used to render group state icons. |
Constructor Summary | |
---|---|
GroupNodePainter()
Creates a new instance of GroupNodePainter that uses a ShapeNodePainter to paint the node itself. |
|
GroupNodePainter(GenericNodeRealizer.Painter painterDelegate)
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 | |
---|---|
protected void |
configureDefaultLabel(NodeRealizer context,
NodeLabel label)
Configures the given label as default group label. |
boolean |
contains(NodeRealizer context,
double x,
double y)
Determines whether the point given by the specified coordinates lies within the (visual) bounds of the specified realizer or within the bounds of the specified realizer's default label (if it exists). |
MouseInputEditor |
findMouseInputEditor(NodeRealizer context,
Graph2DView view,
double x,
double y,
HitInfo hitInfo)
Returns an editor to handle mouse events for group/folder nodes that are configured to use this GroupNodePainter instance as their
GenericNodeRealizer.GenericMouseInputEditorProvider . |
javax.swing.Icon |
getClosedGroupIcon()
Returns the icon that is used for the state label when the group is closed. |
protected float |
getGroupStateOpacity(NodeRealizer context)
Returns the state icon's opacity value for the given NodeRealizer . |
protected HierarchyManager |
getHierarchyManager(Graph graph)
Returns the hierarchy manager responsibly for managing the node represented by this realizer. |
protected YInsets |
getInnerGraphInsets(NodeRealizer context)
Returns the insets for painting inner graphs. |
javax.swing.Icon |
getOpenGroupIcon()
Returns the icon that is used for the state label when the group is opened. |
GenericNodeRealizer.Painter |
getPainterDelegate()
Returns the delegate painter that paints the node itself. |
protected NodeLabel |
getStateLabel(NodeRealizer context)
Returns the state label of this realizer. |
void |
initialize(NodeRealizer context)
Configures the given realizer's default label as default group label. |
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,
java.awt.Graphics2D graphics)
Used as a callback for the GenericNodeRealizer.paint(Graphics2D) method. |
protected void |
paintGroupState(NodeRealizer context,
java.awt.Graphics2D graphics,
boolean sloppy)
Paints an icon representing the context realizer's group state. |
protected void |
paintInnerGraph(NodeRealizer context,
java.awt.Graphics2D gfx)
Used to paint the inner graph of a folder node when innerGraphDisplay is enabled. |
void |
paintSloppy(NodeRealizer context,
java.awt.Graphics2D graphics)
Used as a callback for the GenericNodeRealizer.paintSloppy(Graphics2D) method. |
void |
setClosedGroupIcon(javax.swing.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(javax.swing.Icon icon)
Sets the icon to be used for the state label when the group is open. |
protected boolean |
shouldChangeState(NodeRealizer context,
double x,
double y)
Determines whether or not a state change gesture at the specified point should result in a group state change for the node represented by the specified node realizer. |
protected boolean |
shouldConfigureDefaultLabel(NodeRealizer context,
NodeLabel label)
Determines if the given label should be configured as default group label. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String GROUP_STATE_STYLE_ID
GroupNodePainter.GroupStateStyle
.
Style properties registered for this key are considered transient
and will not be serialized.
paintGroupState(y.view.NodeRealizer, java.awt.Graphics2D, boolean)
,
GenericNodeRealizer.setStyleProperty(String, Object)
,
Constant Field ValuesConstructor Detail |
---|
public GroupNodePainter()
ShapeNodePainter
to paint the node itself.
public GroupNodePainter(GenericNodeRealizer.Painter painterDelegate)
GenericNodeRealizer.Painter
implementation
to paint node itself and adds the state label and the ability to open/close this node to it.
painterDelegate
- an implementation of GenericNodeRealizer.Painter
that will be used for painting the
node itself.Method Detail |
---|
public GenericNodeRealizer.Painter getPainterDelegate()
GroupNodePainter(y.view.GenericNodeRealizer.Painter)
public void paint(NodeRealizer context, java.awt.Graphics2D graphics)
GenericNodeRealizer.Painter
GenericNodeRealizer.paint(Graphics2D)
method.
paint
in interface GenericNodeRealizer.Painter
public void paintSloppy(NodeRealizer context, java.awt.Graphics2D graphics)
GenericNodeRealizer.Painter
GenericNodeRealizer.paintSloppy(Graphics2D)
method.
paintSloppy
in interface GenericNodeRealizer.Painter
protected void paintGroupState(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
paint(y.view.NodeRealizer, java.awt.Graphics2D)
and paintSloppy(y.view.NodeRealizer, java.awt.Graphics2D)
.
The default implementation calls the
state label's
paint
method.
context
- the context node.graphics
- the graphics context to use.sloppy
- whether or not to paint in sloppy mode.protected float getGroupStateOpacity(NodeRealizer context)
NodeRealizer
.
The default implementation checks the style property
GROUP_STATE_STYLE_ID
for the opacity value to be set.
context
- The node realizer where the opacity value is set for
GroupNodePainter.GroupStateStyle.getOpacity()
protected void paintInnerGraph(NodeRealizer context, java.awt.Graphics2D gfx)
innerGraphDisplay
is enabled.
context
- the node realizer that this painter is associated with.gfx
- the graphics context to paint to.protected YInsets getInnerGraphInsets(NodeRealizer context)
context
- the node realizer for which an inner graph is painted.
paintInnerGraph(y.view.NodeRealizer, java.awt.Graphics2D)
public javax.swing.Icon getClosedGroupIcon()
public void setClosedGroupIcon(javax.swing.Icon icon)
icon
- used to illustrate a closed state.public javax.swing.Icon getOpenGroupIcon()
public void setOpenGroupIcon(javax.swing.Icon icon)
icon
- used to illustrate an open state.public void setGroupDepthFillColorEnabled(boolean enabled)
enabled
- whether the group depth shall be reflected by the groups fill color. Default is true.public boolean isGroupDepthFillColorEnabled()
setGroupDepthFillColorEnabled(boolean)
protected NodeLabel getStateLabel(NodeRealizer context)
context
- the node realizer that this painter is associated with.
protected HierarchyManager getHierarchyManager(Graph graph)
graph
- the graph for whom the HierarchyManager shall be returned.
public boolean isInnerGraphDisplayEnabled()
public void setInnerGraphDisplayEnabled(boolean innerGraphDisplayEnabled)
innerGraphDisplayEnabled
- whether or not the inner graph of a folder node should be displayed.public MouseInputEditor findMouseInputEditor(NodeRealizer context, Graph2DView view, double x, double y, HitInfo hitInfo)
GroupNodePainter
instance as their
GenericNodeRealizer.GenericMouseInputEditorProvider
.
By default, a GroupNodePainter.GroupStateEditor
instance that
closes groups/opens folders when
shouldChangeState
yields true
is returned.
findMouseInputEditor
in interface GenericNodeRealizer.GenericMouseInputEditorProvider
context
- the node context.view
- the component that received the mouse event.x
- the x-component of the world (graph) coordinate of the event.y
- the y-component of the world (graph) coordinate of the event.hitInfo
- the elements of the specified view's graph at the event
location.
MouseInputEditor
instance that handles mouse events
at the given coordinates or null
if events at the given
coordinates are ignored.GroupNodePainter.GroupStateEditor
protected boolean shouldChangeState(NodeRealizer context, double x, double y)
The default implementation returns true
if the specified
point lies in the group node's state label and false
otherwise.
Called from
findMouseInputEditor
.
context
- the node context.x
- the x-coordinate of the state change gesture.y
- the y-coordinate of the state change gesture.
true
if the group state should be changed when
the appropriate gesture is received at the specified coordinates;
false
otherwise.public void initialize(NodeRealizer context)
Calls
shouldConfigureDefaultLabel
and
configureDefaultLabel
.
initialize
in interface GenericNodeRealizer.Initializer
shouldConfigureDefaultLabel(NodeRealizer, NodeLabel)
,
configureDefaultLabel(NodeRealizer, NodeLabel)
protected boolean shouldConfigureDefaultLabel(NodeRealizer context, NodeLabel label)
Called from initialize
.
context
- the node context.label
- the label to be checked
true
if the given label should be configured as
default group label and false
otherwise.initialize(NodeRealizer)
,
configureDefaultLabel(NodeRealizer, NodeLabel)
protected void configureDefaultLabel(NodeRealizer context, NodeLabel label)
Called from initialize
.
context
- the node context.label
- the label to be configuredinitialize(NodeRealizer)
,
shouldConfigureDefaultLabel(NodeRealizer, NodeLabel)
public boolean contains(NodeRealizer context, double x, double y)
contains
in interface GenericNodeRealizer.ContainsTest
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |