diff --git a/CHANGELOG.md b/CHANGELOG.md index 018bf0f3..6a060cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.6.0 +* Synced ``Doughnut/PieOptions`` from ChartJS source code #293 +* Synced ``GridLineConfiguration`` from ChartJS source code / improved Types for more options #289 +* Updated dependencies + ## 2.5.0 * Synced ``Legend`` from ChartJS source code #285 diff --git a/chartjs-java-model-demo/pom.xml b/chartjs-java-model-demo/pom.xml index 15d5cea2..7a5aa258 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.5.1-SNAPSHOT + 2.6.0-SNAPSHOT chartjs-java-model-demo - 2.5.1-SNAPSHOT + 2.6.0-SNAPSHOT jar diff --git a/chartjs-java-model/pom.xml b/chartjs-java-model/pom.xml index a7f45308..e5e1feb2 100644 --- a/chartjs-java-model/pom.xml +++ b/chartjs-java-model/pom.xml @@ -6,7 +6,7 @@ software.xdev chartjs-java-model - 2.5.1-SNAPSHOT + 2.6.0-SNAPSHOT jar chartjs-java-model @@ -49,8 +49,8 @@ UTF-8 2.0.16 - 2.24.1 - 1.20.3 + 2.24.2 + 1.20.4 true @@ -95,7 +95,7 @@ com.fasterxml.jackson.core jackson-databind - 2.18.1 + 2.18.2 @@ -170,7 +170,7 @@ org.seleniumhq.selenium selenium-chrome-driver - 4.26.0 + 4.27.0 test @@ -245,7 +245,7 @@ attach-javadocs - verify + package jar @@ -263,7 +263,7 @@ attach-sources - verify + package jar-no-fork @@ -360,7 +360,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 @@ -397,12 +397,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0 diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptions.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptions.java index 4575c537..fa9b109b 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptions.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptions.java @@ -16,100 +16,8 @@ package software.xdev.chartjs.model.options; import software.xdev.chartjs.model.options.animation.DoughnutAnimation; -import software.xdev.chartjs.model.options.elements.ArcElements; -public class DoughnutOptions extends Options +public class DoughnutOptions extends DoughnutOptionsBase { - /** - * Default {@code 50} - * - * @see #setCutout(Number cutout) - */ - protected Number cutout; - - /** - * Rotation in degrees. Default {@code 0}. {@code 0} is at the top. - * - * @see #setRotation(Number rotation) - */ - protected Number rotation; - - /** - * Circumference in degrees. Default {@code 360}. - * - * @see #setCircumference(Number circumference) - */ - protected Number circumference; - - protected ArcElements elements; - - /** - * @see #setCutout(Number cutoutPercentage) - */ - public Number getCutout() - { - return this.cutout; - } - - /** - * The pixels as number of the chart that is cut out of the middle. - */ - public DoughnutOptions setCutout(final Number cutout) - { - this.cutout = cutout; - return this; - } - - /** - * @see #setRotation(Number rotation) - */ - public Number getRotation() - { - return this.rotation; - } - - /** - * Starting angle to draw arcs from in degrees - */ - public DoughnutOptions setRotation(final Number rotation) - { - this.rotation = rotation; - return this; - } - - /** - * @see #setCircumference(Number circumference) - */ - public Number getCircumference() - { - return this.circumference; - } - - /** - * Sweep to allow arcs to cover in degrees - */ - public DoughnutOptions setCircumference(final Number circumference) - { - this.circumference = circumference; - return this; - } - - /** - * @return {@link ArcElements} instance, or {@code null} if not set - */ - public ArcElements getElements() - { - return this.elements; - } - - /** - * @param elements an {@link ArcElements} instance, or {@code null} - * @return this instance for method chaining - */ - public DoughnutOptions setElements(final ArcElements elements) - { - this.elements = elements; - return this; - } } diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptionsBase.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptionsBase.java new file mode 100644 index 00000000..ceca81df --- /dev/null +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptionsBase.java @@ -0,0 +1,99 @@ +/* + * 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.options.animation.DoughnutAnimationBase; + + +/** + * @see ChartJS Source + */ +public abstract class DoughnutOptionsBase, A extends DoughnutAnimationBase> + extends Options +{ + protected Number circumference; + protected Object cutout; // number or string + protected Object offset; // number or number[] + protected Object radius; // number or string + protected Number rotation; + protected Number spacing; + + public Number getCircumference() + { + return this.circumference; + } + + public DoughnutOptionsBase setCircumference(final Number circumference) + { + this.circumference = circumference; + return this.self(); + } + + public Object getCutout() + { + return this.cutout; + } + + public DoughnutOptionsBase setCutout(final Object cutout) + { + this.cutout = cutout; + return this.self(); + } + + public Object getOffset() + { + return this.offset; + } + + public DoughnutOptionsBase setOffset(final Object offset) + { + this.offset = offset; + return this.self(); + } + + public Object getRadius() + { + return this.radius; + } + + public DoughnutOptionsBase setRadius(final Object radius) + { + this.radius = radius; + return this.self(); + } + + public Number getRotation() + { + return this.rotation; + } + + public DoughnutOptionsBase setRotation(final Number rotation) + { + this.rotation = rotation; + return this.self(); + } + + public Number getSpacing() + { + return this.spacing; + } + + public DoughnutOptionsBase setSpacing(final Number spacing) + { + this.spacing = spacing; + return this.self(); + } +} 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 9afdc3ac..b82f5b07 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 @@ -28,7 +28,10 @@ /** - * @see ChartJS Source + * @see + * ChartJS Source (Options) + * @see + * ChartJS Source (AnimationOptons) */ public class Options, A extends Animation> { @@ -43,7 +46,7 @@ public class Options, A extends Animation> protected CoreInteractionOptions interaction; protected CoreInteractionOptions hover; protected Animations animations; - protected Boolean animation = true; + protected Object animation; // Usually a boolean or of Type protected Layout layout; protected Plugins plugins = new Plugins(); @@ -89,18 +92,12 @@ public T setResponsive(final Boolean responsive) return this.self(); } - /** - * @see #setAnimation(Boolean) - */ - public Boolean getAnimation() + public Object getAnimation() { return this.animation; } - /** - * Default {@code true} Disables the Animation completely if set to {@code false}. - */ - public T setAnimation(final Boolean animation) + public T setAnimation(final Object animation) { this.animation = animation; return this.self(); diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PieOptions.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PieOptions.java index 5d90e687..020d7bd3 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PieOptions.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PieOptions.java @@ -16,101 +16,8 @@ package software.xdev.chartjs.model.options; import software.xdev.chartjs.model.options.animation.PieAnimation; -import software.xdev.chartjs.model.options.elements.ArcElements; -public class PieOptions extends Options +public class PieOptions extends DoughnutOptionsBase { - - /** - * Default {@code 50 - for doughnut, 0 - for pie} - * - * @see #setCutoutPercentage(Number cutoutPercentage) - */ - protected Number cutoutPercentage; - - /** - * Default {@code -0.5 * Math.PI} - * - * @see #setRotation(Number rotation) - */ - protected Number rotation; - - /** - * Default {@code 2 * Math.PI} - * - * @see #setCircumference(Number circumference) - */ - protected Number circumference; - - protected ArcElements elements; - - /** - * @see #setCutoutPercentage(Number cutoutPercentage) - */ - public Number getCutoutPercentage() - { - return this.cutoutPercentage; - } - - /** - * The percentage of the chart that is cut out of the middle. - */ - public PieOptions setCutoutPercentage(final Number cutoutPercentage) - { - this.cutoutPercentage = cutoutPercentage; - return this; - } - - /** - * @see #setRotation(Number rotation) - */ - public Number getRotation() - { - return this.rotation; - } - - /** - * Starting angle to draw arcs from - */ - public PieOptions setRotation(final Number rotation) - { - this.rotation = rotation; - return this; - } - - /** - * @see #setCircumference(Number circumference) - */ - public Number getCircumference() - { - return this.circumference; - } - - /** - * Sweep to allow arcs to cover - */ - public PieOptions setCircumference(final Number circumference) - { - this.circumference = circumference; - return this; - } - - /** - * @return {@link ArcElements} instance, or {@code null} if not set - */ - public ArcElements getElements() - { - return this.elements; - } - - /** - * @param elements an {@link ArcElements} instance, or {@code null} - * @return this instance for method chaining - */ - public PieOptions setElements(final ArcElements elements) - { - this.elements = elements; - return this; - } } diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimation.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimation.java index 591f3889..d90bf7a4 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimation.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimation.java @@ -15,53 +15,6 @@ */ package software.xdev.chartjs.model.options.animation; -public class DoughnutAnimation extends Animation +public class DoughnutAnimation extends DoughnutAnimationBase { - /** - * Default {@code true} - * - * @see #setAnimateRotate(Boolean) - */ - protected Boolean animateRotate; - - /** - * Default {@code true} - * - * @see #setAnimateScale(Boolean) - */ - protected Boolean animateScale; - - /** - * @see #setAnimateRotate(Boolean) - */ - public Boolean getAnimateRotate() - { - return this.animateRotate; - } - - /** - * If true, will animate the rotation of the chart. - */ - public DoughnutAnimation setAnimateRotate(final Boolean animateRotate) - { - this.animateRotate = animateRotate; - return this; - } - - /** - * @see #setAnimateScale(Boolean) - */ - public Boolean getAnimateScale() - { - return this.animateScale; - } - - /** - * If true, will animate scaling the chart. - */ - public DoughnutAnimation setAnimateScale(final Boolean animateScale) - { - this.animateScale = animateScale; - return this; - } } diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimationBase.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimationBase.java new file mode 100644 index 00000000..479c202a --- /dev/null +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/DoughnutAnimationBase.java @@ -0,0 +1,47 @@ +/* + * 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.animation; + +/** + * @see ChartJS Source + */ +public abstract class DoughnutAnimationBase> extends Animation +{ + protected Boolean animateRotate; + protected Boolean animateScale; + + public Boolean getAnimateRotate() + { + return this.animateRotate; + } + + public DoughnutAnimationBase setAnimateRotate(final Boolean animateRotate) + { + this.animateRotate = animateRotate; + return this.self(); + } + + public Boolean getAnimateScale() + { + return this.animateScale; + } + + public DoughnutAnimationBase setAnimateScale(final Boolean animateScale) + { + this.animateScale = animateScale; + return this.self(); + } +} diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/PieAnimation.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/PieAnimation.java index 83b0321d..4285b7a8 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/PieAnimation.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/animation/PieAnimation.java @@ -15,54 +15,6 @@ */ package software.xdev.chartjs.model.options.animation; -public class PieAnimation extends Animation +public class PieAnimation extends DoughnutAnimationBase { - - /** - * Default {@code true} - * - * @see #setAnimateRotate(Boolean) - */ - protected Boolean animateRotate; - - /** - * Default {@code true} - * - * @see #setAnimateScale(Boolean) - */ - protected Boolean animateScale; - - /** - * @see #setAnimateRotate(Boolean) - */ - public Boolean getAnimateRotate() - { - return this.animateRotate; - } - - /** - * If true, will animate the rotation of the chart. - */ - public PieAnimation setAnimateRotate(final Boolean animateRotate) - { - this.animateRotate = animateRotate; - return this; - } - - /** - * @see #setAnimateScale(Boolean) - */ - public Boolean getAnimateScale() - { - return this.animateScale; - } - - /** - * If true, will animate scaling the chart. - */ - public PieAnimation setAnimateScale(final Boolean animateScale) - { - this.animateScale = animateScale; - return this; - } } diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scale/GridLineConfiguration.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scale/GridLineConfiguration.java index 68a6a6a1..63ffe341 100644 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scale/GridLineConfiguration.java +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scale/GridLineConfiguration.java @@ -15,25 +15,24 @@ */ package software.xdev.chartjs.model.options.scale; -import java.util.List; - import software.xdev.chartjs.model.objects.OptionalArray; /** - * @see ChartJS Source + * @see ChartJS Source */ public class GridLineConfiguration { protected Boolean display; protected Boolean circular; protected Object color; - protected Number lineWidth; + protected Object lineWidth; protected Boolean drawOnChartArea; protected Boolean drawTicks; - protected List tickBorderDash = new OptionalArray<>(); - protected Number tickBorderDashOffset; + protected Object tickBorderDash = new OptionalArray<>(); + protected Object tickBorderDashOffset; protected Object tickColor; + protected Number tickLength; protected Number tickWidth; protected Boolean offset; protected Number z; @@ -71,12 +70,12 @@ public GridLineConfiguration setColor(final Object color) return this; } - public Number getLineWidth() + public Object getLineWidth() { return this.lineWidth; } - public GridLineConfiguration setLineWidth(final Number lineWidth) + public GridLineConfiguration setLineWidth(final Object lineWidth) { this.lineWidth = lineWidth; return this; @@ -104,23 +103,23 @@ public GridLineConfiguration setDrawTicks(final Boolean drawTicks) return this; } - public List getTickBorderDash() + public Object getTickBorderDash() { return this.tickBorderDash; } - public GridLineConfiguration setTickBorderDash(final List tickBorderDash) + public GridLineConfiguration setTickBorderDash(final Object tickBorderDash) { this.tickBorderDash = tickBorderDash; return this; } - public Number getTickBorderDashOffset() + public Object getTickBorderDashOffset() { return this.tickBorderDashOffset; } - public GridLineConfiguration setTickBorderDashOffset(final Number tickBorderDashOffset) + public GridLineConfiguration setTickBorderDashOffset(final Object tickBorderDashOffset) { this.tickBorderDashOffset = tickBorderDashOffset; return this; @@ -137,6 +136,16 @@ public GridLineConfiguration setTickColor(final Object tickColor) return this; } + public Number getTickLength() + { + return this.tickLength; + } + + public void setTickLength(final Number tickLength) + { + this.tickLength = tickLength; + } + public Number getTickWidth() { return this.tickWidth; diff --git a/pom.xml b/pom.xml index 510e55e8..5b012e1a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev chartjs-java-model-root - 2.5.1-SNAPSHOT + 2.6.0-SNAPSHOT pom @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.20.1 + 10.20.2 @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.7.0 + 7.8.0 net.sourceforge.pmd pmd-java - 7.7.0 + 7.8.0