Search this API

y.layout
Class RotatedSliderEdgeLabelModel

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

public class RotatedSliderEdgeLabelModel
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.


Field Summary
static byte CENTER_SLIDER
          Symbolic slider mode specifier.
static byte SIDE_SLIDER
          Symbolic slider mode specifier.
static byte SINGLE_SIDE_SLIDER
          Symbolic slider mode specifier.
 
Constructor Summary
RotatedSliderEdgeLabelModel(byte mode)
          Returns a new instance of RotatedSliderEdgeLabelModel.
 
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.
 double getAngle()
          Returns the angle (measured in radians) of the label model.
 Object getDefaultParameter()
          Returns a model parameter that encodes the default position of this model's allowed edge label positions.
 double getDistance()
          Returns the distance between the label's box and the edge's path.
 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.
 byte getMode()
          Returns the model's slider mode.
 boolean isAutoFlippingEnabled()
          Determines whether or not edge labels get flipped if they would be upside down in their current position.
 boolean isAutoRotationEnabled()
          Returns whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment.
 boolean isDistanceRelativeToEdge()
          Returns a value indicating whether the distance to the edge is interpreted relatively to the edge's path.
 void setAngle(double angle)
          Sets the angle (measured in radians) of the label model.
 void setAutoFlippingEnabled(boolean autoFlippingEnabled)
          Specifies whether or not edge labels get flipped if they would be upside down in their current position.
 void setAutoRotationEnabled(boolean enabled)
          Specifies whether or not edge labels have to be automatically rotated according to the angle of the corresponding reference edge segment.
 void setDistance(double distance)
          Sets the distance between the label's box and the edge's path.
 void setDistanceRelativeToEdge(boolean distanceRelativeToEdge)
          Sets a value indicating whether the distance to the edge is interpreted relatively to the edge's path.
 
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 both sides of the edge path.

See Also:
Constant Field Values

SINGLE_SIDE_SLIDER

public static final byte SINGLE_SIDE_SLIDER
Symbolic slider mode specifier. Chooses continuous label positions along a side of the edge path.

See Also:
Constant Field Values
Constructor Detail

RotatedSliderEdgeLabelModel

public RotatedSliderEdgeLabelModel(byte mode)
Returns a new instance of RotatedSliderEdgeLabelModel.

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

getMode

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

Returns:
the model's slider mode.

isDistanceRelativeToEdge

public boolean isDistanceRelativeToEdge()
Returns a value indicating whether the distance to the edge is interpreted relatively to the edge's path. If this value is set, the label is placed to the left of the edge segment (relative to the segment direction) if distance is less than 0 and to the right of the edge segment if distance is greater than 0. If this value is not set, the label is placed below the edge segment (in geometric sense) if distance is less than 0 and above the edge segment if distance is greater than 0.

The default value is true.

See Also:
setDistanceRelativeToEdge(boolean), setDistance(double)

setDistanceRelativeToEdge

public void setDistanceRelativeToEdge(boolean distanceRelativeToEdge)
Sets a value indicating whether the distance to the edge is interpreted relatively to the edge's path. If this value is set, the label is placed to the left of the edge segment (relative to the segment direction) if distance is less than 0 and to the right of the edge segment if distance is greater than 0. If this value is not set, the label is placed below the edge segment (in geometric sense) if distance ls less than 0 and above the edge segment if distance is greater than 0.

The default value is true.

See Also:
isDistanceRelativeToEdge(), setDistance(double)

getDistance

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

Returns:
the distance between the label's box and the edge's path.
See Also:
setDistance(double), isDistanceRelativeToEdge(), setDistanceRelativeToEdge(boolean)

setDistance

public void setDistance(double distance)
Sets the distance between the label's box and the edge's path. The interpretation of positive/negative values depends on property distanceRelativeToEdge.

Parameters:
distance - the distance between the label's box and the edge's path.
See Also:
getDistance(), isDistanceRelativeToEdge(), setDistanceRelativeToEdge(boolean)

isAutoRotationEnabled

public boolean isAutoRotationEnabled()
Returns whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment.

By default, this feature is enabled.

Returns:
true if edge labels are automatically rotated according to the angle of the corresponding reference edge segment and false if they are not.
See Also:
setAutoRotationEnabled(boolean)

setAutoRotationEnabled

public void setAutoRotationEnabled(boolean enabled)
Specifies whether or not edge labels have to be automatically rotated according to the angle of the corresponding reference edge segment.

By default, this feature is enabled.

Parameters:
enabled - true if edge labels are automatically rotated according to the angle of the corresponding reference edge segment.
See Also:
isAutoRotationEnabled()

isAutoFlippingEnabled

public boolean isAutoFlippingEnabled()
Determines whether or not edge labels get flipped if they would be upside down in their current position.

By default, this feature is disabled.

Returns:
true if edge labels get flipped if they would be upside down in their current position, false otherwise.
See Also:
setAutoFlippingEnabled(boolean)

setAutoFlippingEnabled

public void setAutoFlippingEnabled(boolean autoFlippingEnabled)
Specifies whether or not edge labels get flipped if they would be upside down in their current position.

By default, this feature is disabled.

Parameters:
autoFlippingEnabled - true if edge labels get flipped if they would be upside down in their current position.
See Also:
isAutoFlippingEnabled()

getAngle

public double getAngle()
Returns the angle (measured in radians) of the label model. The angle is applied in clockwise direction.

Returns:
the angle of the label model.

setAngle

public void setAngle(double angle)
Sets the angle (measured in radians) of the label model. The angle is applied in clockwise direction.

Parameters:
angle - the angle of the label model.

getDefaultParameter

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

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.

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