y.layout
Class FreeNodeLabelModel

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

public class FreeNodeLabelModel
extends Object
implements NodeLabelModel

A node label model that allows placement of labels at a fixed offset relative to the node's upper-left corner.

 
Your browser does not support SVG content.

Nested Class Summary
static class FreeNodeLabelModel.ModelParameter
          The model parameter that encodes a node label position within FreeNodeLabelModel.
 
Constructor Summary
FreeNodeLabelModel()
          Returns a new instance of FreeNodeLabelModel.
 
Method Summary
 Object createModelParameter(YRectangle labelBounds, NodeLayout nodeLayout)
          Creates a model parameter that represents the given node label context best within this model.
 Object getDefaultParameter()
          Returns a model parameter that encodes the default position of this model's allowed node label positions.
 YList getLabelCandidates(NodeLabelLayout nl, NodeLayout nodeLayout)
          Returns a list of candidate positions for the given node label.
 YPoint getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, Object param)
          Returns the coordinate of the upper-left corner of the label position encoded by the given model parameter.
 void setLocation(double x, double y)
          Sets the node label's offset that is used with this model.
 
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. The offset is set to a default value of -20 [pixel] for both directions, i.e., the node label's upper-left corner is placed 20 [pixel] to the left and 20 [pixel] above the node.

Method Detail

getDefaultParameter

public Object getDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed node label positions.

The default position uses an offset of 0 [pixel] for both directions, i.e., the upper-left corners of both node label and node are at the same location.

Specified by:
getDefaultParameter in interface NodeLabelModel
Returns:
A model parameter that can be passed to the NodeLabelModel.getLabelPlacement(YDimension, NodeLayout, Object) method.

getLabelPlacement

public YPoint getLabelPlacement(YDimension labelSize,
                                NodeLayout nodeLayout,
                                Object param)
Returns the coordinate of the upper-left corner of the label position encoded by the given model parameter.

Specified by:
getLabelPlacement in interface NodeLabelModel
Parameters:
labelSize - The size of the label.
nodeLayout - The geometric description of the label's node.
param - A model parameter that encodes a label position that is valid in this model.
Returns:
The coordinates of the upper-left corner of a label position.

getLabelCandidates

public YList getLabelCandidates(NodeLabelLayout nl,
                                NodeLayout nodeLayout)
Returns a list of candidate positions for the given node label. The list consists of exactly one position.

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 objects.

setLocation

public void setLocation(double x,
                        double y)
Sets the node label's offset that is used with this model.


createModelParameter

public Object createModelParameter(YRectangle labelBounds,
                                   NodeLayout nodeLayout)
Description copied from interface: NodeLabelModel
Creates a model parameter that represents the given node label context best within this model. The created model parameter represents the closest parameter representation of the given label location that can be achieved within this model.

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 model parameter that can be passed to the NodeLabelModel.getLabelPlacement(YDimension, NodeLayout, Object) method.

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