public class NinePositionsEdgeLabelModel extends Object implements ILabelModel, ILabelModelParameterProvider
The possible positions are near the source port, at the center of the edge, or near the target port, each above, below, or centered on the edge. The distance to the edge and the absolute angular orientation of the label can be specified.
Modifier and Type | Class and Description |
---|---|
static class |
NinePositionsEdgeLabelModel.Position
Determines the position of a label in the
NinePositionsEdgeLabelModel . |
Modifier and Type | Field and Description |
---|---|
static ILabelModelParameter |
CENTER_ABOVE
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
CENTER_BELOW
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
CENTER_CENTERED
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
SOURCE_ABOVE
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
SOURCE_BELOW
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
SOURCE_CENTERED
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
TARGET_ABOVE
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
TARGET_BELOW
A convenience parameter instance that can be shared between label instances.
|
static ILabelModelParameter |
TARGET_CENTERED
A convenience parameter instance that can be shared between label instances.
|
Constructor and Description |
---|
NinePositionsEdgeLabelModel()
Initializes a new instance of the
NinePositionsEdgeLabelModel class with a Distance of 10
and an Angle of 0. |
NinePositionsEdgeLabelModel(double distance,
double angle)
Initializes a new instance of the
NinePositionsEdgeLabelModel class. |
Modifier and Type | Method and Description |
---|---|
ILabelModelParameter |
createDefaultParameter()
Creates a default parameter that can be used for this model.
|
ILabelModelParameter |
createParameter(NinePositionsEdgeLabelModel.Position position)
Create a model parameter for the specified .
|
double |
getAngle()
Gets the angle for the rotation of the labels.
|
ILookup |
getContext(ILabel label,
ILabelModelParameter layoutParameter)
Provides a
lookup context for the given combination of label and parameter. |
double |
getDistance()
Gets the distance of the labels above or below the edge.
|
IOrientedRectangle |
getGeometry(ILabel label,
ILabelModelParameter layoutParameter)
Calculates the
geometry of the given label using the given model parameter. |
IEnumerable<ILabelModelParameter> |
getParameters(ILabel label,
ILabelModel model)
Returns an enumerator over a set of possible
ILabelModelParameter instances that can be used for the given label
and model. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
void |
setAngle(double value)
Sets the angle for the rotation of the labels.
|
void |
setDistance(double value)
Sets the distance of the labels above or below the edge.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public static final ILabelModelParameter CENTER_ABOVE
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter CENTER_BELOW
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter CENTER_CENTERED
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter SOURCE_ABOVE
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter SOURCE_BELOW
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter SOURCE_CENTERED
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter TARGET_ABOVE
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter TARGET_BELOW
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public static final ILabelModelParameter TARGET_CENTERED
Trying to change that instances' Angle
or Distance
properties will raise an
IllegalStateException
.
public NinePositionsEdgeLabelModel()
NinePositionsEdgeLabelModel
class with a Distance
of 10
and an Angle
of 0.public NinePositionsEdgeLabelModel(double distance, double angle)
NinePositionsEdgeLabelModel
class.distance
- The distance.angle
- The angle.public final ILabelModelParameter createDefaultParameter()
ILabelModel
createDefaultParameter
in interface ILabelModel
public ILabelModelParameter createParameter(NinePositionsEdgeLabelModel.Position position)
position
position
- The position for this parameterposition
public double getAngle()
A value of 0
makes the label appear horizontally aligned.
setAngle(double)
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 double getDistance()
setDistance(double)
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 IEnumerable<ILabelModelParameter> getParameters(ILabel label, ILabelModel model)
ILabelModelParameterProvider
ILabelModelParameter
instances that can be used for the given label
and model.getParameters
in interface ILabelModelParameterProvider
label
- The label instance to use.model
- The model to provide parameters for.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 setAngle(double value)
A value of 0
makes the label appear horizontally aligned.
value
- The angle in radians.getAngle()
public void setDistance(double value)
value
- The distance to the edge.getDistance()