# acmi/l2tool architecture

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

- Interactive diagram: https://gitdiagram.com/acmi/l2tool
- Repository: https://github.com/acmi/l2tool

## Overview

##### Main Components
- User Interface (UI) Layer:
– This includes the JavaFX components defined by the .fxml files (l2tool.fxml and textureview/view.fxml) found in src/main/resources.
– The UI interacts with the user, displaying textures and receiving replacement commands.
- Controller Layer:
– The Controller.java and TextureView.java files in the “l2tool” and “textureview” packages, respectively, are the entry points that handle UI events.
– They coordinate the flow between the front-end (UI) and the underlying business logic.
- Business Logic & Command Processing:
– The L2Tool.java and L2ToolCmd.java classes act as the core of the application’s logic, processing commands and powering key features.
– They likely parse user actions and delegate tasks to specific modules.
- Image Processing Module:
– Under the “img” package, classes such as DDS.java, TGA.java, Palette.java, etc., are dedicated to handling different image formats and texture properties.
– This component encapsulates the logic necessary for reading, processing, and possibly converting image files.
- Texture Conversion Module:
– The texconv/ConvertTool.java class is responsible for converting textures between different formats.
– It operates in coordination with the image processing module.

##### Interactions & Data Flow
- The UI layer (JavaFX FXML views) sends user actions (e.g., opening a texture, requesting a replacement) to their corresponding controllers.
- Controllers (Controller.java, TextureView.java) then call the business logic components (L2Tool.java, L2ToolCmd.java) to execute these commands.
- When conversion or processing is needed, the business logic interacts with the image processing module (the classes in the “img” package as well as ConvertTool.java).
- Processed image data or conversion results are sent back up to the UI for display or further interaction.

##### Architectural Patterns & Important Details
- Separation of Concerns:
– UI is clearly separated from business logic, as each set of responsibilities is isolated into different packages (e.g., clientmod/l2tool for UI/logic and clientmod/texconv for conversion).
- MVC-like Structure:
– Although not a formal MVC, the project naturally divides into view (FXMLs), controllers, and the underlying processing logic, simplifying maintenance and scalability.
- Modular Image Processing:
– The numerous classes in the img subpackage illustrate a modular approach to handling various image formats and properties, making the component extensible.
- Use of Gradle:
– The presence of build.gradle, gradle wrapper files, and accompanying batch/shell scripts signals that build and dependency management are handled by Gradle.

##### Summary of Detailed Components
- Clear labels for each architectural module:
– JavaFX UI (FXML: l2tool.fxml, view.fxml)
– Controllers (Controller.java, TextureView.java)
– Core Business Logic (L2Tool.java, L2ToolCmd.java)
– Image Processing (classes like DDS.java, TGA.java, Palette.java, etc.)
– Texture Conversion (ConvertTool.java)
– Data flow from UI to Controllers
– Command and process delegation from Controllers to Business Logic
– Processing requests to Image Modules and back
– Presentation layer, business logic, and processing modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI1["l2tool.fxml"]:::ui
        UI2["view.fxml"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        CTRL1["Controller.java"]:::controller
        CTRL2["TextureView.java"]:::controller
    end

    %% Business Logic & Command Processing
    subgraph "Business Logic & Command Processing"
        BL1["L2Tool.java"]:::logic
        BL2["L2ToolCmd.java"]:::logic
    end

    %% Image Processing Module
    subgraph "Image Processing Module"
        IMG1["img Module"]:::imageProcessing
    end

    %% Texture Conversion Module
    subgraph "Texture Conversion Module"
        TX1["ConvertTool.java"]:::texconv
    end

    %% Connections: UI -> Controller
    UI1 -->|"user_action"| CTRL1
    UI2 -->|"user_action"| CTRL2

    %% Connections: Controller -> Business Logic
    CTRL1 -->|"command_calls"| BL1
    CTRL2 -->|"command_calls"| BL2

    %% Connections: Business Logic -> Processing Modules
    BL1 -->|"image_processing"| IMG1
    BL2 -->|"image_processing"| IMG1
    BL1 -->|"texture_conversion"| TX1
    BL2 -->|"texture_conversion"| TX1

    %% Return flows: Processing Modules -> UI
    IMG1 -->|"result_data"| UI1
    TX1 -->|"result_data"| UI2

    %% Click Events
    click UI1 "https://github.com/acmi/l2tool/blob/master/src/main/resources/acmi/l2/clientmod/l2tool/l2tool.fxml"
    click UI2 "https://github.com/acmi/l2tool/blob/master/src/main/resources/acmi/l2/clientmod/l2tool/textureview/view.fxml"
    click CTRL1 "https://github.com/acmi/l2tool/blob/master/src/main/java/acmi/l2/clientmod/l2tool/Controller.java"
    click CTRL2 "https://github.com/acmi/l2tool/blob/master/src/main/java/acmi/l2/clientmod/l2tool/textureview/TextureView.java"
    click BL1 "https://github.com/acmi/l2tool/blob/master/src/main/java/acmi/l2/clientmod/l2tool/L2Tool.java"
    click BL2 "https://github.com/acmi/l2tool/blob/master/src/main/java/acmi/l2/clientmod/l2tool/L2ToolCmd.java"
    click IMG1 "https://github.com/acmi/l2tool/tree/master/src/main/java/acmi/l2/clientmod/l2tool/img"
    click TX1 "https://github.com/acmi/l2tool/blob/master/src/main/java/acmi/l2/clientmod/texconv/ConvertTool.java"

    %% Styles
    classDef ui fill:#1f77b4,stroke:#333,stroke-width:2px,color:#fff;
    classDef controller fill:#ff7f0e,stroke:#333,stroke-width:2px,color:#fff;
    classDef logic fill:#2ca02c,stroke:#333,stroke-width:2px,color:#fff;
    classDef imageProcessing fill:#d62728,stroke:#333,stroke-width:2px,color:#fff;
    classDef texconv fill:#9467bd,stroke:#333,stroke-width:2px,color:#fff;
```
