Search this API

y.view
Class GenericEdgePainter

java.lang.Object
  extended by y.view.GenericEdgePainter
All Implemented Interfaces:
GenericEdgeRealizer.Painter
Direct Known Subclasses:
FramedEdgePainter

public class GenericEdgePainter
extends java.lang.Object
implements GenericEdgeRealizer.Painter

This class serves as a base class for the GenericEdgeRealizer.Painter interface implementations. It offers convenient methods for partially overriding distinct behaviors during the rendering of edges.

See Also:
GenericEdgeRealizer
 
Your browser does not support SVG content.

Constructor Summary
GenericEdgePainter()
          Creates a new stateless instance of GenericEdgePainter
 
Method Summary
protected  java.awt.geom.GeneralPath adjustPath(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, BridgeCalculator bridgeCalculator, boolean selected)
          Callback method that can be used to adjust the calculated path before the final rendering.
protected  java.awt.Paint getLinePaint(EdgeRealizer context, boolean selected)
          Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the color of the line.
protected  java.awt.Stroke getLineStroke(EdgeRealizer context, boolean selected)
          Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the stroke of the line.
protected  java.awt.Paint getSelectionLinePaint(EdgeRealizer context, boolean selected)
          Callback method used by initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the color of the selection line.
protected  java.awt.Stroke getSelectionLineStroke(EdgeRealizer context, boolean selected)
          Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the selection line stroke.
protected  java.awt.Stroke getSloppyLineStroke(EdgeRealizer context, boolean selected)
          Callback method used by paintSloppy(EdgeRealizer, BendList, java.awt.geom.GeneralPath, java.awt.Graphics2D, boolean) to determine the stroke of the line.
protected  boolean initializeControlPolygonLine(EdgeRealizer context, java.awt.Graphics2D gfx, boolean selected)
          This utility function can be called by subclasses to initialize the graphics context for the drawing of the control polygon.
protected  boolean initializeLine(EdgeRealizer context, java.awt.Graphics2D gfx, boolean selected)
          This utility function can be called by subclasses to initialize the graphics context for the drawing of the lines of the edge.
