Skip to content

Commit 76cebbb

Browse files
committed
IDataSet generic
Use BaseEntry<Float> instead of FloatEntry
1 parent 7feafc2 commit 76cebbb

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

chartLib/src/main/kotlin/info/appdev/charting/data/ChartData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract class ChartData<T : IDataSet<out EntryFloat>> : Serializable {
5252
protected set
5353

5454
constructor() {
55-
this.dataSets = ArrayList<T>()
55+
this.dataSets = ArrayList()
5656
}
5757

5858
constructor(vararg dataSets: T) {
@@ -446,7 +446,7 @@ abstract class ChartData<T : IDataSet<out EntryFloat>> : Serializable {
446446
}
447447

448448
val dataSet: IDataSet<*> = dataSets[dataSetIndex]
449-
val entryFloat: EntryFloat = dataSet.getEntryForXValue(xValue, Float.NaN) ?: return false
449+
val entryFloat: EntryFloat = dataSet.getEntryForXValue(xValue, Float.NaN) as? EntryFloat ?: return false
450450

451451
return removeEntry(entryFloat, dataSetIndex)
452452
}

chartLib/src/main/kotlin/info/appdev/charting/highlight/ChartHighlighter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ open class ChartHighlighter<T : BarLineScatterCandleBubbleDataProvider<*>>(prote
122122
): MutableList<Highlight> {
123123
val highlights = ArrayList<Highlight>()
124124

125-
var entries = set.getEntriesForXValue(xVal)
125+
var entries = set.getEntriesForXValue(xVal)?.map { it as EntryFloat }?.toMutableList()
126126
if (entries != null && entries.isEmpty()) {
127127
// Try to find closest x-value and take all entries for that x-value
128-
val closest: EntryFloat? = set.getEntryForXValue(xVal, Float.NaN, rounding)
128+
val closest: EntryFloat? = set.getEntryForXValue(xVal, Float.NaN, rounding) as? EntryFloat
129129
if (closest != null) {
130-
entries = set.getEntriesForXValue(closest.x)
130+
entries = set.getEntriesForXValue(closest.x)?.map { it as EntryFloat }?.toMutableList()
131131
}
132132
}
133133

chartLib/src/main/kotlin/info/appdev/charting/highlight/HorizontalBarHighlighter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ class HorizontalBarHighlighter(dataProvider: BarDataProvider) : BarHighlighter(d
3535
override fun buildHighlights(set: IDataSet<*>, dataSetIndex: Int, xVal: Float, rounding: DataSet.Rounding?): MutableList<Highlight> {
3636
val highlights = ArrayList<Highlight>()
3737

38-
var entries = set.getEntriesForXValue(xVal)
38+
var entries = set.getEntriesForXValue(xVal)?.map { it as EntryFloat }?.toMutableList()
3939
if (entries != null && entries.isEmpty()) {
4040
// Try to find closest x-value and take all entries for that x-value
41-
val closestEntryFloat: EntryFloat? = set.getEntryForXValue(xVal, Float.NaN, rounding)
41+
val closestEntryFloat: EntryFloat? = set.getEntryForXValue(xVal, Float.NaN, rounding) as? EntryFloat
4242
closestEntryFloat?.let { closestE ->
43-
entries = set.getEntriesForXValue(closestE.x)
43+
entries = set.getEntriesForXValue(closestE.x)?.map { it as EntryFloat }?.toMutableList()
4444
}
4545
}
4646

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package info.appdev.charting.interfaces.datasets
22

3-
import info.appdev.charting.data.EntryFloat
3+
import info.appdev.charting.data.BaseEntry
44

5-
interface IBarLineScatterCandleBubbleDataSet<T : EntryFloat> : IDataSet<T> {
5+
interface IBarLineScatterCandleBubbleDataSet<T : BaseEntry<Float>> : IDataSet<T> {
66

77
val highLightColor: Int
88
}

chartLib/src/main/kotlin/info/appdev/charting/interfaces/datasets/IDataSet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import android.graphics.Typeface
55
import info.appdev.charting.components.Legend
66
import info.appdev.charting.components.YAxis
77
import info.appdev.charting.data.DataSet
8-
import info.appdev.charting.data.EntryFloat
8+
import info.appdev.charting.data.BaseEntry
99
import info.appdev.charting.formatter.IValueFormatter
1010
import info.appdev.charting.utils.PointF
1111

12-
interface IDataSet<T : EntryFloat> {
12+
interface IDataSet<T : BaseEntry<Float>> {
1313
/**
1414
* returns the minimum y-value this DataSet holds
1515
*/

chartLib/src/main/kotlin/info/appdev/charting/interfaces/datasets/ILineRadarDataSet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package info.appdev.charting.interfaces.datasets
22

33
import android.graphics.drawable.Drawable
4-
import info.appdev.charting.data.EntryFloat
4+
import info.appdev.charting.data.BaseEntry
55

6-
interface ILineRadarDataSet<T : EntryFloat> : ILineScatterCandleRadarDataSet<T> {
6+
interface ILineRadarDataSet<T : BaseEntry<Float>> : ILineScatterCandleRadarDataSet<T> {
77
/**
88
* Returns the color that is used for filling the line surface area.
99
*/

chartLib/src/main/kotlin/info/appdev/charting/interfaces/datasets/ILineScatterCandleRadarDataSet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package info.appdev.charting.interfaces.datasets
22

33
import android.graphics.DashPathEffect
4-
import info.appdev.charting.data.EntryFloat
4+
import info.appdev.charting.data.BaseEntry
55

6-
interface ILineScatterCandleRadarDataSet<T : EntryFloat> : IBarLineScatterCandleBubbleDataSet<T> {
6+
interface ILineScatterCandleRadarDataSet<T : BaseEntry<Float>> : IBarLineScatterCandleBubbleDataSet<T> {
77
/**
88
* Returns true if vertical highlight indicator lines are enabled (drawn)
99
*/

chartLib/src/main/kotlin/info/appdev/charting/renderer/BarLineScatterCandleBubbleRenderer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package info.appdev.charting.renderer
22

33
import info.appdev.charting.animation.ChartAnimator
44
import info.appdev.charting.data.DataSet
5-
import info.appdev.charting.data.EntryFloat
5+
import info.appdev.charting.data.BaseEntry
66
import info.appdev.charting.interfaces.dataprovider.base.BarLineScatterCandleBubbleDataProvider
77
import info.appdev.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet
88
import info.appdev.charting.interfaces.datasets.IDataSet
@@ -29,7 +29,7 @@ abstract class BarLineScatterCandleBubbleRenderer(
2929
/**
3030
* Checks if the provided entry object is in bounds for drawing considering the current animation phase.
3131
*/
32-
protected fun <T : EntryFloat> isInBoundsX(entry: T, set: IBarLineScatterCandleBubbleDataSet<T>): Boolean {
32+
protected fun <T : BaseEntry<Float>> isInBoundsX(entry: T, set: IBarLineScatterCandleBubbleDataSet<T>): Boolean {
3333
val entryIndex = set.getEntryIndex(entry).toFloat()
3434

3535
return if (entryIndex >= set.entryCount * animator.phaseX) {
@@ -61,7 +61,7 @@ abstract class BarLineScatterCandleBubbleRenderer(
6161
/**
6262
* Calculates the minimum and maximum x values as well as the range between them.
6363
*/
64-
fun <T : EntryFloat> set(chart: BarLineScatterCandleBubbleDataProvider<*>, dataSet: IBarLineScatterCandleBubbleDataSet<T>) {
64+
fun <T : BaseEntry<Float>> set(chart: BarLineScatterCandleBubbleDataProvider<*>, dataSet: IBarLineScatterCandleBubbleDataSet<T>) {
6565
val phaseX = max(0f, min(1f, animator.phaseX))
6666

6767
val low = chart.lowestVisibleX

0 commit comments

Comments
 (0)