Search this API

y.layout
Class PreferredPlacementDescriptor

java.lang.Object
  extended by y.layout.PreferredPlacementDescriptor
All Implemented Interfaces:
LabelLayoutConstants

public class PreferredPlacementDescriptor
extends Object
implements LabelLayoutConstants

A descriptor that holds preferred placement information for automatic edge labeling.

It provides methods to specify


Field Summary
static byte ANGLE_IS_ABSOLUTE
          Angle interpretation specifier for edge labels.
static byte ANGLE_IS_RELATIVE_TO_EDGE_FLOW
          Angle interpretation specifier for edge labels.
static byte ANGLE_OFFSET_ON_RIGHT_SIDE_0
          Angle offset specifier for edge labels whose descriptor isRightOfEdge().
static byte ANGLE_OFFSET_ON_RIGHT_SIDE_180
          Angle offset specifier for edge labels whose descriptor isRightOfEdge().
static byte ANGLE_ON_RIGHT_SIDE_CO_ROTATING
          Angle interpretation specifier for edge labels whose descriptor isRightOfEdge().
static byte ANGLE_ON_RIGHT_SIDE_COUNTER_ROTATING
          Angle interpretation specifier for edge labels whose descriptor isRightOfEdge().
static byte SIDE_IS_ABSOLUTE_WITH_LEFT_IN_NORTH
          Side placement specifier for edge labels.
static byte SIDE_IS_ABSOLUTE_WITH_RIGHT_IN_NORTH
          Side placement specifier for edge labels.
static byte SIDE_IS_RELATIVE_TO_EDGE_FLOW
          Side placement specifier for edge labels.
 
Fields inherited from interface y.layout.LabelLayoutConstants
PLACE_ANYWHERE, PLACE_AT_CENTER, PLACE_AT_SOURCE, PLACE_AT_TARGET, PLACE_LEFT_OF_EDGE, PLACE_ON_EDGE, PLACE_RIGHT_OF_EDGE, PLACEMENT_ALONG_EDGE_MASK, PLACEMENT_ON_SIDE_OF_EDGE_MASK
 
Constructor Summary
PreferredPlacementDescriptor()
          Creates a mutable instance of this descriptor.
PreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
          Creates a mutable copy of the given PreferredPlacementDescriptor.
 
Method Summary
 boolean equals(Object o)
           
 void freeze()
          Makes this instance immutable.
 double getAngle()
          Returns the angle (in radians) for the label rotation.
 byte getAngleOffsetOnRightSide()
          Returns the angle offset for labels that are placed on the right side of the edge.
 byte getAngleReference()
          Specifies the reference of the angle given by getAngle().
 byte getAngleRotationOnRightSide()
          Specifies how the angle is applied to labels on the right side in respect of the labels of the left side of the edge.
 double getDistanceToEdge()
          Returns the preferred distance between a label and the corresponding edge segment.
 byte getPlaceAlongEdge()
          Returns the preferred placement along the edge.
 byte getSideOfEdge()
          Returns the preferred side of the edge.
 byte getSideReference()
          Specifies how to interpret the preferred side as given by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE.
 int hashCode()
           
 boolean isAngleAbsolute()
          Returns if one of the angle interpretations is to interpret the angle absolute.
 boolean isAngleOffsetOnRightSide0()
          Returns if one of the angle interpretations is to add no additional angle offset to labels that are right of the edge.
 boolean isAngleOffsetOnRightSide180()
          Returns if one of the angle interpretations is to add an additional angle offset of 180 degree to labels that are right of the edge.
 boolean isAngleOnRightSideCoRotating()
          Returns if one of the angle interpretations is to interpret the angle of labels that are right of the edge as co-rotating with the labels left of or centered on edge, i.e. the angle of all labels is interpreted clockwise.
 boolean isAngleOnRightSideCounterRotating()
          Returns if one of the angle interpretations is to interpret the angle of labels that are right of the edge as counter-rotating with the labels left of or centered on edge, i.e. the angle of labels left or centered on edge is interpreted clockwise while the angle of labels right of edge is interpreted counter-clockwise.
 boolean isAngleRelativeToEdgeFlow()
          Returns if one of the angle interpretations is to interpret the angle relative to the edge slope.
 boolean isAtCenter()
          Returns if one of the preferred placements for this label is at center.
 boolean isAtSource()
          Returns if one of the preferred placements for this label is at source.
 boolean isAtTarget()
          Returns if one of the preferred placements for this label is at target.
 boolean isFrozen()
          Returns whether or not this is an immutable descriptor instance.
 boolean isLeftOfEdge()
          Returns if one of the preferred sides for this label is left of the edge.
 boolean isOnEdge()
          Returns if one of the preferred sides for this label is on the edge.
 boolean isRightOfEdge()
          Returns if one of the preferred sides for this label is right of the edge.
 boolean isSideAbsoluteWithLeftInNorth()
          Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted absolute and on horizontal segments, labels with preferred side LabelLayoutConstants.PLACE_LEFT_OF_EDGE are placed above the segment.
 boolean isSideAbsoluteWithRightInNorth()
          Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted absolute and on horizontal segments, labels with preferred side LabelLayoutConstants.PLACE_RIGHT_OF_EDGE are placed above the segment.
 boolean isSideRelativeToEdgeFlow()
          Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted relative to the edge flow.
