de.cau.cs.kieler.kiml.layout
Class LayoutServices

java.lang.Object
  extended by de.cau.cs.kieler.kiml.layout.LayoutServices
Direct Known Subclasses:
EclipseLayoutServices

public class LayoutServices
extends Object

Singleton class for access to the KIML layout services. 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.

Rating proposed yellow
(2009-12-11) msp

Nested Class Summary
 class LayoutServices.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 LayoutServices()
          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 the singleton instance of the registry.
protected static void createLayoutServices(LayoutServices subclassInstance)
          Sets a layout services instance created by a specific subclass and assigns the singleton instance of the registry.
 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 LayoutServices getInstance()
          Returns the singleton instance of the layout services class.
 Collection<LayoutOptionData> getLayoutOptionData()
          Returns a data collection for all registered layout options.
 LayoutOptionData getLayoutOptionData(String id)
          Returns the layout option data associated with the given identifier.
 List<LayoutOptionData> getLayoutOptions(LayoutProviderData providerData, LayoutOptionData.Target target)
          Returns a list of layout options that are suitable for the given layout provider and layout option target.
 AbstractLayoutProvider getLayoutProvider(KNode layoutNode)
          Returns the most appropriate layout provider for the given node.
 Collection<LayoutProviderData> getLayoutProviderData()
          Returns a data collection for all registered layout providers.
 LayoutProviderData getLayoutProviderData(String id)
          Returns the layout provider data associated with the given identifier.
 LayoutProviderData getLayoutProviderData(String layoutHint, String diagramType)
          Returns the layout provider with highest priority for the given layout hint and diagram type.
 String getLayoutTypeName(String id)
          Returns the name of the layout type with given identifier.
 List<Pair<String,String>> getLayoutTypes()
          Returns a list of layout type identifiers and names.
 Object getOption(String objectId, String optionId)
          Retrieves the layout option with given identifier for an object identifier.
 Map<String,Object> getOptions(String id)
          Returns a map that contains all layout options for an object identifier.
static LayoutServices.Registry getRegistry()
          Returns the singleton instance of the registry class.
 void layoutPerformed(KNode layoutGraph, IKielerProgressMonitor monitor)
          Calls the layoutPerformed method of all registered layout listeners.
 void layoutRequested(KNode layoutGraph)
          Calls the layoutRequested method of all registered layout listeners.
protected  LayoutServices.Registry registry()
          Returns the associated instance of the registry class.
 
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

LayoutServices

protected LayoutServices()
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 the singleton instance of the registry.


createLayoutServices

protected static void createLayoutServices(LayoutServices subclassInstance)
Sets a layout services instance created by a specific subclass and assigns the singleton instance of the registry.

Parameters:
subclassInstance - an instance created by a subclass

getInstance

public static LayoutServices getInstance()
Returns the singleton instance of the layout services class.

Returns:
the singleton instance

getRegistry

public static final LayoutServices.Registry getRegistry()
Returns the singleton instance of the registry class.

Returns:
the singleton registry

registry

protected final LayoutServices.Registry registry()
Returns the associated instance of the registry class.

Returns:
the associated registry

layoutRequested

public final void layoutRequested(KNode layoutGraph)
Calls the layoutRequested method of all registered layout listeners.

Parameters:
layoutGraph - layout graph for which layout is requested

layoutPerformed

public final void layoutPerformed(KNode layoutGraph,
                                  IKielerProgressMonitor monitor)
Calls the layoutPerformed method of all registered layout listeners.

Parameters:
layoutGraph - layout graph for which layout was performed
monitor - progress monitor containing execution time results

getLayoutProviderData

public final LayoutProviderData getLayoutProviderData(String id)
Returns the layout provider data associated with the given identifier.

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

getLayoutProviderData

public final Collection<LayoutProviderData> getLayoutProviderData()
Returns a data collection for all registered layout providers. The collection is unmodifiable.

Returns:
collection of registered layout providers

getLayoutProviderData

public final LayoutProviderData getLayoutProviderData(String layoutHint,
                                                      String diagramType)
Returns the layout provider with highest priority for the given layout hint and diagram type.

Parameters:
layoutHint - identifier of either a layout provider or a layout type
diagramType - identifier of a diagram type
Returns:
the layout provider with highest priority, or null if there is no registered layout provider

getLayoutProvider

public final AbstractLayoutProvider getLayoutProvider(KNode layoutNode)
                                               throws KielerException
Returns the most appropriate layout provider for the given node.

Parameters:
layoutNode - node for which a layout provider is requested
Returns:
a layout provider instance that fits the layout hints for the given node
Throws:
KielerException - if there is no registered layout provider

getLayoutOptionData

public final LayoutOptionData getLayoutOptionData(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

getLayoutOptionData

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

Returns:
collection of registered layout options

getLayoutOptions

public final List<LayoutOptionData> getLayoutOptions(LayoutProviderData providerData,
                                                     LayoutOptionData.Target target)
Returns a list of layout options that are suitable for the given layout provider and layout option target. The layout provider must know the layout options and at the target must be active for each option.

Parameters:
providerData - layout provider data
target - layout option target
Returns:
list of suitable layout options

getLayoutTypeName

public final String getLayoutTypeName(String id)
Returns the name of the layout type with given identifier.

Parameters:
id - identifier of the type
Returns:
user friendly name of the type, or null if the layout type is not registered

getLayoutTypes

public final List<Pair<String,String>> getLayoutTypes()
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 id)
Returns a map that contains all layout options for an object identifier.

Parameters:
id - an object identifier
Returns:
a map of layout option identifiers to their values

getOption

public final Object getOption(String objectId,
                              String optionId)
Retrieves the layout option with given identifier for an object identifier.

Parameters:
objectId - an object identifier
optionId - the layout option identifier
Returns:
the preconfigured value of the option, or null if the option is not set for the given object