Login | Register
My pages Projects Community openCollabNet

Discussions > users > [gef-users] MVC trouble or how to create edges

Discussion topic

Back to topic list

[gef-users] MVC trouble or how to create edges


Author jevopi
Full name Jens v. P.
Date 2005-02-09 05:33:33 PST
Message Hi all,

I'm trying to build a very simple diagram editor for directed graphs.
A graph is my model consiting of the following classes:

    +-----| MyGraph |---------------+
    | +---------+ |
    | |
    | |
   *|+nodes *|+veteces
+------+ 1 +sourceVertex +-----------+
|MyEdge|------------​-----------| MyVertex |
+------+ +sourceEdges *+-----------+
    |1 +targetVertex |+ x |
    +---------------------------|+ y |
     +targetEdges *|+width |
                               |+height |

(anyone knows about an ASCII export plugin for Argo/UML ;) )

Now I've implemented a GraphNodeRenderer and a GraphEdgeRenderer:

MyVertexRenderer creating MyVertexFigures (subclass of FigNode) and
MyEdgeRenderer creating MyEdgeFigures (subclass of FigEdgeLine).

MyGraphModel is a subclass of MutableGraphSupport. This class is the
first one I don't understand. On the one hand its methods are called by
the framework (Hollywood principle aka Inversion of Control). On the
other hand I have to "call back", e.g. by calling the super methods or
firing an event. Is this correct?

Now I could succesfully create a Node, i.e. a pair of MyVertex with its
figure MyVertexFigure. The model object (MyVertex) is created by the
command, MyGraphModel.addNode(..) is called and
MyVertexRenderer.getFigFor(..) is called. Everything is fine.
Except the fact that I don't know how to retrieve the position of the
mouse. The object model is created by the command, and there's no
information about the position when the GraphModel is called.
How do I set the position inside the model?

My most serious problem is that I can't create an edge, that is MyEdge
and MyEdgeFigure here. Dragging a rubber band from one node (or vertex)
to another is working fine. When releasing the mouse button,
MyGraphModel:connect(..) is called. There I can create an instance of
MyEdge. This is how my connect method (and addNode/Edge) looks like:

public class MyGraphModel extends MutableGraphSupport {

     public Object connect(Object i_fromPort, Object i_toPort) {
         MyEdge e = new MyEdge();
         return e;

     public void addEdge(Object i_edge) {

     public void addNode(Object i_node) {

(as you see my model doesn't support ports - verteces are the ports

After that, MyEdgeRenderer is called creating a new MyEdgeFigure (which
is a FigEdgeLine).

And then an exception occurs in FigEdgeLine.computeRoute(). This method
is called from LayerPerspective after the model and view object were
created. The problem is:

FigEdgeLine expects property "sourceportfig" to be set, but it isn't.
Where do I have to set this property? My model objects don't know
anything about the views. Thus it's not possibe to "ask" the model
object about its view. I think this is one principle of the MVC
paradim. But exectly that is what NetNode is doing in
NetNode.presentationFor(Layer lay). I guess I'm missunderstanding
something. What is NetNode? Is it part of the model? Or part of the
controller? I'm confused. Maybe I need something like a map, mapping
model objects to figures. Is this the way to solve the problem?

Summary: All I want to do is create a simple editor for verteces and
edges, with an underlying model which doen't know anything about the
graphical editor. The GraphEdgeRenderer, GraphNodeRenderer and
GraphModel seems to be mediators between the model and GEF. What did I



BTW: I was looking for tutorials and documentations about GEF. Since
there are no links on the web page, maybe this list will be helpful for
others -- and maybe somebody can add some links I didn't found:

Robbins, J. E. (1999): Cognitive Support Features for Software
Development Tools. Dissertation University of California. URL:
http://argouml.tigris.org/docs/ (GEF: pages 184-192)

Skinner, M. (2001): Enhancing an Open Source UML Editor by
Context-Based Constraints for Components. Thesis TU Berlin. URL:
http://www.cocons.or​g/publications/CCL_p​lugin_for_ArgoUML.pd​f (GEF:
pages 42-48)

Zhang, G. (2002): CASE support For Modeling Web Applications. Thesis
LMU Munich. URL:
-0.8.1a.pdf (GEF: pages 39-49)

Steinbrueckner, F. (2002) Analyse von Software Systemen - Projekt
Argo-UML. Seminararbeit TU Cottbus. URL:
steinbrueckner0.pdf (German language only, GEF: pages 9-10)

To unsubscribe, e-mail: users-unsubscribe@ge​f.tigris.org
For additional commands, e-mail: users-help at gef dot tigris dot org

« Previous message in topic | 1 of 5 | Next message in topic »


Show all messages in topic

[gef-users] MVC trouble or how to create edges jevopi Jens v. P. 2005-02-09 05:33:33 PST
     Re: [gef-users] MVC trouble or how to create edges bobtarling Bob Tarling 2005-02-09 06:14:54 PST
         Re: [gef-users] MVC trouble or how to create edges jevopi Jens v. P. 2005-02-09 07:55:33 PST
             Re: [gef-users] MVC trouble or how to create edges bobtarling Bob Tarling 2005-02-09 08:10:13 PST
     Re: [gef-users] MVC trouble or how to create edges jevopi Jens v. P. 2005-02-09 06:17:31 PST
Messages per page: