Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.demcha.compose.document.api.DocumentPageSize;
import com.demcha.compose.document.api.DocumentSession;
import com.demcha.compose.document.templates.builtins.InvoiceTemplateV1;
import com.demcha.compose.document.templates.builtins.ProposalTemplateV1;
import com.demcha.compose.document.templates.api.DocumentTemplate;
import com.demcha.compose.document.templates.data.invoice.InvoiceDocumentSpec;
import com.demcha.compose.document.templates.data.proposal.ProposalDocumentSpec;
import com.demcha.compose.document.templates.invoice.v2.presets.ModernInvoice;
import com.demcha.compose.document.templates.proposal.v2.presets.ModernProposal;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -46,9 +47,9 @@ public static void main(String[] args) throws Exception {
enableAllocationMeasurement();

InvoiceDocumentSpec invoice = CanonicalBenchmarkSupport.canonicalInvoice();
InvoiceTemplateV1 invoiceTemplate = new InvoiceTemplateV1();
DocumentTemplate<InvoiceDocumentSpec> invoiceTemplate = ModernInvoice.create();
ProposalDocumentSpec proposal = CanonicalBenchmarkSupport.canonicalProposal();
ProposalTemplateV1 proposalTemplate = new ProposalTemplateV1();
DocumentTemplate<ProposalDocumentSpec> proposalTemplate = ModernProposal.create();

System.out.println("GraphCompose allocation-rate / GC-pressure probe (" + MEASURE + " warm renders each)");
System.out.printf("%-12s | %14s | %10s | %12s | %12s%n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import com.demcha.compose.document.style.DocumentTextStyle;
import com.demcha.compose.document.svg.SvgIcon;
import com.demcha.compose.document.templates.api.DocumentTemplate;
import com.demcha.compose.document.templates.builtins.InvoiceTemplateV1;
import com.demcha.compose.document.templates.builtins.ProposalTemplateV1;
import com.demcha.compose.document.templates.cv.presets.ModernProfessional;
import com.demcha.compose.document.templates.cv.spec.CvSpec;
import com.demcha.compose.document.templates.data.invoice.InvoiceDocumentSpec;
import com.demcha.compose.document.templates.data.proposal.ProposalDocumentSpec;
import com.demcha.compose.document.templates.invoice.v2.presets.ModernInvoice;
import com.demcha.compose.document.templates.proposal.v2.presets.ModernProposal;
import com.demcha.compose.document.theme.BusinessTheme;
import com.demcha.compose.engine.components.style.Margin;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
Expand Down Expand Up @@ -85,9 +85,9 @@ public final class CurrentSpeedBenchmark {
.color(DocumentColor.of(new Color(58, 69, 84)))
.build();

private final InvoiceTemplateV1 invoiceTemplate = new InvoiceTemplateV1();
private final DocumentTemplate<InvoiceDocumentSpec> invoiceTemplate = ModernInvoice.create();
private final DocumentTemplate<CvSpec> cvTemplate = ModernProfessional.create(BusinessTheme.modern());
private final ProposalTemplateV1 proposalTemplate = new ProposalTemplateV1();
private final DocumentTemplate<ProposalDocumentSpec> proposalTemplate = ModernProposal.create();
private final InvoiceDocumentSpec invoice = CanonicalBenchmarkSupport.canonicalInvoice();
private final ProposalDocumentSpec proposal = CanonicalBenchmarkSupport.canonicalProposal();
private final CvSpec cv = CanonicalBenchmarkSupport.canonicalCv();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import com.demcha.compose.document.api.DocumentPageSize;
import com.demcha.compose.document.api.DocumentSession;
import com.demcha.compose.document.style.DocumentInsets;
import com.demcha.compose.document.templates.builtins.InvoiceTemplateV1;
import com.demcha.compose.document.templates.cv.presets.ModernProfessional;
import com.demcha.compose.document.templates.cv.spec.CvSpec;
import com.demcha.compose.document.templates.data.invoice.InvoiceDocumentSpec;
import com.demcha.compose.document.templates.invoice.v2.presets.ModernInvoice;
import com.demcha.compose.document.theme.BusinessTheme;
import com.demcha.compose.document.templates.api.DocumentTemplate;
import org.openjdk.jmh.annotations.Benchmark;
Expand Down Expand Up @@ -37,7 +37,7 @@
* reported number is a distribution of cold first-renders, not one lucky start.
* The spec/template objects are built in {@link #setUp()} so the measured shot is
* the cold render path, not fixture assembly. Same workloads as the warm benches
* ({@code engine-simple} inline, {@code InvoiceTemplateV1}, {@code ModernProfessional})
* ({@code engine-simple} inline, {@code ModernInvoice}, {@code ModernProfessional})
* so cold and warm numbers are directly comparable.</p>
*
* <pre>
Expand All @@ -56,15 +56,15 @@
public class ColdStartJmhBenchmark {

private InvoiceDocumentSpec invoice;
private InvoiceTemplateV1 invoiceTemplate;
private DocumentTemplate<InvoiceDocumentSpec> invoiceTemplate;
private CvSpec cv;
private DocumentTemplate<CvSpec> cvTemplate;

/** Builds the specs and templates once per fork, outside the measured cold shot. */
@Setup
public void setUp() {
invoice = CanonicalBenchmarkSupport.canonicalInvoice();
invoiceTemplate = new InvoiceTemplateV1();
invoiceTemplate = ModernInvoice.create();
cv = CanonicalBenchmarkSupport.canonicalCv();
cvTemplate = ModernProfessional.create(BusinessTheme.modern());
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public byte[] coldEngineSimple() throws Exception {
}

/**
* Cold first render of the canonical invoice through {@code InvoiceTemplateV1}.
* Cold first render of the canonical invoice through {@code ModernInvoice}.
*
* @return the rendered PDF bytes (consumed by JMH)
* @throws Exception if rendering fails
Expand Down
43 changes: 1 addition & 42 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ are with the canonical DSL, then jump to its detailed section below.

| Example | What it shows | Preview · Source |
|---|---|---|
| [Invoice (V1)](#invoice-v1) | `InvoiceTemplateV1` driven from `InvoiceDocumentSpec` — pre-rebuild surface, supported only | [PDF](../assets/readme/examples/invoice.pdf) · [Source](src/main/java/com/demcha/examples/templates/invoice/InvoiceFileExample.java) |
| [Proposal (V1)](#proposal-v1) | `ProposalTemplateV1` driven from `ProposalDocumentSpec` — pre-rebuild surface, supported only | [PDF](../assets/readme/examples/proposal.pdf) · [Source](src/main/java/com/demcha/examples/templates/proposal/ProposalFileExample.java) |
| [Handcrafted Proposal](#handcrafted-proposal) | v1.4-style cinematic proposal composed by hand — pre-template authoring; kept for parity reference | [PDF](../assets/readme/examples/project-proposal-cinematic.pdf) · [Source](src/main/java/com/demcha/examples/templates/proposal/CinematicProposalFileExample.java) |
| [Weekly schedule](#weekly-schedule) | Bar / restaurant shift schedule via `WeeklyScheduleRenderer` (`WeeklyScheduleTemplateV1` — no V2 yet; will be re-shaped before 2.0) | [PDF](../assets/readme/examples/weekly-schedule.pdf) · [Source](src/main/java/com/demcha/examples/templates/schedule/WeeklyScheduleFileExample.java) |
| [Weekly schedule](#weekly-schedule) | Bar / restaurant shift schedule via `WeeklyScheduleRenderer` | [PDF](../assets/readme/examples/weekly-schedule.pdf) · [Source](src/main/java/com/demcha/examples/templates/schedule/WeeklyScheduleFileExample.java) |

---

Expand Down Expand Up @@ -177,45 +175,6 @@ try (DocumentSession document = GraphCompose.document(outputFile)
[📄 View PDF](../assets/readme/examples/cover-letter.pdf) ·
[📜 Full source](src/main/java/com/demcha/examples/templates/coverletter/CoverLetterFileExample.java)

### Invoice (V1)

`InvoiceTemplateV1.compose(document, spec)` handles the full layout —
header band, parties row, line-items table, totals row, payment-terms
footer — driven from a `InvoiceDocumentSpec`. Use this when you want
the legacy hard-coded theme; for V2 cinematic, see below.

```java
InvoiceDocumentSpec spec = InvoiceDocumentSpec.builder()
.invoiceNumber("GC-2026-041")
.issueDate("02 Apr 2026")
.dueDate("16 Apr 2026")
.fromParty(p -> p.name("GraphCompose Studio"))
.billToParty(p -> p.name("Northwind Systems"))
.lineItem("Template architecture", "Reusable invoice flow", "2", "GBP 980", "GBP 1,960")
.totalRow("Total", "GBP 1,960")
.build();

try (DocumentSession document = GraphCompose.document(outputFile)
.pageSize(DocumentPageSize.A4)
.margin(28, 28, 28, 28)
.create()) {
new InvoiceTemplateV1().compose(document, spec);
document.buildPdf();
}
```

[📄 View PDF](../assets/readme/examples/invoice.pdf) ·
[📜 Full source](src/main/java/com/demcha/examples/templates/invoice/InvoiceFileExample.java)

### Proposal (V1)

`ProposalTemplateV1` rendered against a `ProposalDocumentSpec` —
sections, scope items, deliverables, sign-off. Pairs naturally with
`InvoiceTemplateV1` for consistent "spec → PDF" pipelines.

[📄 View PDF](../assets/readme/examples/proposal.pdf) ·
[📜 Full source](src/main/java/com/demcha/examples/templates/proposal/ProposalFileExample.java)

### Module-first profile

Authoring against `DocumentSession.pageFlow().module(...)` — no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@
import com.demcha.examples.templates.cv.v2.CvSidebarPortraitExample;
import com.demcha.examples.templates.cv.v2.CvTimelineMinimalExample;
import com.demcha.examples.templates.invoice.InvoiceCinematicFileExample;
import com.demcha.examples.templates.invoice.InvoiceFileExample;
import com.demcha.examples.templates.invoice.v2.ModernInvoiceV2Example;
import com.demcha.examples.templates.proposal.CinematicProposalFileExample;
import com.demcha.examples.templates.proposal.ProposalCinematicFileExample;
import com.demcha.examples.templates.proposal.v2.ModernProposalV2Example;
import com.demcha.examples.templates.proposal.ProposalFileExample;
import com.demcha.examples.templates.schedule.WeeklyScheduleFileExample;

/**
Expand Down Expand Up @@ -138,12 +136,10 @@ public static void main(String[] args) throws Exception {
System.out.println("Generated: " + CvTimelineMinimalLetterV2Example.generate());

// Invoices
System.out.println("Generated: " + InvoiceFileExample.generate());
System.out.println("Generated: " + InvoiceCinematicFileExample.generate());
System.out.println("Generated: " + ModernInvoiceV2Example.generate());

// Proposals
System.out.println("Generated: " + ProposalFileExample.generate());
System.out.println("Generated: " + ProposalCinematicFileExample.generate());
System.out.println("Generated: " + ModernProposalV2Example.generate());
System.out.println("Generated: " + CinematicProposalFileExample.generate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ record Entry(String title, String description, List<String> tags, String codeUrl
letter("cover-letter-mint-editorial-v2", "CvMintEditorialLetterV2Example", "Mint Editorial letter", "Letter paired with Mint Editorial CV — magazine-style mint accent.");

// ===== Templates / Invoice =====
invoice("invoice", "Invoice (canonical)", "Single-page invoice with line items, totals, and structured chrome — InvoiceTemplateV1.", "invoice");
invoice("invoice-cinematic", "Cinematic Invoice", "Polished V2 invoice template with theme-driven layout, advanced tables, and totals.", "invoice", "cinematic");

// ===== Templates / Proposal =====
proposal("proposal", "Proposal (canonical)", "Multi-section proposal with cover, scope, deliverables, and pricing — ProposalTemplateV1.", "proposal");
proposal("proposal-cinematic", "Cinematic Proposal", "Cinematic V2 proposal layout with cover panel, hero spread, and rich typography.", "proposal", "cinematic");
proposal("project-proposal-cinematic", "Project Proposal (cinematic)", "End-to-end project proposal with mountain hero, scope panels, and pricing summary.", "proposal", "cinematic");

Expand Down Expand Up @@ -183,16 +181,13 @@ private static void letter(String id, String exampleClass, String title, String
}

private static void invoice(String id, String title, String desc, String... tags) {
String file = id.contains("cinematic") ? "InvoiceCinematicFileExample" : "InvoiceFileExample";
ENTRIES.put(id, entry(title, desc, withCategory("invoice", tags),
EX_BASE + "/templates/invoice/" + file + ".java"));
EX_BASE + "/templates/invoice/InvoiceCinematicFileExample.java"));
}

private static void proposal(String id, String title, String desc, String... tags) {
String file;
if (id.equals("project-proposal-cinematic")) file = "CinematicProposalFileExample";
else if (id.contains("cinematic")) file = "ProposalCinematicFileExample";
else file = "ProposalFileExample";
String file = id.equals("project-proposal-cinematic")
? "CinematicProposalFileExample" : "ProposalCinematicFileExample";
ENTRIES.put(id, entry(title, desc, withCategory("proposal", tags),
EX_BASE + "/templates/proposal/" + file + ".java"));
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* {@link DocumentSession}.</p>
*
* <pre>{@code
* InvoiceTemplate template = new InvoiceTemplateV1();
* InvoiceTemplate template = new InvoiceTemplateV2();
* InvoiceDocumentSpec invoice = InvoiceDocumentSpec.builder()
* .invoiceNumber("GC-2026-041")
* .fromParty(party -> party.name("GraphCompose Studio"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* {@link DocumentSession}.</p>
*
* <pre>{@code
* ProposalTemplate template = new ProposalTemplateV1();
* ProposalTemplate template = new ProposalTemplateV2();
* ProposalDocumentSpec proposal = ProposalDocumentSpec.builder()
* .projectTitle("GraphCompose rollout")
* .section("Scope", "Introduce reusable invoice and proposal templates.")
Expand Down

This file was deleted.

Loading
Loading