Search this API

y.view
Class ShinyPlateNodePainter

java.lang.Object
  extended by y.view.AbstractCustomNodePainter
      extended by y.view.ShinyPlateNodePainter
All Implemented Interfaces:
GenericNodeRealizer.ContainsTest, GenericNodeRealizer.Painter

public class ShinyPlateNodePainter
extends AbstractCustomNodePainter
implements GenericNodeRealizer.ContainsTest

Draws a simple floating shiny plate with a slight gradient, a thin border and an optional simple drop shadow.

 

Field Summary
static java.lang.String SHADOW_PAINTING_STYLE_ID
          Style property key to selectively turn shadow painting on or off.
 
Constructor Summary
ShinyPlateNodePainter()
          Creates a new instance of this Painter.
 
Method Summary
 boolean contains(NodeRealizer context, double x, double y)
          Determines if the point (x,y) lies within the given visual representation of a node.
protected  java.awt.Paint getEffectFillPaint(NodeRealizer context, java.awt.Graphics2D graphics)
          Determines the paint for the shiny plate effect.
 double getRadius()
          Returns the radius of the rounded corners of the rounded rectangle shape.
protected  double getRadius(NodeRealizer context)
          Callback to allow subclass to customize the corner radius depending on context.
 java.awt.Color getShadowColor()
          Gets the color of the shadow.
protected  java.awt.Color getShadowColor(NodeRealizer context)
          Callback invoked from paintShadow(NodeRealizer, java.awt.Graphics2D) to allow subclasses to customize shadow painting depending on context.
protected  boolean initializeEffectFillPaint(NodeRealizer context, java.awt.Graphics2D graphics)
          Initializes the graphics context for painting the shiny plate effect.
 boolean isDrawShadow()
          Returns whether the painter will draw a drop shadow effect.
protected  boolean isDrawShadow(NodeRealizer context)
          Callback invoked from paintShadow(NodeRealizer, java.awt.Graphics2D) to allow subclasses to customize shadow painting depending on context.
protected  void paintBackground(NodeRealizer context, java.awt.Graphics2D graphics)
          Paints the node's background.
protected  void paintBorder(NodeRealizer context, java.awt.Graphics2D graphics)
          Draws the border of the node.
protected  void paintEffect(NodeRealizer context, java.awt.Graphics2D graphics)
          Paints the shiny plate effect.
