diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..7d6f27a14 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.java text=auto diff --git a/.github/labeler.yml b/.github/labeler.yml index 4f260b7ec..3924b988d 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,37 +1,55 @@ 'm:release': -- 'CHANGELOG.md' -- 'gradle.properties' +- changed-files: + - any-glob-to-any-file: + - 'CHANGELOG.md' + - 'gradle.properties' 'm:docs': -- '*.md' -- 'docs/**/*' +- changed-files: + - any-glob-to-any-file: + - '*.md' + - 'docs/**/*' 'm:workflow': -- .github/** +- changed-files: + - any-glob-to-any-file: + - .github/** 'm:gradle': -- 'gradle*' -- 'gradle/**' -- '**/settings.gradle.*' -- '**/build.gradle.*' -- 'sjpp.jar' +- changed-files: + - any-glob-to-any-file: + - 'gradle*' + - 'gradle/**' + - '**/settings.gradle.*' + - '**/build.gradle.*' + - 'sjpp.jar' 'm:source': -- 'skin/**/*' -- 'src/**/*' -- 'stdlib/**/*' -- 'svg/**/*' -- 'themes/**/*' -- 'manifest.txt' +- changed-files: + - any-glob-to-any-file: + - 'skin/**/*' + - 'src/**/*' + - 'stdlib/**/*' + - 'svg/**/*' + - 'themes/**/*' + - 'manifest.txt' 'm:test': -- 'test/**/*' +- changed-files: + - any-glob-to-any-file: + - 'test/**/*' 'm:license': -- '**/*license.txt' +- changed-files: + - any-glob-to-any-file: + - '**/*license.txt' 'm:docker': -- Dockerfile +- changed-files: + - any-glob-to-any-file: + - Dockerfile 'm:native': -- .github/workflows/native-image.yml +- changed-files: + - any-glob-to-any-file: + - .github/workflows/native-image.yml diff --git a/.github/workflows/add-triage-label.yml b/.github/workflows/add-triage-label.yml index 56da33e00..c98272529 100644 --- a/.github/workflows/add-triage-label.yml +++ b/.github/workflows/add-triage-label.yml @@ -12,7 +12,7 @@ jobs: permissions: issues: write steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: script: | github.rest.issues.addLabels({ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bc3effb2..7b685a9f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,7 +99,7 @@ jobs: - name: Set up java if: needs.workflow_config.outputs.do_test_linux == 'true' - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java_version }} distribution: temurin @@ -115,7 +115,7 @@ jobs: run: gradle test --no-daemon -i - name: Upload test reports - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: needs.workflow_config.outputs.do_test_linux == 'true' with: # Using github.run_number here to reduce confusion when downloading & comparing from several builds @@ -132,7 +132,7 @@ jobs: - name: Checkout the repository uses: actions/checkout@v4 - name: Set up java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin @@ -172,7 +172,7 @@ jobs: run: | echo "release_version=$(gradle properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_OUTPUT - name: Cache libs - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | build/libs @@ -195,7 +195,7 @@ jobs: uses: actions/checkout@v4 - name: Set up java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin @@ -221,14 +221,14 @@ jobs: uses: actions/checkout@v4 - name: Set up java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin cache: gradle - name: Restore Libs cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | build/libs @@ -244,7 +244,7 @@ jobs: enableCrossOsArchive: true - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: # Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds name: ${{ github.run_number }}-artifacts diff --git a/.github/workflows/close-and-put-in-backlog.yml b/.github/workflows/close-and-put-in-backlog.yml index 26afa923d..91ad3c50d 100644 --- a/.github/workflows/close-and-put-in-backlog.yml +++ b/.github/workflows/close-and-put-in-backlog.yml @@ -7,7 +7,7 @@ jobs: if: github.event.label.name == 'p:backlog' runs-on: ubuntu-latest steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: script: | const welcomeMessage = ` diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 07b21837d..2a340279e 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,4 +9,4 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 diff --git a/.github/workflows/native-image.yml b/.github/workflows/native-image.yml index de3990925..7db154b09 100644 --- a/.github/workflows/native-image.yml +++ b/.github/workflows/native-image.yml @@ -32,7 +32,7 @@ jobs: components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/cache/restore@v3 + - uses: actions/cache/restore@v4 with: path: | build/libs @@ -57,7 +57,7 @@ jobs: native-image -H:ConfigurationFileDirectories=native-image-config-dir --no-fallback --report-unsupported-elements-at-runtime -jar "build/libs/plantuml-${{ inputs.release-version }}.jar" -H:Path="build/libs" -H:Name="plantuml-${{ matrix.platform }}-${{ inputs.release-version }}" - name: Cache native image - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: "build/libs/plantuml-${{ matrix.platform }}-*" key: "native-image-${{ matrix.platform }}-${{ github.run_id }}" diff --git a/.gitignore b/.gitignore index 73ddb5bb8..da13ed288 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ out #vscode files -/bin +**/bin/ # Ant result file plantuml.jar diff --git a/BUILDING.md b/BUILDING.md index 3c436bdb5..be2856729 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -2,7 +2,7 @@ Thank you for your interest in contributing to PlantUML! This guide will help you build the PlantUML project. -PlantUML can be built using either [Gradle](#building-plantuml-with-gradle) or [Ant](#building-plantuml-with-ant-alternative-method). It's recommended to use Gradle as the primary build tool for this project. You will find instructions for both methods, starting with Gradle. +PlantUML can be built using either [Gradle](#-building-plantuml-with-gradle) or [Ant](#-building-plantuml-with-ant-alternative-method). It's recommended to use Gradle as the primary build tool for this project. You will find instructions for both methods, starting with Gradle. ## ☕ Java Compatibility and Development Notes diff --git a/README.md b/README.md index 94a914390..ed53dcb1e 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ PlantUML is a component that allows you to create various UML diagrams through s - [SDL (Specification and Description Language)](http://plantuml.com/activity-diagram-beta#sdl) - [Ditaa diagram](http://plantuml.com/ditaa) - [Gantt diagram](http://plantuml.com/gantt-diagram) + - [Chronology diagram](http://plantuml.com/chronology-diagram) - [MindMap diagram](http://plantuml.com/mindmap-diagram) - [WBS (Work Breakdown Structure)](http://plantuml.com/wbs-diagram) - [Mathematical Notations (AsciiMath, JLaTeXMath)](http://plantuml.com/ascii-math) diff --git a/build.gradle.kts b/build.gradle.kts index 72fb2d760..6b79adc39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,8 +31,9 @@ dependencies { compileOnly("org.apache.ant:ant:1.10.14") testImplementation("io.github.glytching:junit-extensions:2.6.0") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") if (JavaVersion.current().isJava8) { testImplementation("org.mockito:mockito-core:4.+") testImplementation("org.mockito:mockito-junit-jupiter:4.+") diff --git a/docs/PACKAGE_AND_DISTRIBUTION.md b/docs/PACKAGE_AND_DISTRIBUTION.md new file mode 100644 index 000000000..c1266219c --- /dev/null +++ b/docs/PACKAGE_AND_DISTRIBUTION.md @@ -0,0 +1,97 @@ +# PlantUML packages and PlantUML on the _[most popular]_ GNU/Linux distributions + +## PlantUML packages + +### GitHub _(The main PlantUML package repository)_ +[![GitHub Release](https://img.shields.io/github/v/release/plantuml/plantuml)](https://github.com/plantuml/plantuml/releases/latest) + +### Chocolatey +[![Chocolatey Version](https://img.shields.io/chocolatey/v/plantuml)](https://community.chocolatey.org/packages/plantuml) + +### Docker +[![Docker Image Version](https://img.shields.io/docker/v/plantuml/plantuml)](https://github.com/plantuml/plantuml/pkgs/container/plantuml) + +### Homebrew +[![homebrew version](https://img.shields.io/homebrew/v/plantuml)](https://formulae.brew.sh/formula/plantuml) + +### Maven +[![Maven Central Version](https://img.shields.io/maven-central/v/net.sourceforge.plantuml/plantuml)](https://mvnrepository.com/artifact/net.sourceforge.plantuml/plantuml) + +### Scoop +[![Scoop Version](https://img.shields.io/scoop/v/plantuml?bucket=extras)](https://scoop.sh/#/apps?q=plantuml) + + + +## PlantUML on the _[most popular]_ GNU/Linux distributions + +### [Alpine Linux](https://www.alpinelinux.org) +| Type | Link | +| ------- | ---- | +| Distribution | ![Alpine Linux](https://img.shields.io/badge/Alpine_Linux-%230D597F.svg?style=for-the-badge&logo=alpine-linux&logoColor=white) | +| Last PlantUML version | | +| Link | https://pkgs.alpinelinux.org/packages?name=plantuml&branch=edge | +| Specificity | | + +### [Archlinux](https://archlinux.org) +| Type | Link | +| ------- | ---- | +| Distribution | ![Arch](https://img.shields.io/badge/Arch%20Linux-1793D1?logo=arch-linux&logoColor=fff&style=for-the-badge) | +| Last PlantUML version | [![Arch Linux package](https://img.shields.io/archlinux/v/extra/any/plantuml)](https://archlinux.org/packages/extra/any/plantuml/) | +| Link | https://archlinux.org/packages/extra/any/plantuml/ | +| Specificity | | + +### [Debian](https://www.debian.org) +| Type | Link | +| ------- | ---- | +| Distribution | ![Debian](https://img.shields.io/badge/Debian-D70A53?style=for-the-badge&logo=debian&logoColor=white) | +| Last PlantUML version | [![Debian package](https://img.shields.io/debian/v/plantuml)](https://salsa.debian.org/debian/plantuml) | +| Link | https://salsa.debian.org/debian/plantuml | +| Specificity | https://salsa.debian.org/debian/plantuml/-/tree/master/debian | + +### [Fedora](https://fedoraproject.org) +| Type | Link | +| ------- | ---- | +| Distribution | ![Fedora](https://img.shields.io/badge/Fedora-294172?style=for-the-badge&logo=fedora&logoColor=white) | +| Last PlantUML version | [![Fedora package](https://img.shields.io/fedora/v/plantuml)](https://src.fedoraproject.org/rpms/plantuml) | +| Link | https://src.fedoraproject.org/rpms/plantuml | +| Specificity | | + +### [Gentoo](https://www.gentoo.org/) +| Type | Link | +| ------- | ---- | +| Distribution | ![Gentoo](https://img.shields.io/badge/Gentoo-54487A?style=for-the-badge&logo=gentoo&logoColor=white) | +| Last PlantUML version | | +| Link | https://packages.gentoo.org/packages/media-gfx/plantuml | +| Specificity | | + +### [openSUSE](https://www.opensuse.org) +| Type | Link | +| ------- | ---- | +| Distribution | ![openSUSE](https://img.shields.io/badge/openSUSE-%2364B345?style=for-the-badge&logo=openSUSE&logoColor=white) | +| Last PlantUML version | | +| Link | https://build.opensuse.org/search?search_text=plantuml | +| Specificity | https://build.opensuse.org/package/show/Java:packages/plantuml
https://build.opensuse.org/package/show/home:mnhauke/plantuml | + +### [SUSE](https://www.suse.com) +| Type | Link | +| ------- | ---- | +| Distribution | ![Suse](https://img.shields.io/badge/SUSE-0C322C?style=for-the-badge&logo=SUSE&logoColor=white) | +| Last PlantUML version | | +| Link | https://packagehub.suse.com/packages/plantuml/ | +| Specificity | | + +### [Ubuntu](https://ubuntu.com) +| Type | Link | +| ------- | ---- | +| Distribution | ![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white) | +| Last PlantUML version | [![Ubuntu Package Version](https://img.shields.io/ubuntu/v/plantuml)](https://packages.ubuntu.com/search?keywords=plantuml&searchon=names&suite=all§ion=all) | +| Link | https://packages.ubuntu.com/search?keywords=plantuml&searchon=names&suite=all§ion=all | +| Specificity | | + + +# Reference and acknowledgement +- https://en.wikipedia.org/wiki/List_of_software_package_management_systems +- https://en.wikipedia.org/wiki/List_of_Linux_distributions +- https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/creating-a-default-community-health-file +- https://shields.io + diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 000000000..555a79f16 --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,58 @@ +# 🌱 PlantUML Support + +Thank you for using PlantUML! If you need assistance or have questions, please refer to the following resources: + +## Where to Get Support + +### GitHub Issues + +- For reporting bugs or issues, open an [issue on GitHub](https://github.com/plantuml/plantuml/issues). + - When submitting an issue, provide clear steps to reproduce the problem and include your PlantUML version. +- Before creating a new issue, search the existing ones on [GitHub](https://github.com/plantuml/plantuml/issues) to see if your problem has already been addressed. + +### Community Forum + +- Visit our [Community Forum](https://forum.plantuml.net/) for discussions, FAQs, and community support. +- Check for existing threads to see if your question has already been answered. + +### Discord + +- Feel free to ask questions on our official [Discord](https://discord.com/invite/sXhzexAQGh) server. + +## Asking Questions + +If you have a question about using PlantUML: + +- Search through the [official documentation](https://plantuml.com/) and available resources before asking. +- Feel free to ask questions on the GitHub issues or the Community Forum after performing initial research. +- Provide as much detail as possible when asking questions to receive effective assistance. + +## Contributing + +We welcome contributions to PlantUML! If you're interested in contributing: + +### Reporting Bugs + +- Ensure you're using the latest version and search for existing issues on GitHub or the Community Forum before reporting a bug. +- Submit a bug report on [GitHub](https://github.com/plantuml/plantuml/issues) with clear steps to reproduce and your environment details. + +### Suggesting Enhancements + +- Search existing enhancement suggestions on GitHub or the Community Forum before submitting a new one. +- Submit your enhancement suggestion with a clear title and detailed description on [GitHub](https://github.com/plantuml/plantuml/issues). + +### Your First Code Contribution + +- Review our [contributing guide](CONTRIBUTING.md) to get started with code contributions. +- If you're new to contributing, consider tackling issues labeled as 'good first issue' or 'help wanted'. + +## Additional Resources + +- For comprehensive documentation, refer to the [official PlantUML Javadoc](https://plantuml.github.io/plantuml/). +- Explore the [GitHub issues](https://github.com/plantuml/plantuml/issues/) for discussions and known problems. + +## 🧑‍🤝‍🧑 Community Support + +Feel free to engage with the PlantUML community on GitHub and the Community Forum. + +Thank you for being a part of the PlantUML community! diff --git a/gradle.properties b/gradle.properties index 39994fd2b..4b0a74673 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ # Warning, "version" should be the same in gradle.properties and Version.java # Any idea anyone how to magically synchronize those :-) ? -version = 1.2023.13beta1 +version = 1.2024.4beta6 org.gradle.workers.max = 3 \ No newline at end of file diff --git a/plantuml-asl/build.gradle.kts b/plantuml-asl/build.gradle.kts index 79ebca686..b4217ad15 100644 --- a/plantuml-asl/build.gradle.kts +++ b/plantuml-asl/build.gradle.kts @@ -25,9 +25,10 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") } repositories { diff --git a/plantuml-bsd/build.gradle.kts b/plantuml-bsd/build.gradle.kts index f57ec2fe1..393e7a45c 100644 --- a/plantuml-bsd/build.gradle.kts +++ b/plantuml-bsd/build.gradle.kts @@ -25,8 +25,8 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") } diff --git a/plantuml-epl/build.gradle.kts b/plantuml-epl/build.gradle.kts index 0c94e1a85..5bf7756f4 100644 --- a/plantuml-epl/build.gradle.kts +++ b/plantuml-epl/build.gradle.kts @@ -25,9 +25,10 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") } repositories { diff --git a/plantuml-gplv2/build.gradle.kts b/plantuml-gplv2/build.gradle.kts index 740d97e91..c7df0ca29 100644 --- a/plantuml-gplv2/build.gradle.kts +++ b/plantuml-gplv2/build.gradle.kts @@ -25,9 +25,10 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") } repositories { diff --git a/plantuml-lgpl/build.gradle.kts b/plantuml-lgpl/build.gradle.kts index f110030e0..667667df0 100644 --- a/plantuml-lgpl/build.gradle.kts +++ b/plantuml-lgpl/build.gradle.kts @@ -25,9 +25,10 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") } repositories { diff --git a/plantuml-mit/build.gradle.kts b/plantuml-mit/build.gradle.kts index 995be47c3..d7e2cf555 100644 --- a/plantuml-mit/build.gradle.kts +++ b/plantuml-mit/build.gradle.kts @@ -25,9 +25,10 @@ java { dependencies { compileOnly("org.apache.ant:ant:1.10.14") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.scilab.forge:jlatexmath:1.0.7") + testImplementation("org.xmlunit:xmlunit-core:2.9.+") } repositories { diff --git a/skin/plantuml.skin b/skin/plantuml.skin index 9f7920474..e71b91a42 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -367,9 +367,21 @@ ganttDiagram { Margin 5 Padding 5 } + verticalSeparator { + LineThickness 2 + LineStyle 2-2 + LineColor black + } timeline { BackgroundColor transparent LineColor #C0C0C0 + FontSize 10 + month { + FontSize 12 + } + year { + FontSize 14 + } } closed { BackGroundColor #F1E5E5 diff --git a/src/com/plantuml/api/cheerpj/v1/DirectDraw.java b/src/com/plantuml/api/cheerpj/v1/DirectDraw.java index 295b0cc0b..88572fcf6 100644 --- a/src/com/plantuml/api/cheerpj/v1/DirectDraw.java +++ b/src/com/plantuml/api/cheerpj/v1/DirectDraw.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.BlockUml; import net.sourceforge.plantuml.BlockUmlBuilder; import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.error.PSystemError; import net.sourceforge.plantuml.klimt.color.ColorMapper; @@ -122,7 +123,7 @@ public class DirectDraw { ug.apply(back).apply(back.bg()).draw(URectangle.build(frameWidth, frameHeight)); WasmLog.log("...drawing..."); - system.exportDiagramGraphic(ug); + system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG)); WasmLog.log("done!"); diff --git a/src/com/plantuml/api/cheerpj/v1/Raw.java b/src/com/plantuml/api/cheerpj/v1/Raw.java index c8a12200e..e1ec34f5c 100644 --- a/src/com/plantuml/api/cheerpj/v1/Raw.java +++ b/src/com/plantuml/api/cheerpj/v1/Raw.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.BlockUmlBuilder; import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; @@ -124,7 +125,7 @@ public class Raw { ug.resetMax(); WasmLog.log("...drawing..."); - system.exportDiagramGraphic(ug); + system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG)); final int width = (int) (2 + ug.getMaxX()); final int height = (int) (2 + ug.getMaxY()); @@ -208,7 +209,7 @@ public class Raw { ug.resetMax(); WasmLog.log("...drawing..."); - system.exportDiagramGraphic(ug); + system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG)); final int width = (int) (2 + ug.getMaxX()); final int height = (int) (2 + ug.getMaxY()); diff --git a/src/h/package-info.java b/src/h/package-info.java index dff6c2a46..154188af6 100644 --- a/src/h/package-info.java +++ b/src/h/package-info.java @@ -12,9 +12,9 @@ * *

* - * @see gen + * @see "gen" * @see gen.annotation - * @see gen.lib + * @see "gen.lib" * @see gen.plugin.dot_layout * @see smetana.core * @see net.sourceforge.plantuml.sdot diff --git a/src/jcckit/package-info.java b/src/jcckit/package-info.java new file mode 100644 index 000000000..6bc88456f --- /dev/null +++ b/src/jcckit/package-info.java @@ -0,0 +1,16 @@ +/* + * ⚠ Disclaimer 🚩 + * This file was not part of the original package. + * It was included only on the PlantUML package + * to provide source citation and documentation. + * + */ +/** + * Internal copy of + * + * JCCKit (code of Franz-Josef Elmer). + * + * @see net.sourceforge.plantuml.jcckit + * + */ +package jcckit; diff --git a/src/jcckit/readme.md b/src/jcckit/readme.md new file mode 100644 index 000000000..19b4239f5 --- /dev/null +++ b/src/jcckit/readme.md @@ -0,0 +1,15 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `jcckit` + +## Description +Internal copy of `JCCKit` _(code of Franz-Josef Elmer)_. + +## Credit +- [JCCKit _(on Sourceforge)_](https://jcckit.sourceforge.net) + +## See more information on +- [readme of `plantuml/jcckit`](../net/sourceforge/plantuml/jcckit/readme.md) diff --git a/src/net/atmp/CucaDiagram.java b/src/net/atmp/CucaDiagram.java index d13c5fda3..c91cc88d6 100644 --- a/src/net/atmp/CucaDiagram.java +++ b/src/net/atmp/CucaDiagram.java @@ -376,13 +376,13 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, // ::done @Override - final public void exportDiagramGraphic(UGraphic ug) { + final public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { final CucaDiagramFileMaker maker = new CucaDiagramFileMakerSmetana(this, ug.getStringBounder()); maker.createOneGraphic(ug); } @Override - final protected TextBlock getTextBlock() { + final protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index abebc8b07..e45fe9f16 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -114,14 +114,14 @@ public abstract class AbstractPSystem implements Diagram { } final public String getMetadata() { - if (source == null) + if (source == null) return getVersion(); - + final String rawString = source.getRawString("\n"); final String plainString = source.getPlainString("\n"); - if (rawString != null && rawString.equals(plainString)) + if (rawString != null && rawString.equals(plainString)) return rawString + BackSlash.NEWLINE + getVersion(); - + return rawString + BackSlash.NEWLINE + plainString + BackSlash.NEWLINE + getVersion(); } @@ -130,9 +130,9 @@ public abstract class AbstractPSystem implements Diagram { } final public long seed() { - if (source == null) + if (source == null) return 42; - + return getSource().seed(); } @@ -159,9 +159,9 @@ public abstract class AbstractPSystem implements Diagram { } public DisplayPositionned getTitle() { - if (source == null) + if (source == null) return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); - + return DisplayPositioned.single(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); } @@ -247,7 +247,7 @@ public abstract class AbstractPSystem implements Diagram { } @Override - public void exportDiagramGraphic(UGraphic ug) { + public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { final UFont font = UFont.monospaced(14); final FontConfiguration fc = FontConfiguration.blackBlueTrue(font); final UText text = UText.build("Not implemented yet for " + getClass().getName(), fc); diff --git a/src/net/sourceforge/plantuml/AnnotatedBuilder.java b/src/net/sourceforge/plantuml/AnnotatedBuilder.java index 5b539e082..719d20fa4 100644 --- a/src/net/sourceforge/plantuml/AnnotatedBuilder.java +++ b/src/net/sourceforge/plantuml/AnnotatedBuilder.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.abel.DisplayPositioned; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.klimt.Fashion; +import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; @@ -167,7 +168,7 @@ public class AnnotatedBuilder { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(skinParam.getCurrentStyleBuilder()); final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), - skinParam, Style.ID_TITLE); + skinParam, Style.ID_TITLE, LineBreakStrategy.NONE); return block; } @@ -179,7 +180,7 @@ public class AnnotatedBuilder { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption) .getMergedStyle(skinParam.getCurrentStyleBuilder()); return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam, - Style.ID_CAPTION); + Style.ID_CAPTION, LineBreakStrategy.NONE); } diff --git a/src/net/sourceforge/plantuml/BlockUml.java b/src/net/sourceforge/plantuml/BlockUml.java index 9a4229bad..b5c6b76c7 100644 --- a/src/net/sourceforge/plantuml/BlockUml.java +++ b/src/net/sourceforge/plantuml/BlockUml.java @@ -143,7 +143,7 @@ public class BlockUml { this.data = new ArrayList<>(strings); } else { final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, charset, - (DefinitionsContainer) mode); + (DefinitionsContainer) mode, strings.get(0)); this.included.addAll(timLoader.load(strings)); this.data = timLoader.getResultList(); this.debug = timLoader.getDebug(); diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 9543cdd91..6cdd7abed 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -119,6 +119,9 @@ public class EmbeddedDiagram extends AbstractTextBlock implements Line, Atom { if (s.equals(EMBEDDED_START + "files")) return "files"; + if (s.equals(EMBEDDED_START + "chronology")) + return "chronology"; + return null; } diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 2f1db45a0..cf810f740 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -112,6 +112,9 @@ public class Option { private FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG); + /** + * @deprecated Use {@link #setFileFormatOption(FileFormatOption)} instead + */ @Deprecated @ApiWarning(willBeRemoved = "in next major release") final public void setFileFormat(FileFormat fileFormat) { @@ -440,9 +443,11 @@ public class Option { } else if (s.equalsIgnoreCase("-preproc")) { preprocessorOutput = OptionPreprocOutputMode.NORMAL; + setFileFormatOption(new FileFormatOption(FileFormat.PREPROC)); } else if (s.equalsIgnoreCase("-cypher")) { preprocessorOutput = OptionPreprocOutputMode.CYPHER; + setFileFormatOption(new FileFormatOption(FileFormat.PREPROC)); } else if (s.equalsIgnoreCase("-checkmetadata")) { checkMetadata = true; diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index df6938de7..984b8db51 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -85,83 +85,77 @@ public class OptionPrint { System.out.println("\t?\tone and only one character but '" + SFile.separator + "'"); System.out.println("\t**\tmeans any characters (used to recurse through directories)"); System.out.println(); - System.out.println("where options include:"); - System.out.println(" -darkmode\t\tTo use dark mode for diagrams"); - System.out.println(" -gui\t\tTo run the graphical user interface"); - System.out.println(" -tpng\t\tTo generate images using PNG format (default)"); - System.out.println(" -tsvg\t\tTo generate images using SVG format"); - System.out.println(" -teps\t\tTo generate images using EPS format"); - System.out.println(" -tpdf\t\tTo generate images using PDF format"); - System.out.println(" -tvdx\t\tTo generate images using VDX format"); - System.out.println(" -txmi\t\tTo generate XMI file for class diagram"); - System.out.println(" -tscxml\t\tTo generate SCXML file for state diagram"); - System.out.println(" -thtml\t\tTo generate HTML file for class diagram"); - System.out.println(" -ttxt\t\tTo generate images with ASCII art"); - System.out.println(" -tutxt\t\tTo generate images with ASCII art using Unicode characters"); - System.out.println(" -tlatex\t\tTo generate images using LaTeX/Tikz format"); - System.out.println(" -tlatex:nopreamble\tTo generate images using LaTeX/Tikz format without preamble"); - System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory"); - System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used"); - System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used"); - System.out.println(" -Ppragma1=value\tTo set pragma as if '!pragma pragma1 value' were used"); - // System.out.println(" -config \"file\"\tTo read the provided config file - // before each diagram"); final char separator = SFile.separatorChar; - System.out.println(" -I" + separator + "path" + separator + "to" + separator - + "file\tTo include file as if '!include file' were used"); - System.out.println( - " -I" + separator + "path" + separator + "to" + separator + "*.puml\tTo include files with pattern"); - System.out.println(" -theme xxx\t\tTo use a specific theme"); - System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")"); - System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern"); - System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images"); - System.out.println(" -nometadata\t\tTo NOT export metadata in PNG/SVG generated files"); + System.out.println("where options include:"); + System.out.println(" -author[s]\t\tTo print information about PlantUML authors"); System.out.println(" -checkmetadata\t\tSkip PNG files that don't need to be regenerated"); - System.out.println(" -version\t\tTo display information about PlantUML and Java versions"); - System.out.println(" -v[erbose]\t\tTo have log information"); - System.out.println(" -quiet\t\tTo NOT print error message into the console"); - System.out.println(" -debugsvek\t\tTo generate intermediate svek files"); - System.out.println(" -h[elp]\t\tTo display this help message"); - System.out.println(" -testdot\t\tTo test the installation of graphviz"); - System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable"); - System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation"); - System.out.println( - " -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image"); - System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file"); - System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL"); - System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images"); - System.out.println(" -language\t\tTo print the list of PlantUML keywords"); - // System.out.println(" -nosuggestengine\tTo disable the suggest engine when - // errors in diagrams"); System.out.println(" -checkonly\t\tTo check the syntax of files without generating images"); + System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")"); + System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file"); + // System.out.println(" -config \"file\"\tTo read the provided config file + System.out.println(" -cypher\t\tTo cypher texts of diagrams so that you can share them"); + System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used"); + System.out.println(" -darkmode\t\tTo use dark mode for diagrams"); + System.out.println(" -debugsvek\t\tTo generate intermediate svek files"); + System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL"); + System.out.println(" -disablestats\tTo disable statistics computation (default)"); + System.out.println(" -duration\t\tTo print the duration of complete diagrams processing"); + System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern"); + System.out.println(" -enablestats\tTo enable statistics computation"); + System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image"); + System.out.println(" -extractstdlib\tTo extract PlantUML Standard Library into stdlib folder"); System.out.println(" -failfast\t\tTo stop processing as soon as a syntax error in diagram occurs"); System.out.println(" -failfast2\t\tTo do a first syntax check before processing files, to fail even faster"); - System.out.println(" -noerror\t\tTo skip images when error in diagrams"); - System.out.println(" -duration\t\tTo print the duration of complete diagrams processing"); + System.out.println(" -filedir xxx\tTo behave as if the PlantUML source is in this dir (only affects '-pipe' and PicoWeb 'POST /render')"); + System.out.println(" -filename \"example.puml\"\tTo override %filename% variable"); + System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable"); + System.out.println(" -gui\t\tTo run the graphical user interface"); + System.out.println(" -h[elp]\t\tTo display this help message"); + System.out.println(" -htmlstats\t\tTo output general statistics in file plantuml-stats.html"); + System.out.println(" -I" + separator + "path" + separator + "to" + separator + "file\tTo include file as if '!include file' were used"); + System.out.println(" -I" + separator + "path" + separator + "to" + separator + "*.puml\tTo include files with pattern"); + System.out.println(" -language\t\tTo print the list of PlantUML keywords"); + System.out.println(" -loopstats\t\tTo continuously print statistics about usage"); + System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images"); System.out.println(" -nbthread N\t\tTo use (N) threads for processing"); System.out.println(" -nbthread auto\tTo use " + Option.defaultNbThreads() + " threads for processing"); - System.out - .println(" -timeout N\t\tProcessing timeout in (N) seconds. Defaults to 15 minutes (900 seconds)."); - System.out.println(" -author[s]\t\tTo print information about PlantUML authors"); + System.out.println(" -noerror\t\tTo skip images when error in diagrams"); + System.out.println(" -nometadata\t\tTo NOT export metadata in PNG/SVG generated files"); + System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory"); System.out.println(" -overwrite\t\tTo allow to overwrite read only files"); - System.out.println(" -printfonts\t\tTo print fonts available on your system"); - System.out.println(" -enablestats\tTo enable statistics computation"); - System.out.println(" -disablestats\tTo disable statistics computation (default)"); - System.out.println(" -htmlstats\t\tTo output general statistics in file plantuml-stats.html"); - System.out.println(" -xmlstats\t\tTo output general statistics in file plantuml-stats.xml"); - System.out.println(" -realtimestats\tTo generate statistics on the fly rather than at the end"); - System.out.println(" -loopstats\t\tTo continuously print statistics about usage"); - System.out.println(" -splash\t\tTo display a splash screen with some progress bar"); - System.out.println(" -progress\t\tTo display a textual progress bar in console"); - System.out.println(" -pipeimageindex N\tTo generate the Nth image with pipe option"); - System.out.println(" -stdlib\t\tTo print standard library info"); - System.out.println(" -extractstdlib\tTo extract PlantUML Standard Library into stdlib folder"); - System.out.println( - " -filedir xxx\tTo behave as if the PlantUML source is in this dir (only affects '-pipe' and PicoWeb 'POST /render')"); - System.out.println(" -filename \"example.puml\"\tTo override %filename% variable"); - System.out.println(" -preproc\t\tTo output preprocessor text of diagrams"); - System.out.println(" -cypher\t\tTo cypher texts of diagrams so that you can share them"); + System.out.println(" -Ppragma1=value\tTo set pragma as if '!pragma pragma1 value' were used"); + System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation"); System.out.println(" -picoweb\t\tTo start internal HTTP Server. See https://plantuml.com/picoweb"); + System.out.println(" -pipeimageindex N\tTo generate the Nth image with pipe option"); + System.out.println(" -preproc\t\tTo output preprocessor text of diagrams"); + System.out.println(" -printfonts\t\tTo print fonts available on your system"); + System.out.println(" -progress\t\tTo display a textual progress bar in console"); + System.out.println(" -quiet\t\tTo NOT print error message into the console"); + System.out.println(" -realtimestats\tTo generate statistics on the fly rather than at the end"); + System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used"); + System.out.println(" -splash\t\tTo display a splash screen with some progress bar"); + System.out.println(" -stdlib\t\tTo print standard library info"); + System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images"); + System.out.println(" -testdot\t\tTo test the installation of graphviz"); + System.out.println(" -theme xxx\t\tTo use a specific theme"); + System.out.println(" -timeout N\t\tProcessing timeout in (N) seconds. Defaults to 15 minutes (900 seconds)."); + System.out.println(" -teps\t\tTo generate images using EPS format"); + System.out.println(" -testdot\t\tTo test the installation of graphviz"); + System.out.println(" -theme xxx\t\tTo use a specific theme"); + System.out.println(" -thtml\t\tTo generate HTML file for class diagram"); + System.out.println(" -tlatex:nopreamble\tTo generate images using LaTeX/Tikz format without preamble"); + System.out.println(" -tlatex\t\tTo generate images using LaTeX/Tikz format"); + System.out.println(" -tpdf\t\tTo generate images using PDF format"); + System.out.println(" -tpng\t\tTo generate images using PNG format (default)"); + System.out.println(" -tscxml\t\tTo generate SCXML file for state diagram"); + System.out.println(" -tsvg\t\tTo generate images using SVG format"); + System.out.println(" -ttxt\t\tTo generate images with ASCII art"); + System.out.println(" -tutxt\t\tTo generate images with ASCII art using Unicode characters"); + System.out.println(" -tvdx\t\tTo generate images using VDX format"); + System.out.println(" -txmi\t\tTo generate XMI file for class diagram"); + System.out.println(" -v[erbose]\t\tTo have log information"); + System.out.println(" -version\t\tTo display information about PlantUML and Java versions"); + System.out.println(" -xmlstats\t\tTo output general statistics in file plantuml-stats.xml"); System.out.println(); System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT."); exit(0); diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 4838270f2..66b642108 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.api.PSystemFactory; import net.sourceforge.plantuml.board.BoardDiagramFactory; import net.sourceforge.plantuml.bpm.BpmDiagramFactory; import net.sourceforge.plantuml.cheneer.ChenEerDiagramFactory; +import net.sourceforge.plantuml.chronology.ChronologyDiagramFactory; import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.DiagramType; @@ -253,6 +254,7 @@ public class PSystemBuilder { // ::done factories.add(new GanttDiagramFactory()); + factories.add(new ChronologyDiagramFactory()); factories.add(new FlowDiagramFactory()); // ::comment when __CORE__ diff --git a/src/net/sourceforge/plantuml/PlainDiagram.java b/src/net/sourceforge/plantuml/PlainDiagram.java index 7945b7feb..88385e9e5 100644 --- a/src/net/sourceforge/plantuml/PlainDiagram.java +++ b/src/net/sourceforge/plantuml/PlainDiagram.java @@ -66,14 +66,13 @@ public abstract class PlainDiagram extends AbstractPSystem { } @Override - public void exportDiagramGraphic(UGraphic ug) { - final FileFormatOption option = new FileFormatOption(FileFormat.PNG); + public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { try { - final UDrawable rootDrawable = getRootDrawable(option); + final UDrawable rootDrawable = getRootDrawable(fileFormatOption); rootDrawable.drawU(ug); } catch (IOException e) { e.printStackTrace(); - super.exportDiagramGraphic(ug); + super.exportDiagramGraphic(ug, fileFormatOption); } } diff --git a/src/net/sourceforge/plantuml/SourceStringReader.java b/src/net/sourceforge/plantuml/SourceStringReader.java index 32e7f5ace..34f9f713e 100644 --- a/src/net/sourceforge/plantuml/SourceStringReader.java +++ b/src/net/sourceforge/plantuml/SourceStringReader.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.klimt.shape.GraphicStrings; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.security.SFile; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.utils.Log; public class SourceStringReader { @@ -106,6 +107,9 @@ public class SourceStringReader { } } + /** + * @deprecated Use {@link #outputImage(OutputStream)} instead + */ @Deprecated public String generateImage(OutputStream os) throws IOException { return outputImage(os).getDescription(); @@ -116,6 +120,9 @@ public class SourceStringReader { } // ::comment when __CORE__ + /** + * @deprecated Use {@link #outputImage(SFile)} instead + */ @Deprecated public String generateImage(SFile f) throws IOException { return outputImage(f).getDescription(); @@ -128,6 +135,9 @@ public class SourceStringReader { } // ::done + /** + * @deprecated Use {@link #outputImage(OutputStream, FileFormatOption)} instead + */ @Deprecated public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException { return outputImage(os, fileFormatOption).getDescription(); @@ -137,6 +147,9 @@ public class SourceStringReader { return outputImage(os, 0, fileFormatOption); } + /** + * @deprecated Use {@link #outputImage(OutputStream, int)} instead + */ @Deprecated public String generateImage(OutputStream os, int numImage) throws IOException { return outputImage(os, numImage).getDescription(); @@ -146,6 +159,9 @@ public class SourceStringReader { return outputImage(os, numImage, new FileFormatOption(FileFormat.PNG)); } + /** + * @deprecated Use {@link #outputImage(OutputStream, int, FileFormatOption)} instead + */ @Deprecated public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException { return outputImage(os, numImage, fileFormatOption).getDescription(); @@ -157,6 +173,14 @@ public class SourceStringReader { noValidStartFound(os, fileFormatOption); return null; } + if (fileFormatOption.getFileFormat() == FileFormat.PREPROC) { + final BlockUml first = blocks.get(0); + for (StringLocated s : first.getData()) { + os.write(s.getString().getBytes(UTF_8)); + os.write("\n".getBytes(UTF_8)); + } + return new DiagramDescription("PREPROC"); + } for (BlockUml b : blocks) { final Diagram system = b.getDiagram(); final int nbInSystem = system.getNbImages(); @@ -231,7 +255,8 @@ public class SourceStringReader { } public ImageData noValidStartFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException { - final TextBlock error = GraphicStrings.createForError(Arrays.asList("No valid @start/@end found, please check the version"), + final TextBlock error = GraphicStrings.createForError( + Arrays.asList("No valid @start/@end found, please check the version"), fileFormatOption.isUseRedForError()); return plainImageBuilder(error, fileFormatOption).write(os); diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index f5faeba59..9f365f86c 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -253,11 +253,11 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, } - protected abstract TextBlock getTextBlock(); + protected abstract TextBlock getTextMainBlock(FileFormatOption fileFormatOption); @Override - public void exportDiagramGraphic(UGraphic ug) { - final TextBlock textBlock = getTextBlock(); + public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { + final TextBlock textBlock = getTextMainBlock(fileFormatOption); textBlock.drawU(ug); } diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java index a809b3719..15df082ce 100644 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java +++ b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java @@ -47,9 +47,9 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import ext.plantuml.com.ctreber.acearth.ACearth; -import ext.plantuml.com.ctreber.acearth.ConfigurationACearth; -import ext.plantuml.com.ctreber.acearth.plugins.markers.Marker; +import zext.plantuml.com.ctreber.acearth.ACearth; +import zext.plantuml.com.ctreber.acearth.ConfigurationACearth; +import zext.plantuml.com.ctreber.acearth.plugins.markers.Marker; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.api.ImageDataSimple; diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java b/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java index aa19bba56..d7a8e9ad9 100644 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java +++ b/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java @@ -40,7 +40,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import ext.plantuml.com.ctreber.acearth.plugins.markers.Marker; +import zext.plantuml.com.ctreber.acearth.plugins.markers.Marker; import net.sourceforge.plantuml.command.PSystemBasicFactory; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.log.Logme; diff --git a/src/net/sourceforge/plantuml/acearth/package-info.java b/src/net/sourceforge/plantuml/acearth/package-info.java index ff8536d87..26683cf61 100644 --- a/src/net/sourceforge/plantuml/acearth/package-info.java +++ b/src/net/sourceforge/plantuml/acearth/package-info.java @@ -3,6 +3,6 @@ * * XEarth Image. * - * @see ext.plantuml.com.ctreber.acearth + * @see zext.plantuml.com.ctreber.acearth */ package net.sourceforge.plantuml.acearth; diff --git a/src/net/sourceforge/plantuml/acearth/readme.md b/src/net/sourceforge/plantuml/acearth/readme.md index a369bb7a5..e5d8f1c1a 100644 --- a/src/net/sourceforge/plantuml/acearth/readme.md +++ b/src/net/sourceforge/plantuml/acearth/readme.md @@ -3,7 +3,7 @@ ## Description This package provides classes used to generate [XEarth Image](https://plantuml.com/xearth). -The Java port of `XEarth` used in `PlantUML` is the [`AC.earth` of Christian Treber](../../../../ext/plantuml/com/ctreber/acearth/). +The Java port of `XEarth` used in `PlantUML` is the [`AC.earth` of Christian Treber](../../../../zext/plantuml/com/ctreber/acearth/). ## Link - [XEarth Image _(on `PlantUML`)_](https://plantuml.com/xearth) @@ -13,7 +13,7 @@ The Java port of `XEarth` used in `PlantUML` is the [`AC.earth` of Christian Tre - [`xearth` for Windows of Greg Hewgill](https://hewgill.com/xearth/) ## Credit -- [`AC.earth` of Christian Treber](../../../../ext/plantuml/com/ctreber/acearth/) +- [`AC.earth` of Christian Treber](../../../../zext/plantuml/com/ctreber/acearth/) - [AC Earth _(on Web Archive)_](https://web.archive.org/web/20180428011447/http://www.acproductions.de/acearth) ## Misc. diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 6daa6844e..143b3225d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexPartialMatch; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -81,9 +82,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { new RegexLeaf("CODE", "([%pLN][%pLN_.]*)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // ColorParser.exp2(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -105,9 +104,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { new RegexLeaf("BAR2", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN][%pLN_.]*))?"), // new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // new RegexOptional( // new RegexConcat( // new RegexLeaf("in"), // diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 4e008bac8..75d2551e1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -64,6 +64,7 @@ import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.text.BackSlash; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.url.Url; @@ -91,9 +92,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 new RegexLeaf("CODE", "([%pLN][%pLN_.]*)"), // new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), // new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("BACKCOLOR", "(#\\w+)?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index 488cff81b..cef3f0753 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.LineLocation; public class CommandPartition extends SingleLineCommand2 { @@ -69,9 +70,7 @@ public class CommandPartition extends SingleLineCommand2 { new RegexOr(// color().getRegex(), // new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("\\{?"), // RegexLeaf.end()); } @@ -89,12 +88,10 @@ public class CommandPartition extends SingleLineCommand2 { final Entity p = diagram.getCurrentGroup(); final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); - if (colors.isEmpty() == false) { + if (colors.isEmpty() == false) p.setColors(colors); - } - if (arg.get("STEREOTYPE", 0) != null) { - p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); - } + + p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 009bed4dc..281e6c6ce 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -40,7 +40,6 @@ import java.io.OutputStream; import java.util.Map; import java.util.Objects; -import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; @@ -109,11 +108,11 @@ public class ActivityDiagram3 extends UmlDiagram { return swinlanes.nextLinkRenderer(); } - public CommandExecutionResult addActivity(Display activity, BoxStyle style, Url url, Colors colors, + public CommandExecutionResult addActivity(Display activity, BoxStyle boxStyle, Url url, Colors colors, Stereotype stereotype) { manageSwimlaneStrategy(); final InstructionSimple ins = new InstructionSimple(activity, nextLinkRenderer(), - swinlanes.getCurrentSwimlane(), style, url, colors, stereotype); + swinlanes.getCurrentSwimlane(), boxStyle, url, colors, stereotype); final CommandExecutionResult added = current().add(ins); if (added.isOk() == false) return added; @@ -208,8 +207,7 @@ public class ActivityDiagram3 extends UmlDiagram { } @Override - protected TextBlock getTextBlock() { - final FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG); + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); return getTextBlock(stringBounder); } @@ -318,10 +316,10 @@ public class ActivityDiagram3 extends UmlDiagram { return CommandExecutionResult.error("Cannot find switch"); } - public void startIf(Display test, Display whenThen, HColor color, Url url) { + public void startIf(Display test, Display whenThen, HColor color, Url url, Stereotype stereotype) { manageSwimlaneStrategy(); final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test, - LinkRendering.none().withDisplay(whenThen), nextLinkRenderer(), color, getSkinParam(), url); + LinkRendering.none().withDisplay(whenThen), nextLinkRenderer(), color, getSkinParam(), url, stereotype); current().add(instructionIf); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(instructionIf); @@ -392,12 +390,13 @@ public class ActivityDiagram3 extends UmlDiagram { manageSwimlaneStrategy(); if (current() instanceof InstructionRepeat) { final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); - instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2, stereotype); + instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2, + stereotype); return CommandExecutionResult.ok(); } if (current() instanceof InstructionWhile) { final InstructionWhile instructionWhile = (InstructionWhile) current(); - instructionWhile.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2); + instructionWhile.setBackward(label, boxStyle, incoming1, incoming2, stereotype); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("Cannot find repeat"); @@ -407,7 +406,7 @@ public class ActivityDiagram3 extends UmlDiagram { public void doWhile(Display test, Display yes, HColor color) { manageSwimlaneStrategy(); final InstructionWhile instructionWhile = new InstructionWhile(swinlanes.getCurrentSwimlane(), current(), test, - nextLinkRenderer(), yes, color, getSkinParam()); + nextLinkRenderer(), yes, color, getSkinParam().getCurrentStyleBuilder()); current().add(instructionWhile); setCurrent(instructionWhile); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index 0a25a1dc9..35270db4d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.TextBlockUtils; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; @@ -95,12 +96,12 @@ public class Branch { } public Branch(StyleBuilder styleBuilder, Swimlane swimlane, LinkRendering labelPositive, Display labelTest, - HColor color, LinkRendering inlabel) { + HColor color, LinkRendering inlabel, Stereotype stereotype) { this.inlabel = Objects.requireNonNull(inlabel); this.labelTest = Objects.requireNonNull(labelTest); this.labelPositive = Objects.requireNonNull(labelPositive); - final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(styleBuilder); + final Style style = getDefaultStyleDefinitionDiamond().withTOBECHANGED(stereotype).getMergedStyle(styleBuilder); this.color = color == null ? style.value(PName.BackGroundColor).asColor(styleBuilder.getSkinParam().getIHtmlColorSet()) : color; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index 23ddbae23..49e136308 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -47,7 +47,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileDecorateWelding; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; -import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfAlone; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfHexagon; @@ -56,10 +55,11 @@ import net.sourceforge.plantuml.klimt.color.Colors; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.font.StringBounder; -import net.sourceforge.plantuml.klimt.geom.VerticalAlignment; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.url.Url; public class InstructionIf extends WithNote implements Instruction, InstructionCollection { @@ -75,8 +75,10 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC private Branch current; private final LinkRendering topInlinkRendering; private LinkRendering outColor = LinkRendering.none(); + private final Stereotype stereotype; private final Swimlane swimlane; + private final StyleBuilder currentStyleBuilder; @Override public boolean containsBreak() { @@ -91,14 +93,16 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC } public InstructionIf(Swimlane swimlane, Instruction parent, Display labelTest, LinkRendering whenThen, - LinkRendering inlinkRendering, HColor color, ISkinParam skinParam, Url url) { + LinkRendering inlinkRendering, HColor color, ISkinParam skinParam, Url url, Stereotype stereotype) { this.url = url; + this.stereotype = stereotype; this.parent = parent; this.skinParam = skinParam; this.topInlinkRendering = Objects.requireNonNull(inlinkRendering); this.swimlane = swimlane; - this.thens.add(new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, labelTest, color, - LinkRendering.none())); + this.currentStyleBuilder = skinParam.getCurrentStyleBuilder(); + this.thens.add(new Branch(currentStyleBuilder, swimlane, whenThen, labelTest, color, LinkRendering.none(), + stereotype)); this.current = this.thens.get(0); } @@ -137,12 +141,12 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC branch.updateFtile(factory); if (elseBranch == null) - this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, LinkRendering.none(), - Display.NULL, null, LinkRendering.none()); + this.elseBranch = new Branch(currentStyleBuilder, swimlane, LinkRendering.none(), + Display.NULL, null, LinkRendering.none(), stereotype); elseBranch.updateFtile(factory); Ftile result = factory.createIf(swimlane, thens, elseBranch, outColor, topInlinkRendering, url, - getPositionedNotes()); + getPositionedNotes(), stereotype, currentStyleBuilder); // if (getPositionedNotes().size() > 0) // result = FtileWithNoteOpale.create(result, getPositionedNotes(), false, VerticalAlignment.CENTER); @@ -169,7 +173,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC this.current.setInlinkRendering(nextLinkRenderer); this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenElse, Display.NULL, null, - LinkRendering.none()); + LinkRendering.none(), stereotype); this.current = elseBranch; return true; } @@ -180,7 +184,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC return false; this.current.setSpecial(nextLinkRenderer); - this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, test, color, inlabel); + this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, test, color, inlabel, + stereotype); this.thens.add(current); return true; @@ -190,7 +195,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC endifCalled = true; if (elseBranch == null) this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, LinkRendering.none(), - Display.NULL, null, LinkRendering.none()); + Display.NULL, null, LinkRendering.none(), stereotype); this.elseBranch.setSpecial(nextLinkRenderer); this.current.setInlinkRendering(nextLinkRenderer); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java index 7bec98e0d..d8362f656 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java @@ -129,8 +129,13 @@ public class InstructionList extends WithNote implements Instruction, Instructio @Override public Ftile createFtile(FtileFactory factory) { - if (all.size() == 0) - return new FtileEmpty(factory.skinParam(), defaultSwimlane); + if (all.size() == 0) { + Ftile result = new FtileEmpty(factory.skinParam(), defaultSwimlane); + // Not a typo, in that case, we decide to decorate the entry link. + if (outlinkRendering != null) + result = factory.decorateIn(result, outlinkRendering); + return result; + } final List breaks = new ArrayList<>(); Ftile result = eventuallyAddNote(factory, null, getSwimlaneIn(), VerticalAlignment.CENTER); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 287b84a21..1680f463f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; +import net.sourceforge.plantuml.style.StyleBuilder; public class InstructionRepeat extends AbstractInstruction implements Instruction { @@ -87,6 +88,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio private LinkRendering endRepeatLinkRendering = LinkRendering.none(); private final Colors colors; + private final StyleBuilder currentStyleBuilder; public boolean containsBreak() { return repeatList.containsBreak(); @@ -94,6 +96,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio public InstructionRepeat(Swimlanes swimlanes, Instruction parent, LinkRendering nextLinkRenderer, HColor color, Display startLabel, BoxStyle boxStyleIn, Colors colors) { + this.currentStyleBuilder = swimlanes.getCurrentStyleBuilder(); this.swimlanes = swimlanes; this.swimlane = swimlanes.getCurrentSwimlane(); this.repeatList = new InstructionList(this.swimlane); @@ -158,7 +161,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio if (this.testCalled == false && incoming1.isNone()) incoming1 = swimlanes.nextLinkRenderer(); final Ftile result = factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, decorateOut, test, yes, out, - colors, back, isLastOfTheParent(), incoming1, incoming2); + colors, back, isLastOfTheParent(), incoming1, incoming2, currentStyleBuilder); if (killed) return new FtileKilled(result); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java index 901b55ce5..d6886bd0b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java @@ -62,7 +62,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction { private final Display label; private final Colors colors; private final LinkRendering inlinkRendering; - private final BoxStyle style; + private final BoxStyle boxStyle; private final Url url; private final Stereotype stereotype; @@ -71,12 +71,12 @@ public class InstructionSimple extends MonoSwimable implements Instruction { return false; } - public InstructionSimple(Display label, LinkRendering inlinkRendering, Swimlane swimlane, BoxStyle style, Url url, - Colors colors, Stereotype stereotype) { + public InstructionSimple(Display label, LinkRendering inlinkRendering, Swimlane swimlane, BoxStyle boxStyle, + Url url, Colors colors, Stereotype stereotype) { super(swimlane); this.stereotype = stereotype; this.url = url; - this.style = style; + this.boxStyle = boxStyle; this.label = label; this.inlinkRendering = Objects.requireNonNull(inlinkRendering); this.colors = Objects.requireNonNull(colors); @@ -85,7 +85,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction { // ::comment when __CORE__ @Override public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { - GtileBox result = GtileBox.create(stringBounder, colors.mute(skinParam), label, getSwimlaneIn(), style, + GtileBox result = GtileBox.create(stringBounder, colors.mute(skinParam), label, getSwimlaneIn(), boxStyle, stereotype); if (hasNotes()) { final Collection notes = getPositionedNotes(); @@ -103,7 +103,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction { @Override public Ftile createFtile(FtileFactory factory) { - Ftile result = factory.activity(label, getSwimlaneIn(), style, colors, stereotype); + Ftile result = factory.activity(label, getSwimlaneIn(), boxStyle, colors, stereotype); if (url != null) { result = factory.addUrl(result, url); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java index 9ed4ddb98..dc9efedc6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java @@ -58,7 +58,7 @@ import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.style.ISkinParam; public class InstructionSwitch extends WithNote implements Instruction, InstructionCollection { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private final List switches = new ArrayList<>(); private final ISkinParam skinParam; @@ -166,7 +166,7 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct this.current.setSpecial(nextLinkRenderer); this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, LinkRendering.none().withDisplay(labelCase), labelCase, null, - LinkRendering.none().withDisplay(labelCase)); + LinkRendering.none().withDisplay(labelCase), null); this.switches.add(this.current); return true; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java index 554510da7..721f882d0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java @@ -55,7 +55,9 @@ import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.geom.VerticalAlignment; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; +import net.sourceforge.plantuml.style.StyleBuilder; public class InstructionWhile extends WithNote implements Instruction, InstructionCollection { @@ -72,30 +74,32 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi private LinkRendering outColor = LinkRendering.none(); private final Swimlane swimlane; - private final ISkinParam skinParam; private Instruction specialOut; private BoxStyle boxStyle; - private Swimlane swimlaneOut; + private Display backward = Display.NULL; + private Stereotype stereotype; + private LinkRendering incoming1 = LinkRendering.none(); private LinkRendering incoming2 = LinkRendering.none(); private boolean backwardCalled; + private final StyleBuilder currentStyleBuilder; public void overwriteYes(Display yes) { this.yes = yes; } public InstructionWhile(Swimlane swimlane, Instruction parent, Display test, LinkRendering nextLinkRenderer, - Display yes, HColor color, ISkinParam skinParam) { + Display yes, HColor color, StyleBuilder currentStyleBuilder) { this.parent = parent; this.test = Objects.requireNonNull(test); this.nextLinkRenderer = Objects.requireNonNull(nextLinkRenderer); this.yes = Objects.requireNonNull(yes); this.swimlane = swimlane; + this.currentStyleBuilder = currentStyleBuilder; this.color = color; - this.skinParam = skinParam; } @Override @@ -116,9 +120,10 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi @Override public Ftile createFtile(FtileFactory factory) { final Ftile back = Display.isNull(backward) ? null - : factory.activity(backward, swimlane, boxStyle, Colors.empty(), null); + : factory.activity(backward, swimlane, boxStyle, Colors.empty(), stereotype); Ftile tmp = repeatList.createFtile(factory); - tmp = factory.createWhile(outColor, swimlane, tmp, test, yes, color, specialOut, back, incoming1, incoming2); + tmp = factory.createWhile(outColor, swimlane, tmp, test, yes, color, specialOut, back, incoming1, incoming2, + currentStyleBuilder); if (getPositionedNotes().size() > 0) tmp = FtileWithNoteOpale.create(tmp, getPositionedNotes(), false, VerticalAlignment.CENTER); @@ -191,14 +196,14 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi return repeatList.containsBreak(); } - public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle, LinkRendering incoming1, - LinkRendering incoming2) { + public void setBackward(Display label, BoxStyle boxStyle, LinkRendering incoming1, LinkRendering incoming2, + Stereotype stereotype) { this.backward = label; - this.swimlaneOut = swimlaneOut; this.boxStyle = boxStyle; this.incoming1 = incoming1; this.incoming2 = incoming2; this.backwardCalled = true; + this.stereotype = stereotype; } public void incoming(LinkRendering incoming) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 183d130ed..4a38e0c61 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -61,7 +62,7 @@ public class CommandActivity3 extends SingleLineCommand2 { public static final String endingGroup() { return "(" // - + ";(?:[%s]*(\\<\\<\\w+\\>\\>))?" // + + ";[%s]*(\\<\\<\\w+\\>\\>(?:[%s]*\\<\\<\\w+\\>\\>)*)?" // + "|" // + Matcher.quoteReplacement("\\\\") // that is simply \ character + "|" // @@ -77,7 +78,7 @@ public class CommandActivity3 extends SingleLineCommand2 { private static final String endingGroupShort() { return "(" // - + ";(?:[%s]*(\\<\\<\\w+\\>\\>))?" // + + ";[%s]*(\\<\\<\\w+\\>\\>(?:[%s]*\\<\\<\\w+\\>\\>)*)?" // + "|" // + Matcher.quoteReplacement("\\\\") // that is simply \ character + "|" // @@ -104,9 +105,7 @@ public class CommandActivity3 extends SingleLineCommand2 { return RegexConcat.build(CommandActivity3.class.getName(), RegexLeaf.start(), // UrlBuilder.OPTIONAL, // color().getRegex(), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf(":"), // new RegexLeaf("LABEL", "(.*?)"), // new RegexLeaf("STYLE", endingGroupShort()), // diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java index 397f6f977..530e1f43e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.utils.BlocLines; public class CommandActivityLong3 extends CommandMultilines3 { @@ -84,10 +85,16 @@ public class CommandActivityLong3 extends CommandMultilines3 { final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast().getString()); + final String end = lineLast.get("END", 0); + Stereotype stereotype = null; + String stereo = lineLast.get("END", 1); + if (stereo != null) + stereotype = Stereotype.build(stereo); + final BoxStyle style = BoxStyle.fromString(end); lines = lines.removeStartingAndEnding(line0.get("DATA", 0), end.length()); - return diagram.addActivity(lines.toDisplay(), style, null, colors, null); + return diagram.addActivity(lines.toDisplay(), style, null, colors, stereotype); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java index 6f7f93d18..643717928 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java @@ -78,9 +78,8 @@ public class CommandArrow3 extends SingleLineCommand2 { diagram.setColorNextArrow(rainbow); } final String label = arg.get("LABEL", 0); - if (label != null && label.length() > 0) { + if (label != null && label.length() > 0) diagram.setLabelNextArrow(Display.getWithNewlines(label)); - } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java index efd28fb28..fca210ab9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java @@ -47,6 +47,8 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -63,7 +65,7 @@ public class CommandIf2 extends SingleLineCommand2 { UrlBuilder.OPTIONAL, // ColorParser.exp4(), // new RegexLeaf("if"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("\\("), // new RegexLeaf("TEST", "(.*?)"), // new RegexLeaf("\\)"), // @@ -85,9 +87,8 @@ public class CommandIf2 extends SingleLineCommand2 { final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); - if (test.length() == 0) { + if (test.length() == 0) test = null; - } final Url url; if (arg.get("URL", 0) == null) { @@ -96,8 +97,9 @@ public class CommandIf2 extends SingleLineCommand2 { final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT); url = urlBuilder.getUrl(arg.get("URL", 0)); } + final Stereotype stereotype = Stereotype.build(arg.get("STEREO", 0)); - diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, url); + diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, url, stereotype); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java index 926746f8e..331389707 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java @@ -82,10 +82,10 @@ public class CommandIf4 extends SingleLineCommand2 { final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); - if (test.length() == 0) { + if (test.length() == 0) test = null; - } - diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, null); + + diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, null, null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java index 7f1b9a30d..78f120eaa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java @@ -72,7 +72,7 @@ public class CommandIfLegacy1 extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { diagram.startIf(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("WHEN", 0)), null, - null); + null, null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index 63132a782..3e7dcc420 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.utils.LineLocation; @@ -77,9 +78,7 @@ public class CommandPartition3 extends SingleLineCommand2 { new RegexConcat( // RegexLeaf.spaceOneOrMore(), // color("BACK2").getRegex())), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("\\{?"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java index 6289d2b60..82170a3e8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.LineLocation; public class CommandRepeat3 extends SingleLineCommand2 { @@ -62,7 +63,7 @@ public class CommandRepeat3 extends SingleLineCommand2 { static IRegex getRegexConcat() { return RegexConcat.build(CommandRepeat3.class.getName(), RegexLeaf.start(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // + StereotypePattern.optional("STEREO"), // ColorParser.exp4(), // new RegexLeaf("repeat"), // RegexLeaf.spaceZeroOrMore(), // diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java index d2e6a70a3..f803285e7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java @@ -160,11 +160,12 @@ public enum BoxStyle { if (bs.style == style.charAt(0)) return bs; - style = style.replaceAll("\\W", ""); - - for (BoxStyle bs : BoxStyle.values()) - if (style.equalsIgnoreCase(bs.stereotype)) - return bs; + for (String s : style.split("\\s")) { + s = s.replaceAll("\\W", ""); + for (BoxStyle bs : BoxStyle.values()) + if (s.equalsIgnoreCase(bs.stereotype)) + return bs; + } } return PLAIN; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index 75a603cd2..ba8ae42b9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -49,7 +49,9 @@ public class EntityImageLegend { final Style style = StyleSignatureBasic .of(SName.root, SName.root, SName.document, skinParam.getUmlDiagramType().getStyleName(), SName.legend) .getMergedStyle(skinParam.getCurrentStyleBuilder()); - return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam, Style.ID_LEGEND); + + return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam, Style.ID_LEGEND, + style.wrapWidth()); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index 897491f1b..f7cabc662 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.klimt.geom.VerticalAlignment; import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.url.Url; public interface FtileFactory { @@ -83,13 +84,15 @@ public interface FtileFactory { public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, Ftile backward, boolean noOut, - LinkRendering incoming1, LinkRendering incoming2); + LinkRendering incoming1, LinkRendering incoming2, StyleBuilder currentStyleBuilder); public Ftile createWhile(LinkRendering outColor, Swimlane swimlane, Ftile whileBlock, Display test, Display yes, - HColor color, Instruction specialOut, Ftile backward, LinkRendering incoming1, LinkRendering incoming2); + HColor color, Instruction specialOut, Ftile backward, LinkRendering incoming1, LinkRendering incoming2, + StyleBuilder currentStyleBuilder); public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering outColor, - LinkRendering topInlinkRendering, Url url, Collection notes); + LinkRendering topInlinkRendering, Url url, Collection notes, Stereotype stereotype, + StyleBuilder currentStyleBuilder); public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Display labelTest); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 5969966ce..b39f1ad2e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.url.Url; @@ -174,22 +175,25 @@ public class FtileFactoryDelegator implements FtileFactory { @Override public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, Ftile backward, boolean noOut, - LinkRendering incoming1, LinkRendering incoming2) { + LinkRendering incoming1, LinkRendering incoming2, StyleBuilder currentStyleBuilder) { return factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, repeat, test, yes, out, colors, backward, - noOut, incoming1, incoming2); + noOut, incoming1, incoming2, currentStyleBuilder); } @Override public Ftile createWhile(LinkRendering outColor, Swimlane swimlane, Ftile whileBlock, Display test, Display yes, - HColor color, Instruction specialOut, Ftile back, LinkRendering incoming1, LinkRendering incoming2) { + HColor color, Instruction specialOut, Ftile back, LinkRendering incoming1, LinkRendering incoming2, + StyleBuilder styleBuilder) { return factory.createWhile(outColor, swimlane, whileBlock, test, yes, color, specialOut, back, incoming1, - incoming2); + incoming2, styleBuilder); } @Override public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering, Url url, Collection notes) { - return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering, url, notes); + LinkRendering topInlinkRendering, Url url, Collection notes, Stereotype stereotype, + StyleBuilder currentStyleBuilder) { + return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering, url, notes, stereotype, + currentStyleBuilder); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java index 1d5bebdd7..0df019d31 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java @@ -82,6 +82,7 @@ import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.svek.UGraphicForSnake; @@ -127,9 +128,9 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable } protected Style getStyle() { - if (style == null) { + if (style == null) this.style = getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); - } + return style; } @@ -455,4 +456,8 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable return cachedMinMax; } + public StyleBuilder getCurrentStyleBuilder() { + return skinParam.getCurrentStyleBuilder(); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java index 4330e476b..92eda31fe 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java @@ -48,8 +48,10 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.ConditionalBuilder; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.skin.Pragma; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.url.Url; @@ -65,15 +67,16 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { @Override public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering, Url url, Collection notes) { + LinkRendering topInlinkRendering, Url url, Collection notes, Stereotype stereotype, + StyleBuilder currentStyleBuilder) { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); final ConditionEndStyle conditionEndStyle = skinParam().getConditionEndStyle(); final Branch branch0 = thens.get(0); - final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); - final Style styleDiamond = getDefaultStyleDefinitionDiamond() - .getMergedStyle(skinParam().getCurrentStyleBuilder()); + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(currentStyleBuilder); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().withTOBECHANGED(stereotype) + .getMergedStyle(currentStyleBuilder); final HColor backColor = branch0.getColor() == null ? styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet()) : branch0.getColor(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java index a289a153d..140845b0a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.geom.XDimension2D; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.ConditionStyle; public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { @@ -73,13 +74,12 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { @Override public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, final Ftile repeat, Display test, Display yes, Display out, Colors colors, Ftile backward, boolean noOut, - LinkRendering incoming1, LinkRendering incoming2) { + LinkRendering incoming1, LinkRendering incoming2, StyleBuilder currentStyleBuilder) { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); - final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); - final Style styleDiamond = getDefaultStyleDefinitionDiamond() - .getMergedStyle(skinParam().getCurrentStyleBuilder()); + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(currentStyleBuilder); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle(currentStyleBuilder); final HColor borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet()); final HColor diamondColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet()); final Rainbow arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java index 510a8df34..09e28adbc 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.ConditionStyle; public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { @@ -68,13 +69,13 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { @Override public Ftile createWhile(LinkRendering outColor, Swimlane swimlane, Ftile whileBlock, Display test, Display yes, - HColor color, Instruction specialOut, Ftile backward, LinkRendering incoming1, LinkRendering incoming2) { + HColor color, Instruction specialOut, Ftile backward, LinkRendering incoming1, LinkRendering incoming2, + StyleBuilder currentStyleBuilder) { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); - final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); - final Style styleDiamond = getDefaultStyleDefinitionDiamond() - .getMergedStyle(skinParam().getCurrentStyleBuilder()); + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(currentStyleBuilder); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle(currentStyleBuilder); final HColor borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet()); final HColor backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet()); final Rainbow arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java index fd6a1a7cb..924829dd3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java @@ -81,9 +81,9 @@ class FtileForkInner extends AbstractFtile { public static Set mergeSwimlanes(List tiles) { final Set result = new HashSet<>(); - for (Ftile tile : tiles) { + for (Ftile tile : tiles) result.addAll(tile.getSwimlanes()); - } + return Collections.unmodifiableSet(result); } @@ -105,9 +105,9 @@ class FtileForkInner extends AbstractFtile { for (Ftile ftile : forks) { final XDimension2D dim = ftile.calculateDimension(stringBounder); width += dim.getWidth(); - if (dim.getHeight() > height) { + if (dim.getHeight() > height) height = dim.getHeight(); - } + } final XDimension2D dimTotal = new XDimension2D(width, height); return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight()); @@ -116,9 +116,9 @@ class FtileForkInner extends AbstractFtile { public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) { double xpos = 0; for (Ftile ftile : forks) { - if (ftile == searched) { + if (ftile == searched) return UTranslate.dx(xpos); - } + final XDimension2D dim = ftile.calculateDimension(stringBounder); xpos += dim.getWidth(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index 053470efe..90ce41f44 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -85,7 +85,7 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { Ftile result = middle; final List conns = new ArrayList<>(); final Swimlane swimlaneBlack = in; - final Style style = getStyleSignature().getMergedStyle(skinParam().getCurrentStyleBuilder()); + final Style style = getStyleSignatureArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); final Ftile black = new FtileBlackBlock(skinParam(), swimlaneBlack); double x = 0; for (Ftile tmp : list99) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index 267511711..743936057 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -156,20 +156,21 @@ public class VCompactFactory implements FtileFactory { @Override public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, Ftile backward, boolean noOut, - LinkRendering incoming1, LinkRendering incoming2) { + LinkRendering incoming1, LinkRendering incoming2, StyleBuilder currentStyleBuilder) { return repeat; } @Override public Ftile createWhile(LinkRendering afterEndwhile, Swimlane swimlane, Ftile whileBlock, Display test, Display yes, HColor color, Instruction specialOut, Ftile back, LinkRendering incoming1, - LinkRendering incoming2) { + LinkRendering incoming2, StyleBuilder styleBuilder) { return whileBlock; } @Override public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, - LinkRendering topInlinkRendering, Url url, Collection notes) { + LinkRendering topInlinkRendering, Url url, Collection notes, Stereotype stereotype, + StyleBuilder currentStyleBuilder) { final List ftiles = new ArrayList<>(); for (Branch branch : thens) ftiles.add(branch.getFtile()); diff --git a/src/net/sourceforge/plantuml/board/BoardDiagram.java b/src/net/sourceforge/plantuml/board/BoardDiagram.java index 266c7cb8f..f7fc67e1b 100644 --- a/src/net/sourceforge/plantuml/board/BoardDiagram.java +++ b/src/net/sourceforge/plantuml/board/BoardDiagram.java @@ -73,11 +73,11 @@ public class BoardDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java index 2cbc3663e..c568879e4 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java +++ b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java @@ -194,7 +194,7 @@ public class BpmDiagram extends UmlDiagram { } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { throw new UnsupportedOperationException(); } } diff --git a/src/net/sourceforge/plantuml/chronology/ChronologyDiagram.java b/src/net/sourceforge/plantuml/chronology/ChronologyDiagram.java new file mode 100644 index 000000000..9731c3506 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/ChronologyDiagram.java @@ -0,0 +1,853 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; + +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.TitledDiagram; +import net.sourceforge.plantuml.WithSprite; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColorSet; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; +import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.project.GanttStyle; +import net.sourceforge.plantuml.project.LabelPosition; +import net.sourceforge.plantuml.project.LabelStrategy; +import net.sourceforge.plantuml.project.LoadPlanable; +import net.sourceforge.plantuml.project.TimeHeaderParameters; +import net.sourceforge.plantuml.project.ToTaskDraw; +import net.sourceforge.plantuml.project.core.PrintScale; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskCode; +import net.sourceforge.plantuml.project.core.TaskGroup; +import net.sourceforge.plantuml.project.draw.TaskDraw; +import net.sourceforge.plantuml.project.draw.TaskDrawDiamond; +import net.sourceforge.plantuml.project.draw.TimeHeader; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.timescale.TimeScale; +import net.sourceforge.plantuml.real.Real; +import net.sourceforge.plantuml.real.RealOrigin; +import net.sourceforge.plantuml.real.RealUtils; +import net.sourceforge.plantuml.skin.UmlDiagramType; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignatureBasic; + +public class ChronologyDiagram extends TitledDiagram implements ToTaskDraw, WithSprite, GanttStyle { + + private final Map draws = new LinkedHashMap(); + private final Map tasks = new LinkedHashMap(); + private final Map byShortName = new HashMap(); +// private final List constraints = new ArrayList<>(); + private final HColorSet colorSet = HColorSet.instance(); +// +// private final OpenClose openClose = new OpenClose(); +// +// private final Map resources = new LinkedHashMap(); +// private final Map colorDaysToday = new HashMap(); +// private final Map colorDaysInternal = new HashMap(); +// private final Map colorDaysOfWeek = new HashMap(); +// private final Map nameDays = new HashMap(); + private LabelStrategy labelStrategy = new LabelStrategy(LabelPosition.LEGACY, HorizontalAlignment.LEFT); +// +// // Let's follow ISO-8601 rules +// private WeekNumberStrategy weekNumberStrategy = new WeekNumberStrategy(DayOfWeek.MONDAY, 4); +// +// private PrintScale printScale = PrintScale.DAILY; +// private double factorScale = 1.0; + private Locale locale = Locale.ENGLISH; +// +// private Day today; +// private double totalHeightWithoutFooter; + private Day min; + private Day max; + private TimeScaleChronology timeScale; +// +// private Day printStart; +// private Day printEnd; +// + private final RealOrigin origin = RealUtils.createOrigin(); +// +// private int defaultCompletion = 100; +// +// private Task it; +// private Resource they; + + public CommandExecutionResult changeLanguage(String lang) { + this.locale = new Locale(lang); + return CommandExecutionResult.ok(); + } + + public DiagramDescription getDescription() { + return new DiagramDescription("(Chronology)"); + } + +// public void setWeekNumberStrategy(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) { +// this.weekNumberStrategy = new WeekNumberStrategy(firstDayOfWeek, minimalDaysInFirstWeek); +// } + + public ChronologyDiagram(UmlSource source) { + super(source, UmlDiagramType.CHRONOLOGY, null); + } + +// public final int getDpi(FileFormatOption fileFormatOption) { +// return 96; +// } + + @Override + protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) + throws IOException { + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); + } + +// public void setPrintScale(PrintScale printScale) { +// this.printScale = printScale; +// } +// +// public void setFactorScale(double factorScale) { +// this.factorScale = factorScale; +// } +// +// private double getFactorScale() { +// return this.printScale.getDefaultScale() * this.factorScale; +// } +// +// private boolean isHidden(Task task) { +// if (printStart == null || task instanceof TaskSeparator) +// return false; +// +// if (task.getEnd().compareTo(min) < 0) +// return true; +// +// if (task.getStart().compareTo(max) > 0) +// return true; +// +// return false; +// } +// +// @Override +// public String checkFinalError() { +// try { +// initMinMax(); +// } catch (ImpossibleSolvingException ex) { +// return ex.getMessage(); +// } +// return null; +// } + + @Override + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { + final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); + initMinMax(); + + final TimeHeader timeHeader = new TimeHeaderChronology(stringBounder, thParam(), PrintScale.DAILY, + this.timeScale); + initTaskAndResourceDraws(timeHeader.getTimeScale(), timeHeader.getFullHeaderHeight(stringBounder), + stringBounder); + + return new AbstractTextBlock() { + public XDimension2D calculateDimension(StringBounder stringBounder) { + return new XDimension2D(1000, 1000); + } + + @Override + public void drawU(UGraphic ug) { + timeHeader.drawTimeHeader(ug, 200); + drawTasksRect(ug); + drawTasksTitle(ug, 0, 0); + } + }; + + } + +// +// private double getTitlesColumnWidth(StringBounder stringBounder) { +// if (labelStrategy.titleInside()) +// return 0; +// +// double width = 0; +// for (Task task : tasks.values()) { +// if (isHidden(task)) +// continue; +// +// width = Math.max(width, draws.get(task).getTitleWidth(stringBounder)); +// } +// return width; +// } +// +// public XDimension2D calculateDimension(StringBounder stringBounder) { +// return new XDimension2D(getTitlesColumnWidth(stringBounder) + getBarsColumnWidth(timeHeader), +// getTotalHeight(stringBounder, timeHeader)); +// } +// +// private double getBarsColumnWidth(final TimeHeader timeHeader) { +// final double xmin = timeHeader.getTimeScale().getStartingPosition(min); +// final double xmax = timeHeader.getTimeScale().getEndingPosition(max); +// return xmax - xmin; +// } +// +// }; +// } +// +// private TimeHeader getTimeHeader(StringBounder stringBounder) { +// if (openClose.getStartingDay() == null) +// return new TimeHeaderSimple(stringBounder, thParam(), printScale); +// else if (printScale == PrintScale.DAILY) +// return new TimeHeaderDaily(stringBounder, thParam(), nameDays, printStart, printEnd); +// else if (printScale == PrintScale.WEEKLY) +// return new TimeHeaderWeekly(stringBounder, thParam(), weekNumberStrategy, withCalendarDate); +// else if (printScale == PrintScale.MONTHLY) +// return new TimeHeaderMonthly(stringBounder, thParam()); +// else if (printScale == PrintScale.QUARTERLY) +// return new TimeHeaderQuarterly(stringBounder, thParam()); +// else if (printScale == PrintScale.YEARLY) +// return new TimeHeaderYearly(stringBounder, thParam()); +// else +// throw new IllegalStateException(); +// +// } + + private TimeHeaderParameters thParam() { + return new TimeHeaderParameters(null, 1, min, max, getIHtmlColorSet(), locale, null, null, null, this); + } + +// private Map colorDays() { +// colorDaysInternal.putAll(colorDaysToday); +// return Collections.unmodifiableMap(colorDaysInternal); +// } + + @Override + public final Style getStyle(SName param) { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param) + .getMergedStyle(getCurrentStyleBuilder()); + } + + @Override + public final Style getStyle(SName param1, SName param2) { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param1, param2) + .getMergedStyle(getCurrentStyleBuilder()); + } + +// private double getTotalHeight(StringBounder stringBounder, TimeHeader timeHeader) { +// if (showFootbox) +// return totalHeightWithoutFooter + timeHeader.getTimeFooterHeight(stringBounder); +// +// return totalHeightWithoutFooter; +// } + + private void drawTasksRect(UGraphic ug) { + for (Task task : tasks.values()) { +// if (isHidden(task)) +// continue; + + final TaskDraw draw = draws.get(task); + final UTranslate move = UTranslate.dy(draw.getY(ug.getStringBounder()).getCurrentValue()); + draw.drawU(ug.apply(move)); + } + } + +// private void drawConstraints(final UGraphic ug, TimeScale timeScale) { +// for (GanttConstraint constraint : constraints) { +// if (printStart != null && constraint.isHidden(min, max)) +// continue; +// +// constraint.getUDrawable(timeScale, this).drawU(ug); +// } +// +// } +// +// public StyleSignatureBasic getDefaultStyleDefinitionArrow() { +// return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.arrow); +// } + + private void drawTasksTitle(UGraphic ug, double colTitles, double colBars) { + for (Task task : tasks.values()) { +// if (isHidden(task)) +// continue; + + final TaskDraw draw = draws.get(task); + final UTranslate move = UTranslate.dy(draw.getY(ug.getStringBounder()).getCurrentValue()); + draw.drawTitle(ug.apply(move), labelStrategy, colTitles, colBars); + } + } + +// private void drawResources(UGraphic ug) { +// for (Resource res : resources.values()) { +// final ResourceDraw draw = res.getResourceDraw(); +// final UTranslate move = UTranslate.dy(draw.getY()); +// draw.drawU(ug.apply(move)); +// } +// } +// +// public void closeDayOfWeek(DayOfWeek day, String task) { +// openClose.close(day); +// } +// +// public void openDayOfWeek(DayOfWeek day, String task) { +// if (task.length() == 0) +// openClose.open(day); +// else +// getOpenCloseForTask(task).open(day); +// } +// +// public void closeDayAsDate(Day day, String task) { +// if (task.length() == 0) +// openClose.close(day); +// else +// getOpenCloseForTask(task).close(day); +// +// } +// +// public void openDayAsDate(Day day, String task) { +// if (task.length() == 0) +// openClose.open(day); +// else +// getOpenCloseForTask(task).open(day); +// +// } +// +// private OpenClose getOpenCloseForTask(String task) { +// OpenClose except = openCloseForTask.get(task); +// if (except == null) { +// except = new OpenClose(); +// openCloseForTask.put(task, except); +// } +// return except; +// } +// +// private final Map openCloseForTask = new HashMap<>(); +// + private void initTaskAndResourceDraws(TimeScale timeScale, double headerHeight, StringBounder stringBounder) { + Real y = origin; + y = y.addFixed(headerHeight); + for (Task task : tasks.values()) { + final TaskDraw draw; + final String disp = task.getCode().getSimpleDisplay(); + draw = new TaskDrawDiamond(timeScale, y, disp, task.getStart(), task, this, task.getStyleBuilder()); + final double height = draw.getFullHeightTask(stringBounder); + y = y.addAtLeast(height); +// if (task instanceof TaskSeparator) { +// final TaskSeparator taskSeparator = (TaskSeparator) task; +// draw = new TaskDrawSeparator(taskSeparator.getName(), timeScale, y, min, max, task.getStyleBuilder(), +// getSkinParam().getIHtmlColorSet()); +// } else if (task instanceof TaskGroup) { +// final TaskGroup taskGroup = (TaskGroup) task; +// draw = new TaskDrawGroup(timeScale, y, taskGroup.getCode().getSimpleDisplay(), getStart(taskGroup), +// getEnd(taskGroup), task, this, task.getStyleBuilder()); +// } else { +// final TaskImpl tmp = (TaskImpl) task; +// final String disp = hideResourceName ? tmp.getCode().getSimpleDisplay() : tmp.getPrettyDisplay(); +// if (tmp.isDiamond()) { +// draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), task, this, task.getStyleBuilder()); +// } else { +// final boolean oddStart = printStart != null && min.compareTo(getStart(tmp)) == 0; +// final boolean oddEnd = printStart != null && max.compareTo(getEnd(tmp)) == 0; +// draw = new TaskDrawRegular(timeScale, y, disp, getStart(tmp), getEnd(tmp), oddStart, oddEnd, +// getSkinParam(), task, this, getConstraints(task), task.getStyleBuilder()); +// } +// draw.setColorsAndCompletion(tmp.getColors(), tmp.getCompletion(), tmp.getUrl(), tmp.getNote()); +// } +// if (task.getRow() == null) +// y = y.addAtLeast(draw.getFullHeightTask(stringBounder)); +// + draws.put(task, draw); + } +// origin.compileNow(); +// magicPush(stringBounder); +// double yy = lastY(stringBounder); +// if (yy == 0) { +// yy = headerHeight; +// } else if (this.hideResourceFoobox == false) +// for (Resource res : resources.values()) { +// final ResourceDraw draw = buildResourceDraw(this, res, timeScale, yy, min, max); +// res.setTaskDraw(draw); +// yy += draw.getHeight(stringBounder); +// } +// +// this.totalHeightWithoutFooter = yy; + } + +// +// private ResourceDraw buildResourceDraw(ChronologyDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, +// Day max) { +// return new ResourceDrawBasic(gantt, res, timeScale, y, min, max); +// // return new ResourceDrawVersion2(gantt, res, timeScale, y, min, max); +// } +// +// private Collection getConstraints(Task task) { +// final List result = new ArrayList<>(); +// for (GanttConstraint constraint : constraints) { +// if (constraint.isOn(task)) +// result.add(constraint); +// +// } +// return Collections.unmodifiableCollection(result); +// } +// +// private double lastY(StringBounder stringBounder) { +// double result = 0; +// for (TaskDraw td : draws.values()) +// result = Math.max(result, td.getY(stringBounder).getCurrentValue() + td.getHeightMax(stringBounder)); +// +// return result; +// } +// +// private void magicPush(StringBounder stringBounder) { +// final List notes = new ArrayList<>(); +// for (TaskDraw td : draws.values()) { +// final FingerPrint taskPrint = td.getFingerPrint(stringBounder); +// final FingerPrint fingerPrintNote = td.getFingerPrintNote(stringBounder); +// +// if (td.getTrueRow() == null) +// for (TaskDraw note : notes) { +// final FingerPrint otherNote = note.getFingerPrintNote(stringBounder); +// final double deltaY = otherNote.overlap(taskPrint); +// if (deltaY > 0) { +// final Real bottom = note.getY(stringBounder).addAtLeast(note.getHeightMax(stringBounder)); +// td.getY(stringBounder).ensureBiggerThan(bottom); +// origin.compileNow(); +// } +// +// } +// +// if (fingerPrintNote != null) +// notes.add(td); +// +// } +// } +// +// private Day getStart(final Task tmp) { +// if (printStart == null) +// return tmp.getStart(); +// +// return Day.max(min, tmp.getStart()); +// } +// +// private Day getEnd(final Task tmp) { +// if (printStart == null) +// return tmp.getEnd(); +// +// return Day.min(max, tmp.getEnd()); +// } +// + private void initMinMax() { + if (tasks.size() == 0) { + throw new IllegalStateException(); + } + for (Task task : tasks.values()) { + if (this.min == null || this.max == null) { + this.min = task.getStart(); + this.max = task.getEnd(); + continue; + + } + if (this.min.compareTo(task.getStart()) > 0) + this.min = task.getStart(); + if (this.max.compareTo(task.getEnd()) < 0) + this.max = task.getEnd(); + } + + this.min = this.min.roundDayDown(); + this.max = this.max.roundDayUp(); + + this.timeScale = new TimeScaleChronology(1000); + this.timeScale.setMin(this.min.getMillis()); + this.timeScale.setMax(this.max.getMillis()); + } + +// public Day getThenDate() { +// Day result = getStartingDate(); +// for (Day d : colorDays().keySet()) +// if (d.compareTo(result) > 0) +// result = d; +// +// for (Day d : nameDays.keySet()) +// if (d.compareTo(result) > 0) +// result = d; +// +// return result; +// } +// +// public Task getExistingTask(String id) { +// final Task result = byShortName.get(Objects.requireNonNull(id)); +// if (result != null) +// return result; +// +// final TaskCode code = new TaskCode(id); +// return tasks.get(code); +// } +// +// public GanttConstraint forceTaskOrder(Task task1, Task task2) { +// final TaskInstant end1 = new TaskInstant(task1, TaskAttribute.END); +// task2.setStart(end1.getInstantPrecise()); +// final GanttConstraint result = new GanttConstraint(this.getIHtmlColorSet(), +// getSkinParam().getCurrentStyleBuilder(), end1, new TaskInstant(task2, TaskAttribute.START)); +// addContraint(result); +// return result; +// } + + public Task getOrCreateTask(String codeOrShortName, String shortName, boolean linkedToPrevious) { + Objects.requireNonNull(codeOrShortName); + Task result = shortName == null ? null : byShortName.get(shortName); + if (result != null) + return result; + + result = byShortName.get(codeOrShortName); + if (result != null) + return result; + + final TaskCode code = new TaskCode(codeOrShortName); + result = tasks.get(code); + if (result == null) { + + result = new TaskChronology(getSkinParam().getCurrentStyleBuilder(), code); + if (currentGroup != null) + currentGroup.addTask(result); + + tasks.put(code, result); + if (byShortName != null) + byShortName.put(shortName, result); + + } + return result; + } + +// private Task getLastCreatedTask() { +// final List all = new ArrayList<>(tasks.values()); +// for (int i = all.size() - 1; i >= 0; i--) +// if (all.get(i) instanceof TaskImpl) +// return all.get(i); +// +// return null; +// } +// +// public void addSeparator(String comment) { +// TaskSeparator separator = new TaskSeparator(getSkinParam().getCurrentStyleBuilder(), comment, tasks.size()); +// tasks.put(separator.getCode(), separator); +// } +// + private TaskGroup currentGroup = null; +// +// public CommandExecutionResult addGroup(String name) { +// TaskGroup group = new TaskGroup(this.currentGroup, getSkinParam().getCurrentStyleBuilder(), name); +// +// if (this.currentGroup != null) +// this.currentGroup.addTask(group); +// +// this.currentGroup = group; +// tasks.put(group.getCode(), group); +// return CommandExecutionResult.ok(); +// } +// +// public CommandExecutionResult endGroup() { +// if (this.currentGroup == null) +// return CommandExecutionResult.error("No group to be closed"); +// +// this.currentGroup = this.currentGroup.getParent(); +// +// return CommandExecutionResult.ok(); +// } +// +// public void addContraint(GanttConstraint constraint) { +// constraints.add(constraint); +// } +// +// public HColorSet getIHtmlColorSet() { +// return colorSet; +// } +// +// public void setProjectStartingDate(Day start) { +// openClose.setStartingDay(start); +// this.min = start; +// } +// +// public Day getStartingDate() { +// if (openClose.getStartingDay() == null) +// return min; +// +// return openClose.getStartingDay(); +// } +// +// public Day getEndingDate() { +// initMinMax(); +// return max; +// } +// +// public int daysInWeek() { +// return openClose.daysInWeek(); +// } +// +// public boolean isOpen(Day day) { +// return openClose.getLoadAt(day) > 0; +// } +// +// public boolean affectResource(Task result, String description) { +// final Pattern p = Pattern.compile("([^:]+)(:(\\d+))?"); +// final Matcher m = p.matcher(description); +// if (m.find() == false) +// throw new IllegalArgumentException(); +// +// final Resource resource = getResource(m.group(1)); +// int percentage = 100; +// if (m.group(3) != null) +// percentage = Integer.parseInt(m.group(3)); +// +// if (percentage == 0) +// return false; +// +// result.addResource(resource, percentage); +// return true; +// } +// +// public Resource getResource(String resourceName) { +// Resource resource = resources.get(resourceName); +// if (resource == null) +// resource = new Resource(resourceName); +// +// resources.put(resourceName, resource); +// return resource; +// } +// +// public int getLoadForResource(Resource res, Day i) { +// int result = 0; +// for (Task task : tasks.values()) { +// if (task instanceof TaskSeparator) +// continue; +// +// final TaskImpl task2 = (TaskImpl) task; +// result += task2.loadForResource(res, i); +// } +// return result; +// } +// +// public Moment getExistingMoment(String id) { +// Moment result = getExistingTask(id); +// if (result == null) { +// Day start = null; +// Day end = null; +// for (Map.Entry ent : nameDays.entrySet()) { +// if (ent.getValue().equalsIgnoreCase(id) == false) +// continue; +// +// start = min(start, ent.getKey()); +// end = max(end, ent.getKey()); +// } +// if (start != null) +// result = new MomentImpl(start, end); +// +// } +// return result; +// } +// +// private Day min(Day d1, Day d2) { +// if (d1 == null) +// return d2; +// +// if (d1.compareTo(d2) > 0) +// return d2; +// +// return d1; +// } +// +// private Day max(Day d1, Day d2) { +// if (d1 == null) +// return d2; +// +// if (d1.compareTo(d2) < 0) +// return d2; +// +// return d1; +// } +// +// public void colorDay(Day day, HColor color) { +// colorDaysInternal.put(day, color); +// } +// +// public void colorDay(DayOfWeek day, HColor color) { +// colorDaysOfWeek.put(day, color); +// } +// +// public void nameDay(Day day, String name) { +// nameDays.put(day, name); +// } +// +// public Day getToday() { +// if (today == null) +// this.today = Day.today(); +// +// return today; +// } +// +// public void setTodayColors(CenterBorderColor colors) { +// if (today == null) +// this.today = Day.today(); +// +// colorDaysToday.put(today, colors.getCenter()); +// } +// +// public CommandExecutionResult setToday(Day date) { +// this.today = date; +// return CommandExecutionResult.ok(); +// } +// +// public CommandExecutionResult deleteTask(Task task) { +// task.setColors(new CenterBorderColor(HColors.WHITE, HColors.BLACK)); +// return CommandExecutionResult.ok(); +// } +// +// public void setPrintInterval(Day start, Day end) { +// this.printStart = start; +// this.printEnd = end; +// } +// +// public TaskDraw getTaskDraw(Task task) { +// return draws.get(task); +// } +// +// public CommandExecutionResult addNote(Display note) { +// Task last = null; +// for (Task current : tasks.values()) +// last = current; +// if (last == null) +// return CommandExecutionResult.error("No task defined"); +// +// last.setNote(note); +// return CommandExecutionResult.ok(); +// } + + public LoadPlanable getDefaultPlan() { + throw new UnsupportedOperationException(); + } + + @Override + public TaskDraw getTaskDraw(Task task) { + // TODO Auto-generated method stub + return null; + } + + @Override + public HColorSet getIHtmlColorSet() { + return colorSet; + } + +// private boolean showFootbox = true; +// +// public void setShowFootbox(boolean footbox) { +// this.showFootbox = footbox; +// +// } +// +// @Override +// public ClockwiseTopRightBottomLeft getDefaultMargins() { +// return ClockwiseTopRightBottomLeft.none(); +// } +// +// public void setLabelStrategy(LabelStrategy strategy) { +// this.labelStrategy = strategy; +// } +// +// private boolean withCalendarDate; +// +// public void setWithCalendarDate(boolean withCalendarDate) { +// this.withCalendarDate = withCalendarDate; +// } +// +// private boolean hideResourceName; +// private boolean hideResourceFoobox; +// +// public CommandExecutionResult hideResourceName() { +// this.hideResourceName = true; +// return CommandExecutionResult.ok(); +// } +// +// public CommandExecutionResult hideResourceFootbox() { +// this.hideResourceFoobox = true; +// return CommandExecutionResult.ok(); +// } +// +// private final Set verticalSeparatorBefore = new HashSet<>(); +// +// public void addVerticalSeparatorBefore(Day day) { +// verticalSeparatorBefore.add(day); +// } +// +// public void setTaskDefaultCompletion(int defaultCompletion) { +// this.defaultCompletion = defaultCompletion; +// } +// +// public List getAllTasksForResource(Resource res) { +// final List result = new ArrayList(); +// for (Task task : tasks.values()) +// if (task.isAssignedTo(res)) { +// final TaskDrawRegular draw = (TaskDrawRegular) draws.get(task); +// result.add(draw); +// } +// +// return Collections.unmodifiableList(result); +// } +// +// public void setIt(Task result) { +// this.it = result; +// } +// +// public Task getIt() { +// return it; +// } +// +// public final Resource getThey() { +// return they; +// } +// +// public final void setThey(Resource they) { +// this.they = they; +// } + +} diff --git a/src/net/sourceforge/plantuml/chronology/ChronologyDiagramFactory.java b/src/net/sourceforge/plantuml/chronology/ChronologyDiagramFactory.java new file mode 100644 index 000000000..063b908f9 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/ChronologyDiagramFactory.java @@ -0,0 +1,126 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.CommonCommands; +import net.sourceforge.plantuml.command.PSystemCommandFactory; +import net.sourceforge.plantuml.core.DiagramType; +import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.project.command.NaturalCommand; +import net.sourceforge.plantuml.project.lang.SentenceAnd; +import net.sourceforge.plantuml.project.lang.SentenceAndAnd; +import net.sourceforge.plantuml.project.lang.SentenceSimple; +import net.sourceforge.plantuml.project.lang.Subject; + +public class ChronologyDiagramFactory extends PSystemCommandFactory { + + static private final List> subjects() { + return Arrays.asList(SubjectTask.ME); + } + + public ChronologyDiagramFactory() { + super(DiagramType.CHRONOLOGY); + } + + @Override + protected void initCommandsList(List cmds) { + CommonCommands.addTitleCommands(cmds); + CommonCommands.addCommonCommands2(cmds); + +// cmds.add(CommandStyleMultilinesCSS.ME); +// cmds.add(CommandStyleImport.ME); +// +// cmds.add(CommandNope.ME); + + addLanguageCommands(cmds); + +// cmds.add(new CommandGanttArrow()); +// cmds.add(new CommandGanttArrow2()); +// cmds.add(new CommandColorTask()); +// cmds.add(new CommandSeparator()); +// cmds.add(new CommandWeekNumberStrategy()); +// cmds.add(new CommandGroupStart()); +// cmds.add(new CommandGroupEnd()); +// +// cmds.add(new CommandLanguage()); +// cmds.add(new CommandPrintScale()); +// cmds.add(new CommandPrintBetween()); +// cmds.add(new CommandNoteBottom()); +// cmds.add(new CommandFootbox()); +// cmds.add(new CommandLabelOnColumn()); +// cmds.add(new CommandHideResourceName()); +// cmds.add(new CommandHideResourceFootbox()); +// cmds.add(new CommandTaskCompleteDefault()); + } + + private void addLanguageCommands(List cmd) { + for (Subject subject : subjects()) + for (SentenceSimple sentenceA : subject.getSentences()) { + cmd.add(NaturalCommand.create(sentenceA)); + for (SentenceSimple sentenceB : subject.getSentences()) { + final String signatureA = sentenceA.getSignature(); + final String signatureB = sentenceB.getSignature(); + if (signatureA.equals(signatureB) == false) + cmd.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB))); + + } + } + + for (Subject subject : subjects()) + for (SentenceSimple sentenceA : subject.getSentences()) + for (SentenceSimple sentenceB : subject.getSentences()) + for (SentenceSimple sentenceC : subject.getSentences()) { + final String signatureA = sentenceA.getSignature(); + final String signatureB = sentenceB.getSignature(); + final String signatureC = sentenceC.getSignature(); + if (signatureA.equals(signatureB) == false && signatureA.equals(signatureC) == false + && signatureC.equals(signatureB) == false) + cmd.add(NaturalCommand + .create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC))); + } + } + + @Override + public ChronologyDiagram createEmptyDiagram(UmlSource source, Map skinParam) { + return new ChronologyDiagram(source); + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/ComplementAnything.java b/src/net/sourceforge/plantuml/chronology/ComplementAnything.java new file mode 100644 index 000000000..436232f47 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/ComplementAnything.java @@ -0,0 +1,54 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.lang.Something; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexResult; + +public class ComplementAnything implements Something { + + public IRegex toRegex(String suffix) { + return new RegexLeaf("ANYTHING" + suffix, "(.*?)"); + } + + public Failable getMe(ChronologyDiagram system, RegexResult arg, String suffix) { + final String value = arg.get("ANYTHING" + suffix, 0); + return Failable.ok(value); + } +} diff --git a/src/net/sourceforge/plantuml/chronology/ComplementHour.java b/src/net/sourceforge/plantuml/chronology/ComplementHour.java new file mode 100644 index 000000000..d45338571 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/ComplementHour.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.lang.Something; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOptional; +import net.sourceforge.plantuml.regex.RegexResult; + +public class ComplementHour implements Something { + + // [Task1] starts at 2023-11-28 15:41:21, ends at 2023-11-28 19:40:00 + + static private final SimpleDateFormat inputFormat; + static private final SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + static { + inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + inputFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + + } + + public IRegex toRegex(String suffix) { + return new RegexConcat( // + new RegexLeaf("TIME", "(\\d+-\\d+-\\d+ \\d+:\\d+:\\d+)"), // + new RegexOptional(new RegexLeaf("MS", "\\.(\\d+)")) // + ); // + } + + public Failable getMe(ChronologyDiagram system, RegexResult arg, String suffix) { + final String value = arg.get("TIME", 0); + System.err.println("value=" + value); + try { + final Date date = inputFormat.parse(value); + return Failable.ok(Day.create(date.getTime())); + } catch (ParseException e) { + e.printStackTrace(); + } + throw new IllegalStateException(); + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/HourPattern.java b/src/net/sourceforge/plantuml/chronology/HourPattern.java new file mode 100644 index 000000000..f34c49290 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/HourPattern.java @@ -0,0 +1,136 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.Month; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOr; +import net.sourceforge.plantuml.regex.RegexResult; + +public class HourPattern { + + private final String id; + private final String yearKeyA; + private final String yearKeyB; + private final String yearKeyC; + private final String monthKeyA; + private final String monthKeyB; + private final String monthKeyC; + private final String dayKeyA; + private final String dayKeyB; + private final String dayKeyC; + + public HourPattern(String id) { + this.id = id; + this.yearKeyA = "AYEAR" + id; + this.yearKeyB = "BYEAR" + id; + this.yearKeyC = "CYEAR" + id; + this.monthKeyA = "AMONTH" + id; + this.monthKeyB = "BMONTH" + id; + this.monthKeyC = "CMONTH" + id; + this.dayKeyA = "ADAY" + id; + this.dayKeyB = "BDAY" + id; + this.dayKeyC = "CDAY" + id; + } + + public IRegex toRegex() { + return new RegexOr(toRegexA_DD_MONTH_YYYY(), toRegexB_YYYY_MM_DD(), toRegexC_MONTH_DD_YYYY()); + } + + public Day getDay(RegexResult arg) { + if (arg.get(dayKeyA, 0) != null) + return resultA(arg); + + if (arg.get(dayKeyB, 0) != null) + return resultB(arg); + + if (arg.get(dayKeyC, 0) != null) + return resultC(arg); + return null; + } + + private IRegex toRegexA_DD_MONTH_YYYY() { + return new RegexConcat( // + new RegexLeaf(dayKeyA, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(monthKeyA, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(yearKeyA, "([\\d]{1,4})")); + } + + private Day resultA(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyA, 0)); + final String month = arg.get(monthKeyA, 0); + final int year = Integer.parseInt(arg.get(yearKeyA, 0)); + return Day.create(year, month, day); + } + + private IRegex toRegexB_YYYY_MM_DD() { + return new RegexConcat( // + new RegexLeaf(yearKeyB, "([\\d]{1,4})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(monthKeyB, "([\\d]{1,2})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(dayKeyB, "([\\d]{1,2})")); + } + + private Day resultB(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyB, 0)); + final int month = Integer.parseInt(arg.get(monthKeyB, 0)); + final int year = Integer.parseInt(arg.get(yearKeyB, 0)); + return Day.create(year, month, day); + } + + private IRegex toRegexC_MONTH_DD_YYYY() { + return new RegexConcat( // + new RegexLeaf(monthKeyC, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(dayKeyC, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(yearKeyC, "([\\d]{1,4})")); + } + + private Day resultC(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyC, 0)); + final String month = arg.get(monthKeyC, 0); + final int year = Integer.parseInt(arg.get(yearKeyC, 0)); + return Day.create(year, month, day); + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/SentenceHappensChronology.java b/src/net/sourceforge/plantuml/chronology/SentenceHappensChronology.java new file mode 100644 index 000000000..2cfb488db --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/SentenceHappensChronology.java @@ -0,0 +1,60 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.lang.SentenceSimple; +import net.sourceforge.plantuml.project.lang.Verbs; +import net.sourceforge.plantuml.project.lang.Words; +import net.sourceforge.plantuml.project.time.Day; + +public class SentenceHappensChronology extends SentenceSimple { + + public SentenceHappensChronology() { + super(SubjectTask.ME, Verbs.happens, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), new ComplementHour()); + } + + @Override + public CommandExecutionResult execute(ChronologyDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day start = (Day) complement; + task.setStart(start); + task.setEnd(start); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/SubjectTask.java b/src/net/sourceforge/plantuml/chronology/SubjectTask.java new file mode 100644 index 000000000..cd5eeb396 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/SubjectTask.java @@ -0,0 +1,92 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import java.util.Arrays; +import java.util.Collection; + +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.lang.SentenceSimple; +import net.sourceforge.plantuml.project.lang.Subject; +import net.sourceforge.plantuml.project.lang.Words; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOptional; +import net.sourceforge.plantuml.regex.RegexOr; +import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; + +public class SubjectTask implements Subject { + + public static final Subject ME = new SubjectTask(); + + private SubjectTask() { + } + + public Failable getMe(ChronologyDiagram chronology, RegexResult arg) { + final Task result; + + final String subject = arg.get("SUBJECT", 0); + final String shortName = arg.get("SHORTNAME", 0); + final String stereotype = arg.get("STEREOTYPE", 0); + + result = chronology.getOrCreateTask(subject, shortName, false); + + if (stereotype != null) + result.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); + + return Failable.ok(result); + } + + public Collection> getSentences() { + return Arrays.asList(new SentenceHappensChronology()); + } + + public IRegex toRegex() { + return new RegexOr( // + new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\]"), // + StereotypePattern.optional("STEREOTYPE"), // + new RegexOptional(new RegexConcat(// + Words.exactly(Words.AS), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("SHORTNAME", "\\[([^\\[\\]]+?)\\]"))) // + ); + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/TaskChronology.java b/src/net/sourceforge/plantuml/chronology/TaskChronology.java new file mode 100644 index 000000000..20d877c1e --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/TaskChronology.java @@ -0,0 +1,372 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.klimt.creole.Display; +import net.sourceforge.plantuml.project.Load; +import net.sourceforge.plantuml.project.core.AbstractTask; +import net.sourceforge.plantuml.project.core.Resource; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.core.TaskCode; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.DayOfWeek; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.url.Url; + +public class TaskChronology extends AbstractTask implements Task { + + private Display note; + + private Url url; + private CenterBorderColor[] colors; + + private Day start; + private Day end; + + public void setUrl(Url url) { + this.url = url; + } + + public TaskChronology(StyleBuilder styleBuilder, TaskCode code) { + super(styleBuilder, code); + } + + @Override + public void setStart(Day start) { + this.start = start; + + } + + @Override + public Day getStart() { + return this.start; + } + + @Override + public void setEnd(Day end) { + this.end = end; + } + + @Override + public Day getEnd() { + return this.end; + } + + @Override + public Load getLoad() { + throw new UnsupportedOperationException(); + } + + @Override + public void setLoad(Load load) { + throw new UnsupportedOperationException(); + } + + @Override + public void addResource(Resource resource, int percentage) { + throw new UnsupportedOperationException(); + } + + @Override + public void setDiamond(boolean diamond) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isDiamond() { + return false; + } + + @Override + public void setCompletion(int completion) { + throw new UnsupportedOperationException(); + } + + @Override + public void addPause(Day pause) { + throw new UnsupportedOperationException(); + } + + @Override + public void addPause(DayOfWeek pause) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isAssignedTo(Resource res) { + throw new UnsupportedOperationException(); + } + +// @Override +// public int getLoadAt(Day instant) { +// if (isPaused(instant)) +// return 0; +// +// LoadPlanable result = defaultPlan; +// if (resources.size() > 0) +// result = PlanUtils.multiply(defaultPlan, getResourcePlan()); +// +// return result.getLoadAt(instant); +// } +// +// private boolean isPaused(Day instant) { +// if (pausedDay.contains(instant)) +// return true; +// +// if (pausedDayOfWeek(instant)) +// return true; +// +// return false; +// } +// +// private boolean pausedDayOfWeek(Day instant) { +// for (DayOfWeek dayOfWeek : pausedDayOfWeek) +// if (instant.getDayOfWeek() == dayOfWeek) +// return true; +// +// return false; +// } +// +// public int loadForResource(Resource res, Day instant) { +// if (resources.keySet().contains(res) && instant.compareTo(getStart()) >= 0 +// && instant.compareTo(getEnd()) <= 0) { +// if (isPaused(instant)) +// return 0; +// +// if (res.isClosedAt(instant)) +// return 0; +// +// return resources.get(res); +// } +// return 0; +// } +// +// @Override +// public void addPause(Day pause) { +// this.pausedDay.add(pause); +// } +// +// @Override +// public void addPause(DayOfWeek pause) { +// this.pausedDayOfWeek.add(pause); +// } +// +// private LoadPlanable getResourcePlan() { +// if (resources.size() == 0) +// throw new IllegalStateException(); +// +// return new LoadPlanable() { +// public int getLoadAt(Day instant) { +// int result = 0; +// for (Map.Entry ent : resources.entrySet()) { +// final Resource res = ent.getKey(); +// if (res.isClosedAt(instant)) +// continue; +// +// final int percentage = ent.getValue(); +// result += percentage; +// } +// return result; +// } +// +// @Override +// public Day getLastDayIfAny() { +// return TaskChronology.this.getLastDayIfAny(); +// } +// }; +// } +// +// @Override +// public Day getLastDayIfAny() { +// Day result = null; +// +// for (Resource res : resources.keySet()) { +// if (res.getLastDayIfAny() == null) +// return null; +// +// if (result == null || result.compareTo(res.getLastDayIfAny()) < 0) +// result = res.getLastDayIfAny(); +// } +// +// return result; +// } +// +// public String getPrettyDisplay() { +// if (resources.size() > 0) { +// final StringBuilder result = new StringBuilder(getCode().getSimpleDisplay()); +// result.append(" "); +// for (Iterator> it = resources.entrySet().iterator(); it.hasNext();) { +// final Map.Entry ent = it.next(); +// result.append("{"); +// result.append(ent.getKey().getName()); +// final int percentage = ent.getValue(); +// if (percentage != 100) +// result.append(":" + percentage + "%"); +// +// result.append("}"); +// if (it.hasNext()) +// result.append(" "); +// +// } +// return result.toString(); +// } +// return getCode().getSimpleDisplay(); +// } +// +// @Override +// public String toString() { +// return getCode().toString(); +// } +// +// public String debug() { +// return "" + getStart() + " ---> " + getEnd() + " [" + getLoad() + "]"; +// } +// +// @Override +// public Day getStart() { +// Day result = (Day) solver.getData(TaskAttribute.START); +// if (diamond == false) +// while (getLoadAt(result) == 0) +// result = result.increment(); +// +// return result; +// } +// +// @Override +// public Day getEnd() { +// return (Day) solver.getData(TaskAttribute.END); +// } +// +// @Override +// public Load getLoad() { +// return (Load) solver.getData(TaskAttribute.LOAD); +// } +// +// @Override +// public void setLoad(Load load) { +// solver.setData(TaskAttribute.LOAD, load); +// } +// +// @Override +// public void setStart(Day start) { +// solver.setData(TaskAttribute.START, start); +// } +// +// @Override +// public void setEnd(Day end) { +// solver.setData(TaskAttribute.END, end); +// } + + @Override + public void setColors(CenterBorderColor... colors) { + this.colors = colors; + } + +// @Override +// public void addResource(Resource resource, int percentage) { +// this.resources.put(resource, percentage); +// } +// +// @Override +// public void setDiamond(boolean diamond) { +// this.diamond = diamond; +// } +// +// @Override +// public boolean isDiamond() { +// return this.diamond; +// } +// +// @Override +// public void setCompletion(int completion) { +// this.completion = completion; +// } +// +// public final Url getUrl() { +// return url; +// } +// +// public final CenterBorderColor getColors() { +// if (colors == null) +// return null; +// +// if (colors.length == 1) +// return colors[0]; +// +// return colors[0].unlinearTo(colors[1], completion); +// } +// +// public final int getCompletion() { +// return completion; +// } +// +// public final Collection getAllPaused() { +// final SortedSet result = new TreeSet<>(pausedDay); +// for (DayOfWeek dayOfWeek : pausedDayOfWeek) +// addAll(result, dayOfWeek); +// +// return Collections.unmodifiableCollection(result); +// } +// +// private void addAll(SortedSet result, DayOfWeek dayOfWeek) { +// final Day start = getStart(); +// final Day end = getEnd(); +// for (Day current = start; current.compareTo(end) <= 0; current = current.increment()) +// if (current.getDayOfWeek() == dayOfWeek) +// result.add(current); +// +// } + + @Override + public void setNote(Display note) { + this.note = note; + } + + public Display getNote() { + return note; + } + +// public LoadPlanable getDefaultPlan() { +// return defaultPlan; +// } +// +// @Override +// public boolean isAssignedTo(Resource res) { +// return resources.containsKey(res); +// } + +} diff --git a/src/net/sourceforge/plantuml/chronology/TimeHeaderChronology.java b/src/net/sourceforge/plantuml/chronology/TimeHeaderChronology.java new file mode 100644 index 000000000..fca77fb27 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/TimeHeaderChronology.java @@ -0,0 +1,197 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.creole.Display; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.font.UFont; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.shape.ULine; +import net.sourceforge.plantuml.klimt.sprite.SpriteContainerEmpty; +import net.sourceforge.plantuml.project.TimeHeaderParameters; +import net.sourceforge.plantuml.project.core.PrintScale; +import net.sourceforge.plantuml.project.draw.TimeHeader; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.timescale.TimeScale; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; + +public class TimeHeaderChronology extends TimeHeader { + + private final PrintScale printScale; + + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder) + getHeaderNameDayHeight(); + } + + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return h + 6; + } + + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return h + 6; + } + + private double getHeaderNameDayHeight() { + return 0; + } + + public TimeHeaderChronology(StringBounder stringBounder, TimeHeaderParameters thParam, PrintScale printScale, + TimeScaleChronology timeScale) { + super(thParam, timeScale); + this.printScale = printScale; + } + + private void drawSmallVlinesDay(UGraphic ug, TimeScale timeScale, double totalHeightWithoutFooter) { + ug = ug.apply(getLineColor()); + ug = ug.apply(UTranslate.dy(6)); + final ULine vbar = ULine.vline(totalHeightWithoutFooter + 2); + for (Day i = getMin(); i.compareTo(getMax().increment()) < 0; i = i.increment(printScale)) { + final double x1 = timeScale.getStartingPosition(i); + ug.apply(UTranslate.dx(x1)).draw(vbar); + } + } + + private void drawSimpleDayCounter(UGraphic ug, TimeScale timeScale) { + for (Day i = getMin(); i.compareTo(getMax().increment()) < 0; i = i.increment(printScale)) { + final UFont font = thParam.getStyle(SName.timeline, SName.day).getUFont(); + final FontConfiguration fontConfiguration = getFontConfiguration(font, false, openFontColor()); + final TextBlock num = Display.getWithNewlines(i.toStringShort(thParam.getLocale())) + .create(fontConfiguration, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + final double x1 = timeScale.getStartingPosition(i); + final double x2; + if (printScale == PrintScale.WEEKLY) + x2 = timeScale.getEndingPosition(i.addDays(6)); + else + x2 = timeScale.getEndingPosition(i); + final double width = num.calculateDimension(ug.getStringBounder()).getWidth(); + final double delta = (x2 - x1) - width; + if (i.compareTo(getMax().increment()) < 0) + num.drawU(ug.apply(UTranslate.dx(x1 + delta / 2))); + + } + } + + @Override + public void drawTimeHeader(UGraphic ug, double totalHeightWithoutFooter) { + // drawTextsBackground(ug.apply(UTranslate.dy(-3)), totalHeightWithoutFooter + + // 6); + final double xmin = getTimeScale().getStartingPosition(getMin()); + final double xmax = getTimeScale().getEndingPosition(getMax()); + drawSmallVlinesDay(ug, getTimeScale(), totalHeightWithoutFooter); + // printVerticalSeparators(ug, totalHeightWithoutFooter); + drawSimpleDayCounter(ug, getTimeScale()); + // ug = ug.apply(getLineColor()); + // ug.draw(ULine.hline(xmax - xmin)); + // ug.apply(UTranslate.dy(getFullHeaderHeight(ug.getStringBounder()) - + // 3)).draw(ULine.hline(xmax - xmin)); + + } + + @Override + public void drawTimeFooter(UGraphic ug) { + final double xmin = getTimeScale().getStartingPosition(getMin()); + final double xmax = getTimeScale().getEndingPosition(getMax()); + ug = ug.apply(UTranslate.dy(3)); + // drawSmallVlinesDay(ug, getTimeScale(), + // getTimeFooterHeight(ug.getStringBounder()) - 3); + drawSimpleDayCounter(ug, getTimeScale()); + // ug.apply(getLineColor()).draw(ULine.hline(xmax - xmin)); + } + + // Duplicate in TimeHeaderDaily + class Pending { + final double x1; + double x2; + final HColor color; + + Pending(HColor color, double x1, double x2) { + this.x1 = x1; + this.x2 = x2; + this.color = color; + } + + public void draw(UGraphic ug, double height) { + drawRectangle(ug.apply(color.bg()), height, x1, x2); + } + } + + protected final void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) { + + final double height = totalHeightWithoutFooter - getFullHeaderHeight(ug.getStringBounder()); + Pending pending = null; + + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { + final double x1 = getTimeScale().getStartingPosition(wink); + final double x2 = getTimeScale().getEndingPosition(wink); + HColor back = thParam.getColor(wink); +// // Day of week should be stronger than period of time (back color). +// final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek()); +// if (backDoW != null) { +// back = backDoW; +// } +// if (back == null && defaultPlan.getLoadAt(wink) == 0) { +// back = closedBackgroundColor(); +// } + if (back == null) { + if (pending != null) + pending.draw(ug, height); + pending = null; + } else { + if (pending != null && pending.color.equals(back) == false) { + pending.draw(ug, height); + pending = null; + } + if (pending == null) + pending = new Pending(back, x1, x2); + else + pending.x2 = x2; + + } + } + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/TimeScaleChronology.java b/src/net/sourceforge/plantuml/chronology/TimeScaleChronology.java new file mode 100644 index 000000000..b77f714cd --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/TimeScaleChronology.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.chronology; + +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.timescale.TimeScale; + +public class TimeScaleChronology implements TimeScale { + + private final double fullWidth; + private long min; + private long max; + + public TimeScaleChronology(double fullWidth) { + this.fullWidth = fullWidth; + } + + public double getStartingPosition(Day instant) { + final long wink = instant.getMillis(); + if (wink < min) + throw new IllegalArgumentException(); + if (wink > max) + throw new IllegalArgumentException(); + + return fullWidth * (wink - min) / (max - min); + } + + public double getEndingPosition(Day instant) { + return getStartingPosition(instant); + } + + public double getWidth(Day instant) { + throw new UnsupportedOperationException(); + } + + public boolean isBreaking(Day instant) { + throw new UnsupportedOperationException(); + } + + public final void setMin(long min) { + this.min = min; + } + + public final void setMax(long max) { + this.max = max; + } + +} diff --git a/src/net/sourceforge/plantuml/chronology/package-info.java b/src/net/sourceforge/plantuml/chronology/package-info.java new file mode 100644 index 000000000..297264f3b --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/package-info.java @@ -0,0 +1,9 @@ +/** + * Provides classes used to manage + * + * Chronology Diagram. + * + * @see net.sourceforge.plantuml.project + * + */ +package net.sourceforge.plantuml.chronology; diff --git a/src/net/sourceforge/plantuml/chronology/readme.md b/src/net/sourceforge/plantuml/chronology/readme.md new file mode 100644 index 000000000..59ffb89f4 --- /dev/null +++ b/src/net/sourceforge/plantuml/chronology/readme.md @@ -0,0 +1,10 @@ +# Directory Documentation for `chronology` + +## Description +This package provides classes used to manage [Chronology Diagram](https://plantuml.com/chronology-diagram). + +## Link +- [Chronology Diagram](https://plantuml.com/chronology-diagram) + +## Reference +- [Gantt Diagram](https://plantuml.com/gantt-diagram) diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 7f42d13f0..0b5c8cd73 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -101,9 +102,7 @@ public class CommandCreateClass extends SingleLineCommand2 { new RegexLeaf("GENERIC", "\\<(" + GenericRegexProducer.PATTERN + ")\\>"))), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 2ddf84b86..ac36c3685 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -65,6 +65,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; @@ -115,9 +116,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2"))), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -128,10 +127,16 @@ public class CommandCreateClassMultilines extends CommandMultilines2"))) // + )), // new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf("IMPLEMENTS", - "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // + "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"), + new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), + new RegexLeaf("\\<(" + GenericRegexProducer.PATTERN + ")\\>"))) // + )), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("\\{"), // RegexLeaf.spaceZeroOrMore(), // diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java index 906f0d877..cb1a677e8 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java @@ -53,11 +53,11 @@ import net.sourceforge.plantuml.klimt.font.FontParam; import net.sourceforge.plantuml.plasma.Quark; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; -import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -88,21 +88,14 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), // new RegexConcat(// new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.+\\>\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE2", CommandCreateElementFull.CODE)) // ), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -118,21 +111,14 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), // new RegexConcat(// new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.+\\>\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE2", CommandCreateElementFull.CODE)) // ), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java index d4b8686b5..4d762c4f8 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.LineLocation; public class CommandStereotype extends SingleLineCommand2 { @@ -60,7 +61,8 @@ public class CommandStereotype extends SingleLineCommand2 { RegexLeaf.start(), // new RegexLeaf("NAME", "([%pLN_.]+|[%g][^%g]+[%g])"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)"), RegexLeaf.end()); // + StereotypePattern.mandatory("STEREO"), // + RegexLeaf.end()); // } @Override diff --git a/src/net/sourceforge/plantuml/code/CompressionGZip.java b/src/net/sourceforge/plantuml/code/CompressionGZip.java new file mode 100644 index 000000000..0f87d56ef --- /dev/null +++ b/src/net/sourceforge/plantuml/code/CompressionGZip.java @@ -0,0 +1,71 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.code; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.zip.GZIPInputStream; + +public class CompressionGZip implements Compression { + // ::remove file when __CORE__ + + public byte[] compress(byte[] in) { + throw new UnsupportedOperationException(); + } + + public ByteArray decompress(byte[] input) throws NoPlantumlCompressionException { + try { + try (final GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(input))) { + final byte[] buffer = new byte[10_000]; + + try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + int len; + while ((len = gzip.read(buffer)) > 0) { + baos.write(buffer, 0, len); + if (baos.size() > 200_000) + throw new NoPlantumlCompressionException("Gzip error"); + } + return ByteArray.from(baos.toByteArray()); + } + } + } catch (IOException e) { + throw new NoPlantumlCompressionException(e); + } + + } + +} diff --git a/src/net/sourceforge/plantuml/code/TranscoderSmart.java b/src/net/sourceforge/plantuml/code/TranscoderSmart.java index 072bbd27c..dbf5a2bb2 100644 --- a/src/net/sourceforge/plantuml/code/TranscoderSmart.java +++ b/src/net/sourceforge/plantuml/code/TranscoderSmart.java @@ -49,6 +49,8 @@ public class TranscoderSmart implements Transcoder { new CompressionHuffman()); private final Transcoder zip = TranscoderImpl.utf8(new AsciiEncoder(), new ArobaseStringCompressor(), new CompressionZip()); + private final Transcoder gzip = TranscoderImpl.utf8(new AsciiEncoder(), new ArobaseStringCompressor(), + new CompressionGZip()); // ::done public String decode(String code) throws NoPlantumlCompressionException { @@ -66,6 +68,9 @@ public class TranscoderSmart implements Transcoder { if (code.startsWith("~h")) return hexOnly.decode(code.substring(2)); + if (code.startsWith("~g")) + return gzip.decode(code.substring(2)); + // ::comment when __CORE__ if (code.startsWith("~zip~")) return zip.decode(code.substring(5)); diff --git a/src/net/sourceforge/plantuml/code/TranscoderSmartProtected.java b/src/net/sourceforge/plantuml/code/TranscoderSmartProtected.java index f0b2dc7ca..61aefd6df 100644 --- a/src/net/sourceforge/plantuml/code/TranscoderSmartProtected.java +++ b/src/net/sourceforge/plantuml/code/TranscoderSmartProtected.java @@ -49,6 +49,8 @@ public class TranscoderSmartProtected implements Transcoder { new CompressionNone()); private final Transcoder zip = TranscoderImpl.utf8(new AsciiEncoder(), new ArobaseStringCompressor(), new CompressionZip()); + private final Transcoder gzip = TranscoderImpl.utf8(new AsciiEncoder(), new ArobaseStringCompressor(), + new CompressionGZip()); public String decode(String code) throws NoPlantumlCompressionException { // Work in progress @@ -63,6 +65,9 @@ public class TranscoderSmartProtected implements Transcoder { if (code.startsWith("~h")) return hexOnly.decode(code.substring(2)); + if (code.startsWith("~g")) + return gzip.decode(code.substring(2)); + if (code.startsWith("~zip~")) return zip.decode(code.substring(5)); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 67cf02b22..9404cd513 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -68,9 +69,7 @@ public class CommandNamespace extends SingleLineCommand2 { new RegexLeaf("namespace"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", NAMESPACE_REGEX), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java index 768b1a181..f32845c77 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace2.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -72,9 +73,7 @@ public class CommandNamespace2 extends SingleLineCommand2 { RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", CommandNamespace.NAMESPACE_REGEX), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java index 6e9e9c81b..00a0ab641 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -64,9 +65,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2 { new RegexLeaf("namespace"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", CommandNamespace.NAMESPACE_REGEX), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index d0d64c477..934bd4020 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -80,9 +81,7 @@ public class CommandPackage extends SingleLineCommand2 { )), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java index 65a763e9b..bc89bf64a 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.BlocLines; import net.sourceforge.plantuml.utils.LineLocation; @@ -70,9 +71,7 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // ColorParser.exp1(), // RegexLeaf.end() // ); @@ -91,9 +90,7 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // ColorParser.exp1(), // RegexLeaf.end() // ); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java index 363f8809e..f3d7f37ea 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java @@ -63,6 +63,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -92,9 +93,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma new RegexLeaf("")), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // @@ -127,9 +126,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma new RegexLeaf("")), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // @@ -153,9 +150,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma new RegexLeaf("")), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java index bdfac6571..edfb84034 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -89,9 +90,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman partialPattern, // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // @@ -112,9 +111,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman partialPattern, // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java index ccbbfb5ad..a93e0bafe 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -70,13 +71,9 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("ACROSS", "(accross|across)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -89,13 +86,9 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("ACROSS", "(accross|across)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java index fb6a746fb..c5a0d4596 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -66,7 +67,7 @@ import net.sourceforge.plantuml.utils.BlocLines; import net.sourceforge.plantuml.utils.LineLocation; public final class FactorySequenceNoteCommand implements SingleMultiFactoryCommand { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private IRegex getRegexConcatMultiLine() { return RegexConcat.build(FactorySequenceNoteCommand.class.getName() + "multi", RegexLeaf.start(), // @@ -74,15 +75,11 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("POSITION", "(right|left|over)"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("PARTICIPANT", "(?:of[%s]+)?([%pLN_.@]+|[%g][^%g]+[%g])"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -95,15 +92,11 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("POSITION", "(right|left|over)"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("PARTICIPANT", "(?:of[%s])?([%pLN_.@]+|[%g][^%g]+[%g])"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index f886d749f..556b146da 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -72,13 +73,9 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto return RegexConcat.build(FactorySequenceNoteOnArrowCommand.class.getName() + "multi", RegexLeaf.start(), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("POSITION", "(right|left|bottom|top)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // ColorParser.exp1(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -89,13 +86,9 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto return RegexConcat.build(FactorySequenceNoteOnArrowCommand.class.getName() + "single", RegexLeaf.start(), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("POSITION", "(right|left|bottom|top)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // ColorParser.exp1(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index 52154e96e..a2ceee953 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ColorParam; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -72,9 +73,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("over"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("P1", "([%pLN_.@]+|[%g][^%g]+[%g])"), // @@ -82,9 +81,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF new RegexLeaf(","), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // @@ -98,9 +95,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF new RegexLeaf("VMERGE", "(/)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO1"), // new RegexLeaf("over"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("P1", "([%pLN_.@]+|[%g][^%g]+[%g])"), // @@ -108,9 +103,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF new RegexLeaf(","), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO2"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/core/Diagram.java b/src/net/sourceforge/plantuml/core/Diagram.java index 368d0b926..18ce748ff 100644 --- a/src/net/sourceforge/plantuml/core/Diagram.java +++ b/src/net/sourceforge/plantuml/core/Diagram.java @@ -68,7 +68,7 @@ public interface Diagram { */ ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException; - void exportDiagramGraphic(UGraphic ug); + void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormat); /** * Number of images in this diagram (usually, 1) diff --git a/src/net/sourceforge/plantuml/core/DiagramType.java b/src/net/sourceforge/plantuml/core/DiagramType.java index 3b6ae6270..24a92b7e3 100644 --- a/src/net/sourceforge/plantuml/core/DiagramType.java +++ b/src/net/sourceforge/plantuml/core/DiagramType.java @@ -38,9 +38,9 @@ package net.sourceforge.plantuml.core; import net.sourceforge.plantuml.utils.StartUtils; public enum DiagramType { - // ::remove folder when __HAXE__ - UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, MATH, LATEX, DEFINITION, GANTT, NW, - MINDMAP, WBS, WIRE, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES, CHEN_EER, UNKNOWN; + // ::remove folder when __HAXE__ + UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, MATH, LATEX, DEFINITION, GANTT, CHRONOLOGY, NW, MINDMAP, + WBS, WIRE, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES, CHEN_EER, UNKNOWN; static public DiagramType getTypeFromArobaseStart(String s) { s = s.toLowerCase(); @@ -59,7 +59,8 @@ public enum DiagramType { if (StartUtils.startsWithSymbolAnd("startdot", s)) return DOT; - // ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or __LGPL__ + // ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or + // __LGPL__ if (StartUtils.startsWithSymbolAnd("startjcckit", s)) return JCCKIT; // ::done @@ -126,9 +127,6 @@ public enum DiagramType { if (StartUtils.startsWithSymbolAnd("startfiles", s)) return FILES; - if (StartUtils.startsWithSymbolAnd("startchen", s)) - return CHEN_EER; - return UNKNOWN; } } diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java index 97b5ccc7b..0dacdc5ef 100755 --- a/src/net/sourceforge/plantuml/core/UmlSource.java +++ b/src/net/sourceforge/plantuml/core/UmlSource.java @@ -158,7 +158,10 @@ final public class UmlSource { // return Collections.unmodifiableCollection(rawSource).iterator(); // } - + /** + * @deprecated Use {@link #getPlainString(String)} instead, + * like getPlainString("\n") + */ @Deprecated() public String getPlainString() { return getPlainString("\n"); diff --git a/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java b/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java index 6f4328614..c3248e6b6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java +++ b/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.EnumMap; import java.util.Map; +import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; @@ -96,7 +97,8 @@ public class DisplaySection { return null; if (style != null) - return style.createTextBlockBordered(display, spriteContainer.getIHtmlColorSet(), spriteContainer, null); + return style.createTextBlockBordered(display, spriteContainer.getIHtmlColorSet(), spriteContainer, null, + LineBreakStrategy.NONE); return display.create(fontConfiguration, getHorizontalAlignment(), spriteContainer); } diff --git a/src/net/sourceforge/plantuml/decoration/symbol/USymbolAction.java b/src/net/sourceforge/plantuml/decoration/symbol/USymbolAction.java new file mode 100644 index 000000000..7ee042799 --- /dev/null +++ b/src/net/sourceforge/plantuml/decoration/symbol/USymbolAction.java @@ -0,0 +1,145 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.decoration.symbol; + +import net.sourceforge.plantuml.klimt.Fashion; +import net.sourceforge.plantuml.klimt.Shadowable; +import net.sourceforge.plantuml.klimt.UPath; +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.drawing.UGraphicStencil; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; +import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.shape.TextBlockUtils; +import net.sourceforge.plantuml.klimt.shape.UPolygon; +import net.sourceforge.plantuml.klimt.shape.URectangle; +import net.sourceforge.plantuml.style.SName; + +class USymbolAction extends USymbol { + + private final SName sname; + + public USymbolAction(SName sname) { + this.sname = sname; + } + + @Override + public SName getSName() { + return sname; + } + + private void drawAction(UGraphic ug, double width, double height, double shadowing, double roundCorner, + double diagonalCorner) { + final UPolygon shape = new UPolygon(); + shape.addPoint(0, 0); + shape.addPoint(width - 10, 0); + shape.addPoint(width, height / 2); + shape.addPoint(width - 10, height); + shape.addPoint(0, height); + ug.draw(shape); + } + + private Margin getMargin() { + return new Margin(10, 20, 10, 10); + } + + @Override + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, + final Fashion symbolContext, final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + final XDimension2D dim = calculateDimension(ug.getStringBounder()); + ug = UGraphicStencil.create(ug, dim); + ug = symbolContext.apply(ug); + drawAction(ug, dim.getWidth(), dim.getHeight(), symbolContext.getDeltaShadow(), + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); + final Margin margin = getMargin(); + final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereoAlignment); + tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1()))); + } + + public XDimension2D calculateDimension(StringBounder stringBounder) { + final XDimension2D dimLabel = label.calculateDimension(stringBounder); + final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); + } + }; + } + + private double getHTitle(XDimension2D dimTitle) { + final double htitle; + if (dimTitle.getWidth() == 0) + htitle = 10; + else + htitle = dimTitle.getHeight(); + + return htitle; + } + + + + @Override + public TextBlock asBig(final TextBlock title, final HorizontalAlignment labelAlignment, final TextBlock stereotype, + final double width, final double height, final Fashion symbolContext, + final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D dim = calculateDimension(stringBounder); + ug = symbolContext.apply(ug); + final XDimension2D dimTitle = title.calculateDimension(stringBounder); + drawAction(ug, dim.getWidth(), dim.getHeight(), symbolContext.getDeltaShadow(), + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); + final double posTitle = (width - dimTitle.getWidth()) / 2; + title.drawU(ug.apply(new UTranslate(posTitle, 2))); + final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); + final double posStereo = (width - dimStereo.getWidth()) / 2; + + stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getHTitle(dimTitle)))); + } + + public XDimension2D calculateDimension(StringBounder stringBounder) { + return new XDimension2D(width, height); + } + }; + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/decoration/symbol/USymbolProcess.java b/src/net/sourceforge/plantuml/decoration/symbol/USymbolProcess.java new file mode 100644 index 000000000..e8bcb9315 --- /dev/null +++ b/src/net/sourceforge/plantuml/decoration/symbol/USymbolProcess.java @@ -0,0 +1,144 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.decoration.symbol; + +import net.sourceforge.plantuml.klimt.Fashion; +import net.sourceforge.plantuml.klimt.Shadowable; +import net.sourceforge.plantuml.klimt.UPath; +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.drawing.UGraphicStencil; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; +import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.shape.TextBlockUtils; +import net.sourceforge.plantuml.klimt.shape.UPolygon; +import net.sourceforge.plantuml.klimt.shape.URectangle; +import net.sourceforge.plantuml.style.SName; + +class USymbolProcess extends USymbol { + + private final SName sname; + + public USymbolProcess(SName sname) { + this.sname = sname; + } + + @Override + public SName getSName() { + return sname; + } + + private void drawProcess(UGraphic ug, double width, double height, double shadowing, double roundCorner, + double diagonalCorner) { + final UPolygon shape = new UPolygon(); + shape.addPoint(0, 0); + shape.addPoint(width - 10, 0); + shape.addPoint(width, height / 2); + shape.addPoint(width - 10, height); + shape.addPoint(0, height); + shape.addPoint(10, height / 2); + ug.draw(shape); + } + + private Margin getMargin() { + return new Margin(20, 20, 10, 10); + } + + @Override + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, + final Fashion symbolContext, final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + final XDimension2D dim = calculateDimension(ug.getStringBounder()); + ug = UGraphicStencil.create(ug, dim); + ug = symbolContext.apply(ug); + drawProcess(ug, dim.getWidth(), dim.getHeight(), symbolContext.getDeltaShadow(), + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); + final Margin margin = getMargin(); + final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereoAlignment); + tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1()))); + } + + public XDimension2D calculateDimension(StringBounder stringBounder) { + final XDimension2D dimLabel = label.calculateDimension(stringBounder); + final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); + return getMargin().addDimension(dimStereo.mergeTB(dimLabel)); + } + }; + } + + private double getHTitle(XDimension2D dimTitle) { + final double htitle; + if (dimTitle.getWidth() == 0) + htitle = 10; + else + htitle = dimTitle.getHeight(); + + return htitle; + } + + @Override + public TextBlock asBig(final TextBlock title, final HorizontalAlignment labelAlignment, final TextBlock stereotype, + final double width, final double height, final Fashion symbolContext, + final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D dim = calculateDimension(stringBounder); + ug = symbolContext.apply(ug); + final XDimension2D dimTitle = title.calculateDimension(stringBounder); + drawProcess(ug, dim.getWidth(), dim.getHeight(), symbolContext.getDeltaShadow(), + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); + final double posTitle = (width - dimTitle.getWidth()) / 2; + title.drawU(ug.apply(new UTranslate(posTitle, 2))); + final XDimension2D dimStereo = stereotype.calculateDimension(stringBounder); + final double posStereo = (width - dimStereo.getWidth()) / 2; + + stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getHTitle(dimTitle)))); + } + + public XDimension2D calculateDimension(StringBounder stringBounder) { + return new XDimension2D(width, height); + } + }; + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/decoration/symbol/USymbols.java b/src/net/sourceforge/plantuml/decoration/symbol/USymbols.java index b2f64a4a2..98758878f 100644 --- a/src/net/sourceforge/plantuml/decoration/symbol/USymbols.java +++ b/src/net/sourceforge/plantuml/decoration/symbol/USymbols.java @@ -70,6 +70,8 @@ public abstract class USymbols { public final static USymbol FOLDER = record("FOLDER", new USymbolFolder(SName.folder, false)); public final static USymbol FILE = record("FILE", new USymbolFile()); public final static USymbol RECTANGLE = record("RECTANGLE", new USymbolRectangle(SName.rectangle)); + public final static USymbol ACTION = record("ACTION", new USymbolAction(SName.action)); + public final static USymbol PROCESS = record("PROCESS", new USymbolProcess(SName.process)); public final static USymbol HEXAGON = record("HEXAGON", new USymbolHexagon()); public final static USymbol PERSON = record("PERSON", new USymbolPerson()); public final static USymbol LABEL = record("LABEL", new USymbolLabel()); @@ -142,6 +144,10 @@ public abstract class USymbols { usymbol = USymbols.FRAME; else if (symbol.equalsIgnoreCase("cloud")) usymbol = USymbols.CLOUD; + else if (symbol.equalsIgnoreCase("action")) + usymbol = USymbols.ACTION; + else if (symbol.equalsIgnoreCase("process")) + usymbol = USymbols.PROCESS; else if (symbol.equalsIgnoreCase("database")) usymbol = USymbols.DATABASE; else if (symbol.equalsIgnoreCase("queue")) diff --git a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java index 10e4f354c..43864b44d 100644 --- a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -73,11 +74,11 @@ public class CommandCreateDomain extends SingleLineCommand2 new RegexLeaf("DISPLAY", DISPLAY_WITH_GENERIC), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("as"), // - RegexLeaf.spaceOneOrMore(), new RegexLeaf("CODE", "([a-zA-Z0-9]+)"), RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("CODE", "([a-zA-Z0-9]+)"), // + StereotypePattern.optional("STEREO"), // // domain: lexical, causal, biddable // requirement: FR, NFR, quality - RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("GROUP", "(\\{)?"), RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java index 7bc02b008..cfa09179c 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.LineLocation; public class CommandArchimate extends SingleLineCommand2 { @@ -74,44 +75,25 @@ public class CommandArchimate extends SingleLineCommand2 { new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), // new RegexConcat(// new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE2", "(?:\\<\\<([-\\w]+)\\>\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optionalArchimate("STEREOTYPE2"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE2", CommandCreateElementFull.CODE)), // new RegexConcat(// new RegexLeaf("CODE3", CommandCreateElementFull.CODE), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE3", "(?:\\<\\<([-\\w]+)\\>\\>)") // - )), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optionalArchimate("STEREOTYPE3"), // new RegexLeaf("as"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("DISPLAY3", CommandCreateElementFull.DISPLAY)), // new RegexConcat(// new RegexLeaf("DISPLAY4", CommandCreateElementFull.DISPLAY_WITHOUT_QUOTE), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE4", "(?:\\<\\<([-\\w]+)\\>\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optionalArchimate("STEREOTYPE4"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE4", CommandCreateElementFull.CODE)) // ), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(?:\\<\\<([-\\w]+)\\>\\>)") // - )), RegexLeaf.end()); + StereotypePattern.optionalArchimate("STEREOTYPE"), // + RegexLeaf.end()); } private static ColorParser color() { @@ -134,7 +116,7 @@ public class CommandArchimate extends SingleLineCommand2 { entity = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(display), LeafType.DESCRIPTION, USymbols.ARCHIMATE); - final String icon = arg.getLazzy("STEREOTYPE", 0); + final String icon = StereotypePattern.removeChevronBrackets(arg.getLazzy("STEREOTYPE", 0)); entity.setDisplay(Display.getWithNewlines(display)); entity.setUSymbol(USymbols.ARCHIMATE); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java index 11cccd9bc..5aa5f5012 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.utils.BlocLines; @@ -77,13 +78,7 @@ public class CommandArchimateMultilines extends CommandMultilines2\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optionalArchimate("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // @@ -108,7 +103,7 @@ public class CommandArchimateMultilines extends CommandMultilines2 { - public static final String ALL_TYPES = "person|artifact|actor/|actor|folder|card|file|package|rectangle|hexagon|label|node|frame|cloud|database|queue|stack|storage|agent|usecase/|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; + public static final String ALL_TYPES = "person|artifact|actor/|actor|folder|card|file|package|rectangle|hexagon|label|node|frame|cloud|action|process|database|queue|stack|storage|agent|usecase/|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; public CommandCreateElementFull() { super(getRegexConcat()); @@ -84,43 +84,26 @@ public class CommandCreateElementFull extends SingleLineCommand2\\>)")// - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE2", CODE)), // new RegexConcat(// new RegexLeaf("CODE3", CODE), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE3", "(\\<\\<.+\\>\\>)") // - )), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optional("STEREOTYPE3"), // new RegexLeaf("as"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("DISPLAY3", DISPLAY)), // new RegexConcat(// new RegexLeaf("DISPLAY4", DISPLAY_WITHOUT_QUOTE), // - new RegexOptional( // - new RegexConcat( // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE4", "(\\<\\<.+\\>\\>)") // - )), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE4"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE4", CODE)) // ), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java index 3dc3a4665..eeba727d1 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -93,9 +94,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // @@ -110,9 +109,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index b607964eb..bbc59b124 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.ActorStyle; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.Direction; import net.sourceforge.plantuml.utils.LineLocation; @@ -104,9 +105,7 @@ public class CommandLinkElement extends SingleLineCommand2 { // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index 92a2e931a..bbe8fc65c 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -71,7 +72,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/ditaa/package-info.java b/src/net/sourceforge/plantuml/ditaa/package-info.java index c2cbdbd4c..f0a3a50f5 100644 --- a/src/net/sourceforge/plantuml/ditaa/package-info.java +++ b/src/net/sourceforge/plantuml/ditaa/package-info.java @@ -3,7 +3,9 @@ * * Ditaa Diagram. * + * @see org.stathissideris.ascii2image.core * @see org.stathissideris.ascii2image.graphics + * @see org.stathissideris.ascii2image.text * */ package net.sourceforge.plantuml.ditaa; diff --git a/src/net/sourceforge/plantuml/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/dot/GraphvizUtils.java index 803023cbc..23261f328 100644 --- a/src/net/sourceforge/plantuml/dot/GraphvizUtils.java +++ b/src/net/sourceforge/plantuml/dot/GraphvizUtils.java @@ -197,7 +197,7 @@ public class GraphvizUtils { if (s == null) return -1; - final Pattern p = Pattern.compile("\\s(\\d)\\.(\\d\\d?)\\D"); + final Pattern p = Pattern.compile("\\s(\\d+)\\.(\\d\\d?)\\D"); final Matcher m = p.matcher(s); if (m.find() == false) return -1; diff --git a/src/net/sourceforge/plantuml/dot/GraphvizVersionFinder.java b/src/net/sourceforge/plantuml/dot/GraphvizVersionFinder.java index 8a58e7b25..706bb5f0a 100644 --- a/src/net/sourceforge/plantuml/dot/GraphvizVersionFinder.java +++ b/src/net/sourceforge/plantuml/dot/GraphvizVersionFinder.java @@ -73,7 +73,7 @@ public class GraphvizVersionFinder { public GraphvizVersion getVersion() { final String dotVersion = dotVersion(); - final Pattern p = Pattern.compile("(\\d)\\.(\\d\\d?)"); + final Pattern p = Pattern.compile("(\\d+)\\.(\\d\\d?)"); final Matcher m = p.matcher(dotVersion); final boolean find = m.find(); if (find == false) diff --git a/src/net/sourceforge/plantuml/ebnf/ETileLookAheadOrBehind.java b/src/net/sourceforge/plantuml/ebnf/ETileLookAheadOrBehind.java new file mode 100644 index 000000000..23a046faf --- /dev/null +++ b/src/net/sourceforge/plantuml/ebnf/ETileLookAheadOrBehind.java @@ -0,0 +1,110 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.ebnf; + +import net.sourceforge.plantuml.klimt.UStroke; +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.color.HColorSet; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; +import net.sourceforge.plantuml.klimt.shape.URectangle; +import net.sourceforge.plantuml.klimt.shape.UText; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; + +public class ETileLookAheadOrBehind extends ETile { + + private final ETile orig; + private final HColorSet colorSet; + private final double deltax1 = 4; + private final double deltax2 = 8; + private final double deltay = 6; + private final Style style; + private final UText supText; + + private final FontConfiguration fc; + + public ETileLookAheadOrBehind(ETile orig, FontConfiguration fc, Style style, HColorSet colorSet, String type) { + this.style = style; + this.orig = orig; + this.fc = fc; + this.colorSet = colorSet; + this.supText = UText.build(type, fc); + + } + + @Override + public double getH1(StringBounder stringBounder) { + return deltay + orig.getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + return orig.getH2(stringBounder) + deltay; + } + + @Override + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + deltax1 + deltax2 + supText.calculateDimension(stringBounder).getWidth(); + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D dim = calculateDimension(stringBounder); + + final HColor lineColor = style.value(PName.LineColor).asColor(colorSet); + + final URectangle rect = URectangle.build(dim).rounded(30); + + ug.apply(lineColor).apply(new UStroke(2, 3, 1)).draw(rect); + final double posText = getH1(stringBounder) + supText.getDescent(stringBounder); + + ug.apply(new UTranslate(4, 2 + posText)).draw(supText); + + orig.drawU(ug.apply(new UTranslate(deltax1 + supText.calculateDimension(stringBounder).getWidth(), deltay))); + + } + + @Override + public void push(ETile tile) { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/ebnf/ETileNamedGroup.java b/src/net/sourceforge/plantuml/ebnf/ETileNamedGroup.java new file mode 100644 index 000000000..60927fa4c --- /dev/null +++ b/src/net/sourceforge/plantuml/ebnf/ETileNamedGroup.java @@ -0,0 +1,143 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.ebnf; + +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.color.HColorSet; +import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; +import net.sourceforge.plantuml.klimt.shape.URectangle; +import net.sourceforge.plantuml.klimt.shape.UText; +import net.sourceforge.plantuml.style.ISkinParam; + +public class ETileNamedGroup extends ETile { + + private final ETile orig; + private final ISkinParam skinParam; + private String commentAbove; + private String commentBelow; + private final HColorSet colorSet; + private final double deltax = 10; + private final double deltay1 = 10; + private final double deltay2 = 10; + private final UText groupName; + + private final FontConfiguration fc; + + public ETileNamedGroup(ETile orig, FontConfiguration fc, HColorSet colorSet, ISkinParam skinParam, String name) { + this.skinParam = skinParam; + this.orig = orig; + this.fc = fc; + this.colorSet = colorSet; + this.groupName = UText.build(name, fc); + + } + + @Override + public double getH1(StringBounder stringBounder) { + // final TextBlock note = getNoteAbove(stringBounder); + return deltay1 + orig.getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + // final TextBlock note = getNoteBelow(stringBounder); + return orig.getH2(stringBounder) + deltay2; + } + + @Override + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + 2 * deltax; + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D dim = calculateDimension(stringBounder); + + try { + final HColor background = colorSet.getColor("#E8E8FF"); + final UGraphic ugBack = ug.apply(background).apply(background.bg()); + ugBack.draw(URectangle.build(dim)); + final XDimension2D dimText = stringBounder.calculateDimension(fc.getFont(), groupName.getText()); + ugBack.apply(UTranslate.dy(-dimText.getHeight())).draw(URectangle.build(dimText.delta(10, 0))); + + } catch (NoSuchColorException e) { + e.printStackTrace(); + } + final double linePos = getH1(stringBounder); + drawHline(ug, linePos, 0, deltax); + drawHline(ug, linePos, dim.getWidth() - deltax, dim.getWidth()); + + orig.drawU(ug.apply(new UTranslate(deltax, deltay1))); + ug.apply(UTranslate.dx(5)).draw(groupName); + + } + + @Override + public void push(ETile tile) { + throw new UnsupportedOperationException(); + } + +// @Override +// protected void addCommentAbove(String comment) { +// this.commentAbove = comment; +// } +// +// @Override +// protected void addCommentBelow(String comment) { +// this.commentBelow = comment; +// } + +// private TextBlock getNoteAbove(StringBounder stringBounder) { +// if (commentAbove == null) +// return TextBlockUtils.EMPTY_TEXT_BLOCK; +// final FloatingNote note = FloatingNote.create(Display.getWithNewlines(commentAbove), skinParam, SName.ebnf); +// return TextBlockUtils.withMargin(note, 0, 0, 0, 10); +// } +// +// private TextBlock getNoteBelow(StringBounder stringBounder) { +// if (commentBelow == null) +// return TextBlockUtils.EMPTY_TEXT_BLOCK; +// final FloatingNote note = FloatingNote.create(Display.getWithNewlines(commentBelow), skinParam, SName.ebnf); +// return TextBlockUtils.withMargin(note, 0, 0, 10, 0); +// } + +} diff --git a/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java b/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java index 9604c7f74..ccf0e1649 100644 --- a/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java +++ b/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java @@ -97,11 +97,11 @@ public class PSystemEbnf extends TitledDiagram { @Override protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { if (expressions.size() == 0) { final Style style = ETile.getStyleSignature().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); final FontConfiguration fc = style.getFontConfiguration(getSkinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java index 0f94cb8fe..015879156 100644 --- a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java +++ b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java @@ -127,6 +127,7 @@ import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; import net.sourceforge.plantuml.svek.ClusterDecoration; +import net.sourceforge.plantuml.svek.ClusterHeader; import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; import net.sourceforge.plantuml.svek.DotStringFactory; import net.sourceforge.plantuml.svek.GeneralImageBuilder; @@ -298,12 +299,12 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { // final double roundCorner = group.getUSymbol() == null ? 0 // : group.getUSymbol().getSkinParameter().getRoundCorner(skinParam, group.getStereotype()); - final TextBlock ztitle = getTitleBlock(group); - final TextBlock zstereo = TextBlockUtils.empty(0, 0); - final RectangleArea rectangleArea = new RectangleArea(0, 0, elkNode.getWidth(), elkNode.getHeight()); - final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle, - zstereo, rectangleArea, stroke); + final ClusterHeader clusterHeader = new ClusterHeader(group, diagram.getSkinParam(), diagram, + stringBounder); + + final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), + clusterHeader.getTitle(), clusterHeader.getStereo(), rectangleArea, stroke); final HColor borderColor = HColors.BLACK; decoration.drawU(ug.apply(UTranslate.point(corner)), backColor, borderColor, shadowing, roundCorner, @@ -314,16 +315,6 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { // ug.apply(HColorUtils.BLACK).apply(UStroke.withThickness(1.5)).apply(new UTranslate(corner)).draw(rect); } - private TextBlock getTitleBlock(Entity g) { - final Display label = g.getDisplay(); - if (label == null) - return TextBlockUtils.empty(0, 0); - - final ISkinParam skinParam = diagram.getSkinParam(); - final FontConfiguration fontConfiguration = g.getFontConfigurationForTitle(skinParam); - return label.create(fontConfiguration, HorizontalAlignment.CENTER, skinParam); - } - private HColor getBackColor(UmlDiagramType umlDiagramType) { return null; } @@ -429,7 +420,14 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { // We create the "cluster" in ELK for this group final ElkNode elkCluster = ElkGraphUtil.createNode(cluster); elkCluster.setProperty(CoreOptions.DIRECTION, Direction.DOWN); - elkCluster.setProperty(CoreOptions.PADDING, new ElkPadding(40, 15, 15, 15)); + + final ClusterHeader clusterHeader = new ClusterHeader(g, diagram.getSkinParam(), diagram, + stringBounder); + + final int titleAndAttributeHeight = clusterHeader.getTitleAndAttributeHeight(); + + final double topPadding = Math.max(25, titleAndAttributeHeight) + 15; + elkCluster.setProperty(CoreOptions.PADDING, new ElkPadding(topPadding, 15, 15, 15)); // Not sure this is usefull to put a label on a "cluster" final ElkLabel label = ElkGraphUtil.createLabel(elkCluster); diff --git a/src/net/sourceforge/plantuml/filesdiagram/FEntry.java b/src/net/sourceforge/plantuml/filesdiagram/FEntry.java index eefc7d18e..c48785d39 100644 --- a/src/net/sourceforge/plantuml/filesdiagram/FEntry.java +++ b/src/net/sourceforge/plantuml/filesdiagram/FEntry.java @@ -60,47 +60,48 @@ import net.sourceforge.plantuml.svek.image.Opale; public class FEntry implements Iterable { - private final ISkinParam skinParam; + private final FEntry parent; private final List note; private final String name; private FilesType type; private List children = new ArrayList<>(); - public static FEntry createRoot(ISkinParam skinParam) { - return new FEntry(null, "", FilesType.FOLDER, skinParam); + public static FEntry createRoot() { + return new FEntry(null, FilesType.FOLDER, "", null); } - private FEntry(List note, String name, FilesType type, ISkinParam skinParam) { + private FEntry(FEntry parent, FilesType type, String name, List note) { + this.parent = parent; this.note = note; this.name = name; this.type = type; - this.skinParam = skinParam; } - public void addRawEntry(String raw, ISkinParam skinParam) { + public FEntry addRawEntry(String raw) { final int x = raw.indexOf('/'); if (x == -1) { - final FEntry result = new FEntry(null, raw, FilesType.DATA, skinParam); + final FEntry result = new FEntry(this, FilesType.DATA, raw, null); children.add(result); - return; + return result; } - final FEntry folder = getOrCreateFolder(raw.substring(0, x), skinParam); + final FEntry folder = getOrCreateFolder(raw.substring(0, x)); final String remain = raw.substring(x + 1); if (remain.length() != 0) - folder.addRawEntry(remain, skinParam); + return folder.addRawEntry(remain); + return null; } - public void addNote(List note, ISkinParam skinParam) { - final FEntry result = new FEntry(note, "NONE", FilesType.NOTE, skinParam); + public void addNote(List note) { + final FEntry result = new FEntry(this, FilesType.NOTE, "NONE", note); children.add(result); } - private FEntry getOrCreateFolder(String folderName, ISkinParam skinParam) { + private FEntry getOrCreateFolder(String folderName) { for (FEntry child : children) if (child.type == FilesType.FOLDER && child.getName().equals(folderName)) return child; - final FEntry result = new FEntry(null, folderName, FilesType.FOLDER, skinParam); + final FEntry result = new FEntry(this, FilesType.FOLDER, folderName, null); children.add(result); return result; } @@ -110,6 +111,10 @@ public class FEntry implements Iterable { return Collections.unmodifiableCollection(children).iterator(); } + public FEntry getParent() { + return parent; + } + public String getName() { return name; } @@ -132,14 +137,15 @@ public class FEntry implements Iterable { private TextBlock getTextBlock(FontConfiguration fontConfiguration, ISkinParam skinParam) { if (type == FilesType.NOTE) - return createOpale(); + return createOpale(skinParam); final Display display = Display.getWithNewlines(getEmoticon() + getName()); - TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); + TextBlock result = display.create7(fontConfiguration, HorizontalAlignment.LEFT, skinParam, + CreoleMode.NO_CREOLE); return result; } - private Opale createOpale() { + private Opale createOpale(ISkinParam skinParam) { final StyleSignatureBasic signature = StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram, SName.note); diff --git a/src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java b/src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java index b5142b7c0..891ad8940 100644 --- a/src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java +++ b/src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java @@ -89,11 +89,11 @@ public class FilesDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return list; } diff --git a/src/net/sourceforge/plantuml/filesdiagram/FilesListing.java b/src/net/sourceforge/plantuml/filesdiagram/FilesListing.java index 592a779a0..a90e78caf 100644 --- a/src/net/sourceforge/plantuml/filesdiagram/FilesListing.java +++ b/src/net/sourceforge/plantuml/filesdiagram/FilesListing.java @@ -49,10 +49,11 @@ public class FilesListing extends AbstractTextBlock { private final ISkinParam skinParam; private final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(UFont.courier(14)); private final FEntry root; + private FEntry lastCreated; public FilesListing(ISkinParam skinParam) { this.skinParam = skinParam; - this.root = FEntry.createRoot(skinParam); + this.root = FEntry.createRoot(); } @Override @@ -67,11 +68,14 @@ public class FilesListing extends AbstractTextBlock { } public void addRawEntry(String raw) { - root.addRawEntry(raw, skinParam); + lastCreated = root.addRawEntry(raw); } public void addNote(List note) { - root.addNote(note, skinParam); + if (lastCreated == null) + root.addNote(note); + else + lastCreated.getParent().addNote(note); } } diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsZxing.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsZxing.java index f2058b5d2..902e27b8a 100644 --- a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsZxing.java +++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsZxing.java @@ -41,12 +41,12 @@ import java.util.Hashtable; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import ext.plantuml.com.google.zxing.BarcodeFormat; -import ext.plantuml.com.google.zxing.EncodeHintType; -import ext.plantuml.com.google.zxing.client.j2se.MatrixToImageWriter; -import ext.plantuml.com.google.zxing.common.BitMatrix; -import ext.plantuml.com.google.zxing.qrcode.QRCodeWriter; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.BarcodeFormat; +import zext.plantuml.com.google.zxing.EncodeHintType; +import zext.plantuml.com.google.zxing.client.j2se.MatrixToImageWriter; +import zext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.qrcode.QRCodeWriter; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import net.sourceforge.plantuml.utils.Log; public class FlashCodeUtilsZxing implements FlashCodeUtils { diff --git a/src/net/sourceforge/plantuml/flashcode/package-info.java b/src/net/sourceforge/plantuml/flashcode/package-info.java index e016dc1c9..1d995313b 100644 --- a/src/net/sourceforge/plantuml/flashcode/package-info.java +++ b/src/net/sourceforge/plantuml/flashcode/package-info.java @@ -2,7 +2,7 @@ * Provides classes used to manage * Flashcode especially QR Code (on PlantUML). * - * @see ext.plantuml.com.google.zxing + * @see zext.plantuml.com.google.zxing * @see net.sourceforge.plantuml.klimt.creole.atom.AtomImg#createQrcode */ package net.sourceforge.plantuml.flashcode; diff --git a/src/net/sourceforge/plantuml/flashcode/readme.md b/src/net/sourceforge/plantuml/flashcode/readme.md index 5d49c3123..eac30f0ae 100644 --- a/src/net/sourceforge/plantuml/flashcode/readme.md +++ b/src/net/sourceforge/plantuml/flashcode/readme.md @@ -8,7 +8,7 @@ This package provides classes used to manage Flashcode especially QR Code (on Pl - [QR code _(on Wikipedia)_](https://en.wikipedia.org/wiki/QR_code) ## Credit -- [`com.google.zxing`](../../../../ext/plantuml/com/google/zxing/) _(included in PlantUML)_ +- [`com.google.zxing`](../../../../zext/plantuml/com/google/zxing/) _(included in PlantUML)_ - :octocat: [zxing/zxing](https://github.com/zxing/zxing) ## Misc. diff --git a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java index 7d4b21638..5b4b4b125 100644 --- a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java +++ b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java @@ -230,7 +230,7 @@ public class FlowDiagram extends UmlDiagram implements TextBlock { } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return this; } diff --git a/src/net/sourceforge/plantuml/flowdiagram/package-info.java b/src/net/sourceforge/plantuml/flowdiagram/package-info.java new file mode 100644 index 000000000..c146b9255 --- /dev/null +++ b/src/net/sourceforge/plantuml/flowdiagram/package-info.java @@ -0,0 +1,7 @@ +/** + * Provides classes used to manage + * + * Flow Diagram. + * + */ +package net.sourceforge.plantuml.flowdiagram; diff --git a/src/net/sourceforge/plantuml/flowdiagram/readme.md b/src/net/sourceforge/plantuml/flowdiagram/readme.md new file mode 100644 index 000000000..720bea988 --- /dev/null +++ b/src/net/sourceforge/plantuml/flowdiagram/readme.md @@ -0,0 +1,11 @@ +# Directory Documentation for `flowdiagram` + +## Description +This package provides classes used to manage [PlantUML Flow Diagram](http://alphadoc.plantuml.com/doc/markdown/en/flow-diagram). + +## Link +- [Flow Diagram _(on Alpha-doc)_](http://alphadoc.plantuml.com/doc/markdown/en/flow-diagram) + +## Reference +- [GH-501](https://github.com/plantuml/plantuml/issues/501#issuecomment-805783661) +- [QA-13557](https://forum.plantuml.net/13557/support-for-the-different-%40start-commands) diff --git a/src/net/sourceforge/plantuml/gitlog/GitDiagram.java b/src/net/sourceforge/plantuml/gitlog/GitDiagram.java index b355612cf..f1ad5fd1e 100644 --- a/src/net/sourceforge/plantuml/gitlog/GitDiagram.java +++ b/src/net/sourceforge/plantuml/gitlog/GitDiagram.java @@ -68,7 +68,7 @@ public class GitDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } private void drawInternal(UGraphic ug) { @@ -84,7 +84,7 @@ public class GitDiagram extends UmlDiagram { } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/help/Help.java b/src/net/sourceforge/plantuml/help/Help.java index 36962e0a5..cc7322dbb 100644 --- a/src/net/sourceforge/plantuml/help/Help.java +++ b/src/net/sourceforge/plantuml/help/Help.java @@ -96,7 +96,7 @@ public class Help extends UmlDiagram { } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java index 7aabbed27..cdc6eb494 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java @@ -94,7 +94,7 @@ public class JsonDiagram extends TitledDiagram { protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } private void drawInternal(UGraphic ug) { @@ -113,7 +113,7 @@ public class JsonDiagram extends TitledDiagram { } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(final FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { @@ -121,7 +121,7 @@ public class JsonDiagram extends TitledDiagram { } public XDimension2D calculateDimension(StringBounder stringBounder) { - return TextBlockUtils.getMinMax(getTextBlock(), stringBounder, true).getDimension(); + return TextBlockUtils.getMinMax(getTextMainBlock(fileFormatOption), stringBounder, true).getDimension(); } }; } diff --git a/src/net/sourceforge/plantuml/klimt/color/package-info.java b/src/net/sourceforge/plantuml/klimt/color/package-info.java new file mode 100644 index 000000000..1568496a9 --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/color/package-info.java @@ -0,0 +1,12 @@ +/** + * Provides classes used to manage + * + * Color. + * + * @see net.sourceforge.plantuml.help.CommandHelpColor + * @see net.sourceforge.plantuml.eggs.PSystemColorsFactory + * @see net.sourceforge.plantuml.klimt.creole.command.CommandCreoleColorAndSizeChange + * @see net.sourceforge.plantuml.klimt.creole.command.CommandCreoleColorChange + * + */ +package net.sourceforge.plantuml.klimt.color; diff --git a/src/net/sourceforge/plantuml/klimt/color/readme.md b/src/net/sourceforge/plantuml/klimt/color/readme.md new file mode 100644 index 000000000..6d7808afb --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/color/readme.md @@ -0,0 +1,16 @@ +# Directory Documentation for `color` + +## Description +This package provides classes used to manage [PlantUML Color](https://plantuml.com/color). + +## Link +- [PlantUML Color](https://plantuml.com/color) + +## Reference + +## Credit or Inspiration +- [HSLuv, a developer friendly perceptual color space](https://www.kuon.ch/post/2020-03-08-hsluv/) by _Nicolas Goy_. +- [HSLuv color space](https://www.hsluv.org) by [_Alexei Boronine_](https://www.boronine.com) +- :octocat: [hsluv/hsluv-java](https://github.com/hsluv/hsluv-java) +- [Calculating Color Contrast](https://24ways.org/2010/calculating-color-contrast) by _Brian Suda_. +- [`HSLColor.java` _(on Web Archive)_](https://web.archive.org/web/20220328231936/http://www.camick.com/java/source/HSLColor.java) diff --git a/src/net/sourceforge/plantuml/klimt/creole/atom/AtomTable.java b/src/net/sourceforge/plantuml/klimt/creole/atom/AtomTable.java index 9e32d2a7a..d49fe62be 100644 --- a/src/net/sourceforge/plantuml/klimt/creole/atom/AtomTable.java +++ b/src/net/sourceforge/plantuml/klimt/creole/atom/AtomTable.java @@ -81,6 +81,7 @@ public class AtomTable extends AbstractAtom implements Atom { private final List lines = new ArrayList<>(); private final Map positions = new HashMap(); private final HColor lineColor; + private Class lastCaller; public AtomTable(HColor lineColor) { this.lineColor = lineColor; @@ -110,14 +111,14 @@ public class AtomTable extends AbstractAtom implements Atom { .draw(URectangle.build(x2 - x1, y2 - y1)); } for (int j = 0; j < getNbCols(); j++) { - if (j >= line.cells.size()) { + if (j >= line.cells.size()) continue; - } + final Atom cell = line.cells.get(j); HorizontalAlignment align = HorizontalAlignment.LEFT; - if (cell instanceof SheetBlock1) { + if (cell instanceof SheetBlock1) align = ((SheetBlock1) cell).getCellAlignment(); - } + final HColor cellBackColor = line.cellsBackColor.get(j); final double x1 = getStartingX(j); final double x2 = getStartingX(j + 1); @@ -131,11 +132,11 @@ public class AtomTable extends AbstractAtom implements Atom { final Position pos = positions.get(cell); final XDimension2D dimCell = cell.calculateDimension(ug.getStringBounder()); final double dx; - if (align == HorizontalAlignment.RIGHT) { + if (align == HorizontalAlignment.RIGHT) dx = cellWidth - dimCell.getWidth(); - } else { + else dx = 0; - } + if (cellBackColor == null) cell.drawU(ug.apply(pos.getTranslate().compose(UTranslate.dx(dx)))); else @@ -144,20 +145,25 @@ public class AtomTable extends AbstractAtom implements Atom { } ug = ug.apply(lineColor); final ULine hline = ULine.hline(getEndingX(getNbCols() - 1)); - for (int i = 0; i <= getNbLines(); i++) { + for (int i = 0; i <= getNbLines(); i++) ug.apply(UTranslate.dy(getStartingY(i))).draw(hline); - } + final ULine vline = ULine.vline(getEndingY(getNbLines() - 1)); - for (int i = 0; i <= getNbCols(); i++) { + for (int i = 0; i <= getNbCols(); i++) ug.apply(UTranslate.dx(getStartingX(i))).draw(vline); - } } private void initMap(StringBounder stringBounder) { - if (positions.size() > 0) { + final Class currentCaller = stringBounder.getClass(); + if (lastCaller != currentCaller) + positions.clear(); + + this.lastCaller = currentCaller; + + if (positions.size() > 0) return; - } + for (Line line : lines) { for (Atom cell : line.cells) { final XDimension2D dim = cell.calculateDimension(stringBounder); @@ -179,33 +185,33 @@ public class AtomTable extends AbstractAtom implements Atom { private double getStartingX(int col) { double result = 0; - for (int i = 0; i < col; i++) { + for (int i = 0; i < col; i++) result += getColWidth(i); - } + return result; } private double getEndingX(int col) { double result = 0; - for (int i = 0; i <= col; i++) { + for (int i = 0; i <= col; i++) result += getColWidth(i); - } + return result; } private double getStartingY(int line) { double result = 0; - for (int i = 0; i < line; i++) { + for (int i = 0; i < line; i++) result += getLineHeight(i); - } + return result; } private double getEndingY(int line) { double result = 0; - for (int i = 0; i <= line; i++) { + for (int i = 0; i <= line; i++) result += getLineHeight(i); - } + return result; } @@ -213,9 +219,9 @@ public class AtomTable extends AbstractAtom implements Atom { double result = 0; for (int i = 0; i < getNbLines(); i++) { final Position position = getPosition(i, col); - if (position == null) { + if (position == null) continue; - } + final double width = position.getWidth(); result = Math.max(result, width); } @@ -226,9 +232,9 @@ public class AtomTable extends AbstractAtom implements Atom { double result = 0; for (int i = 0; i < getNbCols(); i++) { final Position position = getPosition(line, i); - if (position == null) { + if (position == null) continue; - } + final double height = position.getHeight(); result = Math.max(result, height); } @@ -236,13 +242,13 @@ public class AtomTable extends AbstractAtom implements Atom { } private Position getPosition(int line, int col) { - if (line >= lines.size()) { + if (line >= lines.size()) return null; - } + final Line l = lines.get(line); - if (col >= l.cells.size()) { + if (col >= l.cells.size()) return null; - } + final Atom atom = l.cells.get(col); return positions.get(atom); } diff --git a/src/net/sourceforge/plantuml/klimt/creole/package-info.java b/src/net/sourceforge/plantuml/klimt/creole/package-info.java new file mode 100644 index 000000000..99f501c28 --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/creole/package-info.java @@ -0,0 +1,7 @@ +/** + * Provides classes used to manage + * + * Creole (markup language). + * + */ +package net.sourceforge.plantuml.klimt.creole; diff --git a/src/net/sourceforge/plantuml/klimt/creole/readme.md b/src/net/sourceforge/plantuml/klimt/creole/readme.md new file mode 100644 index 000000000..d1dd36370 --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/creole/readme.md @@ -0,0 +1,10 @@ +# Directory Documentation for `creole` + +## Description +This package provides classes used to manage [PlantUML Creole](https://plantuml.com/creole) markup language. + +## Link +- [PlantUML Creole](https://plantuml.com/creole) + +## Reference +- [Creole (markup) _(on Wikipedia)_](https://en.wikipedia.org/wiki/Creole_(markup)) diff --git a/src/net/sourceforge/plantuml/klimt/drawing/g2d/ExtendedGeneralPath.java b/src/net/sourceforge/plantuml/klimt/drawing/g2d/ExtendedGeneralPath.java index 37bfe9b7b..1ff88279b 100644 --- a/src/net/sourceforge/plantuml/klimt/drawing/g2d/ExtendedGeneralPath.java +++ b/src/net/sourceforge/plantuml/klimt/drawing/g2d/ExtendedGeneralPath.java @@ -35,25 +35,6 @@ */ package net.sourceforge.plantuml.klimt.drawing.g2d; -/* - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - */ - import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; diff --git a/src/net/sourceforge/plantuml/klimt/drawing/svg/SvgGraphics.java b/src/net/sourceforge/plantuml/klimt/drawing/svg/SvgGraphics.java index c13d9b5a7..be1e8f466 100644 --- a/src/net/sourceforge/plantuml/klimt/drawing/svg/SvgGraphics.java +++ b/src/net/sourceforge/plantuml/klimt/drawing/svg/SvgGraphics.java @@ -1024,7 +1024,7 @@ public class SvgGraphics { public void addCommentMetadata(String metadata) { // ::comment when __CORE__ - final String signature = getMetadataHex(metadata); + final String signature = getMetadataHex(metadata).replace("--", "- -"); final String comment = "SRC=[" + signature + "]"; final Comment commentElement = document.createComment(comment); getG().appendChild(commentElement); diff --git a/src/net/sourceforge/plantuml/klimt/shape/UText.java b/src/net/sourceforge/plantuml/klimt/shape/UText.java index 938007efb..6968ba1ed 100644 --- a/src/net/sourceforge/plantuml/klimt/shape/UText.java +++ b/src/net/sourceforge/plantuml/klimt/shape/UText.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.klimt.shape; import net.sourceforge.plantuml.klimt.UShape; import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.geom.XDimension2D; public class UText implements UShape { @@ -83,4 +84,8 @@ public class UText implements UShape { return orientation; } + public XDimension2D calculateDimension(StringBounder stringBounder) { + return stringBounder.calculateDimension(font.getFont(), text); + } + } diff --git a/src/net/sourceforge/plantuml/klimt/sprite/ListSpriteDiagram.java b/src/net/sourceforge/plantuml/klimt/sprite/ListSpriteDiagram.java index b23c5610d..ec49bdf7d 100644 --- a/src/net/sourceforge/plantuml/klimt/sprite/ListSpriteDiagram.java +++ b/src/net/sourceforge/plantuml/klimt/sprite/ListSpriteDiagram.java @@ -79,11 +79,11 @@ public class ListSpriteDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/klimt/sprite/StdlibDiagram.java b/src/net/sourceforge/plantuml/klimt/sprite/StdlibDiagram.java index f637002ea..74c0f7ec5 100644 --- a/src/net/sourceforge/plantuml/klimt/sprite/StdlibDiagram.java +++ b/src/net/sourceforge/plantuml/klimt/sprite/StdlibDiagram.java @@ -91,11 +91,11 @@ public class StdlibDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/klimt/sprite/package-info.java b/src/net/sourceforge/plantuml/klimt/sprite/package-info.java new file mode 100644 index 000000000..53dd54d25 --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/sprite/package-info.java @@ -0,0 +1,10 @@ +/** + * Provides classes used to manage + * + * Sprite. + * + * @see net.sourceforge.plantuml.klimt.sprite.CommandListSprite + * @see net.sourceforge.plantuml.klimt.sprite.CommandStdlib + * + */ +package net.sourceforge.plantuml.klimt.sprite; diff --git a/src/net/sourceforge/plantuml/klimt/sprite/readme.md b/src/net/sourceforge/plantuml/klimt/sprite/readme.md new file mode 100644 index 000000000..314f10af7 --- /dev/null +++ b/src/net/sourceforge/plantuml/klimt/sprite/readme.md @@ -0,0 +1,14 @@ +# Directory Documentation for `sprite` + +## Description +This package provides classes used to manage [PlantUML Sprite](https://plantuml.com/sprite). + +## Link +- [PlantUML Sprite](https://plantuml.com/sprite) + +## Reference + +## See also +- [PlantUML Standard Library](https://plantuml.com/stdlib) +- [`stdlib`](../../../../../../stdlib/) +- :octocat: [plantuml/plantuml-stdlib](https://github.com/plantuml/plantuml-stdlib) diff --git a/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java b/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java index 6aec5694c..d4d32969b 100644 --- a/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java +++ b/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java @@ -602,7 +602,7 @@ public class ASCIIMathTeXImg { case CONST: str = AMremoveCharsAndBlanks(str, symbol.input.length()); String texsymbol = AMTgetTeXsymbol(symbol); - if (texsymbol.charAt(0) == '\\' || symbol.tag.equals("mo")) + if (texsymbol.isEmpty() || texsymbol.charAt(0) == '\\' || symbol.tag.equals("mo")) return new String[] { texsymbol, str }; else { return new String[] { "{" + texsymbol + "}", str }; @@ -676,7 +676,7 @@ public class ASCIIMathTeXImg { if (result[0] == null) return new String[] { "{" + AMTgetTeXsymbol(symbol) + "}", str }; if (symbol.hasFlag("func")) { // functions hack - st = "" + str.charAt(0); + st = "" + (str.isEmpty() ? "" : str.charAt(0)); if (st.equals("^") || st.equals("_") || st.equals("/") || st.equals("|") || st.equals(",") || (symbol.input.length() == 1 && symbol.input.matches("\\w") && !st.equals("("))) { return new String[] { "{" + AMTgetTeXsymbol(symbol) + "}", str }; @@ -905,8 +905,8 @@ public class ASCIIMathTeXImg { subarr = new ArrayList(Arrays.asList( newFrag.substring(pos.get(i) + 8, subpos.get(pos.get(i)).get(1)))); for (int j = 2; j < subpos.get(pos.get(i)).size(); j++) { - subarr.add(newFrag.substring(subpos.get(i).get(j - 1) + 1, - subpos.get(i).get(j))); + subarr.add(newFrag.substring(subpos.get(pos.get(i)).get(j - 1) + 1, + subpos.get(pos.get(i)).get(j))); } subarr.add(newFrag.substring( subpos.get(pos.get(i)).get(subpos.get(pos.get(i)).size() - 1) + 1, diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapDirection.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapDirection.java index 27f658495..d23e8f8ea 100644 --- a/src/net/sourceforge/plantuml/mindmap/CommandMindMapDirection.java +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapDirection.java @@ -53,13 +53,13 @@ public class CommandMindMapDirection extends SingleLineCommand2 static IRegex getRegexConcat() { return RegexConcat.build(CommandMindMapDirection.class.getName(), RegexLeaf.start(), // - new RegexLeaf("[^*]*"), // + new RegexLeaf("[^*#]*"), // new RegexLeaf("\\b"), // new RegexLeaf("DIRECTION", "(left|right|top|bottom)"), // new RegexLeaf("\\b"), // - new RegexLeaf("[^*]*"), // + new RegexLeaf("[^*#]*"), // new RegexLeaf("(side|direction)"), // - new RegexLeaf("[^*]*"), // + new RegexLeaf("[^*#]*"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java index 8c53a6853..e46204474 100644 --- a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java @@ -55,7 +55,7 @@ public class CommandMindMapOrgmode extends SingleLineCommand2 { static IRegex getRegexConcat() { return RegexConcat.build(CommandMindMapOrgmode.class.getName(), RegexLeaf.start(), // - new RegexLeaf("TYPE", "([ \t]*\\*+)"), // + new RegexLeaf("TYPE", "([ \t]*[*#]+)"), // new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), // new RegexLeaf("SHAPE", "(_)?"), // RegexLeaf.spaceOneOrMore(), // diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java index 79fd1936a..7d03529bc 100644 --- a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java @@ -60,7 +60,7 @@ public class CommandMindMapOrgmodeMultiline extends CommandMultilines2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), RegexLeaf.end()); diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java index ec7457a56..de7209791 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.utils.BlocLines; @@ -70,9 +71,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java index 94f3c4c13..ad217dd09 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.utils.BlocLines; @@ -74,9 +75,7 @@ public class CommandCreateJson extends CommandMultilines2 new RegexLeaf("TYPE", "json"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([%pLN_.]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java index fbdc4aa76..b185f30aa 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJsonSingleLine.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.utils.LineLocation; @@ -70,9 +71,7 @@ public class CommandCreateJsonSingleLine extends SingleLineCommand2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), // diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java index 8e2cbe564..939c14edf 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateMap.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.utils.BlocLines; @@ -77,9 +78,7 @@ public class CommandCreateMap extends CommandMultilines2 new RegexLeaf("TYPE", "map"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([%pLN_.]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // diff --git a/src/net/sourceforge/plantuml/png/PngTitler.java b/src/net/sourceforge/plantuml/png/PngTitler.java index 662710e6f..56a35e0d0 100644 --- a/src/net/sourceforge/plantuml/png/PngTitler.java +++ b/src/net/sourceforge/plantuml/png/PngTitler.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.png; import net.sourceforge.plantuml.cucadiagram.DisplaySection; +import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.font.StringBounder; @@ -73,6 +74,6 @@ public class PngTitler { if (display == null) return null; - return style.createTextBlockBordered(display, set, spriteContainer, Style.ID_TITLE); + return style.createTextBlockBordered(display, set, spriteContainer, Style.ID_TITLE, LineBreakStrategy.NONE); } } diff --git a/src/net/sourceforge/plantuml/preproc/Defines.java b/src/net/sourceforge/plantuml/preproc/Defines.java index ed1478741..14ec49a0e 100644 --- a/src/net/sourceforge/plantuml/preproc/Defines.java +++ b/src/net/sourceforge/plantuml/preproc/Defines.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.file.AParentFolder; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityProfile; import net.sourceforge.plantuml.security.SecurityUtils; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.TVariableScope; @@ -81,11 +82,11 @@ public class Defines implements Truth { return new Defines(); } - public void copyTo(TMemory memory) throws EaterException { + public void copyTo(TMemory memory, StringLocated location) throws EaterException { for (Entry ent : values.entrySet()) { final String name = ent.getKey(); final Define def = ent.getValue(); - memory.putVariable(name, def.asTVariable(), TVariableScope.GLOBAL); + memory.putVariable(name, def.asTVariable(), TVariableScope.GLOBAL, location); } } @@ -114,10 +115,10 @@ public class Defines implements Truth { final Defines result = createEmpty(); result.overrideFilename(file.getName()); result.environment.put("filedate", new Date(file.lastModified()).toString()); - if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) { + if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) result.environment.put("dirpath", file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/')); - } + return result; } @@ -126,10 +127,10 @@ public class Defines implements Truth { final Defines result = createEmpty(); result.overrideFilename(file.getName()); result.environment.put("filedate", new Date(file.lastModified()).toString()); - if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) { + if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) result.environment.put("dirpath", file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/')); - } + return result; } @@ -147,9 +148,9 @@ public class Defines implements Truth { private static String nameNoExtension(String name) { final int x = name.lastIndexOf('.'); - if (x == -1) { + if (x == -1) return name; - } + return name.substring(0, x); } @@ -169,11 +170,10 @@ public class Defines implements Truth { } public boolean isTrue(String name) { - for (String key : values.keySet()) { - if (key.equals(name) || key.startsWith(name + "(")) { + for (String key : values.keySet()) + if (key.equals(name) || key.startsWith(name + "(")) return true; - } - } + return false; } @@ -192,9 +192,9 @@ public class Defines implements Truth { } private String method1(String line) { - for (Define def : values.values()) { + for (Define def : values.values()) line = def.apply(line); - } + return line; } @@ -215,18 +215,17 @@ public class Defines implements Truth { private String method2(String line) { final Set words = words(line); - if (magic == null) { + if (magic == null) magic = getAll(); - } for (String w : words) { Collection tmp = magic.get(w); - if (tmp == null) { + if (tmp == null) continue; - } - for (Define def : tmp) { + + for (Define def : tmp) line = def.apply(line); - } + } return line; } @@ -236,9 +235,9 @@ public class Defines implements Truth { Pattern p = Pattern.compile(ID); Matcher m = p.matcher(line); final Set words = new HashSet<>(); - while (m.find()) { + while (m.find()) words.add(m.group(0)); - } + return words; } diff --git a/src/net/sourceforge/plantuml/preproc/Stdlib.java b/src/net/sourceforge/plantuml/preproc/Stdlib.java index 43b00edea..805b9f1c8 100644 --- a/src/net/sourceforge/plantuml/preproc/Stdlib.java +++ b/src/net/sourceforge/plantuml/preproc/Stdlib.java @@ -3,10 +3,13 @@ package net.sourceforge.plantuml.preproc; import static java.nio.charset.StandardCharsets.UTF_8; import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -317,9 +320,12 @@ public class Stdlib { return new BrotliInputStream(raw); } - private static InputStream getInternalInputStream(String fullname, String extension) { - final String res = "/stdlib/" + fullname + extension; - return Stdlib.class.getResourceAsStream(res); + private static InputStream getInternalInputStream(String fullname, String extension) throws FileNotFoundException { + final String path = "stdlib/" + fullname + extension; + InputStream result = Stdlib.class.getResourceAsStream("/" + path); + if (result == null) + result = new BufferedInputStream(new FileInputStream(path)); + return result; } public static void extractStdLib() throws IOException { @@ -329,9 +335,12 @@ public class Stdlib { } } - private static Collection getAll() throws IOException { + public static Collection getAll() throws IOException { final Set result = new TreeSet<>(); final InputStream home = getInternalInputStream("home", ".repx"); + if (home == null) + throw new IOException("Cannot access to /stdlib/*.repx files"); + final BufferedReader br = new BufferedReader(new InputStreamReader(home)); String name; while ((name = br.readLine()) != null) @@ -442,11 +451,11 @@ public class Stdlib { } } - private String getVersion() { + public String getVersion() { return info.get("VERSION"); } - private String getSource() { + public String getSource() { return info.get("SOURCE"); } diff --git a/src/net/sourceforge/plantuml/preproc/Sub.java b/src/net/sourceforge/plantuml/preproc/Sub.java index 00b7bddcd..b39e8d4d0 100644 --- a/src/net/sourceforge/plantuml/preproc/Sub.java +++ b/src/net/sourceforge/plantuml/preproc/Sub.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; public class Sub { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private final String name; private final List lines = new ArrayList<>(); diff --git a/src/net/sourceforge/plantuml/preproc/Truth.java b/src/net/sourceforge/plantuml/preproc/Truth.java index 7a33da793..1ec283d02 100644 --- a/src/net/sourceforge/plantuml/preproc/Truth.java +++ b/src/net/sourceforge/plantuml/preproc/Truth.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.preproc; public interface Truth { + public boolean isTrue(String name); } diff --git a/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java b/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java index ee238c99c..8132faab8 100644 --- a/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java +++ b/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java @@ -54,7 +54,6 @@ import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.security.SURL; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.Log; public class PreprocessorUtils { @@ -139,21 +138,21 @@ public class PreprocessorUtils { if (StartDiagramExtractReader.containsStartDiagram(url, s, charset)) return StartDiagramExtractReader.build(url, s, suf, charset); - return getReaderInclude(url, s.getLocation(), charset); + return getReaderInclude(url, s, charset); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot open URL " + e.getMessage()); + throw new EaterException("Cannot open URL " + e.getMessage(), s); } } - public static ReadLine getReaderInclude(SURL url, LineLocation lineLocation, Charset charset) + public static ReadLine getReaderInclude(SURL url, StringLocated s, Charset charset) throws EaterException, UnsupportedEncodingException { final InputStream is = url.openStream(); if (is == null) - throw EaterException.located("Cannot open URL"); + throw new EaterException("Cannot open URL", s); - return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), lineLocation); + return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation()); } } diff --git a/src/net/sourceforge/plantuml/project/ConstantPlan.java b/src/net/sourceforge/plantuml/project/ConstantPlan.java index 67ebf79eb..0d0b74b3c 100644 --- a/src/net/sourceforge/plantuml/project/ConstantPlan.java +++ b/src/net/sourceforge/plantuml/project/ConstantPlan.java @@ -53,8 +53,14 @@ public class ConstantPlan implements LoadPlanable { return new ConstantPlan(load); } + @Override public int getLoadAt(Day instant) { return loadPerInstant; } + + @Override + public Day getLastDayIfAny() { + return null; + } } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index fdc8a18c0..44e2bb2e6 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -51,7 +51,6 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.WithSprite; @@ -86,6 +85,7 @@ import net.sourceforge.plantuml.project.core.TaskInstant; import net.sourceforge.plantuml.project.core.TaskSeparator; import net.sourceforge.plantuml.project.draw.FingerPrint; import net.sourceforge.plantuml.project.draw.ResourceDraw; +import net.sourceforge.plantuml.project.draw.ResourceDrawBasic; import net.sourceforge.plantuml.project.draw.TaskDraw; import net.sourceforge.plantuml.project.draw.TaskDrawDiamond; import net.sourceforge.plantuml.project.draw.TaskDrawGroup; @@ -99,6 +99,7 @@ import net.sourceforge.plantuml.project.draw.TimeHeaderSimple; import net.sourceforge.plantuml.project.draw.TimeHeaderWeekly; import net.sourceforge.plantuml.project.draw.TimeHeaderYearly; import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.solver.ImpossibleSolvingException; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.project.time.WeekNumberStrategy; @@ -115,7 +116,7 @@ import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.text.BackSlash; -public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite { +public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite, GanttStyle { private final Map draws = new LinkedHashMap(); private final Map tasks = new LinkedHashMap(); @@ -149,13 +150,18 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit private final RealOrigin origin = RealUtils.createOrigin(); + private int defaultCompletion = 100; + + private Task it; + private Resource they; + public CommandExecutionResult changeLanguage(String lang) { this.locale = new Locale(lang); return CommandExecutionResult.ok(); } public DiagramDescription getDescription() { - return new DiagramDescription("(Project)"); + return new DiagramDescription("(Gantt)"); } public void setWeekNumberStrategy(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) { @@ -173,8 +179,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit @Override protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); - return createImageBuilder(fileFormatOption).drawable(getTextBlock(stringBounder)).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } public void setPrintScale(PrintScale printScale) { @@ -203,21 +208,27 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit } @Override - protected TextBlock getTextBlock() { - final FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG); - final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); - return getTextBlock(stringBounder); + public String checkFinalError() { + try { + initMinMax(); + } catch (ImpossibleSolvingException ex) { + return ex.getMessage(); + } + return null; } - private TextBlock getTextBlock(StringBounder stringBounder) { + @Override + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { + final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); if (printStart == null) { initMinMax(); } else { this.min = printStart; this.max = printEnd; } - final TimeHeader timeHeader = getTimeHeader(); - initTaskAndResourceDraws(timeHeader.getTimeScale(), timeHeader.getFullHeaderHeight(), stringBounder); + final TimeHeader timeHeader = getTimeHeader(stringBounder); + initTaskAndResourceDraws(timeHeader.getTimeScale(), timeHeader.getFullHeaderHeight(stringBounder), + stringBounder); return new AbstractTextBlock() { public void drawU(UGraphic ug) { @@ -233,12 +244,12 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit final HColor back = timelineStyle.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); if (back.isTransparent() == false) { final URectangle rect1 = URectangle.build(calculateDimension(ug.getStringBounder()).getWidth(), - timeHeader.getTimeHeaderHeight()); + timeHeader.getTimeHeaderHeight(ug.getStringBounder())); ug.apply(back.bg()).draw(rect1); if (showFootbox) { final URectangle rect2 = URectangle.build( calculateDimension(ug.getStringBounder()).getWidth(), - timeHeader.getTimeFooterHeight()); + timeHeader.getTimeFooterHeight(ug.getStringBounder())); ug.apply(back.bg()).apply(UTranslate.dy(totalHeightWithoutFooter)).draw(rect2); } } @@ -280,7 +291,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit public XDimension2D calculateDimension(StringBounder stringBounder) { return new XDimension2D(getTitlesColumnWidth(stringBounder) + getBarsColumnWidth(timeHeader), - getTotalHeight(timeHeader)); + getTotalHeight(stringBounder, timeHeader)); } private double getBarsColumnWidth(final TimeHeader timeHeader) { @@ -292,27 +303,27 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit }; } - private TimeHeader getTimeHeader() { + private TimeHeader getTimeHeader(StringBounder stringBounder) { if (openClose.getStartingDay() == null) - return new TimeHeaderSimple(thParam(), printScale); + return new TimeHeaderSimple(stringBounder, thParam(), printScale); else if (printScale == PrintScale.DAILY) - return new TimeHeaderDaily(thParam(), nameDays, printStart, printEnd); + return new TimeHeaderDaily(stringBounder, thParam(), nameDays, printStart); else if (printScale == PrintScale.WEEKLY) - return new TimeHeaderWeekly(thParam(), weekNumberStrategy, withCalendarDate); + return new TimeHeaderWeekly(stringBounder, thParam(), weekNumberStrategy, withCalendarDate, printStart); else if (printScale == PrintScale.MONTHLY) - return new TimeHeaderMonthly(thParam()); + return new TimeHeaderMonthly(stringBounder, thParam(), printStart); else if (printScale == PrintScale.QUARTERLY) - return new TimeHeaderQuarterly(thParam()); + return new TimeHeaderQuarterly(stringBounder, thParam(), printStart); else if (printScale == PrintScale.YEARLY) - return new TimeHeaderYearly(thParam()); + return new TimeHeaderYearly(stringBounder, thParam(), printStart); else throw new IllegalStateException(); } private TimeHeaderParameters thParam() { - return new TimeHeaderParameters(colorDays(), getFactorScale(), min, max, getIHtmlColorSet(), getTimelineStyle(), - getClosedStyle(), locale, openClose, colorDaysOfWeek, verticalSeparatorBefore); + return new TimeHeaderParameters(colorDays(), getFactorScale(), min, max, getIHtmlColorSet(), locale, openClose, + colorDaysOfWeek, verticalSeparatorBefore, this); } private Map colorDays() { @@ -320,19 +331,21 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit return Collections.unmodifiableMap(colorDaysInternal); } - private Style getClosedStyle() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.closed) + @Override + public final Style getStyle(SName param) { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param) .getMergedStyle(getCurrentStyleBuilder()); } - private Style getTimelineStyle() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.timeline) + @Override + public final Style getStyle(SName param1, SName param2) { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, param1, param2) .getMergedStyle(getCurrentStyleBuilder()); } - private double getTotalHeight(TimeHeader timeHeader) { + private double getTotalHeight(StringBounder stringBounder, TimeHeader timeHeader) { if (showFootbox) - return totalHeightWithoutFooter + timeHeader.getTimeFooterHeight(); + return totalHeightWithoutFooter + timeHeader.getTimeFooterHeight(stringBounder); return totalHeightWithoutFooter; } @@ -430,13 +443,12 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit } else if (task instanceof TaskGroup) { final TaskGroup taskGroup = (TaskGroup) task; draw = new TaskDrawGroup(timeScale, y, taskGroup.getCode().getSimpleDisplay(), getStart(taskGroup), - getEnd(taskGroup), getSkinParam(), task, this, task.getStyleBuilder()); + getEnd(taskGroup), task, this, task.getStyleBuilder()); } else { final TaskImpl tmp = (TaskImpl) task; final String disp = hideResourceName ? tmp.getCode().getSimpleDisplay() : tmp.getPrettyDisplay(); if (tmp.isDiamond()) { - draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), getSkinParam(), task, this, - task.getStyleBuilder()); + draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), task, this, task.getStyleBuilder()); } else { final boolean oddStart = printStart != null && min.compareTo(getStart(tmp)) == 0; final boolean oddEnd = printStart != null && max.compareTo(getEnd(tmp)) == 0; @@ -457,14 +469,20 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit yy = headerHeight; } else if (this.hideResourceFoobox == false) for (Resource res : resources.values()) { - final ResourceDraw draw = new ResourceDraw(this, res, timeScale, yy, min, max); + final ResourceDraw draw = buildResourceDraw(this, res, timeScale, yy, min, max); res.setTaskDraw(draw); - yy += draw.getHeight(); + yy += draw.getHeight(stringBounder); } this.totalHeightWithoutFooter = yy; } + private ResourceDraw buildResourceDraw(GanttDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, + Day max) { + return new ResourceDrawBasic(gantt, res, timeScale, y, min, max); + // return new ResourceDrawVersion2(gantt, res, timeScale, y, min, max); + } + private Collection getConstraints(Task task) { final List result = new ArrayList<>(); for (GanttConstraint constraint : constraints) { @@ -603,7 +621,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit final OpenClose except = this.openCloseForTask.get(codeOrShortName); result = new TaskImpl(getSkinParam().getCurrentStyleBuilder(), code, openClose.mutateMe(except), - openClose.getStartingDay()); + openClose.getStartingDay(), defaultCompletion); if (currentGroup != null) currentGroup.addTask(result); @@ -866,4 +884,35 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit verticalSeparatorBefore.add(day); } + public void setTaskDefaultCompletion(int defaultCompletion) { + this.defaultCompletion = defaultCompletion; + } + + public List getAllTasksForResource(Resource res) { + final List result = new ArrayList(); + for (Task task : tasks.values()) + if (task.isAssignedTo(res)) { + final TaskDrawRegular draw = (TaskDrawRegular) draws.get(task); + result.add(draw); + } + + return Collections.unmodifiableList(result); + } + + public void setIt(Task result) { + this.it = result; + } + + public Task getIt() { + return it; + } + + public final Resource getThey() { + return they; + } + + public final void setThey(Resource they) { + this.they = they; + } + } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java index 392990439..ceb183bcb 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.project.command.CommandNoteBottom; import net.sourceforge.plantuml.project.command.CommandPrintBetween; import net.sourceforge.plantuml.project.command.CommandPrintScale; import net.sourceforge.plantuml.project.command.CommandSeparator; +import net.sourceforge.plantuml.project.command.CommandTaskCompleteDefault; import net.sourceforge.plantuml.project.command.CommandWeekNumberStrategy; import net.sourceforge.plantuml.project.command.NaturalCommand; import net.sourceforge.plantuml.project.lang.SentenceAnd; @@ -78,8 +79,8 @@ import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; public class GanttDiagramFactory extends PSystemCommandFactory { - static private final List subjects() { - return Arrays.asList(SubjectTask.ME, SubjectProject.ME, SubjectDayOfWeek.ME, SubjectDayAsDate.ME, + static private final List> subjects() { + return Arrays.asList(SubjectTask.ME, SubjectProject.ME, SubjectDayOfWeek.ME, SubjectDayAsDate.ME, SubjectDaysAsDates.ME, SubjectResource.ME, SubjectToday.ME, SubjectSeparator.ME); } @@ -115,31 +116,32 @@ public class GanttDiagramFactory extends PSystemCommandFactory { cmds.add(new CommandLabelOnColumn()); cmds.add(new CommandHideResourceName()); cmds.add(new CommandHideResourceFootbox()); + cmds.add(new CommandTaskCompleteDefault()); } private void addLanguageCommands(List cmd) { - for (Subject subject : subjects()) - for (SentenceSimple sentenceA : subject.getSentences()) { + for (Subject subject : subjects()) + for (SentenceSimple sentenceA : subject.getSentences()) { cmd.add(NaturalCommand.create(sentenceA)); - for (SentenceSimple sentenceB : subject.getSentences()) { + for (SentenceSimple sentenceB : subject.getSentences()) { final String signatureA = sentenceA.getSignature(); final String signatureB = sentenceB.getSignature(); if (signatureA.equals(signatureB) == false) - cmd.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB))); + cmd.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB))); } } - for (Subject subject : subjects()) - for (SentenceSimple sentenceA : subject.getSentences()) - for (SentenceSimple sentenceB : subject.getSentences()) - for (SentenceSimple sentenceC : subject.getSentences()) { + for (Subject subject : subjects()) + for (SentenceSimple sentenceA : subject.getSentences()) + for (SentenceSimple sentenceB : subject.getSentences()) + for (SentenceSimple sentenceC : subject.getSentences()) { final String signatureA = sentenceA.getSignature(); final String signatureB = sentenceB.getSignature(); final String signatureC = sentenceC.getSignature(); if (signatureA.equals(signatureB) == false && signatureA.equals(signatureC) == false && signatureC.equals(signatureB) == false) - cmd.add(NaturalCommand.create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC))); + cmd.add(NaturalCommand.create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC))); } } diff --git a/src/net/sourceforge/plantuml/project/GanttStyle.java b/src/net/sourceforge/plantuml/project/GanttStyle.java new file mode 100644 index 000000000..44e15537d --- /dev/null +++ b/src/net/sourceforge/plantuml/project/GanttStyle.java @@ -0,0 +1,47 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project; + +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; + +public interface GanttStyle { + + public Style getStyle(SName param); + + public Style getStyle(SName param1, SName param2); + +} diff --git a/src/net/sourceforge/plantuml/project/LoadPlanable.java b/src/net/sourceforge/plantuml/project/LoadPlanable.java index d8e71f71d..76ad4c539 100644 --- a/src/net/sourceforge/plantuml/project/LoadPlanable.java +++ b/src/net/sourceforge/plantuml/project/LoadPlanable.java @@ -40,4 +40,6 @@ import net.sourceforge.plantuml.project.time.Day; public interface LoadPlanable { public int getLoadAt(Day instant); + + public Day getLastDayIfAny(); } diff --git a/src/net/sourceforge/plantuml/project/OpenClose.java b/src/net/sourceforge/plantuml/project/OpenClose.java index 1e8afbf65..7d0256c6d 100644 --- a/src/net/sourceforge/plantuml/project/OpenClose.java +++ b/src/net/sourceforge/plantuml/project/OpenClose.java @@ -49,6 +49,8 @@ public class OpenClose implements Histogram, LoadPlanable { private final Map weekdayStatus = new EnumMap<>(DayOfWeek.class); private final Map dayStatus = new HashMap<>(); private Day startingDay; + private Day offBefore; + private Day offAfter; public int daysInWeek() { int result = 7; @@ -89,6 +91,11 @@ public class OpenClose implements Histogram, LoadPlanable { } private DayStatus getLocalStatus(Day day) { + if (offBefore != null && day.compareTo(offBefore) < 0) + return DayStatus.CLOSE; + if (offAfter != null && day.compareTo(offAfter) > 0) + return DayStatus.CLOSE; + final DayStatus status1 = dayStatus.get(day); if (status1 != null) return status1; @@ -174,6 +181,14 @@ public class OpenClose implements Histogram, LoadPlanable { return getLoatAtInternal(day); } + public void setOffBeforeDate(Day day) { + this.offBefore = day; + } + + public void setOffAfterDate(Day day) { + this.offAfter = day; + } + private int getLoatAtInternal(Day day) { if (isClosed(day)) return 0; @@ -193,8 +208,18 @@ public class OpenClose implements Histogram, LoadPlanable { return 100; return OpenClose.this.getLoadAt(instant); } + + @Override + public Day getLastDayIfAny() { + return offAfter; + } }; return this; } + @Override + public Day getLastDayIfAny() { + return offAfter; + } + } diff --git a/src/net/sourceforge/plantuml/project/PlanUtils.java b/src/net/sourceforge/plantuml/project/PlanUtils.java index b80f591b8..d75adfd5e 100644 --- a/src/net/sourceforge/plantuml/project/PlanUtils.java +++ b/src/net/sourceforge/plantuml/project/PlanUtils.java @@ -48,6 +48,10 @@ public class PlanUtils { public int getLoadAt(Day instant) { return Math.min(p1.getLoadAt(instant), p2.getLoadAt(instant)); } + + public Day getLastDayIfAny() { + return lastOf(p1.getLastDayIfAny(), p2.getLastDayIfAny()); + } }; } @@ -56,7 +60,21 @@ public class PlanUtils { public int getLoadAt(Day instant) { return p1.getLoadAt(instant) * p2.getLoadAt(instant) / 100; } + + public Day getLastDayIfAny() { + return lastOf(p1.getLastDayIfAny(), p2.getLastDayIfAny()); + } }; } + private static Day lastOf(Day day1, Day day2) { + if (day1 == null) + return day2; + if (day2 == null) + return day1; + if (day1.compareTo(day2) > 0) + return day1; + return day2; + } + } diff --git a/src/net/sourceforge/plantuml/project/TimeHeaderParameters.java b/src/net/sourceforge/plantuml/project/TimeHeaderParameters.java index 95bcdd4f4..c140797ac 100644 --- a/src/net/sourceforge/plantuml/project/TimeHeaderParameters.java +++ b/src/net/sourceforge/plantuml/project/TimeHeaderParameters.java @@ -37,38 +37,42 @@ package net.sourceforge.plantuml.project; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; +import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -public class TimeHeaderParameters { +public class TimeHeaderParameters implements GanttStyle { private final Map colorDays; private final double scale; private final Day min; private final Day max; private final HColorSet colorSet; - private final Style timelineStyle; - private final Style closedStyle; + private final GanttStyle ganttStyle; private final Locale locale; private final OpenClose openClose; private final Map colorDaysOfWeek; private final Set verticalSeparatorBefore; public TimeHeaderParameters(Map colorDays, double scale, Day min, Day max, HColorSet colorSet, - Style timelineStyle, Style closedStyle, Locale locale, OpenClose openClose, - Map colorDaysOfWeek, Set verticalSeparatorBefore) { + Locale locale, OpenClose openClose, Map colorDaysOfWeek, + Set verticalSeparatorBefore, GanttStyle ganttStyle) { this.colorDays = colorDays; this.scale = scale; this.min = min; this.max = max; - this.colorSet = colorSet; - this.timelineStyle = timelineStyle; - this.closedStyle = closedStyle; + this.colorSet = Objects.requireNonNull(colorSet); + this.ganttStyle = ganttStyle; this.locale = locale; this.openClose = openClose; this.colorDaysOfWeek = colorDaysOfWeek; @@ -100,11 +104,11 @@ public class TimeHeaderParameters { } public final Style getTimelineStyle() { - return timelineStyle; + return getStyle(SName.timeline); } public final Style getClosedStyle() { - return closedStyle; + return getStyle(SName.closed); } public final Locale getLocale() { @@ -123,4 +127,26 @@ public class TimeHeaderParameters { return verticalSeparatorBefore; } + public final UGraphic forVerticalSeparator(UGraphic ug) { + final Style style = getStyle(SName.verticalSeparator); + final HColor color = style.value(PName.LineColor).asColor(getColorSet()); + final UStroke stroke = style.getStroke(); + return ug.apply(color).apply(stroke); + } + + @Override + public final Style getStyle(SName param1, SName param2) { + return ganttStyle.getStyle(param1, param2); + } + + @Override + public Style getStyle(SName param) { + return ganttStyle.getStyle(param); + } + + public double getCellWidth(StringBounder stringBounder) { + final double w = getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return w * 1.6; + } + } diff --git a/src/net/sourceforge/plantuml/project/command/CommandColorTask.java b/src/net/sourceforge/plantuml/project/command/CommandColorTask.java index 57f5e58c0..6c5583384 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandColorTask.java +++ b/src/net/sourceforge/plantuml/project/command/CommandColorTask.java @@ -59,7 +59,8 @@ public class CommandColorTask extends SingleLineCommand2 { new RegexLeaf("CODE", "\\[([%pLN_.]+)\\]"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("COLORS", "#(\\w+)(?:/(#?\\w+))?"), // - RegexLeaf.spaceZeroOrMore(), RegexLeaf.end()); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandFootbox.java b/src/net/sourceforge/plantuml/project/command/CommandFootbox.java index 43697e905..36ce4504c 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandFootbox.java +++ b/src/net/sourceforge/plantuml/project/command/CommandFootbox.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.utils.LineLocation; public class CommandFootbox extends SingleLineCommand2 { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ public CommandFootbox() { super(getRegexConcat()); @@ -55,7 +55,8 @@ public class CommandFootbox extends SingleLineCommand2 { return RegexConcat.build(CommandFootbox.class.getName(), RegexLeaf.start(), // new RegexLeaf("TYPE", "(hide|show)?"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("footbox"), RegexLeaf.end()); // + new RegexLeaf("footbox"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java index 1c1c55a30..0929fd2a8 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java +++ b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java @@ -63,7 +63,8 @@ public class CommandGanttArrow extends SingleLineCommand2 { new RegexLeaf("\\>"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("CODE2", "([%pLN_.]+)"), // - RegexLeaf.spaceZeroOrMore(), RegexLeaf.end()); + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java b/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java index acfa84310..08e48fa3c 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java +++ b/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java @@ -57,7 +57,7 @@ public class CommandHideResourceFootbox extends SingleLineCommand2 new RegexLeaf("ress?ources?"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("footbox"), // - RegexLeaf.end()); // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandHideResourceName.java b/src/net/sourceforge/plantuml/project/command/CommandHideResourceName.java index e343e3461..e386dee8c 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandHideResourceName.java +++ b/src/net/sourceforge/plantuml/project/command/CommandHideResourceName.java @@ -57,7 +57,7 @@ public class CommandHideResourceName extends SingleLineCommand2 { new RegexLeaf("ress?ources?"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("names?"), // - RegexLeaf.end()); // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandLabelOnColumn.java b/src/net/sourceforge/plantuml/project/command/CommandLabelOnColumn.java index ff2d12789..949f12e64 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandLabelOnColumn.java +++ b/src/net/sourceforge/plantuml/project/command/CommandLabelOnColumn.java @@ -70,7 +70,8 @@ public class CommandLabelOnColumn extends SingleLineCommand2 { new RegexLeaf("ALIGNED", "(left|right)"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("aligned") // - )), RegexLeaf.end()); // + )), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandLanguage.java b/src/net/sourceforge/plantuml/project/command/CommandLanguage.java index cae28078d..a8532b63d 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandLanguage.java +++ b/src/net/sourceforge/plantuml/project/command/CommandLanguage.java @@ -55,7 +55,7 @@ public class CommandLanguage extends SingleLineCommand2 { new RegexLeaf("language"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("LANG", "(\\w+)"), // - RegexLeaf.end()); // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java b/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java index cc0412fb2..5c0d1a8a5 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java +++ b/src/net/sourceforge/plantuml/project/command/CommandPrintBetween.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.utils.LineLocation; public class CommandPrintBetween extends SingleLineCommand2 { - private static final ComplementDate pattern = new ComplementDate(); + private static final ComplementDate pattern = ComplementDate.any(); public CommandPrintBetween() { super(getRegexConcat()); @@ -66,7 +66,7 @@ public class CommandPrintBetween extends SingleLineCommand2 { new RegexLeaf("and"), // RegexLeaf.spaceOneOrMore(), // pattern.toRegex("END"), // - RegexLeaf.end()); // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandPrintScale.java b/src/net/sourceforge/plantuml/project/command/CommandPrintScale.java index c82a9c027..84b1a6edb 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandPrintScale.java +++ b/src/net/sourceforge/plantuml/project/command/CommandPrintScale.java @@ -77,7 +77,7 @@ public class CommandPrintScale extends SingleLineCommand2 { new RegexLeaf("zoom"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("ZOOM", "([.\\d]+)"))), // - RegexLeaf.end()); // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/project/command/CommandTaskCompleteDefault.java b/src/net/sourceforge/plantuml/project/command/CommandTaskCompleteDefault.java new file mode 100644 index 000000000..794c91455 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/command/CommandTaskCompleteDefault.java @@ -0,0 +1,83 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.command; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOr; +import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.utils.LineLocation; + +public class CommandTaskCompleteDefault extends SingleLineCommand2 { + + public CommandTaskCompleteDefault() { + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandTaskCompleteDefault.class.getName(), RegexLeaf.start(), // + new RegexLeaf("task"), // + RegexLeaf.spaceOneOrMore(), // + new RegexOr(// + new RegexLeaf("default[%s]+completion"), // + new RegexLeaf("completion[%s]+default")), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("to"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("VALUE", "(\\d+)"), // + new RegexLeaf(".*"), // + RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { + + final int value = Integer.parseInt(arg.get("VALUE", 0)); + if (value > 100) + return CommandExecutionResult.error("Completetion must between 0 and 100"); + + diagram.setTaskDefaultCompletion(value); + + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/command/NaturalCommand.java b/src/net/sourceforge/plantuml/project/command/NaturalCommand.java index 2da5d3792..88511e131 100644 --- a/src/net/sourceforge/plantuml/project/command/NaturalCommand.java +++ b/src/net/sourceforge/plantuml/project/command/NaturalCommand.java @@ -37,27 +37,27 @@ package net.sourceforge.plantuml.project.command; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.lang.Sentence; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.utils.LineLocation; -public class NaturalCommand extends SingleLineCommand2 { +public class NaturalCommand extends SingleLineCommand2 { - private final Sentence sentence; + private final Sentence sentence; - public NaturalCommand(Sentence sentence) { + public NaturalCommand(Sentence sentence) { super(sentence.toRegex()); this.sentence = sentence; } @Override - final protected CommandExecutionResult executeArg(GanttDiagram system, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(D system, LineLocation location, RegexResult arg) { return sentence.execute(system, arg); } - public static NaturalCommand create(Sentence sentence) { - return new NaturalCommand(sentence); + public static NaturalCommand create(Sentence sentence) { + return new NaturalCommand(sentence); } diff --git a/src/net/sourceforge/plantuml/project/core/AbstractTask.java b/src/net/sourceforge/plantuml/project/core/AbstractTask.java index fe74f41cf..69d385016 100644 --- a/src/net/sourceforge/plantuml/project/core/AbstractTask.java +++ b/src/net/sourceforge/plantuml/project/core/AbstractTask.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.project.core; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.StyleBuilder; public abstract class AbstractTask implements Task { @@ -43,27 +44,54 @@ public abstract class AbstractTask implements Task { private final StyleBuilder styleBuilder; private Task row; + private String displayString; + private Stereotype stereotype; protected AbstractTask(StyleBuilder styleBuilder, TaskCode code) { this.styleBuilder = styleBuilder; this.code = code; } + @Override final public void putInSameRowAs(Task row) { if (this != row) this.row = row; } + @Override public final Task getRow() { return row; } + @Override public final TaskCode getCode() { return code; } + @Override public final StyleBuilder getStyleBuilder() { return styleBuilder; } + @Override + public void setDisplay(String displayString) { + this.displayString = displayString; + } + + @Override + public String getDisplayString() { + return this.displayString; + } + + @Override + public Stereotype getStereotype() { + return stereotype; + } + + @Override + public final void setStereotype(Stereotype stereotype) { + this.stereotype = stereotype; + } + + } diff --git a/src/net/sourceforge/plantuml/project/core/Resource.java b/src/net/sourceforge/plantuml/project/core/Resource.java index 687b479a2..594209158 100644 --- a/src/net/sourceforge/plantuml/project/core/Resource.java +++ b/src/net/sourceforge/plantuml/project/core/Resource.java @@ -94,4 +94,17 @@ public class Resource { public void addCloseDay(DayOfWeek day) { openClose.close(day); } + + public void setOffBeforeDate(Day day) { + openClose.setOffBeforeDate(day); + } + + public void setOffAfterDate(Day day) { + openClose.setOffAfterDate(day); + } + + public Day getLastDayIfAny() { + return openClose.getLastDayIfAny(); + } + } diff --git a/src/net/sourceforge/plantuml/project/core/Task.java b/src/net/sourceforge/plantuml/project/core/Task.java index 653cff0d2..b6b2bc351 100644 --- a/src/net/sourceforge/plantuml/project/core/Task.java +++ b/src/net/sourceforge/plantuml/project/core/Task.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.url.Url; @@ -79,4 +80,14 @@ public interface Task extends Moment { public StyleBuilder getStyleBuilder(); + public boolean isAssignedTo(Resource res); + + public void setDisplay(String displayString); + + public String getDisplayString(); + + public Stereotype getStereotype(); + + public void setStereotype(Stereotype stereotype); + } diff --git a/src/net/sourceforge/plantuml/project/core/TaskGroup.java b/src/net/sourceforge/plantuml/project/core/TaskGroup.java index 804e08bf1..b8d1e8c49 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskGroup.java +++ b/src/net/sourceforge/plantuml/project/core/TaskGroup.java @@ -56,6 +56,7 @@ public class TaskGroup extends AbstractTask implements Task { this.parent = parent; } + @Override public Day getStart() { Day min = null; for (Task child : children) @@ -68,6 +69,7 @@ public class TaskGroup extends AbstractTask implements Task { throw new UnsupportedOperationException(); } + @Override public Day getEnd() { Day max = null; for (Task child : children) @@ -80,54 +82,67 @@ public class TaskGroup extends AbstractTask implements Task { throw new UnsupportedOperationException(); } + @Override public void setStart(Day start) { throw new UnsupportedOperationException(); } + @Override public void setEnd(Day end) { throw new UnsupportedOperationException(); } + @Override public void setColors(CenterBorderColor... colors) { throw new UnsupportedOperationException(); } + @Override public void addResource(Resource resource, int percentage) { throw new UnsupportedOperationException(); } + @Override public Load getLoad() { throw new UnsupportedOperationException(); } + @Override public void setLoad(Load load) { throw new UnsupportedOperationException(); } + @Override public void setDiamond(boolean diamond) { throw new UnsupportedOperationException(); } + @Override public boolean isDiamond() { throw new UnsupportedOperationException(); } + @Override public void setCompletion(int completion) { throw new UnsupportedOperationException(); } + @Override public void setUrl(Url url) { throw new UnsupportedOperationException(); } + @Override public void addPause(Day pause) { throw new UnsupportedOperationException(); } + @Override public void addPause(DayOfWeek pause) { throw new UnsupportedOperationException(); } + @Override public void setNote(Display note) { } @@ -139,4 +154,9 @@ public class TaskGroup extends AbstractTask implements Task { return parent; } + @Override + public boolean isAssignedTo(Resource res) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/project/core/TaskImpl.java b/src/net/sourceforge/plantuml/project/core/TaskImpl.java index 491a3dbc1..a3db7f866 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskImpl.java +++ b/src/net/sourceforge/plantuml/project/core/TaskImpl.java @@ -66,7 +66,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { private final LoadPlanable defaultPlan; private boolean diamond; - private int completion = 100; + private int completion; private Display note; private Url url; @@ -76,8 +76,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { this.url = url; } - public TaskImpl(StyleBuilder styleBuilder, TaskCode code, LoadPlanable plan, Day startingDay) { + public TaskImpl(StyleBuilder styleBuilder, TaskCode code, LoadPlanable plan, Day startingDay, int completion) { super(styleBuilder, code); + this.completion = completion; this.defaultPlan = plan; this.solver = new SolverImpl(this); if (startingDay == null) @@ -88,6 +89,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { setLoad(Load.inWinks(1)); } + @Override public int getLoadAt(Day instant) { if (isPaused(instant)) return 0; @@ -131,10 +133,12 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return 0; } + @Override public void addPause(Day pause) { this.pausedDay.add(pause); } + @Override public void addPause(DayOfWeek pause) { this.pausedDayOfWeek.add(pause); } @@ -156,9 +160,29 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { } return result; } + + @Override + public Day getLastDayIfAny() { + return TaskImpl.this.getLastDayIfAny(); + } }; } + @Override + public Day getLastDayIfAny() { + Day result = null; + + for (Resource res : resources.keySet()) { + if (res.getLastDayIfAny() == null) + return null; + + if (result == null || result.compareTo(res.getLastDayIfAny()) < 0) + result = res.getLastDayIfAny(); + } + + return result; + } + public String getPrettyDisplay() { if (resources.size() > 0) { final StringBuilder result = new StringBuilder(getCode().getSimpleDisplay()); @@ -190,6 +214,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return "" + getStart() + " ---> " + getEnd() + " [" + getLoad() + "]"; } + @Override public Day getStart() { Day result = (Day) solver.getData(TaskAttribute.START); if (diamond == false) @@ -199,42 +224,52 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return result; } + @Override public Day getEnd() { return (Day) solver.getData(TaskAttribute.END); } + @Override public Load getLoad() { return (Load) solver.getData(TaskAttribute.LOAD); } + @Override public void setLoad(Load load) { solver.setData(TaskAttribute.LOAD, load); } + @Override public void setStart(Day start) { solver.setData(TaskAttribute.START, start); } + @Override public void setEnd(Day end) { solver.setData(TaskAttribute.END, end); } + @Override public void setColors(CenterBorderColor... colors) { this.colors = colors; } + @Override public void addResource(Resource resource, int percentage) { this.resources.put(resource, percentage); } + @Override public void setDiamond(boolean diamond) { this.diamond = diamond; } + @Override public boolean isDiamond() { return this.diamond; } + @Override public void setCompletion(int completion) { this.completion = completion; } @@ -274,6 +309,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { } + @Override public void setNote(Display note) { this.note = note; } @@ -286,4 +322,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return defaultPlan; } + @Override + public boolean isAssignedTo(Resource res) { + return resources.containsKey(res); + } + } diff --git a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java index fcf21d64a..68b30a326 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java +++ b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java @@ -52,22 +52,27 @@ public class TaskSeparator extends AbstractTask implements Task { this.comment = comment; } + @Override public Day getStart() { throw new UnsupportedOperationException(); } + @Override public Day getEnd() { throw new UnsupportedOperationException(); } + @Override public void setStart(Day start) { throw new UnsupportedOperationException(); } + @Override public void setEnd(Day end) { throw new UnsupportedOperationException(); } + @Override public void setColors(CenterBorderColor... colors) { throw new UnsupportedOperationException(); } @@ -76,10 +81,12 @@ public class TaskSeparator extends AbstractTask implements Task { return comment; } + @Override public void addResource(Resource resource, int percentage) { throw new UnsupportedOperationException(); } + @Override public Load getLoad() { throw new UnsupportedOperationException(); } @@ -88,31 +95,43 @@ public class TaskSeparator extends AbstractTask implements Task { throw new UnsupportedOperationException(); } + @Override public void setDiamond(boolean diamond) { throw new UnsupportedOperationException(); } + @Override public boolean isDiamond() { throw new UnsupportedOperationException(); } + @Override public void setCompletion(int completion) { throw new UnsupportedOperationException(); } + @Override public void setUrl(Url url) { throw new UnsupportedOperationException(); } + @Override public void addPause(Day pause) { throw new UnsupportedOperationException(); } + @Override public void addPause(DayOfWeek pause) { throw new UnsupportedOperationException(); } + @Override public void setNote(Display note) { } + @Override + public boolean isAssignedTo(Resource res) { + return false; + } + } diff --git a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java index 70c21a718..7d501e98e 100644 --- a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java @@ -49,11 +49,11 @@ import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; -import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.utils.Direction; @@ -85,8 +85,8 @@ public abstract class AbstractTaskDraw implements TaskDraw { this.note = note; } - public AbstractTaskDraw(TimeScale timeScale, Real y, String prettyDisplay, Day start, ISkinParam skinParam, - Task task, ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { + public AbstractTaskDraw(TimeScale timeScale, Real y, String prettyDisplay, Day start, Task task, + ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { this.y = y; this.styleBuilder = styleBuilder; this.toTaskDraw = toTaskDraw; @@ -96,7 +96,7 @@ public abstract class AbstractTaskDraw implements TaskDraw { this.task = task; } - abstract StyleSignatureBasic getStyleSignature(); + abstract StyleSignature getStyleSignature(); private StyleSignatureBasic getStyleSignatureUnstarted() { return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.task, SName.unstarted); diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java index fb4f72f99..0215bceae 100644 --- a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java @@ -35,96 +35,13 @@ */ package net.sourceforge.plantuml.project.draw; -import net.sourceforge.plantuml.klimt.UTranslate; -import net.sourceforge.plantuml.klimt.color.HColor; -import net.sourceforge.plantuml.klimt.color.HColors; -import net.sourceforge.plantuml.klimt.creole.Display; -import net.sourceforge.plantuml.klimt.drawing.UGraphic; -import net.sourceforge.plantuml.klimt.font.FontConfiguration; -import net.sourceforge.plantuml.klimt.font.UFont; -import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; -import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.UDrawable; -import net.sourceforge.plantuml.klimt.shape.ULine; -import net.sourceforge.plantuml.klimt.sprite.SpriteContainerEmpty; -import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.core.Resource; -import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.timescale.TimeScale; -public class ResourceDraw implements UDrawable { +public interface ResourceDraw extends UDrawable { - private final Resource res; - private final TimeScale timeScale; - private final double y; - private final Day min; - private final Day max; - private final GanttDiagram gantt; + public double getHeight(StringBounder stringBounder); - public ResourceDraw(GanttDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, Day max) { - this.res = res; - this.timeScale = timeScale; - this.y = y; - this.min = min; - this.max = max; - this.gantt = gantt; - } - - public void drawU(UGraphic ug) { - final TextBlock title = Display.getWithNewlines(res.getName()).create(getFontConfiguration(13), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - title.drawU(ug); - final ULine line = ULine.hline(timeScale.getEndingPosition(max) - timeScale.getStartingPosition(min)); - ug.apply(HColors.BLACK).apply(UTranslate.dy(title.calculateDimension(ug.getStringBounder()).getHeight())) - .draw(line); - - double startingPosition = -1; - int totalLoad = 0; - int totalLimit = 0; - for (Day i = min; i.compareTo(max) <= 0; i = i.increment()) { - final boolean isBreaking = timeScale.isBreaking(i); - totalLoad += gantt.getLoadForResource(res, i); - totalLimit += 100; - if (isBreaking) { - if (totalLoad > 0) { - final boolean over = totalLoad > totalLimit; - final FontConfiguration fontConfiguration = getFontConfiguration(9, - over ? HColors.RED : HColors.BLACK); - final TextBlock value = Display.getWithNewlines("" + totalLoad).create(fontConfiguration, - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - if (startingPosition == -1) - startingPosition = timeScale.getStartingPosition(i); - final double endingPosition = timeScale.getEndingPosition(i); - final double start = (startingPosition + endingPosition) / 2 - - value.calculateDimension(ug.getStringBounder()).getWidth() / 2; - value.drawU(ug.apply(new UTranslate(start, 16))); - } - startingPosition = -1; - totalLoad = 0; - totalLimit = 0; - } else { - if (startingPosition == -1) - startingPosition = timeScale.getStartingPosition(i); - } - } - - } - - private FontConfiguration getFontConfiguration(int size) { - return getFontConfiguration(size, HColors.BLACK); - } - - private FontConfiguration getFontConfiguration(int size, HColor color) { - final UFont font = UFont.serif(size); - return FontConfiguration.create(font, color, color, null); - } - - public double getHeight() { - return 16 * 2; - } - - public final double getY() { - return y; - } + public double getY(); } diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDrawBasic.java b/src/net/sourceforge/plantuml/project/draw/ResourceDrawBasic.java new file mode 100644 index 000000000..5ba180cda --- /dev/null +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDrawBasic.java @@ -0,0 +1,132 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.draw; + +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.color.HColors; +import net.sourceforge.plantuml.klimt.creole.Display; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.font.UFont; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.shape.ULine; +import net.sourceforge.plantuml.klimt.sprite.SpriteContainerEmpty; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Resource; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.timescale.TimeScale; + +public class ResourceDrawBasic implements ResourceDraw { + + private final Resource res; + private final TimeScale timeScale; + private final double y; + private final Day min; + private final Day max; + private final GanttDiagram gantt; + + public ResourceDrawBasic(GanttDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, Day max) { + this.res = res; + this.timeScale = timeScale; + this.y = y; + this.min = min; + this.max = max; + this.gantt = gantt; + } + + public void drawU(UGraphic ug) { + final TextBlock title = Display.getWithNewlines(res.getName()).create(getFontConfiguration(13), + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + title.drawU(ug); + final ULine line = ULine.hline(timeScale.getEndingPosition(max) - timeScale.getStartingPosition(min)); + ug.apply(HColors.BLACK).apply(UTranslate.dy(title.calculateDimension(ug.getStringBounder()).getHeight())) + .draw(line); + + double startingPosition = -1; + int totalLoad = 0; + int totalLimit = 0; + for (Day i = min; i.compareTo(max) <= 0; i = i.increment()) { + final boolean isBreaking = timeScale.isBreaking(i); + totalLoad += gantt.getLoadForResource(res, i); + totalLimit += 100; + if (isBreaking) { + if (totalLoad > 0) { + final boolean over = totalLoad > totalLimit; + final FontConfiguration fontConfiguration = getFontConfiguration(9, + over ? HColors.RED : HColors.BLACK); + final TextBlock value = Display.getWithNewlines("" + totalLoad).create(fontConfiguration, + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + if (startingPosition == -1) + startingPosition = timeScale.getStartingPosition(i); + final double endingPosition = timeScale.getEndingPosition(i); + final double start = (startingPosition + endingPosition) / 2 + - value.calculateDimension(ug.getStringBounder()).getWidth() / 2; + value.drawU(ug.apply(new UTranslate(start, 16))); + } + startingPosition = -1; + totalLoad = 0; + totalLimit = 0; + } else { + if (startingPosition == -1) + startingPosition = timeScale.getStartingPosition(i); + } + } + + } + + private FontConfiguration getFontConfiguration(int size) { + return getFontConfiguration(size, HColors.BLACK); + } + + private FontConfiguration getFontConfiguration(int size, HColor color) { + final UFont font = UFont.serif(size); + return FontConfiguration.create(font, color, color, null); + } + + @Override + public double getHeight(StringBounder stringBounder) { + return 16 * 2; + } + + @Override + public final double getY() { + return y; + } + +} diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDrawVersion2.java b/src/net/sourceforge/plantuml/project/draw/ResourceDrawVersion2.java new file mode 100644 index 000000000..522fe9e91 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDrawVersion2.java @@ -0,0 +1,138 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.draw; + +import net.sourceforge.plantuml.klimt.UShape; +import net.sourceforge.plantuml.klimt.UTranslate; +import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.color.HColors; +import net.sourceforge.plantuml.klimt.creole.Display; +import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.font.UFont; +import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; +import net.sourceforge.plantuml.klimt.shape.TextBlock; +import net.sourceforge.plantuml.klimt.shape.ULine; +import net.sourceforge.plantuml.klimt.shape.URectangle; +import net.sourceforge.plantuml.klimt.sprite.SpriteContainerEmpty; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.LabelPosition; +import net.sourceforge.plantuml.project.LabelStrategy; +import net.sourceforge.plantuml.project.core.Resource; +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.timescale.TimeScale; + +public class ResourceDrawVersion2 implements ResourceDraw { + + private final Resource res; + private final TimeScale timeScale; + private final double y; + private final Day min; + private final Day max; + private final GanttDiagram gantt; + + public ResourceDrawVersion2(GanttDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, Day max) { + this.res = res; + this.timeScale = timeScale; + this.y = y; + this.min = min; + this.max = max; + this.gantt = gantt; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + + double ypos = 16; + final double tmpHeight = getHeight(stringBounder) - ypos; + for (Day wink = gantt.getStartingDate(); wink.compareTo(gantt.getEndingDate()) <= 0; wink = wink.increment()) { + final double start = timeScale.getStartingPosition(wink); + final double end = timeScale.getEndingPosition(wink); + final UShape rect = URectangle.build(end - start, tmpHeight); + if (res.isClosedAt(wink)) + ug.apply(HColors.LIGHT_GRAY.bg()).apply(new UTranslate(start, ypos)).draw(rect); + + } + + final TextBlock title = Display.getWithNewlines(res.getName()).create(getFontConfiguration(13), + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + title.drawU(ug); + final ULine line = ULine.hline(timeScale.getEndingPosition(max) - timeScale.getStartingPosition(min)); + ug.apply(HColors.BLACK).apply(UTranslate.dy(title.calculateDimension(ug.getStringBounder()).getHeight())) + .draw(line); + + final LabelStrategy labelStrategy = new LabelStrategy(LabelPosition.LEGACY, HorizontalAlignment.LEFT); + + for (TaskDrawRegular draw : gantt.getAllTasksForResource(res)) { + draw.drawShape(ug.apply(UTranslate.dy(ypos + getTopMarginBetweenTask()))); + draw.drawTitle(ug.apply(UTranslate.dy(ypos + getTopMarginBetweenTask())), labelStrategy, 10, 100); + ypos += draw.getShapeHeight(stringBounder) + getMarginBetweenTask(); + } + } + + @Override + public double getHeight(StringBounder stringBounder) { + double ypos = 16; + for (TaskDrawRegular draw : gantt.getAllTasksForResource(res)) + ypos += draw.getShapeHeight(stringBounder) + getMarginBetweenTask(); + + return ypos + 8; + } + + private double getTopMarginBetweenTask() { + return 2; + } + + private double getMarginBetweenTask() { + return 4; + } + + private FontConfiguration getFontConfiguration(int size) { + return getFontConfiguration(size, HColors.BLACK); + } + + private FontConfiguration getFontConfiguration(int size, HColor color) { + final UFont font = UFont.serif(size); + return FontConfiguration.create(font, color, color, null); + } + + @Override + public final double getY() { + return y; + } + +} diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java index 30e3d8031..260579d10 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java @@ -54,21 +54,21 @@ import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; -import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignatureBasic; public class TaskDrawDiamond extends AbstractTaskDraw { - public TaskDrawDiamond(TimeScale timeScale, Real y, String prettyDisplay, Day start, ISkinParam skinParam, - Task task, ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { - super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw, styleBuilder); + public TaskDrawDiamond(TimeScale timeScale, Real y, String prettyDisplay, Day start, Task task, + ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { + super(timeScale, y, prettyDisplay, start, task, toTaskDraw, styleBuilder); } @Override - StyleSignatureBasic getStyleSignature() { + StyleSignature getStyleSignature() { return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.milestone); } @@ -134,29 +134,39 @@ public class TaskDrawDiamond extends AbstractTaskDraw { @Override public void drawU(UGraphic ug) { + if (url != null) + ug.startUrl(url); + + final String displayString = getTask().getDisplayString(); + final Style style = getStyle(); final ClockwiseTopRightBottomLeft margin = style.getMargin(); ug = ug.apply(UTranslate.dy(margin.getTop())); final double x1 = timeScale.getStartingPosition(start); - final double x2 = timeScale.getEndingPosition(start); - final double width = getDiamondHeight(); - final double delta = x2 - x1 - width; - if (url != null) - ug.startUrl(url); - - drawShape(applyColors(ug).apply(UTranslate.dx(x1 + delta / 2))); + ug = ug.apply(UTranslate.dx(x1)); + if (displayString == null) { + final double x2 = timeScale.getEndingPosition(start); + final double width = getDiamondHeight(); + final double delta = x2 - x1 - width; + ug = ug.apply(UTranslate.dx(delta / 2)); + drawShape(applyColors(ug)); + } else { + final TextBlock draw = Display.getWithNewlines(displayString).create(getFontConfiguration(), + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + draw.drawU(ug); + } if (url != null) ug.closeUrl(); } private UGraphic applyColors(UGraphic ug) { final CenterBorderColor col = this.getColors(); - if (col != null && col.isOk()) { + if (col != null && col.isOk()) return col.apply(ug); - } + return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawGroup.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawGroup.java index 88ff50d60..346182887 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawGroup.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawGroup.java @@ -54,22 +54,19 @@ import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; -import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignatureBasic; public class TaskDrawGroup extends AbstractTaskDraw { private final Day end; - private final ISkinParam skinParam; - - public TaskDrawGroup(TimeScale timeScale, Real y, String prettyDisplay, Day start, Day end, ISkinParam skinParam, - Task task, ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { - super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw, styleBuilder); - this.skinParam = skinParam; + public TaskDrawGroup(TimeScale timeScale, Real y, String prettyDisplay, Day start, Day end, Task task, + ToTaskDraw toTaskDraw, StyleBuilder styleBuilder) { + super(timeScale, y, prettyDisplay, start, task, toTaskDraw, styleBuilder); this.end = end; } @@ -122,7 +119,7 @@ public class TaskDrawGroup extends AbstractTaskDraw { } @Override - StyleSignatureBasic getStyleSignature() { + StyleSignature getStyleSignature() { return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.task); } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index ebe606c9a..7d8d9a1ae 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -65,11 +65,12 @@ import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.sequencediagram.graphic.Segment; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; -import net.sourceforge.plantuml.style.ISkinParam; +import net.sourceforge.plantuml.style.ISkinSimple; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.image.Opale; @@ -80,13 +81,13 @@ public class TaskDrawRegular extends AbstractTaskDraw { private final boolean oddEnd; private final Collection paused; private final Collection constraints; - private final ISkinParam skinParam; + private final ISkinSimple skinSimple; public TaskDrawRegular(TimeScale timeScale, Real y, String prettyDisplay, Day start, Day end, boolean oddStart, - boolean oddEnd, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw, + boolean oddEnd, ISkinSimple skinSimple, Task task, ToTaskDraw toTaskDraw, Collection constraints, StyleBuilder styleBuilder) { - super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw, styleBuilder); - this.skinParam = skinParam; + super(timeScale, y, prettyDisplay, start, task, toTaskDraw, styleBuilder); + this.skinSimple = skinSimple; this.constraints = constraints; this.end = end; this.oddStart = oddStart; @@ -101,7 +102,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { } @Override - protected double getShapeHeight(StringBounder stringBounder) { + public double getShapeHeight(StringBounder stringBounder) { final Style style = getStyle(); final ClockwiseTopRightBottomLeft padding = style.getPadding(); return padding.getTop() + getTitle().calculateDimension(stringBounder).getHeight() + padding.getBottom(); @@ -162,15 +163,15 @@ public class TaskDrawRegular extends AbstractTaskDraw { } @Override - StyleSignatureBasic getStyleSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.task); + StyleSignature getStyleSignature() { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ganttDiagram, SName.task) + .withTOBECHANGED(getTask().getStereotype()); } public void drawU(UGraphic ug) { final double startPos = timeScale.getStartingPosition(start); drawNote(ug.apply((new UTranslate(startPos, getYNotePosition(ug.getStringBounder()))))); - ug = applyColors(ug); drawShape(ug); } @@ -203,7 +204,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { final FontConfiguration fc = style.getFontConfiguration(getColorSet()); final HorizontalAlignment horizontalAlignment = style.value(PName.HorizontalAlignment).asHorizontalAlignment(); - final Sheet sheet = skinParam.sheet(fc, horizontalAlignment, CreoleMode.FULL).createSheet(note); + final Sheet sheet = skinSimple.sheet(fc, horizontalAlignment, CreoleMode.FULL).createSheet(note); final double padding = style.value(PName.Padding).asDouble(); final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, padding); @@ -256,7 +257,8 @@ public class TaskDrawRegular extends AbstractTaskDraw { return endPos; } - private void drawShape(UGraphic ug) { + public void drawShape(UGraphic ug) { + ug = applyColors(ug); final Style style = getStyleSignature().getMergedStyle(getStyleBuilder()); final ClockwiseTopRightBottomLeft margin = style.getMargin(); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java index ab995c7e4..9d171188e 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java @@ -35,113 +35,102 @@ */ package net.sourceforge.plantuml.project.draw; -import java.util.Objects; - -import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; -import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.HColors; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.font.UFont; import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.ULine; import net.sourceforge.plantuml.klimt.shape.URectangle; import net.sourceforge.plantuml.klimt.sprite.SpriteContainerEmpty; +import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.style.PName; -import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.SName; public abstract class TimeHeader { - // ::remove folder when __HAXE__ - - protected final double Y_POS_ROW16() { - return 16; - } - - protected final double Y_POS_ROW28() { - return 28; - } + // ::remove folder when __HAXE__ private final TimeScale timeScale; - private final Style closedStyle; - private final Style timelineStyle; - private final HColorSet colorSet; + protected final TimeHeaderParameters thParam; - protected final Day min; - protected final Day max; - - public TimeHeader(Style timelineStyle, Style closedStyle, Day min, Day max, TimeScale timeScale, - HColorSet colorSet) { + public TimeHeader(TimeHeaderParameters thParam, TimeScale timeScale) { + this.thParam = thParam; this.timeScale = timeScale; - this.min = min; - this.max = max; - this.closedStyle = Objects.requireNonNull(closedStyle); - this.timelineStyle = Objects.requireNonNull(timelineStyle); - this.colorSet = colorSet; + } + + protected final boolean isBold2(Day wink) { + return thParam.getVerticalSeparatorBefore().contains(wink); + } + + protected final Day getMin() { + return thParam.getMin(); + } + + protected final Day getMax() { + return thParam.getMax(); } protected final HColor closedBackgroundColor() { - return closedStyle.value(PName.BackGroundColor).asColor(colorSet); + return thParam.getClosedStyle().value(PName.BackGroundColor).asColor(thParam.getColorSet()); } protected final HColor closedFontColor() { - return closedStyle.value(PName.FontColor).asColor(colorSet); + return thParam.getClosedStyle().value(PName.FontColor).asColor(thParam.getColorSet()); } protected final HColor openFontColor() { - return timelineStyle.value(PName.FontColor).asColor(colorSet); + return thParam.getTimelineStyle().value(PName.FontColor).asColor(thParam.getColorSet()); } - protected final HColor getBarColor() { - return timelineStyle.value(PName.LineColor).asColor(colorSet); + protected final HColor getLineColor() { + return thParam.getTimelineStyle().value(PName.LineColor).asColor(thParam.getColorSet()); } - public abstract double getTimeHeaderHeight(); + public abstract double getTimeHeaderHeight(StringBounder stringBounder); - public abstract double getTimeFooterHeight(); + public abstract double getTimeFooterHeight(StringBounder stringBounder); + + public abstract double getFullHeaderHeight(StringBounder stringBounder); public abstract void drawTimeHeader(UGraphic ug, double totalHeightWithoutFooter); public abstract void drawTimeFooter(UGraphic ug); - public abstract double getFullHeaderHeight(); - - protected final void drawHline(UGraphic ug, double y) { - final double xmin = getTimeScale().getStartingPosition(min); - final double xmax = getTimeScale().getEndingPosition(max); - final ULine hline = ULine.hline(xmax - xmin); - ug.apply(getBarColor()).apply(UTranslate.dy(y)).draw(hline); + public final TimeScale getTimeScale() { + return timeScale; } - protected final void drawVbar(UGraphic ug, double x, double y1, double y2, boolean bold) { + protected final void drawHline(UGraphic ug, double y) { + final double xmin = getTimeScale().getStartingPosition(thParam.getMin()); + final double xmax = getTimeScale().getEndingPosition(thParam.getMax()); + final ULine hline = ULine.hline(xmax - xmin); + ug.apply(getLineColor()).apply(UTranslate.dy(y)).draw(hline); + } + + protected final void drawVline(UGraphic ug, double x, double y1, double y2) { final ULine vbar = ULine.vline(y2 - y1); - if (bold) - ug = goBold(ug); - else - ug = ug.apply(getBarColor()); ug.apply(new UTranslate(x, y1)).draw(vbar); } - final protected FontConfiguration getFontConfiguration(int size, boolean bold, HColor color) { - UFont font = UFont.serif(size); + final protected FontConfiguration getFontConfiguration(UFont font, boolean bold, HColor color) { if (bold) font = font.bold(); return FontConfiguration.create(font, color, color, null); } - public final TimeScale getTimeScale() { - return timeScale; - } - - protected final TextBlock getTextBlock(String text, int size, boolean bold, HColor color) { - return Display.getWithNewlines(text).create(getFontConfiguration(size, bold, color), HorizontalAlignment.LEFT, + protected final TextBlock getTextBlock(SName param, String text, boolean bold, HColor color) { + final UFont font = thParam.getStyle(SName.timeline, param).getUFont(); + final FontConfiguration fontConfiguration = getFontConfiguration(font, bold, color); + return Display.getWithNewlines(text).create(fontConfiguration, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); } @@ -171,12 +160,16 @@ public abstract class TimeHeader { return; ug = ug.apply(HColors.none()); - ug = ug.apply(new UTranslate(x1, getFullHeaderHeight())); + ug = ug.apply(new UTranslate(x1, getFullHeaderHeight(ug.getStringBounder()))); ug.draw(URectangle.build(x2 - x1, height)); } - protected final UGraphic goBold(UGraphic ug) { - return ug.apply(HColors.BLACK).apply(UStroke.withThickness(2)); + protected void printVerticalSeparators(UGraphic ug, double totalHeightWithoutFooter) { + ug = thParam.forVerticalSeparator(ug); + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) + if (isBold2(wink)) + drawVline(ug, getTimeScale().getStartingPosition(wink), + getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter); } } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderCalendar.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderCalendar.java index 3d8274958..fb85e6503 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderCalendar.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderCalendar.java @@ -45,16 +45,8 @@ import net.sourceforge.plantuml.project.timescale.TimeScale; public abstract class TimeHeaderCalendar extends TimeHeader { - private final TimeHeaderParameters thParam; - public TimeHeaderCalendar(TimeHeaderParameters thParam, TimeScale timeScale) { - super(thParam.getTimelineStyle(), thParam.getClosedStyle(), thParam.getMin(), thParam.getMax(), timeScale, - thParam.getColorSet()); - this.thParam = thParam; - } - - protected final boolean isBold(Day wink) { - return thParam.getVerticalSeparatorBefore().contains(wink); + super(thParam, timeScale); } protected final Locale locale() { @@ -64,7 +56,7 @@ public abstract class TimeHeaderCalendar extends TimeHeader { protected final int getLoadAt(Day instant) { return thParam.getLoadPlanable().getLoadAt(instant); } - + // Duplicate in TimeHeaderSimple class Pending { final double x1; @@ -84,10 +76,10 @@ public abstract class TimeHeaderCalendar extends TimeHeader { protected final void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) { - final double height = totalHeightWithoutFooter - getFullHeaderHeight(); + final double height = totalHeightWithoutFooter - getFullHeaderHeight(ug.getStringBounder()); Pending pending = null; - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); HColor back = thParam.getColor(wink); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java index 8fd5bf794..039180af5 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java @@ -40,74 +40,122 @@ import java.util.Map; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.MonthYear; import net.sourceforge.plantuml.project.timescale.TimeScaleDaily; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderDaily extends TimeHeaderCalendar { - public double getTimeHeaderHeight() { - return Y_POS_ROW28() + 13; + private double getH1(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 2; + return h; } - public double getTimeFooterHeight() { - // return 0; - return 24 + 14; + private double getH2(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 2; + return getH1(stringBounder) + h; + } + + private double getH3(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 3; + return getH2(stringBounder) + h; + } + + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + return getH3(stringBounder); + } + + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + final double h3 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + return h1 + h2 + h3 + 8; + } + + private double getHeaderNameDayHeight() { + if (nameDays.size() > 0) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 6; + return h; + } + + return 0; + } + + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder) + getHeaderNameDayHeight(); } private final Map nameDays; - public TimeHeaderDaily(TimeHeaderParameters thParam, Map nameDays, Day printStart, Day printEnd) { - super(thParam, new TimeScaleDaily(thParam.getStartingDay(), thParam.getScale(), printStart)); + public TimeHeaderDaily(StringBounder stringBounder, TimeHeaderParameters thParam, Map nameDays, + Day printStart) { + super(thParam, new TimeScaleDaily(thParam.getCellWidth(stringBounder), thParam.getStartingDay(), + thParam.getScale(), printStart)); this.nameDays = nameDays; } @Override public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) { drawTextsBackground(ug, totalHeightWithoutFooter); - drawTextsDayOfWeek(ug.apply(UTranslate.dy(Y_POS_ROW16()))); - drawTextDayOfMonth(ug.apply(UTranslate.dy(Y_POS_ROW28()))); + drawTextsDayOfWeek(ug.apply(UTranslate.dy(getH1(ug.getStringBounder())))); + drawTextDayOfMonth(ug.apply(UTranslate.dy(getH2(ug.getStringBounder())))); drawMonths(ug); - printSmallVbars(ug, totalHeightWithoutFooter); + printVerticalSeparators(ug, totalHeightWithoutFooter); printNamedDays(ug); - drawHline(ug, getFullHeaderHeight()); + drawHline(ug, getFullHeaderHeight(ug.getStringBounder())); drawHline(ug, totalHeightWithoutFooter); } - private void printSmallVbars(final UGraphic ug, double totalHeightWithoutFooter) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) - drawVbar(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(), totalHeightWithoutFooter, - isBold(wink)); + @Override + protected void printVerticalSeparators(final UGraphic ug, double totalHeightWithoutFooter) { + final UGraphic ugVerticalSeparator = thParam.forVerticalSeparator(ug); + final UGraphic ugLineColor = ug.apply(getLineColor()); + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) + if (isBold2(wink)) + drawVline(ugVerticalSeparator, getTimeScale().getStartingPosition(wink), + getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter); + else + drawVline(ugLineColor, getTimeScale().getStartingPosition(wink), + getFullHeaderHeight(ug.getStringBounder()), totalHeightWithoutFooter); - drawVbar(ug, getTimeScale().getEndingPosition(max), getFullHeaderHeight(), totalHeightWithoutFooter, false); + drawVline(ugLineColor, getTimeScale().getEndingPosition(getMax()), getFullHeaderHeight(ug.getStringBounder()), + totalHeightWithoutFooter); } @Override public void drawTimeFooter(UGraphic ug) { - drawTextDayOfMonth(ug.apply(UTranslate.dy(12))); + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble() + 2; drawTextsDayOfWeek(ug); - drawMonths(ug.apply(UTranslate.dy(24))); + drawTextDayOfMonth(ug.apply(UTranslate.dy(h + 2))); + drawMonths(ug.apply(UTranslate.dy(2 * h + 3))); } private void drawTextsDayOfWeek(UGraphic ug) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); final HColor textColor = getTextBackColor(wink); - printCentered(ug, getTextBlock(wink.getDayOfWeek().shortName(locale()), 10, false, textColor), x1, x2); + printCentered(ug, getTextBlock(SName.day, wink.getDayOfWeek().shortName(locale()), false, textColor), x1, + x2); } } private void drawTextDayOfMonth(UGraphic ug) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); final HColor textColor = getTextBackColor(wink); - printCentered(ug, getTextBlock("" + wink.getDayOfMonth(), 10, false, textColor), x1, x2); + printCentered(ug, getTextBlock(SName.day, "" + wink.getDayOfMonth(), false, textColor), x1, x2); } } @@ -121,7 +169,7 @@ public class TimeHeaderDaily extends TimeHeaderCalendar { private void drawMonths(final UGraphic ug) { MonthYear last = null; double lastChangeMonth = -1; - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (wink.monthYear().equals(last) == false) { if (last != null) @@ -131,48 +179,38 @@ public class TimeHeaderDaily extends TimeHeaderCalendar { last = wink.monthYear(); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); if (x1 > lastChangeMonth) printMonth(ug, last, lastChangeMonth, x1); } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock tiny = getTextBlock(monthYear.shortName(locale()), 12, true, openFontColor()); - final TextBlock small = getTextBlock(monthYear.longName(locale()), 12, true, openFontColor()); - final TextBlock big = getTextBlock(monthYear.longNameYYYY(locale()), 12, true, openFontColor()); + final TextBlock tiny = getTextBlock(SName.month, monthYear.shortName(locale()), true, openFontColor()); + final TextBlock small = getTextBlock(SName.month, monthYear.longName(locale()), true, openFontColor()); + final TextBlock big = getTextBlock(SName.month, monthYear.longNameYYYY(locale()), true, openFontColor()); printCentered(ug, false, start, end, tiny, small, big); } private void printNamedDays(final UGraphic ug) { if (nameDays.size() > 0) { String last = null; - for (Day wink = min; wink.compareTo(max.increment()) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax().increment()) <= 0; wink = wink.increment()) { final String name = nameDays.get(wink); if (name != null && name.equals(last) == false) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); - final TextBlock label = getTextBlock(name, 12, false, openFontColor()); + final TextBlock label = getTextBlock(SName.month, name, false, openFontColor()); final double h = label.calculateDimension(ug.getStringBounder()).getHeight(); - double y1 = getTimeHeaderHeight(); - double y2 = getFullHeaderHeight(); - label.drawU(ug.apply(new UTranslate(x1, Y_POS_ROW28() + 11))); + double y1 = getTimeHeaderHeight(ug.getStringBounder()); + double y2 = getFullHeaderHeight(ug.getStringBounder()); + + final double position = getH3(ug.getStringBounder()); + label.drawU(ug.apply(new UTranslate(x1, position))); } last = name; } } } - @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight() + getHeaderNameDayHeight(); - } - - private double getHeaderNameDayHeight() { - if (nameDays.size() > 0) - return 16; - - return 0; - } - } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java index d8d6e2d67..f784519cd 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java @@ -37,104 +37,120 @@ package net.sourceforge.plantuml.project.draw; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.MonthYear; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderMonthly extends TimeHeaderCalendar { - public double getTimeHeaderHeight() { - return 16 + 13; + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + return h1 + h2 + 5; } - public double getTimeFooterHeight() { - return 16 + 13 - 1; + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + return h1 + h2 + 5; } - public TimeHeaderMonthly(TimeHeaderParameters thParam) { - super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale())); + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder); + } + + public TimeHeaderMonthly(StringBounder stringBounder, TimeHeaderParameters thParam, Day printStart) { + super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(), + thParam.getScale(), printStart)); } @Override public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) { drawTextsBackground(ug, totalHeightWithoutFooter); drawYears(ug); - drawMonths(ug.apply(UTranslate.dy(16))); - printSmallVbars(ug, totalHeightWithoutFooter); + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + drawMonths(ug.apply(UTranslate.dy(h1 + 2))); + printVerticalSeparators(ug, totalHeightWithoutFooter); drawHline(ug, 0); - drawHline(ug, 16); - drawHline(ug, getFullHeaderHeight()); - } - - private void printSmallVbars(final UGraphic ug, double totalHeightWithoutFooter) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) - if (isBold(wink)) - drawVbar(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(), totalHeightWithoutFooter, - isBold(wink)); + drawHline(ug, h1 + 2); + drawHline(ug, h1 + 2 + h2 + 2); +// drawHline(ug, getFullHeaderHeight(ug.getStringBounder())); } @Override public void drawTimeFooter(UGraphic ug) { - ug = ug.apply(UTranslate.dy(3)); + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + // ug = ug.apply(UTranslate.dy(3)); drawMonths(ug); - drawYears(ug.apply(UTranslate.dy(13))); + drawYears(ug.apply(UTranslate.dy(h2 + 2))); drawHline(ug, 0); - drawHline(ug, 13); - drawHline(ug, getTimeFooterHeight()); + drawHline(ug, h2 + 2); + drawHline(ug, h1 + 2 + h2 + 2); +// drawHline(ug, getTimeFooterHeight(ug.getStringBounder())); } private void drawYears(final UGraphic ug) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); MonthYear last = null; double lastChange = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (last == null || wink.monthYear().year() != last.year()) { - drawVbar(ug, x1, 0, 15, false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2); + if (last != null) printYear(ug, last, lastChange, x1); - } + lastChange = x1; last = wink.monthYear(); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChange) { + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (x1 > lastChange) printYear(ug, last, lastChange, x1); - } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, 15, false); + + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2); } private void drawMonths(UGraphic ug) { + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); MonthYear last = null; double lastChange = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (wink.monthYear().equals(last) == false) { - drawVbar(ug, x1, 0, 12, false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, h2 + 2); + if (last != null) printMonth(ug, last, lastChange, x1); - } + lastChange = x1; last = wink.monthYear(); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChange) { + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (x1 > lastChange) printMonth(ug, last, lastChange, x1); - } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, 12, false); + + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h2 + 2); } private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock("" + monthYear.year(), 12, true, openFontColor()); + final TextBlock small = getTextBlock(SName.month, "" + monthYear.year(), true, openFontColor()); printCentered(ug, false, start, end, small); } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock(monthYear.shortName(locale()), 10, false, openFontColor()); - final TextBlock big = getTextBlock(monthYear.longName(locale()), 10, false, openFontColor()); + final TextBlock small = getTextBlock(SName.day, monthYear.shortName(locale()), false, openFontColor()); + final TextBlock big = getTextBlock(SName.day, monthYear.longName(locale()), false, openFontColor()); printCentered(ug, false, start, end, small, big); } @@ -142,9 +158,4 @@ public class TimeHeaderMonthly extends TimeHeaderCalendar { text.drawU(ug.apply(UTranslate.dx(start))); } - @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight(); - } - } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderQuarterly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderQuarterly.java index dcf03c017..daa68bcfe 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderQuarterly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderQuarterly.java @@ -37,94 +37,110 @@ package net.sourceforge.plantuml.project.draw; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.MonthYear; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderQuarterly extends TimeHeaderCalendar { - public double getTimeHeaderHeight() { - return 16 + 13; + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + return h1 + h2 + 5; } - public double getTimeFooterHeight() { - return 16 + 13 - 1; + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + return h1 + h2 + 5; } - public TimeHeaderQuarterly(TimeHeaderParameters thParam) { - super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale())); + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder); + } + + public TimeHeaderQuarterly(StringBounder stringBounder, TimeHeaderParameters thParam, Day printStart) { + super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(), + thParam.getScale(), printStart)); } @Override public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) { drawTextsBackground(ug, totalHeightWithoutFooter); drawYears(ug); - drawQuarters(ug.apply(UTranslate.dy(16))); - printSmallVbars(ug, totalHeightWithoutFooter); + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + drawQuarters(ug.apply(UTranslate.dy(h1 + 2))); + printVerticalSeparators(ug, totalHeightWithoutFooter); drawHline(ug, 0); - drawHline(ug, 16); - drawHline(ug, getFullHeaderHeight()); - } - - private void printSmallVbars(final UGraphic ug, double totalHeightWithoutFooter) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) - if (isBold(wink)) - drawVbar(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(), totalHeightWithoutFooter, - isBold(wink)); + drawHline(ug, h1 + 2); + drawHline(ug, h1 + 2 + h2 + 2); + // drawHline(ug, getFullHeaderHeight(ug.getStringBounder())); } @Override public void drawTimeFooter(UGraphic ug) { - ug = ug.apply(UTranslate.dy(3)); + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + // ug = ug.apply(UTranslate.dy(3)); drawQuarters(ug); - drawYears(ug.apply(UTranslate.dy(13))); + drawYears(ug.apply(UTranslate.dy(h2 + 2))); drawHline(ug, 0); - drawHline(ug, 13); - drawHline(ug, getTimeFooterHeight()); + drawHline(ug, h2 + 2); + drawHline(ug, h1 + 2 + h2 + 2); +// drawHline(ug, getTimeFooterHeight(ug.getStringBounder())); } private void drawYears(final UGraphic ug) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); MonthYear last = null; double lastChange = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (last == null || wink.monthYear().year() != last.year()) { - drawVbar(ug, x1, 0, 15, false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2); + if (last != null) printYear(ug, last, lastChange, x1); - } + lastChange = x1; last = wink.monthYear(); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChange) { + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (x1 > lastChange) printYear(ug, last, lastChange, x1); - } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, 15, false); + + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2); } private void drawQuarters(UGraphic ug) { + final double h2 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); String last = null; double lastChange = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (quarter(wink).equals(last) == false) { - drawVbar(ug, x1, 0, 12, false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, h2 + 2); + if (last != null) printQuarter(ug, last, lastChange, x1); - } + lastChange = x1; last = quarter(wink); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChange) { + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (x1 > lastChange) printQuarter(ug, last, lastChange, x1); - } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, 12, false); + + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h2 + 2); } private String quarter(Day day) { @@ -132,12 +148,12 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar { } private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock("" + monthYear.year(), 12, true, openFontColor()); + final TextBlock small = getTextBlock(SName.month, "" + monthYear.year(), true, openFontColor()); printCentered(ug, false, start, end, small); } private void printQuarter(UGraphic ug, String quarter, double start, double end) { - final TextBlock small = getTextBlock(quarter, 10, false, openFontColor()); + final TextBlock small = getTextBlock(SName.day, quarter, false, openFontColor()); printCentered(ug, false, start, end, small); } @@ -145,9 +161,4 @@ public class TimeHeaderQuarterly extends TimeHeaderCalendar { text.drawU(ug.apply(UTranslate.dx(start))); } - @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight(); - } - } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java index a4a68f26f..a837c08f1 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java @@ -35,12 +35,13 @@ */ package net.sourceforge.plantuml.project.draw; -import java.util.Set; - import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.FontConfiguration; +import net.sourceforge.plantuml.klimt.font.StringBounder; +import net.sourceforge.plantuml.klimt.font.UFont; import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.ULine; @@ -50,70 +51,60 @@ import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.project.timescale.TimeScaleWink; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderSimple extends TimeHeader { - private final TimeHeaderParameters colorDays; private final PrintScale printScale; - private final Set verticalSeparators; @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight() + getHeaderNameDayHeight(); + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder) + getHeaderNameDayHeight(); } - public double getTimeHeaderHeight() { - return 16; + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return h + 6; } - public double getTimeFooterHeight() { - return 16; + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return h + 6; } private double getHeaderNameDayHeight() { return 0; } - public TimeHeaderSimple(TimeHeaderParameters thParam, PrintScale printScale) { - super(thParam.getTimelineStyle(), thParam.getClosedStyle(), thParam.getMin(), thParam.getMax(), - new TimeScaleWink(thParam.getScale(), printScale), thParam.getColorSet()); - this.colorDays = thParam; + public TimeHeaderSimple(StringBounder stringBounder, TimeHeaderParameters thParam, PrintScale printScale) { + super(thParam, new TimeScaleWink(thParam.getCellWidth(stringBounder), thParam.getScale(), printScale)); this.printScale = printScale; - this.verticalSeparators = thParam.getVerticalSeparatorBefore(); - } - - private boolean isBold(Day wink) { - return verticalSeparators.contains(wink); - } - - private void drawSeparatorsDay(UGraphic ug, TimeScale timeScale, double totalHeightWithoutFooter) { - final ULine vbar = ULine.vline(totalHeightWithoutFooter - getFullHeaderHeight() + 2); - ug = goBold(ug).apply(UTranslate.dy(getFullHeaderHeight() - 1)); - for (Day i = min; i.compareTo(max.increment()) <= 0; i = i.increment(printScale)) - if (isBold(i)) { - final double x1 = timeScale.getStartingPosition(i); - ug.apply(UTranslate.dx(x1)).draw(vbar); - } } private void drawSmallVlinesDay(UGraphic ug, TimeScale timeScale, double totalHeightWithoutFooter) { - final ULine vbar = ULine.vline(totalHeightWithoutFooter); - for (Day i = min; i.compareTo(max.increment()) <= 0; i = i.increment(printScale)) { + ug = ug.apply(getLineColor()); + ug = ug.apply(UTranslate.dy(6)); + final ULine vbar = ULine.vline(totalHeightWithoutFooter + 2); + for (Day i = getMin(); i.compareTo(getMax().increment()) <= 0; i = i.increment(printScale)) { final double x1 = timeScale.getStartingPosition(i); - ug.apply(getBarColor()).apply(UTranslate.dx(x1)).draw(vbar); + ug.apply(UTranslate.dx(x1)).draw(vbar); } } private void drawSimpleDayCounter(UGraphic ug, TimeScale timeScale) { - for (Day i = min; i.compareTo(max.increment()) <= 0; i = i.increment(printScale)) { + for (Day i = getMin(); i.compareTo(getMax().increment()) <= 0; i = i.increment(printScale)) { final int value; if (printScale == PrintScale.WEEKLY) value = i.getAbsoluteDayNum() / 7 + 1; else value = i.getAbsoluteDayNum() + 1; - final TextBlock num = Display.getWithNewlines("" + value).create( - getFontConfiguration(10, false, openFontColor()), HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); + final UFont font = thParam.getStyle(SName.timeline, SName.day).getUFont(); + final FontConfiguration fontConfiguration = getFontConfiguration(font, false, openFontColor()); + final TextBlock num = Display.getWithNewlines("" + value).create(fontConfiguration, + HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final double x1 = timeScale.getStartingPosition(i); final double x2; if (printScale == PrintScale.WEEKLY) @@ -122,33 +113,37 @@ public class TimeHeaderSimple extends TimeHeader { x2 = timeScale.getEndingPosition(i); final double width = num.calculateDimension(ug.getStringBounder()).getWidth(); final double delta = (x2 - x1) - width; - if (i.compareTo(max.increment()) < 0) + if (i.compareTo(getMax().increment()) < 0) num.drawU(ug.apply(UTranslate.dx(x1 + delta / 2))); } } @Override - public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) { - drawTextsBackground(ug.apply(UTranslate.dy(-3)), totalHeightWithoutFooter + 6); - final double xmin = getTimeScale().getStartingPosition(min); - final double xmax = getTimeScale().getEndingPosition(max); - drawSmallVlinesDay(ug, getTimeScale(), totalHeightWithoutFooter + 2); - drawSeparatorsDay(ug, getTimeScale(), totalHeightWithoutFooter); + public void drawTimeHeader(UGraphic ug, double totalHeightWithoutFooter) { + // drawTextsBackground(ug.apply(UTranslate.dy(-3)), totalHeightWithoutFooter + + // 6); + final double xmin = getTimeScale().getStartingPosition(getMin()); + final double xmax = getTimeScale().getEndingPosition(getMax()); + drawSmallVlinesDay(ug, getTimeScale(), totalHeightWithoutFooter); + printVerticalSeparators(ug, totalHeightWithoutFooter); drawSimpleDayCounter(ug, getTimeScale()); - ug.apply(getBarColor()).draw(ULine.hline(xmax - xmin)); - ug.apply(getBarColor()).apply(UTranslate.dy(getFullHeaderHeight() - 3)).draw(ULine.hline(xmax - xmin)); + // ug = ug.apply(getLineColor()); + // ug.draw(ULine.hline(xmax - xmin)); + // ug.apply(UTranslate.dy(getFullHeaderHeight(ug.getStringBounder()) - + // 3)).draw(ULine.hline(xmax - xmin)); } @Override public void drawTimeFooter(UGraphic ug) { - final double xmin = getTimeScale().getStartingPosition(min); - final double xmax = getTimeScale().getEndingPosition(max); + final double xmin = getTimeScale().getStartingPosition(getMin()); + final double xmax = getTimeScale().getEndingPosition(getMax()); ug = ug.apply(UTranslate.dy(3)); - drawSmallVlinesDay(ug, getTimeScale(), getTimeFooterHeight() - 3); + // drawSmallVlinesDay(ug, getTimeScale(), + // getTimeFooterHeight(ug.getStringBounder()) - 3); drawSimpleDayCounter(ug, getTimeScale()); - ug.apply(getBarColor()).draw(ULine.hline(xmax - xmin)); + // ug.apply(getLineColor()).draw(ULine.hline(xmax - xmin)); } // Duplicate in TimeHeaderDaily @@ -170,13 +165,13 @@ public class TimeHeaderSimple extends TimeHeader { protected final void drawTextsBackground(UGraphic ug, double totalHeightWithoutFooter) { - final double height = totalHeightWithoutFooter - getFullHeaderHeight(); + final double height = totalHeightWithoutFooter - getFullHeaderHeight(ug.getStringBounder()); Pending pending = null; - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); - HColor back = colorDays.getColor(wink); + HColor back = thParam.getColor(wink); // // Day of week should be stronger than period of time (back color). // final HColor backDoW = colorDaysOfWeek.get(wink.getDayOfWeek()); // if (backDoW != null) { diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java index aa8374632..af6fbaffd 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java @@ -37,29 +37,48 @@ package net.sourceforge.plantuml.project.draw; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.MonthYear; import net.sourceforge.plantuml.project.time.WeekNumberStrategy; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderWeekly extends TimeHeaderCalendar { private final WeekNumberStrategy weekNumberStrategy; private final boolean withCalendarDate; - public double getTimeHeaderHeight() { - return 16 + 13; + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble(); + final double h2 = thParam.getStyle(SName.timeline, SName.day).value(PName.FontSize).asDouble(); + return h1 + h2 + 5; } - public double getTimeFooterHeight() { - return 16; + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 4; + return h; } - public TimeHeaderWeekly(TimeHeaderParameters thParam, WeekNumberStrategy weekNumberStrategy, - boolean withCalendarDate) { - super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale())); + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder); + } + + private double getH1(StringBounder stringBounder) { + final double h = thParam.getStyle(SName.timeline, SName.month).value(PName.FontSize).asDouble() + 4; + return h; + } + + public TimeHeaderWeekly(StringBounder stringBounder, TimeHeaderParameters thParam, + WeekNumberStrategy weekNumberStrategy, boolean withCalendarDate, Day printStart) { + super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(), + thParam.getScale(), printStart)); this.weekNumberStrategy = weekNumberStrategy; this.withCalendarDate = withCalendarDate; } @@ -69,76 +88,75 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar { drawTextsBackground(ug, totalHeightWithoutFooter); drawCalendar(ug, totalHeightWithoutFooter); drawHline(ug, 0); - drawHline(ug, Y_POS_ROW16()); - drawHline(ug, getFullHeaderHeight()); + drawHline(ug, getH1(ug.getStringBounder())); + drawHline(ug, getFullHeaderHeight(ug.getStringBounder())); } @Override public void drawTimeFooter(UGraphic ug) { drawHline(ug, 0); printMonths(ug); - drawHline(ug, getTimeFooterHeight()); + drawHline(ug, getTimeFooterHeight(ug.getStringBounder())); } private void drawCalendar(final UGraphic ug, double totalHeightWithoutFooter) { printDaysOfMonth(ug); - printSmallVbars(ug, totalHeightWithoutFooter); + printVerticalSeparators(ug, totalHeightWithoutFooter); printMonths(ug); } private void printMonths(final UGraphic ug) { MonthYear last = null; double lastChangeMonth = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (wink.monthYear().equals(last) == false) { - drawVbar(ug, x1, 0, Y_POS_ROW16(), false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, getH1(ug.getStringBounder())); + if (last != null) printMonth(ug, last, lastChangeMonth, x1); - } + lastChangeMonth = x1; last = wink.monthYear(); } } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, Y_POS_ROW16(), false); - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChangeMonth) { + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), (double) 0, + getH1(ug.getStringBounder())); + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (last != null && x1 > lastChangeMonth) printMonth(ug, last, lastChangeMonth, x1); - } + } - private void printSmallVbars(final UGraphic ug, double totalHeightWithoutFooter) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) + @Override + protected void printVerticalSeparators(final UGraphic ug, double totalHeightWithoutFooter) { + for (Day wink = getMin(); wink.compareTo(getMax()) <= 0; wink = wink.increment()) if (wink.getDayOfWeek() == weekNumberStrategy.getFirstDayOfWeek()) - drawVbar(ug, getTimeScale().getStartingPosition(wink), Y_POS_ROW16(), totalHeightWithoutFooter, false); - - drawVbar(ug, getTimeScale().getEndingPosition(max), Y_POS_ROW16(), totalHeightWithoutFooter, false); - - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) - if (isBold(wink)) - drawVbar(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(), totalHeightWithoutFooter, - isBold(wink)); + drawVline(ug.apply(getLineColor()), getTimeScale().getStartingPosition(wink), + getH1(ug.getStringBounder()), totalHeightWithoutFooter); + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), getH1(ug.getStringBounder()), + totalHeightWithoutFooter); + super.printVerticalSeparators(ug, totalHeightWithoutFooter); } private void printDaysOfMonth(final UGraphic ug) { - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { if (wink.getDayOfWeek() == weekNumberStrategy.getFirstDayOfWeek()) { final String num; if (withCalendarDate) num = "" + wink.getDayOfMonth(); else num = "" + wink.getWeekOfYear(weekNumberStrategy); - final TextBlock textBlock = getTextBlock(num, 10, false, openFontColor()); - printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16())), textBlock, + final TextBlock textBlock = getTextBlock(SName.day, num, false, openFontColor()); + printLeft(ug.apply(UTranslate.dy(getH1(ug.getStringBounder()))), textBlock, getTimeScale().getStartingPosition(wink) + 5); } } } private void printMonth(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock(monthYear.shortName(locale()), 12, true, openFontColor()); - final TextBlock big = getTextBlock(monthYear.shortNameYYYY(locale()), 12, true, openFontColor()); + final TextBlock small = getTextBlock(SName.month, monthYear.shortName(locale()), true, openFontColor()); + final TextBlock big = getTextBlock(SName.month, monthYear.shortNameYYYY(locale()), true, openFontColor()); printCentered(ug, false, start, end, small, big); } @@ -146,9 +164,4 @@ public class TimeHeaderWeekly extends TimeHeaderCalendar { text.drawU(ug.apply(UTranslate.dx(start))); } - @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight(); - } - } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderYearly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderYearly.java index 9d537fd41..fddee9e9a 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderYearly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderYearly.java @@ -35,81 +35,83 @@ */ package net.sourceforge.plantuml.project.draw; -import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.drawing.UGraphic; +import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.project.TimeHeaderParameters; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.MonthYear; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; public class TimeHeaderYearly extends TimeHeaderCalendar { - public double getTimeHeaderHeight() { - return 20; + @Override + public double getTimeHeaderHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + return h1 + 3; } - public double getTimeFooterHeight() { - return 20 - 1; + @Override + public double getTimeFooterHeight(StringBounder stringBounder) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + return h1 + 3; } - public TimeHeaderYearly(TimeHeaderParameters thParam) { - super(thParam, new TimeScaleCompressed(thParam.getStartingDay(), thParam.getScale())); + @Override + public double getFullHeaderHeight(StringBounder stringBounder) { + return getTimeHeaderHeight(stringBounder); + } + + public TimeHeaderYearly(StringBounder stringBounder, TimeHeaderParameters thParam, Day printStart) { + super(thParam, new TimeScaleCompressed(thParam.getCellWidth(stringBounder), thParam.getStartingDay(), + thParam.getScale(), printStart)); } @Override public void drawTimeHeader(final UGraphic ug, double totalHeightWithoutFooter) { drawTextsBackground(ug, totalHeightWithoutFooter); drawYears(ug); - printSmallVbars(ug, totalHeightWithoutFooter); + printVerticalSeparators(ug, totalHeightWithoutFooter); drawHline(ug, 0); - drawHline(ug, getFullHeaderHeight()); - } - - private void printSmallVbars(final UGraphic ug, double totalHeightWithoutFooter) { - for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) - if (isBold(wink)) - drawVbar(ug, getTimeScale().getStartingPosition(wink), getFullHeaderHeight(), totalHeightWithoutFooter, - isBold(wink)); + drawHline(ug, getFullHeaderHeight(ug.getStringBounder())); } @Override public void drawTimeFooter(UGraphic ug) { - ug = ug.apply(UTranslate.dy(3)); + // ug = ug.apply(UTranslate.dy(3)); drawYears(ug); drawHline(ug, 0); - drawHline(ug, getTimeFooterHeight()); + drawHline(ug, getTimeFooterHeight(ug.getStringBounder())); } private void drawYears(final UGraphic ug) { + final double h1 = thParam.getStyle(SName.timeline, SName.year).value(PName.FontSize).asDouble(); + MonthYear last = null; double lastChange = -1; - for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + for (Day wink = getMin(); wink.compareTo(getMax()) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); if (last == null || wink.monthYear().year() != last.year()) { - drawVbar(ug, x1, 0, 19, false); - if (last != null) { + drawVline(ug.apply(getLineColor()), x1, 0, h1 + 2); + if (last != null) printYear(ug, last, lastChange, x1); - } + lastChange = x1; last = wink.monthYear(); } } - final double x1 = getTimeScale().getStartingPosition(max.increment()); - if (x1 > lastChange) { + final double x1 = getTimeScale().getStartingPosition(getMax().increment()); + if (x1 > lastChange) printYear(ug, last, lastChange, x1); - } - drawVbar(ug, getTimeScale().getEndingPosition(max), 0, 19, false); + + drawVline(ug.apply(getLineColor()), getTimeScale().getEndingPosition(getMax()), 0, h1 + 2); } private void printYear(UGraphic ug, MonthYear monthYear, double start, double end) { - final TextBlock small = getTextBlock("" + monthYear.year(), 14, true, openFontColor()); + final TextBlock small = getTextBlock(SName.year, "" + monthYear.year(), true, openFontColor()); printCentered(ug, true, start, end, small); } - @Override - public double getFullHeaderHeight() { - return getTimeHeaderHeight(); - } - } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementAnything.java b/src/net/sourceforge/plantuml/project/lang/ComplementAnything.java new file mode 100644 index 000000000..5a9bc3c45 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/ComplementAnything.java @@ -0,0 +1,54 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexResult; + +public class ComplementAnything implements Something { + + public IRegex toRegex(String suffix) { + return new RegexLeaf("ANYTHING" + suffix, "(.*?)"); + } + + public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { + final String value = arg.get("ANYTHING" + suffix, 0); + return Failable.ok(value); + } +} diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java b/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java index fc61a7aad..cd8a2b411 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementBeforeOrAfterOrAtTaskStartOrEnd.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements Something { +public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements Something { private static final int POS_NB1 = 0; private static final int POS_WORKING1 = 1; diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementClose.java b/src/net/sourceforge/plantuml/project/lang/ComplementClose.java index a3ef45a6e..c2c2e449d 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementClose.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementClose.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementClose implements Something { +public class ComplementClose implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("CLOSED" + suffix, "(closed?(?: for \\[([^\\[\\]]+?)\\])?)"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java b/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java index 5931f8e37..0ffcf0b1e 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementCompleted.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementCompleted implements Something { +public class ComplementCompleted implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "(\\d+).*completed?"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDate.java b/src/net/sourceforge/plantuml/project/lang/ComplementDate.java index ae52dfdb0..2b70fd246 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDate.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDate.java @@ -38,44 +38,45 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.Month; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementDate implements Something { +public class ComplementDate implements Something { + + private final Type type; + + static enum Type { + ANY, ONLY_RELATIVE, ONLY_ABSOLUTE; + } + + private ComplementDate(Type type) { + this.type = type; + } + + public static ComplementDate any() { + return new ComplementDate(Type.ANY); + } + + public static ComplementDate onlyRelative() { + return new ComplementDate(Type.ONLY_RELATIVE); + } + + public static ComplementDate onlyAbsolute() { + return new ComplementDate(Type.ONLY_ABSOLUTE); + } public IRegex toRegex(String suffix) { - return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix), toRegexD(suffix), toRegexE(suffix)); - } - - private IRegex toRegexA(String suffix) { - return new RegexConcat( // - new RegexLeaf("ADAY" + suffix, "([\\d]+)"), // - new RegexLeaf("[\\w, ]*?"), // - new RegexLeaf("AMONTH" + suffix, "(" + Month.getRegexString() + ")"), // - new RegexLeaf("[\\w, ]*?"), // - new RegexLeaf("AYEAR" + suffix, "([\\d]{4})")); - } - - private IRegex toRegexB(String suffix) { - return new RegexConcat( // - new RegexLeaf("BYEAR" + suffix, "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH" + suffix, "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY" + suffix, "([\\d]{1,2})")); - } - - private IRegex toRegexC(String suffix) { - return new RegexConcat( // - new RegexLeaf("CMONTH" + suffix, "(" + Month.getRegexString() + ")"), // - new RegexLeaf("[\\w, ]*?"), // - new RegexLeaf("CDAY" + suffix, "([\\d]+)"), // - new RegexLeaf("[\\w, ]*?"), // - new RegexLeaf("CYEAR" + suffix, "([\\d]{4})")); + final DayPattern dayPattern = new DayPattern(suffix); + switch (type) { + case ONLY_ABSOLUTE: + return dayPattern.toRegex(); + case ONLY_RELATIVE: + return new RegexOr(toRegexD(suffix), toRegexE(suffix)); + } + return new RegexOr(dayPattern.toRegex(), toRegexD(suffix), toRegexE(suffix)); } private IRegex toRegexD(String suffix) { @@ -98,45 +99,21 @@ public class ComplementDate implements Something { } public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { - if (arg.get("ADAY" + suffix, 0) != null) { - return Failable.ok(resultA(arg, suffix)); - } - if (arg.get("BDAY" + suffix, 0) != null) { - return Failable.ok(resultB(arg, suffix)); - } - if (arg.get("CDAY" + suffix, 0) != null) { - return Failable.ok(resultC(arg, suffix)); - } - if (arg.get("DCOUNT" + suffix, 0) != null) { + final DayPattern dayPattern = new DayPattern(suffix); + final Day result = dayPattern.getDay(arg); + + if (result != null) + return Failable.ok(result); + + if (arg.get("DCOUNT" + suffix, 0) != null) return Failable.ok(resultD(system, arg, suffix)); - } - if (arg.get("ECOUNT" + suffix, 0) != null) { + + if (arg.get("ECOUNT" + suffix, 0) != null) return Failable.ok(resultE(system, arg, suffix)); - } + throw new IllegalStateException(); } - private Day resultA(RegexResult arg, String suffix) { - final int day = Integer.parseInt(arg.get("ADAY" + suffix, 0)); - final String month = arg.get("AMONTH" + suffix, 0); - final int year = Integer.parseInt(arg.get("AYEAR" + suffix, 0)); - return Day.create(year, month, day); - } - - private Day resultB(RegexResult arg, String suffix) { - final int day = Integer.parseInt(arg.get("BDAY" + suffix, 0)); - final int month = Integer.parseInt(arg.get("BMONTH" + suffix, 0)); - final int year = Integer.parseInt(arg.get("BYEAR" + suffix, 0)); - return Day.create(year, month, day); - } - - private Day resultC(RegexResult arg, String suffix) { - final int day = Integer.parseInt(arg.get("CDAY" + suffix, 0)); - final String month = arg.get("CMONTH" + suffix, 0); - final int year = Integer.parseInt(arg.get("CYEAR" + suffix, 0)); - return Day.create(year, month, day); - } - private Day resultD(GanttDiagram system, RegexResult arg, String suffix) { final int day = Integer.parseInt(arg.get("DCOUNT" + suffix, 0)); return system.getStartingDate().addDays(day); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDates.java b/src/net/sourceforge/plantuml/project/lang/ComplementDates.java index 4bcbb31f1..253f3e0cf 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDates.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDates.java @@ -45,27 +45,21 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementDates implements Something { +public class ComplementDates implements Something { public IRegex toRegex(String suffix) { return new RegexOr(toRegexB(suffix), toRegexE(suffix)); } private IRegex toRegexB(String suffix) { + final DayPattern dayPattern1 = new DayPattern("1"); + final DayPattern dayPattern2 = new DayPattern("2"); return new RegexConcat( // - new RegexLeaf("BYEAR1" + suffix, "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH1" + suffix, "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY1" + suffix, "([\\d]{1,2})"), // + dayPattern1.toRegex(), // + Words.exactly(Words.TO), // + Words.zeroOrMore(Words.THE), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("to"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("BYEAR2" + suffix, "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH2" + suffix, "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY2" + suffix, "([\\d]{1,2})") // + dayPattern2.toRegex() // ); } @@ -73,8 +67,8 @@ public class ComplementDates implements Something { return new RegexConcat( // new RegexLeaf("[dD]\\+"), // new RegexLeaf("ECOUNT1" + suffix, "([\\d]+)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("to"), // + Words.exactly(Words.TO), // + Words.zeroOrMore(Words.THE), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("[dD]\\+"), // new RegexLeaf("ECOUNT2" + suffix, "([\\d]+)") // @@ -82,30 +76,19 @@ public class ComplementDates implements Something { } public Failable getMe(GanttDiagram project, RegexResult arg, String suffix) { - if (arg.get("BDAY1" + suffix, 0) != null) { - return Failable.ok(resultB(arg, suffix)); + final Day d1 = new DayPattern("1").getDay(arg); + if (d1 != null) { + final Day d2 = new DayPattern("2").getDay(arg); + return Failable.ok(new DaysAsDates(d1, d2)); } - if (arg.get("ECOUNT1" + suffix, 0) != null) { + + if (arg.get("ECOUNT1" + suffix, 0) != null) return Failable.ok(resultE(project, arg, suffix)); - } + throw new IllegalStateException(); } - private DaysAsDates resultB(RegexResult arg, String suffix) { - final int day1 = Integer.parseInt(arg.get("BDAY1" + suffix, 0)); - final int month1 = Integer.parseInt(arg.get("BMONTH1" + suffix, 0)); - final int year1 = Integer.parseInt(arg.get("BYEAR1" + suffix, 0)); - final Day date1 = Day.create(year1, month1, day1); - - final int day2 = Integer.parseInt(arg.get("BDAY2" + suffix, 0)); - final int month2 = Integer.parseInt(arg.get("BMONTH2" + suffix, 0)); - final int year2 = Integer.parseInt(arg.get("BYEAR2" + suffix, 0)); - final Day date2 = Day.create(year2, month2, day2); - - return new DaysAsDates(date1, date2); - } - private DaysAsDates resultE(GanttDiagram project, RegexResult arg, String suffix) { final int day1 = Integer.parseInt(arg.get("ECOUNT1" + suffix, 0)); final Day date1 = project.getStartingDate().addDays(day1); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java index 0bf87b3fe..e0cb00362 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementDayOfWeek.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementDayOfWeek implements Something { +public class ComplementDayOfWeek implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java b/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java index 52b5a3c96..d8ea753fe 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementEmpty.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementEmpty implements Something { +public class ComplementEmpty implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf(""); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java b/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java index e20149962..ac0eec32b 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementFromTo.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementFromTo implements Something { +public class ComplementFromTo implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "from[%s]+\\[([^\\[\\]]+)\\][%s]+to[%s]+\\[([^\\[\\]]+)\\]"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java index 05fa7851e..a5e6cc3aa 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementInColors implements Something { +public class ComplementInColors implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "in[%s]+(#?\\w+)(?:/(#?\\w+))?"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java index 1a31c1c37..d68fefc74 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementInColors2 implements Something { +public class ComplementInColors2 implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "colou?red[%s]+(?:in[%s]+)?(#?\\w+)(?:/(#?\\w+))?"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java index 05d964cd6..ae9d67cdd 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementInColorsFromTo implements Something { +public class ComplementInColorsFromTo implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java b/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java index 901aef1ba..d8f05d7aa 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementNamed.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementNamed implements Something { +public class ComplementNamed implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("COMPLEMENT" + suffix, "\\[([^\\[\\]]+)\\]"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java b/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java index c2090468d..a72a48027 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementOpen.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementOpen implements Something { +public class ComplementOpen implements Something { public IRegex toRegex(String suffix) { return new RegexLeaf("OPEN" + suffix, "(opene?d?(?: for \\[([^\\[\\]]+?)\\])?)"); diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java b/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java index 03f1ebad2..b59548795 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementSeveralDays.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementSeveralDays implements Something { +public class ComplementSeveralDays implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementTask.java b/src/net/sourceforge/plantuml/project/lang/ComplementTask.java new file mode 100644 index 000000000..79759fcb9 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/ComplementTask.java @@ -0,0 +1,58 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexResult; + +public class ComplementTask implements Something { + + public IRegex toRegex(String suffix) { + return new RegexLeaf("COMPLEMENT" + suffix, "\\[([^\\[\\]]+?)\\]"); + } + + public Failable getMe(GanttDiagram gantt, RegexResult arg, String suffix) { + final String code = arg.get("COMPLEMENT" + suffix, 0); + final Task task = gantt.getExistingTask(code); + if (task == null) + return Failable.error("No such task " + code); + return Failable.ok(task); + } +} diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java b/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java index c7499f38a..5d2c44c9d 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementUrl.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; -public class ComplementUrl implements Something { +public class ComplementUrl implements Something { public IRegex toRegex(String suffix) { return new RegexConcat( // diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java index 688e44b44..b03645955 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class ComplementWithColorLink implements Something { +public class ComplementWithColorLink implements Something { public IRegex toRegex(String suffix) { final String optionalStyle = "(?:(dotted|bold|dashed)[%s]+)?"; diff --git a/src/net/sourceforge/plantuml/project/lang/DayPattern.java b/src/net/sourceforge/plantuml/project/lang/DayPattern.java new file mode 100644 index 000000000..647d204d4 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/DayPattern.java @@ -0,0 +1,136 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.project.time.Day; +import net.sourceforge.plantuml.project.time.Month; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOr; +import net.sourceforge.plantuml.regex.RegexResult; + +public class DayPattern { + + private final String id; + private final String yearKeyA; + private final String yearKeyB; + private final String yearKeyC; + private final String monthKeyA; + private final String monthKeyB; + private final String monthKeyC; + private final String dayKeyA; + private final String dayKeyB; + private final String dayKeyC; + + public DayPattern(String id) { + this.id = id; + this.yearKeyA = "AYEAR" + id; + this.yearKeyB = "BYEAR" + id; + this.yearKeyC = "CYEAR" + id; + this.monthKeyA = "AMONTH" + id; + this.monthKeyB = "BMONTH" + id; + this.monthKeyC = "CMONTH" + id; + this.dayKeyA = "ADAY" + id; + this.dayKeyB = "BDAY" + id; + this.dayKeyC = "CDAY" + id; + } + + public IRegex toRegex() { + return new RegexOr(toRegexA_DD_MONTH_YYYY(), toRegexB_YYYY_MM_DD(), toRegexC_MONTH_DD_YYYY()); + } + + public Day getDay(RegexResult arg) { + if (arg.get(dayKeyA, 0) != null) + return resultA(arg); + + if (arg.get(dayKeyB, 0) != null) + return resultB(arg); + + if (arg.get(dayKeyC, 0) != null) + return resultC(arg); + return null; + } + + private IRegex toRegexA_DD_MONTH_YYYY() { + return new RegexConcat( // + new RegexLeaf(dayKeyA, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(monthKeyA, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(yearKeyA, "([\\d]{1,4})")); + } + + private Day resultA(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyA, 0)); + final String month = arg.get(monthKeyA, 0); + final int year = Integer.parseInt(arg.get(yearKeyA, 0)); + return Day.create(year, month, day); + } + + private IRegex toRegexB_YYYY_MM_DD() { + return new RegexConcat( // + new RegexLeaf(yearKeyB, "([\\d]{1,4})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(monthKeyB, "([\\d]{1,2})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(dayKeyB, "([\\d]{1,2})")); + } + + private Day resultB(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyB, 0)); + final int month = Integer.parseInt(arg.get(monthKeyB, 0)); + final int year = Integer.parseInt(arg.get(yearKeyB, 0)); + return Day.create(year, month, day); + } + + private IRegex toRegexC_MONTH_DD_YYYY() { + return new RegexConcat( // + new RegexLeaf(monthKeyC, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(dayKeyC, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(yearKeyC, "([\\d]{1,4})")); + } + + private Day resultC(RegexResult arg) { + final int day = Integer.parseInt(arg.get(dayKeyC, 0)); + final String month = arg.get(monthKeyC, 0); + final int year = Integer.parseInt(arg.get(yearKeyC, 0)); + return Day.create(year, month, day); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java b/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java index ceb3e679b..9c2a02364 100644 --- a/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java +++ b/src/net/sourceforge/plantuml/project/lang/PairOfSomething.java @@ -35,26 +35,26 @@ */ package net.sourceforge.plantuml.project.lang; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class PairOfSomething implements Something { +public class PairOfSomething implements Something { - private final Something complement1; - private final Something complement2; + private final Something complement1; + private final Something complement2; - public PairOfSomething(Something complement1, Something complement2) { + public PairOfSomething(Something complement1, Something complement2) { this.complement1 = complement1; this.complement2 = complement2; } - public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { - final Failable r1 = complement1.getMe(system, arg, "A" + suffix); - final Failable r2 = complement2.getMe(system, arg, "B" + suffix); + public Failable getMe(D diagram, RegexResult arg, String suffix) { + final Failable r1 = complement1.getMe(diagram, arg, "A" + suffix); + final Failable r2 = complement2.getMe(diagram, arg, "B" + suffix); if (r1.isFail()) { return r1; } diff --git a/src/net/sourceforge/plantuml/project/lang/Sentence.java b/src/net/sourceforge/plantuml/project/lang/Sentence.java index 3110735fd..769157d28 100644 --- a/src/net/sourceforge/plantuml/project/lang/Sentence.java +++ b/src/net/sourceforge/plantuml/project/lang/Sentence.java @@ -36,14 +36,19 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public interface Sentence { +public interface Sentence { + + public final RegexLeaf OPTIONAL_FINAL_DOT = new RegexLeaf("\\s*[.]?\\s*$"); + + public final RegexLeaf SENTENCE_SEPARATOR = new RegexLeaf("\\s*(,|\\sand\\s)\\s*"); public IRegex toRegex(); - public CommandExecutionResult execute(GanttDiagram project, RegexResult arg); + public CommandExecutionResult execute(D project, RegexResult arg); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java b/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java index c2f9bd82b..898a476fc 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceAnd.java @@ -36,19 +36,19 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SentenceAnd implements Sentence { +public class SentenceAnd implements Sentence { - private final SentenceSimple sentence1; - private final SentenceSimple sentence2; + private final SentenceSimple sentence1; + private final SentenceSimple sentence2; - public SentenceAnd(SentenceSimple sentence1, SentenceSimple sentence2) { + public SentenceAnd(SentenceSimple sentence1, SentenceSimple sentence2) { this.sentence1 = sentence1; this.sentence2 = sentence2; } @@ -56,37 +56,37 @@ public class SentenceAnd implements Sentence { public IRegex toRegex() { return new RegexConcat(// RegexLeaf.start(), // - sentence1.subjectii.toRegex(), // + sentence1.getSubject().toRegex(), // RegexLeaf.spaceOneOrMore(), // sentence1.getVerbRegex(), // + sentence1.getAdverbialOrPropositon(), // RegexLeaf.spaceOneOrMore(), // - sentence1.complementii.toRegex("1"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // + sentence1.getComplement().toRegex("1"), // + SENTENCE_SEPARATOR, // sentence2.getVerbRegex(), // + sentence2.getAdverbialOrPropositon(), // RegexLeaf.spaceOneOrMore(), // - sentence2.complementii.toRegex("2"), // - RegexLeaf.end()); + sentence2.getComplement().toRegex("2"), // + OPTIONAL_FINAL_DOT); } - public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { - final Failable subject = sentence1.subjectii.getMe(project, arg); - if (subject.isFail()) { + public final CommandExecutionResult execute(D project, RegexResult arg) { + final Failable subject = sentence1.getSubject().getMe(project, arg); + if (subject.isFail()) return CommandExecutionResult.error(subject.getError()); - } - final Failable complement1 = sentence1.complementii.getMe(project, arg, "1"); - if (complement1.isFail()) { + + final Failable complement1 = sentence1.getComplement().getMe(project, arg, "1"); + if (complement1.isFail()) return CommandExecutionResult.error(complement1.getError()); - } + final CommandExecutionResult result1 = sentence1.execute(project, subject.get(), complement1.get()); - if (result1.isOk() == false) { + if (result1.isOk() == false) return result1; - } - final Failable complement2 = sentence2.complementii.getMe(project, arg, "2"); - if (complement2.isFail()) { + + final Failable complement2 = sentence2.getComplement().getMe(project, arg, "2"); + if (complement2.isFail()) return CommandExecutionResult.error(complement2.getError()); - } + return sentence2.execute(project, subject.get(), complement2.get()); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java b/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java index 3385842fc..5e8ba2406 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceAndAnd.java @@ -36,20 +36,20 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SentenceAndAnd implements Sentence { +public class SentenceAndAnd implements Sentence { - private final SentenceSimple sentence1; - private final SentenceSimple sentence2; - private final SentenceSimple sentence3; + private final SentenceSimple sentence1; + private final SentenceSimple sentence2; + private final SentenceSimple sentence3; - public SentenceAndAnd(SentenceSimple sentence1, SentenceSimple sentence2, SentenceSimple sentence3) { + public SentenceAndAnd(SentenceSimple sentence1, SentenceSimple sentence2, SentenceSimple sentence3) { this.sentence1 = sentence1; this.sentence2 = sentence2; this.sentence3 = sentence3; @@ -58,51 +58,50 @@ public class SentenceAndAnd implements Sentence { public IRegex toRegex() { return new RegexConcat(// RegexLeaf.start(), // - sentence1.subjectii.toRegex(), // + sentence1.getSubject().toRegex(), // RegexLeaf.spaceOneOrMore(), // sentence1.getVerbRegex(), // + sentence1.getAdverbialOrPropositon(), // RegexLeaf.spaceOneOrMore(), // - sentence1.complementii.toRegex("1"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // + sentence1.getComplement().toRegex("1"), // + SENTENCE_SEPARATOR, // sentence2.getVerbRegex(), // + sentence2.getAdverbialOrPropositon(), // RegexLeaf.spaceOneOrMore(), // - sentence2.complementii.toRegex("2"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // - RegexLeaf.spaceOneOrMore(), // + sentence2.getComplement().toRegex("2"), // + SENTENCE_SEPARATOR, // sentence3.getVerbRegex(), // + sentence3.getAdverbialOrPropositon(), // RegexLeaf.spaceOneOrMore(), // - sentence3.complementii.toRegex("3"), // - RegexLeaf.end()); + sentence3.getComplement().toRegex("3"), // + OPTIONAL_FINAL_DOT); } - public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { - final Failable subject = sentence1.subjectii.getMe(project, arg); - if (subject.isFail()) { + public final CommandExecutionResult execute(D project, RegexResult arg) { + final Failable subject = sentence1.getSubject().getMe(project, arg); + if (subject.isFail()) return CommandExecutionResult.error(subject.getError()); - } - final Failable complement1 = sentence1.complementii.getMe(project, arg, "1"); - if (complement1.isFail()) { + + final Failable complement1 = sentence1.getComplement().getMe(project, arg, "1"); + if (complement1.isFail()) return CommandExecutionResult.error(complement1.getError()); - } + final CommandExecutionResult result1 = sentence1.execute(project, subject.get(), complement1.get()); - if (result1.isOk() == false) { + if (result1.isOk() == false) return result1; - } - final Failable complement2 = sentence2.complementii.getMe(project, arg, "2"); - if (complement2.isFail()) { + + final Failable complement2 = sentence2.getComplement().getMe(project, arg, "2"); + if (complement2.isFail()) return CommandExecutionResult.error(complement2.getError()); - } + final CommandExecutionResult result2 = sentence2.execute(project, subject.get(), complement2.get()); - if (result2.isOk() == false) { + if (result2.isOk() == false) return result2; - } - final Failable complement3 = sentence3.complementii.getMe(project, arg, "3"); - if (complement3.isFail()) { + + final Failable complement3 = sentence3.getComplement().getMe(project, arg, "3"); + if (complement3.isFail()) return CommandExecutionResult.error(complement3.getError()); - } + final CommandExecutionResult result3 = sentence3.execute(project, subject.get(), complement3.get()); return result3; diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java b/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java index 4e4c955cb..9881a9a6b 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceDisplayOnSameRowAs.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SentenceDisplayOnSameRowAs extends SentenceSimple { +public class SentenceDisplayOnSameRowAs extends SentenceSimple { public SentenceDisplayOnSameRowAs() { super(SubjectTask.ME, Verbs.displayOnSameRowAs, new ComplementNamed()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java b/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java index 1fad6f20e..8cccba70f 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceEnds.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; -public class SentenceEnds extends SentenceSimple { +public class SentenceEnds extends SentenceSimple { public SentenceEnds() { super(SubjectTask.ME, Verbs.ends, new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java b/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java index 4c41586f3..7d408b59c 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceHappens.java @@ -41,10 +41,11 @@ import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskInstant; -public class SentenceHappens extends SentenceSimple { +public class SentenceHappens extends SentenceSimple { public SentenceHappens() { - super(SubjectTask.ME, Verbs.happens, new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); + super(SubjectTask.ME, Verbs.happens, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), + new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java index 2d1b81ead..8dd8ceac8 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java @@ -41,10 +41,10 @@ import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class SentenceHappensDate extends SentenceSimple { +public class SentenceHappensDate extends SentenceSimple { public SentenceHappensDate() { - super(SubjectTask.ME, Verbs.happens, new ComplementDate()); + super(SubjectTask.ME, Verbs.happens, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), ComplementDate.any()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java index 67b576d84..8787d7472 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsColored.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SentenceIsColored extends SentenceSimple { +public class SentenceIsColored extends SentenceSimple { public SentenceIsColored() { super(SubjectTask.ME, Verbs.isColored, new ComplementInColors()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java index 8aa022a2b..502b2e370 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java @@ -39,10 +39,11 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SentenceIsColoredForCompletion extends SentenceSimple { +public class SentenceIsColoredForCompletion extends SentenceSimple { public SentenceIsColoredForCompletion() { - super(SubjectTask.ME, Verbs.isColoredForCompletion, new ComplementInColorsFromTo()); + super(SubjectTask.ME, Verbs.isColored, Words.exactly(Words.FOR, Words.COMPLETION), + new ComplementInColorsFromTo()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java index 470793882..6e9840f49 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsDeleted.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SentenceIsDeleted extends SentenceSimple { +public class SentenceIsDeleted extends SentenceSimple { public SentenceIsDeleted() { super(SubjectTask.ME, Verbs.isDeleted, new ComplementEmpty()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsDisplayedAs.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsDisplayedAs.java new file mode 100644 index 000000000..9cd47e52c --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsDisplayedAs.java @@ -0,0 +1,56 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceIsDisplayedAs extends SentenceSimple { + + public SentenceIsDisplayedAs() { + super(SubjectTask.ME, Verbs.isDisplayedAs, new ComplementAnything()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final String displayString = (String) complement; + task.setDisplay(displayString); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java index f69a156e7..2744814c7 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsForTask.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.project.Completion; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -public class SentenceIsForTask extends SentenceSimple { +public class SentenceIsForTask extends SentenceSimple { public SentenceIsForTask() { super(SubjectTask.ME, Verbs.is, new ComplementCompleted()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java b/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java index 68aca0d68..0901fd427 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceLinksTo.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.url.Url; -public class SentenceLinksTo extends SentenceSimple { +public class SentenceLinksTo extends SentenceSimple { public SentenceLinksTo() { super(SubjectTask.ME, Verbs.linksTo, new ComplementUrl()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java b/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java index b307a2dc1..04fe2c3e3 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceOccurs.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; -public class SentenceOccurs extends SentenceSimple { +public class SentenceOccurs extends SentenceSimple { public SentenceOccurs() { super(SubjectTask.ME, Verbs.occurs, new ComplementFromTo()); diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java index bc311db46..893a20967 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java @@ -40,10 +40,11 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class SentencePausesDate extends SentenceSimple { +public class SentencePausesDate extends SentenceSimple { public SentencePausesDate() { - super(SubjectTask.ME, Verbs.pauses, new ComplementDate()); + super(SubjectTask.ME, Verbs.pauses, Words.zeroOrMore(Words.THE, Words.ON, Words.AT, Words.FROM), + ComplementDate.any()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java index 9fdf7dc5e..36ac07c9a 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java @@ -41,23 +41,20 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class SentencePausesDates extends SentenceSimple { +public class SentencePausesDates extends SentenceSimple { public SentencePausesDates() { - super(SubjectTask.ME, Verbs.pauses, new ComplementDates()); + super(SubjectTask.ME, Verbs.pauses, Words.zeroOrMore(Words.THE, Words.ON, Words.AT, Words.FROM), + new ComplementDates()); } @Override public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Task task = (Task) subject; final DaysAsDates pauses = (DaysAsDates) complement; -// final Day startingDate = project.getStartingDate(); -// if (startingDate == null) { -// return CommandExecutionResult.error("No starting date for the project"); -// } - for (Day day : pauses) { + for (Day day : pauses) task.addPause(day); - } + return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java index 05526f414..da52bf859 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDayOfWeek.java @@ -40,10 +40,11 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.DayOfWeek; -public class SentencePausesDayOfWeek extends SentenceSimple { +public class SentencePausesDayOfWeek extends SentenceSimple { public SentencePausesDayOfWeek() { - super(SubjectTask.ME, Verbs.pauses, new ComplementDayOfWeek()); + super(SubjectTask.ME, Verbs.pauses, Words.zeroOrMore(Words.THE, Words.ON, Words.AT, Words.FROM), + new ComplementDayOfWeek()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceLasts.java b/src/net/sourceforge/plantuml/project/lang/SentenceRequire.java similarity index 91% rename from src/net/sourceforge/plantuml/project/lang/SentenceLasts.java rename to src/net/sourceforge/plantuml/project/lang/SentenceRequire.java index 8927dc05b..d866359c9 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceLasts.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceRequire.java @@ -40,10 +40,10 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.core.Task; -public class SentenceLasts extends SentenceSimple { +public class SentenceRequire extends SentenceSimple { - public SentenceLasts() { - super(SubjectTask.ME, Verbs.lasts, new ComplementSeveralDays()); + public SentenceRequire() { + super(SubjectTask.ME, Verbs.requires, new ComplementSeveralDays()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java index 745dc4b39..a82b8121e 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java @@ -36,65 +36,85 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public abstract class SentenceSimple implements Sentence { +public abstract class SentenceSimple implements Sentence { - protected final Subject subjectii; + private final Subject subject; private final IRegex verb; - protected final Something complementii; + private final IRegex adverbialOrPropositon; + private final Something complement; - public SentenceSimple(Subject subject, IRegex verb, Something complement) { - this.subjectii = subject; + public SentenceSimple(Subject subject, IRegex verb, Something complement) { + this(subject, verb, new RegexLeaf(""), complement); + } + + public SentenceSimple(Subject subject, IRegex verb, IRegex adverbialOrPropositon, Something complement) { + this.subject = subject; this.verb = verb; - this.complementii = complement; + this.adverbialOrPropositon = adverbialOrPropositon; + this.complement = complement; } public String getSignature() { - return subjectii.getClass() + "/" + verb.getPattern() + "/" + complementii.getClass(); + return subject.getClass() + "/" + verb.getPattern() + "/" + complement.getClass(); } public final IRegex toRegex() { - if (complementii instanceof ComplementEmpty) + if (complement instanceof ComplementEmpty) return new RegexConcat(// RegexLeaf.start(), // - subjectii.toRegex(), // + subject.toRegex(), // RegexLeaf.spaceOneOrMore(), // verb, // - RegexLeaf.end()); + adverbialOrPropositon, // + OPTIONAL_FINAL_DOT); return new RegexConcat(// RegexLeaf.start(), // - subjectii.toRegex(), // + subject.toRegex(), // RegexLeaf.spaceOneOrMore(), // verb, // + adverbialOrPropositon, // RegexLeaf.spaceOneOrMore(), // - complementii.toRegex("0"), // - RegexLeaf.end()); + complement.toRegex("0"), // + OPTIONAL_FINAL_DOT); } - public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { - final Failable subject = subjectii.getMe(project, arg); - if (subject.isFail()) - return CommandExecutionResult.error(subject.getError()); + public final CommandExecutionResult execute(D project, RegexResult arg) { + final Failable currentSubject = subject.getMe(project, arg); + if (currentSubject.isFail()) + return CommandExecutionResult.error(currentSubject.getError()); - final Failable complement = complementii.getMe(project, arg, "0"); - if (complement.isFail()) - return CommandExecutionResult.error(complement.getError()); + final Failable currentComplement = complement.getMe(project, arg, "0"); + if (currentComplement.isFail()) + return CommandExecutionResult.error(currentComplement.getError()); - return execute(project, subject.get(), complement.get()); + return execute(project, currentSubject.get(), currentComplement.get()); } - public abstract CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement); + public abstract CommandExecutionResult execute(D project, Object subject, Object complement); public IRegex getVerbRegex() { return verb; } + protected final IRegex getAdverbialOrPropositon() { + return adverbialOrPropositon; + } + + protected final Subject getSubject() { + return subject; + } + + protected final Something getComplement() { + return complement; + } + } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java index 484f7a41b..57d26e398 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java @@ -40,12 +40,13 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class SentenceTaskEndsAbsolute extends SentenceSimple { +public class SentenceTaskEndsAbsolute extends SentenceSimple { public SentenceTaskEndsAbsolute() { - super(SubjectTask.ME, Verbs.ends2, new ComplementDate()); + super(SubjectTask.ME, Verbs.ends, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), ComplementDate.any()); } + @Override public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Task task = (Task) subject; diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsOnlyRelative.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsOnlyRelative.java new file mode 100644 index 000000000..0fbbd5676 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsOnlyRelative.java @@ -0,0 +1,59 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.Day; + +public class SentenceTaskEndsOnlyRelative extends SentenceSimple { + + public SentenceTaskEndsOnlyRelative() { + super(SubjectTask.ME, Verbs.ends, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), + ComplementDate.onlyRelative()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day end = (Day) complement; + + task.setEnd(end); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java index 8737f4020..95aeb442b 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java @@ -43,10 +43,10 @@ import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; -public class SentenceTaskStarts extends SentenceSimple { +public class SentenceTaskStarts extends SentenceSimple { public SentenceTaskStarts() { - super(SubjectTask.ME, Verbs.starts2, new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); + super(SubjectTask.ME, Verbs.starts, new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java index e535412e0..a37db325d 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java @@ -40,10 +40,10 @@ import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -public class SentenceTaskStartsAbsolute extends SentenceSimple { +public class SentenceTaskStartsAbsolute extends SentenceSimple { public SentenceTaskStartsAbsolute() { - super(SubjectTask.ME, Verbs.starts3, new ComplementDate()); + super(SubjectTask.ME, Verbs.starts, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), ComplementDate.any()); } @Override @@ -52,7 +52,7 @@ public class SentenceTaskStartsAbsolute extends SentenceSimple { final Day start = (Day) complement; final Day startingDate = project.getStartingDate(); if (startingDate.getAbsoluteDayNum() == 0) - project.setProjectStartingDate(start); + return CommandExecutionResult.error("No starting date for the project"); task.setStart(start); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsOnlyRelative.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsOnlyRelative.java new file mode 100644 index 000000000..223a321d4 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsOnlyRelative.java @@ -0,0 +1,59 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; +import net.sourceforge.plantuml.project.time.Day; + +public class SentenceTaskStartsOnlyRelative extends SentenceSimple { + + public SentenceTaskStartsOnlyRelative() { + super(SubjectTask.ME, Verbs.starts, Words.zeroOrMore(Words.THE, Words.ON, Words.AT), + ComplementDate.onlyRelative()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final Day start = (Day) complement; + + task.setStart(start); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java index 9029d0a8a..a02ff614a 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsWithColor.java @@ -43,11 +43,11 @@ import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskInstant; -public class SentenceTaskStartsWithColor extends SentenceSimple { +public class SentenceTaskStartsWithColor extends SentenceSimple { public SentenceTaskStartsWithColor() { - super(SubjectTask.ME, Verbs.starts2, - new PairOfSomething(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementWithColorLink())); + super(SubjectTask.ME, Verbs.starts, + new PairOfSomething<>(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementWithColorLink())); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/Something.java b/src/net/sourceforge/plantuml/project/lang/Something.java index 174518188..ac005a991 100644 --- a/src/net/sourceforge/plantuml/project/lang/Something.java +++ b/src/net/sourceforge/plantuml/project/lang/Something.java @@ -35,15 +35,15 @@ */ package net.sourceforge.plantuml.project.lang; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexResult; -public interface Something { +public interface Something { public IRegex toRegex(String suffix); - public Failable getMe(GanttDiagram project, RegexResult arg, String suffix); + public Failable getMe(D diagram, RegexResult arg, String suffix); } diff --git a/src/net/sourceforge/plantuml/project/lang/Subject.java b/src/net/sourceforge/plantuml/project/lang/Subject.java index 92c80670c..f53c0f906 100644 --- a/src/net/sourceforge/plantuml/project/lang/Subject.java +++ b/src/net/sourceforge/plantuml/project/lang/Subject.java @@ -37,17 +37,17 @@ package net.sourceforge.plantuml.project.lang; import java.util.Collection; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.project.Failable; -import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexResult; -public interface Subject { +public interface Subject { - public Collection getSentences(); + public Collection> getSentences(); public IRegex toRegex(); - public Failable getMe(GanttDiagram project, RegexResult arg); + public Failable getMe(D project, RegexResult arg); } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java b/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java index 9394b889e..ddc48e6e1 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDayAsDate.java @@ -49,9 +49,9 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectDayAsDate implements Subject { +public class SubjectDayAsDate implements Subject { - public static final Subject ME = new SubjectDayAsDate(); + public static final Subject ME = new SubjectDayAsDate(); private SubjectDayAsDate() { } @@ -89,11 +89,11 @@ public class SubjectDayAsDate implements Subject { throw new IllegalStateException(); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new Close(), new Open(), new InColor()); } - class Close extends SentenceSimple { + class Close extends SentenceSimple { public Close() { super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementClose()); @@ -106,7 +106,7 @@ public class SubjectDayAsDate implements Subject { } } - class Open extends SentenceSimple { + class Open extends SentenceSimple { public Open() { super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementOpen()); } @@ -118,7 +118,7 @@ public class SubjectDayAsDate implements Subject { } } - class InColor extends SentenceSimple { + class InColor extends SentenceSimple { public InColor() { super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementInColors2()); @@ -138,12 +138,7 @@ public class SubjectDayAsDate implements Subject { } private IRegex toRegexB() { - return new RegexConcat( // - new RegexLeaf("BYEAR", "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH", "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY", "([\\d]{1,2})")); + return TimeResolution.toRegexB_YYYY_MM_DD("BYEAR", "BMONTH", "BDAY"); } private IRegex toRegexE() { diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java b/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java index a1c643774..9b4fffd05 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDayOfWeek.java @@ -47,9 +47,9 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectDayOfWeek implements Subject { +public class SubjectDayOfWeek implements Subject { - public static final Subject ME = new SubjectDayOfWeek(); + public static final Subject ME = new SubjectDayOfWeek(); private SubjectDayOfWeek() { } @@ -63,11 +63,11 @@ public class SubjectDayOfWeek implements Subject { return Failable.ok(DayOfWeek.fromString(s)); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new AreClose(), new AreOpen(), new InColor()); } - class AreOpen extends SentenceSimple { + class AreOpen extends SentenceSimple { public AreOpen() { super(SubjectDayOfWeek.this, Verbs.are, new ComplementOpen()); } @@ -80,7 +80,7 @@ public class SubjectDayOfWeek implements Subject { } } - class AreClose extends SentenceSimple { + class AreClose extends SentenceSimple { public AreClose() { super(SubjectDayOfWeek.this, Verbs.are, new ComplementClose()); @@ -95,7 +95,7 @@ public class SubjectDayOfWeek implements Subject { } - class InColor extends SentenceSimple { + class InColor extends SentenceSimple { public InColor() { super(SubjectDayOfWeek.this, Verbs.isOrAre, new ComplementInColors2()); diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java b/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java index e3f48196f..6f8955fa7 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectDaysAsDates.java @@ -50,9 +50,9 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectDaysAsDates implements Subject { +public class SubjectDaysAsDates implements Subject { - public static final Subject ME = new SubjectDaysAsDates(); + public static final Subject ME = new SubjectDaysAsDates(); private SubjectDaysAsDates() { } @@ -63,19 +63,10 @@ public class SubjectDaysAsDates implements Subject { private IRegex toRegexB() { return new RegexConcat( // - new RegexLeaf("BYEAR1", "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH1", "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY1", "([\\d]{1,2})"), // + TimeResolution.toRegexB_YYYY_MM_DD("BYEAR1", "BMONTH1", "BDAY1"), // + Words.exactly(Words.TO), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("to"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("BYEAR2", "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH2", "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY2", "([\\d]{1,2})") // + TimeResolution.toRegexB_YYYY_MM_DD("BYEAR2", "BMONTH2", "BDAY2") // ); } @@ -83,8 +74,7 @@ public class SubjectDaysAsDates implements Subject { return new RegexConcat( // new RegexLeaf("[dD]\\+"), // new RegexLeaf("ECOUNT1", "([\\d]+)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("to"), // + Words.exactly(Words.TO), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("[dD]\\+"), // new RegexLeaf("ECOUNT2", "([\\d]+)") // @@ -93,13 +83,8 @@ public class SubjectDaysAsDates implements Subject { private IRegex andRegex() { return new RegexConcat( // - new RegexLeaf("BYEAR3", "([\\d]{4})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BMONTH3", "([\\d]{1,2})"), // - new RegexLeaf("\\D"), // - new RegexLeaf("BDAY3", "([\\d]{1,2})"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("and"), // + TimeResolution.toRegexB_YYYY_MM_DD("BYEAR3", "BMONTH3", "BDAY3"), // + Words.exactly(Words.AND), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("COUNT_AND", "([\\d]+)"), // RegexLeaf.spaceOneOrMore(), // @@ -151,11 +136,11 @@ public class SubjectDaysAsDates implements Subject { throw new IllegalStateException(); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new Close(), new Open(), new InColor(), new Named()); } - class Close extends SentenceSimple { + class Close extends SentenceSimple { public Close() { super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementClose()); @@ -171,7 +156,7 @@ public class SubjectDaysAsDates implements Subject { } } - class Open extends SentenceSimple { + class Open extends SentenceSimple { public Open() { super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementOpen()); @@ -188,7 +173,7 @@ public class SubjectDaysAsDates implements Subject { } - class InColor extends SentenceSimple { + class InColor extends SentenceSimple { public InColor() { super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementInColors2()); @@ -206,7 +191,7 @@ public class SubjectDaysAsDates implements Subject { } - class Named extends SentenceSimple { + class Named extends SentenceSimple { public Named() { super(SubjectDaysAsDates.this, Verbs.isOrAreNamed, new ComplementNamed()); diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java b/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java index c76eaec28..164726cb6 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectLinks.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; // Removed -public class SubjectLinks implements Subject { +public class SubjectLinks implements Subject { private SubjectLinks() { } @@ -59,11 +59,11 @@ public class SubjectLinks implements Subject { return Failable.ok(project); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new InColor()); } - public class InColor extends SentenceSimple { + public class InColor extends SentenceSimple { public InColor() { super(SubjectLinks.this, Verbs.areColored, new ComplementInColors()); diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java index 7b7a29c4d..6bafeb2f2 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java @@ -46,9 +46,9 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectProject implements Subject { +public class SubjectProject implements Subject { - public static final Subject ME = new SubjectProject(); + public static final Subject ME = new SubjectProject(); private SubjectProject() { } @@ -61,14 +61,15 @@ public class SubjectProject implements Subject { return Failable.ok(project); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new Starts()); } - class Starts extends SentenceSimple { + class Starts extends SentenceSimple { public Starts() { - super(SubjectProject.this, Verbs.starts, new ComplementDate()); + super(SubjectProject.this, Verbs.starts, Words.zeroOrMore(Words.ON, Words.FOR, Words.THE, Words.AT), + ComplementDate.onlyAbsolute()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java index 95b813ce9..ab9ab182a 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java @@ -43,43 +43,105 @@ import net.sourceforge.plantuml.project.DaysAsDates; import net.sourceforge.plantuml.project.Failable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Resource; +import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; import net.sourceforge.plantuml.regex.IRegex; -import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectResource implements Subject { +public class SubjectResource implements Subject { - public static final Subject ME = new SubjectResource(); + public static final Subject ME = new SubjectResource(); private SubjectResource() { } - public Failable getMe(GanttDiagram project, RegexResult arg) { - final String s = arg.get("RESOURCE", 0); - return Failable.ok(project.getResource(s)); + public Failable getMe(GanttDiagram gantt, RegexResult arg) { + if (arg.get("THEY", 0) != null) { + final Resource they = gantt.getThey(); + if (they == null) + return Failable.error("Not sure who are you refering to?"); + return Failable.ok(they); + } + final String resource = arg.get("RESOURCE", 0); + final Resource result = gantt.getResource(resource); + gantt.setThey(result); + return Failable.ok(result); } - public Collection getSentences() { - return Arrays.asList(new IsOffDate(), new IsOffDates(), new IsOffDayOfWeek(), new IsOnDate(), new IsOnDates()); + public Collection> getSentences() { + return Arrays.asList(new IsOffDate(), new IsOffDates(), new IsOffDayOfWeek(), new IsOnDate(), new IsOnDates(), + new IsOffBeforeDate(), new IsOffAfterDate(), new WorksOn()); } public IRegex toRegex() { - return new RegexConcat( // + return new RegexOr( // + new RegexLeaf("THEY", "(she|he|they)"), // new RegexLeaf("RESOURCE", "\\{([^{}]+)\\}") // ); } - public class IsOffDate extends SentenceSimple { + public class WorksOn extends SentenceSimple { - public IsOffDate() { - super(SubjectResource.this, Verbs.isOff, new ComplementDate()); + public WorksOn() { + super(SubjectResource.this, Verbs.worksOn, new ComplementTask()); } @Override - public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { + final Resource resource = (Resource) subject; + final Task task = (Task) complement; + task.addResource(resource, 100); + return CommandExecutionResult.ok(); + } + + } + + public class IsOffBeforeDate extends SentenceSimple { + + public IsOffBeforeDate() { + super(SubjectResource.this, Verbs.isOff, + Words.concat(Words.exactly(Words.BEFORE), Words.zeroOrMore(Words.THE)), ComplementDate.any()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { + final Resource resource = (Resource) subject; + final Day when = (Day) complement; + resource.setOffBeforeDate(when); + return CommandExecutionResult.ok(); + } + + } + + public class IsOffAfterDate extends SentenceSimple { + + public IsOffAfterDate() { + super(SubjectResource.this, Verbs.isOff, + Words.concat(Words.exactly(Words.AFTER), Words.zeroOrMore(Words.THE)), ComplementDate.any()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { + final Resource resource = (Resource) subject; + final Day when = (Day) complement; + resource.setOffAfterDate(when); + return CommandExecutionResult.ok(); + } + + } + + public class IsOffDate extends SentenceSimple { + + public IsOffDate() { + super(SubjectResource.this, Verbs.isOff, + Words.zeroOrMore(Words.FROM, Words.ON, Words.FOR, Words.THE, Words.AT), ComplementDate.any()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { final Resource resource = (Resource) subject; final Day when = (Day) complement; resource.addCloseDay(when); @@ -88,14 +150,15 @@ public class SubjectResource implements Subject { } - public class IsOffDates extends SentenceSimple { + public class IsOffDates extends SentenceSimple { public IsOffDates() { - super(SubjectResource.this, Verbs.isOff, new ComplementDates()); + super(SubjectResource.this, Verbs.isOff, + Words.zeroOrMore(Words.FROM, Words.ON, Words.FOR, Words.THE, Words.AT), new ComplementDates()); } @Override - public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { final Resource resource = (Resource) subject; for (Day when : (DaysAsDates) complement) { resource.addCloseDay(when); @@ -105,14 +168,15 @@ public class SubjectResource implements Subject { } - public class IsOffDayOfWeek extends SentenceSimple { + public class IsOffDayOfWeek extends SentenceSimple { public IsOffDayOfWeek() { - super(SubjectResource.this, Verbs.isOff, new ComplementDayOfWeek()); + super(SubjectResource.this, Verbs.isOff, + Words.zeroOrMore(Words.FROM, Words.ON, Words.FOR, Words.THE, Words.AT), new ComplementDayOfWeek()); } @Override - public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { final Resource resource = (Resource) subject; resource.addCloseDay(((DayOfWeek) complement)); return CommandExecutionResult.ok(); @@ -120,14 +184,15 @@ public class SubjectResource implements Subject { } - public class IsOnDate extends SentenceSimple { + public class IsOnDate extends SentenceSimple { public IsOnDate() { - super(SubjectResource.this, Verbs.isOn, new ComplementDate()); + super(SubjectResource.this, Verbs.isOn, + Words.zeroOrMore(Words.FROM, Words.ON, Words.FOR, Words.THE, Words.AT), ComplementDate.any()); } @Override - public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { final Resource resource = (Resource) subject; final Day when = (Day) complement; resource.addForceOnDay(when); @@ -136,14 +201,15 @@ public class SubjectResource implements Subject { } - public class IsOnDates extends SentenceSimple { + public class IsOnDates extends SentenceSimple { public IsOnDates() { - super(SubjectResource.this, Verbs.isOn, new ComplementDates()); + super(SubjectResource.this, Verbs.isOn, + Words.zeroOrMore(Words.FROM, Words.ON, Words.FOR, Words.THE, Words.AT), new ComplementDates()); } @Override - public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + public CommandExecutionResult execute(GanttDiagram gantt, Object subject, Object complement) { final Resource resource = (Resource) subject; for (Day when : (DaysAsDates) complement) { resource.addForceOnDay(when); diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectSeparator.java b/src/net/sourceforge/plantuml/project/lang/SubjectSeparator.java index 85344a55f..473696163 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectSeparator.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectSeparator.java @@ -47,9 +47,9 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectSeparator implements Subject { +public class SubjectSeparator implements Subject { - public static final Subject ME = new SubjectSeparator(); + public static final Subject ME = new SubjectSeparator(); private SubjectSeparator() { } @@ -62,14 +62,14 @@ public class SubjectSeparator implements Subject { return Failable.ok(project); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new JustBefore(), new JustAfter(), new Just()); } - class JustBefore extends SentenceSimple { + class JustBefore extends SentenceSimple { public JustBefore() { - super(SubjectSeparator.this, Verbs.justBefore, new ComplementDate()); + super(SubjectSeparator.this, Verbs.just, Words.exactly(Words.BEFORE), ComplementDate.any()); } @Override @@ -82,10 +82,10 @@ public class SubjectSeparator implements Subject { } - class JustAfter extends SentenceSimple { + class JustAfter extends SentenceSimple { public JustAfter() { - super(SubjectSeparator.this, Verbs.justAfter, new ComplementDate()); + super(SubjectSeparator.this, Verbs.just, Words.exactly(Words.AFTER), ComplementDate.any()); } @Override @@ -98,7 +98,7 @@ public class SubjectSeparator implements Subject { } - class Just extends SentenceSimple { + class Just extends SentenceSimple { public Just() { super(SubjectSeparator.this, Verbs.just, new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java index b9386bb85..0a0ef31dd 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java @@ -46,32 +46,51 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; +import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; -public class SubjectTask implements Subject { +public class SubjectTask implements Subject { - public static final Subject ME = new SubjectTask(); + public static final Subject ME = new SubjectTask(); private SubjectTask() { } - public Failable getMe(GanttDiagram project, RegexResult arg) { - final String s = arg.get("SUBJECT", 0); - final String shortName = arg.get("SUBJECT", 1); - final String then = arg.get("THEN", 0); - final String resource = arg.get("RESOURCE", 0); - final Task result = project.getOrCreateTask(s, shortName, then != null); - if (result == null) { - throw new IllegalStateException(); + public Failable getMe(GanttDiagram gantt, RegexResult arg) { + final Task result; + if (arg.get("IT", 0) != null) { + result = gantt.getIt(); + if (result == null) + return Failable.error("Not sure what are you refering to?"); + } else { + final String subject = arg.get("SUBJECT", 0); + final String shortName = arg.get("SHORTNAME", 0); + final String then = arg.get("THEN", 0); + final String stereotype = arg.get("STEREOTYPE", 0); + + result = gantt.getOrCreateTask(subject, shortName, then != null); + + if (stereotype != null) + result.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); + + + gantt.setIt(result); } + + if (result == null) + throw new IllegalStateException(); + + final String resource = arg.get("RESOURCE", 0); if (resource != null) { for (final StringTokenizer st = new StringTokenizer(resource, "{}"); st.hasMoreTokens();) { final String part = st.nextToken().trim(); if (part.length() > 0) { - final boolean ok = project.affectResource(result, part); - if (ok == false) { + final boolean ok = gantt.affectResource(result, part); + if (ok == false) return Failable.error("Bad argument for resource"); - } + } } @@ -79,27 +98,31 @@ public class SubjectTask implements Subject { return Failable.ok(result); } - public Collection getSentences() { - return Arrays.asList(new SentenceLasts(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(), - new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(), + public Collection> getSentences() { + return Arrays.asList(new SentenceRequire(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(), + new SentenceTaskStartsOnlyRelative(), new SentenceTaskStartsAbsolute(), new SentenceHappens(), + new SentenceHappensDate(), new SentenceEnds(), new SentenceTaskEndsOnlyRelative(), new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsColoredForCompletion(), new SentenceIsDeleted(), new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), new SentenceDisplayOnSameRowAs(), new SentencePausesDate(), new SentencePausesDates(), - new SentencePausesDayOfWeek()); + new SentencePausesDayOfWeek(), new SentenceIsDisplayedAs()); } public IRegex toRegex() { - return new RegexConcat( // - new RegexLeaf("THEN", "(then[%s]+)?"), // - new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\](?:[%s]+as[%s]+\\[([^\\[\\]]+?)\\])?"), // - new RegexOptional( // - new RegexConcat( // + return new RegexOr( // + new RegexLeaf("IT", "(it)"), // + new RegexConcat(new RegexLeaf("THEN", "(then[%s]+)?"), // + new RegexLeaf("SUBJECT", "\\[([^\\[\\]]+?)\\]"), // + StereotypePattern.optional("STEREOTYPE"), // + new RegexOptional(new RegexConcat(// + Words.exactly(Words.AS), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("on"), // + new RegexLeaf("SHORTNAME", "\\[([^\\[\\]]+?)\\]"))), // + new RegexOptional(new RegexConcat( // + Words.exactly(Words.ON), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("RESOURCE", "((?:\\{[^{}]+\\}[%s]*)+)") // - )) // - ); + )))); } } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectToday.java b/src/net/sourceforge/plantuml/project/lang/SubjectToday.java index 05c58e6eb..0f4854f16 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectToday.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectToday.java @@ -48,10 +48,10 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; -public class SubjectToday implements Subject { - // ::remove folder when __HAXE__ +public class SubjectToday implements Subject { + // ::remove folder when __HAXE__ - public static final Subject ME = new SubjectToday(); + public static final Subject ME = new SubjectToday(); private SubjectToday() { } @@ -66,11 +66,11 @@ public class SubjectToday implements Subject { return Failable.ok(new Today()); } - public Collection getSentences() { + public Collection> getSentences() { return Arrays.asList(new InColor(), new IsDate()); } - class InColor extends SentenceSimple { + class InColor extends SentenceSimple { public InColor() { super(SubjectToday.this, Verbs.isColored, new ComplementInColors()); @@ -87,10 +87,10 @@ public class SubjectToday implements Subject { } - class IsDate extends SentenceSimple { + class IsDate extends SentenceSimple { public IsDate() { - super(SubjectToday.this, Verbs.is, new ComplementDate()); + super(SubjectToday.this, Verbs.is, ComplementDate.any()); } @Override diff --git a/src/net/sourceforge/plantuml/project/lang/TimeResolution.java b/src/net/sourceforge/plantuml/project/lang/TimeResolution.java new file mode 100644 index 000000000..8d9015823 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/TimeResolution.java @@ -0,0 +1,72 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.project.time.Month; +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; + +public abstract class TimeResolution { + + public static IRegex toRegexA_DD_MONTH_YYYY(String year, String month, String day) { + return new RegexConcat( // + new RegexLeaf(day, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(month, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(year, "([\\d]{1,4})")); + } + + public static IRegex toRegexB_YYYY_MM_DD(String year, String month, String day) { + return new RegexConcat( // + new RegexLeaf(year, "([\\d]{1,4})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(month, "([\\d]{1,2})"), // + new RegexLeaf("\\D"), // + new RegexLeaf(day, "([\\d]{1,2})")); + } + + public static IRegex toRegexC_MONTH_DD_YYYY(String year, String month, String day) { + return new RegexConcat( // + new RegexLeaf(month, "(" + Month.getRegexString() + ")"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(day, "([\\d]{1,2})"), // + new RegexLeaf("[\\w, ]*?"), // + new RegexLeaf(year, "([\\d]{1,4})")); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/Verbs.java b/src/net/sourceforge/plantuml/project/lang/Verbs.java index f80c3a88e..107a16b3f 100644 --- a/src/net/sourceforge/plantuml/project/lang/Verbs.java +++ b/src/net/sourceforge/plantuml/project/lang/Verbs.java @@ -36,87 +36,29 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.regex.IRegex; -import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; -import net.sourceforge.plantuml.regex.RegexOptional; -import net.sourceforge.plantuml.regex.RegexOr; public class Verbs { public static IRegex are = new RegexLeaf("are"); - public static IRegex areColored = new RegexLeaf("are[%s]+colou?red"); - public static IRegex displayOnSameRowAs = new RegexLeaf("displays?[%s]+on[%s]+same[%s]+row[%s]+as"); - public static IRegex ends = new RegexLeaf("ends"); - - public static IRegex ends2 = new RegexLeaf("ends[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); - - public static IRegex happens = new RegexLeaf("happens?[%s]*(at[%s]*|the[%s]*|on[%s]*)*"); - - public static IRegex pauses = new RegexLeaf("pauses?[%s]*(at[%s]*|the[%s]*|on[%s]*|from[%s]*)*"); - - public static IRegex isDeleted = new RegexLeaf("is[%s]+deleted"); - + public static IRegex happens = new RegexLeaf("happens"); public static IRegex is = new RegexLeaf("is"); - public static IRegex isColored = new RegexLeaf("is[%s]+colou?red"); - - public static IRegex isColoredForCompletion = new RegexLeaf("is[%s]+colou?red[%s]+for[%s]+completion"); - - public static IRegex isOff = new RegexConcat(new RegexLeaf("is"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("off"), // - RegexLeaf.spaceOneOrMore(), // - new RegexOr(// - new RegexLeaf("on"), // - new RegexLeaf("for"), // - new RegexLeaf("the"), // - new RegexLeaf("at") // - )); - - public static IRegex isOn = new RegexConcat(new RegexLeaf("is"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("on"), // - RegexLeaf.spaceOneOrMore(), // - new RegexOr(// - new RegexLeaf("on"), // - new RegexLeaf("for"), // - new RegexLeaf("the"), // - new RegexLeaf("at") // - ) // - ); - + public static IRegex isDeleted = new RegexLeaf("is[%s]+deleted"); + public static IRegex isDisplayedAs = new RegexLeaf("is[%s]+displayed[%s]+as"); + public static IRegex isOff = new RegexLeaf("is[%s]+off"); + public static IRegex isOn = new RegexLeaf("is[%s]+on"); public static IRegex isOrAre = new RegexLeaf("(is|are)"); - public static IRegex isOrAreNamed = new RegexLeaf("(is|are)[%s]+named"); - - public static IRegex lasts = new RegexLeaf("(lasts|requires)"); - - public static IRegex linksTo = new RegexLeaf("links to"); - - public static IRegex occurs = new RegexLeaf("occurs?"); - - public static IRegex starts3 = new RegexLeaf("starts[%s]*(the[%s]*|on[%s]*|at[%s]*)*"); - - public static IRegex starts2 = new RegexLeaf("starts"); - - public static IRegex starts = new RegexConcat(new RegexLeaf("start"), // - new RegexOptional(new RegexLeaf("s")), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional(new RegexOr(// - new RegexLeaf("on"), // - new RegexLeaf("for"), // - new RegexLeaf("the"), // - new RegexLeaf("at") // - )) // - ); - public static IRegex just = new RegexLeaf("just"); - - public static IRegex justBefore = new RegexLeaf("just[%s]*before"); - - public static IRegex justAfter = new RegexLeaf("just[%s]*after"); + public static IRegex linksTo = new RegexLeaf("links[%s]+to"); + public static IRegex occurs = new RegexLeaf("occurs"); + public static IRegex pauses = new RegexLeaf("pauses"); + public static IRegex requires = new RegexLeaf("(lasts|requires)"); + public static IRegex starts = new RegexLeaf("starts"); + public static IRegex worksOn = new RegexLeaf("works[%s]+on"); } diff --git a/src/net/sourceforge/plantuml/project/lang/Words.java b/src/net/sourceforge/plantuml/project/lang/Words.java new file mode 100644 index 000000000..41bb31782 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/Words.java @@ -0,0 +1,79 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.lang; + +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOr; +import net.sourceforge.plantuml.regex.RegexRepeatedZeroOrMore; + +public class Words { + + public final static String AFTER = "after"; + public final static String AND = "and"; + public final static String AS = "as"; + public final static String AT = "at"; + public final static String BEFORE = "before"; + public final static String COMPLETION = "completion"; + public final static String FOR = "for"; + public final static String FROM = "from"; + public final static String ON = "on"; + public final static String THE = "the"; + public final static String TO = "to"; + + public static IRegex zeroOrMore(String... words) { + final IRegex tmp[] = new IRegex[words.length]; + for (int i = 0; i < words.length; i++) + tmp[i] = new RegexLeaf(words[i]); + + final RegexOr or = new RegexOr(tmp); + return new RegexRepeatedZeroOrMore(new RegexConcat(RegexLeaf.spaceOneOrMore(), or)); + } + + public static IRegex exactly(String... words) { + final IRegex tmp[] = new IRegex[words.length]; + for (int i = 0; i < words.length; i++) + tmp[i] = new RegexConcat(RegexLeaf.spaceOneOrMore(), new RegexLeaf(words[i])); + + return new RegexConcat(tmp); + } + + public static IRegex concat(IRegex... expressions) { + return new RegexConcat(expressions); + } + +} diff --git a/src/net/sourceforge/plantuml/project/solver/ImpossibleSolvingException.java b/src/net/sourceforge/plantuml/project/solver/ImpossibleSolvingException.java new file mode 100644 index 000000000..c13085fde --- /dev/null +++ b/src/net/sourceforge/plantuml/project/solver/ImpossibleSolvingException.java @@ -0,0 +1,44 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.project.solver; + +public class ImpossibleSolvingException extends RuntimeException { + + public ImpossibleSolvingException(String message) { + super(message); + } + +} diff --git a/src/net/sourceforge/plantuml/project/solver/SolverImpl.java b/src/net/sourceforge/plantuml/project/solver/SolverImpl.java index b7898c72b..d20d0d851 100644 --- a/src/net/sourceforge/plantuml/project/solver/SolverImpl.java +++ b/src/net/sourceforge/plantuml/project/solver/SolverImpl.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.time.Day; public class SolverImpl extends AbstractSolver implements Solver { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private final LoadPlanable loadPlanable; @@ -54,12 +54,17 @@ public class SolverImpl extends AbstractSolver implements Solver { Day current = (Day) values.get(TaskAttribute.START); int fullLoad = ((Load) values.get(TaskAttribute.LOAD)).getFullLoad(); int cpt = 0; + final Day lastDayIfAny = loadPlanable.getLastDayIfAny(); while (fullLoad > 0) { fullLoad -= loadPlanable.getLoadAt(current); current = current.increment(); + if (lastDayIfAny != null && current.compareTo(lastDayIfAny) > 0) + throw new ImpossibleSolvingException( + "Because all resources will be off at some point, we cannot compute any end date for " + + loadPlanable); cpt++; if (cpt > 100000) - throw new IllegalStateException(); + throw new ImpossibleSolvingException("There is an issue in planning your tasks!"); } return current.decrement(); @@ -78,7 +83,7 @@ public class SolverImpl extends AbstractSolver implements Solver { cpt++; if (cpt > 100000) - throw new IllegalStateException(); + throw new ImpossibleSolvingException("There is an issue in planning your tasks!"); } return current.increment(); diff --git a/src/net/sourceforge/plantuml/project/time/Day.java b/src/net/sourceforge/plantuml/project/time/Day.java index b6eb3df98..f8d27cae6 100644 --- a/src/net/sourceforge/plantuml/project/time/Day.java +++ b/src/net/sourceforge/plantuml/project/time/Day.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.project.time; import java.util.Calendar; +import java.util.Locale; import java.util.TimeZone; import net.sourceforge.plantuml.project.Value; @@ -48,7 +49,7 @@ public class Day implements Comparable, Value { private final int dayOfMonth; private final MonthYear monthYear; - private final long ms1; + private final long milliseconds; public static Day create(int year, String month, int dayOfMonth) { return new Day(year, Month.fromString(month), dayOfMonth); @@ -66,10 +67,14 @@ public class Day implements Comparable, Value { return create(System.currentTimeMillis()); } + public String toStringShort(Locale locale) { + return monthYear.shortName(locale) + " " + dayOfMonth; + } + public int getWeekOfYear(WeekNumberStrategy strategy) { synchronized (gmt) { gmt.clear(); - gmt.setTimeInMillis(ms1); + gmt.setTimeInMillis(milliseconds); gmt.setFirstDayOfWeek(strategy.getFirstDayOfWeekAsLegacyInt()); gmt.setMinimalDaysInFirstWeek(strategy.getMinimalDaysInFirstWeek()); return gmt.get(Calendar.WEEK_OF_YEAR); @@ -82,12 +87,12 @@ public class Day implements Comparable, Value { synchronized (gmt) { gmt.clear(); gmt.set(year, month.ordinal(), dayOfMonth); - this.ms1 = gmt.getTimeInMillis(); + this.milliseconds = gmt.getTimeInMillis(); } } private Day(long ms) { - this.ms1 = ms; + this.milliseconds = ms; synchronized (gmt) { gmt.clear(); gmt.setTimeInMillis(ms); @@ -113,11 +118,11 @@ public class Day implements Comparable, Value { } public final int getAbsoluteDayNum() { - return (int) (ms1 / MILLISECONDS_PER_DAY); + return (int) (milliseconds / MILLISECONDS_PER_DAY); } public final long getMillis() { - return ms1; + return milliseconds; } public int year() { @@ -195,4 +200,12 @@ public class Day implements Comparable, Value { return increment(); } + public Day roundDayDown() { + return new Day((milliseconds / MILLISECONDS_PER_DAY) * MILLISECONDS_PER_DAY); + } + + public Day roundDayUp() { + return new Day(((milliseconds + MILLISECONDS_PER_DAY - 1) / MILLISECONDS_PER_DAY) * MILLISECONDS_PER_DAY); + } + } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java index 1f0ea9a3d..3e8155866 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java @@ -42,8 +42,8 @@ public class TimeScaleCompressed implements TimeScale { private final TimeScale daily; - public TimeScaleCompressed(Day calendar, double scale) { - this.daily = new TimeScaleDaily(calendar, scale, null); + public TimeScaleCompressed(double size, Day calendar, double scale, Day zeroDay) { + this.daily = new TimeScaleDaily(size, calendar, scale, zeroDay); } public double getStartingPosition(Day instant) { diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java index dafc2e93f..acf558340 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java @@ -39,13 +39,13 @@ import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.time.Day; public final class TimeScaleDaily implements TimeScale { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private final TimeScaleWink basic; private final double delta; - public TimeScaleDaily(Day startingDay, double scale, Day zeroDay) { - this.basic = new TimeScaleWink(scale, PrintScale.DAILY); + public TimeScaleDaily(double size, Day startingDay, double scale, Day zeroDay) { + this.basic = new TimeScaleWink(size, scale, PrintScale.DAILY); if (zeroDay == null) this.delta = basic.getStartingPosition(startingDay); else diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java index 9324097e2..d4cc0a070 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java @@ -40,17 +40,17 @@ import net.sourceforge.plantuml.project.time.Day; public class TimeScaleWink implements TimeScale { - private final double scale; + private final double cellWidth; private final PrintScale printScale; - public TimeScaleWink(double scale, PrintScale printScale) { - this.scale = 16.0 * scale; + public TimeScaleWink(double size, double scale, PrintScale printScale) { + this.cellWidth = size * scale; this.printScale = printScale; } public double getStartingPosition(Day instant) { final long wink = instant.getMillis(); - return wink * scale / Day.MILLISECONDS_PER_DAY; + return wink * cellWidth / Day.MILLISECONDS_PER_DAY; } public double getEndingPosition(Day instant) { @@ -58,7 +58,7 @@ public class TimeScaleWink implements TimeScale { } public double getWidth(Day instant) { - return scale; + return cellWidth; } public boolean isBreaking(Day instant) { diff --git a/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java b/src/net/sourceforge/plantuml/regex/RegexRepeatedZeroOrMore.java similarity index 68% rename from src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java rename to src/net/sourceforge/plantuml/regex/RegexRepeatedZeroOrMore.java index 36ee62187..ab0febc5e 100644 --- a/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java +++ b/src/net/sourceforge/plantuml/regex/RegexRepeatedZeroOrMore.java @@ -5,12 +5,12 @@ * (C) Copyright 2009-2024, Arnaud Roques * * Project Info: https://plantuml.com - * + * * If you like this project or if you find it useful, you can support us at: - * + * * https://plantuml.com/patreon (only 1$ per month!) * https://plantuml.com/paypal - * + * * This file is part of PlantUML. * * PlantUML is free software; you can redistribute it and/or modify it @@ -30,34 +30,29 @@ * * * Original Author: Arnaud Roques + * * */ -package net.sourceforge.plantuml.tim; - -import java.util.Objects; +package net.sourceforge.plantuml.regex; import net.sourceforge.plantuml.text.StringLocated; -public class EaterExceptionLocated extends Exception { +public class RegexRepeatedZeroOrMore extends RegexComposed implements IRegex { - private final String message; - private final StringLocated location; - - private EaterExceptionLocated(String message, StringLocated location) { - this.message = message; - this.location = location; + public RegexRepeatedZeroOrMore(IRegex partial) { + super(partial); } - public static EaterExceptionLocated located(String message, StringLocated location) { - return new EaterExceptionLocated(message, Objects.requireNonNull(location)); + @Override + protected String getFullSlow() { + final StringBuilder sb = new StringBuilder("(?:"); + sb.append(partials().get(0).getPattern()); + sb.append(")*"); + return sb.toString(); } - public final String getMessage() { - return message; - } - - public final StringLocated getLocation() { - return location; + public boolean match(StringLocated full) { + throw new UnsupportedOperationException(); } } diff --git a/src/net/sourceforge/plantuml/regexdiagram/PSystemRegex.java b/src/net/sourceforge/plantuml/regexdiagram/PSystemRegex.java index af874516c..4a1e610f0 100644 --- a/src/net/sourceforge/plantuml/regexdiagram/PSystemRegex.java +++ b/src/net/sourceforge/plantuml/regexdiagram/PSystemRegex.java @@ -52,11 +52,12 @@ import net.sourceforge.plantuml.ebnf.ETile; import net.sourceforge.plantuml.ebnf.ETileAlternation; import net.sourceforge.plantuml.ebnf.ETileBox; import net.sourceforge.plantuml.ebnf.ETileConcatenation; +import net.sourceforge.plantuml.ebnf.ETileLookAheadOrBehind; +import net.sourceforge.plantuml.ebnf.ETileNamedGroup; import net.sourceforge.plantuml.ebnf.ETileOneOrMore; import net.sourceforge.plantuml.ebnf.ETileOptional; import net.sourceforge.plantuml.ebnf.ETileZeroOrMore; import net.sourceforge.plantuml.ebnf.Symbol; -import net.sourceforge.plantuml.ebnf.TextBlockable; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.HColors; @@ -76,8 +77,6 @@ import net.sourceforge.plantuml.utils.CharInspector; public class PSystemRegex extends TitledDiagram { - private final List expressions = new ArrayList<>(); - public PSystemRegex(UmlSource source) { super(source, UmlDiagramType.REGEX, null); final ISkinParam skinParam = getSkinParam(); @@ -122,11 +121,11 @@ public class PSystemRegex extends TitledDiagram { @Override protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { // while (stack.size() > 1) // concatenation(); final ETile peekFirst = stack.peekFirst(); @@ -164,6 +163,12 @@ public class PSystemRegex extends TitledDiagram { push(token, Symbol.TERMINAL_STRING1); else if (token.getType() == ReTokenType.GROUP) push(token, Symbol.SPECIAL_SEQUENCE); + else if (token.getType() == ReTokenType.LOOK_AHEAD) + lookAheadOrBehind(token.getData()); + else if (token.getType() == ReTokenType.LOOK_BEHIND) + lookAheadOrBehind(token.getData()); + else if (token.getType() == ReTokenType.NAMED_GROUP) + namedGroup(token.getData()); else if (token.getType() == ReTokenType.CLASS) push(token, Symbol.LITTERAL); else if (token.getType() == ReTokenType.ANCHOR) @@ -205,6 +210,16 @@ public class PSystemRegex extends TitledDiagram { stack.addFirst(new ETileBox(element.getData(), type, fontConfiguration, style, colorSet, getSkinParam())); } + private void lookAheadOrBehind(String name) { + final ETile arg1 = stack.removeFirst(); + stack.addFirst(new ETileLookAheadOrBehind(arg1, fontConfiguration, style, colorSet, name)); + } + + private void namedGroup(String name) { + final ETile arg1 = stack.removeFirst(); + stack.addFirst(new ETileNamedGroup(arg1, fontConfiguration, colorSet, getSkinParam(), name)); + } + private void repetitionZeroOrMore(boolean isCompact) { final ETile arg1 = stack.removeFirst(); if (isCompact) @@ -266,9 +281,10 @@ public class PSystemRegex extends TitledDiagram { if (arg1 instanceof ETileConcatenation) { arg1.push(arg2); stack.addFirst(arg1); - } else if (arg2 instanceof ETileConcatenation) { - arg2.push(arg1); - stack.addFirst(arg2); + // This does not work for (A[B])(C) +// } else if (arg2 instanceof ETileConcatenation) { +// arg2.push(arg1); +// stack.addFirst(arg2); } else { final ETile concat = new ETileConcatenation(); concat.push(arg1); diff --git a/src/net/sourceforge/plantuml/regexdiagram/ReTokenType.java b/src/net/sourceforge/plantuml/regexdiagram/ReTokenType.java index d723fcfed..5941488ea 100644 --- a/src/net/sourceforge/plantuml/regexdiagram/ReTokenType.java +++ b/src/net/sourceforge/plantuml/regexdiagram/ReTokenType.java @@ -43,12 +43,21 @@ public enum ReTokenType { QUANTIFIER, // ANCHOR, // GROUP, // + NAMED_GROUP, // + LOOK_AHEAD, // + LOOK_BEHIND, // ALTERNATIVE, // PARENTHESIS_OPEN, // PARENTHESIS_CLOSE, // CONCATENATION_IMPLICIT; + public boolean isNamedGroupOrLookAheadOrLookBehind() { + return this == NAMED_GROUP || this == LOOK_AHEAD || this == LOOK_BEHIND; + } + static public boolean needImplicitConcatenation(ReTokenType token1, ReTokenType token2) { + if (token1.isNamedGroupOrLookAheadOrLookBehind()) + return false; if (token1 == ALTERNATIVE) return false; if (token2 == ALTERNATIVE) diff --git a/src/net/sourceforge/plantuml/regexdiagram/RegexExpression.java b/src/net/sourceforge/plantuml/regexdiagram/RegexExpression.java index 77ab74334..50a3003e3 100644 --- a/src/net/sourceforge/plantuml/regexdiagram/RegexExpression.java +++ b/src/net/sourceforge/plantuml/regexdiagram/RegexExpression.java @@ -60,12 +60,29 @@ public class RegexExpression { } else if (current == '|') { result.add(new ReToken(ReTokenType.ALTERNATIVE, "|")); it.jump(); + } else if (isStartPosixGroup(it)) { + final String s = readGroupPosix(it); + result.add(new ReToken(ReTokenType.CLASS, s)); } else if (current == '[') { final String s = readGroup(it); result.add(new ReToken(ReTokenType.GROUP, s)); + } else if (isStartComment(it)) { + skipComment(it); + } else if (isStartLookAhead(it)) { + final ReToken token = readLookAhead(it); + result.add(token); + result.add(new ReToken(ReTokenType.PARENTHESIS_OPEN, "(")); + } else if (isStartLookBehind(it)) { + final ReToken token = readLookBehind(it); + result.add(token); + result.add(new ReToken(ReTokenType.PARENTHESIS_OPEN, "(")); + } else if (isStartNamedCapturingGroup(it)) { + final ReToken token = readNamedGroup(it); + result.add(token); + result.add(new ReToken(ReTokenType.PARENTHESIS_OPEN, "(")); } else if (isStartOpenParenthesis(it)) { - final String s = readOpenParenthesis(it); - result.add(new ReToken(ReTokenType.PARENTHESIS_OPEN, s)); + final ReToken token = readOpenParenthesis(it); + result.add(token); } else if (current == ')') { result.add(new ReToken(ReTokenType.PARENTHESIS_CLOSE, ")")); it.jump(); @@ -96,6 +113,20 @@ public class RegexExpression { } + private static boolean isStartLookAhead(CharInspector it) { + final char current0 = it.peek(0); + if (current0 == '(' && it.peek(1) == '?' && (it.peek(2) == '=' || it.peek(2) == '!')) + return true; + return false; + } + + private static boolean isStartLookBehind(CharInspector it) { + final char current0 = it.peek(0); + if (current0 == '(' && it.peek(1) == '?' && it.peek(2) == '<' && (it.peek(3) == '=' || it.peek(3) == '!')) + return true; + return false; + } + private static boolean isStartOpenParenthesis(CharInspector it) { final char current0 = it.peek(0); if (current0 == '(') @@ -103,7 +134,90 @@ public class RegexExpression { return false; } - private static String readOpenParenthesis(CharInspector it) { + private static boolean isStartPosixGroup(CharInspector it) { + final char current0 = it.peek(0); + if (current0 == '[' && it.peek(1) == '[' && it.peek(2) == ':') + return true; + return false; + } + + private static boolean isStartNamedCapturingGroup(CharInspector it) { + final char current0 = it.peek(0); + if (current0 == '(' && it.peek(1) == '?' && it.peek(2) == '<') { + int i = 3; + while (it.peek(i) != 0) { + if (it.peek(i) == '>' && i == 3) + return false; + if (it.peek(i) == '>') + return true; + if (Character.isLetter(it.peek(i)) == false) + return false; + i++; + } + + } + return false; + } + + private static boolean isStartComment(CharInspector it) { + final char current0 = it.peek(0); + if (current0 == '(' && it.peek(1) == '?' && it.peek(2) == '#') + return true; + return false; + } + + private static void skipComment(CharInspector it) throws RegexParsingException { + it.jump(); + it.jump(); + it.jump(); + final StringBuilder comment = new StringBuilder(); + while (true) { + if (it.peek(0) == 0) + throw new RegexParsingException("Unclosed comment"); + if (it.peek(0) == ')') { + it.jump(); + return; + } + comment.append(it.peek(0)); + it.jump(); + } + } + + private static ReToken readLookAhead(CharInspector it) throws RegexParsingException { + it.jump(); + it.jump(); + final char ch = it.peek(0); + it.jump(); + return new ReToken(ReTokenType.LOOK_AHEAD, "?" + ch); + } + + private static ReToken readLookBehind(CharInspector it) throws RegexParsingException { + it.jump(); + it.jump(); + it.jump(); + final char ch = it.peek(0); + it.jump(); + return new ReToken(ReTokenType.LOOK_BEHIND, "?<" + ch); + } + + private static ReToken readNamedGroup(CharInspector it) throws RegexParsingException { + it.jump(); + it.jump(); + it.jump(); + final StringBuilder namedGroup = new StringBuilder(); + while (true) { + if (it.peek(0) == 0) + throw new RegexParsingException("Unclosed named capturing group"); + if (it.peek(0) == '>') { + it.jump(); + return new ReToken(ReTokenType.NAMED_GROUP, namedGroup.toString()); + } + namedGroup.append(it.peek(0)); + it.jump(); + } + } + + private static ReToken readOpenParenthesis(CharInspector it) { final char current0 = it.peek(0); it.jump(); final StringBuilder result = new StringBuilder(); @@ -118,7 +232,7 @@ public class RegexExpression { it.jump(); result.append("?!"); } - return result.toString(); + return new ReToken(ReTokenType.PARENTHESIS_OPEN, result.toString()); } private static boolean isStartQuantifier(CharInspector it) { @@ -164,6 +278,23 @@ public class RegexExpression { return false; } + private static String readGroupPosix(CharInspector it) { + it.jump(); + it.jump(); + it.jump(); + final StringBuilder result = new StringBuilder(":"); + while (it.peek(0) != 0) { + char ch = it.peek(0); + it.jump(); + result.append(ch); + if (ch == ':') + break; + } + it.jump(); + it.jump(); + return result.toString(); + } + private static String readGroup(CharInspector it) { final char current0 = it.peek(0); if (current0 != '[') diff --git a/src/net/sourceforge/plantuml/regexdiagram/ShuntingYard.java b/src/net/sourceforge/plantuml/regexdiagram/ShuntingYard.java index c29e83702..3749d771e 100644 --- a/src/net/sourceforge/plantuml/regexdiagram/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/regexdiagram/ShuntingYard.java @@ -59,6 +59,8 @@ public class ShuntingYard { ouputQueue.add(token); } else if (token.getType() == ReTokenType.GROUP) { ouputQueue.add(token); + } else if (token.getType().isNamedGroupOrLookAheadOrLookBehind()) { + operatorStack.addFirst(token); } else if (token.getType() == ReTokenType.CLASS) { ouputQueue.add(token); } else if (token.getType() == ReTokenType.ANCHOR) { @@ -80,7 +82,8 @@ public class ShuntingYard { && operatorStack.peekFirst().getType() != ReTokenType.PARENTHESIS_OPEN) ouputQueue.add(operatorStack.removeFirst()); final ReToken first = operatorStack.removeFirst(); -// ouputQueue.add(first); + if (operatorStack.peekFirst() != null && operatorStack.peekFirst().getType().isNamedGroupOrLookAheadOrLookBehind()) + ouputQueue.add(operatorStack.removeFirst()); } else { throw new UnsupportedOperationException(token.toString()); diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index be3c0922a..303aa32bf 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -126,8 +126,7 @@ public class PSystemSalt extends TitledDiagram implements WithSprite { } @Override - protected TextBlock getTextBlock() { - final FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG); + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { final Element salt = createElement(manageSprite()); final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); final XDimension2D size = salt.getPreferredDimension(stringBounder, 0, 0); diff --git a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java index 8de7a1bc6..bb5ff3d5f 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java +++ b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java @@ -44,21 +44,22 @@ public enum NoteStyle { NORMAL, HEXAGONAL, BOX; public static NoteStyle getNoteStyle(String s) { - if (s.equalsIgnoreCase("hnote")) { + if (s.equalsIgnoreCase("hnote")) return NoteStyle.HEXAGONAL; - } else if (s.equalsIgnoreCase("rnote")) { + + if (s.equalsIgnoreCase("rnote")) return NoteStyle.BOX; - } + return NoteStyle.NORMAL; } public ComponentType getNoteComponentType() { - if (this == NoteStyle.HEXAGONAL) { + if (this == NoteStyle.HEXAGONAL) return ComponentType.NOTE_HEXAGONAL; - } - if (this == NoteStyle.BOX) { + + if (this == NoteStyle.BOX) return ComponentType.NOTE_BOX; - } + return ComponentType.NOTE; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index d70277fb4..21bd66775 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -296,13 +296,13 @@ public class SequenceDiagram extends UmlDiagram { } @Override - final public void exportDiagramGraphic(UGraphic ug) { - final FileMaker sequenceDiagramPngMaker = getSequenceDiagramPngMaker(0, new FileFormatOption(FileFormat.PNG)); + final public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { + final FileMaker sequenceDiagramPngMaker = getSequenceDiagramPngMaker(0, fileFormatOption); sequenceDiagramPngMaker.createOneGraphic(ug); } @Override - final protected TextBlock getTextBlock() { + final protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java index c41b98fbd..5b4aa1ebe 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java @@ -65,6 +65,7 @@ import net.sourceforge.plantuml.skin.ArrowDecoration; import net.sourceforge.plantuml.skin.ArrowHead; import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -123,9 +124,7 @@ public class CommandArrow extends SingleLineCommand2 { new RegexLeaf("ACTIVATION", "(?:(\\+\\+|\\*\\*|!!|--|--\\+\\+|\\+\\+--)?)"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), // diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java index 9dc4752c6..10bd93bdd 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.utils.LineLocation; @@ -69,8 +70,7 @@ public class CommandBoxStart extends SingleLineCommand2 { new RegexConcat( // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME2", "([^#]+)")))), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // + StereotypePattern.optional("STEREO"), // color().getRegex(), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java index 03c0cd3df..04236f68c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; public class CommandParticipantA extends CommandParticipant { @@ -60,13 +61,12 @@ public class CommandParticipantA extends CommandParticipant { RegexLeaf.spaceOneOrMore() // )), // new RegexLeaf("CODE", "([%pLN_.@]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // getOrderRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // ColorParser.exp1(), RegexLeaf.end()); } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java index 954bf7ac2..7014b0073 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.klimt.color.ColorParser; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; public class CommandParticipantA2 extends CommandParticipant { @@ -56,9 +57,7 @@ public class CommandParticipantA2 extends CommandParticipant { new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // getOrderRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java index dcb2b2f0c..fe05fbc49 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.klimt.color.ColorParser; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; public class CommandParticipantA3 extends CommandParticipant { @@ -56,9 +57,7 @@ public class CommandParticipantA3 extends CommandParticipant { new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE", "([%pLN_.@]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // getOrderRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java index 6197f0265..c2ec8e1d0 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.klimt.color.ColorParser; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.UrlBuilder; public class CommandParticipantA4 extends CommandParticipant { @@ -52,9 +53,7 @@ public class CommandParticipantA4 extends CommandParticipant { getRegexType(), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE", "[%g]([^%g]+)[%g]"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // getOrderRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantMultilines.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantMultilines.java index b9d3a554e..6404fb347 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantMultilines.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantMultilines.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.ParticipantType; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; @@ -74,9 +75,7 @@ public class CommandParticipantMultilines extends CommandMultilines2\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREO"), // CommandParticipant.getOrderRegex(), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index 65600ca90..f6f35de5a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.AnnotatedBuilder; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.DisplaySection; +import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; @@ -165,7 +166,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); compTitle = style.createTextBlockBordered(page.getTitle(), diagram.getSkinParam().getIHtmlColorSet(), - diagram.getSkinParam(), Style.ID_TITLE); + diagram.getSkinParam(), Style.ID_TITLE, LineBreakStrategy.NONE); final XDimension2D dimTitle = compTitle.calculateDimension(stringBounder); area.setTitleArea(dimTitle.getWidth(), dimTitle.getHeight()); } @@ -179,7 +180,8 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.legend) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); legendBlock = style.createTextBlockBordered(diagram.getLegend().getDisplay(), - diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_LEGEND); + diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_LEGEND, + LineBreakStrategy.NONE); } final XDimension2D dimLegend = legendBlock.calculateDimension(stringBounder); area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java index 63ba0a34e..be9146eb4 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java @@ -46,7 +46,6 @@ import net.sourceforge.plantuml.sequencediagram.Note; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.style.ISkinParam; class Step1MessageExo extends Step1Abstract { @@ -69,7 +68,8 @@ class Step1MessageExo extends Step1Abstract { for (Note noteOnMessage : noteOnMessages) { final ISkinParam skinParam = noteOnMessage.getSkinParamBackcolored(drawingSet.getSkinParam()); final Component note = drawingSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), - ComponentType.NOTE, skinParam, noteOnMessage.getDisplay(), noteOnMessage.getColors()); + noteOnMessage.getNoteStyle().getNoteComponentType(), skinParam, noteOnMessage.getDisplay(), + noteOnMessage.getColors()); addNote(note); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index 96d4a3fff..0128c06a9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.DisplaySection; +import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; @@ -213,7 +214,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); final TextBlock compTitle = style.createTextBlockBordered(diagram.getTitle().getDisplay(), - diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_TITLE); + diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_TITLE, + LineBreakStrategy.NONE); return compTitle; } diff --git a/src/net/sourceforge/plantuml/skin/ActorAwesome.java b/src/net/sourceforge/plantuml/skin/ActorAwesome.java index 50869e283..d2926998c 100644 --- a/src/net/sourceforge/plantuml/skin/ActorAwesome.java +++ b/src/net/sourceforge/plantuml/skin/ActorAwesome.java @@ -55,10 +55,10 @@ public class ActorAwesome extends AbstractTextBlock implements TextBlock { private final double radius = 8; private final double bodyHeight = 28; - private final Fashion symbolContext; + private final Fashion fashion; - public ActorAwesome(Fashion symbolContext) { - this.symbolContext = symbolContext.withStroke(UStroke.withThickness(1.5)); + public ActorAwesome(Fashion fashion) { + this.fashion = fashion; } public void drawU(UGraphic ug) { @@ -81,18 +81,18 @@ public class ActorAwesome extends AbstractTextBlock implements TextBlock { path.cubicTo(-bodyWidth / 2 + shoulder + collar, collar, -collar, collar, 0, collar); path.closePath(); - if (symbolContext.getDeltaShadow() != 0) { - head.setDeltaShadow(symbolContext.getDeltaShadow()); - path.setDeltaShadow(symbolContext.getDeltaShadow()); + if (fashion.getDeltaShadow() != 0) { + head.setDeltaShadow(fashion.getDeltaShadow()); + path.setDeltaShadow(fashion.getDeltaShadow()); } - ug = symbolContext.apply(ug); + ug = fashion.apply(ug); ug.apply(new UTranslate(centerX - head.getWidth() / 2, thickness())).draw(head); ug.apply(new UTranslate(centerX, head.getHeight() + thickness())).draw(path); } private double thickness() { - return symbolContext.getStroke().getThickness(); + return fashion.getStroke().getThickness(); } public double getPreferredWidth() { diff --git a/src/net/sourceforge/plantuml/skin/ActorHollow.java b/src/net/sourceforge/plantuml/skin/ActorHollow.java index 91fc51ffc..0e8e79293 100644 --- a/src/net/sourceforge/plantuml/skin/ActorHollow.java +++ b/src/net/sourceforge/plantuml/skin/ActorHollow.java @@ -57,10 +57,10 @@ public class ActorHollow extends AbstractTextBlock implements TextBlock { private final double bodyThickness = 6; private final double legThickness = 6; - private final Fashion symbolContext; + private final Fashion fashion; - public ActorHollow(Fashion symbolContext) { - this.symbolContext = symbolContext; + public ActorHollow(Fashion fashion) { + this.fashion = fashion; } public void drawU(UGraphic ug) { @@ -87,17 +87,17 @@ public class ActorHollow extends AbstractTextBlock implements TextBlock { path.lineTo(-bodyWidth / 2, 0); path.closePath(); - if (symbolContext.getDeltaShadow() != 0) { - head.setDeltaShadow(symbolContext.getDeltaShadow()); - path.setDeltaShadow(symbolContext.getDeltaShadow()); + if (fashion.getDeltaShadow() != 0) { + head.setDeltaShadow(fashion.getDeltaShadow()); + path.setDeltaShadow(fashion.getDeltaShadow()); } - ug = symbolContext.apply(ug); + ug = fashion.apply(ug); ug.apply(new UTranslate(centerX - head.getWidth() / 2, thickness())).draw(head); ug.apply(new UTranslate(centerX, head.getHeight() + thickness() + neckHeight)).draw(path); } private double thickness() { - return symbolContext.getStroke().getThickness(); + return fashion.getStroke().getThickness(); } public double getPreferredWidth() { @@ -105,7 +105,7 @@ public class ActorHollow extends AbstractTextBlock implements TextBlock { } public double getPreferredHeight() { - return headDiam + neckHeight + bodyHeight + thickness() * 2 + symbolContext.getDeltaShadow(); + return headDiam + neckHeight + bodyHeight + thickness() * 2 + fashion.getDeltaShadow(); } public XDimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/skin/ActorStickMan.java b/src/net/sourceforge/plantuml/skin/ActorStickMan.java index b92cb27eb..03e24ffdd 100644 --- a/src/net/sourceforge/plantuml/skin/ActorStickMan.java +++ b/src/net/sourceforge/plantuml/skin/ActorStickMan.java @@ -57,11 +57,11 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { private final double legsY = 15; private final double headDiam = 16; - private final Fashion symbolContext; + private final Fashion fashion; private final boolean actorBusiness; - ActorStickMan(Fashion symbolContext, boolean actorBusiness) { - this.symbolContext = symbolContext; + ActorStickMan(Fashion fashion, boolean actorBusiness) { + this.fashion = fashion; this.actorBusiness = actorBusiness; } @@ -81,12 +81,12 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { path.lineTo(-legsX, bodyLenght + legsY); path.moveTo(0, bodyLenght); path.lineTo(legsX, bodyLenght + legsY); - if (symbolContext.getDeltaShadow() != 0) { - head.setDeltaShadow(symbolContext.getDeltaShadow()); - path.setDeltaShadow(symbolContext.getDeltaShadow()); + if (fashion.getDeltaShadow() != 0) { + head.setDeltaShadow(fashion.getDeltaShadow()); + path.setDeltaShadow(fashion.getDeltaShadow()); } - ug = symbolContext.apply(ug); + ug = fashion.apply(ug); ug.apply(new UTranslate(startX, thickness())).draw(head); if (actorBusiness) { specialBusiness(ug.apply(new UTranslate(startX + headDiam / 2, thickness() + headDiam / 2))); @@ -109,7 +109,7 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { } private double thickness() { - return symbolContext.getStroke().getThickness(); + return fashion.getStroke().getThickness(); } public double getPreferredWidth() { @@ -117,7 +117,7 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { } public double getPreferredHeight() { - return headDiam + bodyLenght + legsY + 2 * thickness() + symbolContext.getDeltaShadow() + 1; + return headDiam + bodyLenght + legsY + 2 * thickness() + fashion.getDeltaShadow() + 1; } public XDimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/skin/UmlDiagramType.java b/src/net/sourceforge/plantuml/skin/UmlDiagramType.java index f30c09913..b29b560aa 100644 --- a/src/net/sourceforge/plantuml/skin/UmlDiagramType.java +++ b/src/net/sourceforge/plantuml/skin/UmlDiagramType.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.style.SName; public enum UmlDiagramType { SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE, - HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES, CHEN_EER; + HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES, CHRONOLOGY, CHEN_EER; public SName getStyleName() { if (this == SEQUENCE) @@ -96,6 +96,9 @@ public enum UmlDiagramType { if (this == REGEX) return SName.regex; + if (this == CHRONOLOGY) + return SName.ganttDiagram; + return SName.activityDiagram; } } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java index a683fe5b7..b2d94a443 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackage2.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -83,9 +84,7 @@ public class CommandCreatePackage2 extends SingleLineCommand2 { new RegexLeaf("as"), RegexLeaf.spaceOneOrMore() // )), // new RegexLeaf("CODE2", "([%pLN_.]+)"))), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // UrlBuilder.OPTIONAL, // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java index 6a8e408aa..b8a502ab9 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -86,9 +87,7 @@ public class CommandCreatePackageState extends SingleLineCommand2 new RegexLeaf("CODE2", "([%pLN_.]+)"))), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java index 1de76f5f1..abb561747 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.url.Url; import net.sourceforge.plantuml.url.UrlBuilder; import net.sourceforge.plantuml.url.UrlMode; @@ -85,9 +86,7 @@ public class CommandCreateState extends SingleLineCommand2 { new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // RegexLeaf.spaceZeroOrMore(), // UrlBuilder.OPTIONAL, // diff --git a/src/net/sourceforge/plantuml/stats/FormatCounter.java b/src/net/sourceforge/plantuml/stats/FormatCounter.java index 0f376d811..fe621aed7 100644 --- a/src/net/sourceforge/plantuml/stats/FormatCounter.java +++ b/src/net/sourceforge/plantuml/stats/FormatCounter.java @@ -97,7 +97,10 @@ public class FormatCounter { final String name = removeDotSaved(key); final NumberAnalyzed value = NumberAnalyzed.load(name, prefs); if (value != null) { - final FileFormat format = FileFormat.valueOf(name.substring(prefix.length())); + final String subname = name.substring(prefix.length()); + if (subname.equals("ANIMATED_GIF")) + continue; + final FileFormat format = FileFormat.valueOf(subname); data.put(format, value); } } catch (Exception e) { diff --git a/src/net/sourceforge/plantuml/stereo/Stereotype.java b/src/net/sourceforge/plantuml/stereo/Stereotype.java index 0268b9ae6..7cc43cd38 100644 --- a/src/net/sourceforge/plantuml/stereo/Stereotype.java +++ b/src/net/sourceforge/plantuml/stereo/Stereotype.java @@ -78,6 +78,8 @@ public class Stereotype implements CharSequence { } public static Stereotype build(String label) { + if (label == null) + return null; return build(label, true); } diff --git a/src/net/sourceforge/plantuml/stereo/StereotypePattern.java b/src/net/sourceforge/plantuml/stereo/StereotypePattern.java new file mode 100644 index 000000000..c86520408 --- /dev/null +++ b/src/net/sourceforge/plantuml/stereo/StereotypePattern.java @@ -0,0 +1,71 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.stereo; + +import net.sourceforge.plantuml.regex.IRegex; +import net.sourceforge.plantuml.regex.RegexConcat; +import net.sourceforge.plantuml.regex.RegexLeaf; +import net.sourceforge.plantuml.regex.RegexOptional; + +public class StereotypePattern { + + public static IRegex optional(String param) { + return new RegexConcat( // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(mandatory(param)), // + RegexLeaf.spaceZeroOrMore() // + ); + } + + public static IRegex mandatory(String param) { + return new RegexLeaf(param, "(\\<\\<.+\\>\\>)"); + } + + public static IRegex optionalArchimate(String param) { + return new RegexConcat( // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional(new RegexLeaf(param, "(\\<\\<[-\\w]+\\>\\>)")), // + RegexLeaf.spaceZeroOrMore() // + ); + } + + public static String removeChevronBrackets(String stereo) { + if (stereo != null && stereo.startsWith("<<") && stereo.endsWith(">>")) + return stereo.substring(2, stereo.length() - 2); + return stereo; + } + +} diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index 451a65036..a0bad78fd 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.style; public enum SName { + action, // activity, // activityBar, // activityDiagram, // @@ -73,6 +74,7 @@ public enum SName { constraintArrow, // control, // database, // + day, // delay, // destroy, // diamond, // @@ -104,6 +106,7 @@ public enum SName { map, // milestone, // mindmapDiagram, // + month, // network, // node, // note, // @@ -115,6 +118,7 @@ public enum SName { partition, // person, // port, // + process, // queue, // rectangle, // reference, // @@ -142,7 +146,9 @@ public enum SName { undone, // unstarted, // usecase, // - + verticalSeparator, // + year, // + visibilityIcon, // private_, // protected_, // diff --git a/src/net/sourceforge/plantuml/style/Style.java b/src/net/sourceforge/plantuml/style/Style.java index 78e92f2de..c1c960ec6 100644 --- a/src/net/sourceforge/plantuml/style/Style.java +++ b/src/net/sourceforge/plantuml/style/Style.java @@ -40,7 +40,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.StringTokenizer; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.klimt.Fashion; import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.UStroke; @@ -49,6 +48,7 @@ import net.sourceforge.plantuml.klimt.color.Colors; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.HColors; +import net.sourceforge.plantuml.klimt.creole.CreoleMode; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.font.FontConfiguration; @@ -283,19 +283,17 @@ public class Style { return value(PName.HorizontalAlignment).asHorizontalAlignment(); } - private TextBlock createTextBlockInternal(Display display, HColorSet set, ISkinSimple spriteContainer, - HorizontalAlignment alignment) { - final FontConfiguration fc = getFontConfiguration(set); - return display.create(fc, alignment, spriteContainer); - } - public static final String ID_TITLE = "_title"; public static final String ID_CAPTION = "_caption"; public static final String ID_LEGEND = "_legend"; - public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer, String id) { + public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer, String id, + LineBreakStrategy lineBreak) { final HorizontalAlignment alignment = this.getHorizontalAlignment(); - final TextBlock textBlock = this.createTextBlockInternal(note, set, spriteContainer, alignment); + final FontConfiguration fc = this.getFontConfiguration(set); + + final TextBlock textBlock = note.create0(fc, alignment, spriteContainer, lineBreak, CreoleMode.FULL, null, + null); final HColor backgroundColor = this.value(PName.BackGroundColor).asColor(set); final HColor lineColor = this.value(PName.LineColor).asColor(set); diff --git a/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java b/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java index 90ce3c596..11c342031 100644 --- a/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java +++ b/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java @@ -70,7 +70,7 @@ public class PSystemSudoku extends AbstractPSystem { } @Override - public void exportDiagramGraphic(UGraphic ug) { + public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { final GraphicsSudoku sud = new GraphicsSudoku(sudoku); sud.drawInternal(ug); } diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 175478e73..2505b5220 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -633,7 +633,7 @@ public final class GeneralImageBuilder { if (g.getGroupType() == GroupType.CONCURRENT_STATE) return; - final ClusterHeader clusterHeader = new ClusterHeader((Entity) g, dotData.getSkinParam(), dotData, + final ClusterHeader clusterHeader = new ClusterHeader(g, dotData.getSkinParam(), dotData, stringBounder); dotStringFactory.openCluster(g, clusterHeader); this.printEntities(dotStringFactory, g.leafs()); diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index 31bd7245a..597b5b2e7 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -93,6 +93,8 @@ public class LanguageDescriptor { type.add("metaclass"); type.add("map"); type.add("json"); + type.add("action"); + type.add("process"); keyword.add("@startwire"); keyword.add("@startbpm"); @@ -121,6 +123,7 @@ public class LanguageDescriptor { keyword.add("@startebnf"); keyword.add("@startregex"); keyword.add("@startfiles"); + keyword.add("@startchronology"); keyword.add("@endwire"); keyword.add("@endbpm"); keyword.add("@enduml"); @@ -148,6 +151,7 @@ public class LanguageDescriptor { keyword.add("@endebnf"); keyword.add("@endregex"); keyword.add("@endfiles"); + keyword.add("@endchronology"); keyword.add("as"); keyword.add("also"); keyword.add("autonumber"); diff --git a/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java new file mode 100644 index 000000000..399a3b3b3 --- /dev/null +++ b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java @@ -0,0 +1,150 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.syntax; + +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.BlockUml; +import net.sourceforge.plantuml.ErrorUml; +import net.sourceforge.plantuml.OptionFlags; +import net.sourceforge.plantuml.SourceStringReader; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.error.PSystemError; +import net.sourceforge.plantuml.preproc.Defines; +import net.sourceforge.plantuml.text.BackSlash; +import net.sourceforge.plantuml.utils.LineLocation; +import net.sourceforge.plantuml.utils.LineLocationImpl; + +public class SyntaxChecker { + // ::remove folder when __HAXE__ + // ::remove file when __CORE__ + + public static SyntaxResult checkSyntax(List source) { + final StringBuilder sb = new StringBuilder(); + for (String s : source) { + sb.append(s); + sb.append(BackSlash.NEWLINE); + } + return checkSyntax(sb.toString()); + } + + public static SyntaxResult checkSyntax(String source) { + OptionFlags.getInstance().setQuiet(true); + final SyntaxResult result = new SyntaxResult(); + + if (source.startsWith("@startuml\n") == false) { + result.setError(true); + result.setLineLocation(new LineLocationImpl("", null).oneLineRead()); + result.addErrorText("No @startuml/@enduml found"); + return result; + } + if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) { + result.setError(true); + result.setLineLocation(lastLineNumber(source)); + result.addErrorText("No @enduml found"); + return result; + } + final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source, + Collections.emptyList()); + + final List blocks = sourceStringReader.getBlocks(); + if (blocks.size() == 0) { + result.setError(true); + result.setLineLocation(lastLineNumber(source)); + result.addErrorText("No @enduml found"); + return result; + } + final Diagram system = blocks.get(0).getDiagram(); + result.setCmapData(system.hasUrl()); + if (system instanceof UmlDiagram) { + result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType()); + result.setDescription(system.getDescription().getDescription()); + } else if (system instanceof PSystemError) { + result.setError(true); + final PSystemError sys = (PSystemError) system; + result.setLineLocation(sys.getLineLocation()); + result.setSystemError(sys); + for (ErrorUml er : sys.getErrorsUml()) + result.addErrorText(er.getError()); + } else { + result.setDescription(system.getDescription().getDescription()); + } + return result; + } + + public static SyntaxResult checkSyntaxFair(String source) { + final SyntaxResult result = new SyntaxResult(); + final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source, + Collections.emptyList()); + + final List blocks = sourceStringReader.getBlocks(); + if (blocks.size() == 0) { + result.setError(true); + result.setLineLocation(lastLineNumber(source)); + result.addErrorText("No @enduml found"); + return result; + } + + final Diagram system = blocks.get(0).getDiagram(); + result.setCmapData(system.hasUrl()); + if (system instanceof UmlDiagram) { + result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType()); + result.setDescription(system.getDescription().getDescription()); + } else if (system instanceof PSystemError) { + result.setError(true); + final PSystemError sys = (PSystemError) system; + result.setLineLocation(sys.getLineLocation()); + for (ErrorUml er : sys.getErrorsUml()) { + result.addErrorText(er.getError()); + } + result.setSystemError(sys); + } else { + result.setDescription(system.getDescription().getDescription()); + } + return result; + } + + private static LineLocation lastLineNumber(String source) { + LineLocationImpl result = new LineLocationImpl("", null).oneLineRead(); + for (int i = 0; i < source.length(); i++) + if (source.charAt(i) == '\n') + result = result.oneLineRead(); + + return result; + } +} diff --git a/src/net/sourceforge/plantuml/text/StringLocated.java b/src/net/sourceforge/plantuml/text/StringLocated.java index ed15e2f11..bc99b864a 100644 --- a/src/net/sourceforge/plantuml/text/StringLocated.java +++ b/src/net/sourceforge/plantuml/text/StringLocated.java @@ -158,4 +158,8 @@ final public class StringLocated { return s.length(); } + public char charAt(int i) { + return s.charAt(i); + } + } diff --git a/src/net/sourceforge/plantuml/text/TLineType.java b/src/net/sourceforge/plantuml/text/TLineType.java index 869f3d810..315c58b88 100644 --- a/src/net/sourceforge/plantuml/text/TLineType.java +++ b/src/net/sourceforge/plantuml/text/TLineType.java @@ -34,6 +34,8 @@ */ package net.sourceforge.plantuml.text; +import java.util.regex.Pattern; + public enum TLineType { PLAIN, AFFECTATION_DEFINE, AFFECTATION, ASSERT, IF, IFDEF, UNDEF, IFNDEF, ELSE, ELSEIF, ENDIF, WHILE, ENDWHILE, @@ -41,115 +43,174 @@ public enum TLineType { LEGACY_DEFINELONG, THEME, INCLUDE, INCLUDE_DEF, IMPORT, STARTSUB, ENDSUB, INCLUDESUB, LOG, DUMP_MEMORY, COMMENT_SIMPLE, COMMENT_LONG_START; -// private boolean elseLike() { -// return this == ELSE || this == ELSEIF; -// } -// -// public boolean incIndentAfter() { -// return this == IF || this == IFDEF || this == IFNDEF || elseLike(); -// } -// -// public boolean decIndentBefore() { -// return this == ENDIF || elseLike(); -// } + private static final Pattern PATTERN_LEGACY_DEFINE = Pattern.compile("^\\s*!define\\s+[\\p{L}_][\\p{L}_0-9]*\\(.*"); + + private static final Pattern PATTERN_LEGACY_DEFINELONG = Pattern + .compile("^\\s*!definelong\\s+[\\p{L}_][\\p{L}_0-9]*\\b.*"); + + private static final Pattern PATTERN_AFFECTATION_DEFINE = Pattern + .compile("^\\s*!define\\s+[\\p{L}_][\\p{L}_0-9]*\\b.*"); + + private static final Pattern PATTERN_AFFECTATION = Pattern + .compile("^\\s*!\\s*(local|global)?\\s*\\$?[\\p{L}_][\\p{L}_0-9]*\\s*\\??=.*"); + + private static final Pattern PATTERN_COMMENT_SIMPLE1 = Pattern.compile("^\\s*'.*"); + + private static final Pattern PATTERN_COMMENT_SIMPLE2 = Pattern.compile("^\\s*/'.*'/\\s*$"); + + private static final Pattern PATTERN_COMMENT_LONG_START = Pattern.compile("^\\s*/'.*"); + + private static final Pattern PATTERN_IFDEF = Pattern.compile("^\\s*!ifdef\\s+.*"); + + private static final Pattern PATTERN_UNDEF = Pattern.compile("^\\s*!undef\\s+.*"); + + private static final Pattern PATTERN_IFNDEF = Pattern.compile("^\\s*!ifndef\\s+.*"); + + private static final Pattern PATTERN_ASSERT = Pattern.compile("^\\s*!assert\\s+.*"); + + private static final Pattern PATTERN_IF = Pattern.compile("^\\s*!if\\s+.*"); + + private static final Pattern PATTERN_DECLARE_RETURN_FUNCTION = Pattern + .compile("^\\s*!(unquoted\\s|final\\s)*(function)\\s+\\$?[\\p{L}_][\\p{L}_0-9]*.*"); + + private static final Pattern PATTERN_DECLARE_PROCEDURE = Pattern + .compile("^\\s*!(unquoted\\s|final\\s)*(procedure)\\s+\\$?[\\p{L}_][\\p{L}_0-9]*.*"); + + private static final Pattern PATTERN_ELSE = Pattern.compile("^\\s*!else\\b.*"); + + private static final Pattern PATTERN_ELSEIF = Pattern.compile("^\\s*!elseif\\b.*"); + + private static final Pattern PATTERN_ENDIF = Pattern.compile("^\\s*!endif\\b.*"); + + private static final Pattern PATTERN_WHILE = Pattern.compile("^\\s*!while\\s+.*"); + + private static final Pattern PATTERN_ENDWHILE = Pattern.compile("^\\s*!endwhile\\b.*"); + + private static final Pattern PATTERN_FOREACH = Pattern.compile("^\\s*!foreach\\s+.*"); + + private static final Pattern PATTERN_ENDFOREACH = Pattern.compile("^\\s*!endfor\\b.*"); + + private static final Pattern PATTERN_END_FUNCTION = Pattern + .compile("^\\s*!(end\\s*function|end\\s*definelong|end\\s*procedure)\\b.*"); + + private static final Pattern PATTERN_RETURN = Pattern.compile("^\\s*!return\\b.*"); + + private static final Pattern PATTERN_THEME = Pattern.compile("^\\s*!theme\\b.*"); + + private static final Pattern PATTERN_INCLUDE = Pattern + .compile("^\\s*!(include|includeurl|include_many|include_once)\\b.*"); + + private static final Pattern PATTERN_INCLUDE_DEF = Pattern.compile("^\\s*!(includedef)\\b.*"); + + private static final Pattern PATTERN_IMPORT = Pattern.compile("^\\s*!(import)\\b.*"); + + private static final Pattern PATTERN_STARTSUB = Pattern.compile("^\\s*!startsub\\s+.*"); + + private static final Pattern PATTERN_ENDSUB = Pattern.compile("^\\s*!endsub\\b.*"); + + private static final Pattern PATTERN_INCLUDESUB = Pattern.compile("^\\s*!includesub\\b.*"); + + private static final Pattern PATTERN_LOG = Pattern.compile("^\\s*!(log)\\b.*"); + + private static final Pattern PATTERN_DUMP_MEMORY = Pattern.compile("^\\s*!(dump_memory)\\b.*"); public static TLineType getFromLineInternal(String s) { - if (s.matches("^\\s*!define\\s+[\\p{L}_][\\p{L}_0-9]*\\(.*")) { + if (PATTERN_LEGACY_DEFINE.matcher(s).matches()) return LEGACY_DEFINE; - } - if (s.matches("^\\s*!definelong\\s+[\\p{L}_][\\p{L}_0-9]*\\b.*")) { + + if (PATTERN_LEGACY_DEFINELONG.matcher(s).matches()) return LEGACY_DEFINELONG; - } - if (s.matches("^\\s*!define\\s+[\\p{L}_][\\p{L}_0-9]*\\b.*")) { + + if (PATTERN_AFFECTATION_DEFINE.matcher(s).matches()) return AFFECTATION_DEFINE; - } - if (s.matches("^\\s*!\\s*(local|global)?\\s*\\$?[\\p{L}_][\\p{L}_0-9]*\\s*\\??=.*")) { + + if (PATTERN_AFFECTATION.matcher(s).matches()) return AFFECTATION; - } - if (s.matches("^\\s*'.*")) { + + if (PATTERN_COMMENT_SIMPLE1.matcher(s).matches()) return COMMENT_SIMPLE; - } - if (s.matches("^\\s*/'.*'/\\s*$")) { + + if (PATTERN_COMMENT_SIMPLE2.matcher(s).matches()) return COMMENT_SIMPLE; - } - if (s.matches("^\\s*/'.*") && s.contains("'/") == false) { + + if (PATTERN_COMMENT_LONG_START.matcher(s).matches() && s.contains("'/") == false) return COMMENT_LONG_START; - } - if (s.matches("^\\s*!ifdef\\s+.*")) { + + if (PATTERN_IFDEF.matcher(s).matches()) return IFDEF; - } - if (s.matches("^\\s*!undef\\s+.*")) { + + if (PATTERN_UNDEF.matcher(s).matches()) return UNDEF; - } - if (s.matches("^\\s*!ifndef\\s+.*")) { + + if (PATTERN_IFNDEF.matcher(s).matches()) return IFNDEF; - } - if (s.matches("^\\s*!assert\\s+.*")) { + + if (PATTERN_ASSERT.matcher(s).matches()) return ASSERT; - } - if (s.matches("^\\s*!if\\s+.*")) { + + if (PATTERN_IF.matcher(s).matches()) return IF; - } - if (s.matches("^\\s*!(unquoted\\s|final\\s)*(function)\\s+\\$?[\\p{L}_][\\p{L}_0-9]*.*")) { + + if (PATTERN_DECLARE_RETURN_FUNCTION.matcher(s).matches()) return DECLARE_RETURN_FUNCTION; - } - if (s.matches("^\\s*!(unquoted\\s|final\\s)*(procedure)\\s+\\$?[\\p{L}_][\\p{L}_0-9]*.*")) { + + if (PATTERN_DECLARE_PROCEDURE.matcher(s).matches()) return DECLARE_PROCEDURE; - } - if (s.matches("^\\s*!else\\b.*")) { + + if (PATTERN_ELSE.matcher(s).matches()) return ELSE; - } - if (s.matches("^\\s*!elseif\\b.*")) { + + if (PATTERN_ELSEIF.matcher(s).matches()) return ELSEIF; - } - if (s.matches("^\\s*!endif\\b.*")) { + + if (PATTERN_ENDIF.matcher(s).matches()) return ENDIF; - } - if (s.matches("^\\s*!while\\s+.*")) { + + if (PATTERN_WHILE.matcher(s).matches()) return WHILE; - } - if (s.matches("^\\s*!endwhile\\b.*")) { + + if (PATTERN_ENDWHILE.matcher(s).matches()) return ENDWHILE; - } - if (s.matches("^\\s*!foreach\\s+.*")) { + + if (PATTERN_FOREACH.matcher(s).matches()) return FOREACH; - } - if (s.matches("^\\s*!endfor\\b.*")) { + + if (PATTERN_ENDFOREACH.matcher(s).matches()) return ENDFOREACH; - } - if (s.matches("^\\s*!(end\\s*function|end\\s*definelong|end\\s*procedure)\\b.*")) { + + if (PATTERN_END_FUNCTION.matcher(s).matches()) return END_FUNCTION; - } - if (s.matches("^\\s*!return\\b.*")) { + + if (PATTERN_RETURN.matcher(s).matches()) return RETURN; - } - if (s.matches("^\\s*!theme\\b.*")) { + + if (PATTERN_THEME.matcher(s).matches()) return THEME; - } - if (s.matches("^\\s*!(include|includeurl|include_many|include_once)\\b.*")) { + + if (PATTERN_INCLUDE.matcher(s).matches()) return INCLUDE; - } - if (s.matches("^\\s*!(includedef)\\b.*")) { + + if (PATTERN_INCLUDE_DEF.matcher(s).matches()) return INCLUDE_DEF; - } - if (s.matches("^\\s*!(import)\\b.*")) { + + if (PATTERN_IMPORT.matcher(s).matches()) return IMPORT; - } - if (s.matches("^\\s*!startsub\\s+.*")) { + + if (PATTERN_STARTSUB.matcher(s).matches()) return STARTSUB; - } - if (s.matches("^\\s*!endsub\\b.*")) { + + if (PATTERN_ENDSUB.matcher(s).matches()) return ENDSUB; - } - if (s.matches("^\\s*!includesub\\b.*")) { + + if (PATTERN_INCLUDESUB.matcher(s).matches()) return INCLUDESUB; - } - if (s.matches("^\\s*!(log)\\b.*")) { + + if (PATTERN_LOG.matcher(s).matches()) return LOG; - } - if (s.matches("^\\s*!(dump_memory)\\b.*")) { + + if (PATTERN_DUMP_MEMORY.matcher(s).matches()) return DUMP_MEMORY; - } + return PLAIN; } diff --git a/src/net/sourceforge/plantuml/tim/Eater.java b/src/net/sourceforge/plantuml/tim/Eater.java index 6e97e651f..2f5287555 100644 --- a/src/net/sourceforge/plantuml/tim/Eater.java +++ b/src/net/sourceforge/plantuml/tim/Eater.java @@ -50,36 +50,35 @@ import net.sourceforge.plantuml.utils.LineLocation; public abstract class Eater { private int i = 0; - private final String s; - private final LineLocation lineLocation; + private final StringLocated stringLocated; - public Eater(StringLocated sl) { - this(sl.getString(), sl.getLocation()); - } - - protected Eater(String s, LineLocation lineLocation) { - this.s = s; - this.lineLocation = lineLocation; + public Eater(StringLocated stringLocated) { + this.stringLocated = stringLocated; } public final LineLocation getLineLocation() { - return lineLocation; + return stringLocated.getLocation(); } - public abstract void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated; + public final StringLocated getStringLocated() { + return stringLocated; + } + + public abstract void analyze(TContext context, TMemory memory) throws EaterException; public int getCurrentPosition() { return i; } final protected String eatAllToEnd() throws EaterException { - final String result = s.substring(i); - i = s.length(); + final String result = stringLocated.getString().substring(i); + i = stringLocated.length(); return result; } - final public TValue eatExpression(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { - if (peekChar() == '{') { + final public TValue eatExpression(TContext context, TMemory memory) throws EaterException { + final char ch = peekChar(); + if (ch == '{' || ch == '[') { final String data = eatAllToEnd(); // System.err.println("data=" + data); final JsonValue json = Json.parse(data); @@ -87,23 +86,22 @@ public abstract class Eater { return TValue.fromJson(json); } final TokenStack tokenStack = eatTokenStack(); - return tokenStack.getResult(getLineLocation(), context, memory); + return tokenStack.getResult(getStringLocated(), context, memory); } final protected TokenStack eatTokenStack() throws EaterException { final TokenStack tokenStack = new TokenStack(); addIntoTokenStack(tokenStack, false); if (tokenStack.size() == 0) - throw EaterException.located("Missing expression"); + throw new EaterException("Missing expression", stringLocated); return tokenStack; } - final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { + final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) throws EaterException { final TokenStack tokenStack = new TokenStack(); addIntoTokenStack(tokenStack, true); - return tokenStack.getResult(getLineLocation(), context, memory); + return tokenStack.getResult(getStringLocated(), context, memory); } final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterException { @@ -122,7 +120,7 @@ public abstract class Eater { final public String eatAndGetQuotedString() throws EaterException { final char separator = peekChar(); if (TLineType.isQuote(separator) == false) - throw EaterException.located("quote10"); + throw new EaterException("quote10", stringLocated); checkAndEatChar(separator); final StringBuilder value = new StringBuilder(); @@ -143,7 +141,7 @@ public abstract class Eater { while (true) { char ch = peekChar(); if (ch == 0) - throw EaterException.located("until001"); + throw new EaterException("until001", stringLocated); if (level == 0 && (ch == ',' || ch == ')')) return value.toString().trim(); @@ -191,7 +189,7 @@ public abstract class Eater { final protected String eatAndGetVarname() throws EaterException { final StringBuilder varname = new StringBuilder("" + eatOneChar()); if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) - throw EaterException.located("a002"); + throw new EaterException("a002", stringLocated); addUpToLastLetterOrUnderscoreOrDigit(varname); return varname.toString(); @@ -200,63 +198,63 @@ public abstract class Eater { final protected String eatAndGetFunctionName() throws EaterException { final StringBuilder varname = new StringBuilder("" + eatOneChar()); if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) - throw EaterException.located("a003"); + throw new EaterException("a003", stringLocated); addUpToLastLetterOrUnderscoreOrDigit(varname); return varname.toString(); } final public void skipSpaces() { - while (i < s.length() && Character.isWhitespace(s.charAt(i))) + while (i < stringLocated.length() && Character.isWhitespace(stringLocated.charAt(i))) i++; } final protected void skipUntilChar(char ch) { - while (i < s.length() && s.charAt(i) != ch) + while (i < stringLocated.length() && stringLocated.charAt(i) != ch) i++; } final public char peekChar() { - if (i >= s.length()) + if (i >= stringLocated.length()) return 0; - return s.charAt(i); + return stringLocated.charAt(i); } final public boolean matchAffectation() { - final String tmp = s.substring(i); + final String tmp = stringLocated.getString().substring(i); final boolean result = tmp.matches("^\\$?[_\\p{L}][_\\p{L}0-9]*\\s*=.*"); return result; } final public char peekCharN2() { - if (i + 1 >= s.length()) + if (i + 1 >= stringLocated.length()) return 0; - return s.charAt(i + 1); + return stringLocated.charAt(i + 1); } final protected boolean hasNextChar() { - return i < s.length(); + return i < stringLocated.length(); } final public char eatOneChar() { - final char ch = s.charAt(i); + final char ch = stringLocated.charAt(i); i++; return ch; } final protected void checkAndEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) - throw EaterException.located("a001"); + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) + throw new EaterException("a001", stringLocated); i++; } final protected boolean safeCheckAndEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return false; i++; @@ -264,10 +262,10 @@ public abstract class Eater { } final protected void optionallyEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return; - assert s.charAt(i) == ch; + assert stringLocated.charAt(i) == ch; i++; } @@ -278,8 +276,8 @@ public abstract class Eater { } final protected void addUpToLastLetterOrUnderscoreOrDigit(StringBuilder sb) { - while (i < s.length()) { - final char ch = s.charAt(i); + while (i < stringLocated.length()) { + final char ch = stringLocated.charAt(i); if (TLineType.isLetterOrUnderscoreOrDigit(ch) == false) return; @@ -289,7 +287,7 @@ public abstract class Eater { } final protected void addUpTo(char separator, StringBuilder sb) { - while (i < s.length()) { + while (i < stringLocated.length()) { final char ch = peekChar(); if (ch == separator) return; @@ -300,8 +298,7 @@ public abstract class Eater { } final protected TFunctionImpl eatDeclareFunction(TContext context, TMemory memory, boolean unquoted, - LineLocation location, boolean allowNoParenthesis, TFunctionType type) - throws EaterException, EaterExceptionLocated { + StringLocated location, boolean allowNoParenthesis, TFunctionType type) throws EaterException { final List args = new ArrayList<>(); final String functionName = eatAndGetFunctionName(); skipSpaces(); @@ -309,7 +306,7 @@ public abstract class Eater { if (allowNoParenthesis) return new TFunctionImpl(functionName, args, unquoted, type); - throw EaterException.located("Missing opening parenthesis"); + throw new EaterException("Missing opening parenthesis", stringLocated); } while (true) { skipSpaces(); @@ -321,8 +318,8 @@ public abstract class Eater { if (peekChar() == '=') { eatOneChar(); final TokenStack def = TokenStack.eatUntilCloseParenthesisOrComma(this); - def.guessFunctions(); - defValue = def.getResult(getLineLocation(), context, memory); + def.guessFunctions(location); + defValue = def.getResult(getStringLocated(), context, memory); // System.err.println("result=" + defValue); } else { defValue = null; @@ -334,7 +331,7 @@ public abstract class Eater { checkAndEatChar(")"); break; } else { - throw EaterException.located("Error in function definition"); + throw new EaterException("Error in function definition", stringLocated); } } skipSpaces(); @@ -342,25 +339,25 @@ public abstract class Eater { } final protected TFunctionImpl eatDeclareReturnFunctionWithOptionalReturn(TContext context, TMemory memory, - boolean unquoted, LineLocation location) throws EaterException, EaterExceptionLocated { + boolean unquoted, StringLocated location) throws EaterException { final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false, TFunctionType.RETURN_FUNCTION); if (peekChar() == 'r') { checkAndEatChar("return"); skipSpaces(); final String line = "!return " + eatAllToEnd(); - result.addBody(new StringLocated(line, location)); + result.addBody(new StringLocated(line, location.getLocation())); } else if (peekChar() == '!') { checkAndEatChar("!return"); skipSpaces(); final String line = "!return " + eatAllToEnd(); - result.addBody(new StringLocated(line, location)); + result.addBody(new StringLocated(line, location.getLocation())); } return result; } final protected TFunctionImpl eatDeclareProcedure(TContext context, TMemory memory, boolean unquoted, - LineLocation location) throws EaterException, EaterExceptionLocated { + StringLocated location) throws EaterException { final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false, TFunctionType.PROCEDURE); return result; diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectation.java b/src/net/sourceforge/plantuml/tim/EaterAffectation.java index 1c7297580..cad5ded5e 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectation.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectation.java @@ -44,7 +44,7 @@ public class EaterAffectation extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!"); skipSpaces(); @@ -53,7 +53,8 @@ public class EaterAffectation extends Eater { if (scope != null) { skipSpaces(); if (peekChar() == '?' || peekChar() == '=') { - // The variable itself is "local" or "glocal", which is not a good idea by the way + // The variable itself is "local" or "global", which is not a good idea by the + // way scope = null; } else varname = eatAndGetVarname(); @@ -71,7 +72,7 @@ public class EaterAffectation extends Eater { skipSpaces(); final TValue value = eatExpression(context, memory); - memory.putVariable(varname, value, scope); + memory.putVariable(varname, value, scope, getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java index d5a4fb950..3db77f96c 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java @@ -44,19 +44,19 @@ public class EaterAffectationDefine extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!define"); skipSpaces(); final String varname = eatAndGetVarname(); skipSpaces(); final String tmp = eatAllToEnd(); - final String tmp2 = context.applyFunctionsAndVariables(memory, getLineLocation(), tmp); + final String tmp2 = context.applyFunctionsAndVariables(memory, new StringLocated(tmp, getLineLocation())); final TValue value = TValue.fromString(tmp2); // if (memory instanceof TMemoryLocal) { // memory = ((TMemoryLocal) memory).getGlobalForInternalUseOnly(); // } - memory.putVariable(varname, value, TVariableScope.GLOBAL); + memory.putVariable(varname, value, TVariableScope.GLOBAL, getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterAssert.java b/src/net/sourceforge/plantuml/tim/EaterAssert.java index 1858579ee..00603e675 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAssert.java +++ b/src/net/sourceforge/plantuml/tim/EaterAssert.java @@ -44,7 +44,7 @@ public class EaterAssert extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!assert"); skipSpaces(); @@ -55,9 +55,9 @@ public class EaterAssert extends Eater { if (ch == ':') { checkAndEatChar(':'); final TValue message = eatExpression(context, memory); - throw EaterException.located("Assertion error : " + message.toString()); + throw new EaterException("Assertion error : " + message.toString(), getStringLocated()); } - throw EaterException.located("Assertion error"); + throw new EaterException("Assertion error", getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java b/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java index 43dc732c3..b26b2b425 100644 --- a/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java +++ b/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java @@ -35,21 +35,20 @@ package net.sourceforge.plantuml.tim; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.utils.LineLocation; public class EaterDeclareProcedure extends Eater { private TFunctionImpl function; - private final LineLocation location; + private final StringLocated location; private boolean finalFlag; public EaterDeclareProcedure(StringLocated s) { super(s.getTrimmed()); - this.location = s.getLocation(); + this.location = s; } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!"); boolean unquoted = false; diff --git a/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java b/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java index e02ad1e30..139130ed6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java @@ -35,21 +35,20 @@ package net.sourceforge.plantuml.tim; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.utils.LineLocation; public class EaterDeclareReturnFunction extends Eater { private TFunctionImpl function; - private final LineLocation location; + private final StringLocated location; private boolean finalFlag; public EaterDeclareReturnFunction(StringLocated s) { super(s.getTrimmed()); - this.location = s.getLocation(); + this.location = s; } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!"); boolean unquoted = false; diff --git a/src/net/sourceforge/plantuml/tim/EaterElseIf.java b/src/net/sourceforge/plantuml/tim/EaterElseIf.java index 8ddc5e35a..85f8a1ae8 100644 --- a/src/net/sourceforge/plantuml/tim/EaterElseIf.java +++ b/src/net/sourceforge/plantuml/tim/EaterElseIf.java @@ -46,7 +46,7 @@ public class EaterElseIf extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!elseif"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterException.java b/src/net/sourceforge/plantuml/tim/EaterException.java index 94cf2a604..4de83e32b 100644 --- a/src/net/sourceforge/plantuml/tim/EaterException.java +++ b/src/net/sourceforge/plantuml/tim/EaterException.java @@ -34,30 +34,26 @@ */ package net.sourceforge.plantuml.tim; +import java.util.Objects; + import net.sourceforge.plantuml.text.StringLocated; public class EaterException extends Exception { private final String message; + private final StringLocated location; - private EaterException(String message) { - this.message = message; - } - - public static EaterException unlocated(String message) { - return new EaterException(message); - } - - public static EaterException located(String message) { - return unlocated(message); + public EaterException(String message, StringLocated location) { + this.message = Objects.requireNonNull(message); + this.location = Objects.requireNonNull(location); } public final String getMessage() { return message; } - public EaterExceptionLocated withLocation(StringLocated sl) { - return EaterExceptionLocated.located(message, sl); + public final StringLocated getLocation() { + return location; } } diff --git a/src/net/sourceforge/plantuml/tim/EaterForeach.java b/src/net/sourceforge/plantuml/tim/EaterForeach.java index b7be391da..37be05afc 100644 --- a/src/net/sourceforge/plantuml/tim/EaterForeach.java +++ b/src/net/sourceforge/plantuml/tim/EaterForeach.java @@ -48,7 +48,7 @@ public class EaterForeach extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!foreach"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java index 22c233868..b5cc4204b 100644 --- a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java +++ b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java @@ -58,7 +58,7 @@ public class EaterFunctionCall extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipUntilChar('('); checkAndEatChar('('); skipSpaces(); @@ -70,7 +70,8 @@ public class EaterFunctionCall extends Eater { skipSpaces(); if (isLegacyDefine) { final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); values.add(result); } else if (unquoted) { @@ -80,12 +81,14 @@ public class EaterFunctionCall extends Eater { checkAndEatChar('='); skipSpaces(); final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); namedArguments.put(varname, result); } else { final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); values.add(result); } @@ -97,13 +100,13 @@ public class EaterFunctionCall extends Eater { checkAndEatChar('='); skipSpaces(); final TokenStack tokens = TokenStack.eatUntilCloseParenthesisOrComma(this).withoutSpace(); - tokens.guessFunctions(); - final TValue result = tokens.getResult(getLineLocation(), context, memory); + tokens.guessFunctions(getStringLocated()); + final TValue result = tokens.getResult(getStringLocated(), context, memory); namedArguments.put(varname, result); } else { final TokenStack tokens = TokenStack.eatUntilCloseParenthesisOrComma(this).withoutSpace(); - tokens.guessFunctions(); - final TValue result = tokens.getResult(getLineLocation(), context, memory); + tokens.guessFunctions(getStringLocated()); + final TValue result = tokens.getResult(getStringLocated(), context, memory); values.add(result); } } @@ -116,9 +119,9 @@ public class EaterFunctionCall extends Eater { break; } if (unquoted) { - throw EaterException.located("unquoted function/procedure cannot use expression."); + throw new EaterException("unquoted function/procedure cannot use expression.", getStringLocated()); } - throw EaterException.located("call001"); + throw new EaterException("call001", getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterIf.java b/src/net/sourceforge/plantuml/tim/EaterIf.java index 50ad453da..f44772c48 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIf.java +++ b/src/net/sourceforge/plantuml/tim/EaterIf.java @@ -46,7 +46,7 @@ public class EaterIf extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!if"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterImport.java b/src/net/sourceforge/plantuml/tim/EaterImport.java index b17727d17..3f1296de6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterImport.java +++ b/src/net/sourceforge/plantuml/tim/EaterImport.java @@ -38,23 +38,24 @@ import net.sourceforge.plantuml.text.StringLocated; public class EaterImport extends Eater { - private String location; + private String what; public EaterImport(StringLocated s) { super(s); } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!import"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.what = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } - public final String getLocation() { - return location; + public final String getWhat() { + return what; } } diff --git a/src/net/sourceforge/plantuml/tim/EaterInclude.java b/src/net/sourceforge/plantuml/tim/EaterInclude.java index c41bd9f88..cf6eb3975 100644 --- a/src/net/sourceforge/plantuml/tim/EaterInclude.java +++ b/src/net/sourceforge/plantuml/tim/EaterInclude.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.text.StringLocated; public class EaterInclude extends Eater { - private String location; + private String what; private PreprocessorIncludeStrategy strategy = PreprocessorIncludeStrategy.DEFAULT; public EaterInclude(StringLocated s) { @@ -47,7 +47,7 @@ public class EaterInclude extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!include"); final char peekChar = peekChar(); @@ -65,14 +65,15 @@ public class EaterInclude extends Eater { } } skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.what = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); // final TValue value = eatExpression(context, memory); // this.location = value.toString(); } - public final String getLocation() { - return location; + public final String getWhat() { + return what; } public final PreprocessorIncludeStrategy getPreprocessorIncludeStrategy() { diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java index 1cb813363..6e3ce76c5 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java @@ -45,11 +45,12 @@ public class EaterIncludeDef extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!includedef"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.location = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java index 355b11605..5cdb7f5c6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java @@ -38,23 +38,24 @@ import net.sourceforge.plantuml.text.StringLocated; public class EaterIncludesub extends Eater { - private String location; + private String what; public EaterIncludesub(StringLocated s) { super(s); } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!includesub"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.what = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } - public final String getLocation() { - return location; + public final String getWhat() { + return what; } } diff --git a/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java b/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java index bd82decbe..6035a7ed6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java +++ b/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java @@ -45,11 +45,11 @@ public class EaterLegacyDefine extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!define"); skipSpaces(); - function = eatDeclareFunction(context, memory, true, getLineLocation(), false, TFunctionType.LEGACY_DEFINE); + function = eatDeclareFunction(context, memory, true, getStringLocated(), false, TFunctionType.LEGACY_DEFINE); final String def = this.eatAllToEnd(); // function.setFunctionType(TFunctionType.LEGACY_DEFINE); function.setLegacyDefinition(def); diff --git a/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java b/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java index 56a10e488..3fccd619c 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java +++ b/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java @@ -45,11 +45,11 @@ public class EaterLegacyDefineLong extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!definelong"); skipSpaces(); - function = eatDeclareFunction(context, memory, true, getLineLocation(), true, TFunctionType.LEGACY_DEFINELONG); + function = eatDeclareFunction(context, memory, true, getStringLocated(), true, TFunctionType.LEGACY_DEFINELONG); // function.setFunctionType(TFunctionType.LEGACY_DEFINELONG); } diff --git a/src/net/sourceforge/plantuml/tim/EaterLog.java b/src/net/sourceforge/plantuml/tim/EaterLog.java index 4a0bc62df..3e31b00f7 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLog.java +++ b/src/net/sourceforge/plantuml/tim/EaterLog.java @@ -44,11 +44,12 @@ public class EaterLog extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!log"); skipSpaces(); - final String logData = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + final String logData = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); Log.error("[Log] " + logData); } diff --git a/src/net/sourceforge/plantuml/tim/EaterReturn.java b/src/net/sourceforge/plantuml/tim/EaterReturn.java index 99ed3dd21..327940207 100644 --- a/src/net/sourceforge/plantuml/tim/EaterReturn.java +++ b/src/net/sourceforge/plantuml/tim/EaterReturn.java @@ -46,7 +46,7 @@ public class EaterReturn extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!return"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterStartsub.java b/src/net/sourceforge/plantuml/tim/EaterStartsub.java index 44a1ba175..5cd8207b2 100644 --- a/src/net/sourceforge/plantuml/tim/EaterStartsub.java +++ b/src/net/sourceforge/plantuml/tim/EaterStartsub.java @@ -50,9 +50,9 @@ public class EaterStartsub extends Eater { checkAndEatChar("!startsub"); skipSpaces(); this.subname = eatAllToEnd(); - if (this.subname.matches("\\w+") == false) { - throw EaterException.located("Bad sub name"); - } + if (this.subname.matches("\\w+") == false) + throw new EaterException("Bad sub name", getStringLocated()); + } public final String getSubname() { diff --git a/src/net/sourceforge/plantuml/tim/EaterTheme.java b/src/net/sourceforge/plantuml/tim/EaterTheme.java index 35dfc4938..7203c5521 100644 --- a/src/net/sourceforge/plantuml/tim/EaterTheme.java +++ b/src/net/sourceforge/plantuml/tim/EaterTheme.java @@ -67,7 +67,7 @@ public class EaterTheme extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { skipSpaces(); checkAndEatChar("!theme"); skipSpaces(); @@ -76,12 +76,12 @@ public class EaterTheme extends Eater { final int x = this.name.toLowerCase().indexOf(" from "); if (x != -1) { final String fromTmp = this.name.substring(x + " from ".length()).trim(); - this.from = context.applyFunctionsAndVariables(memory, getLineLocation(), fromTmp); + this.from = context.applyFunctionsAndVariables(memory, new StringLocated(fromTmp, getLineLocation())); this.name = this.name.substring(0, x).trim(); this.context = context; } - this.realName = context.applyFunctionsAndVariables(memory, getLineLocation(), this.name); + this.realName = context.applyFunctionsAndVariables(memory, new StringLocated(this.name, getLineLocation())); } @@ -101,24 +101,24 @@ public class EaterTheme extends Eater { } catch (IOException e) { Logme.error(e); } - throw EaterException.located("Cannot load " + realName); + throw new EaterException("Cannot load " + realName, getStringLocated()); } if (from.startsWith("<") && from.endsWith(">")) { final ReadLine reader = ThemeUtils.getReaderTheme(realName, from); if (reader == null) - throw EaterException.located("No such theme " + realName + " in " + from); + throw new EaterException("No such theme " + realName + " in " + from, getStringLocated()); return reader; } else if (from.startsWith("http://") || from.startsWith("https://")) { final SURL url = SURL.create(ThemeUtils.getFullPath(from, realName)); if (url == null) - throw EaterException.located("Cannot open URL"); + throw new EaterException("Cannot open URL", getStringLocated()); try { - return PreprocessorUtils.getReaderInclude(url, getLineLocation(), UTF_8); + return PreprocessorUtils.getReaderInclude(url, getStringLocated(), UTF_8); } catch (UnsupportedEncodingException e) { Logme.error(e); - throw EaterException.located("Cannot decode charset"); + throw new EaterException("Cannot decode charset", getStringLocated()); } } @@ -126,12 +126,12 @@ public class EaterTheme extends Eater { final FileWithSuffix file = context.getFileWithSuffix(from, realName); final Reader tmp = file.getReader(UTF_8); if (tmp == null) - throw EaterException.located("No such theme " + realName); + throw new EaterException("No such theme " + realName, getStringLocated()); return ReadLineReader.create(tmp, "theme " + realName); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot load " + realName); + throw new EaterException("Cannot load " + realName, getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java index 424a3d845..9e406e185 100644 --- a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java +++ b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java @@ -34,6 +34,7 @@ */ package net.sourceforge.plantuml.tim; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; import net.sourceforge.plantuml.tim.expression.TokenStack; import net.sourceforge.plantuml.tim.iterator.CodePosition; @@ -59,8 +60,8 @@ public class ExecutionContextWhile { return new ExecutionContextWhile(whileExpression, codePosition); } - public TValue conditionValue(LineLocation location, TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { + public TValue conditionValue(StringLocated location, TContext context, TMemory memory) + throws EaterException { return whileExpression.getResult(location, context, memory); } diff --git a/src/net/sourceforge/plantuml/tim/ExecutionContexts.java b/src/net/sourceforge/plantuml/tim/ExecutionContexts.java index 8a3cb8518..f42116e1a 100644 --- a/src/net/sourceforge/plantuml/tim/ExecutionContexts.java +++ b/src/net/sourceforge/plantuml/tim/ExecutionContexts.java @@ -80,11 +80,11 @@ public abstract class ExecutionContexts { } public boolean areAllIfOk(TContext context, TMemory memory) throws EaterException { - for (ExecutionContextIf conditionalContext : allIfs) { - if (conditionalContext.conditionIsOkHere() == false) { + for (ExecutionContextIf conditionalContext : allIfs) + if (conditionalContext.conditionIsOkHere() == false) return false; - } - } + + return true; } diff --git a/src/net/sourceforge/plantuml/tim/FunctionsSet.java b/src/net/sourceforge/plantuml/tim/FunctionsSet.java index ee9d21019..683d0d7fa 100644 --- a/src/net/sourceforge/plantuml/tim/FunctionsSet.java +++ b/src/net/sourceforge/plantuml/tim/FunctionsSet.java @@ -51,16 +51,16 @@ public class FunctionsSet { public TFunction getFunctionSmart(TFunctionSignature searched) { final TFunction func = this.functions.get(searched); - if (func != null) { + if (func != null) return func; - } + for (TFunction candidate : this.functions.values()) { - if (candidate.getSignature().sameFunctionNameAs(searched) == false) { + if (candidate.getSignature().sameFunctionNameAs(searched) == false) continue; - } - if (candidate.canCover(searched.getNbArg(), searched.getNamedArguments())) { + + if (candidate.canCover(searched.getNbArg(), searched.getNamedArguments())) return candidate; - } + } return null; } @@ -82,9 +82,9 @@ public class FunctionsSet { } public void addFunction(TFunction func) { - if (func.getFunctionType() == TFunctionType.LEGACY_DEFINELONG) { + if (func.getFunctionType() == TFunctionType.LEGACY_DEFINELONG) ((TFunctionImpl) func).finalizeEnddefinelong(); - } + this.functions.put(func.getSignature(), func); this.functions3.add(func.getSignature().getFunctionName() + "("); } @@ -95,10 +95,10 @@ public class FunctionsSet { } public void executeLegacyDefine(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { - if (this.pendingFunction != null) { - throw EaterException.located("already0048"); - } + throws EaterException { + if (this.pendingFunction != null) + throw new EaterException("already0048", s); + final EaterLegacyDefine legacyDefine = new EaterLegacyDefine(s); legacyDefine.analyze(context, memory); final TFunction function = legacyDefine.getFunction(); @@ -107,59 +107,59 @@ public class FunctionsSet { } public void executeLegacyDefineLong(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { - if (this.pendingFunction != null) { - throw EaterException.located("already0068"); - } + throws EaterException { + if (this.pendingFunction != null) + throw new EaterException("already0068", s); + final EaterLegacyDefineLong legacyDefineLong = new EaterLegacyDefineLong(s); legacyDefineLong.analyze(context, memory); this.pendingFunction = legacyDefineLong.getFunction(); } public void executeDeclareReturnFunction(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { - if (this.pendingFunction != null) { - throw EaterException.located("already0068"); - } + throws EaterException { + if (this.pendingFunction != null) + throw new EaterException("already0068", s); + final EaterDeclareReturnFunction declareFunction = new EaterDeclareReturnFunction(s); declareFunction.analyze(context, memory); final boolean finalFlag = declareFunction.getFinalFlag(); final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature(); final TFunction previous = this.functions.get(declaredSignature); - if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) { - throw EaterException.located("This function is already defined"); - } - if (finalFlag) { + if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) + throw new EaterException("This function is already defined", s); + + if (finalFlag) this.functionsFinal.add(declaredSignature); - } - if (declareFunction.getFunction().hasBody()) { + + if (declareFunction.getFunction().hasBody()) this.addFunction(declareFunction.getFunction()); - } else { + else this.pendingFunction = declareFunction.getFunction(); - } + } public void executeDeclareProcedure(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { - if (this.pendingFunction != null) { - throw EaterException.located("already0068"); - } + throws EaterException { + if (this.pendingFunction != null) + throw new EaterException("already0068", s); + final EaterDeclareProcedure declareFunction = new EaterDeclareProcedure(s); declareFunction.analyze(context, memory); final boolean finalFlag = declareFunction.getFinalFlag(); final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature(); final TFunction previous = this.functions.get(declaredSignature); - if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) { - throw EaterException.located("This function is already defined"); - } - if (finalFlag) { + if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) + throw new EaterException("This function is already defined", s); + + if (finalFlag) this.functionsFinal.add(declaredSignature); - } - if (declareFunction.getFunction().hasBody()) { + + if (declareFunction.getFunction().hasBody()) this.addFunction(declareFunction.getFunction()); - } else { + else this.pendingFunction = declareFunction.getFunction(); - } + } } diff --git a/src/net/sourceforge/plantuml/tim/StringEater.java b/src/net/sourceforge/plantuml/tim/StringEater.java index 6e6a1489a..818a7856d 100644 --- a/src/net/sourceforge/plantuml/tim/StringEater.java +++ b/src/net/sourceforge/plantuml/tim/StringEater.java @@ -34,14 +34,16 @@ */ package net.sourceforge.plantuml.tim; +import net.sourceforge.plantuml.text.StringLocated; + public class StringEater extends Eater { public StringEater(String s) { - super(s, null); + super(new StringLocated(s, null)); } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterException { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/TContext.java b/src/net/sourceforge/plantuml/tim/TContext.java index 23c43aa07..79188e5ca 100644 --- a/src/net/sourceforge/plantuml/tim/TContext.java +++ b/src/net/sourceforge/plantuml/tim/TContext.java @@ -97,6 +97,8 @@ import net.sourceforge.plantuml.tim.stdlib.Feature; import net.sourceforge.plantuml.tim.stdlib.FileExists; import net.sourceforge.plantuml.tim.stdlib.Filename; import net.sourceforge.plantuml.tim.stdlib.FunctionExists; +import net.sourceforge.plantuml.tim.stdlib.GetAllStdlib; +import net.sourceforge.plantuml.tim.stdlib.GetAllTheme; import net.sourceforge.plantuml.tim.stdlib.GetJsonKey; import net.sourceforge.plantuml.tim.stdlib.GetJsonType; import net.sourceforge.plantuml.tim.stdlib.GetVariableValue; @@ -122,6 +124,7 @@ import net.sourceforge.plantuml.tim.stdlib.Lower; import net.sourceforge.plantuml.tim.stdlib.Newline; import net.sourceforge.plantuml.tim.stdlib.Now; import net.sourceforge.plantuml.tim.stdlib.Ord; +import net.sourceforge.plantuml.tim.stdlib.RandomFunction; import net.sourceforge.plantuml.tim.stdlib.RetrieveProcedure; import net.sourceforge.plantuml.tim.stdlib.ReverseColor; import net.sourceforge.plantuml.tim.stdlib.ReverseHsluvColor; @@ -208,6 +211,9 @@ public class TContext { functionsSet.addFunction(new LogicalNor()); functionsSet.addFunction(new LogicalNxor()); functionsSet.addFunction(new Ord()); + functionsSet.addFunction(new RandomFunction()); + functionsSet.addFunction(new GetAllTheme()); + functionsSet.addFunction(new GetAllStdlib()); // %standard_exists_function // %str_replace // !exit @@ -230,7 +236,7 @@ public class TContext { public Knowledge asKnowledge(final TMemory memory, final LineLocation location) { return new Knowledge() { - public TValue getVariable(String name) throws EaterException, EaterExceptionLocated { + public TValue getVariable(String name) throws EaterException { if (name.contains(".") || name.contains("[")) { final TValue result = fromJson(memory, name, location); return result; @@ -244,9 +250,8 @@ public class TContext { }; } - private TValue fromJson(TMemory memory, String name, LineLocation location) - throws EaterException, EaterExceptionLocated { - final String result = applyFunctionsAndVariables(memory, location, name); + private TValue fromJson(TMemory memory, String name, LineLocation location) throws EaterException { + final String result = applyFunctionsAndVariables(memory, new StringLocated(name, location)); try { final JsonValue json = Json.parse(result); return TValue.fromJson(json); @@ -274,27 +279,23 @@ public class TContext { } public TValue executeLines(TMemory memory, List body, TFunctionType ftype, boolean modeSpecial) - throws EaterExceptionLocated { + throws EaterException { final CodeIterator it = buildCodeIterator(memory, body); StringLocated s = null; - try { - while ((s = it.peek()) != null) { - final TValue result = executeOneLineSafe(memory, s, ftype, modeSpecial); - if (result != null) - return result; + while ((s = it.peek()) != null) { + final TValue result = executeOneLineSafe(memory, s, ftype, modeSpecial); + if (result != null) + return result; - it.next(); - } - return null; - } catch (EaterException e) { - throw e.withLocation(s); + it.next(); } + return null; } private void executeLinesInternal(TMemory memory, List body, TFunctionType ftype) - throws EaterExceptionLocated, EaterException { + throws EaterException { final CodeIterator it = buildCodeIterator(memory, body); StringLocated s = null; @@ -306,22 +307,20 @@ public class TContext { } private TValue executeOneLineSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial) - throws EaterException, EaterExceptionLocated { + throws EaterException { try { this.debug.add(s); return executeOneLineNotSafe(memory, s, ftype, modeSpecial); } catch (Exception e) { if (e instanceof EaterException) throw (EaterException) e; - if (e instanceof EaterExceptionLocated) - throw (EaterExceptionLocated) e; Logme.error(e); - throw EaterException.located("Fatal parsing error"); + throw new EaterException("Fatal parsing error", s); } } private TValue executeOneLineNotSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial) - throws EaterException, EaterExceptionLocated { + throws EaterException { final TLineType type = s.getType(); if (type == TLineType.INCLUDESUB) { @@ -376,11 +375,11 @@ public class TContext { } else if (s.getString().matches("^\\s+$")) { return null; } else { - throw EaterException.located("Compile Error " + ftype + " " + type); + throw new EaterException("Compile Error " + ftype + " " + type, s); } } - private void addPlain(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void addPlain(TMemory memory, StringLocated s) throws EaterException { final StringLocated tmp[] = applyFunctionsAndVariablesInternal(memory, s); if (tmp != null) { if (pendingAdd != null) { @@ -393,12 +392,11 @@ public class TContext { } } - private void simulatePlain(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void simulatePlain(TMemory memory, StringLocated s) throws EaterException { final StringLocated ignored[] = applyFunctionsAndVariablesInternal(memory, s); } - private void executeAffectationDefine(TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeAffectationDefine(TMemory memory, StringLocated s) throws EaterException { new EaterAffectationDefine(s).analyze(this, memory); } @@ -407,7 +405,7 @@ public class TContext { condition.analyze(this, memory); } - private void executeAssert(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeAssert(TMemory memory, StringLocated s) throws EaterException { final EaterAssert condition = new EaterAssert(s); condition.analyze(this, memory); } @@ -418,11 +416,11 @@ public class TContext { } private StringLocated[] applyFunctionsAndVariablesInternal(TMemory memory, StringLocated located) - throws EaterException, EaterExceptionLocated { + throws EaterException { if (memory.isEmpty() && functionsSet.size() == 0) return new StringLocated[] { located }; - final String result = applyFunctionsAndVariables(memory, located.getLocation(), located.getString()); + final String result = applyFunctionsAndVariables(memory, located); if (result == null) return null; @@ -436,54 +434,53 @@ public class TContext { private String pendingAdd = null; - public String applyFunctionsAndVariables(TMemory memory, LineLocation location, final String str) - throws EaterException, EaterExceptionLocated { + public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) throws EaterException { // https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm // https://stackoverflow.com/questions/1326682/java-replacing-multiple-different-substring-in-a-string-at-once-or-in-the-most // https://en.wikipedia.org/wiki/String-searching_algorithm // https://www.quora.com/What-is-the-most-efficient-algorithm-to-replace-all-occurrences-of-a-pattern-P-in-a-string-with-a-pattern-P // https://en.wikipedia.org/wiki/Trie if (memory.isEmpty() && functionsSet.size() == 0) - return str; + return str.getString(); final StringBuilder result = new StringBuilder(); for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); - final String presentFunction = getFunctionNameAt(str, i); + final String presentFunction = getFunctionNameAt(str.getString(), i); if (presentFunction != null) { - final String sub = str.substring(i); - final EaterFunctionCall call = new EaterFunctionCall(new StringLocated(sub, location), + final String sub = str.getString().substring(i); + final EaterFunctionCall call = new EaterFunctionCall(new StringLocated(sub, str.getLocation()), isLegacyDefine(presentFunction), isUnquoted(presentFunction)); call.analyze(this, memory); final TFunctionSignature signature = new TFunctionSignature(presentFunction, call.getValues().size(), call.getNamedArguments().keySet()); final TFunction function = functionsSet.getFunctionSmart(signature); if (function == null) - throw EaterException.located("Function not found " + presentFunction); + throw new EaterException("Function not found " + presentFunction, str); if (function.getFunctionType() == TFunctionType.PROCEDURE) { this.pendingAdd = result.toString(); - executeVoid3(location, memory, sub, function, call); + executeVoid3(str, memory, function, call); i += call.getCurrentPosition(); - final String remaining = str.substring(i); + final String remaining = str.getString().substring(i); if (remaining.length() > 0) appendToLastResult(remaining); return null; } if (function.getFunctionType() == TFunctionType.LEGACY_DEFINELONG) { - this.pendingAdd = str.substring(0, i); - executeVoid3(location, memory, sub, function, call); + this.pendingAdd = str.getString().substring(0, i); + executeVoid3(str, memory, function, call); return null; } assert function.getFunctionType() == TFunctionType.RETURN_FUNCTION || function.getFunctionType() == TFunctionType.LEGACY_DEFINE; - final TValue functionReturn = function.executeReturnFunction(this, memory, location, call.getValues(), + final TValue functionReturn = function.executeReturnFunction(this, memory, str, call.getValues(), call.getNamedArguments()); result.append(functionReturn.toString()); i += call.getCurrentPosition() - 1; - } else if (new VariableManager(this, memory, location).getVarnameAt(str, i) != null) { - i = new VariableManager(this, memory, location).replaceVariables(str, i, result); + } else if (new VariableManager(this, memory, str).getVarnameAt(str.getString(), i) != null) { + i = new VariableManager(this, memory, str).replaceVariables(str.getString(), i, result); } else { result.append(c); } @@ -496,33 +493,31 @@ public class TContext { this.resultList.set(this.resultList.size() - 1, last.append(remaining)); } - private void executeVoid3(LineLocation location, TMemory memory, String s, TFunction function, - EaterFunctionCall call) throws EaterException, EaterExceptionLocated { - function.executeProcedureInternal(this, memory, call.getValues(), call.getNamedArguments()); - // function.executeProcedure(this, memory, location, s, call.getValues(), - // call.getNamedArguments()); + private void executeVoid3(StringLocated location, TMemory memory, TFunction function, EaterFunctionCall call) + throws EaterException { + function.executeProcedureInternal(this, memory, location, call.getValues(), call.getNamedArguments()); } - private void executeImport(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeImport(TMemory memory, StringLocated s) throws EaterException { final EaterImport _import = new EaterImport(s.getTrimmed()); _import.analyze(this, memory); try { final SFile file = FileSystem.getInstance() - .getFile(applyFunctionsAndVariables(memory, s.getLocation(), _import.getLocation())); + .getFile(applyFunctionsAndVariables(memory, new StringLocated(_import.getWhat(), s.getLocation()))); if (file.exists() && file.isDirectory() == false) { importedFiles.add(file); return; } } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot import " + e.getMessage()); + throw new EaterException("Cannot import " + e.getMessage(), s); } - throw EaterException.located("Cannot import"); + throw new EaterException("Cannot import", s); } - private void executeLog(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeLog(TMemory memory, StringLocated s) throws EaterException { final EaterLog log = new EaterLog(s.getTrimmed()); log.analyze(this, memory); } @@ -534,17 +529,17 @@ public class TContext { } - private void executeIncludesub(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeIncludesub(TMemory memory, StringLocated s) throws EaterException { ImportedFiles saveImportedFiles = null; try { final EaterIncludesub include = new EaterIncludesub(s.getTrimmed()); include.analyze(this, memory); - final String location = include.getLocation(); - final int idx = location.indexOf('!'); + final String what = include.getWhat(); + final int idx = what.indexOf('!'); Sub sub = null; if (idx != -1) { - final String filename = location.substring(0, idx); - final String blocname = location.substring(idx + 1); + final String filename = what.substring(0, idx); + final String blocname = what.substring(idx + 1); try { final FileWithSuffix f2 = importedFiles.getFile(filename, null); if (f2.fileOk()) { @@ -552,10 +547,10 @@ public class TContext { this.importedFiles = this.importedFiles.withCurrentDir(f2.getParentFile()); final Reader reader = f2.getReader(charset); if (reader == null) - throw EaterException.located("cannot include " + location); + throw new EaterException("cannot include " + what, s); try { - ReadLine readerline = ReadLineReader.create(reader, location, s.getLocation()); + ReadLine readerline = ReadLineReader.create(reader, what, s.getLocation()); readerline = new UncommentReadLine(readerline); sub = Sub.fromFile(readerline, blocname, this, memory); } finally { @@ -564,14 +559,14 @@ public class TContext { } } catch (IOException e) { Logme.error(e); - throw EaterException.located("cannot include " + location); + throw new EaterException("cannot include " + what, s); } } if (sub == null) - sub = subs.get(location); + sub = subs.get(what); if (sub == null) - throw EaterException.located("cannot include " + location); + throw new EaterException("cannot include " + what, s); executeLinesInternal(memory, sub.lines(), null); } finally { @@ -581,7 +576,7 @@ public class TContext { } } - private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterException { final EaterIncludeDef include = new EaterIncludeDef(s.getTrimmed()); include.analyze(this, memory); final String definitionName = include.getLocation(); @@ -600,7 +595,7 @@ public class TContext { } while (true); } catch (IOException e) { Logme.error(e); - throw EaterException.located("" + e); + throw new EaterException("" + e, s); } finally { try { reader2.close(); @@ -610,12 +605,12 @@ public class TContext { } } - private void executeTheme(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeTheme(TMemory memory, StringLocated s) throws EaterException { final EaterTheme eater = new EaterTheme(s.getTrimmed(), importedFiles); eater.analyze(this, memory); final ReadLine reader = eater.getTheme(); if (reader == null) - throw EaterException.located("No such theme " + eater.getName()); + throw new EaterException("No such theme " + eater.getName(), s); try { final List body = new ArrayList<>(); @@ -629,7 +624,7 @@ public class TContext { } while (true); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Error reading theme " + e); + throw new EaterException("Error reading theme " + e, s); } finally { try { reader.close(); @@ -639,10 +634,10 @@ public class TContext { } } - private void executeInclude(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeInclude(TMemory memory, StringLocated s) throws EaterException { final EaterInclude include = new EaterInclude(s.getTrimmed()); include.analyze(this, memory); - String location = include.getLocation(); + String location = include.getWhat(); final PreprocessorIncludeStrategy strategy = include.getPreprocessorIncludeStrategy(); final int idx = location.lastIndexOf('!'); String suf = null; @@ -657,7 +652,7 @@ public class TContext { if (location.startsWith("http://") || location.startsWith("https://")) { final SURL url = SURL.create(location); if (url == null) - throw EaterException.located("Cannot open URL"); + throw new EaterException("Cannot open URL", s); reader = PreprocessorUtils.getReaderIncludeUrl(url, s, suf, charset); } else if (location.startsWith("<") && location.endsWith(">")) { @@ -673,14 +668,14 @@ public class TContext { return; if (strategy == PreprocessorIncludeStrategy.ONCE && filesUsedCurrent.contains(f2)) - throw EaterException.located("This file has already been included"); + throw new EaterException("This file has already been included", s); if (StartDiagramExtractReader.containsStartDiagram(f2, s, charset)) { reader = StartDiagramExtractReader.build(f2, s, charset); } else { final Reader tmp = f2.getReader(charset); if (tmp == null) - throw EaterException.located("Cannot include file"); + throw new EaterException("Cannot include file", s); reader = ReadLineReader.create(tmp, location, s.getLocation()); } @@ -709,7 +704,7 @@ public class TContext { } } catch (IOException e) { Logme.error(e); - throw EaterException.located("cannot include " + e); + throw new EaterException("cannot include " + e, s); } finally { if (reader != null) { try { @@ -720,7 +715,7 @@ public class TContext { } } - throw EaterException.located("cannot include " + location); + throw new EaterException("cannot include " + location, s); } public boolean isLegacyDefine(String functionName) { diff --git a/src/net/sourceforge/plantuml/tim/TFunction.java b/src/net/sourceforge/plantuml/tim/TFunction.java index 028996913..3570bfbea 100644 --- a/src/net/sourceforge/plantuml/tim/TFunction.java +++ b/src/net/sourceforge/plantuml/tim/TFunction.java @@ -38,8 +38,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public interface TFunction { @@ -49,14 +49,11 @@ public interface TFunction { public TFunctionType getFunctionType(); - public void executeProcedure(TContext context, TMemory memory, LineLocation location, String s) - throws EaterException, EaterExceptionLocated; + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException; - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List args, - Map named) throws EaterException, EaterExceptionLocated; - - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated; + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException; public boolean isUnquoted(); diff --git a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java index dbdf7eb1a..bf51f7064 100644 --- a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java +++ b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java @@ -69,6 +69,7 @@ public class TFunctionImpl implements TFunction { this.functionType = functionType; } + @Override public boolean canCover(int nbArg, Set namedArguments) { for (String n : namedArguments) if (signature.getNamedArguments().contains(n) == false) @@ -120,30 +121,18 @@ public class TFunctionImpl implements TFunction { return "FUNCTION " + signature + " " + args; } - public void addBody(StringLocated s) throws EaterExceptionLocated { + public void addBody(StringLocated s) throws EaterException { body.add(s); if (s.getType() == TLineType.RETURN) { this.containsReturn = true; if (functionType == TFunctionType.PROCEDURE) - throw EaterExceptionLocated - .located("A procedure cannot have !return directive. Declare it as a function instead ?", s); + throw new EaterException("A procedure cannot have !return directive. Declare it as a function instead ?", s); } } - public void executeProcedure(TContext context, TMemory memory, LineLocation location, String s) - throws EaterException, EaterExceptionLocated { - final EaterFunctionCall call = new EaterFunctionCall(new StringLocated(s, location), - context.isLegacyDefine(signature.getFunctionName()), unquoted); - call.analyze(context, memory); - final String endOfLine = call.getEndOfLine(); - final List args = call.getValues(); - final Map named = call.getNamedArguments(); - executeProcedureInternal(context, memory, args, named); - context.appendEndOfLine(endOfLine); - } - - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated { + @Override + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException { if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG) throw new IllegalStateException(); @@ -151,29 +140,30 @@ public class TFunctionImpl implements TFunction { context.executeLines(copy, body, TFunctionType.PROCEDURE, false); } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List args, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException { if (functionType == TFunctionType.LEGACY_DEFINE) - return executeReturnLegacyDefine(location, context, memory, args); + return executeReturnLegacyDefine(location.getLocation(), context, memory, args); if (functionType != TFunctionType.RETURN_FUNCTION) - throw EaterException.unlocated("Illegal call here. Is there a return directive in your function?"); + throw new EaterException("Illegal call here. Is there a return directive in your function?", location); final TMemory copy = getNewMemory(memory, args, named); final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true); if (result == null) - throw EaterException.unlocated("No return directive found in your function"); + throw new EaterException("No return directive found in your function", location); return result; } private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List args) - throws EaterException, EaterExceptionLocated { + throws EaterException { if (legacyDefinition == null) throw new IllegalStateException(); final TMemory copy = getNewMemory(memory, args, Collections.emptyMap()); - final String tmp = context.applyFunctionsAndVariables(copy, location, legacyDefinition); + final String tmp = context.applyFunctionsAndVariables(copy, new StringLocated(legacyDefinition, location)); if (tmp == null) return TValue.fromString(""); diff --git a/src/net/sourceforge/plantuml/tim/TMemory.java b/src/net/sourceforge/plantuml/tim/TMemory.java index a1f830e79..466b5951b 100644 --- a/src/net/sourceforge/plantuml/tim/TMemory.java +++ b/src/net/sourceforge/plantuml/tim/TMemory.java @@ -37,13 +37,15 @@ package net.sourceforge.plantuml.tim; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; public interface TMemory { public TValue getVariable(String varname); - public void putVariable(String varname, TValue value, TVariableScope scope) throws EaterException; + public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) + throws EaterException; public void removeVariable(String varname); diff --git a/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java b/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java index 9b10805a4..86629e910 100644 --- a/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java +++ b/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java @@ -41,6 +41,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; import net.sourceforge.plantuml.utils.Log; @@ -49,10 +50,12 @@ public class TMemoryGlobal extends ExecutionContexts implements TMemory { private final Map globalVariables = new HashMap(); private final TrieImpl variables = new TrieImpl(); + @Override public TValue getVariable(String varname) { return this.globalVariables.get(varname); } + @Override public void dumpDebug(String message) { Log.error("[MemGlobal] Start of memory_dump " + message); dumpMemoryInternal(); @@ -68,32 +71,39 @@ public class TMemoryGlobal extends ExecutionContexts implements TMemory { } } - public void putVariable(String varname, TValue value, TVariableScope scope) throws EaterException { + @Override + public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) + throws EaterException { Log.info("[MemGlobal] Setting " + varname); - if (scope == TVariableScope.LOCAL) { - throw EaterException.unlocated("Cannot use local variable here"); - } + if (scope == TVariableScope.LOCAL) + throw new EaterException("Cannot use local variable here", location); + this.globalVariables.put(varname, value); this.variables.add(varname); } + @Override public void removeVariable(String varname) { this.globalVariables.remove(varname); this.variables.remove(varname); } + @Override public boolean isEmpty() { return globalVariables.isEmpty(); } + @Override public Set variablesNames() { return Collections.unmodifiableSet(globalVariables.keySet()); } + @Override public Trie variablesNames3() { return variables; } + @Override public TMemory forkFromGlobal(Map input) { return new TMemoryLocal(this, input); } diff --git a/src/net/sourceforge/plantuml/tim/TMemoryLocal.java b/src/net/sourceforge/plantuml/tim/TMemoryLocal.java index 4d9b7da33..2603e1d0d 100644 --- a/src/net/sourceforge/plantuml/tim/TMemoryLocal.java +++ b/src/net/sourceforge/plantuml/tim/TMemoryLocal.java @@ -40,6 +40,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; import net.sourceforge.plantuml.utils.Log; @@ -76,19 +77,21 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { Log.error("[MemGlobal] End of memory_dump"); } - public void putVariable(String varname, TValue value, TVariableScope scope) throws EaterException { + @Override + public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) + throws EaterException { if (scope == TVariableScope.GLOBAL) { - memoryGlobal.putVariable(varname, value, scope); + memoryGlobal.putVariable(varname, value, scope, location); return; } if (scope == TVariableScope.LOCAL || overridenVariables01.containsKey(varname)) { this.overridenVariables01.put(varname, value); - if (this.overridenVariables00 != null) { + if (this.overridenVariables00 != null) this.overridenVariables00.add(varname); - } + Log.info("[MemLocal/overrriden] Setting " + varname); } else if (memoryGlobal.getVariable(varname) != null) { - memoryGlobal.putVariable(varname, value, scope); + memoryGlobal.putVariable(varname, value, scope, location); } else { this.localVariables01.put(varname, value); this.localVariables00.add(varname); @@ -96,12 +99,13 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { } } + @Override public void removeVariable(String varname) { if (overridenVariables01.containsKey(varname)) { this.overridenVariables01.remove(varname); - if (this.overridenVariables00 != null) { + if (this.overridenVariables00 != null) this.overridenVariables00.remove(varname); - } + } else if (memoryGlobal.getVariable(varname) != null) { memoryGlobal.removeVariable(varname); } else { @@ -110,25 +114,27 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { } } + @Override public TValue getVariable(String varname) { TValue result = overridenVariables01.get(varname); - if (result != null) { + if (result != null) return result; - } + result = memoryGlobal.getVariable(varname); - if (result != null) { + if (result != null) return result; - } + result = localVariables01.get(varname); return result; } + @Override public Trie variablesNames3() { if (overridenVariables00 == null) { overridenVariables00 = new TrieImpl(); - for (String name : overridenVariables01.keySet()) { + for (String name : overridenVariables01.keySet()) overridenVariables00.add(name); - } + } return new Trie() { public void add(String s) { @@ -140,12 +146,12 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { final String s2 = overridenVariables00.getLonguestMatchStartingIn(s); final String s3 = localVariables00.getLonguestMatchStartingIn(s); - if (s1.length() >= s2.length() && s1.length() >= s3.length()) { + if (s1.length() >= s2.length() && s1.length() >= s3.length()) return s1; - } - if (s2.length() >= s3.length() && s2.length() >= s1.length()) { + + if (s2.length() >= s3.length() && s2.length() >= s1.length()) return s2; - } + return s3; } }; @@ -162,14 +168,17 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { // return result; } + @Override public boolean isEmpty() { return memoryGlobal.isEmpty() && localVariables01.isEmpty() && overridenVariables01.isEmpty(); } + @Override public Set variablesNames() { throw new UnsupportedOperationException(); } + @Override public TMemory forkFromGlobal(Map input) { return new TMemoryLocal(memoryGlobal, input); } diff --git a/src/net/sourceforge/plantuml/tim/TimLoader.java b/src/net/sourceforge/plantuml/tim/TimLoader.java index de15c55f9..1dcdd9670 100644 --- a/src/net/sourceforge/plantuml/tim/TimLoader.java +++ b/src/net/sourceforge/plantuml/tim/TimLoader.java @@ -53,10 +53,10 @@ public class TimLoader { private List resultList; public TimLoader(ImportedFiles importedFiles, Defines defines, Charset charset, - DefinitionsContainer definitionsContainer) { + DefinitionsContainer definitionsContainer, StringLocated location) { this.context = new TContext(importedFiles, defines, charset, definitionsContainer); try { - defines.copyTo(global); + defines.copyTo(global, location); } catch (EaterException e) { Logme.error(e); } @@ -66,7 +66,7 @@ public class TimLoader { // CodeIteratorImpl.indentNow(list); try { context.executeLines(global, list, null, false); - } catch (EaterExceptionLocated e) { + } catch (EaterException e) { context.getResultList().add(e.getLocation().withErrorPreprocessor(e.getMessage())); changeLastLine(context.getDebug(), e.getMessage()); this.preprocessorError = true; diff --git a/src/net/sourceforge/plantuml/tim/VariableManager.java b/src/net/sourceforge/plantuml/tim/VariableManager.java index ae29bba05..c2a7aed7c 100644 --- a/src/net/sourceforge/plantuml/tim/VariableManager.java +++ b/src/net/sourceforge/plantuml/tim/VariableManager.java @@ -37,27 +37,27 @@ package net.sourceforge.plantuml.tim; import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class VariableManager { private final TMemory memory; private final TContext context; - private final LineLocation location; + private final StringLocated location; - public VariableManager(TContext context, TMemory memory, LineLocation location) { + public VariableManager(TContext context, TMemory memory, StringLocated location) { this.memory = memory; this.context = context; this.location = location; } - public int replaceVariables(String str, int i, StringBuilder result) throws EaterException, EaterExceptionLocated { + public int replaceVariables(String str, int i, StringBuilder result) throws EaterException { final String presentVariable = getVarnameAt(str, i); - if (result.toString().endsWith("##")) { + if (result.toString().endsWith("##")) result.setLength(result.length() - 2); - } + final TValue value = memory.getVariable(presentVariable); i += presentVariable.length() - 1; if (value.isJson()) { @@ -66,30 +66,30 @@ public class VariableManager { } else if (value.toJson().isNumber()) { result.append(value.toJson().toString()); } else { - JsonValue jsonValue = (JsonObject) value.toJson(); + JsonValue jsonValue = (value.toJson().isArray()) ? (JsonArray) value.toJson() + : (JsonObject) value.toJson(); i++; i = replaceJson(jsonValue, str, i, result) - 1; } } else { result.append(value.toString()); } - if (i + 2 < str.length() && str.charAt(i + 1) == '#' && str.charAt(i + 2) == '#') { + if (i + 2 < str.length() && str.charAt(i + 1) == '#' && str.charAt(i + 2) == '#') i += 2; - } + return i; } - private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) - throws EaterException, EaterExceptionLocated { + private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) throws EaterException { while (i < str.length()) { final char n = str.charAt(i); if (n == '.') { i++; final StringBuilder fieldName = new StringBuilder(); while (i < str.length()) { - if (Character.isJavaIdentifierPart(str.charAt(i)) == false) { + if (Character.isJavaIdentifierPart(str.charAt(i)) == false) break; - } + fieldName.append(str.charAt(i)); i++; } @@ -99,9 +99,9 @@ public class VariableManager { final StringBuilder inBracket = new StringBuilder(); int level = 0; while (true) { - if (str.charAt(i) == '[') { + if (str.charAt(i) == '[') level++; - } + if (str.charAt(i) == ']') { if (level == 0) break; @@ -110,29 +110,30 @@ public class VariableManager { inBracket.append(str.charAt(i)); i++; } - final String nbString = context.applyFunctionsAndVariables(memory, location, inBracket.toString()); + final String nbString = context.applyFunctionsAndVariables(memory, + new StringLocated(inBracket.toString(), location.getLocation())); if (jsonValue instanceof JsonArray) { final int nb = Integer.parseInt(nbString); jsonValue = ((JsonArray) jsonValue).get(nb); } else if (jsonValue instanceof JsonObject) { jsonValue = ((JsonObject) jsonValue).get(nbString); } else { - throw EaterException.unlocated("Major parsing error"); - } - if (jsonValue == null) { - throw EaterException.unlocated("Data parsing error"); + throw new EaterException("Major parsing error", location); } + + if (jsonValue == null) + throw new EaterException("Data parsing error", location); + i++; } else { break; } } if (jsonValue != null) { - if (jsonValue.isString()) { + if (jsonValue.isString()) result.append(jsonValue.asString()); - } else { + else result.append(jsonValue.toString()); - } } return i; } @@ -143,13 +144,13 @@ public class VariableManager { return null; } final String varname = memory.variablesNames3().getLonguestMatchStartingIn(s.substring(pos)); - if (varname.length() == 0) { + if (varname.length() == 0) return null; - } + if (pos + varname.length() == s.length() - || TLineType.isLetterOrUnderscoreOrDigit(s.charAt(pos + varname.length())) == false) { + || TLineType.isLetterOrUnderscoreOrDigit(s.charAt(pos + varname.length())) == false) return varname; - } + return null; } diff --git a/src/net/sourceforge/plantuml/tim/expression/Knowledge.java b/src/net/sourceforge/plantuml/tim/expression/Knowledge.java index 60723a615..1ca3fba7b 100644 --- a/src/net/sourceforge/plantuml/tim/expression/Knowledge.java +++ b/src/net/sourceforge/plantuml/tim/expression/Knowledge.java @@ -35,13 +35,12 @@ package net.sourceforge.plantuml.tim.expression; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; public interface Knowledge { - public TValue getVariable(String name) throws EaterException, EaterExceptionLocated; + public TValue getVariable(String name) throws EaterException; public TFunction getFunction(TFunctionSignature signature); diff --git a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java index c5b4be109..7d4aff50f 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java +++ b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java @@ -40,26 +40,20 @@ import java.util.Collections; import java.util.Deque; import java.util.List; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; -import net.sourceforge.plantuml.utils.LineLocation; public class ReversePolishInterpretor { private final TValue result; private final boolean trace = false; - public ReversePolishInterpretor(TokenStack queue, Knowledge knowledge, TMemory memory, TContext context) - throws EaterException, EaterExceptionLocated { - this(null, queue, knowledge, memory, context); - } - - public ReversePolishInterpretor(LineLocation location, TokenStack queue, Knowledge knowledge, TMemory memory, - TContext context) throws EaterException, EaterExceptionLocated { + public ReversePolishInterpretor(StringLocated location, TokenStack queue, Knowledge knowledge, TMemory memory, + TContext context) throws EaterException { final Deque stack = new ArrayDeque<>(); if (trace) @@ -78,45 +72,44 @@ public class ReversePolishInterpretor { final TValue v2 = stack.removeFirst(); final TValue v1 = stack.removeFirst(); final TokenOperator op = token.getTokenOperator(); - if (op == null) { - throw EaterException.unlocated("bad op"); - } + if (op == null) + throw new EaterException("bad op", location); + final TValue tmp = op.operate(v1, v2); stack.addFirst(tmp); } else if (token.getTokenType() == TokenType.OPEN_PAREN_FUNC) { final int nb = Integer.parseInt(token.getSurface()); final Token token2 = it.nextToken(); - if (token2.getTokenType() != TokenType.FUNCTION_NAME) { - throw EaterException.unlocated("rpn43"); - } + if (token2.getTokenType() != TokenType.FUNCTION_NAME) + throw new EaterException("rpn43", location); + if (trace) System.err.println("token2=" + token2); final TFunction function = knowledge.getFunction(new TFunctionSignature(token2.getSurface(), nb)); if (trace) System.err.println("function=" + function); - if (function == null) { - throw EaterException.unlocated("Unknown built-in function " + token2.getSurface()); - } - if (function.canCover(nb, Collections.emptySet()) == false) { - throw EaterException - .unlocated("Bad number of arguments for " + function.getSignature().getFunctionName()); - } + if (function == null) + throw new EaterException("Unknown built-in function " + token2.getSurface(), location); + + if (function.canCover(nb, Collections.emptySet()) == false) + throw new EaterException("Bad number of arguments for " + function.getSignature().getFunctionName(), location); + final List args = new ArrayList<>(); - for (int i = 0; i < nb; i++) { + for (int i = 0; i < nb; i++) args.add(0, stack.removeFirst()); - } + if (trace) System.err.println("args=" + args); - if (location == null) { - throw EaterException.unlocated("rpn44"); - } + if (location == null) + throw new EaterException("rpn44", location); + final TValue r = function.executeReturnFunction(context, memory, location, args, Collections.emptyMap()); if (trace) System.err.println("r=" + r); stack.addFirst(r); } else { - throw EaterException.unlocated("rpn41"); + throw new EaterException("rpn41", location); } } result = stack.removeFirst(); diff --git a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java index c6366f6bd..fb75931c5 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java @@ -37,8 +37,8 @@ package net.sourceforge.plantuml.tim.expression; import java.util.ArrayDeque; import java.util.Deque; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; // https://en.wikipedia.org/wiki/Shunting-yard_algorithm // https://en.cppreference.com/w/c/language/operator_precedence @@ -58,7 +58,7 @@ public class ShuntingYard { System.err.println(""); } - public ShuntingYard(TokenIterator it, Knowledge knowledge) throws EaterException, EaterExceptionLocated { + public ShuntingYard(TokenIterator it, Knowledge knowledge, StringLocated location) throws EaterException { while (it.hasMoreTokens()) { final Token token = it.nextToken(); @@ -74,7 +74,7 @@ public class ShuntingYard { final TValue variable = knowledge.getVariable(name); if (variable == null) { if (isVariableName(name) == false) - throw EaterException.unlocated("Parsing syntax error about " + name); + throw new EaterException("Parsing syntax error about " + name, location); ouputQueue.add(new Token(name, TokenType.QUOTED_STRING, null)); } else { diff --git a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java index 3bd091e4b..e94574dab 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java +++ b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java @@ -42,12 +42,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.Eater; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; -import net.sourceforge.plantuml.utils.LineLocation; public class TokenStack { @@ -95,7 +94,7 @@ public class TokenStack { eater.skipSpaces(); final char ch = eater.peekChar(); if (ch == 0) - throw EaterException.unlocated("until001"); + throw new EaterException("until001", eater.getStringLocated()); if (level == 0 && (ch == ',' || ch == ')')) return result; @@ -113,12 +112,13 @@ public class TokenStack { } } - static public void eatUntilCloseParenthesisOrComma(TokenIterator it) throws EaterException { + static public void eatUntilCloseParenthesisOrComma(TokenIterator it, StringLocated location) + throws EaterException { int level = 0; while (true) { final Token ch = it.peekToken(); if (ch == null) - throw EaterException.unlocated("until002"); + throw new EaterException("until002", location); final TokenType typech = ch.getTokenType(); if (level == 0 && (typech == TokenType.COMMA || typech == TokenType.CLOSE_PAREN_MATH) @@ -135,7 +135,7 @@ public class TokenStack { } } - private int countFunctionArg(TokenIterator it) throws EaterException { + private int countFunctionArg(TokenIterator it, StringLocated location) throws EaterException { // return 42; final TokenType type1 = it.peekToken().getTokenType(); if (type1 == TokenType.CLOSE_PAREN_MATH || type1 == TokenType.CLOSE_PAREN_FUNC) @@ -143,7 +143,7 @@ public class TokenStack { int result = 1; while (it.hasMoreTokens()) { - eatUntilCloseParenthesisOrComma(it); + eatUntilCloseParenthesisOrComma(it, location); final Token token = it.nextToken(); final TokenType type = token.getTokenType(); if (type == TokenType.CLOSE_PAREN_MATH || type == TokenType.CLOSE_PAREN_FUNC) @@ -151,13 +151,13 @@ public class TokenStack { else if (type == TokenType.COMMA) result++; else - throw EaterException.unlocated("count13"); + throw new EaterException("count13", location); } - throw EaterException.unlocated("count12"); + throw new EaterException("count12", location); } - public void guessFunctions() throws EaterException { + public void guessFunctions(StringLocated location) throws EaterException { final Deque open = new ArrayDeque<>(); final Map parens = new HashMap(); for (int i = 0; i < tokens.size(); i++) { @@ -177,7 +177,7 @@ public class TokenStack { assert tokens.get(iclose).getTokenType() == TokenType.CLOSE_PAREN_MATH; if (iopen > 0 && tokens.get(iopen - 1).getTokenType() == TokenType.PLAIN_TEXT) { tokens.set(iopen - 1, new Token(tokens.get(iopen - 1).getSurface(), TokenType.FUNCTION_NAME, null)); - final int nbArg = countFunctionArg(subTokenStack(iopen + 1).tokenIterator()); + final int nbArg = countFunctionArg(subTokenStack(iopen + 1).tokenIterator(), location); tokens.set(iopen, new Token("" + nbArg, TokenType.OPEN_PAREN_FUNC, null)); tokens.set(iclose, new Token(")", TokenType.CLOSE_PAREN_FUNC, null)); } @@ -210,13 +210,12 @@ public class TokenStack { return new InternalIterator(); } - public TValue getResult(LineLocation location, TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { - final Knowledge knowledge = context.asKnowledge(memory, location); + public TValue getResult(StringLocated location, TContext context, TMemory memory) throws EaterException { + final Knowledge knowledge = context.asKnowledge(memory, location.getLocation()); final TokenStack tmp = withoutSpace(); - tmp.guessFunctions(); + tmp.guessFunctions(location); final TokenIterator it = tmp.tokenIterator(); - final ShuntingYard shuntingYard = new ShuntingYard(it, knowledge); + final ShuntingYard shuntingYard = new ShuntingYard(it, knowledge, location); final ReversePolishInterpretor rpn = new ReversePolishInterpretor(location, shuntingYard.getQueue(), knowledge, memory, context); return rpn.getResult(); diff --git a/src/net/sourceforge/plantuml/tim/expression/TokenType.java b/src/net/sourceforge/plantuml/tim/expression/TokenType.java index a72a65bef..41c0fc7ef 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TokenType.java +++ b/src/net/sourceforge/plantuml/tim/expression/TokenType.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.tim.Eater; import net.sourceforge.plantuml.tim.EaterException; public enum TokenType { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ QUOTED_STRING, JSON_DATA, OPERATOR, OPEN_PAREN_MATH, COMMA, CLOSE_PAREN_MATH, NUMBER, PLAIN_TEXT, SPACES, FUNCTION_NAME, OPEN_PAREN_FUNC, CLOSE_PAREN_FUNC; @@ -77,7 +77,8 @@ public enum TokenType { return result; } - final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon) throws EaterException { + final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon) + throws EaterException { char ch = eater.peekChar(); if (ch == 0) return null; diff --git a/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java b/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java index 83165b8ee..51fbdfad5 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java +++ b/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java @@ -34,8 +34,8 @@ */ package net.sourceforge.plantuml.tim.iterator; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; public abstract class AbstractCodeIterator implements CodeIterator { @@ -45,16 +45,20 @@ public abstract class AbstractCodeIterator implements CodeIterator { this.source = source; } - public void next() throws EaterException, EaterExceptionLocated { + @Override + public void next() throws EaterException { source.next(); } + @Override final public CodePosition getCodePosition() { return source.getCodePosition(); } - final public void jumpToCodePosition(CodePosition newPosition) throws EaterException { - source.jumpToCodePosition(newPosition); + @Override + final public void jumpToCodePosition(CodePosition newPosition, StringLocated location) + throws EaterException { + source.jumpToCodePosition(newPosition, location); } } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java index c0b59f04d..401102893 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java @@ -36,17 +36,16 @@ package net.sourceforge.plantuml.tim.iterator; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; public interface CodeIterator { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ - public StringLocated peek() throws EaterException, EaterExceptionLocated; + public StringLocated peek() throws EaterException; - public void next() throws EaterException, EaterExceptionLocated; + public void next() throws EaterException; public CodePosition getCodePosition(); - public void jumpToCodePosition(CodePosition newPosition) throws EaterException; + public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException; } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java index e2a5fc5e9..8bd3a2b4f 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterAffectation; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; @@ -58,7 +57,8 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { this.logs = log; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + @Override + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { @@ -74,16 +74,16 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { } } - private void doAffectation(StringLocated result) throws EaterException, EaterExceptionLocated { + private void doAffectation(StringLocated result) throws EaterException { int lastLocation = -1; for (int i = 0; i < 9999; i++) try { this.executeAffectation(context, memory, result); return; } catch (ParseException e) { - if (e.getColumn() <= lastLocation) { - throw EaterException.located("Error in JSON format"); - } + if (e.getColumn() <= lastLocation) + throw new EaterException("Error in JSON format", result); + lastLocation = e.getColumn(); next(); final StringLocated forward = source.peek(); @@ -92,7 +92,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { } private void executeAffectation(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterException { new EaterAffectation(s).analyze(context, memory); } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java index 540b1e1be..2ea2ef990 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterForeach; import net.sourceforge.plantuml.tim.ExecutionContextForeach; import net.sourceforge.plantuml.tim.TContext; @@ -61,13 +60,12 @@ public class CodeIteratorForeach extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { int level = 0; while (true) { final StringLocated result = source.peek(); - if (result == null) { + if (result == null) return null; - } final ExecutionContextForeach foreach = memory.peekForeach(); if (foreach != null && foreach.isSkipMe()) { @@ -91,15 +89,15 @@ public class CodeIteratorForeach extends AbstractCodeIterator { continue; } else if (result.getType() == TLineType.ENDFOREACH) { logs.add(result); - if (foreach == null) { - throw EaterException.located("No foreach related to this endforeach"); - } + if (foreach == null) + throw new EaterException("No foreach related to this endforeach", result); + foreach.inc(); if (foreach.isSkipMe()) { memory.pollForeach(); } else { setLoopVariable(memory, foreach, result); - source.jumpToCodePosition(foreach.getStartForeach()); + source.jumpToCodePosition(foreach.getStartForeach(), result); } next(); continue; @@ -109,23 +107,23 @@ public class CodeIteratorForeach extends AbstractCodeIterator { } } - private void executeForeach(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeForeach(TMemory memory, StringLocated s) throws EaterException { final EaterForeach condition = new EaterForeach(s); condition.analyze(context, memory); final ExecutionContextForeach foreach = ExecutionContextForeach.fromValue(condition.getVarname(), condition.getJsonArray(), source.getCodePosition()); - if (condition.isSkip()) { + if (condition.isSkip()) foreach.skipMeNow(); - } else { + else setLoopVariable(memory, foreach, s); - } + memory.addForeach(foreach); } private void setLoopVariable(TMemory memory, ExecutionContextForeach foreach, StringLocated position) throws EaterException { final JsonValue first = foreach.getJsonArray().get(foreach.currentIndex()); - memory.putVariable(foreach.getVarname(), TValue.fromJson(first), TVariableScope.GLOBAL); + memory.putVariable(foreach.getVarname(), TValue.fromJson(first), TVariableScope.GLOBAL, position); } } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java index 8ee1d08a1..831726ecc 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterElseIf; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterIf; import net.sourceforge.plantuml.tim.EaterIfdef; import net.sourceforge.plantuml.tim.EaterIfndef; @@ -61,7 +60,7 @@ public class CodeIteratorIf extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { @@ -107,29 +106,26 @@ public class CodeIteratorIf extends AbstractCodeIterator { } } - private void executeIf(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeIf(TContext context, TMemory memory, StringLocated s) throws EaterException { final EaterIf condition = new EaterIf(s); condition.analyze(context, memory); final boolean isTrue = condition.isTrue(); memory.addIf(ExecutionContextIf.fromValue(isTrue)); } - private void executeElseIf(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeElseIf(TContext context, TMemory memory, StringLocated s) throws EaterException { final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf(); - if (poll == null) { - throw EaterException.located("No if related to this else"); - } + if (poll == null) + throw new EaterException("No if related to this else", s); poll.enteringElseIf(); if (poll.hasBeenBurn() == false) { final EaterElseIf condition = new EaterElseIf(s); condition.analyze(context, memory); final boolean isTrue = condition.isTrue(); - if (isTrue) { + if (isTrue) poll.nowInSomeElseIf(); - } + } } @@ -149,17 +145,17 @@ public class CodeIteratorIf extends AbstractCodeIterator { private void executeElse(TContext context, TMemory memory, StringLocated s) throws EaterException { final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf(); - if (poll == null) { - throw EaterException.located("No if related to this else"); - } + if (poll == null) + throw new EaterException("No if related to this else", s); + poll.nowInElse(); } private void executeEndif(TContext context, TMemory memory, StringLocated s) throws EaterException { final ExecutionContextIf poll = (ExecutionContextIf) memory.pollIf(); - if (poll == null) { - throw EaterException.located("No if related to this endif"); - } + if (poll == null) + throw new EaterException("No if related to this endif", s); + } } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java index e00986810..07dead5aa 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java @@ -62,34 +62,38 @@ public class CodeIteratorImpl implements CodeIterator { this.list = list; } + @Override public StringLocated peek() { - if (current == list.size()) { + if (current == list.size()) return null; - } - if (current > list.size()) { + + if (current > list.size()) throw new IllegalStateException(); - } + return list.get(current); } + @Override public void next() { - if (current >= list.size()) { + if (current >= list.size()) throw new IllegalStateException(); - } + assert current < list.size(); current++; assert current <= list.size(); } + @Override public CodePosition getCodePosition() { return new Position(current); } - public void jumpToCodePosition(CodePosition newPosition) throws EaterException { + @Override + public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException { this.countJump++; - if (this.countJump > 999) { - throw EaterException.unlocated("Infinite loop?"); - } + if (this.countJump > 999) + throw new EaterException("Infinite loop?", location); + final Position pos = (Position) newPosition; this.current = pos.pos; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java index f7baab3e8..501bd9b4e 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.tim.iterator; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorInnerComment extends AbstractCodeIterator { @@ -44,7 +43,7 @@ public class CodeIteratorInnerComment extends AbstractCodeIterator { super(source); } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { final StringLocated result = source.peek(); if (result == null) { return null; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java index 51670f20e..fb4a99f75 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; @@ -61,7 +60,7 @@ public class CodeIteratorLegacyDefine extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java index 3f2cc2e0b..656cf882d 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorLongComment extends AbstractCodeIterator { @@ -50,7 +49,7 @@ public class CodeIteratorLongComment extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { if (source.peek() == null) { return null; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java index d03dfcc00..ba88da272 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionType; @@ -62,7 +61,7 @@ public class CodeIteratorProcedure extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java index 8ff1feea5..b3c628fa1 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionType; @@ -62,7 +61,7 @@ public class CodeIteratorReturnFunction extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { @@ -74,9 +73,7 @@ public class CodeIteratorReturnFunction extends AbstractCodeIterator { logs.add(result); if (result.getType() == TLineType.END_FUNCTION) { if (functionsSet.pendingFunction().doesContainReturn() == false) { - throw EaterExceptionLocated.located( - "This function does not have any !return directive. Declare it as a procedure instead ?", - result); + throw new EaterException("This function does not have any !return directive. Declare it as a procedure instead ?", result); } functionsSet.executeEndfunction(); } else { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java index b70c45584..0b36e2374 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorShortComment extends AbstractCodeIterator { @@ -50,7 +49,7 @@ public class CodeIteratorShortComment extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java index 6a7aaa876..248f200f8 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.preproc.Sub; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterStartsub; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; @@ -66,14 +65,14 @@ public class CodeIteratorSub extends AbstractCodeIterator { return Collections.unmodifiableMap(subs); } - public StringLocated peek() throws EaterException, EaterExceptionLocated { - if (readingInProgress != null) { + public StringLocated peek() throws EaterException { + if (readingInProgress != null) return readingInProgress.peek(); - } + StringLocated result = source.peek(); - if (result == null) { + if (result == null) return null; - } + if (result.getType() == TLineType.STARTSUB) { final EaterStartsub eater = new EaterStartsub(result.getTrimmed()); eater.analyze(context, memory); @@ -83,7 +82,7 @@ public class CodeIteratorSub extends AbstractCodeIterator { StringLocated s = null; while ((s = source.peek()) != null) { if (s.getType() == TLineType.STARTSUB) { - throw EaterException.located("Cannot nest sub"); + throw new EaterException("Cannot nest sub", result); } else if (s.getType() == TLineType.ENDSUB) { source.next(); readingInProgress = new CodeIteratorImpl(created.lines()); @@ -94,22 +93,22 @@ public class CodeIteratorSub extends AbstractCodeIterator { } } } - if (readingInProgress != null) { + if (readingInProgress != null) return readingInProgress.peek(); - } + return result; } @Override - public void next() throws EaterException, EaterExceptionLocated { + public void next() throws EaterException { if (readingInProgress == null) { source.next(); return; } readingInProgress.next(); - if (readingInProgress.peek() == null) { + if (readingInProgress.peek() == null) readingInProgress = null; - } + } } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java index 037c33200..68679b1d3 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterWhile; import net.sourceforge.plantuml.tim.ExecutionContextWhile; import net.sourceforge.plantuml.tim.TContext; @@ -60,13 +59,12 @@ public class CodeIteratorWhile extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterException { int level = 0; while (true) { final StringLocated result = source.peek(); - if (result == null) { + if (result == null) return null; - } final ExecutionContextWhile currentWhile = memory.peekWhile(); if (currentWhile != null && currentWhile.isSkipMe()) { @@ -90,15 +88,15 @@ public class CodeIteratorWhile extends AbstractCodeIterator { continue; } else if (result.getType() == TLineType.ENDWHILE) { logs.add(result); - if (currentWhile == null) { - throw EaterException.located("No while related to this endwhile"); - } - final TValue value = currentWhile.conditionValue(result.getLocation(), context, memory); - if (value.toBoolean()) { - source.jumpToCodePosition(currentWhile.getStartWhile()); - } else { + if (currentWhile == null) + throw new EaterException("No while related to this endwhile", result); + + final TValue value = currentWhile.conditionValue(result, context, memory); + if (value.toBoolean()) + source.jumpToCodePosition(currentWhile.getStartWhile(), result); + else memory.pollWhile(); - } + next(); continue; } @@ -107,16 +105,16 @@ public class CodeIteratorWhile extends AbstractCodeIterator { } } - private void executeWhile(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeWhile(TMemory memory, StringLocated s) throws EaterException { final EaterWhile condition = new EaterWhile(s); condition.analyze(context, memory); final TokenStack whileExpression = condition.getWhileExpression(); final ExecutionContextWhile theWhile = ExecutionContextWhile.fromValue(whileExpression, source.getCodePosition()); - final TValue value = theWhile.conditionValue(s.getLocation(), context, memory); - if (value.toBoolean() == false) { + final TValue value = theWhile.conditionValue(s, context, memory); + if (value.toBoolean() == false) theWhile.skipMe(); - } + memory.addWhile(theWhile); } diff --git a/src/net/sourceforge/plantuml/tim/package-info.java b/src/net/sourceforge/plantuml/tim/package-info.java index d185cc4bd..7aa0e198b 100644 --- a/src/net/sourceforge/plantuml/tim/package-info.java +++ b/src/net/sourceforge/plantuml/tim/package-info.java @@ -1,7 +1,7 @@ /** - * Provides classes used to manage - * - * Preprocessing of PlantUML input. + * Provides classes used to manage + * Preprocessing + * of PlantUML input. * * @see net.sourceforge.plantuml.text.TLineType * @see net.sourceforge.plantuml.preproc diff --git a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java index c06523e00..29b116da7 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class AlwaysFalse extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class AlwaysFalse extends SimpleReturnFunction { return new TFunctionSignature("%false", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { return TValue.fromBoolean(false); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java index 90ed2c7c1..e59c5e0f6 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class AlwaysTrue extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class AlwaysTrue extends SimpleReturnFunction { return new TFunctionSignature("%true", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { return TValue.fromBoolean(true); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java index 3282983ca..36bbdf7c1 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java @@ -38,14 +38,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class CallUserFunction extends SimpleReturnFunction { @@ -53,19 +52,21 @@ public class CallUserFunction extends SimpleReturnFunction { return new TFunctionSignature("%call_user_func", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg > 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String fname = values.get(0).toString(); final List args = values.subList(1, values.size()); final TFunctionSignature signature = new TFunctionSignature(fname, args.size()); final TFunction func = context.getFunctionSmart(signature); - if (func == null) { - throw EaterException.unlocated("Cannot find void function " + fname); - } + if (func == null) + throw new EaterException("Cannot find void function " + fname, location); + return func.executeReturnFunction(context, memory, location, args, named); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java index 622230500..fb55e335a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Chr extends SimpleReturnFunction { @@ -52,15 +51,17 @@ public class Chr extends SimpleReturnFunction { return new TFunctionSignature("%chr", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { try { - final char value = (char) values.get(0).toInt(); - return TValue.fromString("" + value); + final String value = String.valueOf(Character.toChars(values.get(0).toInt())); + return TValue.fromString(value); } catch (Throwable t) { return TValue.fromString("\0"); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java index bb5d05a7b..924f24be1 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Darken extends SimpleReturnFunction { @@ -56,12 +55,14 @@ public class Darken extends SimpleReturnFunction { return new TFunctionSignature("%darken", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); try { @@ -69,7 +70,7 @@ public class Darken extends SimpleReturnFunction { color = color.darken(ratio); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java index 0140a6385..6f8efa2ea 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java @@ -40,13 +40,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class DateFunction extends SimpleReturnFunction { @@ -54,12 +53,14 @@ public class DateFunction extends SimpleReturnFunction { return new TFunctionSignature("%date", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0 || nbArg == 1 || nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { if (values.size() == 0) return TValue.fromString(new Date().toString()); @@ -69,10 +70,11 @@ public class DateFunction extends SimpleReturnFunction { now = 1000L * values.get(1).toInt(); else now = System.currentTimeMillis(); + try { return TValue.fromString(new SimpleDateFormat(format).format(now)); } catch (Exception e) { - throw EaterException.unlocated("Bad date pattern"); + throw new EaterException("Bad date pattern", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java index 1c3172996..9bbc29e4c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Dec2hex extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Dec2hex extends SimpleReturnFunction { return new TFunctionSignature("%dec2hex", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { try { return TValue.fromString("" + Integer.toHexString(values.get(0).toInt())); } catch (Throwable t) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java index 54fabb43d..ef08879cc 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java @@ -39,13 +39,12 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.preproc.Defines; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Dirpath extends SimpleReturnFunction { @@ -59,15 +58,17 @@ public class Dirpath extends SimpleReturnFunction { return new TFunctionSignature("%dirpath", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { - if (value == null) { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { + if (value == null) return TValue.fromString(""); - } + return TValue.fromString(value); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java index 7175e2ffc..311404c17 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java @@ -38,14 +38,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.StringEater; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Eval extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class Eval extends SimpleReturnFunction { return new TFunctionSignature("%eval", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String exp = values.get(0).toString(); final StringEater eater = new StringEater(exp); final TValue value = eater.eatExpression(context, memory); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java index 088958f9e..0f789f30c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Feature extends SimpleReturnFunction { @@ -52,19 +51,21 @@ public class Feature extends SimpleReturnFunction { return new TFunctionSignature("%feature", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String arg = values.get(0).toString(); - if ("style".equalsIgnoreCase(arg)) { + if ("style".equalsIgnoreCase(arg)) return TValue.fromInt(1); - } - if ("theme".equalsIgnoreCase(arg)) { + + if ("theme".equalsIgnoreCase(arg)) return TValue.fromInt(1); - } + return TValue.fromInt(0); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java index 47355c4dd..cee70de58 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java @@ -39,13 +39,12 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.security.SFile; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class FileExists extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class FileExists extends SimpleReturnFunction { return new TFunctionSignature("%file_exists", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { // ::comment when __CORE__ final String path = values.get(0).toString(); return TValue.fromBoolean(new SFile(path).exists()); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java index 02e0f2d56..9a4223d45 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java @@ -39,13 +39,12 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.preproc.Defines; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Filename extends SimpleReturnFunction { @@ -59,12 +58,14 @@ public class Filename extends SimpleReturnFunction { return new TFunctionSignature("%filename", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { if (value == null) { return TValue.fromString(""); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java b/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java index c7ccef030..d2bd9d1b2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java @@ -38,27 +38,28 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class FunctionExists extends SimpleReturnFunction { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ public TFunctionSignature getSignature() { return new TFunctionSignature("%function_exists", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String name = values.get(0).toString(); return TValue.fromBoolean(context.doesFunctionExist(name)); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java b/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java new file mode 100644 index 000000000..d1b0bff9d --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java @@ -0,0 +1,105 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.tim.stdlib; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.json.Json; +import net.sourceforge.plantuml.json.JsonArray; +import net.sourceforge.plantuml.json.JsonObject; +import net.sourceforge.plantuml.log.Logme; +import net.sourceforge.plantuml.preproc.Stdlib; +import net.sourceforge.plantuml.text.StringLocated; +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class GetAllStdlib extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%get_all_stdlib", 1); + } + + @Override + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 0 || nbArg == 1; + } + + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { + + switch (values.size()) { + case 0: + final JsonArray result = new JsonArray(); + try { + for (String name : Stdlib.getAll()) { + result.add(name); + } + return TValue.fromJson(result); + } catch (IOException e) { + Logme.error(e); + return TValue.fromJson(result); + } + + case 1: + final JsonObject res = new JsonObject(); + try { + // Inspired by Stdlib.addInfoVersion + for (String name : Stdlib.getAll()) { + final Stdlib folder = Stdlib.retrieve(name); + final JsonObject object = Json.object() // + .add("name", name) // + .add("version", folder.getVersion()) // + .add("source", folder.getSource()); + res.add(name, object); + } + return TValue.fromJson(res); + } catch (IOException e) { + Logme.error(e); + return TValue.fromJson(res); + } + + default: + assert false; // Should not append because of canCover() + throw new EaterException("Error on get_all_stdlib: Too many arguments", location); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java new file mode 100644 index 000000000..2512d26f1 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java @@ -0,0 +1,77 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.tim.stdlib; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.json.JsonArray; +import net.sourceforge.plantuml.log.Logme; +import net.sourceforge.plantuml.text.StringLocated; +import net.sourceforge.plantuml.theme.ThemeUtils; +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class GetAllTheme extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%get_all_theme", 0); + } + + @Override + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 0; + } + + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { + final JsonArray result = new JsonArray(); + try { + for (String theme : ThemeUtils.getAllThemeNames()) { + result.add(theme); + } + return TValue.fromJson(result); + } catch (IOException e) { + Logme.error(e); + return TValue.fromJson(result); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java index 77824aabc..6e7df046c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetJsonKey extends SimpleReturnFunction { @@ -55,15 +54,18 @@ public class GetJsonKey extends SimpleReturnFunction { return new TFunctionSignature("%get_json_keys", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final TValue data = values.get(0); if (data.isJson() == false) - throw EaterException.unlocated("Not JSON data"); + throw new EaterException("Not JSON data", location); + final JsonValue json = data.toJson(); if (json.isObject()) { final JsonObject object = (JsonObject) json; @@ -76,14 +78,16 @@ public class GetJsonKey extends SimpleReturnFunction { final JsonArray array = (JsonArray) json; final JsonArray result = new JsonArray(); for (JsonValue tmp : array) { - final JsonObject object = (JsonObject) tmp; - for (String key : object.names()) - result.add(key); + if (tmp.isObject()) { + final JsonObject object = (JsonObject) tmp; + for (String key : object.names()) + result.add(key); + } } return TValue.fromJson(result); } - throw EaterException.unlocated("Bad JSON type"); + throw new EaterException("Bad JSON type", location); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java index e44b7ce55..0c09b9e84 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java @@ -39,13 +39,12 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetJsonType extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class GetJsonType extends SimpleReturnFunction { return new TFunctionSignature("%get_json_type", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final TValue data = values.get(0); if (data.isString()) return TValue.fromString("string"); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java index ac9261793..b99e3478a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetVariableValue extends SimpleReturnFunction { @@ -52,17 +51,19 @@ public class GetVariableValue extends SimpleReturnFunction { return new TFunctionSignature("%get_variable_value", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String name = values.get(0).toString(); final TValue variable = memory.getVariable(name); - if (variable == null) { + if (variable == null) return TValue.fromString(""); - } + return variable; } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java index 960fd1fb2..df0218cea 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.version.Version; public class GetVersion extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class GetVersion extends SimpleReturnFunction { return new TFunctionSignature("%version", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { return TValue.fromString(Version.versionString()); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java b/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java index 6e947d050..4c93f23f5 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java @@ -39,13 +39,12 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.security.SecurityUtils; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Getenv extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class Getenv extends SimpleReturnFunction { return new TFunctionSignature("%getenv", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { // ::comment when __CORE__ final String value = getenv(values.get(0).toString()); if (value == null) @@ -80,7 +81,7 @@ public class Getenv extends SimpleReturnFunction { // also stop here in other deployments. if (SecurityUtils.getSecurityProfile().canWeReadThisEnvironmentVariable(name) == false) return null; - + final String env = System.getProperty(name); if (env != null) return env; diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java index 622023df2..964a6cfb0 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Hex2dec extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Hex2dec extends SimpleReturnFunction { return new TFunctionSignature("%hex2dec", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { try { return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16)); } catch (Throwable t) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java index fae231c88..2113908d2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColors; import net.sourceforge.plantuml.klimt.color.HSLColor; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class HslColor extends SimpleReturnFunction { @@ -55,12 +54,14 @@ public class HslColor extends SimpleReturnFunction { return new TFunctionSignature("%hsl_color", 3); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 3 || nbArg == 4; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final int h = values.get(0).toInt(); final int s = values.get(1).toInt(); final int l = values.get(2).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java index b9540e5dd..bda216b4c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.Log; public class IntVal extends SimpleReturnFunction { @@ -53,12 +52,14 @@ public class IntVal extends SimpleReturnFunction { return new TFunctionSignature("%intval", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String s = values.get(0).toString(); try { return TValue.fromInt(Integer.parseInt(s)); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java index c9079986a..4eab28dde 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java @@ -38,15 +38,14 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TFunctionType; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class InvokeProcedure implements TFunction { @@ -54,6 +53,7 @@ public class InvokeProcedure implements TFunction { return new TFunctionSignature("%invoke_procedure", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg > 0; } @@ -62,24 +62,21 @@ public class InvokeProcedure implements TFunction { return TFunctionType.PROCEDURE; } - public void executeProcedure(TContext context, TMemory memory, LineLocation location, String s) - throws EaterException, EaterExceptionLocated { - throw new UnsupportedOperationException(); - } - - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated { + @Override + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException { final String fname = args.get(0).toString(); final List sublist = args.subList(1, args.size()); final TFunctionSignature signature = new TFunctionSignature(fname, sublist.size()); final TFunction func = context.getFunctionSmart(signature); - if (func == null) { - throw EaterException.located("Cannot find void function " + fname); - } - func.executeProcedureInternal(context, memory, sublist, named); + if (func == null) + throw new EaterException("Cannot find void function " + fname, location); + + func.executeProcedureInternal(context, memory, location, sublist, named); } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java index 23a4ccc67..cf9449122 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class IsDark extends SimpleReturnFunction { @@ -56,18 +55,20 @@ public class IsDark extends SimpleReturnFunction { return new TFunctionSignature("%is_dark", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); try { final HColor color = HColorSet.instance().getColorLEGACY(colorString); return TValue.fromBoolean(color.isDark()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java index b75e781ef..b717e419a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class IsLight extends SimpleReturnFunction { @@ -56,18 +55,20 @@ public class IsLight extends SimpleReturnFunction { return new TFunctionSignature("%is_light", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); try { final HColor color = HColorSet.instance().getColorLEGACY(colorString); return TValue.fromBoolean(!color.isDark()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java index 64be7d60f..35238cc5b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java @@ -40,13 +40,12 @@ import java.util.Set; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class JsonKeyExists extends SimpleReturnFunction { @@ -54,12 +53,14 @@ public class JsonKeyExists extends SimpleReturnFunction { return new TFunctionSignature("%json_key_exists", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final TValue arg0 = values.get(0); if (arg0.isJson() == false) return TValue.fromBoolean(false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java index 8519054c3..e309859b3 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Lighten extends SimpleReturnFunction { @@ -56,12 +55,14 @@ public class Lighten extends SimpleReturnFunction { return new TFunctionSignature("%lighten", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); try { @@ -69,7 +70,7 @@ public class Lighten extends SimpleReturnFunction { color = color.lighten(ratio); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java index 19dffd462..5f8e30b00 100755 --- a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java @@ -49,13 +49,12 @@ import net.sourceforge.plantuml.json.ParseException; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SURL; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; /** * Loads JSON data from file or URL source. @@ -102,12 +101,14 @@ public class LoadJson extends SimpleReturnFunction { return new TFunctionSignature("%load_json", 3); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1 || nbArg == 2 || nbArg == 3; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String path = values.get(0).toString(); try { String data = loadStringData(path, getCharset(values)); @@ -118,10 +119,10 @@ public class LoadJson extends SimpleReturnFunction { return TValue.fromJson(jsonValue); } catch (ParseException pe) { Logme.error(pe); - throw EaterException.unlocated("JSON parse issue in source " + path + " on location " + pe.getLocation()); + throw new EaterException("JSON parse issue in source " + path + " on location " + pe.getLocation(), location); } catch (UnsupportedEncodingException e) { Logme.error(e); - throw EaterException.unlocated("JSON encoding issue in source " + path + ": " + e.getMessage()); + throw new EaterException("JSON encoding issue in source " + path + ": " + e.getMessage(), location); } } @@ -160,7 +161,8 @@ public class LoadJson extends SimpleReturnFunction { * @return the decoded String from the data source * @throws EaterException if something went wrong on reading data */ - private String loadStringData(String path, String charset) throws EaterException, UnsupportedEncodingException { + private String loadStringData(String path, String charset) + throws EaterException, UnsupportedEncodingException { byte[] byteData = null; if (path.startsWith("http://") || path.startsWith("https://")) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java index b674b4b46..ede165c22 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalAnd extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalAnd extends SimpleReturnFunction { return new TFunctionSignature("%and", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { for (TValue v : values) if (v.toBoolean() == false) return TValue.fromBoolean(false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java index c4f5ea8e0..0740118e5 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNand extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalNand extends SimpleReturnFunction { return new TFunctionSignature("%nand", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { for (TValue v : values) if (v.toBoolean() == false) return TValue.fromBoolean(!false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java index de7a99644..d0fcb1e14 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNor extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalNor extends SimpleReturnFunction { return new TFunctionSignature("%nor", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { for (TValue v : values) if (v.toBoolean() == true) return TValue.fromBoolean(!true); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java index b2385ee38..071620862 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNot extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalNot extends SimpleReturnFunction { return new TFunctionSignature("%not", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final boolean arg = values.get(0).toBoolean(); return TValue.fromBoolean(!arg); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java index 61f8ab06a..8403263c7 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNxor extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalNxor extends SimpleReturnFunction { return new TFunctionSignature("%nxor", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { int cpt = 0; for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java index 3460a3683..de58b384a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalOr extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalOr extends SimpleReturnFunction { return new TFunctionSignature("%or", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { for (TValue v : values) if (v.toBoolean() == true) return TValue.fromBoolean(true); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java index 1736b6cde..3a5e24eab 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalXor extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class LogicalXor extends SimpleReturnFunction { return new TFunctionSignature("%xor", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg >= 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { int cpt = 0; for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java index 463c272d8..721a521b8 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Lower extends SimpleReturnFunction { @@ -50,11 +50,13 @@ public class Lower extends SimpleReturnFunction { return new TFunctionSignature("%lower", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(values.get(0).toString().toLowerCase()); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Newline.java b/src/net/sourceforge/plantuml/tim/stdlib/Newline.java index 8b3cc6659..d3b4b8768 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Newline.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Newline.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Newline extends SimpleReturnFunction { @@ -50,11 +50,13 @@ public class Newline extends SimpleReturnFunction { return new TFunctionSignature("%newline", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString("\n"); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Now.java b/src/net/sourceforge/plantuml/tim/stdlib/Now.java index 866e90f0e..de2c7bb71 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Now.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Now.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Now extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Now extends SimpleReturnFunction { return new TFunctionSignature("%now", 0); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final long now = System.currentTimeMillis() / 1000L; return TValue.fromInt((int) now); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Ord.java b/src/net/sourceforge/plantuml/tim/stdlib/Ord.java index 6e5262189..9b1c87d5d 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Ord.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Ord.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Ord extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Ord extends SimpleReturnFunction { return new TFunctionSignature("%ord", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { try { final int codePoint = values.get(0).toString().codePointAt(0); return TValue.fromInt(codePoint); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java new file mode 100644 index 000000000..1b4de5ac9 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java @@ -0,0 +1,83 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.tim.stdlib; + +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.sourceforge.plantuml.text.StringLocated; +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class RandomFunction extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%random", 2); + } + + @Override + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 0 || nbArg == 1 || nbArg == 2; + } + + private final Random random = new Random(); + + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { + switch (values.size()) { + case 0: + return TValue.fromInt(random.nextInt(2)); + + case 1: + final Integer mx = values.get(0).toInt(); + return TValue.fromInt(random.nextInt(mx)); + + case 2: + final Integer min = values.get(0).toInt(); + final Integer max = values.get(1).toInt(); + return TValue.fromInt(random.nextInt(max - min) + min); + + default: + assert false; // Should not append because of canCover() + throw new EaterException("Error on Random: Too many argument", location); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java index 94a98ec81..a9b51e5f3 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java @@ -39,14 +39,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class RetrieveProcedure extends SimpleReturnFunction { @@ -54,18 +53,20 @@ public class RetrieveProcedure extends SimpleReturnFunction { return new TFunctionSignature("%retrieve_procedure", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg > 0; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String fname = values.get(0).toString(); final List args = values.subList(1, values.size()); final TFunctionSignature signature = new TFunctionSignature(fname, args.size()); final TFunction func = context.getFunctionSmart(signature); final int n1 = context.getResultList().size(); - func.executeProcedureInternal(context, memory, args, Collections.emptyMap()); + func.executeProcedureInternal(context, memory, location, args, Collections.emptyMap()); final String extracted = context.extractFromResultList(n1); return TValue.fromString(extracted); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java index 3a5d5e718..a46c9695f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class ReverseColor extends SimpleReturnFunction { @@ -55,19 +54,21 @@ public class ReverseColor extends SimpleReturnFunction { return new TFunctionSignature("%reverse_color", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); try { HColor color = HColorSet.instance().getColorLEGACY(colorString); color = color.reverse(); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java index d9599aecc..8fd8422e3 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class ReverseHsluvColor extends SimpleReturnFunction { @@ -55,19 +54,21 @@ public class ReverseHsluvColor extends SimpleReturnFunction { return new TFunctionSignature("%reverse_hsluv_color", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String colorString = values.get(0).toString(); try { HColor color = HColorSet.instance().getColorLEGACY(colorString); color = color.reverseHsluv(); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color"); + throw new EaterException("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java index 31897f608..631037c45 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java @@ -38,14 +38,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.TVariableScope; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class SetVariableValue extends SimpleReturnFunction { @@ -53,18 +52,20 @@ public class SetVariableValue extends SimpleReturnFunction { return new TFunctionSignature("%set_variable_value", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { // if (memory instanceof TMemoryLocal) { // memory = ((TMemoryLocal) memory).getGlobalForInternalUseOnly(); // } final String name = values.get(0).toString(); final TValue value = values.get(1); - memory.putVariable(name, value, TVariableScope.GLOBAL); + memory.putVariable(name, value, TVariableScope.GLOBAL, location); return TValue.fromString(""); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java index 146077597..c649a86a4 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java @@ -37,13 +37,13 @@ package net.sourceforge.plantuml.tim.stdlib; import java.util.List; import java.util.Map; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionType; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public abstract class SimpleReturnFunction implements TFunction { @@ -51,13 +51,9 @@ public abstract class SimpleReturnFunction implements TFunction { return TFunctionType.RETURN_FUNCTION; } - final public void executeProcedure(TContext context, TMemory memory, LineLocation location, String s) - throws EaterException { - throw new UnsupportedOperationException(); - } - - final public void executeProcedureInternal(TContext context, TMemory memory, List args, - Map named) throws EaterException { + @Override + final public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, + List args, Map named) throws EaterException { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Size.java b/src/net/sourceforge/plantuml/tim/stdlib/Size.java index ecc0891bf..b2e176504 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Size.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Size.java @@ -41,13 +41,12 @@ import java.util.Set; import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Size extends SimpleReturnFunction { @@ -55,12 +54,14 @@ public class Size extends SimpleReturnFunction { return new TFunctionSignature("%size", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final TValue value = values.get(0); if (value.isNumber()) return TValue.fromInt(0); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java index 2158332ee..536ee9ba0 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java @@ -40,13 +40,12 @@ import java.util.Set; import java.util.StringTokenizer; import net.sourceforge.plantuml.json.JsonArray; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class SplitStr extends SimpleReturnFunction { @@ -54,12 +53,14 @@ public class SplitStr extends SimpleReturnFunction { return new TFunctionSignature("%splitstr", 3); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final JsonArray result = new JsonArray(); final String str = values.get(0).toString(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java index ef87d8cb9..de63add20 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class StringFunction extends SimpleReturnFunction { @@ -50,11 +50,13 @@ public class StringFunction extends SimpleReturnFunction { return new TFunctionSignature("%string", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(values.get(0).toString()); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java b/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java index 432c6a42d..2a91bd05d 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Strlen extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Strlen extends SimpleReturnFunction { return new TFunctionSignature("%strlen", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { return TValue.fromInt(values.get(0).toString().length()); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java b/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java index 7b7b58f1b..2f7c32c7c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Strpos extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Strpos extends SimpleReturnFunction { return new TFunctionSignature("%strpos", 2); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String full = values.get(0).toString(); final String searched = values.get(1).toString(); return TValue.fromInt(full.indexOf(searched)); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java index 2a94fcab6..76e7751f9 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Substr extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class Substr extends SimpleReturnFunction { return new TFunctionSignature("%substr", 3); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 2 || nbArg == 3; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String full = values.get(0).toString(); final int pos = values.get(1).toInt(); if (pos >= full.length()) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java index f3901fb8a..71ebe587e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Upper extends SimpleReturnFunction { @@ -50,11 +50,13 @@ public class Upper extends SimpleReturnFunction { return new TFunctionSignature("%upper", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(values.get(0).toString().toUpperCase()); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java index f19110114..db3c39f1b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java @@ -38,13 +38,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class VariableExists extends SimpleReturnFunction { @@ -52,12 +51,14 @@ public class VariableExists extends SimpleReturnFunction { return new TFunctionSignature("%variable_exists", 1); } + @Override public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 1; } - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, - Map named) throws EaterException, EaterExceptionLocated { + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) throws EaterException { final String name = values.get(0).toString(); return TValue.fromBoolean(memory.getVariable(name) != null); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/Player.java b/src/net/sourceforge/plantuml/timingdiagram/Player.java index 7216c830d..3b271bdc3 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Player.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Player.java @@ -62,8 +62,11 @@ public abstract class Player implements TimeProjected { private final Display title; protected int suggestedHeight; protected final Stereotype stereotype; + private final HColor generalBackgroundColor; - public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) { + public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype, + HColor generalBackgroundColor) { + this.generalBackgroundColor = generalBackgroundColor; this.stereotype = stereotype; this.skinParam = skinParam; this.compact = compact; @@ -75,6 +78,10 @@ public abstract class Player implements TimeProjected { return compact; } + public HColor getGeneralBackgroundColor() { + return generalBackgroundColor; + } + protected abstract StyleSignature getStyleSignature(); final protected Style getStyle() { diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java index 88d37427a..874002e44 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerAnalog.java @@ -76,7 +76,7 @@ public class PlayerAnalog extends Player { private Integer ticksEvery; public PlayerAnalog(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) { - super(code, skinParam, ruler, compact, stereotype); + super(code, skinParam, ruler, compact, stereotype, null); this.suggestedHeight = 100; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java index c34f5d486..feb26832c 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java @@ -76,7 +76,7 @@ public class PlayerBinary extends Player { private final List notes = new ArrayList<>(); public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) { - super(code, skinParam, ruler, compact, stereotype); + super(code, skinParam, ruler, compact, stereotype, null); this.suggestedHeight = 30; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java index ac5a31880..134e67620 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java @@ -65,7 +65,7 @@ public class PlayerClock extends Player { public PlayerClock(String title, ISkinParam skinParam, TimingRuler ruler, int period, int pulse, int offset, boolean compact) { - super(title, skinParam, ruler, compact, null); + super(title, skinParam, ruler, compact, null, null); this.displayTitle = title.length() > 0; this.period = period; this.pulse = pulse; diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerRobustConcise.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerRobustConcise.java index 194e9dfe3..3f97badd1 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerRobustConcise.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerRobustConcise.java @@ -43,6 +43,7 @@ import java.util.TreeSet; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.Colors; +import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.font.StringBounder; @@ -50,6 +51,7 @@ import net.sourceforge.plantuml.klimt.geom.XDimension2D; import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.UDrawable; +import net.sourceforge.plantuml.klimt.shape.URectangle; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.ISkinParam; @@ -77,8 +79,8 @@ public final class PlayerRobustConcise extends Player { private Colors initialColors; public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler, boolean compact, - Stereotype stereotype) { - super(full, skinParam, ruler, compact, stereotype); + Stereotype stereotype, HColor generalBackgroundColor) { + super(full, skinParam, ruler, compact, stereotype, generalBackgroundColor); this.type = type; this.suggestedHeight = 0; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java index 0847489b3..4edc5cd04 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.Colors; import net.sourceforge.plantuml.klimt.color.HColor; +import net.sourceforge.plantuml.klimt.color.HColors; import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.font.StringBounder; @@ -62,6 +63,7 @@ import net.sourceforge.plantuml.klimt.geom.XDimension2D; import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock; import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.ULine; +import net.sourceforge.plantuml.klimt.shape.URectangle; import net.sourceforge.plantuml.skin.UmlDiagramType; import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.style.PName; @@ -99,11 +101,11 @@ public class TimingDiagram extends UmlDiagram implements Clocks { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { @@ -133,6 +135,15 @@ public class TimingDiagram extends UmlDiagram implements Clocks { ruler.ensureNotEmpty(); final StringBounder stringBounder = ug.getStringBounder(); final double part1MaxWidth = getPart1MaxWidth(stringBounder); + + for (Player player : players.values()) { + final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder)); + final HColor generalBackgroundColor = player.getGeneralBackgroundColor(); + if (generalBackgroundColor != null) + ugPlayer.apply(generalBackgroundColor).apply(generalBackgroundColor.bg()) + .draw(URectangle.build(getWidthTotal(stringBounder), player.getFullHeight(stringBounder))); + } + final UTranslate widthPart1 = UTranslate.dx(part1MaxWidth); if (compactByDefault == false) drawBorder(ug); @@ -146,6 +157,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks { for (Player player : players.values()) { final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder)); final double caption = getHeightForCaptions(stringBounder); + if (first) { if (player.isCompact() == false) drawHorizontalSeparator(ugPlayer); @@ -279,9 +291,9 @@ public class TimingDiagram extends UmlDiagram implements Clocks { } public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type, boolean compact, - Stereotype stereotype) { + Stereotype stereotype, HColor backColor) { final Player player = new PlayerRobustConcise(type, full, getSkinParam(), ruler, compactByDefault || compact, - stereotype); + stereotype, backColor); players.put(code, player); lastPlayer = player; return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandAnalog.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandAnalog.java index ebbaf7a68..2c16fc6c2 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandAnalog.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandAnalog.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.timingdiagram.PlayerAnalog; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; import net.sourceforge.plantuml.utils.LineLocation; @@ -62,9 +63,7 @@ public class CommandAnalog extends SingleLineCommand2 { new RegexLeaf("analog"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexOptional(// new RegexConcat( // new RegexLeaf("between"), // @@ -78,9 +77,7 @@ public class CommandAnalog extends SingleLineCommand2 { new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE", "([%pLN_.@]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandBinary.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandBinary.java index 8feb151ab..e46b9d077 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandBinary.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandBinary.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; import net.sourceforge.plantuml.utils.LineLocation; @@ -61,15 +62,11 @@ public class CommandBinary extends SingleLineCommand2 { new RegexLeaf("binary"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceOneOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("CODE", "([%pLN_.@]+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE2"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandDefineStateShort.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandDefineStateShort.java index 671074038..c18d064d3 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandDefineStateShort.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandDefineStateShort.java @@ -59,8 +59,9 @@ public class CommandDefineStateShort extends SingleLineCommand2 { RegexLeaf.spaceOneOrMore(), // new RegexLeaf("has"), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STATE", "([%pLN_.@]+)"), // - new RegexLeaf("STATES", "((,([%pLN_.@]+))*)"), RegexLeaf.end()); + new RegexLeaf("STATE", "([-%pLN_.@]+)"), // + new RegexLeaf("STATES", "((,([-%pLN_.@]+))*)"), // + RegexLeaf.end()); } @Override diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandRobustConcise.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandRobustConcise.java index 432b0fde1..159ad26ff 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandRobustConcise.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandRobustConcise.java @@ -37,12 +37,18 @@ package net.sourceforge.plantuml.timingdiagram.command; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.klimt.color.ColorParser; +import net.sourceforge.plantuml.klimt.color.ColorType; +import net.sourceforge.plantuml.klimt.color.Colors; +import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexOptional; +import net.sourceforge.plantuml.regex.RegexOr; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; import net.sourceforge.plantuml.timingdiagram.TimingStyle; import net.sourceforge.plantuml.utils.LineLocation; @@ -64,20 +70,23 @@ public class CommandRobustConcise extends SingleLineCommand2 { new RegexOptional( // new RegexConcat( // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("as"), // RegexLeaf.spaceOneOrMore())), // new RegexLeaf("CODE", "([%pLN_.@]+)"), // + StereotypePattern.optional("STEREOTYPE2"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + new RegexOr(color().getRegex()), // RegexLeaf.end()); } + private static ColorParser color() { + return ColorParser.simpleColor(ColorType.BACK); + } + @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { final String compact = arg.get("COMPACT", 0); final String code = arg.get("CODE", 0); String full = arg.get("FULL", 0); @@ -91,7 +100,10 @@ public class CommandRobustConcise extends SingleLineCommand2 { stereotype = Stereotype.build(arg.get("STEREOTYPE2", 0)); final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase()); - return diagram.createRobustConcise(code, full, type, compact != null, stereotype); + final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + + return diagram.createRobustConcise(code, full, type, compact != null, stereotype, + colors.getColor(ColorType.BACK)); } } diff --git a/src/net/sourceforge/plantuml/version/PSystemLicense.java b/src/net/sourceforge/plantuml/version/PSystemLicense.java index 50cebbdee..d3ecb24e8 100644 --- a/src/net/sourceforge/plantuml/version/PSystemLicense.java +++ b/src/net/sourceforge/plantuml/version/PSystemLicense.java @@ -76,7 +76,7 @@ public class PSystemLicense extends PlainDiagram implements UDrawable { } @Override - public void exportDiagramGraphic(UGraphic ug) { + public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) { final LicenseInfo licenseInfo = LicenseInfo.retrieveQuick(); getTextBlock(licenseInfo).drawU(ug); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index f4b8d4cd1..700fba39c 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -46,7 +46,7 @@ public class Version { // Warning, "version" should be the same in gradle.properties and Version.java // Any idea anyone how to magically synchronize those :-) ? - private static final String version = "1.2023.13beta1"; + private static final String version = "1.2024.4beta6"; public static String versionString() { return version; @@ -80,7 +80,7 @@ public class Version { } public static long compileTime() { - return 1697809794384L; + return 1708026005000L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/version/version.txt b/src/net/sourceforge/plantuml/version/version.txt deleted file mode 100644 index 3dfd733c5..000000000 --- a/src/net/sourceforge/plantuml/version/version.txt +++ /dev/null @@ -1,2 +0,0 @@ -1.2023.6-beta-3 -1680642535564 \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/wbs/CommandWBSLink.java b/src/net/sourceforge/plantuml/wbs/CommandWBSLink.java index a8ca6d469..0a88bb07e 100644 --- a/src/net/sourceforge/plantuml/wbs/CommandWBSLink.java +++ b/src/net/sourceforge/plantuml/wbs/CommandWBSLink.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; import net.sourceforge.plantuml.regex.RegexResult; import net.sourceforge.plantuml.stereo.Stereotype; +import net.sourceforge.plantuml.stereo.StereotypePattern; import net.sourceforge.plantuml.utils.LineLocation; public class CommandWBSLink extends SingleLineCommand2 { @@ -64,9 +65,7 @@ public class CommandWBSLink extends SingleLineCommand2 { new RegexLeaf("CODE2", "([%pLN_]+)"), // RegexLeaf.spaceZeroOrMore(), // color().getRegex(), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // - RegexLeaf.spaceZeroOrMore(), // + StereotypePattern.optional("STEREOTYPE"), // new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), // RegexLeaf.end()); } diff --git a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java index 6d3e03663..192d9e3b4 100644 --- a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java +++ b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java @@ -92,11 +92,11 @@ public class WBSDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/wire/WireDiagram.java b/src/net/sourceforge/plantuml/wire/WireDiagram.java index 12cf30cc3..7919be884 100644 --- a/src/net/sourceforge/plantuml/wire/WireDiagram.java +++ b/src/net/sourceforge/plantuml/wire/WireDiagram.java @@ -76,11 +76,11 @@ public class WireDiagram extends UmlDiagram { protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); + return createImageBuilder(fileFormatOption).drawable(getTextMainBlock(fileFormatOption)).write(os); } @Override - protected TextBlock getTextBlock() { + protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/org/stathissideris/ascii2image/core/package-info.java b/src/org/stathissideris/ascii2image/core/package-info.java new file mode 100644 index 000000000..d39d0688a --- /dev/null +++ b/src/org/stathissideris/ascii2image/core/package-info.java @@ -0,0 +1,16 @@ +/* + * ⚠ Disclaimer 🚩 + * This file was not part of the original package. + * It was included only on the PlantUML package + * to provide source citation and documentation. + * + */ +/** + * Internal copy of + * + * ditaa (code of Stathis Sideris). + * + * @see net.sourceforge.plantuml.ditaa + * + */ +package org.stathissideris.ascii2image.core; diff --git a/src/org/stathissideris/ascii2image/core/readme.md b/src/org/stathissideris/ascii2image/core/readme.md new file mode 100644 index 000000000..f79ec3ec5 --- /dev/null +++ b/src/org/stathissideris/ascii2image/core/readme.md @@ -0,0 +1,15 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `core` + +## Description +Internal copy of `ditaa` _(code of Stathis Sideris)_. + +## Credit +- :octocat: [stathissideris/ditaa](https://github.com/stathissideris/ditaa) + +## See more information on +- [readme of `plantuml/ditaa`](../../../../net/sourceforge/plantuml/ditaa/readme.md) diff --git a/src/org/stathissideris/ascii2image/readme.md b/src/org/stathissideris/ascii2image/readme.md new file mode 100644 index 000000000..2428d1f19 --- /dev/null +++ b/src/org/stathissideris/ascii2image/readme.md @@ -0,0 +1,15 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `ascii2image` + +## Description +Internal copy of `ditaa` _(code of Stathis Sideris)_. + +## Credit +- :octocat: [stathissideris/ditaa](https://github.com/stathissideris/ditaa) + +## See more information on +- [readme of `plantuml/ditaa`](../../../net/sourceforge/plantuml/ditaa/readme.md) diff --git a/src/smetana/core/package-info.java b/src/smetana/core/package-info.java index 05aa05a4f..0d7268531 100644 --- a/src/smetana/core/package-info.java +++ b/src/smetana/core/package-info.java @@ -5,9 +5,9 @@ * in plantuml. * * @see h - * @see gen + * @see "gen" * @see gen.annotation - * @see gen.lib + * @see "gen.lib" * @see gen.plugin.dot_layout * @see net.sourceforge.plantuml.sdot * diff --git a/src/ext/plantuml/com/ctreber/acearth/ACearth.java b/src/zext/plantuml/com/ctreber/acearth/ACearth.java similarity index 85% rename from src/ext/plantuml/com/ctreber/acearth/ACearth.java rename to src/zext/plantuml/com/ctreber/acearth/ACearth.java index 7f04fc86d..532fb3fec 100644 --- a/src/ext/plantuml/com/ctreber/acearth/ACearth.java +++ b/src/zext/plantuml/com/ctreber/acearth/ACearth.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth; +package zext.plantuml.com.ctreber.acearth; import java.io.IOException; import java.io.OutputStream; @@ -7,33 +7,33 @@ import java.util.Iterator; import java.util.List; import java.util.Random; -import ext.plantuml.com.ctreber.acearth.gui.CanvasACearth; -import ext.plantuml.com.ctreber.acearth.plugins.Plugin; -import ext.plantuml.com.ctreber.acearth.plugins.markers.Marker; -import ext.plantuml.com.ctreber.acearth.plugins.markers.PluginMarkers; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.projection.ProjectionCyl; -import ext.plantuml.com.ctreber.acearth.projection.ProjectionMerc; -import ext.plantuml.com.ctreber.acearth.projection.ProjectionOrtho; -import ext.plantuml.com.ctreber.acearth.renderer.Renderer; -import ext.plantuml.com.ctreber.acearth.renderer.RowTypeRendererScanBit; -import ext.plantuml.com.ctreber.acearth.renderer.RowTypeRendererScanDot; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMapDefault; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMapOrtho; -import ext.plantuml.com.ctreber.acearth.scandot.DotGeneratorLines; -import ext.plantuml.com.ctreber.acearth.scandot.DotGeneratorStars; -import ext.plantuml.com.ctreber.acearth.scandot.ScanDot; -import ext.plantuml.com.ctreber.acearth.scandot.ScanDotGenerator; -import ext.plantuml.com.ctreber.acearth.shader.Shader; -import ext.plantuml.com.ctreber.acearth.shader.ShaderDefault; -import ext.plantuml.com.ctreber.acearth.shader.ShaderFlat; -import ext.plantuml.com.ctreber.acearth.shader.ShaderOrtho; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.SunPositionCalculator; -import ext.plantuml.com.ctreber.acearth.util.Toolkit; -import ext.plantuml.com.ctreber.aclib.sort.CTSort; -import ext.plantuml.com.ctreber.aclib.sort.QuickSort; +import zext.plantuml.com.ctreber.acearth.gui.CanvasACearth; +import zext.plantuml.com.ctreber.acearth.plugins.Plugin; +import zext.plantuml.com.ctreber.acearth.plugins.markers.Marker; +import zext.plantuml.com.ctreber.acearth.plugins.markers.PluginMarkers; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.projection.ProjectionCyl; +import zext.plantuml.com.ctreber.acearth.projection.ProjectionMerc; +import zext.plantuml.com.ctreber.acearth.projection.ProjectionOrtho; +import zext.plantuml.com.ctreber.acearth.renderer.Renderer; +import zext.plantuml.com.ctreber.acearth.renderer.RowTypeRendererScanBit; +import zext.plantuml.com.ctreber.acearth.renderer.RowTypeRendererScanDot; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMapDefault; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMapOrtho; +import zext.plantuml.com.ctreber.acearth.scandot.DotGeneratorLines; +import zext.plantuml.com.ctreber.acearth.scandot.DotGeneratorStars; +import zext.plantuml.com.ctreber.acearth.scandot.ScanDot; +import zext.plantuml.com.ctreber.acearth.scandot.ScanDotGenerator; +import zext.plantuml.com.ctreber.acearth.shader.Shader; +import zext.plantuml.com.ctreber.acearth.shader.ShaderDefault; +import zext.plantuml.com.ctreber.acearth.shader.ShaderFlat; +import zext.plantuml.com.ctreber.acearth.shader.ShaderOrtho; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.SunPositionCalculator; +import zext.plantuml.com.ctreber.acearth.util.Toolkit; +import zext.plantuml.com.ctreber.aclib.sort.CTSort; +import zext.plantuml.com.ctreber.aclib.sort.QuickSort; /** *

AC.earth - XEarth for Java

diff --git a/src/ext/plantuml/com/ctreber/acearth/Configuration.java b/src/zext/plantuml/com/ctreber/acearth/Configuration.java similarity index 85% rename from src/ext/plantuml/com/ctreber/acearth/Configuration.java rename to src/zext/plantuml/com/ctreber/acearth/Configuration.java index 7c84ea5ef..01bc6b508 100644 --- a/src/ext/plantuml/com/ctreber/acearth/Configuration.java +++ b/src/zext/plantuml/com/ctreber/acearth/Configuration.java @@ -1,14 +1,14 @@ -package ext.plantuml.com.ctreber.acearth; +package zext.plantuml.com.ctreber.acearth; import java.util.HashMap; import java.util.Map; -import ext.plantuml.com.ctreber.aclib.gui.MOBoolean; -import ext.plantuml.com.ctreber.aclib.gui.MODouble; -import ext.plantuml.com.ctreber.aclib.gui.MOEnum; -import ext.plantuml.com.ctreber.aclib.gui.MOInteger; -import ext.plantuml.com.ctreber.aclib.gui.MOString; -import ext.plantuml.com.ctreber.aclib.gui.MonitoredObject; +import zext.plantuml.com.ctreber.aclib.gui.MOBoolean; +import zext.plantuml.com.ctreber.aclib.gui.MODouble; +import zext.plantuml.com.ctreber.aclib.gui.MOEnum; +import zext.plantuml.com.ctreber.aclib.gui.MOInteger; +import zext.plantuml.com.ctreber.aclib.gui.MOString; +import zext.plantuml.com.ctreber.aclib.gui.MonitoredObject; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/ConfigurationACearth.java b/src/zext/plantuml/com/ctreber/acearth/ConfigurationACearth.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/ConfigurationACearth.java rename to src/zext/plantuml/com/ctreber/acearth/ConfigurationACearth.java index ae6529c4b..8bc3170f8 100644 --- a/src/ext/plantuml/com/ctreber/acearth/ConfigurationACearth.java +++ b/src/zext/plantuml/com/ctreber/acearth/ConfigurationACearth.java @@ -1,12 +1,12 @@ -package ext.plantuml.com.ctreber.acearth; +package zext.plantuml.com.ctreber.acearth; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.aclib.gui.MOBoolean; -import ext.plantuml.com.ctreber.aclib.gui.MODouble; -import ext.plantuml.com.ctreber.aclib.gui.MOEnum; -import ext.plantuml.com.ctreber.aclib.gui.MOInteger; -import ext.plantuml.com.ctreber.aclib.gui.MOString; -import ext.plantuml.com.ctreber.aclib.gui.MonitoredObject; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.aclib.gui.MOBoolean; +import zext.plantuml.com.ctreber.aclib.gui.MODouble; +import zext.plantuml.com.ctreber.aclib.gui.MOEnum; +import zext.plantuml.com.ctreber.aclib.gui.MOInteger; +import zext.plantuml.com.ctreber.aclib.gui.MOString; +import zext.plantuml.com.ctreber.aclib.gui.MonitoredObject; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/MapData.java b/src/zext/plantuml/com/ctreber/acearth/MapData.java similarity index 99% rename from src/ext/plantuml/com/ctreber/acearth/MapData.java rename to src/zext/plantuml/com/ctreber/acearth/MapData.java index d73641c1f..f20437f9e 100644 --- a/src/ext/plantuml/com/ctreber/acearth/MapData.java +++ b/src/zext/plantuml/com/ctreber/acearth/MapData.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth; +package zext.plantuml.com.ctreber.acearth; import java.util.ArrayList; import java.util.List; diff --git a/src/ext/plantuml/com/ctreber/acearth/MapDataReader.java b/src/zext/plantuml/com/ctreber/acearth/MapDataReader.java similarity index 95% rename from src/ext/plantuml/com/ctreber/acearth/MapDataReader.java rename to src/zext/plantuml/com/ctreber/acearth/MapDataReader.java index 3f70e6afe..f17780e5d 100644 --- a/src/ext/plantuml/com/ctreber/acearth/MapDataReader.java +++ b/src/zext/plantuml/com/ctreber/acearth/MapDataReader.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth; +package zext.plantuml.com.ctreber.acearth; import java.io.IOException; import java.util.ArrayList; @@ -6,8 +6,8 @@ import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; -import ext.plantuml.com.ctreber.acearth.util.Point3D; -import ext.plantuml.com.ctreber.acearth.util.Polygon; +import zext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Polygon; /** * The map data file is a big array of short (16-bit) ints, as follows: - it is diff --git a/src/ext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java b/src/zext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java similarity index 80% rename from src/ext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java rename to src/zext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java index f751a7030..37db1cdc3 100644 --- a/src/ext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java +++ b/src/zext/plantuml/com/ctreber/acearth/gui/CanvasACearth.java @@ -1,6 +1,6 @@ -package ext.plantuml.com.ctreber.acearth.gui; +package zext.plantuml.com.ctreber.acearth.gui; -import ext.plantuml.com.ctreber.acearth.ACearth; +import zext.plantuml.com.ctreber.acearth.ACearth; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java b/src/zext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java rename to src/zext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java index ab4b3deaa..4b7f68969 100644 --- a/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java +++ b/src/zext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.gui; +package zext.plantuml.com.ctreber.acearth.gui; import java.awt.Color; import java.awt.Graphics2D; @@ -6,7 +6,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; -import ext.plantuml.com.ctreber.acearth.renderer.RenderTarget; +import zext.plantuml.com.ctreber.acearth.renderer.RenderTarget; import net.sourceforge.plantuml.security.SImageIO; /** diff --git a/src/zext/plantuml/com/ctreber/acearth/package-info.java b/src/zext/plantuml/com/ctreber/acearth/package-info.java new file mode 100644 index 000000000..89c59c62e --- /dev/null +++ b/src/zext/plantuml/com/ctreber/acearth/package-info.java @@ -0,0 +1,16 @@ +/* + * ⚠ Disclaimer 🚩 + * This file was not part of the original package. + * It was included only on the PlantUML package + * to provide source citation and documentation. + * + */ +/** + * Internal copy of AC.earth - XEarth + * for Java (code of Christian Treber). + * + * @see zext.plantuml.com.ctreber.acearth.ACearth + * @see net.sourceforge.plantuml.acearth + * + */ +package zext.plantuml.com.ctreber.acearth; diff --git a/src/ext/plantuml/com/ctreber/acearth/plugins/Plugin.java b/src/zext/plantuml/com/ctreber/acearth/plugins/Plugin.java similarity index 78% rename from src/ext/plantuml/com/ctreber/acearth/plugins/Plugin.java rename to src/zext/plantuml/com/ctreber/acearth/plugins/Plugin.java index 85de4bb01..f15f31bb1 100644 --- a/src/ext/plantuml/com/ctreber/acearth/plugins/Plugin.java +++ b/src/zext/plantuml/com/ctreber/acearth/plugins/Plugin.java @@ -1,11 +1,11 @@ -package ext.plantuml.com.ctreber.acearth.plugins; +package zext.plantuml.com.ctreber.acearth.plugins; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import ext.plantuml.com.ctreber.acearth.ACearth; -import ext.plantuml.com.ctreber.acearth.gui.PixelCanvas; -import ext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.ACearth; +import zext.plantuml.com.ctreber.acearth.gui.PixelCanvas; +import zext.plantuml.com.ctreber.acearth.projection.Projection; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java b/src/zext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java rename to src/zext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java index ccd8b1589..bae5c8a14 100644 --- a/src/ext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java +++ b/src/zext/plantuml/com/ctreber/acearth/plugins/markers/Marker.java @@ -1,17 +1,17 @@ -package ext.plantuml.com.ctreber.acearth.plugins.markers; +package zext.plantuml.com.ctreber.acearth.plugins.markers; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.util.List; -import ext.plantuml.com.ctreber.acearth.gui.PixelCanvas; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.projection.ProjectionOrtho; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; -import ext.plantuml.com.ctreber.acearth.util.StringParser; +import zext.plantuml.com.ctreber.acearth.gui.PixelCanvas; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.projection.ProjectionOrtho; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.StringParser; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java b/src/zext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java rename to src/zext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java index b5e08db2a..c4f3c5cbb 100644 --- a/src/ext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java +++ b/src/zext/plantuml/com/ctreber/acearth/plugins/markers/PluginMarkers.java @@ -1,9 +1,9 @@ -package ext.plantuml.com.ctreber.acearth.plugins.markers; +package zext.plantuml.com.ctreber.acearth.plugins.markers; import java.util.Iterator; import java.util.List; -import ext.plantuml.com.ctreber.acearth.plugins.Plugin; +import zext.plantuml.com.ctreber.acearth.plugins.Plugin; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/projection/Projection.java b/src/zext/plantuml/com/ctreber/acearth/projection/Projection.java similarity index 96% rename from src/ext/plantuml/com/ctreber/acearth/projection/Projection.java rename to src/zext/plantuml/com/ctreber/acearth/projection/Projection.java index cdb6a2316..2da4743ff 100644 --- a/src/ext/plantuml/com/ctreber/acearth/projection/Projection.java +++ b/src/zext/plantuml/com/ctreber/acearth/projection/Projection.java @@ -1,9 +1,9 @@ -package ext.plantuml.com.ctreber.acearth.projection; +package zext.plantuml.com.ctreber.acearth.projection; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; -import ext.plantuml.com.ctreber.acearth.util.Toolkit; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Toolkit; /** *

A projection for a globe on a flat surface (must be subclassed). diff --git a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java rename to src/zext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java index e25071c9f..5822b52a1 100644 --- a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java +++ b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionCyl.java @@ -1,7 +1,7 @@ -package ext.plantuml.com.ctreber.acearth.projection; +package zext.plantuml.com.ctreber.acearth.projection; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** *

Cylindrical projection. Show Earth flatly spread out on rectangle. diff --git a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java rename to src/zext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java index 775e35ace..f28bd43e8 100644 --- a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java +++ b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionMerc.java @@ -1,7 +1,7 @@ -package ext.plantuml.com.ctreber.acearth.projection; +package zext.plantuml.com.ctreber.acearth.projection; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** diff --git a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java similarity index 88% rename from src/ext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java rename to src/zext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java index 6ff24a612..2b5013436 100644 --- a/src/ext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java +++ b/src/zext/plantuml/com/ctreber/acearth/projection/ProjectionOrtho.java @@ -1,7 +1,7 @@ -package ext.plantuml.com.ctreber.acearth.projection; +package zext.plantuml.com.ctreber.acearth.projection; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** diff --git a/src/zext/plantuml/com/ctreber/acearth/readme.md b/src/zext/plantuml/com/ctreber/acearth/readme.md new file mode 100644 index 000000000..2fc76d570 --- /dev/null +++ b/src/zext/plantuml/com/ctreber/acearth/readme.md @@ -0,0 +1,12 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `acearth` + +## Description +Internal copy of `AC.earth` - `XEarth` for Java _(code of Christian Treber)_. + +## See more information on +- [readme of `plantuml/acearth`](../../../../../net/sourceforge/plantuml/acearth/readme.md) diff --git a/src/ext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java b/src/zext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java similarity index 88% rename from src/ext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java rename to src/zext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java index e155cf32e..57c6fd5b1 100644 --- a/src/ext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java +++ b/src/zext/plantuml/com/ctreber/acearth/renderer/RenderTarget.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.renderer; +package zext.plantuml.com.ctreber.acearth.renderer; import java.awt.Color; diff --git a/src/ext/plantuml/com/ctreber/acearth/renderer/Renderer.java b/src/zext/plantuml/com/ctreber/acearth/renderer/Renderer.java similarity index 95% rename from src/ext/plantuml/com/ctreber/acearth/renderer/Renderer.java rename to src/zext/plantuml/com/ctreber/acearth/renderer/Renderer.java index ae9f389c4..a7d9e62fb 100644 --- a/src/ext/plantuml/com/ctreber/acearth/renderer/Renderer.java +++ b/src/zext/plantuml/com/ctreber/acearth/renderer/Renderer.java @@ -1,11 +1,11 @@ -package ext.plantuml.com.ctreber.acearth.renderer; +package zext.plantuml.com.ctreber.acearth.renderer; import java.awt.Color; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import ext.plantuml.com.ctreber.acearth.shader.Shader; +import zext.plantuml.com.ctreber.acearth.shader.Shader; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java rename to src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java index 7ec815894..d290d37c4 100644 --- a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java +++ b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRenderer.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.renderer; +package zext.plantuml.com.ctreber.acearth.renderer; /** *

Renders a row of pixel types.

diff --git a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java rename to src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java index 312ce543e..15ec2af81 100644 --- a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java +++ b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanBit.java @@ -1,7 +1,7 @@ -package ext.plantuml.com.ctreber.acearth.renderer; +package zext.plantuml.com.ctreber.acearth.renderer; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; -import ext.plantuml.com.ctreber.acearth.scanbit.ScanBit; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; +import zext.plantuml.com.ctreber.acearth.scanbit.ScanBit; /** *

Renders a row of ScanBits to pixel types.

diff --git a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java similarity index 89% rename from src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java rename to src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java index 3223094df..ee8faf78d 100644 --- a/src/ext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java +++ b/src/zext/plantuml/com/ctreber/acearth/renderer/RowTypeRendererScanDot.java @@ -1,7 +1,7 @@ -package ext.plantuml.com.ctreber.acearth.renderer; +package zext.plantuml.com.ctreber.acearth.renderer; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; -import ext.plantuml.com.ctreber.acearth.scandot.ScanDot; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; +import zext.plantuml.com.ctreber.acearth.scandot.ScanDot; /** *

Renders a row of ScanDots to pixel types.

diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java similarity index 88% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java index f907a70b4..c2e36b152 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMap.java @@ -1,16 +1,16 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.util.EdgeCrossing; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; -import ext.plantuml.com.ctreber.acearth.util.Polygon; -import ext.plantuml.com.ctreber.aclib.sort.CTSort; -import ext.plantuml.com.ctreber.aclib.sort.QuickSort; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.util.EdgeCrossing; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.util.Polygon; +import zext.plantuml.com.ctreber.aclib.sort.CTSort; +import zext.plantuml.com.ctreber.aclib.sort.QuickSort; /** *

diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java similarity index 95% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java index 7a3e8619b..780644110 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapDefault.java @@ -1,11 +1,11 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; import java.util.Comparator; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.util.EdgeCrossing; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.util.EdgeCrossing; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** *

Map scanner for mercator and cylindrical projections. diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java similarity index 94% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java index 980b4e5b6..59cc35c33 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/BitGeneratorMapOrtho.java @@ -1,11 +1,11 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; import java.util.Comparator; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.util.EdgeCrossing; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.util.EdgeCrossing; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** *

Map scanner for orthographic projection. diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java index d5f7624d5..e101629ec 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBit.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; /** *

Instruction to paint points xFrom to xTo on line y. @@ -53,7 +53,7 @@ public class ScanBit implements Comparable /** *

See values for - * @see ext.plantuml.com.ctreber.acearth.util.Polygon + * @see zext.plantuml.com.ctreber.acearth.util.Polygon */ public int getType() { diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java index c3e0febe3..531c3673d 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBitGenerator.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; /** *

A ScanBitGenerator produces ScanBits.

diff --git a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java similarity index 96% rename from src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java rename to src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java index 62c3ed347..88e9098c5 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java +++ b/src/zext/plantuml/com/ctreber/acearth/scanbit/ScanBuf.java @@ -1,10 +1,10 @@ -package ext.plantuml.com.ctreber.acearth.scanbit; +package zext.plantuml.com.ctreber.acearth.scanbit; import java.util.ArrayList; import java.util.List; -import ext.plantuml.com.ctreber.aclib.sort.CTSort; -import ext.plantuml.com.ctreber.aclib.sort.QuickSort; +import zext.plantuml.com.ctreber.aclib.sort.CTSort; +import zext.plantuml.com.ctreber.aclib.sort.QuickSort; /** *

For each line, the scanbuffer (= a raster divice) records the points hit diff --git a/src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java b/src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java similarity index 86% rename from src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java rename to src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java index 5392a4ef9..7a382a3be 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java +++ b/src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorLines.java @@ -1,9 +1,9 @@ -package ext.plantuml.com.ctreber.acearth.scandot; +package zext.plantuml.com.ctreber.acearth.scandot; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point2D; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** *

Generate latitude and longitude grid as dots. diff --git a/src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java b/src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java similarity index 96% rename from src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java rename to src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java index e598a27a2..789563753 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java +++ b/src/zext/plantuml/com/ctreber/acearth/scandot/DotGeneratorStars.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.scandot; +package zext.plantuml.com.ctreber.acearth.scandot; import java.util.Random; diff --git a/src/ext/plantuml/com/ctreber/acearth/scandot/ScanDot.java b/src/zext/plantuml/com/ctreber/acearth/scandot/ScanDot.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/scandot/ScanDot.java rename to src/zext/plantuml/com/ctreber/acearth/scandot/ScanDot.java index ac0823a7f..c222ee475 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scandot/ScanDot.java +++ b/src/zext/plantuml/com/ctreber/acearth/scandot/ScanDot.java @@ -1,6 +1,6 @@ -package ext.plantuml.com.ctreber.acearth.scandot; +package zext.plantuml.com.ctreber.acearth.scandot; -import ext.plantuml.com.ctreber.acearth.util.Point2D; +import zext.plantuml.com.ctreber.acearth.util.Point2D; /** *

A single scandot (opposed to a Polygon). diff --git a/src/ext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java b/src/zext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java similarity index 89% rename from src/ext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java rename to src/zext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java index 0013cf42c..3d7d7fe6f 100644 --- a/src/ext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java +++ b/src/zext/plantuml/com/ctreber/acearth/scandot/ScanDotGenerator.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.scandot; +package zext.plantuml.com.ctreber.acearth.scandot; import java.util.ArrayList; import java.util.List; diff --git a/src/ext/plantuml/com/ctreber/acearth/shader/Shader.java b/src/zext/plantuml/com/ctreber/acearth/shader/Shader.java similarity index 92% rename from src/ext/plantuml/com/ctreber/acearth/shader/Shader.java rename to src/zext/plantuml/com/ctreber/acearth/shader/Shader.java index e3ba21578..dcca30fe6 100644 --- a/src/ext/plantuml/com/ctreber/acearth/shader/Shader.java +++ b/src/zext/plantuml/com/ctreber/acearth/shader/Shader.java @@ -1,11 +1,11 @@ -package ext.plantuml.com.ctreber.acearth.shader; +package zext.plantuml.com.ctreber.acearth.shader; import java.awt.Color; -import ext.plantuml.com.ctreber.acearth.projection.Projection; -import ext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; -import ext.plantuml.com.ctreber.acearth.util.Coordinate; -import ext.plantuml.com.ctreber.acearth.util.Point3D; +import zext.plantuml.com.ctreber.acearth.projection.Projection; +import zext.plantuml.com.ctreber.acearth.scanbit.BitGeneratorMap; +import zext.plantuml.com.ctreber.acearth.util.Coordinate; +import zext.plantuml.com.ctreber.acearth.util.Point3D; /** *

A shader computes Colors for a row of pixel types, depending diff --git a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java similarity index 97% rename from src/ext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java rename to src/zext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java index ffb01e469..2dc3a151b 100644 --- a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java +++ b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderDefault.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.shader; +package zext.plantuml.com.ctreber.acearth.shader; import java.awt.Color; diff --git a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java similarity index 91% rename from src/ext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java rename to src/zext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java index a5b983ade..ca7d1c53d 100644 --- a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java +++ b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderFlat.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.shader; +package zext.plantuml.com.ctreber.acearth.shader; import java.awt.Color; diff --git a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java similarity index 96% rename from src/ext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java rename to src/zext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java index 33c646b58..7313ae615 100644 --- a/src/ext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java +++ b/src/zext/plantuml/com/ctreber/acearth/shader/ShaderOrtho.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.shader; +package zext.plantuml.com.ctreber.acearth.shader; import java.awt.Color; diff --git a/src/ext/plantuml/com/ctreber/acearth/util/Coordinate.java b/src/zext/plantuml/com/ctreber/acearth/util/Coordinate.java similarity index 98% rename from src/ext/plantuml/com/ctreber/acearth/util/Coordinate.java rename to src/zext/plantuml/com/ctreber/acearth/util/Coordinate.java index 76d16ae6a..91665e47e 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/Coordinate.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/Coordinate.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; import java.io.IOException; import java.io.Writer; diff --git a/src/ext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java b/src/zext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java similarity index 95% rename from src/ext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java rename to src/zext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java index adc3e2342..d4b03f3fc 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/EdgeCrossing.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; /** *

Holds information about a line crossing "the edge of Earth". diff --git a/src/ext/plantuml/com/ctreber/acearth/util/Point2D.java b/src/zext/plantuml/com/ctreber/acearth/util/Point2D.java similarity index 90% rename from src/ext/plantuml/com/ctreber/acearth/util/Point2D.java rename to src/zext/plantuml/com/ctreber/acearth/util/Point2D.java index 596f2b425..b71ea8c3b 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/Point2D.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/Point2D.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; /** *

A point in a 2 axis space. diff --git a/src/ext/plantuml/com/ctreber/acearth/util/Point3D.java b/src/zext/plantuml/com/ctreber/acearth/util/Point3D.java similarity index 93% rename from src/ext/plantuml/com/ctreber/acearth/util/Point3D.java rename to src/zext/plantuml/com/ctreber/acearth/util/Point3D.java index 8f0a06561..355d7bc05 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/Point3D.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/Point3D.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; /** *

A point in a 2 axis space. diff --git a/src/ext/plantuml/com/ctreber/acearth/util/Polygon.java b/src/zext/plantuml/com/ctreber/acearth/util/Polygon.java similarity index 93% rename from src/ext/plantuml/com/ctreber/acearth/util/Polygon.java rename to src/zext/plantuml/com/ctreber/acearth/util/Polygon.java index 9ea5f7141..5c43c3938 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/Polygon.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/Polygon.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; /** diff --git a/src/ext/plantuml/com/ctreber/acearth/util/StringParser.java b/src/zext/plantuml/com/ctreber/acearth/util/StringParser.java similarity index 98% rename from src/ext/plantuml/com/ctreber/acearth/util/StringParser.java rename to src/zext/plantuml/com/ctreber/acearth/util/StringParser.java index 3ba3b1cd8..7f268573c 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/StringParser.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/StringParser.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; import java.util.ArrayList; import java.util.List; diff --git a/src/ext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java b/src/zext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java similarity index 99% rename from src/ext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java rename to src/zext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java index 736a2c3f7..6cb9624ca 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/SunPositionCalculator.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; import java.util.Calendar; import java.util.Date; diff --git a/src/ext/plantuml/com/ctreber/acearth/util/Toolkit.java b/src/zext/plantuml/com/ctreber/acearth/util/Toolkit.java similarity index 98% rename from src/ext/plantuml/com/ctreber/acearth/util/Toolkit.java rename to src/zext/plantuml/com/ctreber/acearth/util/Toolkit.java index de5850a6d..21cb17adf 100644 --- a/src/ext/plantuml/com/ctreber/acearth/util/Toolkit.java +++ b/src/zext/plantuml/com/ctreber/acearth/util/Toolkit.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.acearth.util; +package zext.plantuml.com.ctreber.acearth.util; import java.util.HashSet; import java.util.StringTokenizer; diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java b/src/zext/plantuml/com/ctreber/aclib/gui/MOBoolean.java similarity index 93% rename from src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MOBoolean.java index 791eaeeab..e1eefd443 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOBoolean.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MOBoolean.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; /** *

diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java b/src/zext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java similarity index 86% rename from src/ext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java index 29416373d..4b8388f25 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MOChangeListener.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; /** *

Implemented by classes interetested in MonitoredObject values changes.

diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MODouble.java b/src/zext/plantuml/com/ctreber/aclib/gui/MODouble.java similarity index 96% rename from src/ext/plantuml/com/ctreber/aclib/gui/MODouble.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MODouble.java index 722a5db95..c77bc966f 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MODouble.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MODouble.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; /** *

diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOEnum.java b/src/zext/plantuml/com/ctreber/aclib/gui/MOEnum.java similarity index 96% rename from src/ext/plantuml/com/ctreber/aclib/gui/MOEnum.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MOEnum.java index f2b3cbf68..98848119e 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOEnum.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MOEnum.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; import java.util.HashSet; diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOInteger.java b/src/zext/plantuml/com/ctreber/aclib/gui/MOInteger.java similarity index 96% rename from src/ext/plantuml/com/ctreber/aclib/gui/MOInteger.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MOInteger.java index 081661562..290dd0783 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOInteger.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MOInteger.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; /** *

diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MOString.java b/src/zext/plantuml/com/ctreber/aclib/gui/MOString.java similarity index 91% rename from src/ext/plantuml/com/ctreber/aclib/gui/MOString.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MOString.java index 3f06fedb0..7a1537c83 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MOString.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MOString.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; diff --git a/src/ext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java b/src/zext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java similarity index 95% rename from src/ext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java rename to src/zext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java index 8bb482492..cfd2b57f4 100644 --- a/src/ext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java +++ b/src/zext/plantuml/com/ctreber/aclib/gui/MonitoredObject.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.gui; +package zext.plantuml.com.ctreber.aclib.gui; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java b/src/zext/plantuml/com/ctreber/aclib/sort/CTSort.java similarity index 91% rename from src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java rename to src/zext/plantuml/com/ctreber/aclib/sort/CTSort.java index 9783f237e..afa16ab2c 100644 --- a/src/ext/plantuml/com/ctreber/aclib/sort/CTSort.java +++ b/src/zext/plantuml/com/ctreber/aclib/sort/CTSort.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.sort; +package zext.plantuml.com.ctreber.aclib.sort; import java.util.Comparator; diff --git a/src/ext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java b/src/zext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java similarity index 90% rename from src/ext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java rename to src/zext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java index b183e4122..ef22c7c31 100644 --- a/src/ext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java +++ b/src/zext/plantuml/com/ctreber/aclib/sort/DefaultComparator.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.sort; +package zext.plantuml.com.ctreber.aclib.sort; import java.util.Comparator; diff --git a/src/ext/plantuml/com/ctreber/aclib/sort/QuickSort.java b/src/zext/plantuml/com/ctreber/aclib/sort/QuickSort.java similarity index 97% rename from src/ext/plantuml/com/ctreber/aclib/sort/QuickSort.java rename to src/zext/plantuml/com/ctreber/aclib/sort/QuickSort.java index a0922dbbe..d0f6cd165 100644 --- a/src/ext/plantuml/com/ctreber/aclib/sort/QuickSort.java +++ b/src/zext/plantuml/com/ctreber/aclib/sort/QuickSort.java @@ -1,4 +1,4 @@ -package ext.plantuml.com.ctreber.aclib.sort; +package zext.plantuml.com.ctreber.aclib.sort; import java.util.Comparator; diff --git a/src/zext/plantuml/com/ctreber/readme.md b/src/zext/plantuml/com/ctreber/readme.md new file mode 100644 index 000000000..4438e1e93 --- /dev/null +++ b/src/zext/plantuml/com/ctreber/readme.md @@ -0,0 +1,12 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `ctreber` + +## Description +Internal copy of `AC.earth` - `XEarth` for Java _(code of Christian Treber)_. + +## See more information on +- [readme of `plantuml/acearth`](../../../../net/sourceforge/plantuml/acearth/readme.md) diff --git a/src/ext/plantuml/com/google/zxing/BarcodeFormat.java b/src/zext/plantuml/com/google/zxing/BarcodeFormat.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/BarcodeFormat.java rename to src/zext/plantuml/com/google/zxing/BarcodeFormat.java index da912f28f..37c444dc2 100644 --- a/src/ext/plantuml/com/google/zxing/BarcodeFormat.java +++ b/src/zext/plantuml/com/google/zxing/BarcodeFormat.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; import java.util.Hashtable; diff --git a/src/ext/plantuml/com/google/zxing/ChecksumException.java b/src/zext/plantuml/com/google/zxing/ChecksumException.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/ChecksumException.java rename to src/zext/plantuml/com/google/zxing/ChecksumException.java index fa2a89030..11a232a37 100644 --- a/src/ext/plantuml/com/google/zxing/ChecksumException.java +++ b/src/zext/plantuml/com/google/zxing/ChecksumException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * Thrown when a barcode was successfully detected and decoded, but diff --git a/src/ext/plantuml/com/google/zxing/DecodeHintType.java b/src/zext/plantuml/com/google/zxing/DecodeHintType.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/DecodeHintType.java rename to src/zext/plantuml/com/google/zxing/DecodeHintType.java index 39d20f30c..6e0e687d4 100644 --- a/src/ext/plantuml/com/google/zxing/DecodeHintType.java +++ b/src/zext/plantuml/com/google/zxing/DecodeHintType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * Encapsulates a type of hint that a caller may pass to a barcode reader to help it diff --git a/src/ext/plantuml/com/google/zxing/EncodeHintType.java b/src/zext/plantuml/com/google/zxing/EncodeHintType.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/EncodeHintType.java rename to src/zext/plantuml/com/google/zxing/EncodeHintType.java index 8fc30c190..ed7228f0b 100644 --- a/src/ext/plantuml/com/google/zxing/EncodeHintType.java +++ b/src/zext/plantuml/com/google/zxing/EncodeHintType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * These are a set of hints that you may pass to Writers to specify their behavior. diff --git a/src/ext/plantuml/com/google/zxing/FormatException.java b/src/zext/plantuml/com/google/zxing/FormatException.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/FormatException.java rename to src/zext/plantuml/com/google/zxing/FormatException.java index b8282a6e1..461d09ee2 100644 --- a/src/ext/plantuml/com/google/zxing/FormatException.java +++ b/src/zext/plantuml/com/google/zxing/FormatException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * Thrown when a barcode was successfully detected, but some aspect of diff --git a/src/ext/plantuml/com/google/zxing/NotFoundException.java b/src/zext/plantuml/com/google/zxing/NotFoundException.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/NotFoundException.java rename to src/zext/plantuml/com/google/zxing/NotFoundException.java index 7d7624216..f45c7f71a 100644 --- a/src/ext/plantuml/com/google/zxing/NotFoundException.java +++ b/src/zext/plantuml/com/google/zxing/NotFoundException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * Thrown when a barcode was not found in the image. It might have been diff --git a/src/ext/plantuml/com/google/zxing/ReaderException.java b/src/zext/plantuml/com/google/zxing/ReaderException.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/ReaderException.java rename to src/zext/plantuml/com/google/zxing/ReaderException.java index 515d71776..8cd652ce1 100644 --- a/src/ext/plantuml/com/google/zxing/ReaderException.java +++ b/src/zext/plantuml/com/google/zxing/ReaderException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * The general exception class throw when something goes wrong during decoding of a barcode. diff --git a/src/ext/plantuml/com/google/zxing/ResultPoint.java b/src/zext/plantuml/com/google/zxing/ResultPoint.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/ResultPoint.java rename to src/zext/plantuml/com/google/zxing/ResultPoint.java index 30a7eac9c..e71240e01 100644 --- a/src/ext/plantuml/com/google/zxing/ResultPoint.java +++ b/src/zext/plantuml/com/google/zxing/ResultPoint.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** *

Encapsulates a point of interest in an image containing a barcode. Typically, this diff --git a/src/ext/plantuml/com/google/zxing/Writer.java b/src/zext/plantuml/com/google/zxing/Writer.java old mode 100755 new mode 100644 similarity index 94% rename from src/ext/plantuml/com/google/zxing/Writer.java rename to src/zext/plantuml/com/google/zxing/Writer.java index 90162a575..ae35c9629 --- a/src/ext/plantuml/com/google/zxing/Writer.java +++ b/src/zext/plantuml/com/google/zxing/Writer.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; import java.util.Hashtable; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** * The base class for all objects which encode/generate a barcode image. diff --git a/src/ext/plantuml/com/google/zxing/WriterException.java b/src/zext/plantuml/com/google/zxing/WriterException.java similarity index 95% rename from src/ext/plantuml/com/google/zxing/WriterException.java rename to src/zext/plantuml/com/google/zxing/WriterException.java index e605dd6af..fce6ac922 100644 --- a/src/ext/plantuml/com/google/zxing/WriterException.java +++ b/src/zext/plantuml/com/google/zxing/WriterException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing; +package zext.plantuml.com.google.zxing; /** * A base class which covers the range of exceptions which may occur when encoding a barcode using diff --git a/src/ext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java b/src/zext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java similarity index 95% rename from src/ext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java rename to src/zext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java index b6668edad..0778a040a 100644 --- a/src/ext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java +++ b/src/zext/plantuml/com/google/zxing/client/j2se/MatrixToImageWriter.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.client.j2se; +package zext.plantuml.com.google.zxing.client.j2se; import java.awt.image.BufferedImage; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** * Writes a {@link BitMatrix} to {@link BufferedImage}, diff --git a/src/ext/plantuml/com/google/zxing/common/BitArray.java b/src/zext/plantuml/com/google/zxing/common/BitArray.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/common/BitArray.java rename to src/zext/plantuml/com/google/zxing/common/BitArray.java index 4145f54c8..b8d795063 100644 --- a/src/ext/plantuml/com/google/zxing/common/BitArray.java +++ b/src/zext/plantuml/com/google/zxing/common/BitArray.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; /** *

A simple, fast array of bits, represented compactly by an array of ints internally.

diff --git a/src/ext/plantuml/com/google/zxing/common/BitMatrix.java b/src/zext/plantuml/com/google/zxing/common/BitMatrix.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/common/BitMatrix.java rename to src/zext/plantuml/com/google/zxing/common/BitMatrix.java index 22712cb53..212d22f24 100644 --- a/src/ext/plantuml/com/google/zxing/common/BitMatrix.java +++ b/src/zext/plantuml/com/google/zxing/common/BitMatrix.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; /** *

Represents a 2D matrix of bits. In function arguments below, and throughout the common diff --git a/src/ext/plantuml/com/google/zxing/common/BitSource.java b/src/zext/plantuml/com/google/zxing/common/BitSource.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/common/BitSource.java rename to src/zext/plantuml/com/google/zxing/common/BitSource.java index 50e39af77..c15f78afa 100644 --- a/src/ext/plantuml/com/google/zxing/common/BitSource.java +++ b/src/zext/plantuml/com/google/zxing/common/BitSource.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; /** *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the diff --git a/src/ext/plantuml/com/google/zxing/common/CharacterSetECI.java b/src/zext/plantuml/com/google/zxing/common/CharacterSetECI.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/common/CharacterSetECI.java rename to src/zext/plantuml/com/google/zxing/common/CharacterSetECI.java index f8520734d..1b01e8ff0 100644 --- a/src/ext/plantuml/com/google/zxing/common/CharacterSetECI.java +++ b/src/zext/plantuml/com/google/zxing/common/CharacterSetECI.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; import java.util.Hashtable; diff --git a/src/ext/plantuml/com/google/zxing/common/DecoderResult.java b/src/zext/plantuml/com/google/zxing/common/DecoderResult.java similarity index 92% rename from src/ext/plantuml/com/google/zxing/common/DecoderResult.java rename to src/zext/plantuml/com/google/zxing/common/DecoderResult.java index 97884c86b..864509b9a 100644 --- a/src/ext/plantuml/com/google/zxing/common/DecoderResult.java +++ b/src/zext/plantuml/com/google/zxing/common/DecoderResult.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; import java.util.Vector; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; /** *

Encapsulates the result of decoding a matrix of bits. This typically diff --git a/src/ext/plantuml/com/google/zxing/common/DetectorResult.java b/src/zext/plantuml/com/google/zxing/common/DetectorResult.java similarity index 92% rename from src/ext/plantuml/com/google/zxing/common/DetectorResult.java rename to src/zext/plantuml/com/google/zxing/common/DetectorResult.java index d62d4b6dc..38ac8016f 100644 --- a/src/ext/plantuml/com/google/zxing/common/DetectorResult.java +++ b/src/zext/plantuml/com/google/zxing/common/DetectorResult.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; -import ext.plantuml.com.google.zxing.ResultPoint; +import zext.plantuml.com.google.zxing.ResultPoint; /** *

Encapsulates the result of detecting a barcode in an image. This includes the raw diff --git a/src/ext/plantuml/com/google/zxing/common/ECI.java b/src/zext/plantuml/com/google/zxing/common/ECI.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/common/ECI.java rename to src/zext/plantuml/com/google/zxing/common/ECI.java index 5414732e1..8046cd179 100644 --- a/src/ext/plantuml/com/google/zxing/common/ECI.java +++ b/src/zext/plantuml/com/google/zxing/common/ECI.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; /** * Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations" diff --git a/src/ext/plantuml/com/google/zxing/common/StringUtils.java b/src/zext/plantuml/com/google/zxing/common/StringUtils.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/common/StringUtils.java rename to src/zext/plantuml/com/google/zxing/common/StringUtils.java index fbb516f61..d3d501ece 100644 --- a/src/ext/plantuml/com/google/zxing/common/StringUtils.java +++ b/src/zext/plantuml/com/google/zxing/common/StringUtils.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common; +package zext.plantuml.com.google.zxing.common; import java.util.Hashtable; -import ext.plantuml.com.google.zxing.DecodeHintType; +import zext.plantuml.com.google.zxing.DecodeHintType; /** * Common string-related functions. diff --git a/src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256.java b/src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256.java rename to src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256.java index 3a726ace1..2c3973b88 100644 --- a/src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256.java +++ b/src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common.reedsolomon; +package zext.plantuml.com.google.zxing.common.reedsolomon; /** *

This class contains utility methods for performing mathematical operations over diff --git a/src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java b/src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java rename to src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java index 29992842f..f4be25bd8 100644 --- a/src/ext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java +++ b/src/zext/plantuml/com/google/zxing/common/reedsolomon/GF256Poly.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common.reedsolomon; +package zext.plantuml.com.google.zxing.common.reedsolomon; /** *

Represents a polynomial whose coefficients are elements of GF(256). diff --git a/src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java b/src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java rename to src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java index bdc62c87e..f08a12ed1 100644 --- a/src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java +++ b/src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common.reedsolomon; +package zext.plantuml.com.google.zxing.common.reedsolomon; import java.util.Vector; diff --git a/src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java b/src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java similarity index 93% rename from src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java rename to src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java index 65301ef3f..de9eb5d55 100644 --- a/src/ext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java +++ b/src/zext/plantuml/com/google/zxing/common/reedsolomon/ReedSolomonException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.common.reedsolomon; +package zext.plantuml.com.google.zxing.common.reedsolomon; /** *

Thrown when an exception occurs during Reed-Solomon decoding, such as when diff --git a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java rename to src/zext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java index 545e6332a..1d3e82147 100644 --- a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java +++ b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/BitMatrixParser.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.datamatrix.decoder; +package zext.plantuml.com.google.zxing.datamatrix.decoder; -import ext.plantuml.com.google.zxing.FormatException; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.FormatException; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** * @author bbrown@google.com (Brian Brown) diff --git a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java rename to src/zext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java index 21a8d203f..5555b0f6c 100644 --- a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java +++ b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/DataBlock.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.datamatrix.decoder; +package zext.plantuml.com.google.zxing.datamatrix.decoder; /** *

Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into diff --git a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/Version.java b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/Version.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/datamatrix/decoder/Version.java rename to src/zext/plantuml/com/google/zxing/datamatrix/decoder/Version.java index 94c9f1783..a2c2c6f45 100644 --- a/src/ext/plantuml/com/google/zxing/datamatrix/decoder/Version.java +++ b/src/zext/plantuml/com/google/zxing/datamatrix/decoder/Version.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.datamatrix.decoder; +package zext.plantuml.com.google.zxing.datamatrix.decoder; -import ext.plantuml.com.google.zxing.FormatException; +import zext.plantuml.com.google.zxing.FormatException; /** * The Version object encapsulates attributes about a particular diff --git a/src/zext/plantuml/com/google/zxing/package-info.java b/src/zext/plantuml/com/google/zxing/package-info.java new file mode 100644 index 000000000..bd1914a8b --- /dev/null +++ b/src/zext/plantuml/com/google/zxing/package-info.java @@ -0,0 +1,16 @@ +/* + * ⚠ Disclaimer 🚩 + * This file was not part of the original package. + * It was included only on the PlantUML package + * to provide source citation and documentation. + * + */ +/** + * Internal copy of + * + * ZXing (code of Google). + * + * @see net.sourceforge.plantuml.flashcode + * + */ +package zext.plantuml.com.google.zxing; diff --git a/src/ext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java b/src/zext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java similarity index 85% rename from src/ext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java rename to src/zext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java index be6e8e1f3..53b7f010c 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/QRCodeWriter.java @@ -14,19 +14,19 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode; +package zext.plantuml.com.google.zxing.qrcode; import java.util.Hashtable; -import ext.plantuml.com.google.zxing.BarcodeFormat; -import ext.plantuml.com.google.zxing.EncodeHintType; -import ext.plantuml.com.google.zxing.Writer; -import ext.plantuml.com.google.zxing.WriterException; -import ext.plantuml.com.google.zxing.common.BitMatrix; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import ext.plantuml.com.google.zxing.qrcode.encoder.ByteMatrix; -import ext.plantuml.com.google.zxing.qrcode.encoder.Encoder; -import ext.plantuml.com.google.zxing.qrcode.encoder.QRCode; +import zext.plantuml.com.google.zxing.BarcodeFormat; +import zext.plantuml.com.google.zxing.EncodeHintType; +import zext.plantuml.com.google.zxing.Writer; +import zext.plantuml.com.google.zxing.WriterException; +import zext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.qrcode.encoder.ByteMatrix; +import zext.plantuml.com.google.zxing.qrcode.encoder.Encoder; +import zext.plantuml.com.google.zxing.qrcode.encoder.QRCode; /** * This object renders a QR Code as a BitMatrix 2D array of greyscale values. diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java index 3fe58c24d..3426a5ca1 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/BitMatrixParser.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; -import ext.plantuml.com.google.zxing.FormatException; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.FormatException; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** * @author Sean Owen diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java index b6f673cd0..00c932f6d 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/DataBlock.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; /** *

Encapsulates a block of data within a QR Code. QR Codes may split their data into diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java index 85e96e72c..475cd4326 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/DataMask.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** *

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java index 61760cc09..6eef3588e 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; /** *

See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java index 6ae6bb9bb..48f54308e 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/FormatInformation.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; /** *

Encapsulates a QR Code's format information, including the data mask used and diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/Mode.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/Mode.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/Mode.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/Mode.java index 882a5c6ff..504e5da2f 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/Mode.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/Mode.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; /** *

See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which diff --git a/src/ext/plantuml/com/google/zxing/qrcode/decoder/Version.java b/src/zext/plantuml/com/google/zxing/qrcode/decoder/Version.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/qrcode/decoder/Version.java rename to src/zext/plantuml/com/google/zxing/qrcode/decoder/Version.java index 93b073281..906233518 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/decoder/Version.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/decoder/Version.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.decoder; +package zext.plantuml.com.google.zxing.qrcode.decoder; -import ext.plantuml.com.google.zxing.FormatException; -import ext.plantuml.com.google.zxing.common.BitMatrix; +import zext.plantuml.com.google.zxing.FormatException; +import zext.plantuml.com.google.zxing.common.BitMatrix; /** * See ISO 18004:2006 Annex D diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java similarity index 94% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java index b0e031213..1acf3a9b9 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/BlockPair.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; final class BlockPair { diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java index e8c7e444e..e99b7e88b 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/ByteMatrix.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; /** * A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java similarity index 96% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java index 04ea0b667..c1fc1eb2b 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/Encoder.java @@ -14,22 +14,22 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; import java.io.UnsupportedEncodingException; import java.util.Hashtable; import java.util.Vector; -import ext.plantuml.com.google.zxing.EncodeHintType; -import ext.plantuml.com.google.zxing.WriterException; -import ext.plantuml.com.google.zxing.common.BitArray; -import ext.plantuml.com.google.zxing.common.CharacterSetECI; -import ext.plantuml.com.google.zxing.common.ECI; -import ext.plantuml.com.google.zxing.common.reedsolomon.GF256; -import ext.plantuml.com.google.zxing.common.reedsolomon.ReedSolomonEncoder; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import ext.plantuml.com.google.zxing.qrcode.decoder.Mode; -import ext.plantuml.com.google.zxing.qrcode.decoder.Version; +import zext.plantuml.com.google.zxing.EncodeHintType; +import zext.plantuml.com.google.zxing.WriterException; +import zext.plantuml.com.google.zxing.common.BitArray; +import zext.plantuml.com.google.zxing.common.CharacterSetECI; +import zext.plantuml.com.google.zxing.common.ECI; +import zext.plantuml.com.google.zxing.common.reedsolomon.GF256; +import zext.plantuml.com.google.zxing.common.reedsolomon.ReedSolomonEncoder; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.qrcode.decoder.Mode; +import zext.plantuml.com.google.zxing.qrcode.decoder.Version; /** * @author satorux@google.com (Satoru Takabayashi) - creator diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java similarity index 99% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java index 4ccd48b6f..cb3c5bb36 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/MaskUtil.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; /** * @author satorux@google.com (Satoru Takabayashi) - creator diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java similarity index 98% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java index bbf1c2245..d755bddf5 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/MatrixUtil.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; -import ext.plantuml.com.google.zxing.WriterException; -import ext.plantuml.com.google.zxing.common.BitArray; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.WriterException; +import zext.plantuml.com.google.zxing.common.BitArray; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; /** * @author satorux@google.com (Satoru Takabayashi) - creator diff --git a/src/ext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java b/src/zext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java similarity index 97% rename from src/ext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java rename to src/zext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java index dae3e1dc4..cc9baa239 100644 --- a/src/ext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java +++ b/src/zext/plantuml/com/google/zxing/qrcode/encoder/QRCode.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package ext.plantuml.com.google.zxing.qrcode.encoder; +package zext.plantuml.com.google.zxing.qrcode.encoder; -import ext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; -import ext.plantuml.com.google.zxing.qrcode.decoder.Mode; +import zext.plantuml.com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import zext.plantuml.com.google.zxing.qrcode.decoder.Mode; /** * @author satorux@google.com (Satoru Takabayashi) - creator diff --git a/src/zext/plantuml/com/google/zxing/readme.md b/src/zext/plantuml/com/google/zxing/readme.md new file mode 100644 index 000000000..fb27815b3 --- /dev/null +++ b/src/zext/plantuml/com/google/zxing/readme.md @@ -0,0 +1,15 @@ +> [!WARNING] +> **Disclaimer**: +> This file was not part of the original package. +> It was included only on the PlantUML package to provide source citation and documentation. + +# Directory Documentation for `zxing` + +## Description +Internal copy of `ZXing` _(code of Google)_. + +## Credit +- :octocat: [zxing/zxing](https://github.com/zxing/zxing) + +## See more information on +- [readme of `plantuml/flashcode`](../../../../../net/sourceforge/plantuml/flashcode/readme.md) diff --git a/stdlib/awslib14-abx.repx b/stdlib/awslib14-abx.repx index df02cc142..515704a87 100644 Binary files a/stdlib/awslib14-abx.repx and b/stdlib/awslib14-abx.repx differ diff --git a/stdlib/azure-abx.repx b/stdlib/azure-abx.repx index ec8a89f67..d765e254e 100644 Binary files a/stdlib/azure-abx.repx and b/stdlib/azure-abx.repx differ diff --git a/stdlib/c4-abx.repx b/stdlib/c4-abx.repx index 24cd069ab..10ef9117e 100644 Binary files a/stdlib/c4-abx.repx and b/stdlib/c4-abx.repx differ diff --git a/stdlib/edgy-abx.repx b/stdlib/edgy-abx.repx new file mode 100644 index 000000000..d3ea483fe Binary files /dev/null and b/stdlib/edgy-abx.repx differ diff --git a/stdlib/edgy-dex.repx b/stdlib/edgy-dex.repx new file mode 100644 index 000000000..1c8a0e797 --- /dev/null +++ b/stdlib/edgy-dex.repx @@ -0,0 +1 @@ +; \ No newline at end of file diff --git a/stdlib/eip-abx.repx b/stdlib/eip-abx.repx new file mode 100644 index 000000000..79df26082 Binary files /dev/null and b/stdlib/eip-abx.repx differ diff --git a/stdlib/eip-dex.repx b/stdlib/eip-dex.repx new file mode 100644 index 000000000..d550fd7b3 Binary files /dev/null and b/stdlib/eip-dex.repx differ diff --git a/stdlib/gcp-abx.repx b/stdlib/gcp-abx.repx new file mode 100644 index 000000000..df8f296e8 Binary files /dev/null and b/stdlib/gcp-abx.repx differ diff --git a/stdlib/gcp-dex.repx b/stdlib/gcp-dex.repx new file mode 100644 index 000000000..e7efda0e3 Binary files /dev/null and b/stdlib/gcp-dex.repx differ diff --git a/stdlib/home.repx b/stdlib/home.repx index 94f621da5..f2ba66b23 100644 --- a/stdlib/home.repx +++ b/stdlib/home.repx @@ -8,10 +8,15 @@ classy-c4 cloudinsight cloudogu domainstory +edgy +eip elastic +gcp kubernetes +k8s logos material office osa -tupadr3 +osa2 +tupadr3 \ No newline at end of file diff --git a/stdlib/k8s-abx.repx b/stdlib/k8s-abx.repx new file mode 100644 index 000000000..c8f870c8c Binary files /dev/null and b/stdlib/k8s-abx.repx differ diff --git a/stdlib/k8s-dex.repx b/stdlib/k8s-dex.repx new file mode 100644 index 000000000..1a528ba86 Binary files /dev/null and b/stdlib/k8s-dex.repx differ diff --git a/stdlib/office-abx.repx b/stdlib/office-abx.repx index f0069b29f..7a4ee4f97 100644 Binary files a/stdlib/office-abx.repx and b/stdlib/office-abx.repx differ diff --git a/stdlib/osa2-abx.repx b/stdlib/osa2-abx.repx new file mode 100644 index 000000000..03f27ade4 Binary files /dev/null and b/stdlib/osa2-abx.repx differ diff --git a/stdlib/osa2-dex.repx b/stdlib/osa2-dex.repx new file mode 100644 index 000000000..096fffbe1 Binary files /dev/null and b/stdlib/osa2-dex.repx differ diff --git a/test/net/sourceforge/plantuml/LoadJsonTest.java b/test/net/sourceforge/plantuml/LoadJsonTest.java index cd5302be7..3ff4c3bb9 100644 --- a/test/net/sourceforge/plantuml/LoadJsonTest.java +++ b/test/net/sourceforge/plantuml/LoadJsonTest.java @@ -1,9 +1,9 @@ package net.sourceforge.plantuml; import static java.nio.charset.StandardCharsets.UTF_8; -import static net.sourceforge.plantuml.test.TestUtils.writeUtf8File; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.newArrayList; +import static test.utils.TestUtils.writeUtf8File; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/test/net/sourceforge/plantuml/PipeTest.java b/test/net/sourceforge/plantuml/PipeTest.java index a975bf26c..6db686723 100644 --- a/test/net/sourceforge/plantuml/PipeTest.java +++ b/test/net/sourceforge/plantuml/PipeTest.java @@ -127,7 +127,7 @@ class PipeTest { false, false)); l.add(TestCase.of("-syntax", "@startuml\na->b\n@enduml\n@startuml\na->b\nb->c\n@enduml\n", "SEQUENCE\n(2 participants)\nSEQUENCE\n(3 participants)\n", Verification.EXACT, false, false)); - l.add(TestCase.of("-syntax", "@startgantt\n[a] lasts 1 day\n@endgantt", "OTHER\n(Project)\n", + l.add(TestCase.of("-syntax", "@startgantt\n[a] lasts 1 day\n@endgantt", "OTHER\n(Gantt)\n", Verification.EXACT, false, false)); // invalid syntax diff --git a/test/net/sourceforge/plantuml/TestFileDirOption.java b/test/net/sourceforge/plantuml/TestFileDirOption.java index d68165ef6..5e71d1937 100644 --- a/test/net/sourceforge/plantuml/TestFileDirOption.java +++ b/test/net/sourceforge/plantuml/TestFileDirOption.java @@ -1,9 +1,9 @@ package net.sourceforge.plantuml; import static java.nio.charset.StandardCharsets.UTF_8; -import static net.sourceforge.plantuml.test.TestUtils.writeUtf8File; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.newArrayList; +import static test.utils.TestUtils.writeUtf8File; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; diff --git a/test/net/sourceforge/plantuml/help/CommandHelpThemeTest.java b/test/net/sourceforge/plantuml/help/CommandHelpThemeTest.java new file mode 100644 index 000000000..caef807b6 --- /dev/null +++ b/test/net/sourceforge/plantuml/help/CommandHelpThemeTest.java @@ -0,0 +1,23 @@ +package net.sourceforge.plantuml.help; + +import static org.assertj.core.api.Assertions.assertThat; +import static test.utils.PlantUmlTestUtils.exportDiagram; + +import org.junit.jupiter.api.Test; + +class CommandHelpThemeTest { + + @Test + public void command_help_theme() throws Exception { + + final String output = exportDiagram( + "@startuml", + "help themes", + "@enduml" + ).asString(); + + assertThat(output) + .contains("Help on themes") + .contains("bluegray", "hacker"); + } +} \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/math/MathTest.java b/test/net/sourceforge/plantuml/math/MathTest.java index d649d9c77..391ff41d6 100644 --- a/test/net/sourceforge/plantuml/math/MathTest.java +++ b/test/net/sourceforge/plantuml/math/MathTest.java @@ -17,6 +17,9 @@ class MathTest { " '[[a,b],[c,d]]', {\\left[\\begin{matrix}{a}&{b}\\\\{c}&{d}\\end{matrix}\\right]} ", " color(red)(x), {\\textcolor{red}{{x}}} ", " color(red)(t)=color(blue)(x), {\\textcolor{red}{{t}}}={\\textcolor{blue}{{x}}} ", + " f, {f} ", + " f_g, {{f}_{{g}}} ", + " '[[1,2,3],[4,5,6]]', {\\left[\\begin{matrix}{1}&{2}&{3}\\\\{4}&{5}&{6}\\end{matrix}\\right]} ", }) public void testMath(String input, String expected) { final String res = new ASCIIMathTeXImg().getTeX(input); diff --git a/test/net/sourceforge/plantuml/tim/EaterTest.java b/test/net/sourceforge/plantuml/tim/EaterTest.java new file mode 100644 index 000000000..1a458ceaa --- /dev/null +++ b/test/net/sourceforge/plantuml/tim/EaterTest.java @@ -0,0 +1,65 @@ +package net.sourceforge.plantuml.tim; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.util.Lists.newArrayList; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import net.sourceforge.plantuml.ErrorStatus; +import net.sourceforge.plantuml.Option; +import net.sourceforge.plantuml.Pipe; + +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) +/** + * Tests the Eater (for JSON data). + */ +class EaterTest { + + @ParameterizedTest(name = "[{index}] {1}") + @CsvSource(nullValues = "null", value = { + "'@startuml\n!$a={\"k\": \"exampleValue\"}\ntitle $a.k\na -> b\n@enduml\n' , exampleValue", + "'@startuml\n!$a=[1, 2, 3]\ntitle xx $a[2] yy\na -> a\n' , xx 3 yy", + "'@startuml\ntitle\n!foreach $i in [1, 2, 3]\nxx $i yy\n!endfor\nendtitle\na -> a\n' , xx 2 yy", + "'@startuml\ntitle\n!foreach $i in [\"a\", \"b\", \"c\"]\nxx $i yy\n!endfor\nendtitle\na -> a\n' , xx b yy", + "'@startuml\nstdlib\n@enduml', archimate", + }) + void Test_EaterTest(String input, String expected) throws Exception { + assertRenderExpectedOutput(input, expected); + } + + // TODO: to Factorize on a specific test package... + private static final String[] COMMON_OPTIONS = {"-tutxt"}; + + private String[] optionArray(String... extraOptions) { + final List list = newArrayList(COMMON_OPTIONS); + Collections.addAll(list, extraOptions); + return list.toArray(new String[0]); + } + + private String render(String diagram, String... extraOptions) throws Exception { + final Option option = new Option(optionArray(extraOptions)); + final ByteArrayInputStream bais = new ByteArrayInputStream(diagram.getBytes(UTF_8)); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final Pipe pipe = new Pipe(option, new PrintStream(baos), bais, option.getCharset()); + pipe.managePipe(ErrorStatus.init()); + String rendered = new String(baos.toByteArray(), UTF_8); + // System.err.println(rendered); + return rendered; + } + + public void assertRenderExpectedOutput(String input, String expected) throws Exception { + String rendered = render(input); + assertThat(rendered).doesNotContain("syntax").contains(expected); + } +} diff --git a/test/net/sourceforge/plantuml/tim/TimTestUtils.java b/test/net/sourceforge/plantuml/tim/TimTestUtils.java index 81993d3a2..c71b7d8a3 100644 --- a/test/net/sourceforge/plantuml/tim/TimTestUtils.java +++ b/test/net/sourceforge/plantuml/tim/TimTestUtils.java @@ -14,27 +14,27 @@ import net.sourceforge.plantuml.json.JsonValue; public class TimTestUtils { // Tfunc: () -> (String) - public static void assertTimExpectedOutput(TFunction func, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutput(TFunction func, String expected) throws EaterException { TValue tValue = func.executeReturnFunction(null, null, null, null, null); assertEquals(expected, tValue.toString()); } // Tfunc: (Integer) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, Integer input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, Integer input, String expected) throws EaterException { List values = Collections.singletonList(TValue.fromInt(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); } // Tfunc: (String) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, String input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, String input, String expected) throws EaterException { List values = Collections.singletonList(TValue.fromString(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); } // Tfunc: (JsonValue) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, JsonValue input, String expected) throws EaterException { List values = Collections.singletonList(TValue.fromJson(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); diff --git a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java index addb2050c..1ff9e68ff 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java @@ -6,12 +6,10 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; /** @@ -24,7 +22,7 @@ class AlwaysFalseTest { final String cutName = "AlwaysFalse"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -34,7 +32,7 @@ class AlwaysFalseTest { " 1 , 0 ", " 'a' , 0 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -44,7 +42,7 @@ class AlwaysFalseTest { " 1 , 0 ", " 123 , 0 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java index 439bde93d..d1e910b84 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java @@ -6,12 +6,10 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; /** @@ -24,7 +22,7 @@ class AlwaysTrueTest { final String cutName = "AlwaysTrue"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "1"); } @@ -34,7 +32,7 @@ class AlwaysTrueTest { " 1 , 1 ", " 'a' , 1 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -44,7 +42,7 @@ class AlwaysTrueTest { " 1 , 1 ", " 123 , 1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java index cf3886aaa..58cba9f04 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java @@ -1,29 +1,29 @@ package net.sourceforge.plantuml.tim.stdlib; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.Collections; -import java.util.List; +import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; -import net.sourceforge.plantuml.tim.expression.TValue; +import net.sourceforge.plantuml.tim.TFunction; /** * Tests the builtin function %chr. */ -class ChrTest { +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) +class ChrTest { + TFunction cut = new Chr(); + final String cutName = "Chr"; /** * Tests chr according to a list of input / expected output * * @throws EaterException should not - * @throws EaterExceptionLocated should not */ - @ParameterizedTest + @ParameterizedTest(name = "[{index}] " + cutName + "({0}) = ''{1}''") @CsvSource(nullValues = "null", value = { " 65 , A ", " 9 , '\t' ", @@ -32,15 +32,11 @@ class ChrTest { " 34 , '\"' ", " 224 , à ", " 233 , é ", -// TODO: fix `%chr` to allow Unicode chars, the corresponding tests are here: -// " 128512 , 😀 ", -// " 128512 , \uD83D\uDE00 ", +// DONE: fix `%chr` to allow Unicode chars, the corresponding tests are here: + " 128512 , 😀 ", + " 128512 , \uD83D\uDE00 ", }) - void executeReturnFunctionChrTest(Integer input, String expected) throws EaterException, EaterExceptionLocated { - Chr cut = new Chr(); - - List values = Collections.singletonList(TValue.fromInt(input)); - TValue tValue = cut.executeReturnFunction(null, null, null, values, null); - assertEquals(expected, tValue.toString()); + void Test_with_Integer(Integer input, String expected) throws EaterException { + assertTimExpectedOutputFromInput(cut, input, expected); } } \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java b/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java index 1134c293d..ff05ebff7 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java @@ -6,12 +6,10 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; /** @@ -24,7 +22,7 @@ class Dec2hexTest { final String cutName = "Dec2hex"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, ""); } @@ -38,7 +36,7 @@ class Dec2hexTest { " 255 , 0 ", " 65535 , 0 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -52,7 +50,7 @@ class Dec2hexTest { " 255 , ff ", " 65535 , ffff ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java b/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java index 74bdf712a..d5ea79e3f 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class FeatureTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -43,7 +42,7 @@ class FeatureTest { " abc , 0", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -52,7 +51,7 @@ class FeatureTest { " 0, 0", " 10, 0", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -62,7 +61,7 @@ class FeatureTest { " \"theme\", 1", " 0, 0", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java new file mode 100644 index 000000000..ab8c23fd3 --- /dev/null +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java @@ -0,0 +1,38 @@ +package net.sourceforge.plantuml.tim.stdlib; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.Test; + +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TFunction; +import net.sourceforge.plantuml.tim.expression.TValue; + +/** + * Tests the builtin function. + */ +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) + +class GetAllStdlibTest { + TFunction cut = new GetAllStdlib(); + final String cutName = "GetAllStdlib"; + + @Test + void Test_without_Param() throws EaterException { + final List empty = Collections.emptyList(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); + assertThat(tValue.toString()).contains("archimate", "aws", "tupadr3"); + } + + @Test + void Test_with_one_argument() throws EaterException { + final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(0)), null); + assertThat(tValue.toString()).contains("archimate", "https://github.com/plantuml-stdlib/Archimate-PlantUML"); + } +} diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java new file mode 100644 index 000000000..1f79076b4 --- /dev/null +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java @@ -0,0 +1,32 @@ +package net.sourceforge.plantuml.tim.stdlib; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.Test; + +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TFunction; +import net.sourceforge.plantuml.tim.expression.TValue; + +/** + * Tests the builtin function. + */ +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) + +class GetAllThemeTest { + TFunction cut = new GetAllTheme(); + final String cutName = "GetAllTheme"; + + @Test + void Test_without_Param() throws EaterException { + final List empty = Collections.emptyList(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); + assertThat(tValue.toString()).contains("_none_", "amiga", "vibrant"); + } +} diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java index c9985befd..269a3aaf3 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class GetJsonKeyTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -39,7 +38,7 @@ class GetJsonKeyTest { " a, Not JSON data", " -1, Not JSON data", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -49,7 +48,7 @@ class GetJsonKeyTest { " 0, Not JSON data", " -1, Not JSON data", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -61,13 +60,13 @@ class GetJsonKeyTest { " '{\"a\":\"abc\"}' , [\"a\"]", " '[{\"a\":[1, 2]}, {\"b\":[3, 4]}]' , '[\"a\",\"b\"]'", " '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '[\"a\",\"b\",\"b\"]'", - // TODO: Manage Array with different type inside + // DONE: Manage Array with different type inside // Ref.: // - https://datatracker.ietf.org/doc/html/rfc8259#section-5 // - https://json-schema.org/understanding-json-schema/reference/array.html - //" '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]", + " '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java index 1b720c9e5..6422fd8de 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class GetJsonTypeTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -38,7 +37,7 @@ class GetJsonTypeTest { " a, string", " -1, string", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -47,7 +46,7 @@ class GetJsonTypeTest { " 0, number", " -1, number", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -67,7 +66,7 @@ class GetJsonTypeTest { " null , json ", " '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , object", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java index aea38a745..883fa0090 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java @@ -9,7 +9,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.expression.TValue; /** @@ -21,7 +20,6 @@ class GetenvTest { * Tests getenv should not publish plantuml.security.* environment variables. * * @throws EaterException should not - * @throws EaterExceptionLocated should not */ @ParameterizedTest @ValueSource(strings = { @@ -29,7 +27,7 @@ class GetenvTest { "plantuml.SECURITY.blabla", "plantuml.security.credentials.path", }) - void executeReturnFunctionSecurityTest(String name) throws EaterException, EaterExceptionLocated { + void executeReturnFunctionSecurityTest(String name) throws EaterException { System.setProperty("plantuml.security.blabla", "example"); Getenv cut = new Getenv(); @@ -42,14 +40,13 @@ class GetenvTest { * Tests getenv still returns 'good' variables. * * @throws EaterException should not - * @throws EaterExceptionLocated should not */ @ParameterizedTest @ValueSource(strings = { "path.separator", "line.separator", }) - void executeReturnFunctionTest(String name) throws EaterException, EaterExceptionLocated { + void executeReturnFunctionTest(String name) throws EaterException { Getenv cut = new Getenv(); List values = Collections.singletonList(TValue.fromString(name)); diff --git a/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java b/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java index 329347b79..08a33c4c7 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java @@ -6,12 +6,10 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; /** @@ -24,7 +22,7 @@ class Hex2decTest { final String cutName = "Hex2dec"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -44,7 +42,7 @@ class Hex2decTest { " -1 , -1 ", " -a , -10 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +53,7 @@ class Hex2decTest { " 10 , 16 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java b/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java index d149c26b9..1488eb641 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class LowerTest { // TODO: Manage Lower function without param. (today: we observe `Function not found %lower`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, ""); } @@ -44,7 +43,7 @@ class LowerTest { " É , é ", " 😀 , 😀 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +54,7 @@ class LowerTest { " 10 , 10 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -70,7 +69,7 @@ class LowerTest { // TODO: See JSON management of TRUE/FALSE //" TRUE , true ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java b/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java index 3d4c2f203..ae2cfcd14 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java @@ -1,29 +1,29 @@ package net.sourceforge.plantuml.tim.stdlib; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.Collections; -import java.util.List; +import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; -import net.sourceforge.plantuml.tim.expression.TValue; +import net.sourceforge.plantuml.tim.TFunction; /** * Tests the builtin function %ord. */ -class OrdTest { +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) +class OrdTest { + TFunction cut = new Ord(); + final String cutName = "Ord"; /** * Tests ord according to a list of input / expected output * * @throws EaterException should not - * @throws EaterExceptionLocated should not */ - @ParameterizedTest + @ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}") @CsvSource(nullValues = "null", value = { " A , 65 ", " ABC , 65 ", @@ -39,11 +39,7 @@ class OrdTest { " 😀 , 128512 ", " \uD83D\uDE00 , 128512 ", }) - void executeReturnFunctionOrdTest(String input, String expected) throws EaterException, EaterExceptionLocated { - Ord cut = new Ord(); - - List values = Collections.singletonList(TValue.fromString(input)); - TValue tValue = cut.executeReturnFunction(null, null, null, values, null); - assertEquals(expected, tValue.toString()); + void Test_with_String(String input, String expected) throws EaterException { + assertTimExpectedOutputFromInput(cut, input, expected); } } \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java b/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java new file mode 100644 index 000000000..fd8033793 --- /dev/null +++ b/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java @@ -0,0 +1,54 @@ +package net.sourceforge.plantuml.tim.stdlib; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.RepeatedTest; + +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.TFunction; +import net.sourceforge.plantuml.tim.expression.TValue; + +/** + * Tests the builtin function. + */ +@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class) + +class RandomFunctionTest { + TFunction cut = new RandomFunction(); + final String cutName = "Random"; + final String repetitionLabel = "[{currentRepetition}/{totalRepetitions}] "; + + @RepeatedTest(value = 10, name = repetitionLabel + cutName + "()") + void test_with_no_argument() throws EaterException { + final List empty = Collections.emptyList(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); + assertThat(tValue.toInt()).isIn(0, 1); + } + + @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(7)") + void test_with_one_argument() throws EaterException { + final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(7)), null); + assertThat(tValue.toInt()).isBetween(0, 7 - 1); + } + + @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(0, 7)") + void test_with_two_argument_first_zero() throws EaterException { + final TValue tValue = cut.executeReturnFunction(null, null, null, + Arrays.asList(TValue.fromInt(0), TValue.fromInt(7)), null); + assertThat(tValue.toInt()).isBetween(0, 7 - 1); + } + + @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(3, 7)") + void test_with_two_argument() throws EaterException { + final TValue tValue = cut.executeReturnFunction(null, null, null, + Arrays.asList(TValue.fromInt(3), TValue.fromInt(7)), null); + assertThat(tValue.toInt()).isBetween(3, 7 - 1); + } +} \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java index 137ff9bef..1763537ba 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class SizeTest { // TODO: Manage `Size` function without param. (today: we observe `Function not found`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, "0"); } @@ -48,7 +47,7 @@ class SizeTest { // " 😀 , 1 ", // " \uD83D\uDE00 , 1", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -58,7 +57,7 @@ class SizeTest { " 1 , 0 ", " 10 , 0 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -75,7 +74,7 @@ class SizeTest { " 1, 0 ", " null, 0 ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java b/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java index 049f0b531..5db56f0e9 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; @@ -8,14 +7,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class UpperTest { // TODO: Manage Upper function without param. (today: we observe `Function not found %upper`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterException { assertTimExpectedOutput(cut, ""); } @@ -44,7 +43,7 @@ class UpperTest { " é , É ", " 😀 , 😀 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +54,7 @@ class UpperTest { " 10 , 10 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -66,7 +65,7 @@ class UpperTest { " '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '{\"A\":[1,2],\"B\":\"ABC\",\"B\":TRUE}'", " true , TRUE ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/_TemplateStdlibTest.template b/test/net/sourceforge/plantuml/tim/stdlib/_TemplateStdlibTest.template index a949f6023..d85b08db0 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/_TemplateStdlibTest.template +++ b/test/net/sourceforge/plantuml/tim/stdlib/_TemplateStdlibTest.template @@ -1,8 +1,8 @@ package net.sourceforge.plantuml.tim.stdlib; -import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; +import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/test/nonreg/RenderViaApiTest.java b/test/nonreg/RenderViaApiTest.java new file mode 100644 index 000000000..295eb1a56 --- /dev/null +++ b/test/nonreg/RenderViaApiTest.java @@ -0,0 +1,56 @@ +package nonreg; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.util.Lists.newArrayList; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.io.PrintStream; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.SourceStringReader; +import net.sourceforge.plantuml.core.DiagramDescription; + +/** + * Tests the Render + */ +class RenderViaApiTest { + + @ParameterizedTest(name = "[{index}] {1}") + @CsvSource(nullValues = "null", value = { + "'@startuml\n!$a={\"k\": \"exampleValue\"}\ntitle $a.k\na -> b\n@enduml\n' , exampleValue", + "'@startuml\n!$a=[1, 2, 3]\ntitle xx $a[2] yy\na -> a\n@enduml' , xx 3 yy", + "'@startuml\ntitle\n!foreach $i in [1, 2, 3]\nxx $i yy\n!endfor\nendtitle\na -> a\n@enduml' , xx 2 yy", + "'@startuml\ntitle\n!foreach $i in [\"a\", \"b\", \"c\"]\nxx $i yy\n!endfor\nendtitle\na -> a\n@enduml' , xx b yy", + }) + void RenderTest(String input, String expected) throws Exception { + assertRenderExpectedOutput(input, expected); + } + + // TODO: to Factorize on a specific test package... + + private String RenderViaApiTest(String diagram, FileFormat format) throws IOException, UnsupportedEncodingException { + final SourceStringReader ssr = new SourceStringReader(diagram, UTF_8); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final DiagramDescription diagramDescription = ssr.outputImage(baos, 0, new FileFormatOption(format)); + final String rendered = new String(baos.toByteArray(), UTF_8); + // System.out.println(rendered); + return rendered; + } + + public void assertRenderExpectedOutput(String input, String expected) throws Exception { + final String rendered = RenderViaApiTest(input, FileFormat.PREPROC); + // OK with: + // final String rendered = RenderViaApiTest(input, FileFormat.UTXT); + assertThat(rendered).doesNotContain("syntax").contains(expected); + } +} diff --git a/test/nonreg/RenderViaPipeTest.java b/test/nonreg/RenderViaPipeTest.java new file mode 100644 index 000000000..9a76078b9 --- /dev/null +++ b/test/nonreg/RenderViaPipeTest.java @@ -0,0 +1,63 @@ +package nonreg; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.util.Lists.newArrayList; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import net.sourceforge.plantuml.ErrorStatus; +import net.sourceforge.plantuml.Option; +import net.sourceforge.plantuml.Pipe; + +/** + * Tests the Render + */ +class RenderViaPipeTest { + + @ParameterizedTest(name = "[{index}] {1}") + @CsvSource(nullValues = "null", value = { + "'@startuml\n!$a={\"k\": \"exampleValue\"}\ntitle $a.k\na -> b\n@enduml\n' , exampleValue", + "'@startuml\n!$a=[1, 2, 3]\ntitle xx $a[2] yy\na -> a\n' , xx 3 yy", + "'@startuml\ntitle\n!foreach $i in [1, 2, 3]\nxx $i yy\n!endfor\nendtitle\na -> a\n' , xx 2 yy", + "'@startuml\ntitle\n!foreach $i in [\"a\", \"b\", \"c\"]\nxx $i yy\n!endfor\nendtitle\na -> a\n' , xx b yy", + }) + void RenderTest(String input, String expected) throws Exception { + assertRenderExpectedOutput(input, expected); + } + + // TODO: to Factorize on a specific test package... + private static final String[] COMMON_OPTIONS = {"-preproc"}; + // OK with "-tutxt" + // private static final String[] COMMON_OPTIONS = {"-tutxt"}; + + private String[] optionArray(String... extraOptions) { + final List list = newArrayList(COMMON_OPTIONS); + Collections.addAll(list, extraOptions); + return list.toArray(new String[0]); + } + + private String renderViaPipe(String diagram, String... extraOptions) throws Exception { + final Option option = new Option(optionArray(extraOptions)); + final ByteArrayInputStream bais = new ByteArrayInputStream(diagram.getBytes(UTF_8)); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final Pipe pipe = new Pipe(option, new PrintStream(baos), bais, option.getCharset()); + pipe.managePipe(ErrorStatus.init()); + final String rendered = new String(baos.toByteArray(), UTF_8); + // System.out.println(rendered); + return rendered; + } + + public void assertRenderExpectedOutput(String input, String expected) throws Exception { + final String rendered = renderViaPipe(input); + assertThat(rendered).doesNotContain("syntax").contains(expected); + } +} diff --git a/test/nonreg/simple/A0003_Test.java b/test/nonreg/simple/A0003_Test.java index 5d78367bd..99bbf5888 100644 --- a/test/nonreg/simple/A0003_Test.java +++ b/test/nonreg/simple/A0003_Test.java @@ -29,6 +29,6 @@ public class A0003_Test extends BasicTest { @Test void testSimple() throws IOException { - checkImage("(Project)"); + checkImage("(Gantt)"); } } diff --git a/test/nonreg/simple/A0003_TestResult.java b/test/nonreg/simple/A0003_TestResult.java index 8bf3f0424..f37024c6e 100644 --- a/test/nonreg/simple/A0003_TestResult.java +++ b/test/nonreg/simple/A0003_TestResult.java @@ -5,7 +5,7 @@ public class A0003_TestResult { /* """ DPI: 96 -dimension: [ 367.7447 ; 76.0000 ] +dimension: [ 367.7447 ; 74.0000 ] scaleFactor: 2.0000 seed: 2061842952546013393 svgLinkTarget: _top @@ -13,8 +13,8 @@ hoverPathColorRGB: null preserveAspectRatio: none RECTANGLE: - pt1: [ 8.0000 ; 29.0000 ] - pt2: [ 16.0000 ; 59.0000 ] + pt1: [ 8.0000 ; 27.0000 ] + pt2: [ 16.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -23,8 +23,8 @@ RECTANGLE: backcolor: fff1e5e5 RECTANGLE: - pt1: [ 36.0000 ; 29.0000 ] - pt2: [ 44.0000 ; 59.0000 ] + pt1: [ 36.0000 ; 27.0000 ] + pt2: [ 44.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -33,8 +33,8 @@ RECTANGLE: backcolor: fff1e5e5 RECTANGLE: - pt1: [ 44.0000 ; 29.0000 ] - pt2: [ 72.0000 ; 59.0000 ] + pt1: [ 44.0000 ; 27.0000 ] + pt2: [ 72.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -43,8 +43,8 @@ RECTANGLE: backcolor: fffa8072 RECTANGLE: - pt1: [ 92.0000 ; 29.0000 ] - pt2: [ 100.0000 ; 59.0000 ] + pt1: [ 92.0000 ; 27.0000 ] + pt2: [ 100.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -53,8 +53,8 @@ RECTANGLE: backcolor: fff1e5e5 RECTANGLE: - pt1: [ 120.0000 ; 29.0000 ] - pt2: [ 128.0000 ; 59.0000 ] + pt1: [ 120.0000 ; 27.0000 ] + pt2: [ 128.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -63,8 +63,8 @@ RECTANGLE: backcolor: fff1e5e5 RECTANGLE: - pt1: [ 148.0000 ; 29.0000 ] - pt2: [ 156.0000 ; 59.0000 ] + pt1: [ 148.0000 ; 27.0000 ] + pt2: [ 156.0000 ; 57.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -76,7 +76,7 @@ TEXT: text: 43 position: [ 21.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR @@ -84,7 +84,7 @@ TEXT: text: 44 position: [ 49.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR @@ -92,7 +92,7 @@ TEXT: text: 45 position: [ 77.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR @@ -100,7 +100,7 @@ TEXT: text: 46 position: [ 105.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR @@ -108,7 +108,7 @@ TEXT: text: 47 position: [ 133.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR @@ -116,55 +116,55 @@ TEXT: text: 48 position: [ 161.0000 ; 23.7778 ] orientation: 0 - font: Serif.plain/10 [] + font: SansSerif.plain/10 [] color: ff000000 extendedColor: NULL_COLOR LINE: pt1: [ 16.0000 ; 16.0000 ] - pt2: [ 16.0000 ; 59.0000 ] + pt2: [ 16.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 44.0000 ; 16.0000 ] - pt2: [ 44.0000 ; 59.0000 ] + pt2: [ 44.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 72.0000 ; 16.0000 ] - pt2: [ 72.0000 ; 59.0000 ] + pt2: [ 72.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 100.0000 ; 16.0000 ] - pt2: [ 100.0000 ; 59.0000 ] + pt2: [ 100.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 128.0000 ; 16.0000 ] - pt2: [ 128.0000 ; 59.0000 ] + pt2: [ 128.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 156.0000 ; 16.0000 ] - pt2: [ 156.0000 ; 59.0000 ] + pt2: [ 156.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: pt1: [ 168.0000 ; 16.0000 ] - pt2: [ 168.0000 ; 59.0000 ] + pt2: [ 168.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 @@ -187,7 +187,7 @@ TEXT: text: Oct position: [ 17.4989 ; 9.3333 ] orientation: 0 - font: Serif.bold/12 [BOLD] + font: SansSerif.bold/12 [BOLD] color: ff000000 extendedColor: NULL_COLOR @@ -202,7 +202,7 @@ TEXT: text: Nov 2020 position: [ 72.7816 ; 9.3333 ] orientation: 0 - font: Serif.bold/12 [BOLD] + font: SansSerif.bold/12 [BOLD] color: ff000000 extendedColor: NULL_COLOR @@ -221,40 +221,40 @@ LINE: color: ffc0c0c0 LINE: - pt1: [ 0.0000 ; 29.0000 ] - pt2: [ 168.0000 ; 29.0000 ] + pt1: [ 0.0000 ; 27.0000 ] + pt2: [ 168.0000 ; 27.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: - pt1: [ 131.0000 ; 42.0000 ] - pt2: [ 131.0000 ; 51.5000 ] + pt1: [ 131.0000 ; 40.0000 ] + pt2: [ 131.0000 ; 49.5000 ] stroke: 0.0-0.0-1.5 shadow: 0 color: ff181818 LINE: - pt1: [ 131.0000 ; 51.5000 ] - pt2: [ 139.0000 ; 51.5000 ] + pt1: [ 131.0000 ; 49.5000 ] + pt2: [ 139.0000 ; 49.5000 ] stroke: 0.0-0.0-1.5 shadow: 0 color: ff181818 POLYGON: points: - - [ 135.0000 ; 47.5000 ] - - [ 135.0000 ; 51.5000 ] - - [ 135.0000 ; 55.5000 ] - - [ 139.0000 ; 51.5000 ] + - [ 135.0000 ; 45.5000 ] + - [ 135.0000 ; 49.5000 ] + - [ 135.0000 ; 53.5000 ] + - [ 139.0000 ; 49.5000 ] stroke: 0.0-0.0-1.5 shadow: 0 color: ff181818 backcolor: ff181818 RECTANGLE: - pt1: [ 2.0000 ; 31.0000 ] - pt2: [ 9.0000 ; 42.0000 ] + pt1: [ 2.0000 ; 29.0000 ] + pt2: [ 9.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -263,29 +263,29 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 2.0000 ; 31.0000 ] - pt2: [ 7.0000 ; 31.0000 ] + pt1: [ 2.0000 ; 29.0000 ] + pt2: [ 7.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 2.0000 ; 42.0000 ] - pt2: [ 7.0000 ; 42.0000 ] + pt1: [ 2.0000 ; 40.0000 ] + pt2: [ 7.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 2.0000 ; 31.0000 ] - pt2: [ 2.0000 ; 42.0000 ] + pt1: [ 2.0000 ; 29.0000 ] + pt2: [ 2.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 16.0000 ; 31.0000 ] - pt2: [ 37.0000 ; 42.0000 ] + pt1: [ 16.0000 ; 29.0000 ] + pt2: [ 37.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -294,22 +294,22 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 17.0000 ; 31.0000 ] - pt2: [ 36.0000 ; 31.0000 ] + pt1: [ 17.0000 ; 29.0000 ] + pt2: [ 36.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 17.0000 ; 42.0000 ] - pt2: [ 36.0000 ; 42.0000 ] + pt1: [ 17.0000 ; 40.0000 ] + pt2: [ 36.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 44.0000 ; 31.0000 ] - pt2: [ 65.0000 ; 42.0000 ] + pt1: [ 44.0000 ; 29.0000 ] + pt2: [ 65.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -318,22 +318,22 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 45.0000 ; 31.0000 ] - pt2: [ 64.0000 ; 31.0000 ] + pt1: [ 45.0000 ; 29.0000 ] + pt2: [ 64.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 45.0000 ; 42.0000 ] - pt2: [ 64.0000 ; 42.0000 ] + pt1: [ 45.0000 ; 40.0000 ] + pt2: [ 64.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 72.0000 ; 31.0000 ] - pt2: [ 93.0000 ; 42.0000 ] + pt1: [ 72.0000 ; 29.0000 ] + pt2: [ 93.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -342,22 +342,22 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 73.0000 ; 31.0000 ] - pt2: [ 92.0000 ; 31.0000 ] + pt1: [ 73.0000 ; 29.0000 ] + pt2: [ 92.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 73.0000 ; 42.0000 ] - pt2: [ 92.0000 ; 42.0000 ] + pt1: [ 73.0000 ; 40.0000 ] + pt2: [ 92.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 100.0000 ; 31.0000 ] - pt2: [ 121.0000 ; 42.0000 ] + pt1: [ 100.0000 ; 29.0000 ] + pt2: [ 121.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -366,22 +366,22 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 101.0000 ; 31.0000 ] - pt2: [ 120.0000 ; 31.0000 ] + pt1: [ 101.0000 ; 29.0000 ] + pt2: [ 120.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 101.0000 ; 42.0000 ] - pt2: [ 120.0000 ; 42.0000 ] + pt1: [ 101.0000 ; 40.0000 ] + pt2: [ 120.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 128.0000 ; 31.0000 ] - pt2: [ 138.0000 ; 42.0000 ] + pt1: [ 128.0000 ; 29.0000 ] + pt2: [ 138.0000 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -390,99 +390,99 @@ RECTANGLE: backcolor: ffe6e6fa LINE: - pt1: [ 129.0000 ; 31.0000 ] - pt2: [ 138.0000 ; 31.0000 ] + pt1: [ 129.0000 ; 29.0000 ] + pt2: [ 138.0000 ; 29.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 129.0000 ; 42.0000 ] - pt2: [ 138.0000 ; 42.0000 ] + pt1: [ 129.0000 ; 40.0000 ] + pt2: [ 138.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 138.0000 ; 31.0000 ] - pt2: [ 138.0000 ; 42.0000 ] + pt1: [ 138.0000 ; 29.0000 ] + pt2: [ 138.0000 ; 40.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 11.0000 ; 31.0000 ] - pt2: [ 13.0000 ; 31.0000 ] + pt1: [ 11.0000 ; 29.0000 ] + pt2: [ 13.0000 ; 29.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 11.0000 ; 42.0000 ] - pt2: [ 13.0000 ; 42.0000 ] + pt1: [ 11.0000 ; 40.0000 ] + pt2: [ 13.0000 ; 40.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 39.0000 ; 31.0000 ] - pt2: [ 41.0000 ; 31.0000 ] + pt1: [ 39.0000 ; 29.0000 ] + pt2: [ 41.0000 ; 29.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 39.0000 ; 42.0000 ] - pt2: [ 41.0000 ; 42.0000 ] + pt1: [ 39.0000 ; 40.0000 ] + pt2: [ 41.0000 ; 40.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 67.0000 ; 31.0000 ] - pt2: [ 69.0000 ; 31.0000 ] + pt1: [ 67.0000 ; 29.0000 ] + pt2: [ 69.0000 ; 29.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 67.0000 ; 42.0000 ] - pt2: [ 69.0000 ; 42.0000 ] + pt1: [ 67.0000 ; 40.0000 ] + pt2: [ 69.0000 ; 40.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 95.0000 ; 31.0000 ] - pt2: [ 97.0000 ; 31.0000 ] + pt1: [ 95.0000 ; 29.0000 ] + pt2: [ 97.0000 ; 29.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 95.0000 ; 42.0000 ] - pt2: [ 97.0000 ; 42.0000 ] + pt1: [ 95.0000 ; 40.0000 ] + pt2: [ 97.0000 ; 40.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 123.0000 ; 31.0000 ] - pt2: [ 125.0000 ; 31.0000 ] + pt1: [ 123.0000 ; 29.0000 ] + pt2: [ 125.0000 ; 29.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 LINE: - pt1: [ 123.0000 ; 42.0000 ] - pt2: [ 125.0000 ; 42.0000 ] + pt1: [ 123.0000 ; 40.0000 ] + pt2: [ 125.0000 ; 40.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ffadd8e6 RECTANGLE: - pt1: [ 142.0000 ; 46.0000 ] - pt2: [ 149.0000 ; 57.0000 ] + pt1: [ 142.0000 ; 44.0000 ] + pt2: [ 149.0000 ; 55.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -491,29 +491,29 @@ RECTANGLE: backcolor: ffe2e2f0 LINE: - pt1: [ 142.0000 ; 46.0000 ] - pt2: [ 147.0000 ; 46.0000 ] + pt1: [ 142.0000 ; 44.0000 ] + pt2: [ 147.0000 ; 44.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 142.0000 ; 57.0000 ] - pt2: [ 147.0000 ; 57.0000 ] + pt1: [ 142.0000 ; 55.0000 ] + pt2: [ 147.0000 ; 55.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 142.0000 ; 46.0000 ] - pt2: [ 142.0000 ; 57.0000 ] + pt1: [ 142.0000 ; 44.0000 ] + pt2: [ 142.0000 ; 55.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 RECTANGLE: - pt1: [ 156.0000 ; 46.0000 ] - pt2: [ 166.0000 ; 57.0000 ] + pt1: [ 156.0000 ; 44.0000 ] + pt2: [ 166.0000 ; 55.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -522,43 +522,43 @@ RECTANGLE: backcolor: ffe2e2f0 LINE: - pt1: [ 157.0000 ; 46.0000 ] - pt2: [ 166.0000 ; 46.0000 ] + pt1: [ 157.0000 ; 44.0000 ] + pt2: [ 166.0000 ; 44.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 157.0000 ; 57.0000 ] - pt2: [ 166.0000 ; 57.0000 ] + pt1: [ 157.0000 ; 55.0000 ] + pt2: [ 166.0000 ; 55.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 166.0000 ; 46.0000 ] - pt2: [ 166.0000 ; 57.0000 ] + pt1: [ 166.0000 ; 44.0000 ] + pt2: [ 166.0000 ; 55.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 151.0000 ; 46.0000 ] - pt2: [ 153.0000 ; 46.0000 ] + pt1: [ 151.0000 ; 44.0000 ] + pt2: [ 153.0000 ; 44.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ff181818 LINE: - pt1: [ 151.0000 ; 57.0000 ] - pt2: [ 153.0000 ; 57.0000 ] + pt1: [ 151.0000 ; 55.0000 ] + pt2: [ 153.0000 ; 55.0000 ] stroke: 2.0-3.0-1.0 shadow: 0 color: ff181818 TEXT: text: Prototype design - position: [ 142.0000 ; 39.5556 ] + position: [ 142.0000 ; 37.5556 ] orientation: 0 font: SansSerif.plain/11 [] color: ff000000 @@ -566,59 +566,59 @@ TEXT: TEXT: text: Testing - position: [ 170.0000 ; 54.5556 ] + position: [ 170.0000 ; 52.5556 ] orientation: 0 font: SansSerif.plain/11 [] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 0.0000 ; 59.0000 ] - pt2: [ 168.0000 ; 59.0000 ] + pt1: [ 0.0000 ; 57.0000 ] + pt2: [ 168.0000 ; 57.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: - pt1: [ 0.0000 ; 59.0000 ] - pt2: [ 0.0000 ; 75.0000 ] + pt1: [ 0.0000 ; 57.0000 ] + pt2: [ 0.0000 ; 73.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 LINE: - pt1: [ 68.0000 ; 59.0000 ] - pt2: [ 68.0000 ; 75.0000 ] + pt1: [ 68.0000 ; 57.0000 ] + pt2: [ 68.0000 ; 73.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 TEXT: text: Oct - position: [ 17.4989 ; 68.3333 ] + position: [ 17.4989 ; 66.3333 ] orientation: 0 - font: Serif.bold/12 [BOLD] + font: SansSerif.bold/12 [BOLD] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 168.0000 ; 59.0000 ] - pt2: [ 168.0000 ; 75.0000 ] + pt1: [ 168.0000 ; 57.0000 ] + pt2: [ 168.0000 ; 73.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 TEXT: text: Nov 2020 - position: [ 72.7816 ; 68.3333 ] + position: [ 72.7816 ; 66.3333 ] orientation: 0 - font: Serif.bold/12 [BOLD] + font: SansSerif.bold/12 [BOLD] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 0.0000 ; 75.0000 ] - pt2: [ 168.0000 ; 75.0000 ] + pt1: [ 0.0000 ; 73.0000 ] + pt2: [ 168.0000 ; 73.0000 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ffc0c0c0 diff --git a/test/nonreg/xmi/XmiTest.java b/test/nonreg/xmi/XmiTest.java index db85e694d..760a2ae6a 100644 --- a/test/nonreg/xmi/XmiTest.java +++ b/test/nonreg/xmi/XmiTest.java @@ -12,9 +12,12 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.atomic.AtomicInteger; + +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.builder.Input; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.ElementSelectors; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; @@ -30,44 +33,31 @@ public class XmiTest { final String star = removeVersion(runPlantUML(expectedDescription, FileFormat.XMI_STAR)); final String starExpected = readStringFromSourceFile(getDiagramFile(), "{{{star", "}}}star"); - // This is really a hack. Since XML generation does not guarantee the order of - // attributes, we make an easy to do check by sorting characters. - // Of course, this is really incomplete: a faulty String may match the expected - // result if, for example, an attribute is moved from a node to another. - // However, we consider that it is a good start. - if (sortString(star).equals(sortString(starExpected)) == false) { - assertEquals(starExpected, star, "XmiStar: Generated GraphML is not ok"); - } + assertXMIEqual(star, starExpected); final String argo = removeVersion(runPlantUML(expectedDescription, FileFormat.XMI_ARGO)); final String argoExpected = readStringFromSourceFile(getDiagramFile(), "{{{argo", "}}}argo"); - if (sortString(argo).equals(sortString(argoExpected)) == false) { - assertEquals(argoExpected, argo, "XmiArgo: Generated GraphML is not ok"); - } + assertXMIEqual(argo, argoExpected); + } + private void assertXMIEqual(final String actual, final String expected) { + // XMI is XML, so we can just use the xmlunit diffbuilder + // Compare elements with the same xmi ID + // checkForSimilar required to ignore order + Diff diff = DiffBuilder.compare(Input.fromString(actual)).withTest(Input.fromString(expected)) + .ignoreWhitespace().ignoreComments().checkForSimilar() + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAttributes("xmi.id"))).build(); + + if (diff.hasDifferences()) { + assertTrue(false, diff.fullDescription()); + } } private String removeVersion(String xmi) { return xmi.replaceFirst("\\.*\\", ""); } - private String sortString(String s) { - final Map map = new TreeMap<>(); - for (int i = 0; i < s.length(); i++) { - final char ch = s.charAt(i); - // We ignore non writable characters - if (ch <= ' ') - continue; - - AtomicInteger count = map.get(ch); - if (count == null) - map.put(ch, new AtomicInteger(1)); - else - count.addAndGet(1); - } - return map.toString(); - } private String getLocalFolder() { return "test/" + getPackageName().replace(".", "/"); diff --git a/test/test/example/TestExample.java b/test/test/example/TestExample.java new file mode 100644 index 000000000..eeedbb088 --- /dev/null +++ b/test/test/example/TestExample.java @@ -0,0 +1,23 @@ +package test.example; + +import static test.utils.PlantUmlTestUtils.exportDiagram; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class TestExample { + + @Test + public void test_help_themes() throws Exception { + + final String output = exportDiagram( + "@startuml", + "help themes", + "@enduml" + ).asString(); + + assertThat(output) + .contains("Help on themes") + .contains("bluegray", "hacker"); + } +} \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/test/ImageTestUtils.java b/test/test/utils/ImageTestUtils.java similarity index 98% rename from test/net/sourceforge/plantuml/test/ImageTestUtils.java rename to test/test/utils/ImageTestUtils.java index cd989f3a7..21dcd284a 100644 --- a/test/net/sourceforge/plantuml/test/ImageTestUtils.java +++ b/test/test/utils/ImageTestUtils.java @@ -1,4 +1,4 @@ -package net.sourceforge.plantuml.test; +package test.utils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/test/net/sourceforge/plantuml/test/ImageTestUtilsTest.java b/test/test/utils/ImageTestUtilsTest.java similarity index 93% rename from test/net/sourceforge/plantuml/test/ImageTestUtilsTest.java rename to test/test/utils/ImageTestUtilsTest.java index 5d96a85a7..c29cb1687 100644 --- a/test/net/sourceforge/plantuml/test/ImageTestUtilsTest.java +++ b/test/test/utils/ImageTestUtilsTest.java @@ -1,9 +1,9 @@ -package net.sourceforge.plantuml.test; +package test.utils; -import static net.sourceforge.plantuml.test.ImageTestUtils.assertImageSizeEqual; -import static net.sourceforge.plantuml.test.ImageTestUtils.assertImagesEqual; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import static test.utils.ImageTestUtils.assertImageSizeEqual; +import static test.utils.ImageTestUtils.assertImagesEqual; import java.awt.image.BufferedImage; diff --git a/test/net/sourceforge/plantuml/test/JunitUtils.java b/test/test/utils/JunitUtils.java similarity index 95% rename from test/net/sourceforge/plantuml/test/JunitUtils.java rename to test/test/utils/JunitUtils.java index 8064ba1fc..e0b6add41 100644 --- a/test/net/sourceforge/plantuml/test/JunitUtils.java +++ b/test/test/utils/JunitUtils.java @@ -1,4 +1,4 @@ -package net.sourceforge.plantuml.test; +package test.utils; import org.junit.jupiter.params.converter.ArgumentConversionException; import org.junit.jupiter.params.converter.SimpleArgumentConverter; diff --git a/test/net/sourceforge/plantuml/test/PlantUmlTestUtils.java b/test/test/utils/PlantUmlTestUtils.java similarity index 98% rename from test/net/sourceforge/plantuml/test/PlantUmlTestUtils.java rename to test/test/utils/PlantUmlTestUtils.java index e4bac23ce..f1f5774ad 100644 --- a/test/net/sourceforge/plantuml/test/PlantUmlTestUtils.java +++ b/test/test/utils/PlantUmlTestUtils.java @@ -1,4 +1,4 @@ -package net.sourceforge.plantuml.test; +package test.utils; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; diff --git a/test/net/sourceforge/plantuml/test/StringTestUtils.java b/test/test/utils/StringTestUtils.java similarity index 96% rename from test/net/sourceforge/plantuml/test/StringTestUtils.java rename to test/test/utils/StringTestUtils.java index 2248dc201..df3705a85 100644 --- a/test/net/sourceforge/plantuml/test/StringTestUtils.java +++ b/test/test/utils/StringTestUtils.java @@ -1,4 +1,4 @@ -package net.sourceforge.plantuml.test; +package test.utils; import static java.util.Objects.requireNonNull; diff --git a/test/net/sourceforge/plantuml/test/TestUtils.java b/test/test/utils/TestUtils.java similarity index 89% rename from test/net/sourceforge/plantuml/test/TestUtils.java rename to test/test/utils/TestUtils.java index 2506ddf4a..d381f545e 100644 --- a/test/net/sourceforge/plantuml/test/TestUtils.java +++ b/test/test/utils/TestUtils.java @@ -1,4 +1,4 @@ -package net.sourceforge.plantuml.test; +package test.utils; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/themes/puml-theme-sunlust.puml b/themes/puml-theme-sunlust.puml new file mode 100644 index 000000000..9001ba947 --- /dev/null +++ b/themes/puml-theme-sunlust.puml @@ -0,0 +1,133 @@ +'' NAME = Sunlust +'' DESCRIPTION = sunlust theme based off of the [solarized theme](https://ethanschoonover.com/solarized) +'' AUTHOR = Artem V. Ageev +'' LICENCE = GPL 3+ + +!$THEME = 'sunlust' +!if %not(%variable_exists("$BGCOLOR")) +!$BGCOLOR = '#fdf6e3' +!endif +scale max 2000 * 2000 +!$colors = { + "font" : "#657b83", + "bg" : "#fdf6e3", + "yellow" : "#b58900", + "yellow_bg" : "#BUSINESS", + "orange" : "#cb4b16", + "orange_bg" : "#STRATEGY", + "red" : "#dc322f", + "red_bg" : "#IMPLEMENTATION", + "violet" : "#6c71c4", + "violet_bg" : "#MOTIVATION", + "blue" : "#268bd2", + "blue_bg" : "#APPLICATION", + "green" : "#859900", + "green_bg" : "#TECHNOLOGY" +} +!$shapes = { + "TECHNOLOGY" : { + "color" : "#859900", + "shapes" : [ "Node", "File"] + }, + "APPLICATION" : { + "color" : "#268bd2", + "shapes" : [ "Participant", "Rectangle", "Component" ] + }, + "BUSINESS" : { + "color" : "#b58900", + "shapes" : [ "Actor", "Note", "Hexagon", "Boundary", "Control", "Entity" ] + }, + "IMPLEMENTATION" : { + "color" : "#dc322f", + "shapes" : [ "Class", "Map", "Json" ] + }, + "MOTIVATION" : { + "color" : "#6c71c4", + "shapes" : [ "Cloud", "Frame", "Collections", "Database", "Queue" ] + }, + "STRATEGY" : { + "color" : "#STRATEGY", + "shapes" : [ "Partition", "Folder", "Card" ] + } +} +!$thickness = 2 + +skinparam { + noteTextAlignment left + actorStyle awesome + Dpi 100 + Shadowing false + BackgroundColor $colors.bg + WrapWidth 200 + RoundCorner 15 + Swimlane { + BorderColor $colors.font + Thickness $thickness + WrapTitleWidth 150 + } + Arrow { + Color $colors.font + Thickness $thickness + } + Default { + TextAlignment center + FontName Dejavu Serif + } + Legend { + FontName VL Gothic + BorderColor transparent + BackgroundColor transparent + } + Sequence { + MessageAlign direction + ArrowThickness $thickness + LifeLineBorderColor $colors.yellow + BoxBorderThickness $thickness + } + !foreach $shape in %splitstr('Activity.State', '.') + $shape { + BackgroundColor transparent + Border { + Color $colors.violet + Thickness $thickness + } + Diamond { + BorderColor $colors.red + BackgroundColor transparent + } + } + !endfor + !foreach $key in %get_json_keys($shapes) + !foreach $shape in $shapes[$key].shapes + $shape { + BackgroundColor #$key + Border { + Color $shapes[$key].color + Thickness $thickness + } + } + !endfor + !endfor +}