# fergmlx/libreria-formato-latex architecture

> Architecture diagram of the GitHub repository fergmlx/libreria-formato-latex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fergmlx/libreria-formato-latex
- Repository: https://github.com/fergmlx/libreria-formato-latex

## Overview

##### Project type and purpose
- This is an open-source Java library (“librería”) named **FormatoLatex** that provides a LaTeX rendering utility for Swing applications.

##### File structure
- Top level:
- `libreriaFormatoLatex/` – the NetBeans library project containing source (`src/formatolatex/FormatoLatex.java`), build scripts, and nbproject metadata.
- `implementacion/` – a sample NetBeans Swing application (“Prueba”) that uses the library. Contains `src/prueba/Prueba.java` and UI forms (`.form`).
- `documentacion/` – generated Javadoc HTML site for the library.
- `FormatoLaTeX.jar` – the built library artifact.
- Key patterns:
- Single utility class with only static methods (no instantiation).
- Dependency on external JLaTeXMath JAR.
- Swing as the presentation layer.
- File I/O for PNG export.

##### README for additional insights
- The README outlines:
- Core methods (renderizarFormula, crearMathTex, mostrarFormulaEnVentana, etc.)
- Integration steps (add JARs to classpath)
- Use cases (educational apps, scientific tools)
- Architectural notes: static utility class, no instance state, clean-code principles.

a. Main components
1. **Client Application** (e.g., `implementacion.Prueba`)
2. **FormatoLatex Library** (static API layer)
3. **JLaTeXMath Engine** (external dependency)
4. **Swing UI Layer** (JLabel, JFrame windows)
5. **File System** (for reading/writing PNGs)

b. Relationships and interactions
- The *Client Application* invokes static methods on the **FormatoLatex Library**.
- The library delegates formula parsing and typesetting to the **JLaTeXMath Engine**.
- JLaTeXMath produces a `TeXIcon` or a `BufferedImage`.

c. Architectural patterns & principles
- **Utility Pattern**: single final class, all-static methods, no instances.
- **Facade Pattern**: the library acts as a façade over JLaTeXMath.
- **Separation of Concerns**:
- Parsing & typesetting → JLaTeXMath
- Rendering API → FormatoLatex
- Presentation → Swing components
- I/O → Java File/BufferedImage APIs

d. Key technologies & libraries
- Java SE (AWT/Swing)
- JLaTeXMath (org.scilab.forge.jlatexmath)
- BufferedImage & Java2D (`TYPE_INT_ARGB`)
- NetBeans build scripts (Ant: build.xml)

##### Detailed capture of essential elements
- `renderizarFormula(...)`
- `crearMathTex(...)`, `establecerMathTex(...)`
- `mostrarFormulaEnVentana(...)`, `mostrarMatrizVentana(...)`
- Configuration constants (TeXConstants, Insets) as side-notes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Sample Client Application" 
        direction TB
        PruebaJava["Prueba.java"]:::blue
        PruebaForm["Prueba.form"]:::blue
        SampleLibJar["FormatoLaTeX.jar"]:::blue
        ClientBuild["build.xml"]:::blue
        ClientMeta["nbproject/"]:::blue
    end

    subgraph "FormatoLatex Library" 
        direction TB
        FormatoLatexNode["FormatoLatex.java\n- renderizarFormula()\n- crearMathTex()\n- mostrarFormulaEnVentana()"]:::blue
        LibBuild["build.xml"]:::blue
        LibMeta["nbproject/"]:::blue
    end

    JLaTeXMath["JLaTeXMath Engine"]:::external
    SwingUI["Swing UI (JLabel, JFrame)"]:::presentation
    Filesystem["File System (PNG output)"]:::filesystem
    Documentation["Javadoc Documentation"]:::blue

    PruebaJava -->|uses API| FormatoLatexNode
    FormatoLatexNode -->|delegates typeset| JLaTeXMath
    JLaTeXMath -->|returns icon/image| FormatoLatexNode
    FormatoLatexNode -->|provides Icon| SwingUI
    FormatoLatexNode -->|writes PNG| Filesystem
    PruebaForm -.->|UI design| SwingUI
    SampleLibJar -->|library on classpath| FormatoLatexNode
    Documentation -.->|docs for API| FormatoLatexNode
    ClientBuild -.-> PruebaJava
    ClientMeta -.-> PruebaJava
    LibBuild -.-> FormatoLatexNode
    LibMeta -.-> FormatoLatexNode

    classDef blue fill:#D0E6FF,stroke:#005A9C,color:#000
    classDef external fill:#DFFFE0,stroke:#2D7A00,color:#000
    classDef presentation fill:#FFF4CC,stroke:#A67C00,color:#000
    classDef filesystem fill:#E0E0E0,stroke:#7A7A7A,color:#000

    click PruebaJava "https://github.com/fergmlx/libreria-formato-latex/blob/main/implementacion/src/prueba/Prueba.java"
    click PruebaForm "https://github.com/fergmlx/libreria-formato-latex/blob/main/implementacion/src/prueba/Prueba.form"
    click FormatoLatexNode "https://github.com/fergmlx/libreria-formato-latex/blob/main/libreriaFormatoLatex/src/formatolatex/FormatoLatex.java"
    click SampleLibJar "https://github.com/fergmlx/libreria-formato-latex/blob/main/implementacion/lib/FormatoLaTeX.jar"
    click Documentation "https://github.com/fergmlx/libreria-formato-latex/tree/main/documentacion/"
    click LibBuild "https://github.com/fergmlx/libreria-formato-latex/blob/main/libreriaFormatoLatex/build.xml"
    click LibMeta "https://github.com/fergmlx/libreria-formato-latex/tree/main/libreriaFormatoLatex/nbproject/"
    click ClientBuild "https://github.com/fergmlx/libreria-formato-latex/blob/main/implementacion/build.xml"
    click ClientMeta "https://github.com/fergmlx/libreria-formato-latex/tree/main/implementacion/nbproject/"
```
