Search this API

y.view
Class ShapeNodePainter

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

public class ShapeNodePainter
extends AbstractCustomNodePainter
implements GenericNodeRealizer.ContainsTest

This class represents a painter implementation for GenericNodeRealizer. It provides several geometric shapes like rectangle, rounded rectangle, ellipse, parallelogram, hexagon, triangle, octagon, diamond and trapezoid.

Method setGroupDepthFillColorEnabled(boolean) allows to define whether the fill color of the shapes shall be adapted to reflect the local group depth of the painted node within the graph hierarchy or not.

 
Your browser does not support SVG content.

Field Summary
static byte DIAMOND
          Shape type constant.
static byte ELLIPSE
          Shape type constant.
static byte FAT_ARROW
          Shape type constant.
static byte FAT_ARROW_2
          Shape type constant.
static byte HEXAGON
          Shape type constant.
static byte OCTAGON
          Shape type constant.
static byte PARALLELOGRAM
          Shape type constant.
static byte PARALLELOGRAM_2
          Shape type constant.
static byte RECT
          Shape type constant.
static byte RECT_3D
          Shape type constant.
static byte ROUND_RECT
          Shape type constant.
static byte STAR5
          Shape type constant.
static byte STAR6
          Shape type constant.
static byte STAR8
          Shape type constant.
static byte TRAPEZOID
          Shape type constant.
static byte TRAPEZOID_2
          Shape type constant.
static byte TRIANGLE
          Shape type constant.
static byte TRIANGLE_2
          Shape type constant.
 
Constructor Summary
ShapeNodePainter()
          Creates a new instance of ShapeNodePainter.
ShapeNodePainter(byte type)
          Creates a new instance of ShapeNodePainter with the given shape type.
 
Method Summary
 boolean contains(NodeRealizer context, double x, double y)
          Used as a callback for the GenericNodeRealizer.contains(double, double) method.
protected  java.awt.Color getFillColor(NodeRealizer context, boolean selected)
          Determines the fill color for the specified realizer.
protected  java.awt.Shape getShape(NodeRealizer context)
          Yields the shape that would be painted for the given context by this instance.
 byte getShapeType()
          Returns the shape type used for visualizing nodes.
 boolean isGroupDepthFillColorEnabled()
          Whether or not the fill color of the painted node should be adapted to reflect the local group depth of this node within the graph hierarchy.
protected  void paintFilledShape(NodeRealizer context, java.awt.Graphics2D graphics, java.awt.Shape shape)
          Responsible for painting the filled shape using a specific color or paint.
protected  void paintNode(NodeRealizer context, java.awt.Graphics2D graphics, boolean sloppy)
          Callback method to be overwritten by subclasses called by AbstractCustomNodePainter.paint(NodeRealizer, Graphics2D).
protected  void paintShapeBorder(NodeRealizer context, java.awt.Graphics2D graphics, java.awt.Shape shape)
          Responsible for painting the border or outline of the shape.
 void setGroupDepthFillColorEnabled(boolean enabled)
          Whether or not the fill color of the painted node should be adapted to reflect the local group depth of this node within the graph hierarchy.
 void setShapeType(byte type)
          Sets the shape type that is being used when painting the node.
 
Methods inherited from class y.view.AbstractCustomNodePainter
backupGraphics, createSelectionColor, 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

RECT

public static final byte RECT
Shape type constant. Specifies a rectangular shape.

See Also:
setShapeType(byte), Constant Field Values

ROUND_RECT

public static final byte ROUND_RECT
Shape type constant. Specifies a rectangular shape whose corners are rounded.

See Also:
setShapeType(byte), Constant Field Values

ELLIPSE

public static final byte ELLIPSE
Shape type constant. Specifies an oval (ellipsoid) shape.

See Also:
setShapeType(byte), Constant Field Values

PARALLELOGRAM

public static final byte PARALLELOGRAM
Shape type constant. Specifies a rhomboidal shape, whose upper right corner is further to the right than its lower right corner.

See Also:
setShapeType(byte), Constant Field Values

HEXAGON

public static final byte HEXAGON
Shape type constant. Specifies a hexagonal shape, i.e, a shape with six corners.

See Also:
setShapeType(byte), Constant Field Values

TRIANGLE

public static final byte TRIANGLE
Shape type constant. Specifies a triangular shape, i.e, a shape with three corners.

See Also:
setShapeType(byte), Constant Field Values

RECT_3D

public static final byte RECT_3D
Shape type constant. Specifies a rectangular shape with 3D-ish looks.

See Also:
setShapeType(byte), Constant Field Values

OCTAGON

public static final byte OCTAGON
Shape type constant. Specifies an octagonal shape, i.e, a shape with eight corners.

See Also:
setShapeType(byte), Constant Field Values

DIAMOND

public static final byte DIAMOND
Shape type constant. Specifies a diamond shape, i.e, a shape with four corners and diagonally sloped sides.

See Also:
setShapeType(byte), Constant Field Values

TRAPEZOID

public static final byte TRAPEZOID
Shape type constant. Specifies a trapezoidal shape, whose upper line is half as long as its lower line.

See Also:
setShapeType(byte), Constant Field Values

TRAPEZOID_2

public static final byte TRAPEZOID_2
Shape type constant. Specifies a trapezoidal shape, whose lower line is half as long as its upper line.

See Also:
setShapeType(byte), Constant Field Values

TRIANGLE_2

public static final byte TRIANGLE_2
Shape type constant. Specifies a triangular shape that points downwards.

