de.cau.cs.kieler.kiml.gmf
Class GmfDiagramLayoutManager

java.lang.Object
  extended by de.cau.cs.kieler.kiml.ui.diagram.GefDiagramLayoutManager<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart>
      extended by de.cau.cs.kieler.kiml.gmf.GmfDiagramLayoutManager
All Implemented Interfaces:
IDiagramLayoutManager<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart>
Direct Known Subclasses:
MultiPartDiagramLayoutManager

public class GmfDiagramLayoutManager
extends GefDiagramLayoutManager<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart>

Diagram layout manager that is able to generically layout diagrams generated by GMF. The internal KGraph graph structure is built from the structure of edit parts in the diagram. The new layout is applied to the diagram using GmfLayoutEditPolicy, which creates a GmfLayoutCommand to directly manipulate data in the GMF notation model, where layout information is stored persistently.

Rating proposed yellow
(2009-12-11) msp

Field Summary
static IProperty<CommandStack> COMMAND_STACK
          the command stack that executes the command.
static IProperty<List<org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart>> CONNECTIONS
          list of connection edit parts that were found in the diagram.
static IProperty<org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart> DIAGRAM_EDIT_PART
          diagram edit part of the currently layouted diagram.
static IProperty<org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor> DIAGRAM_EDITOR
          editor part of the currently layouted diagram.
static IProperty<Command> LAYOUT_COMMAND
          the command that applies the transferred layout to the diagram.
 
Constructor Summary
GmfDiagramLayoutManager()
           
 
Method Summary
protected  void applyLayout(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping)
          Apply the transferred layout to the original diagram.
protected  LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> buildLayoutGraph(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart layoutRootPart)
          Creates the actual mapping given an edit part which functions as the root for the layout.
 LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> buildLayoutGraph(IWorkbenchPart workbenchPart, Object diagramPart)
          Build a KGraph instance for the given diagram.
 IMutableLayoutConfig getLayoutConfig()
          Return a framework-specific layout configuration.
protected  void processEdgeLabels(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping, org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection, KEdge edge, EdgeLabelPlacement placement, KVector offset)
          Process the labels of an edge.
protected  void setEdgeLayout(KEdgeLayout edgeLayout, org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection, KVector offset)
          Stores the layout information of the given connection edit part into an edge layout.
 boolean supports(Object object)
          Determine whether this layout manager is able to perform layout for the given object.
protected  void transferLayout(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping)
          Transfer all layout data from the last created KGraph instance to the original diagram.
 
Methods inherited from class de.cau.cs.kieler.kiml.ui.diagram.GefDiagramLayoutManager
applyLayout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTIONS

public static final IProperty<List<org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart>> CONNECTIONS
list of connection edit parts that were found in the diagram.


DIAGRAM_EDITOR

public static final IProperty<org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor> DIAGRAM_EDITOR
editor part of the currently layouted diagram.


DIAGRAM_EDIT_PART

public static final IProperty<org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart> DIAGRAM_EDIT_PART
diagram edit part of the currently layouted diagram.


LAYOUT_COMMAND

public static final IProperty<Command> LAYOUT_COMMAND
the command that applies the transferred layout to the diagram.


COMMAND_STACK

public static final IProperty<CommandStack> COMMAND_STACK
the command stack that executes the command.

Constructor Detail

GmfDiagramLayoutManager

public GmfDiagramLayoutManager()
Method Detail

supports

public boolean supports(Object object)
Determine whether this layout manager is able to perform layout for the given object.

Parameters:
object - a workbench part or edit part
Returns:
true if this layout manager supports the object

buildLayoutGraph

public LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> buildLayoutGraph(IWorkbenchPart workbenchPart,
                                                                                                       Object diagramPart)
Build a KGraph instance for the given diagram. The resulting layout graph should reflect the structure of the original diagram.

Parameters:
workbenchPart - the workbench part for which layout is performed
diagramPart - the parent object for which layout is performed, or null if the whole diagram shall be layouted
Returns:
a layout graph mapping

buildLayoutGraph

protected LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> buildLayoutGraph(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart layoutRootPart)
Creates the actual mapping given an edit part which functions as the root for the layout.

Parameters:
layoutRootPart - the layout root edit part
Returns:
a layout graph mapping

transferLayout

protected void transferLayout(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping)
Transfer all layout data from the last created KGraph instance to the original diagram. The diagram is not modified yet, but all required preparations are performed.

Specified by:
transferLayout in class GefDiagramLayoutManager<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart>
Parameters:
mapping - a layout mapping that was created by this layout manager

applyLayout

protected void applyLayout(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping)
Apply the transferred layout to the original diagram. This final step is where the actual change to the diagram is done.

Specified by:
applyLayout in class GefDiagramLayoutManager<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart>
Parameters:
mapping - a layout mapping that was created by this layout manager

getLayoutConfig

public IMutableLayoutConfig getLayoutConfig()
Return a framework-specific layout configuration.

Returns:
a layout configuration for this diagram layout manager

setEdgeLayout

protected void setEdgeLayout(KEdgeLayout edgeLayout,
                             org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection,
                             KVector offset)
Stores the layout information of the given connection edit part into an edge layout.

Parameters:
edgeLayout - an edge layout
connection - a connection edit part
offset - offset to be subtracted from coordinates

processEdgeLabels

protected void processEdgeLabels(LayoutMapping<org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart> mapping,
                                 org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection,
                                 KEdge edge,
                                 EdgeLabelPlacement placement,
                                 KVector offset)
Process the labels of an edge.

Parameters:
mapping - the layout mapping
connection - the connection edit part
edge - the layout edge
placement - predefined placement for all labels, or UNDEFINED if the placement shall be derived from the edit part
offset - the offset for coordinates