# rambaut/figtree architecture

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

- Interactive diagram: https://gitdiagram.com/rambaut/figtree
- Repository: https://github.com/rambaut/figtree

## Overview

##### Main Components

a. Core Application Layer:
- Main Application (FigTreeApplication.java)
- Application Frame (FigTreeFrame.java)
- Menu System (FigTreeMenuBarFactory.java)

b. Tree Visualization Layer:
- Tree Viewer Components
- Tree Pane
- Multiple Viewers Support
- Layout Engines

c. Data Management Layer:
- Tree Data Models
- Import/Export Handlers
- File Format Support

d. UI Components:
- Control Panels
- Preference Managers
- Dialog Systems

##### Architectural Patterns to Highlight

a. MVC (Model-View-Controller) Pattern:
- Models: Tree data structures
- Views: TreePane, TreeViewer implementations
- Controllers: Various *Controller classes

b. Observer Pattern:
- Listener interfaces for tree updates
- Event handling system

**[User Interface Layer]**

- Application Frame
- Menu System
- Toolbar

- [Visualization Layer]
- Tree Viewers
- Single Tree View
- Multi-Pane View

- Tree Layouts
- Polar
- Radial
- Rectilinear

- Painters
- Node Painters
- Scale Painters

- [Control Layer]
- Tree Controllers
- Layout Controllers
- Appearance Controllers

- [Data Layer]
- File I/O
- Importers
- Exporters

- Data Models
- Tree Structures

##### Key Relationships

- Event flow paths between components
- Data flow between I/O components and data models

##### Important Implementation Details

- Support for multiple tree layouts
- Plugin architecture for different tree formats
- Separation between tree data and visualization
- Integration with external tools (BEAST)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph UI["User Interface Layer"]
        AppFrame["Application Frame"]
        MenuSys["Menu System"]
        Toolbar["Toolbar"]
        AppFrame --> MenuSys
        AppFrame --> Toolbar
    end

    subgraph VIS["Visualization Layer"]
        TreeView["Tree Viewers"]
        Layouts["Tree Layouts"]
        Paint["Painters"]

        subgraph ViewTypes["Viewer Types"]
            SingleView["Single Tree View"]
            MultiView["Multi-Pane View"]
        end

        subgraph LayoutTypes["Layout Types"]
            Polar["Polar Layout"]
            Radial["Radial Layout"]
            Recti["Rectilinear Layout"]
        end

        subgraph PaintTypes["Painter Types"]
            NodeP["Node Painter"]
            LabelP["Label Painter"]
            ScaleP["Scale Bar Painter"]
        end

        TreeView --> ViewTypes
        Layouts --> LayoutTypes
        Paint --> PaintTypes
    end

    subgraph CTRL["Control Layer"]
        TreeCtrl["Tree Controllers"]
        LayoutCtrl["Layout Controllers"]
        AppCtrl["Appearance Controllers"]
        Prefs["Preferences"]
        CtrlPalette["Control Palette"]
    end

    subgraph DATA["Data Layer"]
        FileIO["File I/O"]
        DataModels["Data Models"]

        subgraph IO["I/O Handlers"]
            Import["Importers"]
            Export["Exporters"]
            JSONExp["JSON Export"]
        end

        FileIO --> IO
        DataModels --> TreeStruct["Tree Structures"]
    end

    %% Inter-layer relationships
    UI --> VIS
    UI --> CTRL
    VIS --> DATA
    CTRL --> VIS
    CTRL --> DATA

    %% Style definitions
    classDef ui fill:#a8d1f0
    classDef vis fill:#90EE90
    classDef ctrl fill:#FFE5B4
    classDef data fill:#FFA07A

    %% Apply styles
    class AppFrame,MenuSys,Toolbar ui
    class TreeView,Layouts,Paint,ViewTypes,LayoutTypes,PaintTypes,SingleView,MultiView,Polar,Radial,Recti,NodeP,LabelP,ScaleP vis
    class TreeCtrl,LayoutCtrl,AppCtrl,Prefs,CtrlPalette ctrl
    class FileIO,DataModels,IO,Import,Export,JSONExp,TreeStruct data

    %% Click events
    click AppFrame "https://github.com/rambaut/figtree/blob/master/src/figtree/application/FigTreeFrame.java"
    click MenuSys "https://github.com/rambaut/figtree/blob/master/src/figtree/application/FigTreeMenuBarFactory.java"
    click Polar "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/treelayouts/PolarTreeLayout.java"
    click Radial "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/treelayouts/RadialTreeLayout.java"
    click Recti "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/treelayouts/RectilinearTreeLayout.java"
    click Import "https://github.com/rambaut/figtree/blob/master/src/figtree/application/FigTreeNexusImporter.java"
    click Export "https://github.com/rambaut/figtree/blob/master/src/figtree/application/FigTreeNexusExporter.java"
    click JSONExp "https://github.com/rambaut/figtree/blob/master/src/figtree/application/JSONTreeExporter.java"
    click CtrlPalette "https://github.com/rambaut/figtree/blob/master/src/figtree/panel/SimpleControlPalette.java"
    click Prefs "https://github.com/rambaut/figtree/tree/master/src/figtree/application/preferences"
    click TreeCtrl "https://github.com/rambaut/figtree/blob/master/src/figtree/panel/TreeViewerController.java"
    click LayoutCtrl "https://github.com/rambaut/figtree/blob/master/src/figtree/panel/TreeLayoutController.java"
    click AppCtrl "https://github.com/rambaut/figtree/blob/master/src/figtree/panel/TreeAppearanceController.java"
    click NodeP "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/painters/NodePainter.java"
    click LabelP "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/painters/LabelPainter.java"
    click ScaleP "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/painters/ScaleBarPainter.java"
    click TreeView "https://github.com/rambaut/figtree/blob/master/src/figtree/treeviewer/TreeViewer.java"

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        VIS_L["Visualization"]:::vis
        CTRL_L["Control"]:::ctrl
        DATA_L["Data"]:::data
    end
```