protected  boolean initializeSelectionLine(EdgeRealizer context, java.awt.Graphics2D gfx, boolean selected)
          This utility function can be called by subclasses to initialize the graphics context for the drawing of the lines of the edge.
 void paint(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          Checks whether or not the edge is visible and recalculates the path if it is flagged dirty.
protected  void paintArrows(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx)
          This method paints the arrows of this edge.
protected  void paintBends(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          This method paints the bends of this edge.
protected  void paintControlPolygon(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          This method can be used to paint a control polygon.
protected  void paintHighlightedBends(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx)
          This method paints the highlighted bends of this edge.
protected  void paintLabels(EdgeRealizer context, java.awt.Graphics2D gfx, boolean selected)
          This method paints the labels that belong to this edge.
protected  void paintPath(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          Paints the actual path and decorations of the edge.
protected  void paintPorts(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          This method paints the ports of the edges.
 void paintSloppy(EdgeRealizer context, BendList bends, java.awt.geom.GeneralPath path, java.awt.Graphics2D gfx, boolean selected)
          This method paints the edge sloppily using simple and fast graphics operations.
protected  void renderPath(EdgeRealizer context, java.awt.Graphics2D gfx, java.awt.geom.GeneralPath path, boolean selected)
          This is a callback method that will be called finally to render the GeneralPath on the graphics context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericEdgePainter

public GenericEdgePainter()
Creates a new stateless instance of GenericEdgePainter

Method Detail

adjustPath

protected java.awt.geom.GeneralPath adjustPath(EdgeRealizer context,
                                               BendList bends,
                                               java.awt.geom.GeneralPath path,
                                               BridgeCalculator bridgeCalculator,
                                               boolean selected)
Callback method that can be used to adjust the calculated path before the final rendering. This method simply returns path or reverses the path when context.isReversedPathRenderingEnabled() returns true.

Parameters:
context - the EdgeRealizer context that is used for the current painting
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
bridgeCalculator - if a BridgeCalculator instance is associated with the current rendering, it will be passed through this parameter, otherwise it is null
selected - whether or not the edge should be painted in selected state
Returns:
the new path instance to use (may the modified path)

getLinePaint

protected java.awt.Paint getLinePaint(EdgeRealizer context,
                                      boolean selected)
Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the color of the line.

Parameters:
context - the context edge
selected - whether or not the edge is currently selected
Returns:
the Color to use or null

getSelectionLinePaint

protected java.awt.Paint getSelectionLinePaint(EdgeRealizer context,
                                               boolean selected)
Callback method used by initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the color of the selection line.

Parameters:
context - the context edge
selected - whether or not the edge is currently selected
Returns:
the Color to use or null

getLineStroke

protected java.awt.Stroke getLineStroke(EdgeRealizer context,
                                        boolean selected)
Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the stroke of the line. This method simply delegates to EdgeRealizer.getLineType().

Parameters:
context - the EdgeRealizer context that is used for the current painting
selected - whether or not the edge is selected
Returns:
the Stroke to use.

getSelectionLineStroke

protected java.awt.Stroke getSelectionLineStroke(EdgeRealizer context,
                                                 boolean selected)
Callback method used by initializeLine(EdgeRealizer,java.awt.Graphics2D,boolean) and initializeSelectionLine(EdgeRealizer,java.awt.Graphics2D,boolean) to determine the selection line stroke.

Parameters:
context - the EdgeRealizer context that is used for the current painting
selected - whether or not the edge is selected
Returns:
the Stroke to use for the selection line

getSloppyLineStroke

protected java.awt.Stroke getSloppyLineStroke(EdgeRealizer context,
                                              boolean selected)
Callback method used by paintSloppy(EdgeRealizer, BendList, java.awt.geom.GeneralPath, java.awt.Graphics2D, boolean) to determine the stroke of the line. This method simply returns LineType.LINE_1.

Parameters:
context - the EdgeRealizer context that is used for the current painting
selected - whether or not the edge is selected
Returns:
the Stroke to use.

initializeSelectionLine

protected boolean initializeSelectionLine(EdgeRealizer context,
                                          java.awt.Graphics2D gfx,
                                          boolean selected)
This utility function can be called by subclasses to initialize the graphics context for the drawing of the lines of the edge. If this method returns false no lines should be drawn.

Parameters:
context - the context edge
gfx - the graphics to configure
selected - whether or not the edge should be painted in selected state
Returns:
whether or not the line should be drawn

initializeLine

protected boolean initializeLine(EdgeRealizer context,
                                 java.awt.Graphics2D gfx,
                                 boolean selected)
This utility function can be called by subclasses to initialize the graphics context for the drawing of the lines of the edge. If this method returns false no lines should be drawn. This method uses methods getLinePaint(EdgeRealizer, boolean) and getLineStroke(EdgeRealizer, boolean) to initialize the graphics context.

Parameters:
context - the context edge
gfx - the graphics to configure
selected - whether or not the edge should be painted in selected state
Returns:
whether or not the line should be drawn

initializeControlPolygonLine

protected boolean initializeControlPolygonLine(EdgeRealizer context,
                                               java.awt.Graphics2D gfx,
                                               boolean selected)
This utility function can be called by subclasses to initialize the graphics context for the drawing of the control polygon. If this method returns false no lines should be drawn. This method simply delegates to initializeSelectionLine(EdgeRealizer, java.awt.Graphics2D, boolean) to initialize the graphics context.

Parameters:
context - the context edge
gfx - the graphics to configure
selected - whether or not the edge is selected
Returns:
whether or not the line should be drawn

paint

public void paint(EdgeRealizer context,
                  BendList bends,
                  java.awt.geom.GeneralPath path,
                  java.awt.Graphics2D gfx,
                  boolean selected)
Checks whether or not the edge is visible and recalculates the path if it is flagged dirty. Then this code calls the following method on a copy of the Graphics2D context.

Specified by:
paint in interface GenericEdgeRealizer.Painter
Parameters:
context - the EdgeRealizer context that is used for the current painting
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted selected

paintPath

protected void paintPath(EdgeRealizer context,
                         BendList bends,
                         java.awt.geom.GeneralPath path,
                         java.awt.Graphics2D gfx,
                         boolean selected)
Paints the actual path and decorations of the edge. This method will render the path using the settings initialized by initializeSelectionLine(EdgeRealizer, java.awt.Graphics2D, boolean) and render the path using the settings initialized by initializeLine(EdgeRealizer, java.awt.Graphics2D, boolean) as well as paint the arrows.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted selected

paintControlPolygon

protected void paintControlPolygon(EdgeRealizer context,
                                   BendList bends,
                                   java.awt.geom.GeneralPath path,
                                   java.awt.Graphics2D gfx,
                                   boolean selected)
This method can be used to paint a control polygon. This implementation does nothing.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted selected

renderPath

protected void renderPath(EdgeRealizer context,
                          java.awt.Graphics2D gfx,
                          java.awt.geom.GeneralPath path,
                          boolean selected)
This is a callback method that will be called finally to render the GeneralPath on the graphics context. This implementation calls gfx.draw(path).

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted selected

paintLabels

protected void paintLabels(EdgeRealizer context,
                           java.awt.Graphics2D gfx,
                           boolean selected)
This method paints the labels that belong to this edge.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
selected - whether or not the edge should be painted selected

paintPorts

protected void paintPorts(EdgeRealizer context,
                          BendList bends,
                          java.awt.geom.GeneralPath path,
                          java.awt.Graphics2D gfx,
                          boolean selected)
This method paints the ports of the edges.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted selected

paintHighlightedBends

protected void paintHighlightedBends(EdgeRealizer context,
                                     BendList bends,
                                     java.awt.geom.GeneralPath path,
                                     java.awt.Graphics2D gfx)
This method paints the highlighted bends of this edge.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.

paintBends

protected void paintBends(EdgeRealizer context,
                          BendList bends,
                          java.awt.geom.GeneralPath path,
                          java.awt.Graphics2D gfx,
                          boolean selected)
This method paints the bends of this edge.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted in selected state

paintArrows

protected void paintArrows(EdgeRealizer context,
                           BendList bends,
                           java.awt.geom.GeneralPath path,
                           java.awt.Graphics2D gfx)
This method paints the arrows of this edge.

Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.

paintSloppy

public void paintSloppy(EdgeRealizer context,
                        BendList bends,
                        java.awt.geom.GeneralPath path,
                        java.awt.Graphics2D gfx,
                        boolean selected)
This method paints the edge sloppily using simple and fast graphics operations.

Specified by:
paintSloppy in interface GenericEdgeRealizer.Painter
Parameters:
context - the EdgeRealizer context that is used for the current painting
gfx - the graphics context to use
bends - the list of bends that the current context holds
path - the GeneralPath instance that can be used to calculate a new result.
selected - whether or not the edge should be painted in selected state

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