Skip to content

Commit e2edeab

Browse files
committed
Kotlin ILineRadarDataSet
Fix build
1 parent 65a1ece commit e2edeab

File tree

14 files changed

+43
-70
lines changed

14 files changed

+43
-70
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/ILineDataSet.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ public interface ILineDataSet extends ILineRadarDataSet<Entry> {
1313

1414
/**
1515
* Returns the drawing mode for this line dataset
16-
*
17-
* @return
1816
*/
1917
LineDataSet.Mode getMode();
2018

2119
/**
2220
* Returns the intensity of the cubic lines (the effect intensity).
2321
* Max = 1f = very cubic, Min = 0.05f = low cubic effect, Default: 0.2f
24-
*
25-
* @return
2622
*/
2723
float getCubicIntensity();
2824

@@ -45,59 +41,42 @@ public interface ILineDataSet extends ILineRadarDataSet<Entry> {
4541
/**
4642
* Returns the color at the given index of the DataSet's circle-color array.
4743
* Performs a IndexOutOfBounds check by modulus.
48-
*
49-
* @param index
50-
* @return
5144
*/
5245
int getCircleColor(int index);
5346

5447
/**
5548
* Returns the number of colors in this DataSet's circle-color array.
56-
*
57-
* @return
5849
*/
5950
int getCircleColorCount();
6051

6152
/**
6253
* Returns true if drawing circles for this DataSet is enabled, false if not
63-
*
64-
* @return
6554
*/
6655
boolean isDrawCirclesEnabled();
6756

6857
/**
6958
* Returns the color of the inner circle (the circle-hole).
70-
*
71-
* @return
7259
*/
7360
int getCircleHoleColor();
7461

7562
/**
7663
* Returns true if drawing the circle-holes is enabled, false if not.
77-
*
78-
* @return
7964
*/
8065
boolean isDrawCircleHoleEnabled();
8166

8267
/**
8368
* Returns the DashPathEffect that is used for drawing the lines.
84-
*
85-
* @return
8669
*/
8770
DashPathEffect getDashPathEffect();
8871

8972
/**
9073
* Returns true if the dashed-line effect is enabled, false if not.
9174
* If the DashPathEffect object is null, also return false here.
92-
*
93-
* @return
9475
*/
9576
boolean isDashedLineEnabled();
9677

9778
/**
9879
* Returns the IFillFormatter that is set for this DataSet.
99-
*
100-
* @return
10180
*/
10281
IFillFormatter getFillFormatter();
10382
}

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
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,21 @@ import com.github.mikephil.charting.data.Entry
66
interface ILineScatterCandleRadarDataSet<T : Entry> : IBarLineScatterCandleBubbleDataSet<T> {
77
/**
88
* Returns true if vertical highlight indicator lines are enabled (drawn)
9-
* @return
109
*/
1110
val isVerticalHighlightIndicatorEnabled: Boolean
1211

1312
/**
1413
* Returns true if vertical highlight indicator lines are enabled (drawn)
15-
* @return
1614
*/
1715
val isHorizontalHighlightIndicatorEnabled: Boolean
1816

1917
/**
2018
* Returns the line-width in which highlight lines are to be drawn.
21-
* @return
2219
*/
2320
val highlightLineWidth: Float
2421

2522
/**
2623
* Returns the DashPathEffect that is used for highlighting.
27-
* @return
2824
*/
2925
val dashPathEffectHighlight: DashPathEffect?
3026
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.widget.SeekBar
1212
import android.widget.SeekBar.OnSeekBarChangeListener
1313
import android.widget.TextView
1414
import androidx.core.content.ContextCompat
15+
import androidx.core.net.toUri
1516
import com.github.mikephil.charting.components.YAxis
1617
import com.github.mikephil.charting.data.Entry
1718
import com.github.mikephil.charting.data.LineData
@@ -22,7 +23,6 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet
2223
import info.appdev.chartexample.DataTools.Companion.getMuchValues
2324
import info.appdev.chartexample.databinding.ActivityLinechartBinding
2425
import info.appdev.chartexample.notimportant.DemoBase
25-
import androidx.core.net.toUri
2626

2727
class CubicLineChartActivity : DemoBase(), OnSeekBarChangeListener {
2828
private var tvX: TextView? = null
@@ -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
@@ -104,7 +104,7 @@ class FilledLineActivity : DemoBase() {
104104
set1.setDrawCircles(false)
105105
set1.setLineWidth(2f)
106106
set1.circleRadius = 3f
107-
set1.fillAlpha = 255
107+
set1.setFillAlpha(255)
108108
set1.setDrawFilled(true)
109109
set1.setFillColor(Color.WHITE)
110110
set1.setHighLightColor(Color.rgb(244, 117, 117))
@@ -124,7 +124,7 @@ class FilledLineActivity : DemoBase() {
124124
set2.setDrawCircles(false)
125125
set2.setLineWidth(2f)
126126
set2.circleRadius = 3f
127-
set2.fillAlpha = 255
127+
set2.setFillAlpha(255)
128128
set2.setDrawFilled(true)
129129
set2.setFillColor(Color.WHITE)
130130
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))

0 commit comments

Comments
 (0)