public class FreeLabelModel extends Object implements ILabelModelParameterFinder, ILabelModel
The position of the label is stored absolutely and is not influenced by the layout or position of the owner of the
label. In fact the owner is not even queried during a call to getGeometry(ILabel, ILabelModelParameter)
.
Modifier and Type | Field and Description |
---|---|
static FreeLabelModel |
INSTANCE
A shared public instance that can be used to obtain parameters.
|
Constructor and Description |
---|
FreeLabelModel() |
Modifier and Type | Method and Description |
---|---|
ILabelModelParameter |
createAbsolute(PointD anchorLocation,
double angle)
Creates a new label model parameter that places the label at the given absolute position using the provided angle.
|
ILabelModelParameter |
createAnchored(IPoint location,
double angle)
Creates a new label at the given dynamic location using the provided angle.
|
ILabelModelParameter |
createDefaultParameter()
Creates a default parameter that can be used for this model.
|
ILabelModelParameter |
createDynamic(IOrientedRectangle layout)
Creates a new label model parameter that dynamically reads the label layout from the provided instance.
|
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. |
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public static final FreeLabelModel INSTANCE
public final ILabelModelParameter createAbsolute(PointD anchorLocation, double angle)
anchorLocation
- The location for the parameter.angle
- The angle of rotation.public final ILabelModelParameter createAnchored(IPoint location, double angle)
location
- The location to place the parameter at. That instance is stored by reference.angle
- The angle of rotation.public final ILabelModelParameter createDefaultParameter()
ILabelModel
createDefaultParameter
in interface ILabelModel
public final ILabelModelParameter createDynamic(IOrientedRectangle layout)
layout
- The oriented rectangle to dynamically retrieve the values from.public final ILabelModelParameter findBestParameter(ILabel label, ILabelModel model, IOrientedRectangle layout)
ILabelModelParameterFinder
This method may not necessarily find a parameter that matches the provided layout exactly. Implementations may choose to
simply return the model's default parameter
but may never return
null
.
findBestParameter
in interface ILabelModelParameterFinder
label
- The label to find a parameter for.model
- The model instance to use. This should be the instance this instance has been obtained from.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 <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.