Skip to content

Commit ecf56df

Browse files
committed
Make it possible to set string as color
1 parent 9a9678b commit ecf56df

File tree

17 files changed

+126
-146
lines changed

17 files changed

+126
-146
lines changed

chartjs-java-model/src/main/java/software/xdev/chartjs/model/color/Color.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525

2626
/**
2727
* Immutable RGBa color model.
28-
* @deprecated Will be phased out and replaced by the simpler 'string'
2928
*/
3029
@SuppressWarnings("checkstyle:MagicNumber") // RGB Numbers
31-
@Deprecated
3230
public class Color
3331
{
3432
private static final Random RANDOMIZER = new SecureRandom();

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

Lines changed: 24 additions & 25 deletions
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)

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

Lines changed: 4 additions & 5 deletions
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;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +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;
2019

2120

2221
public class LegendTitle
2322
{
24-
protected Color color;
23+
protected Object color;
2524
protected Boolean display;
2625
protected Font font;
2726
protected Padding padding;
2827
protected String text;
2928

3029
/**
31-
* @see #setColor(Color)
30+
* @see #setColor(Object)
3231
*/
33-
public Color getColor()
32+
public Object getColor()
3433
{
3534
return this.color;
3635
}
@@ -40,7 +39,7 @@ public Color getColor()
4039
* <p/>
4140
* Color of text
4241
*/
43-
public LegendTitle setColor(final Color color)
42+
public LegendTitle setColor(final Object color)
4443
{
4544
this.color = color;
4645
return this;

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Title.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
*/
1616
package software.xdev.chartjs.model.options;
1717

18-
import software.xdev.chartjs.model.color.Color;
19-
20-
2118
/**
2219
* @see <a href="https://www.chartjs.org/docs/latest/axes/labelling.html#scale-title-configuration">ChartJS docs</a>
2320
*/
2421
public class Title
2522
{
2623
protected String align;
27-
protected Color color;
24+
protected Object color;
2825
protected Boolean display;
2926
protected Boolean fullSize;
3027
protected String position;
@@ -52,17 +49,17 @@ public Title setAlign(final String align)
5249
}
5350

5451
/**
55-
* @see #setColor(Color)
52+
* @see #setColor(Object)
5653
*/
57-
public Color getColor()
54+
public Object getColor()
5855
{
5956
return this.color;
6057
}
6158

6259
/**
6360
* Color of text
6461
*/
65-
public Title setColor(final Color color)
62+
public Title setColor(final Object color)
6663
{
6764
this.color = color;
6865
return this;

0 commit comments

Comments
 (0)