Search this API

y.view
Class AbstractCustomNodePainter

java.lang.Object
  extended by y.view.AbstractCustomNodePainter
All Implemented Interfaces:
GenericNodeRealizer.Painter
Direct Known Subclasses:
BevelNodePainter, GeneralPathNodePainter, ImageNodePainter, NodeCellRendererPainter, ShapeNodePainter, ShinyPlateNodePainter

public abstract class AbstractCustomNodePainter
extends java.lang.Object
implements GenericNodeRealizer.Painter

Abstract base class that can be used with customizations of GenericNodeRealizer instances. This base class contains useful utility functions and delegates the actual work to one simple abstract method.

 
Your browser does not support SVG content.

Constructor Summary
AbstractCustomNodePainter()
          Creates a new instance of AbstractCustomNodePainter
 
Method Summary
protected  void backupGraphics(java.awt.Graphics2D graphics)
          This method should store the graphics context so that all state of the context can be reversed in a subsequent call to restoreGraphics(Graphics2D) This implementation stores and restores the color, the stroke, and the paint of the graphics context.
protected  java.awt.Color createSelectionColor(java.awt.Color original)
          Callback function that calculates/modifies a given Color instance for the selected use case.
protected  java.awt.Color getFillColor(NodeRealizer context, boolean selected)
          Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the first color for the fill.
protected  java.awt.Color getFillColor2(NodeRealizer context, boolean selected)
          Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the second color for the fill.
protected  java.awt.Paint getFillPaint(NodeRealizer context, boolean selected)
          Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the paint for the fill.
protected  java.awt.Color getLineColor(NodeRealizer context, boolean selected)
          Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the color of the lines.
protected  java.awt.Paint getLinePaint(NodeRealizer context, boolean selected)
          Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the color of the line.
protected  java.awt.Stroke getLineStroke(NodeRealizer context, boolean selected)
          Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the stroke of the lines.
protected  boolean initializeFill(NodeRealizer context, java.awt.Graphics2D graphics)
          This utility function can be called by subclasses to initialize the graphics context for the filling of the node.
protected  boolean initializeLine(NodeRealizer context, java.awt.Graphics2D graphics)
          This utility function can be called by subclasses to initialize the graphics context for the drawing of the lines of the node.
 void paint(NodeRealizer context, java.awt.Graphics2D graphics)
          Calls the various utility method and callbacks in this class.
protected  void paintHotSpots(NodeRealizer context, java.awt.Graphics2D graphics)
          This method is invoked from paint(NodeRealizer, Graphics2D) to draw the hot spots of the node if necessary.
