|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.layout.EdgeLabelOrientationSupport
public class EdgeLabelOrientationSupport
EdgeLabelOrientationSupport provides orientation and mirroring support for
layout algorithms with integrated edge labeling.
To calculate the position and orientation of edge labels whose placements are defined with the
PreferredPlacementDescriptor, the OrientationLayouter would need the direction of the associated
edge. Since this direction is not available to the OrientationLayouter, because it is a wrapper, the
calculation must be done in the core layout algorithm itself with the help of the EdgeLabelOrientationSupport.
Important: Since layout algorithms with integrated edge labeling cannot deal with ambiguous preferred placement
descriptors (combinations of the same setting, e.g., source or target for the
PreferredPlacementDescriptor.getPlaceAlongEdge()),
preProcessLabel(Graph, LabelLayoutData, Direction) removes combinations and replaces the original
descriptor with a non-ambiguous one that is used during the layout calculation.
![]() |
![]() |
| Constructor Summary | |
|---|---|
EdgeLabelOrientationSupport()
Creates a new EdgeLabelOrientationSupport instance. |
|
| Method Summary | |
|---|---|
protected PreferredPlacementDescriptor |
createNonAmbiguous(PreferredPlacementDescriptor ambiguous)
Creates and returns a non-ambiguous PreferredPlacementDescriptor of the given potentially ambiguous one. |
static YVector |
getEdgeLabelUpVector(PreferredPlacementDescriptor descriptor,
Direction segmentDirection)
Calculates the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to. |
static YVector |
getLabelUpVector(double rightVectorAngle)
Calculates the up vector for a label whose right vector is rotated clockwise by the given angle. |
static Direction |
getOrientedDirection(Direction direction,
byte orientation,
int mirrorMask)
Transforms a direction of the layout to the oriented layout direction. |
static boolean |
isOrientationMirrored(byte orientation,
int mirrorMask)
Returns whether or not the orientation is mirrored. |
void |
markPortLabelForFallbackPlacement(LabelLayoutData portLabel)
Marks the given port label for a non-port placement (fallback). |
void |
postProcessLabel(Graph graph,
LabelLayoutData label)
Restores the original preferred placement and updates the label rotation according to the layout orientation. |
void |
preProcessLabel(Graph graph,
LabelLayoutData label,
Direction segmentDirection)
Prepares the label for the core layout algorithm. |
void |
replaceAmbiguousLabelDescriptors(Graph graph)
Replaces the PreferredPlacementDescriptors of all edge labels in the given graph with non-ambiguous
descriptors. |
void |
resetAmbiguousLabelDescriptors(Graph graph)
Restores the PreferredPlacementDescriptors of all edge labels in the given graph with their original
descriptors. |
static void |
updateLabelOrientation(LabelLayoutData label,
Direction segmentDirection)
Calculates and sets the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EdgeLabelOrientationSupport()
EdgeLabelOrientationSupport instance.
OrientationLayouter.OrientationLayouter.setConsiderEdgeLabelsEnabled(boolean)| Method Detail |
|---|
public void replaceAmbiguousLabelDescriptors(Graph graph)
PreferredPlacementDescriptors of all edge labels in the given graph with non-ambiguous
descriptors.
The non-ambiguous descriptors are retrieved from the original descriptors. They describe only one of the possible placements.
This method should be called by a layout algorithm at the beginning of the layout calculation to assure that the label's placement is handled consistently.
graph - the input graphpublic void resetAmbiguousLabelDescriptors(Graph graph)
PreferredPlacementDescriptors of all edge labels in the given graph with their original
descriptors.
This method should be called by a layout algorithm at the end of the layout calculation to assure that the original state of the graph is not corrupted.
graph - the input graph
public void preProcessLabel(Graph graph,
LabelLayoutData label,
Direction segmentDirection)
First, the preferred placement of the edge label is
replaced by a non-ambiguous PreferredPlacementDescriptor that has only relative references. This
descriptor is orientation independent and can be used in the core layout algorithm. Second, the method
rotates the label box in respect of its
PreferredPlacementDescriptor and the direction of the segment to which it belongs. After that call, the
core layout algorithm can use the geometry (LabelLayoutData.getWidth() and
LabelLayoutData.getHeight()) of the label to calculate its location.
This method is called by the core layout algorithm with the integrated edge labeling for each edge label before the layout algorithm uses the geometry of labels. It should be called as soon as the direction of the segment the label belongs to is determined.
graph - the graph to get the orientation information fromlabel - the information about the edge label whose segment direction is determinedsegmentDirection - the direction of the segment the edge label belongs toprotected PreferredPlacementDescriptor createNonAmbiguous(PreferredPlacementDescriptor ambiguous)
PreferredPlacementDescriptor of the given potentially ambiguous one.
The created descriptor will be one without any combinations of settings, e.g., source or target for the
PreferredPlacementDescriptor.getPlaceAlongEdge().
ambiguous - an ambiguous PreferredPlacementDescriptor
PreferredPlacementDescriptor
public void postProcessLabel(Graph graph,
LabelLayoutData label)
The original LabelLayoutData.getPreferredPlacementDescriptor() that has been replaced
in preProcessLabel(Graph, LabelLayoutData, Direction) gets restored. Then it moves and rotates the
label box in respect of the orientation.
This method is called by the core layout algorithm with the integrated edge labeling for each edge label after the location of the label is determined.
graph - the graph to get the orientation information fromlabel - the information about the edge label whose location is determined
public static Direction getOrientedDirection(Direction direction,
byte orientation,
int mirrorMask)
direction - direction in the layoutorientation - the orientation of the layoutmirrorMask - the mask to determine whether or not the orientation is mirrored
public static boolean isOrientationMirrored(byte orientation,
int mirrorMask)
orientation - the orientation of the layoutmirrorMask - the mask to determine whether or not the orientation is mirrored
true if the orientation is mirrored, false otherwise
public static void updateLabelOrientation(LabelLayoutData label,
Direction segmentDirection)
label - the data that describes the label orientation and is used for setting the new up vectorsegmentDirection - the direction the edge segment is pointing togetEdgeLabelUpVector(PreferredPlacementDescriptor, Direction)
public static YVector getEdgeLabelUpVector(PreferredPlacementDescriptor descriptor,
Direction segmentDirection)
descriptor - the data describing the preferred label orientationsegmentDirection - the direction the edge segment is pointing to
public static YVector getLabelUpVector(double rightVectorAngle)
The up vector starts in the lower-left corner of the label and points up. If the label is paraxial it is
(0, -1). The right vector starts at the same point and points right. In a paraxial label it is
(1, 0).
rightVectorAngle - the angle in radians the right vector is rotated by
public void markPortLabelForFallbackPlacement(LabelLayoutData portLabel)
The given edge label's PreferredPlacementDescriptor will internally be changed such that
its placement along edge is either
LabelLayoutConstants.PLACE_AT_SOURCE or LabelLayoutConstants.PLACE_AT_TARGET.
Algorithms that are executed after this call and before resetAmbiguousLabelDescriptors(y.base.Graph)
will handle port labels like normal source or target labels.
replaceAmbiguousLabelDescriptors(y.base.Graph).portLabel - an edge label that had a LabelLayoutConstants.PLACE_AT_SOURCE_PORT or
LabelLayoutConstants.PLACE_AT_TARGET_PORT placement preference
java.lang.IllegalStateException - if replaceAmbiguousLabelDescriptors(y.base.Graph) was never
called for the graph containing the given label.LabelLayoutConstants.PLACE_AT_SOURCE_PORT,
LabelLayoutConstants.PLACE_AT_TARGET_PORT
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||