Modelers

org.topcased.modeler.utils
Class Utils

java.lang.Object
  extended by org.topcased.modeler.utils.Utils

public final class Utils
extends java.lang.Object

Helper class to manage the graph model.
creation : 10 d�c. 2004


Method Summary
static GraphEdge createGraphEdge(java.lang.String type)
          Creates a graph edge NOT linked with a model object
static GraphEdge createGraphEdge(java.lang.String type, java.lang.String presentation)
          Creates a graph edge NOT linked with a model object
static GraphNode createGraphNode(java.lang.String type)
          Creates a graph node NOT linked with a model object
static GraphNode createGraphNode(java.lang.String type, java.lang.String presentation)
          Creates a graph node NOT linked with a model object
static void exposeLocation(org.eclipse.draw2d.FigureCanvas canvas, org.eclipse.draw2d.geometry.Point location)
          This api will expose the diagram at the location given in absolute co-ordinates.
static org.eclipse.swt.graphics.Color getBackgroundColor(GraphElement graphElement)
          Returns the background Color of the Figure
static Diagram getDiagram(GraphElement graphElement)
          Used to get the Diagram node of a given graphElement
static EObject getDiagramModelObject(GraphElement graphElement)
          Used to get the model object that is the root of the current diagram
static Diagram[] getDiagrams(GraphElement[] graphElements)
          Used to get the Diagrams of GraphElements
static EdgeGraphConf getEdgeGraphConf(DiagramGraphConf diagGraphConf, EObject modelObject, java.lang.String presentation)
          Search in the DiagramGraphConf the first EdgeGraphConf with the corresponding EClass and presentation that validate all the constraints when they exist
static java.util.List getEdges(GraphElement gElt)
          Get the list of the incoming/outgoing connections
static EObject getElement(GraphElement graphElt)
          Returns the model object linked with the given graph element (If the bridge is an EMFSemanticModelBridge)
static org.eclipse.swt.graphics.Font getFont(DiagramElement diagElement)
          Get the Font corresponding to a DiagramElement
static org.eclipse.swt.graphics.Color getForegroundColor(GraphElement graphElement)
          Returns the foreground Color of the Figure
static GraphElement getGraphElement(GraphElement container, EObject model)
          Returns the GraphElement child associated with the given model object
static GraphElement getGraphElement(GraphElement container, EObject model, boolean deepSearch)
          Returns the GraphElement child associated with the given model object
static GraphElement[] getGraphElements(Diagrams diagrams, EObject model)
          Returns the graphElements associated with the given EObject in all the diagrams
static java.util.List getGraphElements(GraphElement container, EObject model, boolean deepSearch)
          Returns the GraphElement children associated with the given model object
static NodeGraphConf getNodeGraphConf(DiagramGraphConf diagGraphConf, EObject modelObject, java.lang.String presentation)
          Search in the DiagramGraphConf the first NodeGraphConf with the corresponding EClass and presentation that validate all the constraints when they exist
static EList getOwnerList(EObject owner, EStructuralFeature feat)
          Returns the EList associated with the given feature for the given EMF object.
static GraphElement getSource(GraphEdge gEdge)
          Get the source GraphElement for the given connection
static java.util.List<GraphEdge> getSourceEdges(GraphElement gElt)
          Get the list of the outgoing connection
static GraphElement getTarget(GraphEdge gEdge)
          Get the target GraphElement for the given connection
static java.util.List getTargetEdges(GraphElement gElt)
          Get the list of the incoming connection
static java.lang.String getTypeInfo(GraphElement graphElt)
          Returns the type info associated with the given graph element (If the bridge is a SimpleSemanticModelBridge)
static boolean isChild(GraphElement parent, GraphElement child)
          Check if an object is a child of an other object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOwnerList

public static EList getOwnerList(EObject owner,
                                 EStructuralFeature feat)
Returns the EList associated with the given feature for the given EMF object.

Parameters:
owner - The EMF Object
feat - The list feature
Returns:
the EList or null if the feature cannot be found or it is not a multiple feature.

getElement

public static EObject getElement(GraphElement graphElt)
Returns the model object linked with the given graph element (If the bridge is an EMFSemanticModelBridge)

Parameters:
graphElt - the graph element
Returns:
the model object associated with the given graph element or null if unable to find a model object.

getGraphElement

public static GraphElement getGraphElement(GraphElement container,
                                           EObject model)
Returns the GraphElement child associated with the given model object

Parameters:
container - the graph container
model - the model EObject
Returns:
The GraphElement associated with the model object or null if no child can be found.

getGraphElement

public static GraphElement getGraphElement(GraphElement container,
                                           EObject model,
                                           boolean deepSearch)
Returns the GraphElement child associated with the given model object

Parameters:
container - the graph container
model - the model EObject
deepSearch - a boolean indicating if the search process must be recursive
Returns:
The GraphElement associated with the model object or null if no child can be found.

getGraphElements

public static java.util.List getGraphElements(GraphElement container,
                                              EObject model,
                                              boolean deepSearch)
Returns the GraphElement children associated with the given model object

Parameters:
container - the graph container
model - the model EObject
deepSearch - a boolean indicating if the search process must be recursive
Returns:
The list of GraphElements associated with the model object or an Empty list if no child can be found.

