Search this API

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.


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(OrientedRectangle 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.
 OrientedRectangle getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, Object param)
          Returns the oriented label position and bounds 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 Object getDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed node label positions.

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.

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

getLabelPlacement

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

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 oriented label position and bounds.

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.

createModelParameter

public Object createModelParameter(OrientedRectangle 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 oriented label bounds 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-2013,
yWorks GmbH.
All rights reserved.