How to work on Easik

Easik is intended to provide a set of tools for manipulating an EA Sketch diagram.

The Sketch is represented by a JGraph object. A JGraph object is also a swing component that goes right onto the interface. So, the Sketch class is added to the ApplicationFrame. For this reason, the Sketch object can be reset via a method call, but shouldn't simply be recreated, that would require you to add a new swing component.

The ApplicationFrame is the base swing component for this application. There will only ever be one instance of this class, and it contains the instance of the Sketch. The applicationframe is created in the JEase class, which starts everything when instantiated.

Because there will only ever be one Easik, it will be using the singleton design pattern. Here it is implemented with the static method 'getInstance()' which will create an instance if one does not exist and will return the instance. This effectively makes the Sketch global, which is convienent with so many accessors. Accessing the Sketch from anywhere works like this:

JEase.getInstance().getFrame().getSketch()

That's how it works.

Now, we also use JGraphT as our underlying graph datastructure provider. This is a great little package that deals with graphs. It has no output, and that is why we use JGraph. JGraphT interfaces with JGraph using an adapter class. So changes in JGraphT are reflected in the other. However, all the cosmetic aspects of the graph (including how things are selected) are controlled in JGraph. JGraph is a big hairy, but it has some decent forums online at their home page to help one muddle through it. Things that need to be done are curved edges (allowing for multiple visible edges between the same nodes) as well as toggling the visibility of the helper nodes (those which indicate constraints). If you take a peek at how I did the path selecting code, you'll see how the edit function works on JGraphs. If you change it a little so that instead of toggling selectability, it toggles visibility, you can hack together a way to turn visual aids on and off.

Most of the functionality can be used in a bit of an 'immediate' mode, we call it 'basic editing mode'. This is how we immediately create edges, nodes, simple constraints. However, more complicated constraints need a more complicated way to be inputted. This is why we introduced the application state stack.

The application state stack keeps track of what 'state' the program is in. And example of needing some states is adding commutivity constraints. Since we will have to select a path of edges, then say "this is one" and then select another path of edges and say "and here is another" we can't do it immediately by simply highlighting all the edges we want. It is easy to come up with an abiguity. So! We have these states. States get pushed onto the stack, and then can push more stuff onto the stack, and as they are popped off and completed, they pass data among themselves. These states affect how the program works. For example, when selecting a path, only contiguous edges are allowed to be selected. The top state on the stack also gets informed of if the state 'Cancel' and 'Next' buttons are pressed and can control whether or not these buttons are enabled.

