prmr / JetUML

A desktop application for fast UML diagramming.
GNU General Public License v3.0
620 stars 121 forks source link

#375 Add EdgePath, EdgeStorage, and EdgePriority #458

Closed maddy0218 closed 2 years ago

maddy0218 commented 2 years ago

In order to plan the paths of edges in class diagrams, several initial changes are needed:

  1. A way to represent the path of an edge
  2. A way to store the paths of edges
  3. A way to classify edges so that their paths can be planned in a predictable order

To meet these requirements 3 classes: EdgePath, EdgeStorage, and EdgePriority were added.

Representing and storing the paths of edges

An EdgePath class was added, which represents the path of an edge in a class diagram as a list of Points. An EdgeStorage class was created, which maps the edges of a class diagram to EdgePaths.

Once the Layouter class is implemented, it will plan the EdgePaths of edges in a class diagram and store them in EdgeStorage. Then, these stored paths can be used to draw clean, readable class diagrams without edge overlapping.

edgestorage

The EdgeStorage class has several public methods, including a method which allows users to store an Edge and its EdgePath, and a method to get the stored EdgePath of an Edge. Notably, EdgeStorage has a clearStorage() method which clears all entries of edges and their EdgePaths. This is necessary because EdgeStorage must be cleared and refilled whenever the diagram changes.

Establishing a priority classification for edges

An enumerated type EdgePriority was added which classifies class diagram edges. This way, all edges of a higher EdgePriority are planned before edges of lower EdgePriority. Classifying edges using an enumerated type is less error-prone than using the Edge class hierarchy. For example, Inheritance and Implementation edges are both considered GeneralizationEdges, and many different edges can be self-edges. The EdgePriority enumerated type has several public methods which are useful for edge classification.

The order of EdgePriority is as follows (where Inheritance edges have the highest priority):

  1. Inheritance
  2. Implementation
  3. Aggregation
  4. Composition
  5. Association
  6. Dependency
  7. Self-edges
  8. Other (non-class diagram edges)

Tests for EdgePath, EdgePriority, and EdgeStorage were also added.