de.cau.cs.kieler.kiml
Class LayoutDataService

java.lang.Object
  extended by de.cau.cs.kieler.kiml.LayoutDataService
Direct Known Subclasses:
ExtensionLayoutDataService

public class LayoutDataService
extends Object

Singleton class for access to the KIML layout data. This class is used globally to retrieve data for automatic layout through KIML. The class cannot be instantiated directly, but only through a subclass that calls createLayoutServices(). The subclass is then responsible to add appropriate data to the nested registry instance. Multiple instances of subclasses can register themselves by calling createLayoutServices(subInstance), where subInstance is the instance of the subclass, but only one instance per subclass is allowed. Registering another instance will overwrite the prior instance. The different instances are identified by class name and the currently used instance can be determined by calling getMode(). You can switch between the different instances by calling setMode(final Class clas) or setMode(final Object object), where object has to be an instance of a subclass of LayoutDataService.

Rating yellow
(2011-03-14) reviewed by cmot, cds

Nested Class Summary
 class LayoutDataService.Registry
          Class used to register the layout services.
 
Field Summary
static String DIAGRAM_TYPE_GENERAL
          identifier of the 'general' diagram type, which applies to all diagrams.
 
Constructor Summary
protected LayoutDataService()
          The default constructor is hidden to prevent others from instantiating this singleton class.
 
Method Summary
static void createLayoutServices()
          Creates an instance of the layout services and assigns an instance of the registry.
protected static void createLayoutServices(LayoutDataService subInstance)
          Registers a layout data service instance created by a specific subclass and assigns it an instance of the registry.
 Collection<LayoutAlgorithmData> getAlgorithmData()
          Returns a data collection for all registered layout algorithms.
 LayoutAlgorithmData getAlgorithmData(String id)
          Returns the layout algorithm data associated with the given identifier.
 String getCategoryName(String id)
          Returns the name of the given category.
 String getDiagramTypeName(String id)
          Returns the name of the given diagram type.
 List<Pair<String,String>> getDiagramTypes()
          Returns a collection of registered diagram types.
static LayoutDataService getInstance()
          Returns the instance of the currently used layout data service.
static
<T extends LayoutDataService>
T
getInstanceOf(Class<? extends LayoutDataService> clas)
          Returns the instance of a specific layout data service identified by its class name.
static Class<? extends LayoutDataService> getMode()
          Returns the mode in which the layout data service is operating identified by the class name of the layout data service.
 Object getOption(EClass clazz, String optionId)
          Retrieves a layout option value for a domain model class.
 Object getOption(String objectId, String optionId)
          Retrieves a layout option value for an object identifier.
 Collection<LayoutOptionData<?>> getOptionData()
          Returns a data collection for all registered layout options.
 List<LayoutOptionData<?>> getOptionData(LayoutAlgorithmData algorithmData, LayoutOptionData.Target targetType)
          Returns a list of layout options that are suitable for the given layout algorithm and layout option target.
 LayoutOptionData<?> getOptionData(String id)
          Returns the layout option data associated with the given identifier.
 Map<String,Object> getOptions(EClass clazz)
          Returns a map that contains all layout option values for a domain model class.
 Map<String,Object> getOptions(String objectId)
          Returns a map that contains all layout option values for an object identifier.
static LayoutDataService.Registry getRegistry()
          Returns the instance of the registry class associated with the current layout data service.
 List<SemanticLayoutConfig> getSemanticConfigs(EClass clazz)
          Return the semantic layout configurations that are associated with the given domain model class.
 Collection<LayoutTypeData> getTypeData()
          Returns a list of layout type identifiers and names.
 LayoutTypeData getTypeData(String id)
          Returns the data instance of the layout type with given identifier.
static void removeLayoutServices(Class<? extends LayoutDataService> clazz)
          Removes a layout data service instance identified by its class name.
static void removeLayoutServices(LayoutDataService subInstance)
          Removes a layout data service identified by its instance.
static Class<? extends LayoutDataService> setMode(Class<? extends LayoutDataService> clas)
          Sets the mode in which the layout data service is operating identified by the class name of the layout data service to be used.
static Class<? extends LayoutDataService> setMode(Object object)
          Sets the mode in which the layout data service is operating identified by the class name of the object which has to be an instance of a sublass of LayoutDataService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIAGRAM_TYPE_GENERAL

public static final String DIAGRAM_TYPE_GENERAL
identifier of the 'general' diagram type, which applies to all diagrams.

See Also:
Constant Field Values
Constructor Detail

LayoutDataService

protected LayoutDataService()
The default constructor is hidden to prevent others from instantiating this singleton class.

Method Detail

createLayoutServices

public static void createLayoutServices()
Creates an instance of the layout services and assigns an instance of the registry.


createLayoutServices

protected static void createLayoutServices(LayoutDataService subInstance)
Registers a layout data service instance created by a specific subclass and assigns it an instance of the registry.

Parameters:
subInstance - an instance created by a subclass

removeLayoutServices

public static void removeLayoutServices(LayoutDataService subInstance)
Removes a layout data service identified by its instance. If the currently used instance is removed, the layout data service is in an inoperable state and you have to define the new operational mode by calling setMode(final Class clas) or setMode(final Object object).

Parameters:
subInstance - The instance to be removed.

removeLayoutServices

