y.view
Class DefaultGraph2DRenderer

java.lang.Object
  |
  +--y.view.DefaultGraph2DRenderer
All Implemented Interfaces:
Graph2DRenderer

public class DefaultGraph2DRenderer
extends Object
implements Graph2DRenderer

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.


Constructor Summary
DefaultGraph2DRenderer()
           
 
Method Summary
 int getClipEnlargementValue()
          Returns the clip enlargemnt value.
 boolean getDrawEdgesFirst()
          Returns the drawing order of edges and nodes.
 boolean isHierarchicSloppyPaintOrderEnabled()
          Returns whether or not to paint nodes in the correct hierarchic order when when in sloppy mode.
protected  void paint(Graphics2D gfx, EdgeRealizer er)
          Paints the given edge realizer on the graphics context.
 void paint(Graphics2D gfx, Graph2D graph)
          Renders the given graph2D on the given Graphics2D context.
protected  void paint(Graphics2D gfx, NodeRealizer nr)
          Paints the given node realizer on the graphics context.
protected  void paintSloppy(Graphics2D gfx, EdgeRealizer er)
          Paints the given edge realizer sloppily on the graphics context.
 void paintSloppy(Graphics2D gfx, Graph2D graph)
          Renders the given Graph2D on the given Graphics2D context.
protected  void paintSloppy(Graphics2D gfx, NodeRealizer nr)
          Paints the given node realizer sloppily on the graphics context.
 void setClipEnlargementValue(int enlargement)
          Sets the clip enlargemnt value.
 void setDrawEdgesFirst(boolean edgesFirst)
          Sets the drawing order of edges and nodes.
 void setHierarchicSloppyPaintOrderEnabled(boolean enabled)
          Whether or not to paint nodes in the correct hierarchic order when when in sloppy mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGraph2DRenderer

public DefaultGraph2DRenderer()
Method Detail

setDrawEdgesFirst

public void setDrawEdgesFirst(boolean edgesFirst)
Sets the drawing order of edges and nodes. If the given argument is 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.


getDrawEdgesFirst

public boolean getDrawEdgesFirst()
Returns the drawing order of edges and nodes.

See Also:
DefaultGraph2DRenderer.setDrawEdgesFirst(boolean)

setClipEnlargementValue

public void setClipEnlargementValue(int enlargement)
Sets the clip enlargemnt value. Before a graph object gets rendered by this class, it will be tested if it intersects the clip bounds. This test relies upon the results of the node and edgerealizer intersection methods. If these intersection methods are not accurate enough, repaint errors can be the result. Increasing the clip enlargement value for this class can prevent such errors, by clipping objects more defensively.

By default this value is set to 10.


getClipEnlargementValue

public int getClipEnlargementValue()
Returns the clip enlargemnt value.

See Also:
DefaultGraph2DRenderer.setClipEnlargementValue(int)

setHierarchicSloppyPaintOrderEnabled

public void setHierarchicSloppyPaintOrderEnabled(boolean enabled)
Whether or not to paint nodes in the correct hierarchic order when when in sloppy mode. By default this feature is enabled.


isHierarchicSloppyPaintOrderEnabled

public boolean isHierarchicSloppyPaintOrderEnabled()
Returns whether or not to paint nodes in the correct hierarchic order when when in sloppy mode.

See Also:
DefaultGraph2DRenderer.setHierarchicSloppyPaintOrderEnabled(boolean)

paint

public void paint(Graphics2D gfx,
                  Graph2D graph)
Renders the given graph2D on the given Graphics2D context. Rendering is performed by calling the paint() method of each Node- and EdgeRealizer associated with the nodes and edges of the graph.

Specified by:
paint in interface Graph2DRenderer

paintSloppy

public void paintSloppy(Graphics2D gfx,
                        Graph2D graph)
Renders the given Graph2D on the given Graphics2D context. the rendering process should be quick and can be sloppy.

Rendering is performed by calling the paintSloppy() method of each Node- and EdgeRealizer associated with the nodes and edges of the graph.

Specified by:
paintSloppy in interface Graph2DRenderer

paint

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


paint

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


paintSloppy

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


paintSloppy

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


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

2003