JGraph can be a difficult library to understand initially The reader is

Jgraph can be a difficult library to understand

This preview shows page 58 - 60 out of 100 pages.

JGraph can be a difficult library to understand initially. The reader is directed to the JGraph tutorial for an official discussion of the framework. Below is a brief, bottom-up description of the environment. A small class diagram of the “‘core” JGraph model primitives 1 is supplied in figure 8.1. A graphing package at its heart is a convenience package allowing a user to easily connect a set of nodes with lines. In JGraph, a node is made by implementing the abstract GraphCell interface, and a line an Edge . The only way to connect an edge to a node is via another type of cell called a Port . (Nodes, edges and ports are all subtypes of the GraphCell interface). A port must be a child of a node. Thus, to connect one node to another with an edge, you do so via connecting that edge to a child port for each of the nodes. Figure 8.2 illustrates this relationship with a concrete example. In figure 8.2, two tasks are connected to each other with a flow. The tasks are YAWLVertex objects that implement the GraphCell interface. The flow is an extension of Edge interface. The edge is selected, making visible the ports connecting the edge to the boundaries of the relevant tasks. JGraph is an implementation of the MVC (Model-view-controller) software design pattern. An implementa- tion of this pattern requires a model object, a controller object, and a number of view objects. Very basic versions of each type of class are supplied via DefaultGraphModel , JGraph and GraphLayoutCache for the model, controller and views, respectively. Implementations of the interfaces listed in figure 8.1 must be placed within a DefaultGraphModel , to be considered part of that graph. An important conceptual note must be made here on how to appropriately use JGraph: 1 Even then, this is not a faithful representation of the true relationships of classes within JGraph, but does act as a good model of how to view how you’d typically consider these key classes to interact. Page 58 of 100
Image of page 58
org.jgraph.graph G r a p h C e l l E d g e P o r t child of * 1 child of 0-1 * has source * 0-1 has target * 0-1 Figure 8.1: A class diagram of the primitive model classes of JGraph Figure 8.2: An example editor net, showing nodes, edges and ports. A change to the graph model will only be recognised and responded to if done through key methods of the view, controller or graph model objects. If you directly change the color of a node, say, by programatically updating its colour directly, the controller will not know to inform the various views of that node that the colour has changed, and that they must now redraw themselves. All changes made to a graph ultimately must go through one of the three methods of DefaultGraphModel : insert() , remove() , and edit() . As stated earlier, failure to make changes via these methods will leave the views out of sync with the base model. It will also not record those changes as undoable events, which is typically automatically handled by the JGraph framework. Note that these methods are also supplied on the view and controller classes. It is sometimes easier to use one of these classes, if that is the level that your
Image of page 59
Image of page 60

You've reached the end of your free preview.

Want to read all 100 pages?

  • Spring '17
  • Sui
  • yawl

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes