Search this API

y.layout
Class SliderEdgeLabelModel

java.lang.Object
  extended by y.layout.SliderEdgeLabelModel
All Implemented Interfaces:
EdgeLabelModel

public class SliderEdgeLabelModel
extends Object
implements EdgeLabelModel

An edge label model that allows placement of labels at a set of continuous positions along both sides of an edge or directly on the edge path.

The set of positions can be influenced by specifying the density value that controls the spacing between adjacent label positions. Furthermore, it's possible to specify distance values that control the distance between label and edge and between label and nodes.


Nested Class Summary
static class SliderEdgeLabelModel.ModelParameter
          Encodes the model parameters for the two slider edge label models specified by CENTER_SLIDER and SIDE_SLIDER.
 
Field Summary
static byte CENTER_RATIO
          Symbolic ratio specifier.
static byte CENTER_SLIDER
          Symbolic slider mode specifier.
static byte HEAD_RATIO
          Symbolic ratio specifier.
static byte LEFT_RATIO
          Symbolic ratio specifier.
static byte RIGHT_RATIO
          Symbolic ratio specifier.
static byte SIDE_SLIDER
          Symbolic slider mode specifier.
static byte TAIL_RATIO
          Symbolic ratio specifier.
 
Constructor Summary
SliderEdgeLabelModel(byte mode)
          Initializes a new instance of SliderEdgeLabelModel.
 
