# eileen0904/uml_editor architecture

> Architecture diagram of the GitHub repository eileen0904/uml_editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eileen0904/uml_editor
- Repository: https://github.com/eileen0904/uml_editor

## Overview

##### Project Type & Purpose
- It follows a simple MVC-style separation with GUI (View), interaction logic (Mode/Controller), object creation (Factory), and domain objects (Model).

##### File Structure
- src/View: UI components (Frame, Panel, Canvas, Main)
- src/Menu: top-level menus, menu items, grouping/ungrouping
- src/Buttons: toolbar buttons corresponding to actions (oval, rect, line types, select)
- src/Mode: “controller” classes implementing behavior per tool/mode (e.g. OvalMode, SelectMode)
- bin: compiled output
- .vscode: VS Code settings for source/bin mapping

##### README
- Confirms standard Java project layout: src → source, bin → compiled classes
- No additional services or external integrations

##### Main Components & Their Relationships
a. UI Layer (View & Menu & Buttons)
- Main Frame hosts MenuBar, ToolBar (Buttons), and Canvas.
- Canvas renders Model objects and forwards mouse/input events.
b. Controller/Interaction Layer (Mode)
- A Mode class active at runtime handles input on Canvas and delegates to Factory.
- Switching tool buttons or menu items swaps the current Mode.
c. Factory Layer
- LineFactory and ObjectFactory classes implement LineInterface/ObjectInterface.
- Mode classes call the appropriate Factory to instantiate Model objects.
d. Model Layer (Objects)
- A set of abstract classes (ShapeAbstract, LineAbstract, ObjectAbstract) with concrete subclasses (Oval, Rect, Association, Composition, Generalization).
e. External Technology
- Java SE GUI toolkit (Swing or AWT), run in VS Code.

