Search this API

y.layout
Class FreeNodeLabelModel

java.lang.Object
  extended by y.layout.FreeNodeLabelModel
All Implemented Interfaces:
NodeLabelModel

public class FreeNodeLabelModel
extends java.lang.Object
implements NodeLabelModel

FreeNodeLabelModel allows placing node labels at any desired position.

The location of the label does not need to satisfy any constraints. The model parameter describes a fixed offset between the upper-left corner of the node and the center of the label.

 

Nested Class Summary
static class FreeNodeLabelModel.ModelParameter
          The model parameter that encodes a label position within FreeNodeLabelModel.
 
Constructor Summary
FreeNodeLabelModel()
          Returns a new instance of FreeNodeLabelModel.
 
Method Summary
 java.lang.Object createModelParameter(OrientedRectangle labelBounds, NodeLayout nodeLayout)
          Creates a model parameter that represents the given node label position within this model.
 java.lang.Object getDefaultParameter()
          Returns a model parameter that encodes the default position of NodeLabelModel.
 YList getLabelCandidates(NodeLabelLayout labelLayout, NodeLayout nodeLayout)
          Returns the NodeLabelCandidate that describes the current label position.
 OrientedRectangle getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, java.lang.Object param)
          Returns the bounds of the label for the position encoded by the given model parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeNodeLabelModel

public FreeNodeLabelModel()
Returns a new instance of FreeNodeLabelModel.

Method Detail

getDefaultParameter

public java.lang.Object getDefaultParameter()
Returns a model parameter that encodes the default position of NodeLabelModel. The node label's upper-left corner is placed 20 pixels to the left and 20 pixels above the node.

This parameter can be passed to getLabelPlacement(YDimension, NodeLayout, Object) to retrieve the corresponding label box.

Specified by:
getDefaultParameter in interface NodeLabelModel
Returns:
the model parameter describing the default placement of the node label

getLabelPlacement

public OrientedRectangle getLabelPlacement(YDimension labelSize,
                                           NodeLayout nodeLayout,
                                           java.lang.Object param)
Description copied from interface: NodeLabelModel
Returns the bounds of the label for the position encoded by the given model parameter.

Specified by:
getLabelPlacement in interface NodeLabelModel
Parameters:
labelSize - the width and height of the label
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
Returns:
the oriented box of the label

getLabelCandidates

public YList getLabelCandidates(NodeLabelLayout labelLayout,
                                NodeLayout nodeLayout)
Returns the NodeLabelCandidate that describes the current label position.

Specified by:
getLabelCandidates in interface NodeLabelModel
 
The returned list contains only one candidate which describes the current location.
Parameters:
labelLayout - the label for which candidates should be generated
nodeLayout - the layout of the node to which the label belongs
Returns:
a list of NodeLabelCandidate instances

createModelParameter

public java.lang.Object createModelParameter(OrientedRectangle labelBounds,
                                             NodeLayout nodeLayout)
Creates a model parameter that represents the given node label position within this model.

The created model parameter represents the current location of the given label.

This parameter can be passed to getLabelPlacement(YDimension, NodeLayout, Object) to retrieve the current label box.

Specified by:
createModelParameter in interface NodeLabelModel
Parameters:
labelBounds - the bounds of the label the parameter represents
nodeLayout - the layout of the node to which the label belongs
Returns:
the model parameter
Throws:
java.lang.IllegalArgumentException - if one or more of the given bounds' values are invalid, i.e., NaN
See Also:
getLabelPlacement(YDimension, NodeLayout, Object)

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