Search this API

y.view
Class NodeScaledPortLocationModel

java.lang.Object
  extended by y.view.NodeScaledPortLocationModel
All Implemented Interfaces:
PortLocationModel

public class NodeScaledPortLocationModel
extends java.lang.Object
implements PortLocationModel

A PortLocationModel for node ports that determine their location dynamically using the node's visual bounds (as represented by the associated NodeRealizer). Internally, the location is stored as the ratio by which the width and height of the realizer need to be scaled to obtain the offset to the center of the node layout.

 
Your browser does not support SVG content.

Nested Class Summary
static class NodeScaledPortLocationModel.Handler
          Provides GraphML (de-)serialization support for NodeScaledPortLocationModel and its parameters.
 
Field Summary
static PortLocationModelParameter NODE_BOTTOM_ANCHORED
          Scaled parameter that anchors a node port at the bottom border of the node.
static PortLocationModelParameter NODE_BOTTOM_LEFT_ANCHORED
          Scaled parameter that anchors a node port at the bottom left corner of the node.
static PortLocationModelParameter NODE_BOTTOM_RIGHT_ANCHORED
          Scaled parameter that anchors a node port at the bottom right corner of the node.
static PortLocationModelParameter NODE_CENTER_ANCHORED
          Scaled parameter that anchors a node port at the center of the node.
static PortLocationModelParameter NODE_LEFT_ANCHORED
          Scaled parameter that anchors a node port at the left border of the node.
static PortLocationModelParameter NODE_RIGHT_ANCHORED
          Scaled parameter that anchors a node port at the right border of the node.
static PortLocationModelParameter NODE_TOP_ANCHORED
          Scaled parameter that anchors a node port at the top border of the node.
static PortLocationModelParameter NODE_TOP_LEFT_ANCHORED
          Scaled parameter that anchors a node port at the top left corner of the node.
static PortLocationModelParameter NODE_TOP_RIGHT_ANCHORED
          Scaled parameter that anchors a node port at the top right corner of the node.
static byte POLICY_BOUNDARY
          Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on a node's (rectangular) bounds.
static byte POLICY_BOUNDARY_CENTER
          Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on a node's (rectangular) bounds or at the node's center.
static byte POLICY_BOUNDARY_INSIDE
          Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on or inside a node's (rectangular) bounds.
static byte POLICY_DISCRETE
          Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to nine predefined positions: top left, top center, top right, left, center, right, bottom left, bottom center, and bottom right.
static byte POLICY_FREE
          Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that does not impose any location restrictions for the created parameters.
 
Constructor Summary
NodeScaledPortLocationModel()
          Initializes a new NodeScaledPortLocationModel instance.
 
Method Summary
 PortLocationModelParameter createParameter(NodeRealizer owner, YPoint location)
          Creates a parameter for the given port that tries to match the specified location in absolute world coordinates.
 PortLocationModelParameter createScaledParameter(YPoint relativeOffsets)
          Creates a parameter that uses the given relative offsets.
 YPoint getLocation(NodePort port, PortLocationModelParameter parameter)
          Determines the location of the port for the given parameter.
 byte getPortLocationPolicy()
          Returns the current port location policy.
 void setPortLocationPolicy(byte policy)
          Specifies the port location policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_DISCRETE

public static final byte POLICY_DISCRETE
Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to nine predefined positions: top left, top center, top right, left, center, right, bottom left, bottom center, and bottom right.

See Also:
Constant Field Values

POLICY_BOUNDARY

public static final byte POLICY_BOUNDARY
Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on a node's (rectangular) bounds.

See Also:
Constant Field Values

POLICY_BOUNDARY_CENTER

public static final byte POLICY_BOUNDARY_CENTER
Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on a node's (rectangular) bounds or at the node's center.

See Also:
Constant Field Values

POLICY_BOUNDARY_INSIDE

public static final byte POLICY_BOUNDARY_INSIDE
Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that restricts parameters created by the model to allow only locations on or inside a node's (rectangular) bounds.

See Also:
Constant Field Values

POLICY_FREE

public static final byte POLICY_FREE
Port location policy for createParameter(NodeRealizer, y.geom.YPoint) that does not impose any location restrictions for the created parameters.

See Also:
Constant Field Values

NODE_CENTER_ANCHORED

public static final PortLocationModelParameter NODE_CENTER_ANCHORED
Scaled parameter that anchors a node port at the center of the node. This is the same as creating a parameter with relative offset (0,0).