##### Architectural Patterns
- MVC (View, Controller (Mode), Model)
- Factory Method or Abstract Factory for object/line creation
- Strategy pattern for Mode behaviors
- Composite pattern for grouping (CompositeObject)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% View Layer
    subgraph "View Layer"
        Main["Main"]:::ui
        Frame["Frame"]:::ui
        Panel["Panel"]:::ui
        Canvas["Canvas"]:::ui
    end

    %% Menu & Toolbar
    subgraph "Menu & Toolbar"
        subgraph "Menu"
            MenuBar["MenuBar"]:::ui
            Menu["Menu"]:::ui
            MenuItem["MenuItem"]:::ui
            EditMenu["EditMenu"]:::ui
            Group["Group"]:::ui
            Ungroup["Ungroup"]:::ui
            CustomLabel["CustomLabel"]:::ui
        end
        subgraph "Toolbar Buttons"
            ButtonAbstract["ButtonAbstract"]:::ui
            OvalBtn["OvalBtn"]:::ui
            RectBtn["RectBtn"]:::ui
            SelectBtn["SelectBtn"]:::ui
            AssociationLineBtn["AssociationLineBtn"]:::ui
            CompositionLineBtn["CompositionLineBtn"]:::ui
            GeneralizationLineBtn["GeneralizationLineBtn"]:::ui
        end
    end

    %% Controller (Mode) Layer
    subgraph "Controller (Mode) «Strategy»"
        CanvasMode["CanvasMode"]:::controller
        OvalMode["OvalMode"]:::controller
        RectMode["RectMode"]:::controller
        SelectMode["SelectMode"]:::controller
        AssociationLineMode["AssociationLineMode"]:::controller
        CompositionLineMode["CompositionLineMode"]:::controller
        GeneralizationLineMode["GeneralizationLineMode"]:::controller
    end

    %% Factory Layer
    subgraph "Factory Layer «Factory Method»"
        ObjectInterface["ObjectInterface"]:::factory
        OvalObject["OvalObject"]:::factory
        RectObject["RectObject"]:::factory
        LineInterface["LineInterface"]:::factory
        AssociationLine["AssociationLine"]:::factory
        CompositionLine["CompositionLine"]:::factory
        GeneralizationLine["GeneralizationLine"]:::factory
    end

    %% Model Layer
    subgraph "Model Layer"
        ObjectAbstract["ObjectAbstract"]:::model
        ShapeAbstract["ShapeAbstract"]:::model
        LineAbstract["LineAbstract"]:::model
        Port["Port"]:::model
        CompositeObject["CompositeObject"]:::model
        Label["Label"]:::model
        subgraph "BasicObjects"
            Oval["Oval"]:::model
            Rect["Rect"]:::model
        end
        subgraph "Line Objects"
            Association["Association"]:::model
            Composition["Composition"]:::model
            Generalization["Generalization"]:::model
        end
    end

    %% Connections
    Main --> Panel
    Panel --> Canvas
    Canvas -->|"onClick/input"| CanvasMode

    %% Tool selection
    OvalBtn -->|"select"| OvalMode
    RectBtn -->|"select"| RectMode
    SelectBtn -->|"select"| SelectMode
    AssociationLineBtn -->|"select"| AssociationLineMode
    CompositionLineBtn -->|"select"| CompositionLineMode
    GeneralizationLineBtn -->|"select"| GeneralizationLineMode

    %% Mode to Factory
    OvalMode -->|"createObject()"| OvalObject
    RectMode -->|"createObject()"| RectObject
    AssociationLineMode -->|"createLine()"| AssociationLine
    CompositionLineMode -->|"createLine()"| CompositionLine
    GeneralizationLineMode -->|"createLine()"| GeneralizationLine

    %% Factory to Model
    OvalObject -->|"returns Oval"| Oval
    RectObject -->|"returns Rect"| Rect
    AssociationLine -->|"returns Association"| Association
    CompositionLine -->|"returns Composition"| Composition
    GeneralizationLine -->|"returns Generalization"| Generalization

    %% Model to View
    Oval -->|"draw()"| Canvas
    Rect -->|"draw()"| Canvas
    Association -->|"draw()"| Canvas
    Composition -->|"draw()"| Canvas
    Generalization -->|"draw()"| Canvas

    %% Click Events
    click Main "https://github.com/eileen0904/uml_editor/blob/main/src/View/Main.java"
    click Frame "https://github.com/eileen0904/uml_editor/blob/main/src/View/Frame.java"
    click Panel "https://github.com/eileen0904/uml_editor/blob/main/src/View/Panel.java"
    click Canvas "https://github.com/eileen0904/uml_editor/blob/main/src/View/Canvas.java"
    click MenuBar "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/MenuBar.java"
    click Menu "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/Menu.java"
    click MenuItem "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/MenuItem.java"
    click EditMenu "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/EditMenu.java"
    click Group "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/Group.java"
    click Ungroup "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/Ungroup.java"
    click CustomLabel "https://github.com/eileen0904/uml_editor/blob/main/src/Menu/CustomLabel.java"
    click ButtonAbstract "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/ButtonAbstract.java"
    click OvalBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/OvalBtn.java"
    click RectBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/RectBtn.java"
    click SelectBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/SelectBtn.java"
    click AssociationLineBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/AssociationLineBtn.java"
    click CompositionLineBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/CompositionLineBtn.java"
    click GeneralizationLineBtn "https://github.com/eileen0904/uml_editor/blob/main/src/Buttons/GeneralizationLineBtn.java"
    click CanvasMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/CanvasMode.java"
    click OvalMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/OvalMode.java"
    click RectMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/RectMode.java"
    click SelectMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/SelectMode.java"
    click AssociationLineMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/AssociationLineMode.java"
    click CompositionLineMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/CompositionLineMode.java"
    click GeneralizationLineMode "https://github.com/eileen0904/uml_editor/blob/main/src/Mode/GeneralizationLineMode.java"
    click ObjectInterface "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/ObjectInterface.java"
    click OvalObject "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/OvalObject.java"
    click RectObject "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/RectObject.java"
    click LineInterface "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/LineInterface.java"
    click AssociationLine "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/AssociationLine.java"
    click CompositionLine "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/CompositionLine.java"
    click GeneralizationLine "https://github.com/eileen0904/uml_editor/blob/main/src/Factory/GeneralizationLine.java"
    click ObjectAbstract "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/ObjectAbstract.java"
    click ShapeAbstract "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/ShapeAbstract.java"
    click LineAbstract "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Line/LineAbstract.java"
    click Port "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Port.java"
    click CompositeObject "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/CompositeObject.java"
    click Label "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Label.java"
    click Oval "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/BasicObjects/Oval.java"
    click Rect "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/BasicObjects/Rect.java"
    click Association "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Line/Association.java"
    click Composition "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Line/Composition.java"
    click Generalization "https://github.com/eileen0904/uml_editor/blob/main/src/Objects/Line/Generalization.java"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,color:#006064
    classDef controller fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef factory fill:#FFF9C4,stroke:#F57F17,color:#F57F17
    classDef model fill:#FFE0B2,stroke:#E65100,color:#E65100
```