public static void removeLayoutServices(Class<? extends LayoutDataService> clazz)
Removes a layout data service instance identified by its class name.

Parameters:
clazz - Class identifier of the instance to be removed.

getMode

public static Class<? extends LayoutDataService> getMode()
Returns the mode in which the layout data service is operating identified by the class name of the layout data service.

Returns:
Class name of the current layout data service.

setMode

public static Class<? extends LayoutDataService> setMode(Class<? extends LayoutDataService> clas)
Sets the mode in which the layout data service is operating identified by the class name of the layout data service to be used. If no service with this class name has been registered, the mode is not changed.

Parameters:
clas - The class name of the service to be used.
Returns:
The class name of the prior used service.

setMode

public static Class<? extends LayoutDataService> setMode(Object object)
Sets the mode in which the layout data service is operating identified by the class name of the object which has to be an instance of a sublass of LayoutDataService. If no service with this class name has been registered, the mode is not changed.

Parameters:
object - An instance identifying the new mode by its class name.
Returns:
The class name of the prior used service.

getInstance

public static LayoutDataService getInstance()
Returns the instance of the currently used layout data service.

Returns:
the instance, or null if either no instance has been registered yet or the currently used service has been removed.

getInstanceOf

public static <T extends LayoutDataService> T getInstanceOf(Class<? extends LayoutDataService> clas)
Returns the instance of a specific layout data service identified by its class name.

Parameters:
clas - Class name of the required layout data service.
Returns:
the instance, or null if either no instance has been registered yet or it has been removed

getRegistry

public static final LayoutDataService.Registry getRegistry()
Returns the instance of the registry class associated with the current layout data service.

Returns:
the registry instance, or null if either no layout data service has been registered yet or it has been removed

getAlgorithmData

public final LayoutAlgorithmData getAlgorithmData(String id)
Returns the layout algorithm data associated with the given identifier.

Parameters:
id - layout algorithm identifier
Returns:
the corresponding layout algorithm data, or null if there is no algorithm with the given identifier

getAlgorithmData

public final Collection<LayoutAlgorithmData> getAlgorithmData()
Returns a data collection for all registered layout algorithms. The collection is unmodifiable.

Returns:
collection of registered layout algorithms

getOptionData

public final LayoutOptionData<?> getOptionData(String id)
Returns the layout option data associated with the given identifier.

Parameters:
id - layout option identifier
Returns:
the corresponding layout option data, or null if there is no option with the given identifier

getOptionData

public final Collection<LayoutOptionData<?>> getOptionData()
Returns a data collection for all registered layout options. The collection is unmodifiable.

Returns:
collection of registered layout options

getOptionData

public final List<LayoutOptionData<?>> getOptionData(LayoutAlgorithmData algorithmData,
                                                     LayoutOptionData.Target targetType)
Returns a list of layout options that are suitable for the given layout algorithm and layout option target. The layout algorithm must know the layout options and at the target must be active for each option.

Parameters:
algorithmData - layout algorithm data
targetType - type of layout option target
Returns:
list of suitable layout options

getTypeData

public final LayoutTypeData getTypeData(String id)
Returns the data instance of the layout type with given identifier.

Parameters:
id - identifier of the type
Returns:
layout type data instance with given identifier, or null if the layout type is not registered

getTypeData

public final Collection<LayoutTypeData> getTypeData()
Returns a list of layout type identifiers and names. The first string in each entry is the identifier, and the second string is the name.

Returns:
a list of all layout types

getCategoryName

public final String getCategoryName(String id)
Returns the name of the given category.

Parameters:
id - identifier of the category
Returns:
user friendly name of the category, or null if there is no category with the given identifier

getDiagramTypeName

public final String getDiagramTypeName(String id)
Returns the name of the given diagram type.

Parameters:
id - identifier of the diagram type
Returns:
user friendly name of the diagram type, or null if there is no diagram type with the given identifier

getDiagramTypes

public final List<Pair<String,String>> getDiagramTypes()
Returns a collection of registered diagram types. The first element of each returned entry is a diagram type identifier, the second element is the corresponding name.

Returns:
the registered diagram types

getOptions

public final Map<String,Object> getOptions(String objectId)
Returns a map that contains all layout option values for an object identifier.

Parameters:
objectId - an object identifier, such as an edit part class name, a domain model class name, or a diagram type id
Returns:
a map of layout option identifiers to their values

getOption

public final Object getOption(String objectId,
                              String optionId)
Retrieves a layout option value for an object identifier.

Parameters:
objectId - an object identifier, such as an edit part class name, a domain model class name, or a diagram type id
optionId - a layout option identifier
Returns:
the preconfigured value of the option, or null if the option is not set for the given object

getOptions

public final Map<String,Object> getOptions(EClass clazz)
Returns a map that contains all layout option values for a domain model class. This involves options that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
Returns:
a map of layout option identifiers to their values

getOption

public final Object getOption(EClass clazz,
                              String optionId)
Retrieves a layout option value for a domain model class. This involves options that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
optionId - a layout option identifier
Returns:
the option value for the class or a superclass, or null if the option is not set for the class

getSemanticConfigs

public final List<SemanticLayoutConfig> getSemanticConfigs(EClass clazz)
Return the semantic layout configurations that are associated with the given domain model class. This involves configurations that are set for any superclass of the given one.

Parameters:
clazz - a domain model class
Returns:
the semantic layout configurations for the class or a superclass