See Also:
setShapeType(byte), Constant Field Values

PARALLELOGRAM_2

public static final byte PARALLELOGRAM_2
Shape type constant. Specifies a rhomboidal shape, whose upper left corner is further to the left than its lower left corner.

See Also:
setShapeType(byte), Constant Field Values

STAR5

public static final byte STAR5
Shape type constant. Specifies a 5-pointed star shape.

See Also:
setShapeType(byte), Constant Field Values

STAR6

public static final byte STAR6
Shape type constant. Specifies a 6-pointed star shape.

See Also:
setShapeType(byte), Constant Field Values

STAR8

public static final byte STAR8
Shape type constant. Specifies an 8-pointed star shape.

See Also:
setShapeType(byte), Constant Field Values

FAT_ARROW

public static final byte FAT_ARROW
Shape type constant. Specifies an arrow-like shape that points to the right.

See Also:
setShapeType(byte), Constant Field Values

FAT_ARROW_2

public static final byte FAT_ARROW_2
Shape type constant. Specifies an arrow-like shape that points to the left.

See Also:
setShapeType(byte), Constant Field Values
Constructor Detail

ShapeNodePainter

public ShapeNodePainter()
Creates a new instance of ShapeNodePainter. The shape type will be set to RECT.


ShapeNodePainter

public ShapeNodePainter(byte type)
Creates a new instance of ShapeNodePainter with the given shape type. Available types are: DIAMOND, ELLIPSE, FAT_ARROW, FAT_ARROW_2, HEXAGON, OCTAGON, PARALLELOGRAM, PARALLELOGRAM_2, RECT, RECT_3D, ROUND_RECT, STAR5, STAR6, STAR8, TRAPEZOID, TRAPEZOID_2, TRIANGLE, and TRIANGLE_2.

Parameters:
type - the type of shape used for visualizing nodes.
Method Detail

paintNode

protected void paintNode(NodeRealizer context,
                         java.awt.Graphics2D graphics,
                         boolean sloppy)
Description copied from class: AbstractCustomNodePainter
Callback method to be overwritten by subclasses called by AbstractCustomNodePainter.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.

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:
AbstractCustomNodePainter.initializeLine(NodeRealizer, Graphics2D), AbstractCustomNodePainter.initializeFill(NodeRealizer, Graphics2D)

paintFilledShape

protected void paintFilledShape(NodeRealizer context,
                                java.awt.Graphics2D graphics,
                                java.awt.Shape shape)
Responsible for painting the filled shape using a specific color or paint.

Parameters:
context - the node realizer that this painter is associated with.
graphics - the graphics context.
shape - the shape that shall be painted.

getFillColor

protected java.awt.Color getFillColor(NodeRealizer context,
                                      boolean selected)
Determines the fill color for the specified realizer. If groupDepthFillColorEnabled is true, the color depends on the hierarchical group depth of the node represented by the specified realizer. The deeper said node lies in the hierarchy, the darker the color returned.

Overrides:
getFillColor in class AbstractCustomNodePainter
Parameters:
context - the context node
selected - whether the node is currently selected
Returns:
the color to fill the shape of the specified realizer or null if the shape interior should not be painted.
See Also:
HierarchyManager.getLocalGroupDepth(y.base.Node)

paintShapeBorder

protected void paintShapeBorder(NodeRealizer context,
                                java.awt.Graphics2D graphics,
                                java.awt.Shape shape)
Responsible for painting the border or outline of the shape.

Parameters:
context - the node realizer that this painter is associated with.
graphics - the graphics context.
shape - the shape that shall be painted.

setShapeType

public void setShapeType(byte type)
Sets the shape type that is being used when painting the node. Available types are: DIAMOND, ELLIPSE, FAT_ARROW, FAT_ARROW_2, HEXAGON, OCTAGON, PARALLELOGRAM, PARALLELOGRAM_2, RECT, RECT_3D, ROUND_RECT, STAR5, STAR6, STAR8, TRAPEZOID, TRAPEZOID_2, TRIANGLE, and TRIANGLE_2.

Parameters:
type - the type of shape used for visualizing nodes.

getShapeType

public byte getShapeType()
Returns the shape type used for visualizing nodes.

Returns:
the shape type this painter instance uses for painting the node.

setGroupDepthFillColorEnabled

public void setGroupDepthFillColorEnabled(boolean enabled)
Whether or not the fill color of the painted node should be adapted to reflect the local group depth of this node within the graph hierarchy. By default this feature is enabled.

Parameters:
enabled - whether the group depth shall be reflected by the groups fill color. Default is true.

isGroupDepthFillColorEnabled

public boolean isGroupDepthFillColorEnabled()
Whether or not the fill color of the painted node should be adapted to reflect the local group depth of this node within the graph hierarchy. By default this feature is disabled.

Returns:
whether the group depth shall be reflected by the groups fill color. Default is true.
See Also:
setGroupDepthFillColorEnabled(boolean)

getShape

protected java.awt.Shape getShape(NodeRealizer context)
Yields the shape that would be painted for the given context by this instance.

Parameters:
context - the realizer from which the coordinates will be obtained.
Returns:
the Shape that is used for rendering

contains

public boolean contains(NodeRealizer context,
                        double x,
                        double y)
Description copied from interface: GenericNodeRealizer.ContainsTest
Used as a callback for the GenericNodeRealizer.contains(double, double) method.

Specified by:
contains in interface GenericNodeRealizer.ContainsTest

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