Packagecom.yworks.graph.model
Classpublic class GenericLabelModel
InheritanceGenericLabelModel Inheritance Object
Implements ILabelModel, ILabelModelParameterProvider, ILabelCandidateDescriptorProvider

An implementation of 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:

     GenericLabelModel glm = new GenericLabelModel(InteriorLabelModel.Center);
     glm.AddParameter(ExteriorLabelModel.North);
     glm.AddParameter(ExteriorLabelModel.South);
     glm.AddParameter(InteriorStretchLabelModel.East);
     glm.AddParameter(InteriorStretchLabelModel.West);
     

See also

ILabelModel
ILabelModelParameter


Public Properties
 PropertyDefined By
  parameters : ArrayList
[read-only] Gets the parameter list.
GenericLabelModel
Public Methods
 MethodDefined By
  
Create a new generic label model using the provided parameter as the default parameter.
GenericLabelModel
  
Adds another parameter to this models collection of parameters.
GenericLabelModel
  
Creates a default parameter that can be used for this model.
GenericLabelModel
  
Creates a new GenericParameter to wrap the ModelParameter in
GenericLabelModel
  
GenericLabelModel
  
Yields the ILabelCandidateDescriptor that has been associated with the instance during addParameter.
GenericLabelModel
  
Calculates the geometry in form of an IOrientedRectangle for a given label using the given model parameter.
GenericLabelModel
  
Returns an iterator over a set of possible ILabelModelParameter instances that can be used for the given label and model.
GenericLabelModel
  
lookup(type:Class):Object
Returns an instance that implements the given type or null.
GenericLabelModel
Property Detail
parametersproperty
parameters:ArrayList  [read-only]

Gets the parameter list.


Implementation
    public function get parameters():ArrayList
Constructor Detail
GenericLabelModel()Constructor
public function GenericLabelModel(defaultParameter:ILabelModelParameter, descriptor:ILabelCandidateDescriptor = null)

Create a new generic label model using the provided parameter as the default parameter.

The parameter is stored by reference.

Parameters
defaultParameter:ILabelModelParameter — The parameter to use as the default.
 
descriptor:ILabelCandidateDescriptor (default = null) — The descriptor to associate with the default parameter.

See also

Method Detail
addParameter()method
public function addParameter(parameter:ILabelModelParameter, descriptor:ILabelCandidateDescriptor = null):ILabelModelParameter

Adds another parameter to this models collection of parameters.

Note that the parameter will be wrapped by this class and the resulting parameter which will use this model instance as its ILabelModelParameter.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 method.

Parameters

parameter:ILabelModelParameter — The parameter to add to this instance.
 
descriptor:ILabelCandidateDescriptor (default = null) — The descriptor to associate with the parameter.

Returns
ILabelModelParameter — A new parameter that wraps the provided parameter and uses this instance as its model.

See also

createDefaultParameter()method 
public function createDefaultParameter():ILabelModelParameter

Creates a default parameter that can be used for this model.

Returns
ILabelModelParameter — A parameter for this model instance.
createParameter()method 
public function createParameter(parameter:ILabelModelParameter, descriptor:ILabelCandidateDescriptor = null):ILabelModelParameter

Creates a new GenericParameter to wrap the ModelParameter in

Parameters

parameter:ILabelModelParameter — The Parameter to be wrapped in the GenericParameter
 
descriptor:ILabelCandidateDescriptor (default = null)

Returns
ILabelModelParameter — A new parameter that wraps the provided parameter and uses this instance as its model.
getContext()method 
public function getContext(label:ILabel, parameter:ILabelModelParameter):ILookup

Parameters

label:ILabel
 
parameter:ILabelModelParameter

Returns
ILookup
getDescriptor()method 
public function getDescriptor(label:ILabel, parameter:ILabelModelParameter):ILabelCandidateDescriptor

Yields the ILabelCandidateDescriptor that has been associated with the instance during addParameter.

Parameters

label:ILabel — The label instance to use.
 
parameter:ILabelModelParameter — The parameter to get the descriptor for.

Returns
ILabelCandidateDescriptor — The descriptor instance that has been added to this instance during addParameter.

See also

getGeometry()method 
public function getGeometry(modelParameter:ILabelModelParameter, label:ILabel):IOrientedRectangle

Calculates the geometry in form of an IOrientedRectangle for a given label using the given model parameter.

Parameters

modelParameter:ILabelModelParameter — A parameter that has been created by this model. This is typically the parameter that yielded this instance through its ILabelModelParameter.model property.
 
label:ILabel — The label to calculate the geometry for

Returns
IOrientedRectangle — An instance that describes the geometry. This is typically an instance designed as a flyweight, so clients should not cache the instance but store the values if they need a snapshot for later use
getParameters()method 
public function getParameters(label:ILabel, model:ILabelModel):Iterator

Returns an iterator over a set of possible ILabelModelParameter instances that can be used for the given label and model.

Parameters

label:ILabel — The label instance to use.
 
model:ILabelModel — The model to provide parameters for.

Returns
Iterator — A possibly empty iterator over a set of label model parameters.
lookup()method 
public function lookup(type:Class):Object

Returns an instance that implements the given type or 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.

Parameters

type:Class — the type for which an instance shall be returned

Returns
Object — an instance that is assignable to type or null