diff --git a/.config/pmd/ruleset.xml b/.config/pmd/ruleset.xml index 667f74e..7a03f17 100644 --- a/.config/pmd/ruleset.xml +++ b/.config/pmd/ruleset.xml @@ -151,5 +151,12 @@ + + + + + + + diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index c17c397..8f98f1a 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -11,6 +11,7 @@ permissions: jobs: link-checker: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v4 @@ -19,6 +20,8 @@ jobs: - name: Link Checker id: lychee uses: lycheeverse/lychee-action@v2 + with: + fail: false # Don't fail on broken links, create an issue instead - name: Find already existing issue id: find-issue diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 9c43d4f..973e7d8 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -26,6 +26,7 @@ env: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 strategy: matrix: @@ -82,6 +83,7 @@ jobs: checkstyle: runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} + timeout-minutes: 15 strategy: matrix: @@ -104,6 +106,7 @@ jobs: pmd: runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} + timeout-minutes: 15 strategy: matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bf3805..236c0f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,7 @@ permissions: jobs: check-code: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -48,6 +49,7 @@ jobs: prepare-release: runs-on: ubuntu-latest needs: [check-code] + timeout-minutes: 10 outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: @@ -109,6 +111,7 @@ jobs: publish-maven: runs-on: ubuntu-latest needs: [prepare-release] + timeout-minutes: 60 steps: - uses: actions/checkout@v4 @@ -140,6 +143,7 @@ jobs: publish-pages: runs-on: ubuntu-latest needs: [prepare-release] + timeout-minutes: 15 steps: - uses: actions/checkout@v4 @@ -169,6 +173,7 @@ jobs: after-release: runs-on: ubuntu-latest needs: [publish-maven] + timeout-minutes: 10 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index b38f0d8..df6dbb7 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -27,6 +27,7 @@ jobs: token-check: runs-on: ubuntu-latest if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }} + timeout-minutes: 5 outputs: hasToken: ${{ steps.check-token.outputs.has }} steps: @@ -40,6 +41,7 @@ jobs: runs-on: ubuntu-latest needs: token-check if: ${{ needs.token-check.outputs.hasToken }} + timeout-minutes: 30 steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index ff880f0..c9d7ec7 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -14,6 +14,7 @@ permissions: jobs: labels: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index e3ed038..03f5339 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -9,6 +9,7 @@ env: jobs: publish-maven: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/update-from-template.yml b/.github/workflows/update-from-template.yml index aa33de4..6f9497e 100644 --- a/.github/workflows/update-from-template.yml +++ b/.github/workflows/update-from-template.yml @@ -31,6 +31,7 @@ permissions: jobs: update: runs-on: ubuntu-latest + timeout-minutes: 60 outputs: update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }} create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }} @@ -180,6 +181,7 @@ jobs: needs: [update] if: needs.update.outputs.create_update_branch_merged_pr == 1 runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v4 with: diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index eb3fcd8..5f35e01 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,7 +1,7 @@ - 10.15.0 + 10.20.1 JavaOnlyWithTests true true diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a4854f..297ded3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.4.0 +* PointStyle can also contain non-string constants #280 +* Use ``CoreInteractionOptions`` for ``Options#interaction`` and ``Options#hover`` #281 +* Updated dependencies + ## 2.3.1 * Synced ``LineOptions/DataSet`` ``stepped`` and ``tension`` with ChartJS source #262 * Updated dependencies diff --git a/chartjs-java-model-demo/pom.xml b/chartjs-java-model-demo/pom.xml index 3a84f7f..80e0232 100644 --- a/chartjs-java-model-demo/pom.xml +++ b/chartjs-java-model-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev chartjs-java-model-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT chartjs-java-model-demo - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar diff --git a/chartjs-java-model-demo/src/main/java/software/xdev/Application.java b/chartjs-java-model-demo/src/main/java/software/xdev/Application.java index 3d16e65..4dc8b3d 100644 --- a/chartjs-java-model-demo/src/main/java/software/xdev/Application.java +++ b/chartjs-java-model-demo/src/main/java/software/xdev/Application.java @@ -45,7 +45,7 @@ private static void createAndOpenTestFile(final Chart chart) + "\n" + "\t\n" + "\t\t\n" - + "\t\t\n" + + "\t\t\n" + "\t\n" + "\t\n" + "\t\t\n" diff --git a/chartjs-java-model/pom.xml b/chartjs-java-model/pom.xml index 78eff27..d2e6830 100644 --- a/chartjs-java-model/pom.xml +++ b/chartjs-java-model/pom.xml @@ -6,7 +6,7 @@ software.xdev chartjs-java-model - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT jar chartjs-java-model @@ -50,7 +50,7 @@ 2.0.16 2.24.1 - 1.20.2 + 1.20.3 true @@ -95,7 +95,7 @@ com.fasterxml.jackson.core jackson-databind - 2.18.0 + 2.18.1 @@ -129,7 +129,7 @@ org.junit.jupiter junit-jupiter - 5.11.2 + 5.11.3 test @@ -162,7 +162,7 @@ software.xdev testcontainers-selenium - 1.0.2 + 1.1.0 test @@ -170,7 +170,7 @@ org.seleniumhq.selenium selenium-chrome-driver - 4.25.0 + 4.26.0 test @@ -193,7 +193,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.7.0 + 3.8.0 @@ -241,7 +241,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.10.1 + 3.11.1 attach-javadocs @@ -274,7 +274,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.1 + 3.5.2 ${skipTests} @@ -355,12 +355,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.5.0 + 3.6.0 com.puppycrawl.tools checkstyle - 10.18.2 + 10.20.1 @@ -385,7 +385,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.25.0 + 3.26.0 true true @@ -397,12 +397,12 @@ net.sourceforge.pmd pmd-core - 7.6.0 + 7.7.0 net.sourceforge.pmd pmd-java - 7.6.0 + 7.7.0 @@ -414,7 +414,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.5.0 + 3.6.0 diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BarDataset.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BarDataset.java index 051ec6f..44a4b22 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BarDataset.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BarDataset.java @@ -18,7 +18,6 @@ import java.util.List; import software.xdev.chartjs.model.enums.BorderSkipped; -import software.xdev.chartjs.model.enums.PointStyle; import software.xdev.chartjs.model.objects.OptionalArray; @@ -35,7 +34,7 @@ public class BarDataset extends BackgroundBorderHoverDataset protected Object barThickness; protected Number maxBarThickness; protected Number minBarLength; - protected PointStyle pointStyle; + protected Object pointStyle; protected Boolean grouped; protected final List borderSkipped = new OptionalArray<>(); @@ -123,12 +122,12 @@ public BarDataset setMinBarLength(final Number minBarLength) return this; } - public PointStyle getPointStyle() + public Object getPointStyle() { return this.pointStyle; } - public BarDataset setPointStyle(final PointStyle pointStyle) + public BarDataset setPointStyle(final Object pointStyle) { this.pointStyle = pointStyle; return this; diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BubbleDataset.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BubbleDataset.java index 92aab9c..2504a57 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BubbleDataset.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BubbleDataset.java @@ -18,7 +18,6 @@ import java.util.List; import software.xdev.chartjs.model.datapoint.BubbleDataPoint; -import software.xdev.chartjs.model.enums.PointStyle; import software.xdev.chartjs.model.objects.OptionalArray; @@ -32,7 +31,7 @@ public class BubbleDataset extends BackgroundBorderHoverDataset hoverRadius = new OptionalArray<>(); - protected PointStyle pointStyle; + protected Object pointStyle; @Override protected String defaultType() @@ -95,12 +94,12 @@ public List getHoverRadius() return this.hoverRadius; } - public PointStyle getPointStyle() + public Object getPointStyle() { return this.pointStyle; } - public BubbleDataset setPointStyle(final PointStyle pointStyle) + public BubbleDataset setPointStyle(final Object pointStyle) { this.pointStyle = pointStyle; return this; diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/PointDataset.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/PointDataset.java index 87ad4fc..361d037 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/PointDataset.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/PointDataset.java @@ -20,7 +20,6 @@ import software.xdev.chartjs.model.enums.BorderCapStyle; import software.xdev.chartjs.model.enums.BorderJoinStyle; -import software.xdev.chartjs.model.enums.PointStyle; import software.xdev.chartjs.model.objects.OptionalArray; import software.xdev.chartjs.model.options.elements.Fill; @@ -63,7 +62,7 @@ public abstract class PointDataset, O> extends Dataset pointHoverBorderWidth = new OptionalArray<>(); - private final List pointStyle = new OptionalArray<>(); + private final List pointStyle = new OptionalArray<>(); /** * @see #setFill(Fill) @@ -528,7 +527,7 @@ public T setPointHoverBorderWidth(final List pointHoverBorderWidth) /** * @see #setPointStyle(List) */ - public List getPointStyle() + public List getPointStyle() { return this.pointStyle; } @@ -536,7 +535,7 @@ public List getPointStyle() /** * @see #setPointStyle(List) */ - public T addPointStyle(final PointStyle pointStyle) + public T addPointStyle(final Object pointStyle) { this.pointStyle.add(pointStyle); return this.self(); @@ -547,7 +546,7 @@ public T addPointStyle(final PointStyle pointStyle) * and * 'dash'. If the option is an image, that image is drawn on the canvas using drawImage. */ - public T setPointStyle(final List pointStyle) + public T setPointStyle(final List pointStyle) { this.pointStyle.clear(); if(pointStyle != null) diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/PointStyle.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/PointStyle.java index f00696d..173269f 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/PointStyle.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/PointStyle.java @@ -20,18 +20,23 @@ import software.xdev.chartjs.model.EnumNameToCamelCase; +/** + * @apiNote Only contains the (string) constants. Other valid values are e.g. false, an image element or a + * canvas element. + * @see ChartJS Source + */ public enum PointStyle { CIRCLE, - TRIANGLE, + CROSS, + CROSS_ROT, + DASH, + LINE, RECT, RECT_ROUNDED, RECT_ROT, - CROSS, - CROSS_ROT, STAR, - LINE, - DASH; + TRIANGLE; @JsonValue @Override diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/CoreInteractionOptions.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/CoreInteractionOptions.java new file mode 100644 index 0000000..5145f8b --- /dev/null +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/CoreInteractionOptions.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed 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. + */ +package software.xdev.chartjs.model.options; + +/** + * @see ChartJS Source + */ +public class CoreInteractionOptions +{ + protected String mode; + protected Boolean intersect; + protected String axis; + protected Boolean includeInvisible; + + public String getMode() + { + return this.mode; + } + + public CoreInteractionOptions setMode(final String mode) + { + this.mode = mode; + return this; + } + + public Boolean getIntersect() + { + return this.intersect; + } + + public CoreInteractionOptions setIntersect(final Boolean intersect) + { + this.intersect = intersect; + return this; + } + + public String getAxis() + { + return this.axis; + } + + public CoreInteractionOptions setAxis(final String axis) + { + this.axis = axis; + return this; + } + + public Boolean getIncludeInvisible() + { + return this.includeInvisible; + } + + public CoreInteractionOptions setIncludeInvisible(final Boolean includeInvisible) + { + this.includeInvisible = includeInvisible; + return this; + } +} diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Hover.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Hover.java deleted file mode 100644 index f078fe9..0000000 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Hover.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2023 XDEV Software (https://xdev.software) - * - * Licensed 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. - */ -package software.xdev.chartjs.model.options; - -import software.xdev.chartjs.model.enums.HoverMode; -import software.xdev.chartjs.model.javascript.JavaScriptFunction; - - -public class Hover -{ - protected HoverMode mode; - protected JavaScriptFunction onHover; - - /** - * @see #setMode(HoverMode) - */ - public HoverMode getMode() - { - return this.mode; - } - - /** - *