protected  void paintNode(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
          Paints the node.
protected  void paintShadow(NodeRealizer context, java.awt.Graphics2D graphics)
          Paints the shadow of the node.
 void setDrawShadow(boolean drawShadow)
          Sets whether the painter will draw a drop shadow effect.
 void setRadius(double radius)
          Sets the radius of the rounded corners of the rounded rectangle shape.
 void setShadowColor(java.awt.Color shadowColor)
          Sets the color of the shadow.
 
Methods inherited from class y.view.AbstractCustomNodePainter
backupGraphics, createSelectionColor, getFillColor, getFillColor2, getFillPaint, getLineColor, getLinePaint, getLineStroke, initializeFill, initializeLine, paint, paintHotSpots, paintPorts, paintSloppy, paintText, restoreGraphics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHADOW_PAINTING_STYLE_ID

public static final java.lang.String SHADOW_PAINTING_STYLE_ID
Style property key to selectively turn shadow painting on or off. An associated value of Boolean.TRUE will turn on shadow painting. An associated value of Boolean.FALSE will turn off shadow painting.

See Also:
YRenderingHints.isShadowPaintingEnabled(java.awt.Graphics2D), Constant Field Values
Constructor Detail

ShinyPlateNodePainter

public ShinyPlateNodePainter()
Creates a new instance of this Painter.

Method Detail

paintNode

protected void paintNode(NodeRealizer context,
                         java.awt.Graphics2D graphics,
                         boolean sloppy)
Paints the node. For detailed painting (i.e. sloppy==false), this method calls paintShadow, paintBackground, paintBorder, and paintEffect.

Specified by:
paintNode in class AbstractCustomNodePainter
Parameters:
context - the context node
graphics - the graphics context to use
sloppy - whether to draw the node sloppily
See Also:
paintShadow(NodeRealizer, java.awt.Graphics2D), paintBackground(NodeRealizer, java.awt.Graphics2D), paintBorder(NodeRealizer, java.awt.Graphics2D), paintEffect(NodeRealizer, java.awt.Graphics2D)

paintShadow

protected void paintShadow(NodeRealizer context,
                           java.awt.Graphics2D graphics)
Paints the shadow of the node. The shadow is only painted if shadow drawing is enabled.

Parameters:
context - the context node
graphics - the graphics context to use
See Also:
isDrawShadow(), setDrawShadow(boolean)

paintBackground

protected void paintBackground(NodeRealizer context,
                               java.awt.Graphics2D graphics)
Paints the node's background. The default implementation fills the node interior with the color returned by AbstractCustomNodePainter.getFillColor(NodeRealizer, boolean).

Parameters:
context - the context node
graphics - the graphics context to use

paintBorder

protected void paintBorder(NodeRealizer context,
                           java.awt.Graphics2D graphics)
Draws the border of the node. The default implementation uses the color and stroke returned by AbstractCustomNodePainter.getLineColor(NodeRealizer, boolean) and AbstractCustomNodePainter.getLineStroke(NodeRealizer, boolean) to draw the node border.

Parameters:
context - the context node
graphics - the graphics context to use

paintEffect

protected void paintEffect(NodeRealizer context,
                           java.awt.Graphics2D graphics)
Paints the shiny plate effect. This method calls initializeEffectFillPaint.

Parameters:
context - the context node
graphics - the graphics context to use
See Also:
initializeEffectFillPaint(NodeRealizer, java.awt.Graphics2D)

initializeEffectFillPaint

protected boolean initializeEffectFillPaint(NodeRealizer context,
                                            java.awt.Graphics2D graphics)
Initializes the graphics context for painting the shiny plate effect. If this method returns false, the shiny plate effect should not be applied. Calls getEffectFillPaint.

Parameters:
context - the context node
graphics - the graphics context to use
Returns:
true if the shiny plate effect should be painted, false otherwise.
See Also:
getEffectFillPaint(NodeRealizer, java.awt.Graphics2D)

getEffectFillPaint

protected java.awt.Paint getEffectFillPaint(NodeRealizer context,
                                            java.awt.Graphics2D graphics)
Determines the paint for the shiny plate effect.

Parameters:
context - the context node
graphics - the graphics context to use
Returns:
the paint for the shiny plate effect.

isDrawShadow

protected boolean isDrawShadow(NodeRealizer context)
Callback invoked from paintShadow(NodeRealizer, java.awt.Graphics2D) to allow subclasses to customize shadow painting depending on context. The default implementation calls isDrawShadow().

Parameters:
context - the context node
Returns:
true if the painter should draw a shadow; false otherwise.

isDrawShadow

public boolean isDrawShadow()
Returns whether the painter will draw a drop shadow effect. The default is true.

Returns:
whether the painter will draw a shadow

setDrawShadow

public void setDrawShadow(boolean drawShadow)
Sets whether the painter will draw a drop shadow effect. The default is true.

Parameters:
drawShadow - Whether to draw a drop shadow.

getRadius

protected double getRadius(NodeRealizer context)
Callback to allow subclass to customize the corner radius depending on context. The default implementation calls getRadius().

Parameters:
context - the context node
Returns:
the corner radius.

getRadius

public double getRadius()
Returns the radius of the rounded corners of the rounded rectangle shape.

Returns:
The radius of the rounded rectangle corners.

setRadius

public void setRadius(double radius)
Sets the radius of the rounded corners of the rounded rectangle shape.

Parameters:
radius - the radius to use for the rounded rectangle corners.

getShadowColor

protected java.awt.Color getShadowColor(NodeRealizer context)
Callback invoked from paintShadow(NodeRealizer, java.awt.Graphics2D) to allow subclasses to customize shadow painting depending on context. The default implementation calls getShadowColor().

Parameters:
context - the node context
Returns:
the color of the shadow.

getShadowColor

public java.awt.Color getShadowColor()
Gets the color of the shadow.

Returns:
the color of the shadow.

setShadowColor

public void setShadowColor(java.awt.Color shadowColor)
Sets the color of the shadow.

Parameters:
shadowColor - the color of the shadow.

contains

public boolean contains(NodeRealizer context,
                        double x,
                        double y)
Determines if the point (x,y) lies within the given visual representation of a node.

Specified by:
contains in interface GenericNodeRealizer.ContainsTest
Parameters:
context - the visual representation of a node.
x - the x-coordinate of the point.
y - the y-coordinate of the point.
Returns:
true if the point lies within the node; false otherwise.

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