Search this API

y.view
Class DefaultOrderRenderer

java.lang.Object
  extended by y.view.DefaultOrderRenderer
All Implemented Interfaces:
Graph2DRenderer, OrderRenderer

public class DefaultOrderRenderer
extends java.lang.Object
implements OrderRenderer

Default OrderRenderer implementation. The rendering order is specified using Graph2DTraversal instances.

 

Constructor Summary
DefaultOrderRenderer()
          Constructs a new DefaultOrderRenderer which uses instances of DefaultGraph2DTraversal to determine painting and sloppy painting order.
DefaultOrderRenderer(Graph2DTraversal paintOrder, Graph2DTraversal sloppyPaintOrder)
          Constructs a new DefaultOrderRenderer for the specified painting and sloppy painting orders.
 
Method Summary
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  java.lang.Object getNodeLock(Node node)
          Returns the lock to synchronize intersects and paint calls on for the given node.
 Graph2DTraversal getPaintOrder()
          Returns the Graph2DTraversal instance that determines this DefaultOrderRenderer's painting order.
 Graph2DTraversal getSloppyPaintOrder()
          Returns the Graph2DTraversal instance that determines this DefaultOrderRenderer's sloppy painting order.
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.
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 specified 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 specified graphics context.
protected  void paintSloppy(java.awt.Graphics2D gfx, EdgeRealizer er)
          Paints the given edge realizer sloppily on the specified 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 specified graphics context.
 void setGlobalLock(java.lang.Object lock)
          Specifies the global synchronization lock that should be used to synchronize all intersects and paint calls on.
 void setPaintOrder(Graph2DTraversal paintOrder)
          Specifies the Graph2DTraversal instance that determines this DefaultOrderRenderer's painting order.
 void setSloppyPaintOrder(Graph2DTraversal sloppyPaintOrder)
          Specifies the Graph2DTraversal instance that determines this DefaultOrderRenderer's sloppy painting order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultOrderRenderer

public DefaultOrderRenderer()
Constructs a new DefaultOrderRenderer which uses instances of DefaultGraph2DTraversal to determine painting and sloppy painting order.


DefaultOrderRenderer

public DefaultOrderRenderer(Graph2DTraversal paintOrder,
                            Graph2DTraversal sloppyPaintOrder)
Constructs a new DefaultOrderRenderer for the specified painting and sloppy painting orders.

Parameters:
paintOrder - a Graph2DTraversal whose firstToLast method determines this DefaultOrderRenderer painting order.
sloppyPaintOrder - a Graph2DTraversal whose firstToLast method determines this DefaultOrderRenderer sloppy painting order.
Method Detail

getPaintOrder

public Graph2DTraversal getPaintOrder()
Returns the Graph2DTraversal instance that determines this DefaultOrderRenderer's painting order.

Specified by:
getPaintOrder in interface OrderRenderer
Returns:
the Graph2DTraversal instance that determines this DefaultOrderRenderer's painting order.

setPaintOrder

public void setPaintOrder(Graph2DTraversal paintOrder)
Specifies the Graph2DTraversal instance that determines this DefaultOrderRenderer's painting order.

Parameters:
paintOrder - the Graph2DTraversal whose firstToLast method determines the painting order.

getSloppyPaintOrder

public Graph2DTraversal getSloppyPaintOrder()
Returns the Graph2DTraversal instance that determines this DefaultOrderRenderer's sloppy painting order.

Specified by:
getSloppyPaintOrder in interface OrderRenderer
Returns:
the Graph2DTraversal instance that determines this DefaultOrderRenderer's sloppy painting order.

setSloppyPaintOrder

public void setSloppyPaintOrder(Graph2DTraversal sloppyPaintOrder)
Specifies the Graph2DTraversal instance that determines this DefaultOrderRenderer's sloppy painting order.

Parameters:
sloppyPaintOrder - the Graph2DTraversal whose firstToLast method determines the sloppy painting order.

paint

public void paint(java.awt.Graphics2D gfx,
                  Graph2D graph)
Description copied from interface: Graph2DRenderer
Renders the given graph2D on the given Graphics2D context.

Specified by:
paint in interface Graph2DRenderer

paintSloppy

public void paintSloppy(java.awt.Graphics2D gfx,
                        Graph2D graph)
Description copied from interface: Graph2DRenderer
Renders the given graph2D on the given Graphics2D context. the rendering process should be quick and can be sloppy.

Specified by:
paintSloppy in interface Graph2DRenderer

paint

protected void paint(java.awt.Graphics2D gfx,
                     EdgeRealizer er)
Paints the given edge realizer on the specified graphics context.


paint

protected void paint(java.awt.Graphics2D gfx,
                     NodeRealizer nr)
Paints the given node realizer on the specified graphics context.


paintSloppy

protected void paintSloppy(java.awt.Graphics2D gfx,
                           EdgeRealizer er)
Paints the given edge realizer sloppily on the specified graphics context.


paintSloppy

protected void paintSloppy(java.awt.Graphics2D gfx,
                           NodeRealizer nr)
Paints the given node realizer sloppily on the specified graphics context.


intersects

protected boolean intersects(NodeRealizer nr,
                             java.awt.geom.Rectangle2D region)
Checks if the given region overlaps with the node. This method may be overwritten to adjust the intersection detection.

By default it is tested if the node's bounding box including labels and node ports overlaps with the region.

Parameters:
nr - the realizer of the node
region - the rectangular region to be tested
Returns:
true if the node intersects with the region, false otherwise.

intersects

protected boolean intersects(EdgeRealizer er,
                             java.awt.geom.Rectangle2D region)
Checks if the given region overlaps with the edge. This method may be overwritten to adjust the intersection detection.

By default it is tested if the bends and end points of the edge lie within the region, labels are ignored.

Parameters:
er - the realizer of the edge
region - the rectangular region to be tested
Returns:
true if the edge crosses the region, false otherwise.

getGlobalLock

public java.lang.Object getGlobalLock()
Returns the global synchronization lock that should be used to synchronize all intersects and paint calls on.

By default, this lock will be null and intersection calculation and painting will not be synchronized.

See Also:
setGlobalLock(Object), isSynchronizationEnabled(), getNodeLock(y.base.Node), getEdgeLock(y.base.Edge)

setGlobalLock

public void setGlobalLock(java.lang.Object lock)
Specifies the global synchronization lock that should be used to synchronize all intersects and paint calls on.

By default, this lock will be null and intersection calculation and painting will not be synchronized.

Parameters:
lock - the object instance to synchronize all intersects and paint calls on.
See Also:
setGlobalLock(Object), isSynchronizationEnabled(), getNodeLock(y.base.Node), getEdgeLock(y.base.Edge)

isSynchronizationEnabled

protected boolean isSynchronizationEnabled()
Determines whether or not 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.

Returns:
true if intersects and paint calls should be synchronized; false otherwise.
See Also:
getGlobalLock(), setGlobalLock(Object), getNodeLock(y.base.Node), getEdgeLock(y.base.Edge)

getEdgeLock

protected java.lang.Object getEdgeLock(Edge edge)
Returns the lock to synchronize 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.

Parameters:
edge - the edge that is about to be painted.
Returns:
the synchronization lock used for intersection calculation and painting of the given edge.
See Also:
getGlobalLock(), isSynchronizationEnabled()

getNodeLock

protected java.lang.Object getNodeLock(Node node)
Returns the lock to synchronize 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.

Parameters:
node - the node that is about to be painted.
Returns:
the synchronization lock used for intersection calculation and painting of the given node.
See Also:
getGlobalLock(), isSynchronizationEnabled()

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