Search this API

y.view
Class PortLabelModel

java.lang.Object
  extended by y.view.PortLabelModel
All Implemented Interfaces:
NodeLabelModel

public class PortLabelModel
extends java.lang.Object
implements NodeLabelModel

A NodeLabelModel for labels that are associated to node ports.

Note: This label model can only be used with labels in NodeRealizer instances.

Note: Serialization/deserialization of this label model is only supported in the GraphML format.

 

Nested Class Summary
static class PortLabelModel.Handler
          Provides GraphML (de-)serialization support for PortLabelModel and its parameters.
 
Field Summary
static byte CENTER
          Node label position specifier.
static byte EAST
          Node label position specifier.
static byte NORTH
          Node label position specifier.
static byte SOUTH
          Node label position specifier.
static byte WEST
          Node label position specifier.
 
Constructor Summary
PortLabelModel(double offset)
          Initializes a new PortLabelModel.
PortLabelModel(double offset, boolean localCandidatesEnabled)
          Initializes a new PortLabelModel.
 
Method Summary
 java.lang.Object createModelParameter(OrientedRectangle labelBounds, NodeLayout nodeLayout)
          Creates a parameter that holds the best matching positioning information supported by this model for the desired label position and specified node bounds.
static java.lang.Object createParameter(NodePort port, byte position)
          Creates a parameter for the specified port and position.
static java.util.Collection findLabels(NodePort port)
          Returns a collection of labels that are associated to the specified port.
 java.lang.Object getDefaultParameter()
          Creates a parameter that will position its associated label in the center of its node independent of all ports.
 YList getLabelCandidates(NodeLabelLayout nl, NodeLayout nodeLayout)
          Generates a list of possible label positions for this model.
 OrientedRectangle getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, java.lang.Object param)
          Determines the position of a label of the specified size for the specified node bounds and positioning information.
 double getOffset()
          Returns the distance between label and associated node port.
static NodePort getPort(NodeLabel label)
          Returns the port to which the specified label is associated or null if there is no such port.
static NodePort getPort(NodeRealizer owner, java.lang.Object modelParameter)
          Returns the NodePort instance of the specified node realizer that is associated to the specified model parameter.
static byte getPosition(java.lang.Object modelParameter)
          Returns the positions specifier encoded in the specified model parameter.
 boolean isLocalCandidatesEnabled()
          Returns true if this model supports only label candidates that are related to the node port referenced by the model parameter used and false if this model supports label candidates related to all node ports of a given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

public static final byte NORTH
Node label position specifier. Places the label above the associated port.

See Also:
createParameter(NodePort, byte), getPosition(Object), Constant Field Values

SOUTH

public static final byte SOUTH
Node label position specifier. Places the label below the associated port.

See Also:
createParameter(NodePort, byte), getPosition(Object), Constant Field Values

EAST

public static final byte EAST
Node label position specifier. Places the label to the right of it of the associated port.

See Also:
createParameter(NodePort, byte), getPosition(Object), Constant Field Values

WEST

public static final byte WEST
Node label position specifier. Places the label to the left of it of the associated port.

See Also:
createParameter(NodePort, byte), getPosition(Object), Constant Field Values

CENTER

public static final byte CENTER
Node label position specifier. Places the label centered on the associated port.

See Also:
createParameter(NodePort, byte), getPosition(Object), Constant Field Values
Constructor Detail

PortLabelModel

public PortLabelModel(double offset)
Initializes a new PortLabelModel.

Parameters:
offset - specifies the distance between the label and its associated port.

PortLabelModel

public PortLabelModel(double offset,
                      boolean localCandidatesEnabled)
Initializes a new PortLabelModel.

Parameters:
offset - specifies the distance between the label and its associated port.
localCandidatesEnabled - if true this model only allows for label candidates related to the node port referenced by the model parameter used; if false this model allows for label candidates related to all node ports of a given node.
See Also:
getLabelCandidates(y.layout.NodeLabelLayout, y.layout.NodeLayout)
Method Detail

getOffset

public double getOffset()
Returns the distance between label and associated node port.

Returns:
the distance between label and associated node port.

isLocalCandidatesEnabled

public boolean isLocalCandidatesEnabled()
Returns true if this model supports only label candidates that are related to the node port referenced by the model parameter used and false if this model supports label candidates related to all node ports of a given node.

Returns:
true if this model supports only label candidates that are related to the node port referenced by the model parameter used and false if this model supports label candidates related to all node ports of a given node.

createModelParameter

public java.lang.Object createModelParameter(OrientedRectangle labelBounds,
                                             NodeLayout nodeLayout)
Creates a parameter that holds the best matching positioning information supported by this model for the desired label position and specified node bounds.

Specified by:
createModelParameter in interface NodeLabelModel
Parameters:
labelBounds - The bounds of the label for which a parameter representation is sought.
nodeLayout - The layout of the node to which the label belongs.
Returns:
a parameter that holds the best matching positioning information.
See Also:
NodeLabelModel.getLabelPlacement(YDimension, NodeLayout, Object)

getDefaultParameter

public java.lang.Object getDefaultParameter()
Creates a parameter that will position its associated label in the center of its node independent of all ports.

Specified by:
getDefaultParameter in interface NodeLabelModel
Returns:
a parameter that will position its associated label in the center of its node independent of all ports.

getLabelPlacement

public OrientedRectangle getLabelPlacement(YDimension labelSize,
                                           NodeLayout nodeLayout,
                                           java.lang.Object param)
Determines the position of a label of the specified size for the specified node bounds and positioning information.

Specified by:
getLabelPlacement in interface NodeLabelModel
Parameters:
labelSize - The size of the label that should be placed.
nodeLayout - The layout of the node to which the label belongs.
param - The model parameter that describes the abstract position of the label within this model. The parameter must have been generated by this model.
Returns:
the position of a label of the specified size for the specified node bounds and positioning information.

getLabelCandidates

public YList getLabelCandidates(NodeLabelLayout nl,
                                NodeLayout nodeLayout)
Generates a list of possible label positions for this model.

Specified by:
getLabelCandidates in interface NodeLabelModel
Parameters:
nl - The label layout for which candidates should be generated.
nodeLayout - The layout of the node to which the label belongs.
Returns:
a list of NodeLabelCandidate instances.

createParameter

public static java.lang.Object createParameter(NodePort port,
                                               byte position)
Creates a parameter for the specified port and position.

Parameters:
port - the port that will be used as reference for positioning.
position - one of
Returns:
a parameter for the specified port and position.

getPosition

public static byte getPosition(java.lang.Object modelParameter)
Returns the positions specifier encoded in the specified model parameter.

Parameters:
modelParameter - the model parameter from which the position specifier has to be extracted.
Returns:
the positions specifier encoded in the specified model parameter.
Throws:
java.lang.IllegalArgumentException - if the specified model parameter is not valid for this model.
See Also:
NORTH, SOUTH, EAST, WEST, CENTER

getPort

public static NodePort getPort(NodeLabel label)
Returns the port to which the specified label is associated or null if there is no such port.

Parameters:
label - the node label whose associated port should be determined.
Returns:
the port to which the specified label is associated or null if there is no such port.

getPort

public static NodePort getPort(NodeRealizer owner,
                               java.lang.Object modelParameter)
Returns the NodePort instance of the specified node realizer that is associated to the specified model parameter.

Parameters:
owner - the node realizer whose ports are examined.
modelParameter - the model parameter that encodes the label-port association.
Returns:
the NodePort instance of the specified node realizer that is associated to the specified model parameter or null if there is no corresponding NodePort instance.
Throws:
java.lang.IllegalArgumentException - if the specified model parameter is not valid for this model.

findLabels

public static java.util.Collection findLabels(NodePort port)
Returns a collection of labels that are associated to the specified port.

Parameters:
port - the port whose associated labels are returned.
Returns:
a collection of labels that are associated to the specified port.

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