diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.java index d240b446e..883dd0881 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.java @@ -17,7 +17,6 @@ import com.github.mikephil.charting.interfaces.datasets.IPieDataSet; import com.github.mikephil.charting.renderer.PieChartRenderer; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.UtilsKtKt; import java.util.List; @@ -344,7 +343,7 @@ public XAxis getXAxis() { public int getIndexForAngle(float angle) { // take the current angle of the chart into consideration - float a = Utils.getNormalizedAngle(angle - getRotationAngle()); + float a = UtilsKtKt.getNormalizedAngle(angle - getRotationAngle()); for (int i = 0; i < mAbsoluteAngles.length; i++) { if (mAbsoluteAngles[i] > a) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.java index bc07f4138..45e8f336e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.java @@ -19,7 +19,6 @@ import com.github.mikephil.charting.interfaces.datasets.IDataSet; import com.github.mikephil.charting.listener.PieRadarChartTouchListener; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.UtilsKtKt; /** @@ -341,7 +340,7 @@ public float distanceToCenter(float x, float y) { */ public void setRotationAngle(float angle) { mRawRotationAngle = angle; - mRotationAngle = Utils.getNormalizedAngle(mRawRotationAngle); + mRotationAngle = UtilsKtKt.getNormalizedAngle(mRawRotationAngle); } /** diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.java index 15304dadd..5970841b9 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.java @@ -14,7 +14,6 @@ import com.github.mikephil.charting.renderer.RadarChartRenderer; import com.github.mikephil.charting.renderer.XAxisRendererRadarChart; import com.github.mikephil.charting.renderer.YAxisRendererRadarChart; -import com.github.mikephil.charting.utils.Utils; import com.github.mikephil.charting.utils.UtilsKtKt; import java.util.List; @@ -207,7 +206,7 @@ public List getLayerColorList() { public int getIndexForAngle(float angle) { // take the current angle of the chart into consideration - float a = Utils.getNormalizedAngle(angle - getRotationAngle()); + float a = UtilsKtKt.getNormalizedAngle(angle - getRotationAngle()); float sliceangle = getSliceAngle(); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java b/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java index 85adf9eec..12a5946a6 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.java @@ -3,6 +3,7 @@ import android.graphics.DashPathEffect; import android.graphics.Paint; +import com.github.mikephil.charting.utils.CanvasUtilsKt; import com.github.mikephil.charting.utils.ColorTemplate; import com.github.mikephil.charting.utils.FSize; import com.github.mikephil.charting.utils.Utils; @@ -199,7 +200,7 @@ public float getMaximumEntryWidth(Paint p) { String label = entry.label; if (label == null) continue; - float length = (float) Utils.calcTextWidth(p, label); + float length = (float) CanvasUtilsKt.calcTextWidth(p, label); if (length > max) max = length; @@ -221,7 +222,7 @@ public float getMaximumEntryHeight(Paint p) { String label = entry.label; if (label == null) continue; - float length = (float) Utils.calcTextHeight(p, label); + float length = (float) CanvasUtilsKt.calcTextHeight(p, label); if (length > max) max = length; @@ -636,7 +637,7 @@ else if (wasStacked) { wasStacked = false; } - width += Utils.calcTextWidth(labelpaint, label); + width += CanvasUtilsKt.calcTextWidth(labelpaint, label); maxHeight += labelLineHeight + yEntrySpace; } else { @@ -693,7 +694,7 @@ else if (wasStacked) { // grouped forms have null labels if (label != null) { - mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label)); + mCalculatedLabelSizes.add(CanvasUtilsKt.calcTextSize(labelpaint, label)); requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f; requiredWidth += mCalculatedLabelSizes.get(i).width; } else { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/components/YAxis.java b/MPChartLib/src/main/java/com/github/mikephil/charting/components/YAxis.java index d8a04ea86..abe06612a 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/components/YAxis.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/components/YAxis.java @@ -3,7 +3,7 @@ import android.graphics.Color; import android.graphics.Paint; -import com.github.mikephil.charting.utils.Utils; +import com.github.mikephil.charting.utils.CanvasUtilsKt; import com.github.mikephil.charting.utils.UtilsKtKt; /** @@ -309,7 +309,7 @@ public float getRequiredWidthSpace(Paint p) { p.setTextSize(mTextSize); String label = getLongestLabel(p); - float width = (float) Utils.calcTextWidth(p, label) + getXOffset() * 2f; + float width = (float) CanvasUtilsKt.calcTextWidth(p, label) + getXOffset() * 2f; float minWidth = getMinWidth(); float maxWidth = getMaxWidth(); @@ -333,7 +333,7 @@ public float getRequiredHeightSpace(Paint p) { p.setTextSize(mTextSize); String label = getLongestLabel(p); - return (float) Utils.calcTextHeight(p, label) + getYOffset() * 2f; + return (float) CanvasUtilsKt.calcTextHeight(p, label) + getYOffset() * 2f; } /** diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt index 5b79ed31d..6061cd003 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt @@ -11,8 +11,8 @@ import com.github.mikephil.charting.formatter.IValueFormatter import com.github.mikephil.charting.interfaces.datasets.IDataSet import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.convertDpToPixel +import com.github.mikephil.charting.utils.getDefaultValueFormatter /** * This is the base dataset of all DataSets. It's purpose is to implement critical methods diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.java b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.java index d9c64f667..8a03f21b6 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.java @@ -4,7 +4,7 @@ import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.interfaces.datasets.IDataSet; import com.github.mikephil.charting.utils.MPPointF; -import com.github.mikephil.charting.utils.Utils; +import com.github.mikephil.charting.utils.UtilsKtKt; import java.util.List; @@ -65,9 +65,9 @@ protected List getHighlightsAtIndex(int index) { float y = (entry.getY() - mChart.getYChartMin()); - Utils.getPosition( + pOut = UtilsKtKt.getPosition( mChart.getCenterOffsets(), y * factor * phaseY, - sliceangle * index * phaseX + mChart.getRotationAngle(), pOut + sliceangle * index * phaseX + mChart.getRotationAngle() ); mHighlightBuffer.add(new Highlight(index, entry.getY(), pOut.x, pOut.y, i, dataSet.getAxisDependency())); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.kt index 9f33e863c..756e164f8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.kt @@ -14,6 +14,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Transformer import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.ceil import kotlin.math.min @@ -277,7 +278,7 @@ open class BarChartRenderer( // calculate the correct offset depending on the draw position of // the value - val valueTextHeight = Utils.calcTextHeight(paintValues, "8").toFloat() + val valueTextHeight = paintValues.calcTextHeight("8").toFloat() posOffset = (if (drawValueAboveBar) -valueOffsetPlus else valueTextHeight + valueOffsetPlus) negOffset = (if (drawValueAboveBar) valueTextHeight + valueOffsetPlus else -valueOffsetPlus) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.kt index efecf4f61..384a6a9fc 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.kt @@ -10,6 +10,7 @@ import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.abs import kotlin.math.max @@ -96,7 +97,7 @@ open class BubbleChartRenderer( if (isDrawingValuesAllowed(dataProvider)) { val dataSets = bubbleData.dataSets - val lineHeight = Utils.calcTextHeight(paintValues, "1").toFloat() + val lineHeight = paintValues.calcTextHeight("1").toFloat() for (i in dataSets.indices) { val dataSet = dataSets[i] diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt index fe0b27469..d5a2db51b 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt @@ -14,6 +14,8 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Transformer import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight +import com.github.mikephil.charting.utils.calcTextWidth import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.ceil import kotlin.math.min @@ -187,7 +189,7 @@ open class HorizontalBarChartRenderer( // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet) - val halfTextHeight = Utils.calcTextHeight(paintValues, "10") / 2f + val halfTextHeight = paintValues.calcTextHeight("10") / 2f val formatter = dataSet.valueFormatter @@ -225,7 +227,7 @@ open class HorizontalBarChartRenderer( val valueY = barEntry.y val formattedValue = formatter.getFormattedValue(valueY, barEntry, i, viewPortHandler) // calculate the correct offset depending on the draw position of the value - val valueTextWidth = Utils.calcTextWidth(paintValues, formattedValue).toFloat() + val valueTextWidth = paintValues.calcTextWidth(formattedValue).toFloat() posOffset = (if (drawValueAboveBar) valueOffsetPlus else -(valueTextWidth + valueOffsetPlus)) negOffset = ((if (drawValueAboveBar) -(valueTextWidth + valueOffsetPlus) else valueOffsetPlus) - (buffer.buffer[j + 2] - buffer.buffer[j])) @@ -302,7 +304,7 @@ open class HorizontalBarChartRenderer( ) // calculate the correct offset depending on the draw position of the value - val valueTextWidth = Utils.calcTextWidth(paintValues, formattedValue).toFloat() + val valueTextWidth = paintValues.calcTextWidth(formattedValue).toFloat() posOffset = (if (drawValueAboveBar) valueOffsetPlus else -(valueTextWidth + valueOffsetPlus)) negOffset = (if (drawValueAboveBar) -(valueTextWidth + valueOffsetPlus) else valueOffsetPlus) @@ -380,7 +382,7 @@ open class HorizontalBarChartRenderer( ) // calculate the correct offset depending on the draw position of the value - val valueTextWidth = Utils.calcTextWidth(paintValues, formattedValue).toFloat() + val valueTextWidth = paintValues.calcTextWidth(formattedValue).toFloat() posOffset = (if (drawValueAboveBar) valueOffsetPlus else -(valueTextWidth + valueOffsetPlus)) negOffset = (if (drawValueAboveBar) -(valueTextWidth + valueOffsetPlus) else valueOffsetPlus) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.kt index ac0b65448..2d5f20db8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LegendRenderer.kt @@ -19,6 +19,8 @@ import com.github.mikephil.charting.interfaces.datasets.IPieDataSet import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight +import com.github.mikephil.charting.utils.calcTextWidth import com.github.mikephil.charting.utils.convertDpToPixel import java.util.Collections import kotlin.math.min @@ -210,7 +212,7 @@ open class LegendRenderer( val labelLineHeight = Utils.getLineHeight(labelPaint, legendFontMetrics) val labelLineSpacing = (Utils.getLineSpacing(labelPaint, legendFontMetrics) + legend.yEntrySpace.convertDpToPixel()) - val formYOffset = labelLineHeight - Utils.calcTextHeight(labelPaint, "ABC") / 2f + val formYOffset = labelLineHeight - labelPaint.calcTextHeight("ABC") / 2f val entries = legend.entries @@ -380,7 +382,7 @@ open class LegendRenderer( -formToTextSpace else if (wasStacked) posX = originPosX - if (direction == LegendDirection.RIGHT_TO_LEFT) posX -= Utils.calcTextWidth(labelPaint, e.label).toFloat() + if (direction == LegendDirection.RIGHT_TO_LEFT) posX -= labelPaint.calcTextWidth(e.label).toFloat() if (!wasStacked) { drawLabel(canvas, posX, posY + labelLineHeight, e.label) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.kt index 38027684f..6bfbb8724 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.kt @@ -21,6 +21,7 @@ import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight import com.github.mikephil.charting.utils.convertDpToPixel import java.lang.ref.WeakReference import kotlin.math.abs @@ -406,8 +407,7 @@ open class PieChartRenderer( // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet) - val lineHeight = (Utils.calcTextHeight(paintValues, "Q") - + 4f.convertDpToPixel()) + val lineHeight = paintValues.calcTextHeight("Q") + 4f.convertDpToPixel() val formatter = dataSet.valueFormatter diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt index 743b7ea9b..0a6f01410 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt @@ -14,6 +14,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler import com.github.mikephil.charting.utils.convertDpToPixel +import com.github.mikephil.charting.utils.getPosition open class RadarChartRenderer( protected var chart: RadarChart, animator: ChartAnimator, @@ -63,7 +64,7 @@ open class RadarChartRenderer( val factor = chart.factor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) val surface = drawDataSetSurfacePathBuffer surface.reset() @@ -74,10 +75,9 @@ open class RadarChartRenderer( dataSet.getEntryForIndex(j)?.let { e -> - Utils.getPosition( - center, + pOut = center.getPosition( (e.y - chart.yChartMin) * factor * phaseY, - sliceAngle * j * phaseX + chart.rotationAngle, pOut + sliceAngle * j * phaseX + chart.rotationAngle ) } if (java.lang.Float.isNaN(pOut.x)) continue @@ -125,8 +125,8 @@ open class RadarChartRenderer( val factor = chart.factor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) - val pIcon = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) + var pIcon = MPPointF.getInstance(0f, 0f) val yOffset = 5f.convertDpToPixel() @@ -149,12 +149,10 @@ open class RadarChartRenderer( for (j in 0.. - Utils.getPosition( - center, + pOut = center.getPosition( (entry.y - chart.yChartMin) * factor * phaseY, - sliceAngle * j * phaseX + chart.rotationAngle, - pOut - ) + sliceAngle * j * phaseX + chart.rotationAngle + ) if (dataSet.isDrawValues) { drawValue( @@ -172,12 +170,10 @@ open class RadarChartRenderer( if (entry.icon != null && dataSet.isDrawIcons) { val icon = entry.icon - Utils.getPosition( - center, + pIcon = center.getPosition( (entry.y) * factor * phaseY + iconsOffset.y, - sliceAngle * j * phaseX + chart.rotationAngle, - pIcon - ) + sliceAngle * j * phaseX + chart.rotationAngle + ) pIcon.y += iconsOffset.x @@ -223,14 +219,12 @@ open class RadarChartRenderer( val xIncrements = 1 + chart.skipWebLineCount val maxEntryCount = chart.data!!.maxEntryCountSet.entryCount - val p = MPPointF.getInstance(0f, 0f) + var p = MPPointF.getInstance(0f, 0f) var i = 0 while (i < maxEntryCount) { - Utils.getPosition( - center, + p = center.getPosition( chart.yRange * factor, - sliceAngle * i + rotationAngle, - p + sliceAngle * i + rotationAngle ) canvas.drawLine(center.x, center.y, p.x, p.y, webPaint) @@ -245,8 +239,8 @@ open class RadarChartRenderer( val labelCount = chart.yAxis.mEntryCount - val p1out = MPPointF.getInstance(0f, 0f) - val p2out = MPPointF.getInstance(0f, 0f) + var p1out = MPPointF.getInstance(0f, 0f) + var p2out = MPPointF.getInstance(0f, 0f) for (j in 0.. 1) { - val width = Utils.calcTextWidth(paintAxisLabels, label).toFloat() + val width = paintAxisLabels.calcTextWidth(label).toFloat() if (width > viewPortHandler.offsetRight() * 2 && x + width > viewPortHandler.chartWidth @@ -209,7 +213,7 @@ open class XAxisRenderer( // avoid clipping of the first } else if (i == 0) { - val width = Utils.calcTextWidth(paintAxisLabels, label).toFloat() + val width = paintAxisLabels.calcTextWidth(label).toFloat() x += width / 2 } } @@ -221,7 +225,7 @@ open class XAxisRenderer( } protected fun drawLabel(canvas: Canvas, formattedLabel: String?, x: Float, y: Float, anchor: MPPointF, angleDegrees: Float) { - Utils.drawXAxisValue(canvas, formattedLabel, x, y, paintAxisLabels, anchor, angleDegrees) + canvas.drawXAxisValue(formattedLabel, x, y, paintAxisLabels, anchor, angleDegrees) } protected open var mRenderGridLinesPath: Path = Path() @@ -386,7 +390,7 @@ open class XAxisRenderer( when (labelPosition) { LimitLabelPosition.RIGHT_TOP -> { - val labelLineHeight = Utils.calcTextHeight(limitLinePaint, label).toFloat() + val labelLineHeight = limitLinePaint.calcTextHeight(label).toFloat() limitLinePaint.textAlign = Align.LEFT canvas.drawText( label, position[0] + xOffset, viewPortHandler.contentTop() + yOffset + labelLineHeight, @@ -399,7 +403,7 @@ open class XAxisRenderer( } LimitLabelPosition.LEFT_TOP -> { limitLinePaint.textAlign = Align.RIGHT - val labelLineHeight = Utils.calcTextHeight(limitLinePaint, label).toFloat() + val labelLineHeight = limitLinePaint.calcTextHeight(label).toFloat() canvas.drawText( label, position[0] - xOffset, viewPortHandler.contentTop() + yOffset + labelLineHeight, limitLinePaint diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt index e47e637cc..395fa0f93 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt @@ -15,6 +15,8 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Transformer import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextHeight +import com.github.mikephil.charting.utils.calcTextSize import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.roundToInt @@ -57,7 +59,7 @@ open class XAxisRendererHorizontalBarChart( val longest = xAxis.longestLabel - val labelSize = Utils.calcTextSize(paintAxisLabels, longest) + val labelSize = paintAxisLabels.calcTextSize(longest) val labelWidth = (labelSize.width + xAxis.xOffset * 3.5f).toInt().toFloat() val labelHeight = labelSize.height @@ -250,7 +252,7 @@ open class XAxisRendererHorizontalBarChart( limitLinePaint.strokeWidth = 0.5f limitLinePaint.textSize = limitLine.textSize - val labelLineHeight = Utils.calcTextHeight(limitLinePaint, label).toFloat() + val labelLineHeight = limitLinePaint.calcTextHeight(label).toFloat() val xOffset = 4f.convertDpToPixel() + limitLine.xOffset val yOffset = limitLine.lineWidth + labelLineHeight + limitLine.yOffset diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt index eb2a7e072..60c4be3ce 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt @@ -4,8 +4,8 @@ import android.graphics.Canvas import com.github.mikephil.charting.charts.RadarChart import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.getPosition class XAxisRendererRadarChart(viewPortHandler: ViewPortHandler, xAxis: XAxis, private val chart: RadarChart) : XAxisRenderer(viewPortHandler, xAxis, null) { override fun renderAxisLabels(canvas: Canvas) { @@ -26,14 +26,14 @@ class XAxisRendererRadarChart(viewPortHandler: ViewPortHandler, xAxis: XAxis, pr val factor = chart.factor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) for (i in 0.. { - val labelLineHeight = Utils.calcTextHeight(limitLinePaint, label).toFloat() + val labelLineHeight = limitLinePaint.calcTextHeight(label).toFloat() limitLinePaint.textAlign = Align.LEFT canvas.drawText(label, pts[0] + xOffset, viewPortHandler.contentTop() + yOffset + labelLineHeight, limitLinePaint) } @@ -290,7 +290,7 @@ open class YAxisRendererHorizontalBarChart( } LimitLabelPosition.LEFT_TOP -> { limitLinePaint.textAlign = Align.RIGHT - val labelLineHeight = Utils.calcTextHeight(limitLinePaint, label).toFloat() + val labelLineHeight = limitLinePaint.calcTextHeight(label).toFloat() canvas.drawText(label, pts[0] - xOffset, viewPortHandler.contentTop() + yOffset + labelLineHeight, limitLinePaint) } else -> { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererRadarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererRadarChart.kt index b7bb0ce51..2c477fdf2 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererRadarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/YAxisRendererRadarChart.kt @@ -5,8 +5,8 @@ import android.graphics.Path import com.github.mikephil.charting.charts.RadarChart import com.github.mikephil.charting.components.YAxis import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.getPosition import com.github.mikephil.charting.utils.roundToNextSignificant import kotlin.math.abs import kotlin.math.ceil @@ -144,7 +144,7 @@ class YAxisRendererRadarChart(viewPortHandler: ViewPortHandler, yAxis: YAxis, pr paintAxisLabels.color = yAxis.textColor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) val factor = chart.factor val from = if (yAxis.isDrawBottomYLabelEntryEnabled) 0 else 1 @@ -158,7 +158,7 @@ class YAxisRendererRadarChart(viewPortHandler: ViewPortHandler, yAxis: YAxis, pr for (j in from..