Search this API

y.view
Class ShapePortConfiguration

java.lang.Object
  extended by y.view.ShapePortConfiguration
All Implemented Interfaces:
NodePort.BoundsProvider, NodePort.ContainsTest, NodePort.IntersectionTest, NodePort.Painter, NodePort.UnionRectCalculator

public class ShapePortConfiguration
extends java.lang.Object
implements NodePort.Painter, NodePort.IntersectionTest, NodePort.ContainsTest, NodePort.BoundsProvider, NodePort.UnionRectCalculator

Fallback implementations for NodePort implementation interfaces related to visual representation for the simplest case of a rectangular port shape.

 

Constructor Summary
ShapePortConfiguration()
          Initializes a new ShapePortConfiguration instance.
 
Method Summary
 void calcUnionRect(NodePort port, java.awt.geom.Rectangle2D r)
          Calculates the rectangular union of the specified rectangle and the specified port's bounds.
 boolean contains(NodePort port, double x, double y)
          Returns true if the specified port contains the specified point and false otherwise.
 boolean findIntersection(NodePort port, double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
          Returns true if the point i=(ix,iy) lies inside and the point o=(ox,oy) lies outside the specified port and false< otherwise.
 YRectangle getBounds(NodePort port)
          Returns the bounds of the specified port in absolute world (graph) coordinates.
protected  java.awt.Color getPortLineColor(NodeRealizer context, boolean selected)
          Deprecated. Use getPortLineColor(NodeRealizer, NodePort, boolean) instead.
protected  java.awt.Color getPortLineColor(NodeRealizer context, NodePort port, boolean selected)
          Determines the color to draw the border of the specified node port.
protected  java.awt.Paint getPortPaint(NodeRealizer context, boolean selected)
          Deprecated. Use getPortPaint(NodeRealizer, NodePort, boolean) instead.
protected  java.awt.Paint getPortPaint(NodeRealizer context, NodePort port, boolean selected)
          Determines the paint to fill the specified node port.
protected  java.awt.Stroke getPortStroke(NodeRealizer context, boolean selected)
          Deprecated. Use getPortStroke(NodeRealizer, NodePort, boolean) instead.
protected  java.awt.Stroke getPortStroke(NodeRealizer context, NodePort port, boolean selected)
          Determines the stroke to use for the border of the specified node port.
 YPoint getRatio()
          Returns the ratio that is used to determine the edge connection point with respect to the NodePorts bounds.
 YDimension getSize()
          Returns the size of the visual representation of NodePorts that use this configuration.
protected  boolean initializeFill(NodeRealizer context, NodePort port, java.awt.Graphics2D g)
          Initializes the graphics context for the filling of the specified port.
protected  boolean initializeLine(NodeRealizer context, NodePort port, java.awt.Graphics2D g)
          Initializes the graphics context for the drawing of the border of the specified port.
 void paint(NodePort port, java.awt.Graphics2D g)
          Paints the specified port.
protected  void paintSelectionBox(NodeRealizer context, NodePort port, java.awt.Graphics2D g)
          Paints a selection frame for the specified node port if the port's selection state is true.
 void setRatio(double x, double y)
          Specifies the ratio that is used to determine the edge connection point with respect to the NodePorts width.
 void setRatio(YPoint ratio)
          Specifies the ratio that is used to determine the edge connection point with respect to the NodePorts width.
 void setSize(double width, double height)
          Specifies the size of the visual representation of NodePorts that use this configuration.
 void setSize(YDimension size)
          Specifies the size of the visual representation of NodePorts that use this configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapePortConfiguration

public ShapePortConfiguration()
Initializes a new ShapePortConfiguration instance.

Method Detail

getSize

public YDimension getSize()
Returns the size of the visual representation of NodePorts that use this configuration.

Returns:
the size of the NodePorts that use this configuration.
See Also:
setSize(y.geom.YDimension), setSize(double, double)

setSize

public void setSize(YDimension size)
Specifies the size of the visual representation of NodePorts that use this configuration.

Parameters:
size - the new size of NodePorts that use this configuration.
Throws:
java.lang.IllegalArgumentException - it size is null or the specified instance's width or height are less than 0, NaN, or infinitely large in magnitude.
See Also:
getSize(), setSize(double, double)

setSize

public void setSize(double width,
                    double height)
Specifies the size of the visual representation of NodePorts that use this configuration.

Calling this method is equivalent to

setSize(new YDimension(width, height))

Parameters:
width - the new width of NodePorts that use this configuration.
height - the new height of NodePorts that use this configuration.
Throws:
java.lang.IllegalArgumentException - it size is null or the specified instance's width or height are less than 0, NaN, or infinitely large in magnitude.
See Also:
getSize(), setSize(y.geom.YDimension)

getRatio

public YPoint getRatio()
Returns the ratio that is used to determine the edge connection point with respect to the NodePorts bounds. A x/y value of 0 means the edge connection point is at the left/top border of the NodePort's visual representation; a x/y value of 0.5 means the edge connection point is in the center of the NodePort's visual representation; and a x/y value of 1 means the edge connection point is at the right/bottom border of the NodePort's visual representation.

By default, this property is set to (0.5,0.5).

Returns:
a value in [0,1]^2.
See Also:
setRatio(y.geom.YPoint), setRatio(double, double)

setRatio

public void setRatio(YPoint ratio)
Specifies the ratio that is used to determine the edge connection point with respect to the NodePorts width. A x/y value of 0 means the edge connection point is at the left/top border of the NodePort's visual representation; a x/y value of 0.5 means the edge connection point is in the center of the NodePort's visual representation; and a x/y value of 1 means the edge connection point is at the right/bottom border of the NodePort's visual representation.

By default, this property is set to (0.5,0.5).

Parameters:
ratio - a value in [0,1]^2.
Throws:
java.lang.IllegalArgumentException - if x/y is less than 0, larger than 1, or NaN.
See Also:
getRatio(), setRatio(double, double)

setRatio

public void setRatio(double x,
                     double y)
Specifies the ratio that is used to determine the edge connection point with respect to the NodePorts width.

Calling this method is equivalent to

setRatio(new YPoint(x, y))

Parameters:
x - a value in [0,1].
y - a value in [0,1].
Throws:
java.lang.IllegalArgumentException - if x/y is less than 0, larger than 1, or NaN.
See Also:
getRatio(), setRatio(double, double)

contains

public boolean contains(NodePort port,
                        double x,
                        double y)
Description copied from interface: NodePort.ContainsTest
Returns true if the specified port contains the specified point and false otherwise.

Callback method for NodePort.contains(double, double).

Specified by:
contains in interface NodePort.ContainsTest
Parameters:
port - the port instance to check.
x - the x-coordinate of the point to check.
y - the y-coordinate of the point to check.
Returns:
true if the specified port contains the specified point and false otherwise.

findIntersection

public boolean findIntersection(NodePort port,
                                double ix,
                                double iy,
                                double ox,
                                double oy,
                                java.awt.geom.Point2D result)
Description copied from interface: NodePort.IntersectionTest
Returns true if the point i=(ix,iy) lies inside and the point o=(ox,oy) lies outside the specified port and false< otherwise.

Callback method for NodePort.findIntersection(double, double, double, double, java.awt.geom.Point2D).

Specified by:
findIntersection in interface NodePort.IntersectionTest
Parameters:
port - the port instance to check.
ix - the x-coordinate of the point that has to lie inside the port.
iy - the y-coordinate of the point that has to lie inside the port.
ox - the x-coordinate of the point that has to lie outside the port.
oy - the y-coordinate of the point that has to lie outside the port.
result - an output parameter to store the intersection of the line segment through i and o and the port. If this method returns false, the value of this parameter is undefined.
Returns:
true if (ix,iy) lies inside and (ox,oy) lies outside the specified port and false< otherwise.

paint

public void paint(NodePort port,
                  java.awt.Graphics2D g)
Paints the specified port. The default implementation calls initializeFill, initializeLine, and paintSelectionBox.

Specified by:
paint in interface NodePort.Painter
Parameters:
port - the port instance to paint.
g - the graphics context to paint upon.
See Also:
initializeFill(NodeRealizer, NodePort, java.awt.Graphics2D), initializeLine(NodeRealizer, NodePort, java.awt.Graphics2D), paintSelectionBox(NodeRealizer, NodePort, java.awt.Graphics2D)

paintSelectionBox

protected void paintSelectionBox(NodeRealizer context,
                                 NodePort port,
                                 java.awt.Graphics2D g)
Paints a selection frame for the specified node port if the port's selection state is true. Called from paint.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
g - the graphics context to paint upon.
See Also:
paint(NodePort, java.awt.Graphics2D)

initializeFill

protected boolean initializeFill(NodeRealizer context,
                                 NodePort port,
                                 java.awt.Graphics2D g)
Initializes the graphics context for the filling of the specified port. If this method returns false the node should not be filled. Called from paint.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
g - the graphics context to paint upon.
Returns:
true if the interior of the specified port should be filled; false otherwise.
See Also:
paint(NodePort, java.awt.Graphics2D)

getPortPaint

protected java.awt.Paint getPortPaint(NodeRealizer context,
                                      NodePort port,
                                      boolean selected)
Determines the paint to fill the specified node port. Called from initializeFill.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the paint to fill the specified node port or null if the interior of the port should not be filled at all.
See Also:
initializeFill(NodeRealizer, NodePort, java.awt.Graphics2D)

getPortPaint

protected java.awt.Paint getPortPaint(NodeRealizer context,
                                      boolean selected)
Deprecated. Use getPortPaint(NodeRealizer, NodePort, boolean) instead.

Determines the paint to fill NodePorts associated to the specified realizer.

Parameters:
context - the realizer whose NodePorts are painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the paint to fill NodePorts associated to the specified realizer or null if the interior of NodePorts should not be filled at all.

initializeLine

protected boolean initializeLine(NodeRealizer context,
                                 NodePort port,
                                 java.awt.Graphics2D g)
Initializes the graphics context for the drawing of the border of the specified port. If this method returns false no border should be drawn. Called from paint.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
g - the graphics context to paint upon.
Returns:
true if the border of the specified ports should be drawn; false otherwise.
See Also:
paint(NodePort, java.awt.Graphics2D)

getPortStroke

protected java.awt.Stroke getPortStroke(NodeRealizer context,
                                        NodePort port,
                                        boolean selected)
Determines the stroke to use for the border of the specified node port. Called from initializeLine.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the stroke to use for the border of the specified node port or null if no border should be drawn.

getPortStroke

protected java.awt.Stroke getPortStroke(NodeRealizer context,
                                        boolean selected)
Deprecated. Use getPortStroke(NodeRealizer, NodePort, boolean) instead.

Determines the stroke to use for the border of NodePorts associated to the specified realizer.

Parameters:
context - the realizer whose NodePorts are painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the stroke to use for the border of NodePorts associated to the specified realizer or null if no border should be drawn.

getPortLineColor

protected java.awt.Color getPortLineColor(NodeRealizer context,
                                          NodePort port,
                                          boolean selected)
Determines the color to draw the border of the specified node port. Called from initializeLine.

Parameters:
context - the realizer whose NodePorts are painted.
port - the NodePort instance that is painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the color to draw the border of the specified node port or null if no border should be drawn.

getPortLineColor

protected java.awt.Color getPortLineColor(NodeRealizer context,
                                          boolean selected)
Deprecated. Use getPortLineColor(NodeRealizer, NodePort, boolean) instead.

Determines the color to draw the border of NodePorts associated with the specified realizer.

The default implementation checks whether the context realizer has a line color set and if so returns that color; otherwise black is returned.

Parameters:
context - the realizer whose NodePorts are painted.
selected - the selection state of the NodePort instance that is painted.
Returns:
the color to draw the border of NodePorts associated to the specified realizer or null if no border should be drawn.

getBounds

public YRectangle getBounds(NodePort port)
Description copied from interface: NodePort.BoundsProvider
Returns the bounds of the specified port in absolute world (graph) coordinates.

Callback method for NodePort.getBounds().

Specified by:
getBounds in interface NodePort.BoundsProvider
Parameters:
port - the port instance whose bounds have to be determined.
Returns:
the bounds of the specified port in absolute world (graph).

calcUnionRect

public void calcUnionRect(NodePort port,
                          java.awt.geom.Rectangle2D r)
Description copied from interface: NodePort.UnionRectCalculator
Calculates the rectangular union of the specified rectangle and the specified port's bounds.

Callback method for NodePort.calcUnionRect(java.awt.geom.Rectangle2D).

Specified by:
calcUnionRect in interface NodePort.UnionRectCalculator
Parameters:
port - the port instance whose bounds have to be added to the given rectangle.
r - the rectangle to be enlarged such that it contains the bounds of the specified port.

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