Graph Editor

This subject is dedicated to the development of a graph editor. The project will consist of using this editor and the 2nd training lesson on automata to built an automata editor.

Part 1

During this first part, you will realize a graphical component allowing to create circles and move them.
The graphical components used in this part are a JFrame containing a JComponent.

Here are the steps to follow :
  1. Create a class GraphFrame extending JFrame and a class GraphComponent extending JComponent. A GraphFrame will contain a GraphComponent. Instances of GraphComponent will have a default size of 500x500.
  2. Make instances of GraphComponent also instances of MouseInputListener. Trace on the standard output the listening of the mouse events on a GraphComponent.
  3. Draw in the GraphComponent a plain circle with radius 5 and modify the management of the events in such a way that, each time you click inside the circle, the word "win" is written on the standard output.
  4. Modify the management of the events in such a way that, if the circle does not yet exist, it is created when you pressed the button of the mouse, and moved if you drag before releasing the button.
  5. Manage the existence of more than one circle.

Part 2 

  1. Write a new version of GraphComponent using the API Java2D. You will use instances of Ellipse2D for the circles.
  2. Add scrollbars to the GraphComponent.
  3. Add a menu allowing to open and close new windows, and quit the program. Use a dialog to confirm before quit.
  4. Add a toolbar on the left side. Put in the toolbar buttons allowing to create different shapes : circle, square ... Use a GridLayout to organize buttons in the toolbar.

Part 3

  1. How to add easily new shapes like "small square", "big circle" ... ?
  2. Modify the management of the events in such a way that, if the key "alt" is down when you press the mouse button, an edge (line segment) is added between the two shapes. If there is no shape at the point where you release the button, a new shape will be added.
  3. Modify the management of the events in such a way that, if you push the space bar during the creation of an edge, it will add a joint point. Joint points will be showed as small red circles that you may move.
Part 4
  1. Use the right button to delete elements: shapes, edges, joint point.
  2. Label the vertices (shapes) with numbers.
  3. Add labels and arrows to edges.

Project

During the project, you will have to :

The starting point will be the correction of the training lessons. The project must be an extension of it. Then, please modify as less as possible the existing code. Any change must be clearly justified.

You may also improve the quality of the editor : use colors, change type of line for the edges, forbid multi-edges or loops whithout joint point... Nethertheless, the mark will be based more on the quality than the quantity of the code.

Criteria for the evaluation :