Search this API

y.view
Class BevelNodePainter

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

public class BevelNodePainter
extends AbstractCustomNodePainter
implements GenericNodeRealizer.ContainsTest

This class is an implementation of GenericNodeRealizer.Painter that draws a rounded rectangle with a bevel border and an optional simple drop shadow in a shiny fashion.

 

Field Summary
static java.lang.String SHADOW_PAINTING_STYLE_ID
          Style property key to selectively turn shadow painting on or off.
 
Constructor Summary
BevelNodePainter()
           
 
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.
 double getInset()
           
protected  double getInset(NodeRealizer context)
          Callback to allow subclass to customize the bevel inset depending on context.
 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 paintNode(NodeRealizer, java.awt.Graphics2D, boolean) to allow subclasses to customize shadow painting depending on context.
 boolean isDrawShadow()
          Returns whether the painter will draw a drop shadow effect.
protected  boolean isDrawShadow(NodeRealizer context)
          Callback invoked from paintNode(NodeRealizer, java.awt.Graphics2D, boolean) to allow subclasses to customize shadow painting depending on context.
protected  void paintNode(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
          Paints a node realizer with a bevel border in a shiny fashion.
 void setDrawShadow(boolean drawShadow)
          Sets whether the painter will draw a drop shadow effect.
 void setInset(double inset)
          sets the distance of the bevel border from the real border.
 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

BevelNodePainter

public BevelNodePainter()
Method Detail

paintNode

protected void paintNode(NodeRealizer context,
                         java.awt.Graphics2D graphics,
                         boolean sloppy)
Paints a node realizer with a bevel border in a shiny fashion. The fill color is the basis for drawing the node. If the second fill color is set, it is used for creating gradients. If the line color is set, it is used for drawing the bevel border.

Specified by:
paintNode in class AbstractCustomNodePainter
Parameters:
context - the node realizer to be drawn
graphics - where to draw the node realizer
sloppy - if true, only a rectangle is drawn
See Also:
AbstractCustomNodePainter.initializeLine(NodeRealizer, Graphics2D), AbstractCustomNodePainter.initializeFill(NodeRealizer, Graphics2D)

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.

getInset

protected double getInset(NodeRealizer context)
Callback to allow subclass to customize the bevel inset depending on context. The default implementation calls getInset().

Parameters:
context - the context node
Returns:
the bevel inset.

getInset

public double getInset()
Returns:
the distance of the bevel border from the real border.

setInset

public void setInset(double inset)
sets the distance of the bevel border from the real border.

Parameters:
inset - inset of bevel border

isDrawShadow

protected boolean isDrawShadow(NodeRealizer context)
Callback invoked from paintNode(NodeRealizer, java.awt.Graphics2D, boolean) 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 false.

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 false.

Parameters:
drawShadow - whether to draw a shadow.

getShadowColor

protected java.awt.Color getShadowColor(NodeRealizer context)
Callback invoked from paintNode(NodeRealizer, java.awt.Graphics2D, boolean) 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.