Skip to content

Commit 7776519

Browse files
committed
Cosmetic
1 parent 4a96a6a commit 7776519

File tree

8 files changed

+58
-54
lines changed

8 files changed

+58
-54
lines changed

chartLib/src/main/kotlin/info/appdev/charting/charts/BarChart.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,19 @@ open class BarChart : BarLineChartBase<BarData>, BarDataProvider {
9595
return null
9696
} else {
9797
highlighter?.let {
98-
val h = it.getHighlight(x, y)
99-
if (h == null || !isHighlightFullBar)
100-
return h
98+
val highlight = it.getHighlight(x, y)
99+
if (highlight == null || !isHighlightFullBar)
100+
return highlight
101101

102102
// For isHighlightFullBarEnabled, remove stackIndex
103103
return Highlight(
104-
h.x, h.y,
105-
h.xPx, h.yPx,
106-
h.dataSetIndex, -1, h.axis
104+
x = highlight.x,
105+
y = highlight.y,
106+
xPx = highlight.xPx,
107+
yPx = highlight.yPx,
108+
dataSetIndex = highlight.dataSetIndex,
109+
stackIndex = -1,
110+
axis = highlight.axis
107111
)
108112
}
109113
}

chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,10 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
259259
invalidate()
260260
}
261261

262+
/**
263+
* Returns true if the chart is empty (meaning it's data object is either null or contains no entries).
264+
*/
262265
val isEmpty: Boolean
263-
/**
264-
* Returns true if the chart is empty (meaning it's data object is either
265-
* null or contains no entries).
266-
*/
267266
get() {
268267
return if (mData == null) {
269268
true
@@ -353,7 +352,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
353352
*/
354353
protected fun drawDescription(canvas: Canvas) {
355354
// check if description should be drawn
356-
357355
if (description.isEnabled) {
358356
val position = description.position
359357

@@ -761,12 +759,12 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
761759
mAnimator.animateXY(durationMillisX, durationMillisY)
762760
}
763761

762+
/**
763+
* Returns the object representing all x-labels, this method can be used to
764+
* acquire the XAxis object and modify it (e.g. change the position of the
765+
* labels, styling, etc.)
766+
*/
764767
open val xAxis: XAxis
765-
/**
766-
* Returns the object representing all x-labels, this method can be used to
767-
* acquire the XAxis object and modify it (e.g. change the position of the
768-
* labels, styling, etc.)
769-
*/
770768
get() = mXAxis
771769

772770
/**
@@ -1046,17 +1044,13 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
10461044
}
10471045

10481046
/**
1049-
* Sets a custom highlighter object for the chart that handles / processes
1050-
* all highlight touch events performed on the chart-view.
1047+
* Returns a recyclable PointF instance.
10511048
*/
10521049
fun setHighlighter(highlighter: ChartHighlighter<*>?) {
10531050
this.highlighter = highlighter
10541051
}
10551052

10561053
override val centerOfView: PointF
1057-
/**
1058-
* Returns a recyclable PointF instance.
1059-
*/
10601054
get() = this.center
10611055

10621056
/**
@@ -1186,8 +1180,8 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
11861180
}
11871181
}
11881182

1189-
// This may cause the chart view to mutate properties affecting the view port --
1190-
// lets do this before we try to run any pending jobs on the view port itself
1183+
// This may cause the chart view to mutate properties affecting the view port.
1184+
// lets do this before we try to run any pending jobs on the view port itself
11911185
notifyDataSetChanged()
11921186

11931187
for (r in this.jobs) {
@@ -1214,7 +1208,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
12141208
override fun onDetachedFromWindow() {
12151209
super.onDetachedFromWindow()
12161210

1217-
//Timber.i("Detaching...");
12181211
if (mUnbind) {
12191212
unbindDrawables(this)
12201213
}
@@ -1251,7 +1244,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>> : ViewGroup, IBaseP
12511244
this.mUnbind = enabled
12521245
}
12531246

1254-
// region accessibility
12551247
/**
12561248
* @return accessibility description must be created for each chart
12571249
*/

chartLib/src/main/kotlin/info/appdev/charting/charts/CombinedChart.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,13 @@ open class CombinedChart : BarLineChartBase<CombinedData>, CombinedDataProvider
400400

401401
// For isHighlightFullBarEnabled, remove stackIndex
402402
return Highlight(
403-
highlight.x,
404-
highlight.y,
405-
highlight.xPx,
406-
highlight.yPx,
407-
highlight.dataSetIndex,
408-
-1,
409-
highlight.axis
403+
x = highlight.x,
404+
y = highlight.y,
405+
xPx = highlight.xPx,
406+
yPx = highlight.yPx,
407+
dataSetIndex = highlight.dataSetIndex,
408+
stackIndex = -1,
409+
axis = highlight.axis
410410
)
411411
}
412412
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ open class BarHighlighter(barDataProvider: BarDataProvider) : ChartHighlighter<B
4949
val pixels = provider.getTransformer(set.axisDependency)!!.getPixelForValues(high.x, ranges[stackIndex].to)
5050

5151
val stackedHigh = Highlight(
52-
entry.x,
53-
entry.y,
54-
pixels.x.toFloat(),
55-
pixels.y.toFloat(),
56-
high.dataSetIndex,
57-
stackIndex,
58-
high.axis
52+
x = entry.x,
53+
y = entry.y,
54+
xPx = pixels.x.toFloat(),
55+
yPx = pixels.y.toFloat(),
56+
dataSetIndex = high.dataSetIndex,
57+
stackIndex = stackIndex,
58+
axis = high.axis
5959
)
6060

6161
PointD.recycleInstance(pixels)

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ open class ChartHighlighter<T : BarLineScatterCandleBubbleDataProvider<*>>(prote
114114
* An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex.
115115
*/
116116
@Suppress("SameParameterValue")
117-
protected open fun buildHighlights(set: IDataSet<*>, dataSetIndex: Int, xVal: Float, rounding: DataSet.Rounding?): MutableList<Highlight> {
117+
protected open fun buildHighlights(
118+
set: IDataSet<*>,
119+
dataSetIndex: Int,
120+
xVal: Float,
121+
rounding: DataSet.Rounding?
122+
): MutableList<Highlight> {
118123
val highlights = ArrayList<Highlight>()
119124

120125
var entries = set.getEntriesForXValue(xVal)
@@ -135,9 +140,12 @@ open class ChartHighlighter<T : BarLineScatterCandleBubbleDataProvider<*>>(prote
135140

136141
highlights.add(
137142
Highlight(
138-
e.x, e.y,
139-
pixels.x.toFloat(), pixels.y.toFloat(),
140-
dataSetIndex, set.axisDependency
143+
x = e.x,
144+
y = e.y,
145+
xPx = pixels.x.toFloat(),
146+
yPx = pixels.y.toFloat(),
147+
dataSetIndex = dataSetIndex,
148+
axis = set.axisDependency
141149
)
142150
)
143151
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ class Highlight : Serializable {
108108
* selected
109109
*/
110110
constructor(x: Float, y: Float, xPx: Float, yPx: Float, dataSetIndex: Int, stackIndex: Int, axis: AxisDependency?) : this(
111-
x,
112-
y,
113-
xPx,
114-
yPx,
115-
dataSetIndex,
116-
axis
111+
x = x,
112+
y = y,
113+
xPx = xPx,
114+
yPx = yPx,
115+
dataSetIndex = dataSetIndex,
116+
axis = axis
117117
) {
118118
this.stackIndex = stackIndex
119119
}
@@ -144,6 +144,6 @@ class Highlight : Serializable {
144144
}
145145

146146
override fun toString(): String {
147-
return "Highlight, x:$x y:$y dataSetIndex:$dataSetIndex stackIndex:$stackIndex (only stacked bar entry)"
147+
return "Highlight, x:$x y:$y dataSetIndex:$dataSetIndex stackIndex:$stackIndex dataIndex:$dataIndex (only stacked bar entry)"
148148
}
149149
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ abstract class PieRadarHighlighter<T : PieRadarChartBase<*>>(protected var chart
66
/**
77
* buffer for storing previously highlighted values
88
*/
9-
protected var mHighlightBuffer: MutableList<Highlight> = ArrayList()
9+
protected var highlightBuffer: MutableList<Highlight> = ArrayList()
1010

1111
override fun getHighlight(x: Float, y: Float): Highlight? {
1212
val touchDistanceToCenter = chartPieRadar.distanceToCenter(x, y)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ open class RadarHighlighter(chart: RadarChart) : PieRadarHighlighter<RadarChart>
3535
* runtime. Do not over-use in performance critical situations.
3636
*/
3737
protected fun getHighlightsAtIndex(index: Int): MutableList<Highlight> {
38-
mHighlightBuffer.clear()
38+
highlightBuffer.clear()
3939

4040
val phaseX = chartPieRadar.animator.phaseX
4141
val phaseY = chartPieRadar.animator.phaseY
@@ -56,9 +56,9 @@ open class RadarHighlighter(chart: RadarChart) : PieRadarHighlighter<RadarChart>
5656
sliceAngle * index * phaseX + chartPieRadar.rotationAngle, pOut
5757
)
5858

59-
mHighlightBuffer.add(Highlight(index.toFloat(), entry.y, pOut.x, pOut.y, i, dataSet.axisDependency))
59+
highlightBuffer.add(Highlight(index.toFloat(), entry.y, pOut.x, pOut.y, i, dataSet.axisDependency))
6060
}
6161
}
62-
return mHighlightBuffer
62+
return highlightBuffer
6363
}
6464
}

0 commit comments

Comments
 (0)