com.yworks.yfiles.server.graphml.flexio.data
Class GenericLabelModel

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.flexio.data.GenericLabelModel
All Implemented Interfaces:
ILabelCandidateDescriptorProvider, ILabelModel

public class GenericLabelModel
extends java.lang.Object
implements ILabelModel, ILabelCandidateDescriptorProvider

Data object for an 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

Nested Class Summary
static class GenericLabelModel.GenericLabelModelParameterPair
          This class is used to serialize a GenericLabelModel's parameter together with an ILabelCandidateDescriptor.
static class GenericLabelModel.ModelParameter
           
 
Constructor Summary
GenericLabelModel(ILabelModelParameter defaultParameter)
          Create a new generic label model using the provided parameter as the default parameter.
GenericLabelModel(ILabelModelParameter defaultParameter, ILabelCandidateDescriptor descriptor)
          Create a new generic label model using the provided parameter as the default parameter.
 
Method Summary
 ILabelModelParameter addParameter(ILabelModelParameter parameter)
          Adds another parameter to this models collection of parameters.
 ILabelModelParameter addParameter(ILabelModelParameter parameter, ILabelCandidateDescriptor descriptor)
          Adds another parameter to this models collection of parameters.
 ILabelModelParameter createDefaultParameter()
          Creates a default parameter that can be used for this model.
 ILabelCandidateDescriptor getDescriptor(Label label, ILabelModelParameter parameter)
          Yields the ILabelCandidateDescriptor that has been associated with the instance during addParameter.
 java.util.List getParameters()
          Gets the parameter list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericLabelModel

public GenericLabelModel(ILabelModelParameter defaultParameter)
Create a new generic label model using the provided parameter as the default parameter.

The parameter is stored by reference.

Parameters:
defaultParameter - The parameter to use as the default.

GenericLabelModel

public GenericLabelModel(ILabelModelParameter defaultParameter,
                         ILabelCandidateDescriptor descriptor)
Create a new generic label model using the provided parameter as the default parameter.

The parameter is stored by reference.

Parameters:
defaultParameter - The parameter to use as the default.
descriptor - The descriptor to associate with the default parameter.
Method Detail

addParameter

public ILabelModelParameter addParameter(ILabelModelParameter parameter)
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.

Parameters:
parameter - The parameter to add to this instance.
Returns:
A new parameter that wraps the provided parameter and uses this instance as its model.

addParameter

public ILabelModelParameter addParameter(ILabelModelParameter parameter,
                                         ILabelCandidateDescriptor descriptor)
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 - The parameter to add to this instance.
descriptor - The descriptor to associate with the parameter.
Returns:
A new parameter that wraps the provided parameter and uses this instance as its model.

createDefaultParameter

public ILabelModelParameter createDefaultParameter()
Description copied from interface: ILabelModel
Creates a default parameter that can be used for this model.

Specified by:
createDefaultParameter in interface ILabelModel
Returns:
A parameter for this model instance.

getParameters

public java.util.List getParameters()
Gets the parameter list.


getDescriptor

public ILabelCandidateDescriptor getDescriptor(Label label,
                                               ILabelModelParameter parameter)
Yields the ILabelCandidateDescriptor that has been associated with the instance during addParameter.

Specified by:
getDescriptor in interface ILabelCandidateDescriptorProvider
Parameters:
label - The label to possibly assign the parameter.
parameter - The parameter to provide a descriptor for if applied to the given label
Returns:
A descriptor or null.


Copyright © 2000-2013 yWorks GmbH. All rights reserved