Method Summary
 Object createModelParameter(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
          Creates a model parameter that represents the given edge label context best within this model.
 Object getDefaultParameter()
          Returns a model parameter that encodes the default position of this model's allowed edge label positions.
 double getDensity()
          Returns the density to generate label candidate positions.
 YList getLabelCandidates(EdgeLabelLayout label, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
          Returns a list of candidate positions for the given edge label.
 OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, Object para)
          Returns the bounds of the label for the position encoded by the given model parameter.
 double getMaximumDistance()
          Returns the maximum distance between the label's bounding box and the edge's path.
 double getMinimumDistance()
          Returns the minimum distance between the label's bounding box and the edge's path.
 byte getMode()
          Returns the model's slider mode.
 double getNodeBorderDistance()
          Returns the minimal distance between the label's bounding box and a node's borders.
 YVector getOffsetVec(double dx, double dy, double width, double height, byte labelPosition)
          Returns the offset vector for a given edge label and a given edge segment.
 void setDensity(double density)
          Sets the density to generate label candidate positions.
 void setDistances(double minDistance, double maxDistance)
          Sets the minimum and maximum distances between the label's bounding box and the edge's path.
 void setMaximumDistance(double distance)
          Sets the maximum distance between the label's bounding box and the edge's path.
 void setMinimumDistance(double distance)
          Sets the minimum distance between the label's bounding box and the edge's path.
 void setNodeBorderDistance(double value)
          Sets the minimal distance between the label's bounding box and a node's borders.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER_SLIDER

public static final byte CENTER_SLIDER
Symbolic slider mode specifier. Chooses continuous label positions directly on the edge path.

See Also:
Constant Field Values

SIDE_SLIDER

public static final byte SIDE_SLIDER
Symbolic slider mode specifier. Chooses continuous label positions along the sides of the edge path.

See Also:
Constant Field Values

CENTER_RATIO

public static final byte CENTER_RATIO
Symbolic ratio specifier. Valid only in conjunction with slider mode CENTER_SLIDER.

See Also:
Constant Field Values

TAIL_RATIO

public static final byte TAIL_RATIO
Symbolic ratio specifier. Valid only in conjunction with slider mode SIDE_SLIDER. Determines a label to be right of or below the edge's path.

See Also:
Constant Field Values

HEAD_RATIO

public static final byte HEAD_RATIO
Symbolic ratio specifier. Valid only in conjunction with slider mode SIDE_SLIDER. Determines a label to be left of or above the edge's path.

See Also:
Constant Field Values

LEFT_RATIO

public static final byte LEFT_RATIO
Symbolic ratio specifier. Valid only in conjunction with slider mode SIDE_SLIDER. Determines a label to be left of the edge's path.

See Also:
Constant Field Values

RIGHT_RATIO

public static final byte RIGHT_RATIO
Symbolic ratio specifier. Valid only in conjunction with slider mode SIDE_SLIDER. Determines a label to be right of the edge's path.

See Also:
Constant Field Values
Constructor Detail

SliderEdgeLabelModel

public SliderEdgeLabelModel(byte mode)
Initializes a new instance of SliderEdgeLabelModel.

Parameters:
mode - Determines which slider mode to use. Possible values are either CENTER_SLIDER or SIDE_SLIDER.
Method Detail

getMode

public byte getMode()
Returns the model's slider mode.

Returns:
the model's slider mode.

setDistances

public void setDistances(double minDistance,
                         double maxDistance)
Sets the minimum and maximum distances between the label's bounding box and the edge's path.

Parameters:
minDistance - The minimal distance between label and edge.
maxDistance - The maximal distance between label and edge.
See Also:
getMaximumDistance(), getMinimumDistance(), setMaximumDistance(double), setMinimumDistance(double)

getMaximumDistance

public double getMaximumDistance()
Returns the maximum distance between the label's bounding box and the edge's path.

By default, a maximum distance of 1.0 is set.

Returns:
the maximum distance between the label's bounding box and the edge's path.
See Also:
setMaximumDistance(double), setDistances(double, double)

setMaximumDistance

public void setMaximumDistance(double distance)
Sets the maximum distance between the label's bounding box and the edge's path.

By default, a maximum distance of 1.0 is set.

Parameters:
distance - The maximal distance between label and edge.
See Also:
getMaximumDistance(), setDistances(double, double)

getMinimumDistance

public double getMinimumDistance()
Returns the minimum distance between the label's bounding box and the edge's path.

By default, a minimum distance of 1.0 is set.

Returns:
the minimum distance between the label's bounding box and the edge's path.
See Also:
setMinimumDistance(double), setDistances(double, double)

setMinimumDistance

public void setMinimumDistance(double distance)
Sets the minimum distance between the label's bounding box and the edge's path.

By default, a minimum distance of 1.0 is set.

Parameters:
distance - The minimal distance between label and edge.
See Also:
getMinimumDistance(), setDistances(double, double)

getDensity

public double getDensity()
Returns the density to generate label candidate positions.

A density value of 1.0 (which is the default) generates the most possible candidate positions without overlap.

Returns:
the density to generate label candidate positions.
See Also:
setDensity(double)

setDensity

public void setDensity(double density)
Sets the density to generate label candidate positions.

A density value of 1.0 (which is the default) generates the most possible candidate positions without overlap.

Parameters:
density - The density value. It has a range of 0.0 to 1.0.
See Also:
getDensity()

getNodeBorderDistance

public double getNodeBorderDistance()
Returns the minimal distance between the label's bounding box and a node's borders.

Returns:
the minimal distance between the label's bounding box and a node's borders.
See Also:
setNodeBorderDistance(double)

setNodeBorderDistance

public void setNodeBorderDistance(double value)
Sets the minimal distance between the label's bounding box and a node's borders.

Parameters:
value - The distance between label and node border.
See Also:
getNodeBorderDistance()

getDefaultParameter

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

The default positions for both slider edge label models are relative to the first edge segment, either at the beginning of the segment (SIDE_SLIDER model) or at its middle (CENTER_SLIDER model).

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

getLabelPlacement

public OrientedRectangle getLabelPlacement(YDimension labelSize,
                                           EdgeLayout edgeLayout,
                                           NodeLayout sourceNode,
                                           NodeLayout targetNode,
                                           Object para)
Description copied from interface: EdgeLabelModel
Returns the bounds of the label for the position encoded by the given model parameter.

Specified by:
getLabelPlacement in interface EdgeLabelModel
Parameters:
labelSize - The size of the label that should be placed.
edgeLayout - The layout of the edge to which the label belongs.
sourceNode - The layout of the source node of the label owning edge.
targetNode - The layout of the target node of the label owning edge.
para - 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 bounds of the label.

getLabelCandidates

public YList getLabelCandidates(EdgeLabelLayout label,
                                EdgeLayout edgeLayout,
                                NodeLayout sourceNode,
                                NodeLayout targetNode)
Returns a list of candidate positions for the given edge label. The number of candidates and their respective locations are computed depending on the geometries of both label and edge.

Specified by:
getLabelCandidates in interface EdgeLabelModel
Parameters:
label - The label for which candidates should be generated.
edgeLayout - The layout of the edge to which the label belongs.
sourceNode - The layout of the source node of the label owning edge.
targetNode - The layout of the target node of the label owning edge.
Returns:
A list of EdgeLabelCandidate objects.

createModelParameter

public Object createModelParameter(OrientedRectangle labelBounds,
                                   EdgeLayout edgeLayout,
                                   NodeLayout sourceNode,
                                   NodeLayout targetNode)
Description copied from interface: EdgeLabelModel
Creates a model parameter that represents the given edge 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 EdgeLabelModel
Parameters:
labelBounds - The bounds of the label for which a parameter representation is sought.
edgeLayout - The layout of the edge to which the label belongs.
sourceNode - The layout of the source node of the label owning edge.
targetNode - The layout of the target node of the label owning edge.
Returns:
A model parameter that can be passed to the EdgeLabelModel.getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object) method.

getOffsetVec

public YVector getOffsetVec(double dx,
                            double dy,
                            double width,
                            double height,
                            byte labelPosition)
Returns the offset vector for a given edge label and a given edge segment. The offset vector describes where to move a label candidate such that it keeps a certain distance to the edge's path.

Parameters:
dx - x-coordinates delta for an edge segment.
dy - y-coordinates delta for an edge segment.
width - The label's width.
height - The label's height.
labelPosition - One of the symbolic ratio specifiers CENTER_RATIO, LEFT_RATIO, or RIGHT_RATIO.
Returns:
An offset vector.

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