protected abstract  void paintNode(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
          Callback method to be overwritten by subclasses called by paint(NodeRealizer, Graphics2D).
protected  void paintPorts(NodeRealizer context, java.awt.Graphics2D graphics)
          This method is invoked from paint(NodeRealizer, Graphics2D) to draw the ports of the node.
 void paintSloppy(NodeRealizer context, java.awt.Graphics2D graphics)
          Delegates to paintNode(NodeRealizer, Graphics2D, boolean) if the node is visible.
protected  void paintText(NodeRealizer context, java.awt.Graphics2D graphics)
          This method is invoked from paint(NodeRealizer, Graphics2D) to draw the labels of the node.
protected  void restoreGraphics(java.awt.Graphics2D graphics)
          This method should restore the graphics context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCustomNodePainter

public AbstractCustomNodePainter()
Creates a new instance of AbstractCustomNodePainter

Method Detail

paint

public void paint(NodeRealizer context,
                  java.awt.Graphics2D graphics)
Calls the various utility method and callbacks in this class.

Specified by:
paint in interface GenericNodeRealizer.Painter

backupGraphics

protected void backupGraphics(java.awt.Graphics2D graphics)
This method should store the graphics context so that all state of the context can be reversed in a subsequent call to restoreGraphics(Graphics2D) This implementation stores and restores the color, the stroke, and the paint of the graphics context.

Parameters:
graphics - the graphics to store the context

paintHotSpots

protected void paintHotSpots(NodeRealizer context,
                             java.awt.Graphics2D graphics)
This method is invoked from paint(NodeRealizer, Graphics2D) to draw the hot spots of the node if necessary. By default it calls the context's paintHotSpots method if the context is selected.

Parameters:
context - the node realizer for which hot spots may be drawn
graphics - the graphics to draw on

paintText

protected void paintText(NodeRealizer context,
                         java.awt.Graphics2D graphics)
This method is invoked from paint(NodeRealizer, Graphics2D) to draw the labels of the node. By default it calls the context's paintText method if the context has at least one label.

Parameters:
context - the node realizer for which the labels should be drawn
graphics - the graphics to draw on

paintPorts

protected void paintPorts(NodeRealizer context,
                          java.awt.Graphics2D graphics)
This method is invoked from paint(NodeRealizer, Graphics2D) to draw the ports of the node. By default it calls the context's paintPorts method.

Parameters:
context - the node realizer for which node ports should be drawn.
graphics - the graphics to draw on.

restoreGraphics

protected void restoreGraphics(java.awt.Graphics2D graphics)
This method should restore the graphics context. All state of the context should be reverted to the state before the call to backupGraphics(Graphics2D) This implementation stores and restores the color, the stroke, and the paint of the graphics context.

Parameters:
graphics - the graphics to restore the context

initializeLine

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

Parameters:
context - the context node
graphics - the graphics to configure
Returns:
whether the line should be drawn

initializeFill

protected boolean initializeFill(NodeRealizer context,
                                 java.awt.Graphics2D graphics)
This utility function can be called by subclasses to initialize the graphics context for the filling of the node. If this method returns false the node should not be filled.

Parameters:
context - the context node
graphics - the graphics to configure
Returns:
whether the node should be filled

getLineColor

protected java.awt.Color getLineColor(NodeRealizer context,
                                      boolean selected)
Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the color of the lines.

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

getLineStroke

protected java.awt.Stroke getLineStroke(NodeRealizer context,
                                        boolean selected)
Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the stroke of the lines.

Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the stroke to use

getLinePaint

protected java.awt.Paint getLinePaint(NodeRealizer context,
                                      boolean selected)
Callback method used by initializeLine(NodeRealizer, Graphics2D) to determine the color of the line. This methods simply delegates to getLineColor(NodeRealizer, boolean)

Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the Paint to use or null

createSelectionColor

protected java.awt.Color createSelectionColor(java.awt.Color original)
Callback function that calculates/modifies a given Color instance for the selected use case.

Parameters:
original - the color to transform to for the selected case
Returns:
the new color

getFillColor

protected java.awt.Color getFillColor(NodeRealizer context,
                                      boolean selected)
Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the first color for the fill.

Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the color to use or null

getFillPaint

protected java.awt.Paint getFillPaint(NodeRealizer context,
                                      boolean selected)
Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the paint for the fill. This method simply delegates to getFillColor(NodeRealizer, boolean)

Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the paint to use or null

getFillColor2

protected java.awt.Color getFillColor2(NodeRealizer context,
                                       boolean selected)
Callback method used by initializeFill(NodeRealizer, Graphics2D) to determine the second color for the fill.

Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the color to use or null

paintNode

protected abstract void paintNode(NodeRealizer context,
                                  java.awt.Graphics2D graphics,
                                  boolean sloppy)
Callback method to be overwritten by subclasses called by paint(NodeRealizer, Graphics2D). This method is responsible for drawing the actual node only - neither the hotspots, nor the labels, should be painted by this method.

Parameters:
context - the context node
graphics - the graphics context to use
sloppy - whether to draw the node sloppily
See Also:
initializeLine(NodeRealizer, Graphics2D), initializeFill(NodeRealizer, Graphics2D)

paintSloppy

public void paintSloppy(NodeRealizer context,
                        java.awt.Graphics2D graphics)
Delegates to paintNode(NodeRealizer, Graphics2D, boolean) if the node is visible.

Specified by:
paintSloppy in interface GenericNodeRealizer.Painter
Parameters:
context - the context node
graphics - the graphics context to use

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