static PreferredPlacementDescriptor newSharedInstance(byte placement)
          Returns an immutable descriptor instance for the specified placement.
 void setAngle(double angle)
          Sets the angle (in radians) for the label rotation.
 void setAngleOffsetOnRightSide(byte angleOffset)
          Sets the angle offset for labels that are placed on the right side of the edge.
 void setAngleReference(byte angleReference)
          Specifies the reference of the angle given by getAngle().
 void setAngleRotationOnRightSide(byte angleRotation)
          Specifies how the angle is applied to labels on the right side in respect of the labels of the left side of the edge.
 void setDistanceToEdge(double distance)
          Specifies the preferred distance between a label and the corresponding edge segment.
 void setPlaceAlongEdge(byte placeAlongEdge)
          Sets the preferred placement along the edge.
 void setSideOfEdge(byte sideOfEdge)
          Sets the preferred side of the edge.
 void setSideReference(byte sideReference)
          Specifies how to interpret the preferred side as given by LabelLayoutConstants.PLACE_RIGHT_OF_EDGE and LabelLayoutConstants.PLACE_LEFT_OF_EDGE.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SIDE_IS_RELATIVE_TO_EDGE_FLOW

public static final byte SIDE_IS_RELATIVE_TO_EDGE_FLOW
Side placement specifier for edge labels. Expresses that the preferred side (as specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE) is interpreted relative to the edge flow.

See Also:
setSideReference(byte), getSideReference(), Constant Field Values

SIDE_IS_ABSOLUTE_WITH_LEFT_IN_NORTH

public static final byte SIDE_IS_ABSOLUTE_WITH_LEFT_IN_NORTH
Side placement specifier for edge labels. Expresses that the preferred side (as specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE) is interpreted absolute. On horizontal segments labels with preferred side LabelLayoutConstants.PLACE_LEFT_OF_EDGE are placed above the segment.

See Also:
setSideReference(byte), getSideReference(), Constant Field Values

SIDE_IS_ABSOLUTE_WITH_RIGHT_IN_NORTH

public static final byte SIDE_IS_ABSOLUTE_WITH_RIGHT_IN_NORTH
Side placement specifier for edge labels. Expresses that the preferred side (as specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE) is interpreted absolute. On horizontal segments labels with preferred side LabelLayoutConstants.PLACE_RIGHT_OF_EDGE are placed above the segment.

See Also:
setSideReference(byte), getSideReference(), Constant Field Values

ANGLE_IS_ABSOLUTE

public static final byte ANGLE_IS_ABSOLUTE
Angle interpretation specifier for edge labels. Expresses that the angle should be interpreted absolute and not relative to the edge slope.

See Also:
setAngleReference(byte), getAngleReference(), Constant Field Values

ANGLE_IS_RELATIVE_TO_EDGE_FLOW

public static final byte ANGLE_IS_RELATIVE_TO_EDGE_FLOW
Angle interpretation specifier for edge labels. Expresses that the angle should be interpreted relative to the edge slope.

See Also:
setAngleReference(byte), getAngleReference(), Constant Field Values

ANGLE_ON_RIGHT_SIDE_CO_ROTATING

public static final byte ANGLE_ON_RIGHT_SIDE_CO_ROTATING
Angle interpretation specifier for edge labels whose descriptor isRightOfEdge(). Expresses that the angle should be interpreted as clockwise and therefore as co-rotating with the angle of labels that are left of or centered on edge.

See Also:
setAngleRotationOnRightSide(byte), getAngleRotationOnRightSide(), Constant Field Values