- * Default {@code single} - *

- * - *

- * Sets which elements hover. Acceptable options are 'single', 'label', 'x-axis', or 'dataset'. - *

- *
    - *
  • {@code single} highlights the closest element. - *
  • {@code label} highlights elements in all datasets at the same X value. - *
  • {@code x-axis} also highlights elements in all datasets at the same X - * value, but activates when hovering anywhere within the vertical slice of - * the x-axis representing that X value. - *
  • {@code dataset} highlights the closest dataset. - *
- */ - public Hover setMode(final HoverMode mode) - { - this.mode = mode; - return this; - } - - /** - * @see #setOnHover(JavaScriptFunction) - */ - public JavaScriptFunction getOnHover() - { - return this.onHover; - } - - /** - * Default {@code null}
- *

- * Called when any of the events fire. Called in the context of the chart and passed an array of active elements - * (bars, points, etc) - */ - public Hover setOnHover(final JavaScriptFunction onHover) - { - this.onHover = onHover; - return this; - } -} diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java index 309d13e..9afdc3a 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java @@ -40,7 +40,8 @@ public class Options, A extends Animation> protected JavaScriptFunction onClick; protected JavaScriptFunction legendCallback; protected JavaScriptFunction onResize; - protected Hover hover; + protected CoreInteractionOptions interaction; + protected CoreInteractionOptions hover; protected Animations animations; protected Boolean animation = true; protected Layout layout; @@ -215,10 +216,18 @@ public T setOnResize(final JavaScriptFunction onResize) return this.self(); } - /** - * @see #setHover(Hover) - */ - public Hover getHover() + public CoreInteractionOptions getInteraction() + { + return this.interaction; + } + + public T setInteraction(final CoreInteractionOptions interaction) + { + this.interaction = interaction; + return this.self(); + } + + public CoreInteractionOptions getHover() { return this.hover; } @@ -227,7 +236,7 @@ public Hover getHover() * The hover configuration is passed into the options.hover namespace. The global hover configuration is at * Chart.defaults.global.hover. */ - public T setHover(final Hover hover) + public T setHover(final CoreInteractionOptions hover) { this.hover = hover; return this.self(); diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/elements/Point.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/elements/Point.java index e3ec6fd..11d84ed 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/elements/Point.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/elements/Point.java @@ -15,9 +15,6 @@ */ package software.xdev.chartjs.model.options.elements; -import software.xdev.chartjs.model.enums.PointStyle; - - /** *

* Point elements are used to represent the points in a line chart or a bubble chart. @@ -26,12 +23,13 @@ * When set, these options apply to all objects of that type unless specifically overridden by the configuration * attached to a dataset. *

+ * @see ChartJS Source */ public class Point { protected Integer radius; - protected PointStyle pointStyle; + protected Object pointStyle; protected Object backgroundColor; @@ -68,24 +66,17 @@ public Point setRadius(final Integer radius) return this; } - /** - * @see #setPointStyle(PointStyle) - */ - public PointStyle getPointStyle() + public Object getPointStyle() { return this.pointStyle; } /** - *

- * Default point style - *

- * *

* Default {@code 'circle'} *

*/ - public Point setPointStyle(final PointStyle pointStyle) + public Point setPointStyle(final Object pointStyle) { this.pointStyle = pointStyle; return this; diff --git a/chartjs-java-model/src/test/resources/test-template.html b/chartjs-java-model/src/test/resources/test-template.html index 0a54b07..9aa08cd 100644 --- a/chartjs-java-model/src/test/resources/test-template.html +++ b/chartjs-java-model/src/test/resources/test-template.html @@ -2,7 +2,7 @@ - + diff --git a/pom.xml b/pom.xml index a759ab6..7d7209c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev chartjs-java-model-root - 2.3.2-SNAPSHOT + 2.4.0-SNAPSHOT pom @@ -40,12 +40,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.5.0 + 3.6.0 com.puppycrawl.tools checkstyle - 10.18.2 + 10.20.1 @@ -70,7 +70,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.25.0 + 3.26.0 true true @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.6.0 + 7.7.0 net.sourceforge.pmd pmd-java - 7.6.0 + 7.7.0 @@ -99,7 +99,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.5.0 + 3.6.0