de.cau.cs.kieler.kiml.ui.util
Class KimlUiUtil

java.lang.Object
  extended by de.cau.cs.kieler.kiml.ui.util.KimlUiUtil

public final class KimlUiUtil
extends Object

Utility methods used for the KIML UI.

Rating proposed yellow
(2009-12-11) msp

Method Summary
static Insets calcInsets(IFigure parent, IFigure child)
          Determines the insets for a parent figure, relative to the given child.
static Rectangle getAbsoluteBounds(IFigure figure)
          Calculates the absolute bounds of the given figure.
static Point getAbsolutePoint(Connection connection, int index)
          Calculates an absolute position for one of the bend points of the given connection.
static Point getAbsolutePosition(KNode node)
          Will return the absolute position on the canvas of an KNode from a KGraph.
static Point getAbsolutePosition(KPort port)
          Will return the absolute position on the canvas of an KPort from a KGraph.
static List<Point> getBendPointsAbsolutePositions(KEdge edge)
          Gives the absolute positions of all bend points on the given edge.
static LayoutOptionData<?> getOptionData(LayoutAlgorithmData[] providerDataArray, String displayName)
          Retrieves a suitable layout option data instance that matches the given user friendly display name.
static LayoutOptionData<?> getOptionData(LayoutAlgorithmData providerData, String optionName)
          Returns the layout option data that matches the given user-friendly name and is known by the given layout provider.
static void runModelChange(Runnable runnable, TransactionalEditingDomain editingDomain, String label)
          Performs the model changes specified in the given runnable in a safe context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calcInsets

public static Insets calcInsets(IFigure parent,
                                IFigure child)
Determines the insets for a parent figure, relative to the given child.

Parameters:
parent - the figure of a parent edit part
child - the figure of a child edit part
Returns:
the insets to add to the relative coordinates of the child

getAbsoluteBounds

public static Rectangle getAbsoluteBounds(IFigure figure)
Calculates the absolute bounds of the given figure.

Parameters:
figure - a figure
Returns:
the absolute bounds

getAbsolutePoint

public static Point getAbsolutePoint(Connection connection,
                                     int index)
Calculates an absolute position for one of the bend points of the given connection.

Parameters:
connection - a connection figure
index - the index in the point list
Returns:
the absolute point

runModelChange

public static void runModelChange(Runnable runnable,
                                  TransactionalEditingDomain editingDomain,
                                  String label)
Performs the model changes specified in the given runnable in a safe context.

Parameters:
runnable - a runnable that performs model changes
editingDomain - the editing domain for the changes
label - a user friendly label shown for the undo action

getOptionData

public static LayoutOptionData<?> getOptionData(LayoutAlgorithmData providerData,
                                                String optionName)
Returns the layout option data that matches the given user-friendly name and is known by the given layout provider.

Parameters:
providerData - a layout provider data
optionName - user-friendly name of a layout option
Returns:
the corresponding layout option data

getOptionData

public static LayoutOptionData<?> getOptionData(LayoutAlgorithmData[] providerDataArray,
                                                String displayName)
Retrieves a suitable layout option data instance that matches the given user friendly display name.

Parameters:
providerDataArray - array of applicable layout provider data
displayName - display name of the layout option as seen by the user
Returns:
the most suitable layout option data

getAbsolutePosition

public static Point getAbsolutePosition(KNode node)
Will return the absolute position on the canvas of an KNode from a KGraph.

Parameters:
node - The node to find the absolute position for
Returns:
The absolute position on the canvas of the KNode

getAbsolutePosition

public static Point getAbsolutePosition(KPort port)
Will return the absolute position on the canvas of an KPort from a KGraph.

Parameters:
port - The port to find the absolute position for
Returns:
The absolute position on the canvas of the KPort

getBendPointsAbsolutePositions

public static List<Point> getBendPointsAbsolutePositions(KEdge edge)
Gives the absolute positions of all bend points on the given edge.

Parameters:
edge - The edge to get the bend points from
Returns:
A list of points, being the absolute positions of the bend points