ANGLE_ON_RIGHT_SIDE_COUNTER_ROTATING

public static final byte ANGLE_ON_RIGHT_SIDE_COUNTER_ROTATING
Angle interpretation specifier for edge labels whose descriptor isRightOfEdge(). Expresses that the angle should be interpreted as counter-clockwise and therefore as counter-rotating with the angle of labels that are left of or centered on edge.

See Also:
setAngleRotationOnRightSide(byte), getAngleRotationOnRightSide(), Constant Field Values

ANGLE_OFFSET_ON_RIGHT_SIDE_0

public static final byte ANGLE_OFFSET_ON_RIGHT_SIDE_0
Angle offset specifier for edge labels whose descriptor isRightOfEdge(). Expresses that for labels right of edge no additional offset should be added to the angle offset.

See Also:
setAngleOffsetOnRightSide(byte), getAngleOffsetOnRightSide(), Constant Field Values

ANGLE_OFFSET_ON_RIGHT_SIDE_180

public static final byte ANGLE_OFFSET_ON_RIGHT_SIDE_180
Angle offset specifier for edge labels whose descriptor isRightOfEdge(). Expresses that for labels right of edge an additional offset of 180 degree should be added to the angle offset so that point symmetric label placements left and right of the edge can be attained.

See Also:
setAngleOffsetOnRightSide(byte), getAngleOffsetOnRightSide(), Constant Field Values
Constructor Detail

PreferredPlacementDescriptor

public PreferredPlacementDescriptor()
Creates a mutable instance of this descriptor.


PreferredPlacementDescriptor

public PreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
Creates a mutable copy of the given PreferredPlacementDescriptor.

Parameters:
descriptor - PreferredPlacementDescriptor to make a copy from
Method Detail

getPlaceAlongEdge

public byte getPlaceAlongEdge()
Returns the preferred placement along the edge. Default is LabelLayoutConstants.PLACE_AT_CENTER.

Returns:
any combination of LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_CENTER, LabelLayoutConstants.PLACE_AT_TARGET.

setPlaceAlongEdge

public void setPlaceAlongEdge(byte placeAlongEdge)
Sets the preferred placement along the edge. Default is LabelLayoutConstants.PLACE_AT_CENTER.

Throws:
IllegalStateException - if this instance is immutable.
Parameters:
placeAlongEdge - any combination of LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_CENTER and LabelLayoutConstants.PLACE_AT_TARGET.

getSideOfEdge

public byte getSideOfEdge()
Returns the preferred side of the edge. Default is LabelLayoutConstants.PLACE_ON_EDGE.

Returns:
any combination of LabelLayoutConstants.PLACE_LEFT_OF_EDGE, LabelLayoutConstants.PLACE_ON_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE.

setSideOfEdge

public void setSideOfEdge(byte sideOfEdge)
Sets the preferred side of the edge. Default is LabelLayoutConstants.PLACE_ON_EDGE.

Throws:
IllegalStateException - if this instance is immutable.
Parameters:
sideOfEdge - any combination of LabelLayoutConstants.PLACE_LEFT_OF_EDGE, LabelLayoutConstants.PLACE_ON_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE.

getSideReference

public byte getSideReference()
Specifies how to interpret the preferred side as given by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE. Default is SIDE_IS_RELATIVE_TO_EDGE_FLOW.

Returns:
any combination of SIDE_IS_RELATIVE_TO_EDGE_FLOW, SIDE_IS_ABSOLUTE_WITH_LEFT_IN_NORTH and SIDE_IS_ABSOLUTE_WITH_RIGHT_IN_NORTH

setSideReference

public void setSideReference(byte sideReference)
Specifies how to interpret the preferred side as given by LabelLayoutConstants.PLACE_RIGHT_OF_EDGE and LabelLayoutConstants.PLACE_LEFT_OF_EDGE.

Throws:
IllegalStateException - if this instance is immutable.
IllegalArgumentException - if the specified value has not at least one of the required bits set.
Parameters:
sideReference - any combination of SIDE_IS_RELATIVE_TO_EDGE_FLOW, SIDE_IS_ABSOLUTE_WITH_LEFT_IN_NORTH and SIDE_IS_ABSOLUTE_WITH_RIGHT_IN_NORTH

getAngle

public double getAngle()
Returns the angle (in radians) for the label rotation. How this angle is applied is specified by getAngleReference(), getAngleRotationOnRightSide() and getAngleOffsetOnRightSide(). Default is 0.

Returns:
the angle.

