|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.DefaultGraph2DRenderer
public class DefaultGraph2DRenderer
Default Graph2DRenderer implementation.
This class renders a Graph2D by invoking the paint method for the associated
NodeRealizer
and EdgeRealizer
objects. This renderer is aware of
nested graph hierarchies. It will first render a group node, then all of its children.
To be more specific, the rendering order of nodes is determined by
the HierarchyManager.preTraverse(y.view.hierarchy.HierarchyManager.NodeVisitor)
method.
Optionally the rendering order can be controlled via the setDrawEdgesFirst(boolean)
,
the setLayeredPainting(boolean)
, and setNestedEdgeDrawingOrderEnabled(boolean)
properties.
Constructor Summary | |
---|---|
DefaultGraph2DRenderer()
|
Method Summary | |
---|---|
protected void |
beginLayerPainting(java.awt.Graphics2D gfx,
int layer,
boolean sloppy)
Callback that is called before the given layer is painted. |
protected void |
endLayerPainting(java.awt.Graphics2D gfx,
int layer,
boolean sloppy)
Callback that is called after the given layer has been painted. |
BridgeCalculator |
getBridgeCalculator()
Returns the currently installed BridgeCalculator instance or null if no such instance is installed. |
static BridgeCalculator |
getBridgeCalculator(EdgeRealizer er,
java.awt.Graphics2D gfx)
Determines and returns the currently used BridgeCalculator instance for the given
EdgeRealizer and Graphics context. |
int |
getClipEnlargementValue()
Returns the clip enlargement value. |
boolean |
getDrawEdgesFirst()
Returns the drawing order of edges and nodes. |
protected java.lang.Object |
getEdgeLock(Edge edge)
Returns the lock to synchronize intersects and
paint calls on for the given edge. |
java.lang.Object |
getGlobalLock()
Returns the global synchronization lock that should be used to synchronize all intersects and paint calls on. |
protected int |
getLayer(Graph2D graph,
Edge edge)
Callback method that determines the layer index for a given edge. |
protected int |
getLayer(Graph2D graph,
Node n)
Callback method that determines the layer index for a given node. |
protected java.lang.Object |
getNodeLock(Node node)
Returns the lock to synchronize intersects and
paint calls on for the given node. |
Graph2DTraversal |
getPaintOrder()
Returns a Graph2DTraversal that implies the rendering order
used by this DefaultGraph2DRenderer . |
Graph2DTraversal |
getSloppyPaintOrder()
Returns a Graph2DTraversal that implies the sloppy rendering
order used by this DefaultGraph2DRenderer . |
protected boolean |
intersects(EdgeRealizer er,
java.awt.geom.Rectangle2D region)
Checks if the given region overlaps with the edge. |
protected boolean |
intersects(NodeRealizer nr,
java.awt.geom.Rectangle2D region)
Checks if the given region overlaps with the node. |
boolean |
isDrawSelectionOnTop()
|
boolean |
isHierarchicSloppyPaintOrderEnabled()
Returns whether or not to paint nodes in the correct hierarchic order when in sloppy mode. |
boolean |
isLayeredPainting()
Determines whether layers should be used to influence the painting order. |
boolean |
isNestedEdgeDrawingOrderEnabled()
Returns whether or not edges and nodes are so that edges nested in other group nodes will be drawn in such an order that overlapping group nodes will not produce "unconnected edge" artifacts and edges will not be hidden by their encompassing group nodes. |
boolean |
isSloppyNestedEdgeDrawingOrderEnabled()
Determines the mode for the sloppy drawing order of edges and nodes. |
protected boolean |
isSynchronizationEnabled()
Determines whether or not intersects and paint
calls should be synchronized. |
protected void |
paint(java.awt.Graphics2D gfx,
EdgeRealizer er)
Paints the given edge realizer on the graphics context. |
void |
paint(java.awt.Graphics2D gfx,
Graph2D graph)
Renders the given graph2D on the given Graphics2D context. |
protected void |
paint(java.awt.Graphics2D gfx,
NodeRealizer nr)
Paints the given node realizer on the graphics context. |
protected void |
paintLayered(java.awt.Graphics2D gfx,
int layer,
EdgeRealizer edgeRealizer)
Callback that is called during a layered
painting of an EdgeRealizer. |
protected void |
paintLayered(java.awt.Graphics2D gfx,
int layer,
NodeRealizer nodeRealizer)
Callback that is called during a layered
painting of a NodeRealizer. |
protected void |
paintSloppy(java.awt.Graphics2D gfx,
EdgeRealizer er)
Paints the given edge realizer sloppily on the graphics context. |
void |
paintSloppy(java.awt.Graphics2D gfx,
Graph2D graph)
Renders the given Graph2D on the given Graphics2D context. |
protected void |
paintSloppy(java.awt.Graphics2D gfx,
NodeRealizer nr)
Paints the given node realizer sloppily on the graphics context. |
protected void |
paintSloppyLayered(java.awt.Graphics2D gfx,
int layer,
EdgeRealizer edgeRealizer)
Callback that is called during a sloppy layered
painting of an EdgeRealizer. |
protected void |
paintSloppyLayered(java.awt.Graphics2D gfx,
int layer,
NodeRealizer nodeRealizer)
Callback that is called during a sloppy layered
painting of a NodeRealizer. |
protected void |
prepareBridgeCalculator(BridgeCalculator bridgeCalculator,
Graph2D graph,
java.awt.geom.Rectangle2D clip)
Configures the BridgeCalculator instance appropriately by setting the right scope and resetting the instance on startup. |
void |
setBridgeCalculator(BridgeCalculator bridgeCalculator)
Sets a BridgeCalculator instance or null if no such instance is installed. |
void |
setClipEnlargementValue(int enlargement)
Sets the clip enlargement value. |
void |
setDrawEdgesFirst(boolean edgesFirst)
Sets the drawing order of edges and nodes. |
void |
setDrawSelectionOnTop(boolean drawSelectionOnTop)
Sets whether the selection and elements depending on the selection are drawn on top. |
void |
setGlobalLock(java.lang.Object lock)
Specifies the global synchronization lock that should be used to synchronize all intersects and paint calls on. |
void |
setHierarchicSloppyPaintOrderEnabled(boolean enabled)
Whether or not to paint nodes in the correct hierarchic order when when in sloppy mode. |
void |
setLayeredPainting(boolean layeredPainting)
Determines whether layers should be used to influence the painting order. |
void |
setNestedEdgeDrawingOrderEnabled(boolean nestedEdgeDrawing)
Influences the drawing order of edges and nodes. |
void |
setSloppyNestedEdgeDrawingOrderEnabled(boolean enabled)
Influences the sloppy drawing order of edges and nodes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultGraph2DRenderer()
Method Detail |
---|
public Graph2DTraversal getPaintOrder()
Graph2DTraversal
that implies the rendering order
used by this DefaultGraph2DRenderer
.
Note that the values of this DefaultGraph2DRenderer
's
layeredPainting
,
nestedEdgeDrawingOrderEnabled
, and
drawEdgesFirst
properties determine the order of elements
in the returned traversal's iterators.
getPaintOrder
in interface OrderRenderer
Graph2DTraversal
that implies the rendering order
used by this DefaultGraph2DRenderer
.public Graph2DTraversal getSloppyPaintOrder()
Graph2DTraversal
that implies the sloppy rendering
order used by this DefaultGraph2DRenderer
.
Note that the values of this DefaultGraph2DRenderer
's
layeredPainting
,
nestedEdgeDrawingOrderEnabled
,
drawEdgesFirst
, and
hierarchicSloppyPaintOrderEnabled
properties determine the
order of elements in the returned traversal's iterators.
getSloppyPaintOrder
in interface OrderRenderer
Graph2DTraversal
that implies the sloppy rendering
order used by this DefaultGraph2DRenderer
.public boolean isLayeredPainting()
false
.
public void setLayeredPainting(boolean layeredPainting)
false
.
If set to true
for each rendered element the getLayer(y.view.Graph2D, y.base.Edge)
and getLayer(y.view.Graph2D, y.base.Node)
methods respectively will be queried to determine
the layer and then they will be rendered layer by layer so that the elements with the lowest layer
index will be rendered first.
Eventually this will result in calls to paintLayered(java.awt.Graphics2D, int, y.view.NodeRealizer)
,
paintLayered(java.awt.Graphics2D, int, y.view.EdgeRealizer)
and their sloppy variants.
layeredPainting
- whether to use layer information for the rendering order.public void setNestedEdgeDrawingOrderEnabled(boolean nestedEdgeDrawing)
true
then
Group nodes will always be drawn in the correct hierarchical order but the
drawing of edges and nodes is interleaved. This means that depending on the
drawEdgesFirst
property edges will always be drawn in front of group nodes if
their end points belong to the respective group node. However one can still
decide whether nodes from the same nesting level should be painted over or under
those edges.
If the given argument is false
then
the other settings take effect.
By default this is set to false, i.e. the other settings determine the behavior.
setDrawEdgesFirst(boolean)
,
setHierarchicSloppyPaintOrderEnabled(boolean)
public boolean isNestedEdgeDrawingOrderEnabled()
setNestedEdgeDrawingOrderEnabled(boolean)
public BridgeCalculator getBridgeCalculator()
BridgeCalculator
instance or null
if no such instance is installed.
By default no instance is configured for a DefaultGraph2DRenderer instance.
prepareBridgeCalculator(y.view.BridgeCalculator, y.view.Graph2D, java.awt.geom.Rectangle2D)
public void setBridgeCalculator(BridgeCalculator bridgeCalculator)
BridgeCalculator
instance or null
if no such instance is installed.
By default no instance is configured for a DefaultGraph2DRenderer instance.
EdgeRealizer implementations interested in this instance can use the getBridgeCalculator(y.view.EdgeRealizer, java.awt.Graphics2D)
instance to query the current instance.
bridgeCalculator
- the new BridgeCalculator instance to use.prepareBridgeCalculator(y.view.BridgeCalculator, y.view.Graph2D, java.awt.geom.Rectangle2D)
public void setDrawEdgesFirst(boolean edgesFirst)
true
then
edges will be drawn prior to nodes. The effect of this setting
is that nodes will be drawn atop of all drawn edges.
If the given argument is false
then
nodes will drawn be prior to edges. The effect of that setting
is that nodes will be drawn beneath all drawn edges.
By default nodes will be drawn first, then edges.
public boolean getDrawEdgesFirst()
setDrawEdgesFirst(boolean)
public void setDrawSelectionOnTop(boolean drawSelectionOnTop)
drawSelectionOnTop
- whether the selection is drawn on toppublic boolean isDrawSelectionOnTop()
public void setClipEnlargementValue(int enlargement)
10
.
public int getClipEnlargementValue()
setClipEnlargementValue(int)
public void setHierarchicSloppyPaintOrderEnabled(boolean enabled)
public boolean isHierarchicSloppyPaintOrderEnabled()
setHierarchicSloppyPaintOrderEnabled(boolean)
public void paint(java.awt.Graphics2D gfx, Graph2D graph)
paint
in interface Graph2DRenderer
protected void beginLayerPainting(java.awt.Graphics2D gfx, int layer, boolean sloppy)
gfx
- the graphics to paint onlayer
- the layer that will be painted.sloppy
- whether to do sloppy paintingsetLayeredPainting(boolean)
protected void endLayerPainting(java.awt.Graphics2D gfx, int layer, boolean sloppy)
gfx
- the graphics to paint onlayer
- the layer that has been painted.sloppy
- whether to do sloppy paintingsetLayeredPainting(boolean)
protected void paintLayered(java.awt.Graphics2D gfx, int layer, NodeRealizer nodeRealizer)
layered
painting of a NodeRealizer.
This implementation simply delegates to paint(java.awt.Graphics2D, y.view.NodeRealizer)
gfx
- the graphics to uselayer
- the layer index to paint onnodeRealizer
- the node realizer to paintprotected void paintLayered(java.awt.Graphics2D gfx, int layer, EdgeRealizer edgeRealizer)
layered
painting of an EdgeRealizer.
This implementation simply delegates to paint(java.awt.Graphics2D, y.view.EdgeRealizer)
gfx
- the graphics to uselayer
- the layer index to paint onedgeRealizer
- the edge realizer to paintprotected void paintSloppyLayered(java.awt.Graphics2D gfx, int layer, NodeRealizer nodeRealizer)
layered
painting of a NodeRealizer.
This implementation simply delegates to paintSloppy(java.awt.Graphics2D, y.view.NodeRealizer)
gfx
- the graphics to uselayer
- the layer index to paint onnodeRealizer
- the node realizer to paintprotected void paintSloppyLayered(java.awt.Graphics2D gfx, int layer, EdgeRealizer edgeRealizer)
layered
painting of an EdgeRealizer.
This implementation simply delegates to paintSloppy(java.awt.Graphics2D, y.view.EdgeRealizer)
gfx
- the graphics to uselayer
- the layer index to paint onedgeRealizer
- the edge realizer to paintprotected int getLayer(Graph2D graph, Edge edge)
graph
- the graph that contains the edgeedge
- the edge to determine the layer index for
protected int getLayer(Graph2D graph, Node n)
graph
- the graph that contains the edgen
- the node to determine the layer index for
protected void prepareBridgeCalculator(BridgeCalculator bridgeCalculator, Graph2D graph, java.awt.geom.Rectangle2D clip)
BridgeCalculator.CROSSING_MODE_ORDER_INDUCED
This method will invoke for each EdgeRealizer EdgeRealizer.registerObstacles(y.view.BridgeCalculator)
.
bridgeCalculator
- the instance to prepare for the upcoming rendering to gfxgraph
- the graph that will be rendered in the following passclip
- the clip that will be used for the upcoming renderingpublic static BridgeCalculator getBridgeCalculator(EdgeRealizer er, java.awt.Graphics2D gfx)
BridgeCalculator
instance for the given
EdgeRealizer and Graphics context.
er
- the EdgeRealizer which is interested in the BridgeCalculatorgfx
- the gfx context that will be used to render the edge
null
setBridgeCalculator(y.view.BridgeCalculator)
,
getBridgeCalculator()
public void setSloppyNestedEdgeDrawingOrderEnabled(boolean enabled)
true
then
Group nodes will always be drawn in the correct hierarchical order but the
drawing of edges and nodes is interleaved. This means that depending on the
drawEdgesFirst
property edges will always be drawn in front of group nodes if
their end points belong to the respective group node. However one can still
decide whether nodes from the same nesting level should be painted over or under
those edges.
If the given argument is false
then
the other settings take effect.
By default this is set to false
, i.e. the other settings determine the behavior.
setDrawEdgesFirst(boolean)
,
setHierarchicSloppyPaintOrderEnabled(boolean)
,
isSloppyNestedEdgeDrawingOrderEnabled()
,
setNestedEdgeDrawingOrderEnabled(boolean)
public boolean isSloppyNestedEdgeDrawingOrderEnabled()
true
then
Group nodes will always be drawn in the correct hierarchical order but the
drawing of edges and nodes is interleaved. This means that depending on the
drawEdgesFirst
property edges will always be drawn in front of group nodes if
their end points belong to the respective group node. However one can still
decide whether nodes from the same nesting level should be painted over or under
those edges.
If the value is false
then
the other settings take effect.
By default this is set to false
, i.e. the other settings determine the behavior.
setDrawEdgesFirst(boolean)
,
setHierarchicSloppyPaintOrderEnabled(boolean)
,
setNestedEdgeDrawingOrderEnabled(boolean)
protected boolean intersects(NodeRealizer nr, java.awt.geom.Rectangle2D region)
nr
- the realizer of the noderegion
- the rectangular region to be tested
true
if the node intersects with the region, false
otherwise.protected boolean intersects(EdgeRealizer er, java.awt.geom.Rectangle2D region)
er
- the realizer of the edgeregion
- the rectangular region to be tested
true
if the edge crosses the region, false
otherwise.public void paintSloppy(java.awt.Graphics2D gfx, Graph2D graph)
paintSloppy
in interface Graph2DRenderer
protected void paint(java.awt.Graphics2D gfx, NodeRealizer nr)
protected void paint(java.awt.Graphics2D gfx, EdgeRealizer er)
protected void paintSloppy(java.awt.Graphics2D gfx, NodeRealizer nr)
protected void paintSloppy(java.awt.Graphics2D gfx, EdgeRealizer er)
public java.lang.Object getGlobalLock()
intersects
and paint
calls on.
By default, this lock will be null
and intersection
calculation and painting will not be synchronized.
setGlobalLock(Object)
,
isSynchronizationEnabled()
,
getNodeLock(y.base.Node)
,
getEdgeLock(y.base.Edge)
public void setGlobalLock(java.lang.Object lock)
intersects
and paint
calls on.
By default, this lock will be null
and intersection
calculation and painting will not be synchronized.
lock
- the object instance to synchronize all intersects
and paint
calls on.setGlobalLock(Object)
,
isSynchronizationEnabled()
,
getNodeLock(y.base.Node)
,
getEdgeLock(y.base.Edge)
protected boolean isSynchronizationEnabled()
intersects
and paint
calls should be synchronized. Intersection calculation and painting should
be synchronized if multiple threads paint one graph instance e.g. during
printing.
By default, this method returns true
if
getGlobalLock()
returns a non-null
global lock and
false
otherwise.
true
if intersects
and paint
calls should be synchronized; false
otherwise.getGlobalLock()
,
setGlobalLock(Object)
,
getNodeLock(y.base.Node)
,
getEdgeLock(y.base.Edge)
protected java.lang.Object getEdgeLock(Edge edge)
intersects
and
paint
calls on for the given edge.
By default, this method will return the given edge if this class' global
lock is null
; otherwise the global lock is returned.
Client code may overwrite this method for fine-grained control over synchronization locks.
This method may not return null
.
edge
- the edge that is about to be painted.
getGlobalLock()
,
isSynchronizationEnabled()
protected java.lang.Object getNodeLock(Node node)
intersects
and
paint
calls on for the given node.
By default, this method will return the given node if this class' global
lock is null
; otherwise the global lock is returned.
Client code may overwrite this method for fine-grained control over synchronization locks.
This method may not return null
.
node
- the node that is about to be painted.
getGlobalLock()
,
isSynchronizationEnabled()
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |