Skip to content

Commit dfb15d8

Browse files
authored
Merge pull request #182 from xdev-software/scale-rework
Scale rework
2 parents be0c609 + 5659f63 commit dfb15d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2397
-3247
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.0.0
2+
* Scales have been reworked and are now nearly identical to the [types defined in ChartJS](https://github.com/chartjs/Chart.js/blob/v4.4.3/src/types/index.d.ts)
3+
* The use of ``Color`` for various coloring related options is no longer required.
4+
* It's now possible to use e.g. strings
5+
16
## 1.5.0
27
* Added ``JsonIgnore`` to certain fields to help prevent infinite loops #174
38
* Corrected model for ``Title`` and ``Font`` #175

Diff for: chartjs-java-model-demo/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model-demo</artifactId>
9-
<version>1.5.1-SNAPSHOT</version>
9+
<version>2.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<organization>

Diff for: chartjs-java-model/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model</artifactId>
9-
<version>1.5.1-SNAPSHOT</version>
9+
<version>2.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>chartjs-java-model</name>

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/PointDataset.java

+24-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.ArrayList;
1919
import java.util.List;
2020

21-
import software.xdev.chartjs.model.color.Color;
2221
import software.xdev.chartjs.model.enums.BorderCapStyle;
2322
import software.xdev.chartjs.model.enums.BorderJoinStyle;
2423
import software.xdev.chartjs.model.enums.PointStyle;
@@ -34,11 +33,11 @@ public abstract class PointDataset<T extends Dataset<T, O>, O> extends Dataset<T
3433

3534
private Float lineTension;
3635

37-
private Color backgroundColor;
36+
private Object backgroundColor;
3837

3938
private Integer borderWidth;
4039

41-
private Color borderColor;
40+
private Object borderColor;
4241

4342
private BorderCapStyle borderCapStyle;
4443

@@ -48,9 +47,9 @@ public abstract class PointDataset<T extends Dataset<T, O>, O> extends Dataset<T
4847

4948
private BorderJoinStyle borderJoinStyle;
5049

51-
private final List<Color> pointBorderColor = new OptionalArray<>();
50+
private final List<Object> pointBorderColor = new OptionalArray<>();
5251

53-
private final List<Color> pointBackgroundColor = new OptionalArray<>();
52+
private final List<Object> pointBackgroundColor = new OptionalArray<>();
5453

5554
private final List<Integer> pointBorderWidth = new OptionalArray<>();
5655

@@ -60,9 +59,9 @@ public abstract class PointDataset<T extends Dataset<T, O>, O> extends Dataset<T
6059

6160
private final List<Integer> pointHitRadius = new OptionalArray<>();
6261

63-
private final List<Color> pointHoverBackgroundColor = new OptionalArray<>();
62+
private final List<Object> pointHoverBackgroundColor = new OptionalArray<>();
6463

65-
private final List<Color> pointHoverBorderColor = new OptionalArray<>();
64+
private final List<Object> pointHoverBorderColor = new OptionalArray<>();
6665

6766
private final List<Integer> pointHoverBorderWidth = new OptionalArray<>();
6867

@@ -117,17 +116,17 @@ public T setLineTension(final Float lineTension)
117116
}
118117

119118
/**
120-
* @see #setBackgroundColor(Color)
119+
* @see #setBackgroundColor(Object)
121120
*/
122-
public Color getBackgroundColor()
121+
public Object getBackgroundColor()
123122
{
124123
return this.backgroundColor;
125124
}
126125

127126
/**
128127
* The fill color under the line.
129128
*/
130-
public T setBackgroundColor(final Color backgroundColor)
129+
public T setBackgroundColor(final Object backgroundColor)
131130
{
132131
this.backgroundColor = backgroundColor;
133132
return this.self();
@@ -151,17 +150,17 @@ public T setBorderWidth(final Integer borderWidth)
151150
}
152151

153152
/**
154-
* @see #setBorderColor(Color)
153+
* @see #setBorderColor(Object)
155154
*/
156-
public Color getBorderColor()
155+
public Object getBorderColor()
157156
{
158157
return this.borderColor;
159158
}
160159

161160
/**
162161
* The color of the line.
163162
*/
164-
public T setBorderColor(final Color borderColor)
163+
public T setBorderColor(final Object borderColor)
165164
{
166165
this.borderColor = borderColor;
167166
return this.self();
@@ -275,15 +274,15 @@ public T setBorderJoinStyle(final BorderJoinStyle borderJoinStyle)
275274
/**
276275
* @see #setPointBorderColor(List)
277276
*/
278-
public List<Color> getPointBorderColor()
277+
public List<Object> getPointBorderColor()
279278
{
280279
return this.pointBorderColor;
281280
}
282281

283282
/**
284283
* @see #setPointBorderColor(List)
285284
*/
286-
public T addPointBorderColor(final Color pointBorderColor)
285+
public T addPointBorderColor(final Object pointBorderColor)
287286
{
288287
this.pointBorderColor.add(pointBorderColor);
289288
return this.self();
@@ -292,7 +291,7 @@ public T addPointBorderColor(final Color pointBorderColor)
292291
/**
293292
* The border color for points.
294293
*/
295-
public T setPointBorderColor(final List<Color> pointBorderColor)
294+
public T setPointBorderColor(final List<Object> pointBorderColor)
296295
{
297296
this.pointBorderColor.clear();
298297
if(pointBorderColor != null)
@@ -305,15 +304,15 @@ public T setPointBorderColor(final List<Color> pointBorderColor)
305304
/**
306305
* @see #setPointBackgroundColor(List)
307306
*/
308-
public List<Color> getPointBackgroundColor()
307+
public List<Object> getPointBackgroundColor()
309308
{
310309
return this.pointBackgroundColor;
311310
}
312311

313312
/**
314313
* @see #setPointBackgroundColor(List)
315314
*/
316-
public T addPointBackgroundColor(final Color pointBackgroundColor)
315+
public T addPointBackgroundColor(final Object pointBackgroundColor)
317316
{
318317
this.pointBackgroundColor.add(pointBackgroundColor);
319318
return this.self();
@@ -322,7 +321,7 @@ public T addPointBackgroundColor(final Color pointBackgroundColor)
322321
/**
323322
* The fill color for points
324323
*/
325-
public T setPointBackgroundColor(final List<Color> pointBackgroundColor)
324+
public T setPointBackgroundColor(final List<Object> pointBackgroundColor)
326325
{
327326
this.pointBackgroundColor.clear();
328327
if(pointBackgroundColor != null)
@@ -455,15 +454,15 @@ public T setPointHitRadius(final List<Integer> pointHitRadius)
455454
/**
456455
* @see #setPointHoverBackgroundColor(List)
457456
*/
458-
public List<Color> getPointHoverBackgroundColor()
457+
public List<Object> getPointHoverBackgroundColor()
459458
{
460459
return this.pointHoverBackgroundColor;
461460
}
462461

463462
/**
464463
* @see #setPointHoverBackgroundColor(List)
465464
*/
466-
public T addPointHoverBackgroundColor(final Color pointHoverBackgroundColor)
465+
public T addPointHoverBackgroundColor(final Object pointHoverBackgroundColor)
467466
{
468467
this.pointHoverBackgroundColor.add(pointHoverBackgroundColor);
469468
return this.self();
@@ -472,7 +471,7 @@ public T addPointHoverBackgroundColor(final Color pointHoverBackgroundColor)
472471
/**
473472
* Point background color when hovered
474473
*/
475-
public T setPointHoverBackgroundColor(final List<Color> pointHoverBackgroundColor)
474+
public T setPointHoverBackgroundColor(final List<Object> pointHoverBackgroundColor)
476475
{
477476
this.pointHoverBackgroundColor.clear();
478477
if(pointHoverBackgroundColor != null)
@@ -485,15 +484,15 @@ public T setPointHoverBackgroundColor(final List<Color> pointHoverBackgroundColo
485484
/**
486485
* @see #setPointHoverBorderColor(List)
487486
*/
488-
public List<Color> getPointHoverBorderColor()
487+
public List<Object> getPointHoverBorderColor()
489488
{
490489
return this.pointHoverBorderColor;
491490
}
492491

493492
/**
494493
* @see #setPointHoverBorderColor(List)
495494
*/
496-
public T addPointHoverBorderColor(final Color pointHoverBorderColor)
495+
public T addPointHoverBorderColor(final Object pointHoverBorderColor)
497496
{
498497
this.pointHoverBorderColor.add(pointHoverBorderColor);
499498
return this.self();
@@ -502,7 +501,7 @@ public T addPointHoverBorderColor(final Color pointHoverBorderColor)
502501
/**
503502
* Point border color when hovered
504503
*/
505-
public T setPointHoverBorderColor(final List<Color> pointHoverBorderColor)
504+
public T setPointHoverBorderColor(final List<Object> pointHoverBorderColor)
506505
{
507506
this.pointHoverBorderColor.clear();
508507
if(pointHoverBorderColor != null)

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scales/Font.java renamed to chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Font.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.chartjs.model.options.scales;
16+
package software.xdev.chartjs.model.options;
1717

1818
import software.xdev.chartjs.model.enums.FontStyle;
1919

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendLabels.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package software.xdev.chartjs.model.options;
1717

18-
import software.xdev.chartjs.model.color.Color;
1918
import software.xdev.chartjs.model.enums.FontStyle;
2019
import software.xdev.chartjs.model.javascript.JavaScriptFunction;
2120

@@ -25,7 +24,7 @@ public class LegendLabels
2524
protected Integer boxWidth;
2625
protected Integer fontSize;
2726
protected FontStyle fontStyle;
28-
protected Color fontColor;
27+
protected Object fontColor;
2928
protected String fontFamily;
3029
protected Integer padding;
3130
protected JavaScriptFunction generateLabels;
@@ -101,9 +100,9 @@ public LegendLabels setFontStyle(final FontStyle fontStyle)
101100
}
102101

103102
/**
104-
* @see #setFontColor(Color)
103+
* @see #setFontColor(Object)
105104
*/
106-
public Color getFontColor()
105+
public Object getFontColor()
107106
{
108107
return this.fontColor;
109108
}
@@ -117,7 +116,7 @@ public Color getFontColor()
117116
* Default {@code "#666"}
118117
* </p>
119118
*/
120-
public LegendLabels setFontColor(final Color fontColor)
119+
public LegendLabels setFontColor(final Object fontColor)
121120
{
122121
this.fontColor = fontColor;
123122
return this;

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendTitle.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@
1515
*/
1616
package software.xdev.chartjs.model.options;
1717

18-
import software.xdev.chartjs.model.color.Color;
1918
import software.xdev.chartjs.model.options.layout.Padding;
20-
import software.xdev.chartjs.model.options.scales.Font;
2119

2220

2321
public class LegendTitle
2422
{
25-
protected Color color;
23+
protected Object color;
2624
protected Boolean display;
2725
protected Font font;
2826
protected Padding padding;
2927
protected String text;
3028

3129
/**
32-
* @see #setColor(Color)
30+
* @see #setColor(Object)
3331
*/
34-
public Color getColor()
32+
public Object getColor()
3533
{
3634
return this.color;
3735
}
@@ -41,7 +39,7 @@ public Color getColor()
4139
* <p/>
4240
* Color of text
4341
*/
44-
public LegendTitle setColor(final Color color)
42+
public LegendTitle setColor(final Object color)
4543
{
4644
this.color = color;
4745
return this;

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import software.xdev.chartjs.model.options.animation.Animation;
2424
import software.xdev.chartjs.model.options.animation.Animations;
2525
import software.xdev.chartjs.model.options.layout.Layout;
26-
import software.xdev.chartjs.model.options.scales.Scales;
26+
import software.xdev.chartjs.model.options.scale.Scales;
2727

2828

2929
public class Options<T extends Options<T, A>, A extends Animation<A>>

Diff for: chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PolarOptions.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,40 @@
1717

1818
import software.xdev.chartjs.model.options.animation.PolarAnimation;
1919
import software.xdev.chartjs.model.options.elements.ArcElements;
20-
import software.xdev.chartjs.model.options.scales.RadialLinearScale;
21-
import software.xdev.chartjs.model.options.scales.Scale;
20+
import software.xdev.chartjs.model.options.scale.radial.RadialLinearScaleOptions;
2221

2322

2423
public class PolarOptions extends Options<PolarOptions, PolarAnimation>
2524
{
26-
2725
/**
28-
* @see #setScale(RadialLinearScale scale)
26+
* @see #setScale(RadialLinearScaleOptions scale)
2927
*/
30-
protected RadialLinearScale<?> scale;
28+
protected RadialLinearScaleOptions scale;
3129

3230
protected ArcElements elements;
3331

3432
/**
35-
* Static factory, constructs a {@link Scale} implementation appropriate for a {@link PolarOptions} instance.
33+
* Static factory, constructs a Scale implementation appropriate for a {@link PolarOptions} instance.
3634
*
37-
* @return a new {@link RadialLinearScale} instance
35+
* @return a new {@link RadialLinearScaleOptions} instance
3836
*/
39-
public static RadialLinearScale scales()
37+
public static RadialLinearScaleOptions scales()
4038
{
41-
return new RadialLinearScale<>();
39+
return new RadialLinearScaleOptions();
4240
}
4341

4442
/**
45-
* @see #setScale(RadialLinearScale)
43+
* @see #setScale(RadialLinearScaleOptions)
4644
*/
47-
public RadialLinearScale getScale()
45+
public RadialLinearScaleOptions getScale()
4846
{
4947
return this.scale;
5048
}
5149

5250
/**
5351
* Options for the one scale used on the chart. Use this to style the ticks, labels, and grid.
5452
*/
55-
public PolarOptions setScale(final RadialLinearScale<?> scale)
53+
public PolarOptions setScale(final RadialLinearScaleOptions scale)
5654
{
5755
this.scale = scale;
5856
return this;

0 commit comments

Comments
 (0)