@@ -26,9 +26,9 @@ open class XAxisRenderer(
2626) :
2727 AxisRenderer (viewPortHandler, trans, xAxis) {
2828 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)
3232 }
3333
3434 override fun computeAxis (min : Float , max : Float , inverted : Boolean ) {
@@ -65,8 +65,8 @@ open class XAxisRenderer(
6565 protected open fun computeSize () {
6666 val longest = xAxis.longestLabel
6767
68- paintAxisLabels!! .setTypeface(xAxis.typeface)
69- paintAxisLabels!! .textSize = xAxis.textSize
68+ paintAxisLabels.setTypeface(xAxis.typeface)
69+ paintAxisLabels.textSize = xAxis.textSize
7070
7171 val labelSize = Utils .calcTextSize(paintAxisLabels, longest)
7272
@@ -92,7 +92,7 @@ open class XAxisRenderer(
9292
9393 val yoffset = xAxis.yOffset
9494
95- paintAxisLabels!! .color = xAxis.textColor
95+ paintAxisLabels.color = xAxis.textColor
9696
9797 val pointF = MPPointF .getInstance(0f , 0f )
9898 when (xAxis.position) {
@@ -131,23 +131,23 @@ open class XAxisRenderer(
131131 override fun renderAxisLine (c : Canvas ) {
132132 if (! xAxis.isDrawAxisLineEnabled || ! xAxis.isEnabled) return
133133
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)
137137
138138 if (xAxis.position == XAxisPosition .TOP || xAxis.position == XAxisPosition .TOP_INSIDE || xAxis.position == XAxisPosition .BOTH_SIDED ) {
139139 c.drawLine(
140140 viewPortHandler.contentLeft(),
141141 viewPortHandler.contentTop(), viewPortHandler.contentRight(),
142- viewPortHandler.contentTop(), paintAxisLine!!
142+ viewPortHandler.contentTop(), paintAxisLine
143143 )
144144 }
145145
146146 if (xAxis.position == XAxisPosition .BOTTOM || xAxis.position == XAxisPosition .BOTTOM_INSIDE || xAxis.position == XAxisPosition .BOTH_SIDED ) {
147147 c.drawLine(
148148 viewPortHandler.contentLeft(),
149149 viewPortHandler.contentBottom(), viewPortHandler.contentRight(),
150- viewPortHandler.contentBottom(), paintAxisLine!!
150+ viewPortHandler.contentBottom(), paintAxisLine
151151 )
152152 }
153153 }
@@ -223,8 +223,8 @@ open class XAxisRenderer(
223223 Utils .drawXAxisValue(c, formattedLabel, x, y, paintAxisLabels, anchor, angleDegrees)
224224 }
225225
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 )
228228 override fun renderGridLines (c : Canvas ) {
229229 if (! xAxis.isDrawGridLinesEnabled || ! xAxis.isEnabled) return
230230
@@ -280,6 +280,21 @@ open class XAxisRenderer(
280280 return mGridClippingRect
281281 }
282282
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+
283298 /* *
284299 * Draws the grid line at the specified position using the provided path.
285300 *
@@ -293,16 +308,28 @@ open class XAxisRenderer(
293308 gridLinePath.lineTo(x, viewPortHandler.contentTop())
294309
295310 // draw a path because lines don't support dashing on lower android versions
296- c.drawPath(gridLinePath, paintGrid!! )
311+ c.drawPath(gridLinePath, paintGrid)
297312
298313 gridLinePath.reset()
299314 }
300315
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()
303321
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+ }
306333
307334 /* *
308335 * Draws the LimitLines associated with this axis to the screen.
@@ -340,33 +367,6 @@ open class XAxisRenderer(
340367 }
341368 }
342369
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-
370370 fun renderLimitLineLabel (c : Canvas , limitLine : LimitLine , position : FloatArray , yOffset : Float ) {
371371 val label = limitLine.label
372372
0 commit comments