public class CompositeLabelModel extends Object implements ILabelModel, ILabelModelParameterProvider, ILabelModelParameterFinder
ILabelModel that can be used to create custom label models out of existing ILabelModel
instances.
This class holds a number of models and can provide all of their parameters in
getParameters(ILabel, ILabelModel). A custom model can easily be created that way:
| Constructor and Description |
|---|
CompositeLabelModel()
Creates a new instance of this label model with an empty
LabelModels collection. |
| Modifier and Type | Method and Description |
|---|---|
ILabelModelParameter |
createDefaultParameter()
Creates a default parameter that can be used for this model.
|
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. |
List<ILabelModel> |
getLabelModels()
Gets a list of
ILabelModel implementations that are wrapped by this instance. |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookuppublic CompositeLabelModel()
LabelModels collection.public final ILabelModelParameter createDefaultParameter()
If LabelModels is not empty, the default parameter for the first model in that list is
returned. Otherwise, the default parameter for FreeLabelModel.createDefaultParameter() is returned.
createDefaultParameter in interface ILabelModelpublic final ILabelModelParameter findBestParameter(ILabel label, ILabelModel model, IOrientedRectangle layout)
This implementation tests all parameters from all models in LabelModels.
findBestParameter in interface ILabelModelParameterFinderlabel - 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 final ILookup getContext(ILabel label, ILabelModelParameter layoutParameter)
ILabelModellookup context for the given combination of label and parameter.getContext in interface ILabelModellabel - 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.EMPTYpublic final IOrientedRectangle getGeometry(ILabel label, ILabelModelParameter layoutParameter)
ILabelModelgeometry of the given label using the given model parameter.getGeometry in interface ILabelModellabel - 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 final List<ILabelModel> getLabelModels()
ILabelModel implementations that are wrapped by this instance.public final IEnumerable<ILabelModelParameter> getParameters(ILabel label, ILabelModel model)
ILabelModelParameter instances that can be used for the given label
and model.
This implementation returns all parameters from all models in LabelModels
getParameters in interface ILabelModelParameterProviderlabel - The label instance to use.model - The model to provide parameters for.public final <TLookup> TLookup lookup(Class<TLookup> type)
ILookupnull.
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.