Skip to content

Commit d6370fd

Browse files
authored
Merge pull request #159 from aripddev/develop
Shortcomings in simplifying the API by using Number instead of BigDec…
2 parents 47fccfa + c79e4b2 commit d6370fd

File tree

12 files changed

+181
-241
lines changed

12 files changed

+181
-241
lines changed

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

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

18-
import java.math.BigDecimal;
19-
2018
import software.xdev.chartjs.model.options.animation.DoughnutAnimation;
2119
import software.xdev.chartjs.model.options.elements.ArcElements;
2220

@@ -26,72 +24,72 @@ public class DoughnutOptions extends Options<DoughnutOptions, DoughnutAnimation>
2624
/**
2725
* Default {@code 50}
2826
*
29-
* @see #setCutout(BigDecimal cutout)
27+
* @see #setCutout(Number cutout)
3028
*/
31-
protected BigDecimal cutout;
29+
protected Number cutout;
3230

3331
/**
3432
* Rotation in degrees. Default {@code 0}. {@code 0} is at the top.
3533
*
36-
* @see #setRotation(BigDecimal rotation)
34+
* @see #setRotation(Number rotation)
3735
*/
38-
protected BigDecimal rotation;
36+
protected Number rotation;
3937

4038
/**
4139
* Circumference in degrees. Default {@code 360}.
4240
*
43-
* @see #setCircumference(BigDecimal circumference)
41+
* @see #setCircumference(Number circumference)
4442
*/
45-
protected BigDecimal circumference;
43+
protected Number circumference;
4644

4745
protected ArcElements elements;
4846

4947
/**
50-
* @see #setCutout(BigDecimal cutoutPercentage)
48+
* @see #setCutout(Number cutoutPercentage)
5149
*/
52-
public BigDecimal getCutout()
50+
public Number getCutout()
5351
{
5452
return this.cutout;
5553
}
5654

5755
/**
5856
* The pixels as number of the chart that is cut out of the middle.
5957
*/
60-
public DoughnutOptions setCutout(final BigDecimal cutout)
58+
public DoughnutOptions setCutout(final Number cutout)
6159
{
6260
this.cutout = cutout;
6361
return this;
6462
}
6563

6664
/**
67-
* @see #setRotation(BigDecimal rotation)
65+
* @see #setRotation(Number rotation)
6866
*/
69-
public BigDecimal getRotation()
67+
public Number getRotation()
7068
{
7169
return this.rotation;
7270
}
7371

7472
/**
7573
* Starting angle to draw arcs from in degrees
7674
*/
77-
public DoughnutOptions setRotation(final BigDecimal rotation)
75+
public DoughnutOptions setRotation(final Number rotation)
7876
{
7977
this.rotation = rotation;
8078
return this;
8179
}
8280

8381
/**
84-
* @see #setCircumference(BigDecimal circumference)
82+
* @see #setCircumference(Number circumference)
8583
*/
86-
public BigDecimal getCircumference()
84+
public Number getCircumference()
8785
{
8886
return this.circumference;
8987
}
9088

