public class FreeEdgeLabelModel extends Object implements ILabelModelParameterFinder, ILabelModel
The position of the label is stored relative to the positions of the ports of the edge the label belongs to.
Modifier and Type | Field and Description |
---|---|
static FreeEdgeLabelModel |
INSTANCE
A shared unmodifiable public instance that can be used to obtain parameters.
|
Constructor and Description |
---|
FreeEdgeLabelModel() |
Modifier and Type | Method and Description |
---|---|
ILabelModelParameter |
createDefaultParameter()
Creates a default parameter that can be used for this model.
|
ILabelModelParameter |
createEdgeAnchored(double ratio,
double distance,
double angle)
Creates a parameter for the given location.
|
ILabelModelParameter |
findBestParameter(ILabel label,
ILabelModel model,
IOrientedRectangle layout)
Tries to find a parameter that best matches the given layout for the provided label instance.
|
ILookup |
getContext(ILabel label,
ILabelModelParameter layoutParameter)
Provides a
lookup context for the given combination of label and parameter. |
IOrientedRectangle |
getGeometry(ILabel label,
ILabelModelParameter layoutParameter)
Calculates the
geometry of the given label using the given model parameter. |
boolean |
isRelativeAngleEnabled()
Gets a property that indicates whether the angle used by the
parameter
should be interpreted relative to the edge's orientation or as an absolute angle in the coordinate system. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
void |
setRelativeAngleEnabled(boolean value)
Sets a property that indicates whether the angle used by the
parameter
should be interpreted relative to the edge's orientation or as an absolute angle in the coordinate system. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public static final FreeEdgeLabelModel INSTANCE
public final ILabelModelParameter createDefaultParameter()
ILabelModel
createDefaultParameter
in interface ILabelModel
public final ILabelModelParameter createEdgeAnchored(double ratio, double distance, double angle)
ratio
- The ratio at which the label will be anchored between the location of the source port and the location of the target
port.distance
- The distance orthogonally to the connection between the source and target point.angle
- The angle by which the label should be rotated.isRelativeAngleEnabled()
public final ILabelModelParameter findBestParameter(ILabel label, ILabelModel model, IOrientedRectangle layout)
This implementation will match the provided layout perfectly.
findBestParameter
in interface ILabelModelParameterFinder
label
- The label to find a parameter for.model
- The model instance to use. This should be this instance.layout
- The anticipated layout for the label.null
parameter that can be used for the label to approximate the provided layout.public ILookup getContext(ILabel label, ILabelModelParameter layoutParameter)
ILabelModel
lookup context
for the given combination of label and parameter.getContext
in interface ILabelModel
label
- The label to use in the context.layoutParameter
- The parameter to use for the label in the context.ILookup
interface that can be used to query additional aspects of the label/parameter
combination.ILookup.EMPTY
public final IOrientedRectangle getGeometry(ILabel label, ILabelModelParameter layoutParameter)
ILabelModel
geometry
of the given label using the given model parameter.getGeometry
in interface ILabelModel
label
- The label to calculate the geometry for.layoutParameter
- A parameter that is compatible with this model. Typically, this is a parameter that has been created by this model, and
its property Model
returns this instance.IOrientedRectangle
that describes the geometry of the label. This is typically designed as a flyweight,
therefore clients should not cache the instance but store the values if they need a snapshot for later use.public boolean isRelativeAngleEnabled()
parameter
should be interpreted relative to the edge's orientation or as an absolute angle in the coordinate system.
By default the angle is interpreted to be relative to the world coordinates axes.
setRelativeAngleEnabled(boolean)
public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup
null
.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null
implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.public void setRelativeAngleEnabled(boolean value)
parameter
should be interpreted relative to the edge's orientation or as an absolute angle in the coordinate system.
By default the angle is interpreted to be relative to the world coordinates axes.
value
- The RelativeAngleEnabled to set.isRelativeAngleEnabled()