Skip to content

Commit d1d3db7

Browse files
authored
Merge pull request #449 from AppDevNext/KotlinGradientColor
Kotlin GradientColor
2 parents b59e78e + ec17541 commit d1d3db7

File tree

2 files changed

+46
-60
lines changed

2 files changed

+46
-60
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/model/GradientColor.java

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.github.mikephil.charting.model
2+
3+
import com.github.mikephil.charting.utils.Fill
4+
5+
@Deprecated("Use `Fill` instead")
6+
class GradientColor : Fill() {
7+
@get:Deprecated("Use `Fill.getGradientColors()`")
8+
@set:Deprecated("Use `Fill.setGradientColors(...)`")
9+
var startColor: Int
10+
get() = gradientColors[0]
11+
set(startColor) {
12+
if (gradientColors == null || gradientColors.size != 2) {
13+
setGradientColors(
14+
intArrayOf(
15+
startColor,
16+
if (gradientColors != null && gradientColors.size > 1)
17+
gradientColors[1]
18+
else
19+
0
20+
)
21+
)
22+
} else {
23+
gradientColors[0] = startColor
24+
}
25+
}
26+
27+
@get:Deprecated("Use `Fill.getGradientColors()`")
28+
@set:Deprecated("Use `Fill.setGradientColors(...)`")
29+
var endColor: Int
30+
get() = gradientColors[1]
31+
set(endColor) {
32+
if (gradientColors == null || gradientColors.size != 2) {
33+
setGradientColors(
34+
intArrayOf(
35+
if (gradientColors != null && gradientColors.size > 0)
36+
gradientColors[0]
37+
else
38+
0,
39+
endColor
40+
)
41+
)
42+
} else {
43+
gradientColors[1] = endColor
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)