de.cau.cs.kieler.kiml.ui.layout
Class EclipseLayoutConfig

java.lang.Object
  extended by de.cau.cs.kieler.kiml.DefaultLayoutConfig
      extended by de.cau.cs.kieler.kiml.ui.layout.EclipseLayoutConfig
All Implemented Interfaces:
IPropertyHolder, ILayoutConfig
Direct Known Subclasses:
GmfLayoutConfig, GraphitiLayoutConfig

public class EclipseLayoutConfig
extends DefaultLayoutConfig

A layout configuration for extension point configurations and user preferences.

Rating proposed yellow
(2011-01-13) msp

Constructor Summary
EclipseLayoutConfig()
          Create a stand-alone Eclipse layout configuration.
EclipseLayoutConfig(ILayoutConfig externalConfig)
          Create an Eclipse layout configuration embedding an external configuration.
 
Method Summary
protected  void addProperties(Map<IProperty<?>,Object> options)
          Add all options that have pre-configured or user defined default values to the given map.
protected
<T> T
doGetProperty(LayoutOptionData<T> optionData)
          Retrieve the pre-configured or user defined default value for a layout option.
 Map<IProperty<?>,Object> getAllProperties()
          Returns a map of all options that have pre-configured or user defined default values.
 EditPart getEditPart()
          Returns the edit part for the selected element.
 ILayoutConfig getExternalConfig()
          Returns the external layout configuration embedded in this configuration, if present.
protected  Boolean getFixedSizeValue()
          Return the dynamic value for the fixed size option.
static Object getOption(EditPart editPart, EObject modelElement, IProperty<?> property)
          Retrieves a layout option for the given edit part and model element by querying the option for the edit part's class name and its domain model name.
static Object getOption(EditPart editPart, IProperty<?> optionData)
          Retrieves a layout option from the given edit part by using the framework bridge associated with the edit part type.
protected  PortConstraints getPortConstraintsValue()
          Return the dynamic value for the port constraints option.
<T> T
getProperty(IProperty<T> property)
          Retrieve the pre-configured or user defined default value for a layout option.
 void initialize(LayoutOptionData.Target targetType, EditPart editPart, String theLayoutHint)
          Initialize the configuration with a layout hint and an edit part for the content (if target type is LayoutOptionData.Target#PARENTS) or the container of the selected element.
 void setAspectRatio(float ratio)
          Set the suggested aspect ratio.
 void setChildren(boolean children)
          Set whether the node in focus has any children.
 void setFocus(Object element)
          Set the edit part or domain model element as focus for this layout configuration.
 void setPorts(boolean ports)
          Set whether the node in focus has any ports.
 
Methods inherited from class de.cau.cs.kieler.kiml.DefaultLayoutConfig
clearProperties, copyProperties, getContainerLayouterData, getContentLayouterData, getLayouterData, getOptionData, initialize, isDefault, setDiagramDefault, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseLayoutConfig

public EclipseLayoutConfig()
Create a stand-alone Eclipse layout configuration.


EclipseLayoutConfig

public EclipseLayoutConfig(ILayoutConfig externalConfig)
Create an Eclipse layout configuration embedding an external configuration.

Parameters:
externalConfig - an external layout configuration
Method Detail

getOption

public static Object getOption(EditPart editPart,
                               IProperty<?> optionData)
Retrieves a layout option from the given edit part by using the framework bridge associated with the edit part type.

Parameters:
editPart - an edit part
optionData - layout option data
Returns:
the current value for the given option, or null

getOption

public static Object getOption(EditPart editPart,
                               EObject modelElement,
                               IProperty<?> property)
Retrieves a layout option for the given edit part and model element by querying the option for the edit part's class name and its domain model name.

Parameters:
editPart - an edit part
modelElement - the corresponding model element
property - layout option data
Returns:
the current value for the given option, or null

setFocus

public void setFocus(Object element)
Set the edit part or domain model element as focus for this layout configuration. This can be done without initializing the layout configuration in order to use getAllProperties() efficiently, since the same configuration instance can be reused multiple times. Passing null clears the current focus and resets information about children and ports.

Specified by:
setFocus in interface ILayoutConfig
Overrides:
setFocus in class DefaultLayoutConfig
Parameters:
element - an EditPart or EObject

setChildren

public void setChildren(boolean children)
Set whether the node in focus has any children.

Parameters:
children - whether the selected node has children

setPorts

public void setPorts(boolean ports)
Set whether the node in focus has any ports.

Parameters:
ports - whether the selected node has ports

setAspectRatio

public void setAspectRatio(float ratio)
Set the suggested aspect ratio.

Parameters:
ratio - the suggested value for aspect ratio

initialize

public final void initialize(LayoutOptionData.Target targetType,
                             EditPart editPart,
                             String theLayoutHint)
Initialize the configuration with a layout hint and an edit part for the content (if target type is LayoutOptionData.Target#PARENTS) or the container of the selected element.

Parameters:
targetType - type of the selected element (parent, node, edge, port, etc.)
editPart - the edit part
theLayoutHint - a layout hint, or null

getProperty

public final <T> T getProperty(IProperty<T> property)
Retrieve the pre-configured or user defined default value for a layout option. This implementation requires initialize and setFocus to be called first in order to give correct results.

Specified by:
getProperty in interface IPropertyHolder
Overrides:
getProperty in class DefaultLayoutConfig
Type Parameters:
T - type of option
Parameters:
property - a layout option
Returns:
the default value for the layout option

doGetProperty

protected <T> T doGetProperty(LayoutOptionData<T> optionData)
Retrieve the pre-configured or user defined default value for a layout option.

Type Parameters:
T - type of option
Parameters:
optionData - a layout option
Returns:
the default value for the layout option

getFixedSizeValue

protected Boolean getFixedSizeValue()
Return the dynamic value for the fixed size option.

Returns:
true if the selected node has no children, and false otherwise

getPortConstraintsValue

protected PortConstraints getPortConstraintsValue()
Return the dynamic value for the port constraints option.

Returns:
FIXED_POS if the selected node has ports and no children, and FREE otherwise

getAllProperties

public final Map<IProperty<?>,Object> getAllProperties()
Returns a map of all options that have pre-configured or user defined default values.

Specified by:
getAllProperties in interface IPropertyHolder
Overrides:
getAllProperties in class DefaultLayoutConfig
Returns:
a map of layout option values

addProperties

protected void addProperties(Map<IProperty<?>,Object> options)
Add all options that have pre-configured or user defined default values to the given map.

Parameters:
options - a map of layout option values

getEditPart

public final EditPart getEditPart()
Returns the edit part for the selected element.

Returns:
the edit part, or null if none is selected

getExternalConfig

public final ILayoutConfig getExternalConfig()
Returns the external layout configuration embedded in this configuration, if present.

Returns:
an external layout configuration, or null