@@ -26,9 +26,9 @@ open class XAxisRenderer(
26
26
) :
27
27
AxisRenderer (viewPortHandler, trans, xAxis) {
28
28
protected fun setupGridPaint () {
29
- paintGrid!! .color = xAxis.gridColor
30
- paintGrid!! .strokeWidth = xAxis.gridLineWidth
31
- paintGrid!! .setPathEffect(xAxis.gridDashPathEffect)
29
+ paintGrid.color = xAxis.gridColor
30
+ paintGrid.strokeWidth = xAxis.gridLineWidth
31
+ paintGrid.setPathEffect(xAxis.gridDashPathEffect)
32
32
}
33
33
34
34
override fun computeAxis (min : Float , max : Float , inverted : Boolean ) {
@@ -65,8 +65,8 @@ open class XAxisRenderer(
65
65
protected open fun computeSize () {
66
66
val longest = xAxis.longestLabel
67
67
68
- paintAxisLabels!! .setTypeface(xAxis.typeface)
69
- paintAxisLabels!! .textSize = xAxis.textSize
68
+ paintAxisLabels.setTypeface(xAxis.typeface)
69
+ paintAxisLabels.textSize = xAxis.textSize
70
70
71
71
val labelSize = Utils .calcTextSize(paintAxisLabels, longest)
72
72
@@ -92,7 +92,7 @@ open class XAxisRenderer(
92
92
93
93
val yoffset = xAxis.yOffset
94
94
95
- paintAxisLabels!! .color = xAxis.textColor
95
+ paintAxisLabels.color = xAxis.textColor
96
96
97
97
val pointF = MPPointF .getInstance(0f , 0f )
98
98
when (xAxis.position) {
@@ -131,23 +131,23 @@ open class XAxisRenderer(
131
131
override fun renderAxisLine (c : Canvas ) {
132
132
if (! xAxis.isDrawAxisLineEnabled || ! xAxis.isEnabled) return
133
133
134
- paintAxisLine!! .color = xAxis.axisLineColor
135
- paintAxisLine!! .strokeWidth = xAxis.axisLineWidth
136
- paintAxisLine!! .setPathEffect(xAxis.axisLineDashPathEffect)
134
+ paintAxisLine.color = xAxis.axisLineColor
135
+ paintAxisLine.strokeWidth = xAxis.axisLineWidth
136
+ paintAxisLine.setPathEffect(xAxis.axisLineDashPathEffect)
137
137
138
138
if (xAxis.position == XAxisPosition .TOP || xAxis.position == XAxisPosition .TOP_INSIDE || xAxis.position == XAxisPosition .BOTH_SIDED ) {
139
139
c.drawLine(
140
140
viewPortHandler.contentLeft(),
141
141
viewPortHandler.contentTop(), viewPortHandler.contentRight(),
142
- viewPortHandler.contentTop(), paintAxisLine!!
142
+ viewPortHandler.contentTop(), paintAxisLine
143
143
)
144
144
}
145
145
146
146
if (xAxis.position == XAxisPosition .BOTTOM || xAxis.position == XAxisPosition .BOTTOM_INSIDE || xAxis.position == XAxisPosition .BOTH_SIDED ) {
147
147
c.drawLine(
148
148
viewPortHandler.contentLeft(),
149
149
viewPortHandler.contentBottom(), viewPortHandler.contentRight(),
150
- viewPortHandler.contentBottom(), paintAxisLine!!
150
+ viewPortHandler.contentBottom(), paintAxisLine
151
151
)
152
152
}
153
153
}
@@ -223,8 +223,8 @@ open class XAxisRenderer(
223
223
Utils .drawXAxisValue(c, formattedLabel, x, y, paintAxisLabels, anchor, angleDegrees)
224
224
}
225
225
226
- protected var mRenderGridLinesPath: Path = Path ()
227
- protected var mRenderGridLinesBuffer: FloatArray = FloatArray (2 )
226
+ protected open var mRenderGridLinesPath: Path = Path ()
227
+ protected open var mRenderGridLinesBuffer: FloatArray = FloatArray (2 )
228
228
override fun renderGridLines (c : Canvas ) {
229
229
if (! xAxis.isDrawGridLinesEnabled || ! xAxis.isEnabled) return
230
230
@@ -280,6 +280,21 @@ open class XAxisRenderer(
280
280
return mGridClippingRect
281
281
}
282
282
283
+ @JvmField
284
+ protected var mRenderLimitLinesBuffer: FloatArray = FloatArray (2 )
285
+
286
+ @JvmField
287
+ protected var mLimitLineClippingRect: RectF = RectF ()
288
+
289
+ var limitLineSegmentsBuffer: FloatArray = FloatArray (4 )
290
+ private val mLimitLinePath = Path ()
291
+
292
+ init {
293
+ paintAxisLabels.color = Color .BLACK
294
+ paintAxisLabels.textAlign = Align .CENTER
295
+ paintAxisLabels.textSize = Utils .convertDpToPixel(10f )
296
+ }
297
+
283
298
/* *
284
299
* Draws the grid line at the specified position using the provided path.
285
300
*
@@ -293,16 +308,28 @@ open class XAxisRenderer(
293
308
gridLinePath.lineTo(x, viewPortHandler.contentTop())
294
309
295
310
// draw a path because lines don't support dashing on lower android versions
296
- c.drawPath(gridLinePath, paintGrid!! )
311
+ c.drawPath(gridLinePath, paintGrid)
297
312
298
313
gridLinePath.reset()
299
314
}
300
315
301
- @JvmField
302
- protected var mRenderLimitLinesBuffer: FloatArray = FloatArray (2 )
316
+ fun renderLimitLineLine (c : Canvas , limitLine : LimitLine , position : FloatArray ) {
317
+ limitLineSegmentsBuffer[0 ] = position[0 ]
318
+ limitLineSegmentsBuffer[1 ] = viewPortHandler.contentTop()
319
+ limitLineSegmentsBuffer[2 ] = position[0 ]
320
+ limitLineSegmentsBuffer[3 ] = viewPortHandler.contentBottom()
303
321
304
- @JvmField
305
- protected var mLimitLineClippingRect: RectF = RectF ()
322
+ mLimitLinePath.reset()
323
+ mLimitLinePath.moveTo(limitLineSegmentsBuffer[0 ], limitLineSegmentsBuffer[1 ])
324
+ mLimitLinePath.lineTo(limitLineSegmentsBuffer[2 ], limitLineSegmentsBuffer[3 ])
325
+
326
+ limitLinePaint.style = Paint .Style .STROKE
327
+ limitLinePaint.color = limitLine.lineColor
328
+ limitLinePaint.strokeWidth = limitLine.lineWidth
329
+ limitLinePaint.setPathEffect(limitLine.dashPathEffect)
330
+
331
+ c.drawPath(mLimitLinePath, limitLinePaint)
332
+ }
306
333
307
334
/* *
308
335
* Draws the LimitLines associated with this axis to the screen.
@@ -340,33 +367,6 @@ open class XAxisRenderer(
340
367
}
341
368
}
342
369
343
- var mLimitLineSegmentsBuffer: FloatArray = FloatArray (4 )
344
- private val mLimitLinePath = Path ()
345
-
346
- init {
347
- paintAxisLabels!! .color = Color .BLACK
348
- paintAxisLabels!! .textAlign = Align .CENTER
349
- paintAxisLabels!! .textSize = Utils .convertDpToPixel(10f )
350
- }
351
-
352
- fun renderLimitLineLine (c : Canvas , limitLine : LimitLine , position : FloatArray ) {
353
- mLimitLineSegmentsBuffer[0 ] = position[0 ]
354
- mLimitLineSegmentsBuffer[1 ] = viewPortHandler.contentTop()
355
- mLimitLineSegmentsBuffer[2 ] = position[0 ]
356
- mLimitLineSegmentsBuffer[3 ] = viewPortHandler.contentBottom()
357
-
358
- mLimitLinePath.reset()
359
- mLimitLinePath.moveTo(mLimitLineSegmentsBuffer[0 ], mLimitLineSegmentsBuffer[1 ])
360
- mLimitLinePath.lineTo(mLimitLineSegmentsBuffer[2 ], mLimitLineSegmentsBuffer[3 ])
361
-
362
- limitLinePaint.style = Paint .Style .STROKE
363
- limitLinePaint.color = limitLine.lineColor
364
- limitLinePaint.strokeWidth = limitLine.lineWidth
365
- limitLinePaint.setPathEffect(limitLine.dashPathEffect)
366
-
367
- c.drawPath(mLimitLinePath, limitLinePaint)
368
- }
369
-
370
370
fun renderLimitLineLabel (c : Canvas , limitLine : LimitLine , position : FloatArray , yOffset : Float ) {
371
371
val label = limitLine.label
372
372
0 commit comments