NODE_LEFT_ANCHORED

public static final PortLocationModelParameter NODE_LEFT_ANCHORED
Scaled parameter that anchors a node port at the left border of the node. This is the same as creating a parameter with relative offset (-0.5,0).


NODE_RIGHT_ANCHORED

public static final PortLocationModelParameter NODE_RIGHT_ANCHORED
Scaled parameter that anchors a node port at the right border of the node. This is the same as creating a parameter with relative offset (0.5,0).


NODE_TOP_ANCHORED

public static final PortLocationModelParameter NODE_TOP_ANCHORED
Scaled parameter that anchors a node port at the top border of the node. This is the same as creating a parameter with relative offset (0,-0.5).


NODE_BOTTOM_ANCHORED

public static final PortLocationModelParameter NODE_BOTTOM_ANCHORED
Scaled parameter that anchors a node port at the bottom border of the node. This is the same as creating a parameter with relative offset (0,0.5).


NODE_TOP_LEFT_ANCHORED

public static final PortLocationModelParameter NODE_TOP_LEFT_ANCHORED
Scaled parameter that anchors a node port at the top left corner of the node. This is the same as creating a parameter with relative offset (-0.5,-0.5).


NODE_TOP_RIGHT_ANCHORED

public static final PortLocationModelParameter NODE_TOP_RIGHT_ANCHORED
Scaled parameter that anchors a node port at the top right corner of the node. This is the same as creating a parameter with relative offset (0.5,-0.5).


NODE_BOTTOM_RIGHT_ANCHORED

public static final PortLocationModelParameter NODE_BOTTOM_RIGHT_ANCHORED
Scaled parameter that anchors a node port at the bottom right corner of the node. This is the same as creating a parameter with relative offset (0.5,0.5).


NODE_BOTTOM_LEFT_ANCHORED

public static final PortLocationModelParameter NODE_BOTTOM_LEFT_ANCHORED
Scaled parameter that anchors a node port at the bottom left corner of the node. This is the same as creating a parameter with relative offset (-0.5,0.5).

Constructor Detail

NodeScaledPortLocationModel

public NodeScaledPortLocationModel()
Initializes a new NodeScaledPortLocationModel instance.

Method Detail

getPortLocationPolicy

public byte getPortLocationPolicy()
Returns the current port location policy. This policy determines possible restrictions for parameters created by createParameter(NodeRealizer, y.geom.YPoint).

Returns:
the current port location policy.
See Also:
setPortLocationPolicy(byte), POLICY_DISCRETE, POLICY_BOUNDARY, POLICY_BOUNDARY_CENTER, POLICY_BOUNDARY_INSIDE, POLICY_FREE, createParameter(NodeRealizer, y.geom.YPoint)

setPortLocationPolicy

public void setPortLocationPolicy(byte policy)
Specifies the port location policy.

Parameters:
policy - the new port location policy. One of
See Also:
getPortLocationPolicy(), createParameter(NodeRealizer, y.geom.YPoint)

getLocation

public YPoint getLocation(NodePort port,
                          PortLocationModelParameter parameter)
Description copied from interface: PortLocationModel
Determines the location of the port for the given parameter.

Specified by:
getLocation in interface PortLocationModel
Parameters:
port - The port to determine the location for.
parameter - The parameter to use.
Returns:
the calculated location of the port.

createParameter

public PortLocationModelParameter createParameter(NodeRealizer owner,
                                                  YPoint location)
Creates a parameter for the given port that tries to match the specified location in absolute world coordinates.

Specified by:
createParameter in interface PortLocationModel
Parameters:
owner - The realizer that will own the port for which the parameter has to be created.
location - The location in the world coordinate system that should be matched as best as possible.
Returns:
a parameter for the given port that tries to match the specified location in absolute world coordinates.
See Also:
getPortLocationPolicy(), setPortLocationPolicy(byte), POLICY_DISCRETE, POLICY_BOUNDARY, POLICY_BOUNDARY_CENTER, POLICY_BOUNDARY_INSIDE, POLICY_FREE

createScaledParameter

public PortLocationModelParameter createScaledParameter(YPoint relativeOffsets)
Creates a parameter that uses the given relative offsets. The offsets will be scaled by the node layout's size and added to the node center to determine the port location.

E.g.

Parameters:
relativeOffsets - The relative offsets.
Returns:
A parameter instance that matches the specification.

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