Skip to content

Commit e7e8677

Browse files
committed
Kotlin ILineRadarDataSet
1 parent 7955947 commit e7e8677

File tree

12 files changed

+42
-44
lines changed

12 files changed

+42
-44
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/data/DataSet.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ protected void copy(DataSet dataSet) {
191191
super.copy(dataSet);
192192
}
193193

194+
@NonNull
194195
@Override
195196
public String toString() {
196197
StringBuilder buffer = new StringBuilder();
@@ -207,9 +208,11 @@ public String toString() {
207208
*/
208209

209210
public String toSimpleString() {
210-
return"DataSet, label: " + (getLabel() == null ? "" : getLabel()) + ", entries: " + mEntries.size() +
211+
return "DataSet, label: " +
212+
(getLabel() == null ? "" : getLabel()) +
213+
", entries: " +
214+
mEntries.size() +
211215
"\n";
212-
213216
}
214217

215218
@Override
@@ -233,9 +236,9 @@ public float getXMax() {
233236
}
234237

235238
@Override
236-
public void addEntryOrdered(T entry) {
239+
public void addEntryOrdered(@NonNull T entry) {
237240

238-
if (mEntries == null) {
241+
if (mEntries == null) {
239242
mEntries = new ArrayList<>();
240243
}
241244

@@ -269,9 +272,9 @@ public boolean addEntry(@NonNull T entry) {
269272
}
270273

271274
@Override
272-
public boolean removeEntry(T entry) {
275+
public boolean removeEntry(@NonNull T entry) {
273276

274-
if (mEntries == null)
277+
if (mEntries == null)
275278
return false;
276279

277280
// remove the entry
@@ -285,7 +288,7 @@ public boolean removeEntry(T entry) {
285288
}
286289

287290
@Override
288-
public int getEntryIndex(Entry entry) {
291+
public int getEntryIndex(@NonNull Entry entry) {
289292
return mEntries.indexOf(entry);
290293
}
291294

MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IDataSet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface IDataSet<T : Entry> {
3232

3333
/**
3434
* Returns the number of y-values this DataSet represents -> the size of the y-values array
35-
* -> yvals.size()
35+
* -> yVals.size()
3636
*/
3737
val entryCount: Int
3838

@@ -107,7 +107,7 @@ interface IDataSet<T : Entry> {
107107
* Returns the position of the provided entry in the DataSets Entry array.
108108
* Returns -1 if doesn't exist.
109109
*/
110-
fun getEntryIndex(entry: T): Int
110+
fun getEntryIndex(e: T): Int
111111

112112
/**
113113
* This method returns the actual

MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineRadarDataSet.java renamed to MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineRadarDataSet.kt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
package com.github.mikephil.charting.interfaces.datasets;
1+
package com.github.mikephil.charting.interfaces.datasets
22

3-
import android.graphics.drawable.Drawable;
4-
5-
import com.github.mikephil.charting.data.Entry;
6-
7-
/**
8-
* Created by Philipp Jahoda on 21/10/15.
9-
*/
10-
public interface ILineRadarDataSet<T extends Entry> extends ILineScatterCandleRadarDataSet<T> {
3+
import android.graphics.drawable.Drawable
4+
import com.github.mikephil.charting.data.Entry
115

6+
interface ILineRadarDataSet<T : Entry> : ILineScatterCandleRadarDataSet<T> {
127
/**
138
* Returns the color that is used for filling the line surface area.
149
*/
15-
int getFillColor();
10+
val fillColor: Int
1611

1712
/**
1813
* Returns the drawable used for filling the area below the line.
1914
*/
20-
Drawable getFillDrawable();
15+
val fillDrawable: Drawable?
2116

2217
/**
2318
* Returns the alpha value that is used for filling the line surface,
2419
* default: 85
2520
*/
26-
int getFillAlpha();
21+
val fillAlpha: Int
2722

2823
/**
2924
* Returns the stroke-width of the drawn line
3025
*/
31-
float getLineWidth();
26+
val lineWidth: Float
3227

3328
/**
3429
* Returns true if filled drawing is enabled, false if not
3530
*/
36-
boolean isDrawFilledEnabled();
31+
val isDrawFilledEnabled: Boolean
3732

3833
/**
3934
* Set to true if the DataSet should be drawn filled (surface), and not just
@@ -42,5 +37,5 @@ public interface ILineRadarDataSet<T extends Entry> extends ILineScatterCandleRa
4237
* For devices with API level < 18 (Android 4.3), hardware acceleration of the chart should
4338
* be turned off. Default: false
4439
*/
45-
void setDrawFilled(boolean enabled);
40+
fun setDrawFilled(enabled: Boolean)
4641
}

app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ class CubicLineChartActivity : DemoBase(), OnSeekBarChangeListener {
115115
set1.cubicIntensity = 0.2f
116116
set1.setDrawFilled(true)
117117
set1.setDrawCircles(false)
118-
set1.lineWidth = 1.8f
118+
set1.setLineWidth(1.8f)
119119
set1.circleRadius = 4f
120120
set1.setCircleColor(Color.WHITE)
121121
set1.setHighLightColor(Color.rgb(244, 117, 117))
122122
set1.color = Color.WHITE
123-
set1.fillColor = Color.WHITE
124-
set1.fillAlpha = 100
123+
set1.setFillColor(Color.WHITE)
124+
set1.setFillAlpha(100)
125125
set1.setDrawHorizontalHighlightIndicator(false)
126126
set1.fillFormatter = object : IFillFormatter {
127127
override fun getFillLinePosition(dataSet: ILineDataSet?, dataProvider: LineDataProvider?): Float {

app/src/main/kotlin/info/appdev/chartexample/DataTools.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class DataTools {
186186
lineDataSet01.setCircleColor(Color.BLACK)
187187

188188
// line thickness and point size
189-
lineDataSet01.lineWidth = 1f
189+
lineDataSet01.setLineWidth(1f)
190190
lineDataSet01.circleRadius = 3f
191191

192192
// draw points as solid circles
@@ -215,9 +215,9 @@ class DataTools {
215215
if (getSDKInt() >= 18) {
216216
// drawables only supported on api level 18 and above
217217
val drawable = ContextCompat.getDrawable(context, R.drawable.fade_blue)
218-
lineDataSet01.fillDrawable = drawable
218+
lineDataSet01.setFillDrawable(drawable)
219219
} else {
220-
lineDataSet01.fillColor = Color.BLACK
220+
lineDataSet01.setFillColor(Color.BLACK)
221221
}
222222
val dataSets = ArrayList<ILineDataSet>()
223223
dataSets.add(lineDataSet01) // add the data sets

app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen
6262

6363
// create a dataset and give it a type (0)
6464
val set1 = LineDataSet(values, "DataSet")
65-
set1.lineWidth = 3f
65+
set1.setLineWidth(3f)
6666
set1.circleRadius = 5f
6767

6868
// create a data object with the data sets

app/src/main/kotlin/info/appdev/chartexample/FilledLineActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class FilledLineActivity : DemoBase() {
105105
set1.setDrawCircles(false)
106106
set1.setLineWidth(2f)
107107
set1.circleRadius = 3f
108-
set1.fillAlpha = 255
108+
set1.setFillAlpha(255)
109109
set1.setDrawFilled(true)
110110
set1.setFillColor(Color.WHITE)
111111
set1.setHighLightColor(Color.rgb(244, 117, 117))
@@ -125,7 +125,7 @@ class FilledLineActivity : DemoBase() {
125125
set2.setDrawCircles(false)
126126
set2.setLineWidth(2f)
127127
set2.circleRadius = 3f
128-
set2.fillAlpha = 255
128+
set2.setFillAlpha(255)
129129
set2.setDrawFilled(true)
130130
set2.setFillColor(Color.WHITE)
131131
set2.setDrawCircleHole(false)

app/src/main/kotlin/info/appdev/chartexample/LineChartDualAxisActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
167167
set1.setCircleColor(Color.WHITE)
168168
set1.setLineWidth(2f)
169169
set1.circleRadius = 3f
170-
set1.fillAlpha = 65
170+
set1.setFillAlpha(65)
171171
set1.setFillColor(ColorTemplate.getHoloBlue())
172172
set1.setHighLightColor(Color.rgb(244, 117, 117))
173173
set1.setDrawCircleHole(false)
@@ -184,7 +184,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
184184
set2.setCircleColor(Color.WHITE)
185185
set2.setLineWidth(2f)
186186
set2.circleRadius = 3f
187-
set2.fillAlpha = 65
187+
set2.setFillAlpha(65)
188188
set2.setFillColor(Color.BLUE)
189189
set2.setDrawCircleHole(false)
190190
set2.setHighLightColor(Color.rgb(244, 117, 117))
@@ -196,7 +196,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
196196
set3.setCircleColor(Color.WHITE)
197197
set3.setLineWidth(2f)
198198
set3.circleRadius = 3f
199-
set3.fillAlpha = 65
199+
set3.setFillAlpha(65)
200200
set3.setFillColor(ColorTemplate.colorWithAlpha(Color.YELLOW, 200))
201201
set3.setDrawCircleHole(false)
202202
set3.setHighLightColor(Color.rgb(244, 117, 117))

app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
135135
set1.setLineWidth(1.5f)
136136
set1.setDrawCircles(false)
137137
set1.isDrawValues = false
138-
set1.fillAlpha = 65
138+
set1.setFillAlpha(65)
139139
set1.setFillColor(ColorTemplate.getHoloBlue())
140140
set1.setHighLightColor(Color.rgb(244, 117, 117))
141141
set1.setDrawCircleHole(false)

app/src/main/kotlin/info/appdev/chartexample/RadarChartActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class RadarChartActivity : DemoBase() {
107107
set1.color = Color.rgb(103, 110, 129)
108108
set1.setFillColor(Color.rgb(103, 110, 129))
109109
set1.setDrawFilled(true)
110-
set1.fillAlpha = 180
110+
set1.setFillAlpha(180)
111111
set1.setLineWidth(2f)
112112
set1.isDrawHighlightCircleEnabled = true
113113
set1.setDrawHighlightIndicators(false)
@@ -116,7 +116,7 @@ class RadarChartActivity : DemoBase() {
116116
set2.color = Color.rgb(121, 162, 175)
117117
set2.setFillColor(Color.rgb(121, 162, 175))
118118
set2.setDrawFilled(true)
119-
set2.fillAlpha = 180
119+
set2.setFillAlpha(180)
120120
set2.setLineWidth(2f)
121121
set2.isDrawHighlightCircleEnabled = true
122122
set2.setDrawHighlightIndicators(false)
@@ -177,7 +177,7 @@ class RadarChartActivity : DemoBase() {
177177

178178
R.id.actionToggleFilled -> {
179179
chart!!.data!!.dataSets.forEach { set ->
180-
set.setDrawFilled(!set.isDrawFilledEnabled())
180+
set.setDrawFilled(!set.isDrawFilledEnabled)
181181
}
182182
chart!!.invalidate()
183183
}

0 commit comments

Comments
 (0)