public class GenericLabelModel extends Object implements ILabelModel, ILabelModelParameterProvider, ILabelCandidateDescriptorProvider, IMarkupExtensionConverter
ILabelModel that can be used to create custom label models out of existing ILabelModelParameter
instances.
This class holds a number of parameters and serves as a container for these parameters. Custom models can easily be created that way:
| Constructor and Description |
|---|
GenericLabelModel(ILabelModelParameter defaultLayoutParameter)
Create a new generic label model using the provided parameter as the
default parameter.. |
GenericLabelModel(ILabelModelParameter defaultLayoutParameter,
ILabelCandidateDescriptor descriptor)
Create a new generic label model using the provided parameter as the
default parameter.. |
| Modifier and Type | Method and Description |
|---|---|
ILabelModelParameter |
addParameter(ILabelModelParameter layoutParameter)
Adds another parameter to this models collection of parameters.
|
ILabelModelParameter |
addParameter(ILabelModelParameter layoutParameter,
ILabelCandidateDescriptor descriptor)
Adds another parameter to this models collection of parameters.
|
boolean |
canConvert(IWriteContext context,
Object value)
Returns if the converter can convert the
value to a MarkupExtension in the current write context. |
MarkupExtension |
convert(IWriteContext context,
Object value)
Converts the
value to a MarkupExtension using the current write context. |
ILabelModelParameter |
createDefaultParameter()
Creates a default parameter that can be used for this model.
|
ILookup |
getContext(ILabel label,
ILabelModelParameter layoutParameter)
Provides a
lookup context for the given combination of label and parameter. |
ILabelCandidateDescriptor |
getDescriptor(ILabel label,
ILabelModelParameter layoutParameter)
Yields the
ILabelCandidateDescriptor that has been associated with the instance during
addParameter(ILabelModelParameter, ILabelCandidateDescriptor). |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookuppublic GenericLabelModel(ILabelModelParameter defaultLayoutParameter)
default parameter..
The parameter is stored by reference.
NullPointerException - defaultParameter is null.defaultLayoutParameter - The parameter to use as the default.getDescriptor(ILabel, ILabelModelParameter)public GenericLabelModel(ILabelModelParameter defaultLayoutParameter, ILabelCandidateDescriptor descriptor)
default parameter..
The parameter is stored by reference.
NullPointerException - defaultParameter is null.defaultLayoutParameter - The parameter to use as the default.descriptor - The descriptor to associate with the parameter.getDescriptor(ILabel, ILabelModelParameter)public final ILabelModelParameter addParameter(ILabelModelParameter layoutParameter)
Note that the parameter will be wrapped by this class and the resulting parameter which will use this model instance as
its Model will be returned. The parameter is stored by reference and subsequent
modification of the parameter or its associated model will be reflected by this instance. Also the methods allows for
associating a ILabelCandidateDescriptor with each parameter that can later be retrieved via the getDescriptor(ILabel, ILabelModelParameter)
method.
layoutParameter - The parameter to add to this instance.public final ILabelModelParameter addParameter(ILabelModelParameter layoutParameter, ILabelCandidateDescriptor descriptor)
Note that the parameter will be wrapped by this class and the resulting parameter which will use this model instance as
its Model will be returned. The parameter is stored by reference and subsequent
modification of the parameter or its associated model will be reflected by this instance. Also the methods allows for
associating a ILabelCandidateDescriptor with each parameter that can later be retrieved via the getDescriptor(ILabel, ILabelModelParameter)
method.
layoutParameter - The parameter to add to this instance.descriptor - The descriptor to associate with the parameter.public final boolean canConvert(IWriteContext context, Object value)
IMarkupExtensionConvertervalue to a MarkupExtension in the current write context.canConvert in interface IMarkupExtensionConvertercontext - The current write context.value - The object to convert.public final MarkupExtension convert(IWriteContext context, Object value)
IMarkupExtensionConvertervalue to a MarkupExtension using the current write context.convert in interface IMarkupExtensionConvertercontext - The current write context.value - The object to convert.MarkupExtension the value was converted to.public final ILabelModelParameter createDefaultParameter()
ILabelModelcreateDefaultParameter in interface ILabelModelpublic 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 ILabelCandidateDescriptor getDescriptor(ILabel label, ILabelModelParameter layoutParameter)
ILabelCandidateDescriptor that has been associated with the instance during
addParameter(ILabelModelParameter, ILabelCandidateDescriptor).getDescriptor in interface ILabelCandidateDescriptorProviderlabel - The label instance to use.layoutParameter - The parameter to get the descriptor for.addParameter(ILabelModelParameter, ILabelCandidateDescriptor).public 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 IEnumerable<ILabelModelParameter> getParameters(ILabel label, ILabelModel model)
ILabelModelParameterProviderILabelModelParameter instances that can be used for the given label
and model.getParameters in interface ILabelModelParameterProviderlabel - The label instance to use.model - The model to provide parameters for.public <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.