setAngle

public void setAngle(double angle)
Sets the angle (in radians) for the label rotation. How this angle is applied is specified by getAngleReference(), getAngleRotationOnRightSide() and getAngleOffsetOnRightSide(). Default is 0.

Throws:
IllegalStateException - if this instance is immutable.
Parameters:
angle - the angle.

getAngleReference

public byte getAngleReference()
Specifies the reference of the angle given by getAngle(). Default is ANGLE_IS_ABSOLUTE.

Returns:
any combination of ANGLE_IS_ABSOLUTE and ANGLE_IS_RELATIVE_TO_EDGE_FLOW

setAngleReference

public void setAngleReference(byte angleReference)
Specifies the reference of the angle given by getAngle(). Default is ANGLE_IS_ABSOLUTE.

Throws:
IllegalStateException - if this instance is immutable.
IllegalArgumentException - if the specified value has not at least one of the required bits set.
Parameters:
angleReference - any combination of ANGLE_IS_ABSOLUTE and ANGLE_IS_RELATIVE_TO_EDGE_FLOW

getAngleRotationOnRightSide

public byte getAngleRotationOnRightSide()
Specifies how the angle is applied to labels on the right side in respect of the labels of the left side of the edge. Default is ANGLE_ON_RIGHT_SIDE_CO_ROTATING.

Returns:
any combination of ANGLE_ON_RIGHT_SIDE_CO_ROTATING and ANGLE_ON_RIGHT_SIDE_COUNTER_ROTATING

setAngleRotationOnRightSide

public void setAngleRotationOnRightSide(byte angleRotation)
Specifies how the angle is applied to labels on the right side in respect of the labels of the left side of the edge. Default is ANGLE_ON_RIGHT_SIDE_CO_ROTATING.

Throws:
IllegalStateException - if this instance is immutable.
IllegalArgumentException - if the specified value has not at least one of the required bits set.
Parameters:
angleRotation - any combination of ANGLE_ON_RIGHT_SIDE_CO_ROTATING and ANGLE_ON_RIGHT_SIDE_COUNTER_ROTATING

getAngleOffsetOnRightSide

public byte getAngleOffsetOnRightSide()
Returns the angle offset for labels that are placed on the right side of the edge. Default is ANGLE_OFFSET_ON_RIGHT_SIDE_0.

Returns:
any combination of ANGLE_OFFSET_ON_RIGHT_SIDE_0 and ANGLE_OFFSET_ON_RIGHT_SIDE_180

setAngleOffsetOnRightSide

public void setAngleOffsetOnRightSide(byte angleOffset)
Sets the angle offset for labels that are placed on the right side of the edge. Default is ANGLE_OFFSET_ON_RIGHT_SIDE_0.

Throws:
IllegalStateException - if this instance is immutable.
IllegalArgumentException - if the specified value has not at least one of the required bits set.
Parameters:
angleOffset - any combination of ANGLE_OFFSET_ON_RIGHT_SIDE_0 and ANGLE_OFFSET_ON_RIGHT_SIDE_180

getDistanceToEdge

public double getDistanceToEdge()
Returns the preferred distance between a label and the corresponding edge segment. If the given distance is < 0, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm. Default is -1.

Returns:
the preferred distance between a label and the corresponding edge segment.

setDistanceToEdge

public void setDistanceToEdge(double distance)
Specifies the preferred distance between a label and the corresponding edge segment. If the given distance is < 0, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm. Default is -1.

Throws:
IllegalArgumentException - if the specified value is infinite or NaN.
IllegalStateException - if this instance is immutable.
Parameters:
distance - preferred distance between a label and the corresponding edge segment.

isAtSource

public boolean isAtSource()
Returns if one of the preferred placements for this label is at source.

Returns:
true if at source is a possible placement for this label, false otherwise.

isAtCenter

public boolean isAtCenter()
Returns if one of the preferred placements for this label is at center.

Returns:
true if at center is a possible placement for this label, false otherwise.

isAtTarget

public boolean isAtTarget()
Returns if one of the preferred placements for this label is at target.

Returns:
true if at target is a possible placement for this label, false otherwise.

isLeftOfEdge

public boolean isLeftOfEdge()
Returns if one of the preferred sides for this label is left of the edge.

Returns:
true if left of the edge is a possible side for this label, false otherwise.

isOnEdge

public boolean isOnEdge()
Returns if one of the preferred sides for this label is on the edge.

Returns:
true if on the edge is a possible side for this label, false otherwise.

