A toy UML diagram editor.
A toy UML diagram editor.
This is an assignment for Object-Oriented Analysis and Design (SE6029*) in NCU, Taiwan. A complete implementation of the specification.
Clone this repository.
git clone https://github.com/seanwu1105/uml-diagram-editor.git
Use IntelliJ IDEA to open the project. This project requires JDK >= 12
and JavaFX >= 12
(dependencies maintained by the Gradle script).
The following is a prototype UI for the UML editor.
This UML editor UI is divided into three regions. The first region allows users to place diagrams and make connections. This area is called “canvas area”. On the left-hand side is a region called “taskbar” containing a lot of buttons for tool selections.
The boxes that represent a class or the ellipses that represent the use case are said to be “basic objects”. Basic objects can be created by buttons and then moved around in the editing regions. As in common UML semantics, associations can be constructed between two basic objects.
A connection line is an entity between basic objects. We have three types of connection line. They are “association”, “composition” and “generalization”.
Just like many other object-oriented diagram editing tools. A tool user can select a set of objects and group them into a so-called “composite object”. A composite object can be composed of a set of basic objects and this composite object can be composed with other basic objects or composite object to become a more complicated composite object. A composite object is a type of container which can be implemented by a tree hierarchy. Ungrouping a composite object is equal to tear down the top level of the tree.
As in many other object-oriented diagram editing tool, every object has an attribute called “depth (from 0 to 99)”. This attribute concerns the drawing order of the objects. A deeper object is drawn behind an object that has less depth. Besides, when a set of objects are overlapped. The object on top of the objects always intercepts the mouse and keyboard events. For example, when a mouse clicks on two overlapped objects, only the object on the top receives the mouse/keyboard events.
This use case only applies to the modes of “class” and “use case”.
(x, y)
with the left mouse button, a basic object is created at (x, y)
as its top-left-corner.When other buttons in the taskbar are clicked, this mode is terminated and other mode controls the behaviors of the mouse.
This use case applies to the modes of “association line”, “generalization line” and “composition line” in the taskbar.
(x, y)
by mouse left button and (x, y)
is inside a basic object A. The user keeps the mouse button pressed.(x', y')
and (x', y')
is inside a basic object B.(x, y)
is not inside any basic object. The following actions from mouse pressed and mouse drag to mouse released make no effects.
(x', y')
is not inside any basic objects. No connection line is created.
Please assume each basic object has 4 ports as in the following figure. A connection line is established between two ports of basic objects. A simple rule is used to compute which port should be chosen when the mouse is clicked. For example, when the user pressed the mouse in (x, y)
, the distances to for ports can be computed. The port that has the shortest distance to (x, y)
should be chosen as the connection port for the new connection line.
This use case only applies to the “select” mode in the taskbar.
We say an object is “selected” if its four connection ports are displayed as the figure shown above. On the other hand, when an object is not selected, the four connection ports should be hidden.
If (x, y)
is not inside an object, do nothing. Also, deselect every object that is previously selected.
This use case only applies to the “select” mode in the taskbar.
(x1, y1)
without releasing the button and (x1, y1)
is not inside any objects.(x2, y2)
.(x1, y1, x2, y2)
are selected.If no object inside the rectangular area (x1, y1, x2, y2)
, deselect all previously selected objects.
This use case only applies to the case that at least two objects are selected under “select” mode.
This use case only applies to the case that only one composite object has been selected.
This use case only applies to “select” mode.
(x, y)
without releasing the button and (x, y)
is inside an object X (including composite objects).(x', y')
.(x', y')
.
(x, y)
could fall inside more than one objects (they are overlapped). In this case, the object on the top (with less depth) should be moved.
This use case only applies to “select” mode when only one basic object is selected.
User click Cancel button, the popped window disappears and do nothing.