9189
/**
9290
* Sweep to allow arcs to cover in degrees
9391
*/
94-
public DoughnutOptions setCircumference(final BigDecimal circumference)
92+
public DoughnutOptions setCircumference(final Number circumference)
9593
{
9694
this.circumference = circumference;
9795
return this;

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

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

18-
import java.math.BigDecimal;
19-
2018
import software.xdev.chartjs.model.options.animation.PieAnimation;
2119
import software.xdev.chartjs.model.options.elements.ArcElements;
2220

@@ -27,72 +25,72 @@ public class PieOptions extends Options<PieOptions, PieAnimation>
2725
/**
2826
* Default {@code 50 - for doughnut, 0 - for pie}
2927
*
30-
* @see #setCutoutPercentage(BigDecimal cutoutPercentage)
28+
* @see #setCutoutPercentage(Number cutoutPercentage)
3129
*/
32-
protected BigDecimal cutoutPercentage;
30+
protected Number cutoutPercentage;
3331

3432
/**
3533
* Default {@code -0.5 * Math.PI}
3634
*
37-
* @see #setRotation(BigDecimal rotation)
35+
* @see #setRotation(Number rotation)
3836
*/
39-
protected BigDecimal rotation;
37+
protected Number rotation;
4038

4139
/**
4240
* Default {@code 2 * Math.PI}
4341
*
44-
* @see #setCircumference(BigDecimal circumference)
42+
* @see #setCircumference(Number circumference)
4543
*/
46-
protected BigDecimal circumference;
44+
protected Number circumference;
4745

4846
protected ArcElements elements;
4947

5048
/**
51-
* @see #setCutoutPercentage(BigDecimal cutoutPercentage)
49+
* @see #setCutoutPercentage(Number cutoutPercentage)
5250
*/
53-
public BigDecimal getCutoutPercentage()
51+
public Number getCutoutPercentage()
5452
{
5553
return this.cutoutPercentage;
5654
}
5755

5856
/**
5957
* The percentage of the chart that is cut out of the middle.
6058
*/
61-
public PieOptions setCutoutPercentage(final BigDecimal cutoutPercentage)
59+
public PieOptions setCutoutPercentage(final Number cutoutPercentage)
6260
{
6361
this.cutoutPercentage = cutoutPercentage;
6462
return this;
6563
}
6664

6765
/**
68-
* @see #setRotation(BigDecimal rotation)
66+
* @see #setRotation(Number rotation)
6967
*/
70-
public BigDecimal getRotation()
68+
public Number getRotation()
7169
{
7270
return this.rotation;
7371
}
7472

7573
/**
7674
* Starting angle to draw arcs from
7775
*/
78-
public PieOptions setRotation(final BigDecimal rotation)
76+
public PieOptions setRotation(final Number rotation)
7977
{
8078
this.rotation = rotation;
8179
return this;
8280
}
8381

8482
/**
85-
* @see #setCircumference(BigDecimal circumference)
83+
* @see #setCircumference(Number circumference)
8684
*/
87-
public BigDecimal getCircumference()
85+
public Number getCircumference()
8886
{
8987
return this.circumference;
9088
}
9189

9290
/**
9391
* Sweep to allow arcs to cover
9492
*/
95-
public PieOptions setCircumference(final BigDecimal circumference)
93+
public PieOptions setCircumference(final Number circumference)
9694
{
9795
this.circumference = circumference;
9896
return this;

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/plugins/zoom/limits/ScaleLimits.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package software.xdev.chartjs.model.options.plugins.zoom.limits;
1717

18-
import java.math.BigDecimal;
19-
2018

2119
/**
2220
* <a href="https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/options.html#scale-limits">ChartJS docs</a>
@@ -25,7 +23,7 @@ public class ScaleLimits
2523
{
2624
protected Object min;
2725
protected Object max;
28-
protected BigDecimal minRange;
26+
protected Number minRange;
2927

3028
public Object getMin()
3129
{
@@ -49,12 +47,12 @@ public ScaleLimits setMax(final Object max)
4947
return this;
5048
}
5149

52-
public BigDecimal getMinRange()
50+
public Number getMinRange()
5351
{
5452
return this.minRange;
5553
}
5654

57-
public ScaleLimits setMinRange(final BigDecimal minRange)
55+
public ScaleLimits setMinRange(final Number minRange)
5856
{
5957
this.minRange = minRange;
6058
return this;

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scales/AngleLines.java

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

18-
import java.math.BigDecimal;
19-
2018
import software.xdev.chartjs.model.color.Color;
2119

2220

@@ -27,7 +25,7 @@ public class AngleLines
2725
{
2826
protected Boolean display;
2927
protected Color color;
30-
protected BigDecimal lineWidth;
28+
protected Number lineWidth;
3129

3230
/**
3331
* @see #setDisplay(Boolean)
@@ -76,9 +74,9 @@ public AngleLines setColor(final Color color)
7674
}
7775

7876
/**
79-
* @see #setLineWidth(BigDecimal)
77+
* @see #setLineWidth(Number)
8078
*/
81-
public BigDecimal getLineWidth()
79+
public Number getLineWidth()
8280
{
8381
return this.lineWidth;
8482
}
@@ -92,7 +90,7 @@ public BigDecimal getLineWidth()
9290
* Default {@code 1}
9391
* </p>
9492
*/
95-
public AngleLines setLineWidth(final BigDecimal lineWidth)
93+
public AngleLines setLineWidth(final Number lineWidth)
9694
{
9795
this.lineWidth = lineWidth;
9896
return this;

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scales/BarScale.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package software.xdev.chartjs.model.options.scales;
1717

18-
import java.math.BigDecimal;
19-
2018
import software.xdev.chartjs.model.options.ticks.Ticks;
2119

2220

@@ -33,20 +31,20 @@ public class BarScale<T extends Ticks<T>> extends Scale<T, BarScale<T>>
3331
/**
3432
* Default {@code 0.8}
3533
*
36-
* @see #setCategoryPercentage(BigDecimal categoryPercentage)
34+
* @see #setCategoryPercentage(Number categoryPercentage)
3735
*/
38-
protected BigDecimal categoryPercentage;
36+
protected Number categoryPercentage;
3937

4038
/**
4139
* Default {@code 0.9}
4240
*
43-
* @see #setBarPercentage(BigDecimal barPercentage)
41+
* @see #setBarPercentage(Number barPercentage)
4442
*/
45-
protected BigDecimal barPercentage;
43+
protected Number barPercentage;
4644

47-
protected BigDecimal barThickness;
45+
protected Number barThickness;
4846

49-
protected BigDecimal maxBarThickness;
47+
protected Number maxBarThickness;
5048

5149
/**
5250
* @see #setType(String type)
@@ -66,9 +64,9 @@ public BarScale<T> setType(final String type)
6664
}
6765

6866
/**
69-
* @see #setCategoryPercentage(BigDecimal categoryPercentage)
67+
* @see #setCategoryPercentage(Number categoryPercentage)
7068
*/
71-
public BigDecimal getCategoryPercentage()
69+
public Number getCategoryPercentage()
7270
{
7371
return this.categoryPercentage;
7472
}
@@ -77,16 +75,16 @@ public BigDecimal getCategoryPercentage()
7775
* Percent (0-1) of the available width (the space between the gridlines for small datasets) for each data-point to
7876
* use for the bars.
7977
*/
80-
public BarScale<T> setCategoryPercentage(final BigDecimal categoryPercentage)
78+
public BarScale<T> setCategoryPercentage(final Number categoryPercentage)
8179
{
8280
this.categoryPercentage = categoryPercentage;
8381
return this;
8482
}
8583

8684
/**
87-
* @see #setBarPercentage(BigDecimal barPercentage)
85+
* @see #setBarPercentage(Number barPercentage)
8886
*/
89-
public BigDecimal getBarPercentage()
87+
public Number getBarPercentage()
9088
{
9189
return this.barPercentage;
9290
}
@@ -95,16 +93,16 @@ public BigDecimal getBarPercentage()
9593
* Percent (0-1) of the available width each bar should be within the category percentage. 1.0 will take the whole
9694
* category width and put the bars right next to each other.
9795
*/
98-
public BarScale<T> setBarPercentage(final BigDecimal barPercentage)
96+
public BarScale<T> setBarPercentage(final Number barPercentage)
9997
{
10098
this.barPercentage = barPercentage;
10199
return this;
102100
}
103101

104102
/**
105-
* @see #setBarThickness(BigDecimal)
103+
* @see #setBarThickness(Number)
106104
*/
107-
public BigDecimal getBarThickness()
105+
public Number getBarThickness()
108106
{
109107
return this.barThickness;
110108
}
@@ -115,7 +113,7 @@ public BigDecimal getBarThickness()
115113
* they take the full available widths without overlap. Then, the bars are sized using barPercentage and
116114
* categoryPercentage.
117115
*/
118-
public BarScale<T> setBarThickness(final BigDecimal barThickness)
116+
public BarScale<T> setBarThickness(final Number barThickness)
119117
{
120118
this.barThickness = barThickness;
121119
return this;
@@ -124,15 +122,15 @@ public BarScale<T> setBarThickness(final BigDecimal barThickness)
124122
/**
125123
* @see #setGridLines(GridLines gridLines)
126124
*/
127-
public BigDecimal getMaxBarThickness()
125+
public Number getMaxBarThickness()
128126
{
129127
return this.maxBarThickness;
130128
}
131129

132130
/**
133131
* Set this to ensure that bars are not sized thicker than this.
134132
*/
135-
public BarScale<T> setMaxBarThickness(final BigDecimal maxBarThickness)
133+
public BarScale<T> setMaxBarThickness(final Number maxBarThickness)
136134
{
137135
this.maxBarThickness = maxBarThickness;
138136
return this;

0 commit comments

Comments
 (0)