isRightOfEdge

public boolean isRightOfEdge()
Returns if one of the preferred sides for this label is right of the edge.

Returns:
true if right of the edge is a possible side for this label, false otherwise.

isAngleAbsolute

public boolean isAngleAbsolute()
Returns if one of the angle interpretations is to interpret the angle absolute.

Returns:
true if absolute angle interpretation is a possible angle interpretation for this label, false otherwise.

isAngleRelativeToEdgeFlow

public boolean isAngleRelativeToEdgeFlow()
Returns if one of the angle interpretations is to interpret the angle relative to the edge slope.

Returns:
true if interpreting the angle relative to the edge slope is a possible angle interpretation for this label, false otherwise.

isAngleOnRightSideCoRotating

public boolean isAngleOnRightSideCoRotating()
Returns if one of the angle interpretations is to interpret the angle of labels that are right of the edge as co-rotating with the labels left of or centered on edge, i.e. the angle of all labels is interpreted clockwise.

Returns:
true if co-rotating angle interpretation for right-side edges is a possible angle interpretation for this label, false otherwise.
See Also:
isRightOfEdge()

isAngleOnRightSideCounterRotating

public boolean isAngleOnRightSideCounterRotating()
Returns if one of the angle interpretations is to interpret the angle of labels that are right of the edge as counter-rotating with the labels left of or centered on edge, i.e. the angle of labels left or centered on edge is interpreted clockwise while the angle of labels right of edge is interpreted counter-clockwise.

Returns:
true if counter-rotating angle interpretation for right-side edges is a possible angle interpretation for this label, false otherwise.
See Also:
isRightOfEdge()

isAngleOffsetOnRightSide0

public boolean isAngleOffsetOnRightSide0()
Returns if one of the angle interpretations is to add no additional angle offset to labels that are right of the edge.

Returns:
true if adding no additional angle offset for right-side edges is a possible angle interpretation for this label, false otherwise.
See Also:
isRightOfEdge()

isAngleOffsetOnRightSide180

public boolean isAngleOffsetOnRightSide180()
Returns if one of the angle interpretations is to add an additional angle offset of 180 degree to labels that are right of the edge.

Returns:
true if adding an additional angle offset of 180 degree for right-side edges is a possible angle interpretation for this label, false otherwise.
See Also:
isRightOfEdge()

isSideRelativeToEdgeFlow

public boolean isSideRelativeToEdgeFlow()
Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted relative to the edge flow.

Returns:
true if the preferred side is interpreted relative to the edge flow.

isSideAbsoluteWithLeftInNorth

public boolean isSideAbsoluteWithLeftInNorth()
Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted absolute and on horizontal segments, labels with preferred side LabelLayoutConstants.PLACE_LEFT_OF_EDGE are placed above the segment.

Returns:
true if the preferred side is interpreted absolute.

isSideAbsoluteWithRightInNorth

public boolean isSideAbsoluteWithRightInNorth()
Returns if the preferred side specified by LabelLayoutConstants.PLACE_LEFT_OF_EDGE and LabelLayoutConstants.PLACE_RIGHT_OF_EDGE is interpreted absolute and on horizontal segments, labels with preferred side LabelLayoutConstants.PLACE_RIGHT_OF_EDGE are placed above the segment.

Returns:
true if the preferred side is interpreted absolute.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isFrozen

public boolean isFrozen()
Returns whether or not this is an immutable descriptor instance. If this instance is immutable, all set methods will throw an IllegalStateException when invoked.

Returns:
true if this instance is immutable; false otherwise.
See Also:
freeze()

freeze

public void freeze()
Makes this instance immutable. If this instance is immutable, all set methods will throw an IllegalStateException when invoked.

See Also:
isFrozen()

newSharedInstance

public static PreferredPlacementDescriptor newSharedInstance(byte placement)
Returns an immutable descriptor instance for the specified placement. Descriptor instances returned by this method will use default values for all properties but placement along edge and side of edge.

Parameters:
placement - an ORed combination of LabelLayoutConstants.PLACE_ANYWHERE, LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_TARGET, or LabelLayoutConstants.PLACE_AT_CENTER and LabelLayoutConstants.PLACE_LEFT_OF_EDGE, LabelLayoutConstants.PLACE_RIGHT_OF_EDGE, or LabelLayoutConstants.PLACE_ON_EDGE.
Returns:
an immutable descriptor instance for the specified placement.
See Also:
isFrozen()

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