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 :
- 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.
- Make instances of GraphComponent also instances of
MouseInputListener. Trace on the standard output the listening of the
mouse events on a GraphComponent.
- 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.
- 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.
- Manage the existence of more than one circle.
Part 2
- Write a new version of GraphComponent using the API Java2D.
You will use instances of Ellipse2D
for the circles.
- Add scrollbars to the GraphComponent.
- Add a menu allowing to open and close new windows, and quit the
program. Use a dialog to confirm before quit.
- 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
- How to add easily new shapes like "small square", "big circle"
... ?
- 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.
- 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
- Use the right button to delete elements: shapes, edges, joint
point.
- Label the vertices (shapes) with numbers.
- Add labels and arrows to edges.
Project
During the project, you will have to :
- use the graph editor to create an automaton. You will also use
the training lesson on automata ;
- save automata into files and load them. You will use in
particular the component JFileChooser ;
- visualize the acknowledgment of a word in the editor.
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
:
- Quality of the code, object aspects.
- Robustness : protection against user's error during the
execution.
- Ergonomics of the user interface. Clearness of the visualization
of informations.
- Initiative and originality (it is annoying to see all the time
clones of the same program !)