getGraphElements

public static GraphElement[] getGraphElements(Diagrams diagrams,
                                              EObject model)
Returns the graphElements associated with the given EObject in all the diagrams

Parameters:
diagrams - the Diagrams object
model - the searched EObject
Returns:
the List of associated GraphElements

getTypeInfo

public static java.lang.String getTypeInfo(GraphElement graphElt)
Returns the type info associated with the given graph element (If the bridge is a SimpleSemanticModelBridge)

Parameters:
graphElt - the graph element
Returns:
the type info associated with the given graph element or null if unable to find a type info (it is not a SimpleSemanticModelBridge).

createGraphNode

public static GraphNode createGraphNode(java.lang.String type)
Creates a graph node NOT linked with a model object

Parameters:
type - the identifier of the node
Returns:
the graph node

createGraphNode

public static GraphNode createGraphNode(java.lang.String type,
                                        java.lang.String presentation)
Creates a graph node NOT linked with a model object

Parameters:
type - the identifier of the node
presentation - the presentation of the graphical element
Returns:
the graph node

createGraphEdge

public static GraphEdge createGraphEdge(java.lang.String type)
Creates a graph edge NOT linked with a model object

Parameters:
type - the identifier of the edge
Returns:
the graph edge

createGraphEdge

public static GraphEdge createGraphEdge(java.lang.String type,
                                        java.lang.String presentation)
Creates a graph edge NOT linked with a model object

Parameters:
type - the identifier of the edge
presentation - the presentation of the graphical element
Returns:
the graph edge

getBackgroundColor

public static org.eclipse.swt.graphics.Color getBackgroundColor(GraphElement graphElement)
Returns the background Color of the Figure

Parameters:
graphElement -
Returns:
Color

getForegroundColor

public static org.eclipse.swt.graphics.Color getForegroundColor(GraphElement graphElement)
Returns the foreground Color of the Figure

Parameters:
graphElement -
Returns:
Color

getFont

public static org.eclipse.swt.graphics.Font getFont(DiagramElement diagElement)
Get the Font corresponding to a DiagramElement

Parameters:
diagElement -
Returns:
Font

getTarget

public static GraphElement getTarget(GraphEdge gEdge)
Get the target GraphElement for the given connection

Parameters:
gEdge - the connection
Returns:
the target graph element

getSource

public static GraphElement getSource(GraphEdge gEdge)
Get the source GraphElement for the given connection

Parameters:
gEdge - the connection
Returns:
the source graph element

isChild

public static boolean isChild(GraphElement parent,
                              GraphElement child)
Check if an object is a child of an other object

Parameters:
parent - the parent graph element
child - the possible child element
Returns:
a boolean ;)

getEdges

public static java.util.List getEdges(GraphElement gElt)
Get the list of the incoming/outgoing connections

Parameters:
gElt - the graphical element
Returns:
the list of connections

getSourceEdges

public static java.util.List<GraphEdge> getSourceEdges(GraphElement gElt)
Get the list of the outgoing connection

Parameters:
gElt - the source element
Returns:
the list of source connections

getTargetEdges

public static java.util.List getTargetEdges(GraphElement gElt)
Get the list of the incoming connection

Parameters:
gElt - the source element
Returns:
the list of target connections

getDiagramModelObject

public static EObject getDiagramModelObject(GraphElement graphElement)
Used to get the model object that is the root of the current diagram

Parameters:
graphElement -
Returns:
the root model object of the current diagram

getDiagram

public static Diagram getDiagram(GraphElement graphElement)
Used to get the Diagram node of a given graphElement

Parameters:
graphElement -
Returns:
the current Diagram

getDiagrams

public static Diagram[] getDiagrams(GraphElement[] graphElements)
Used to get the Diagrams of GraphElements

Parameters:
graphElements - the elements to have the diagram
Returns:
the current Diagram

exposeLocation

public static void exposeLocation(org.eclipse.draw2d.FigureCanvas canvas,
                                  org.eclipse.draw2d.geometry.Point location)
This api will expose the diagram at the location given in absolute co-ordinates.

Parameters:
canvas -
location -

getNodeGraphConf

public static NodeGraphConf getNodeGraphConf(DiagramGraphConf diagGraphConf,
                                             EObject modelObject,
                                             java.lang.String presentation)
Search in the DiagramGraphConf the first NodeGraphConf with the corresponding EClass and presentation that validate all the constraints when they exist

Parameters:
diagGraphConf - the DiagramGraphConf that contains all the NodeGraphConf objects
modelObject - the model object that should correspond to a NodeGraphConf
presentation - the presentation to match
Returns:
the first NodeGraphConf that match all the constraints

getEdgeGraphConf

public static EdgeGraphConf getEdgeGraphConf(DiagramGraphConf diagGraphConf,
                                             EObject modelObject,
                                             java.lang.String presentation)
Search in the DiagramGraphConf the first EdgeGraphConf with the corresponding EClass and presentation that validate all the constraints when they exist

Parameters:
diagGraphConf - the DiagramGraphConf that contains all the EdgeGraphConf objects
modelObject - the model object that should correspond to an EdgeGraphConf
presentation - the presentation to match
Returns:
the first EdgeGraphConf that match all the constraints

Modelers

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.