diff --git a/chartLib/src/main/kotlin/info/appdev/charting/components/Legend.kt b/chartLib/src/main/kotlin/info/appdev/charting/components/Legend.kt index a2af9adab..aba13720b 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/components/Legend.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/components/Legend.kt @@ -8,7 +8,6 @@ import info.appdev.charting.utils.Utils import info.appdev.charting.utils.ViewPortHandler import info.appdev.charting.utils.calcTextHeight import info.appdev.charting.utils.convertDpToPixel -import java.lang.Float import kotlin.Array import kotlin.Boolean import kotlin.IntArray @@ -126,12 +125,12 @@ class Legend() : ComponentBase() { /** * the size of the legend forms/shapes */ - var formSize: kotlin.Float = 8f + var formSize: Float = 8f /** * the size of the legend forms/shapes */ - var formLineWidth: kotlin.Float = 3f + var formLineWidth: Float = 3f /** * Line dash path effect used for shapes that consist of lines. @@ -141,24 +140,24 @@ class Legend() : ComponentBase() { /** * the space between the legend entries on a horizontal axis, default 6f */ - var xEntrySpace: kotlin.Float = 6f + var xEntrySpace: Float = 6f /** * the space between the legend entries on a vertical axis, default 5f */ - var yEntrySpace: kotlin.Float = 0f + var yEntrySpace: Float = 0f /** * the space between the legend entries on a vertical axis, default 2f * private float mYEntrySpace = 2f; / ** the space between the form and the * actual label/text */ - var formToTextSpace: kotlin.Float = 5f + var formToTextSpace: Float = 5f /** * the space that should be left between stacked forms */ - var stackSpace: kotlin.Float = 3f + var stackSpace: Float = 3f /** * The maximum relative size out of the whole chart view. / If the legend is @@ -168,7 +167,7 @@ class Legend() : ComponentBase() { * piechart, then this defines the size of the rectangular bounds out of the * size of the "hole". / default: 0.95f (95%) */ - var maxSizePercent: kotlin.Float = 0.95f + var maxSizePercent: Float = 0.95f /** * Constructor. Provide entries for the legend. @@ -190,13 +189,13 @@ class Legend() : ComponentBase() { * * @param p the paint object used for rendering the text */ - fun getMaximumEntryWidth(p: Paint): kotlin.Float { + fun getMaximumEntryWidth(p: Paint): Float { var max = 0f var maxFormSize = 0f val formToTextSpace = formToTextSpace.convertDpToPixel() for (entry in this.entries) { - val formSize = (if (Float.isNaN(entry.formSize)) + val formSize = (if (entry.formSize.isNaN()) this.formSize else entry.formSize).convertDpToPixel() @@ -217,7 +216,7 @@ class Legend() : ComponentBase() { * * @param p the paint object used for rendering the text */ - fun getMaximumEntryHeight(p: Paint): kotlin.Float { + fun getMaximumEntryHeight(p: Paint): Float { var max = 0f for (entry in this.entries) { @@ -311,18 +310,18 @@ class Legend() : ComponentBase() { * the total width of the legend (needed width space) */ @JvmField - var neededWidth: kotlin.Float = 0f + var neededWidth: Float = 0f /** * the total height of the legend (needed height space) */ @JvmField - var neededHeight: kotlin.Float = 0f + var neededHeight: Float = 0f @JvmField - var mTextHeightMax: kotlin.Float = 0f + var mTextHeightMax: Float = 0f - var mTextWidthMax: kotlin.Float = 0f + var mTextWidthMax: Float = 0f /** * If this is set, then word wrapping the legend is enabled. This means the @@ -383,7 +382,7 @@ class Legend() : ComponentBase() { while (i < entryCount) { val e = entries[i] val drawingForm = e.form != LegendForm.NONE - val formSize = if (Float.isNaN(e.formSize)) + val formSize = if (e.formSize.isNaN()) defaultFormSize else e.formSize.convertDpToPixel() @@ -444,7 +443,7 @@ class Legend() : ComponentBase() { while (i < entryCount) { val e = entries[i] val drawingForm = e.form != LegendForm.NONE - val formSize = if (Float.isNaN(e.formSize)) + val formSize = if (e.formSize.isNaN()) defaultFormSize else e.formSize.convertDpToPixel() diff --git a/chartLib/src/main/kotlin/info/appdev/charting/data/BarDataSet.kt b/chartLib/src/main/kotlin/info/appdev/charting/data/BarDataSet.kt index 4effeab5c..eb8ce7493 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/data/BarDataSet.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/data/BarDataSet.kt @@ -3,7 +3,6 @@ package info.appdev.charting.data import android.graphics.Color import info.appdev.charting.interfaces.datasets.IBarDataSet import info.appdev.charting.utils.Fill -import java.lang.Float import kotlin.Boolean import kotlin.Deprecated import kotlin.Int @@ -137,7 +136,7 @@ open class BarDataSet(yVals: MutableList, label: String) : BarLineScat } override fun calcMinMax(entry: BarEntry) { - if (!Float.isNaN(entry.y)) { + if (!entry.y.isNaN()) { if (entry.yVals == null) { if (entry.y < yMin) yMin = entry.y diff --git a/chartLib/src/main/kotlin/info/appdev/charting/data/CombinedData.kt b/chartLib/src/main/kotlin/info/appdev/charting/data/CombinedData.kt index 7b62595ed..d83fd7ecd 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/data/CombinedData.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/data/CombinedData.kt @@ -1,11 +1,9 @@ package info.appdev.charting.data -import android.util.Log import info.appdev.charting.components.YAxis import info.appdev.charting.highlight.Highlight import info.appdev.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet import timber.log.Timber -import java.lang.Float import kotlin.Boolean import kotlin.Deprecated import kotlin.Int @@ -152,7 +150,7 @@ class CombinedData : BarLineScatterCandleBubbleData( /** * maximum y-value in the value array */ - override var yMax: kotlin.Float = -Float.MAX_VALUE + override var yMax: Float = -Float.MAX_VALUE protected set /** * minimum y-value in the value array */ - override var yMin: kotlin.Float = Float.MAX_VALUE + override var yMin: Float = Float.MAX_VALUE protected set /** * maximum x-value in the value array */ - override var xMax: kotlin.Float = -Float.MAX_VALUE + override var xMax: Float = -Float.MAX_VALUE protected set /** * minimum x-value in the value array */ - override var xMin: kotlin.Float = Float.MAX_VALUE + override var xMin: Float = Float.MAX_VALUE protected set @@ -72,7 +71,7 @@ abstract class DataSet( } } - override fun calcMinMaxY(fromX: kotlin.Float, toX: kotlin.Float) { + override fun calcMinMaxY(fromX: Float, toX: Float) { this.yMax = -Float.MAX_VALUE this.yMin = Float.MAX_VALUE @@ -179,7 +178,7 @@ abstract class DataSet( override fun addEntryOrdered(entry: T) { if (mEntries == null) { - mEntries = ArrayList() + mEntries = ArrayList() } calcMinMax(entry) @@ -200,7 +199,7 @@ abstract class DataSet( override fun addEntry(entry: T): Boolean { var values = this.entries if (values == null) { - values = ArrayList() + values = ArrayList() } calcMinMax(entry) @@ -229,7 +228,7 @@ abstract class DataSet( } - override fun getEntryForXValue(xValue: kotlin.Float, closestToY: kotlin.Float, rounding: Rounding?): T? { + override fun getEntryForXValue(xValue: Float, closestToY: Float, rounding: Rounding?): T? { val index = getEntryIndex(xValue, closestToY, rounding) if (index > -1) { return mEntries!![index] @@ -237,7 +236,7 @@ abstract class DataSet( return null } - override fun getEntryForXValue(xValue: kotlin.Float, closestToY: kotlin.Float): T? { + override fun getEntryForXValue(xValue: Float, closestToY: Float): T? { return getEntryForXValue(xValue, closestToY, Rounding.CLOSEST) } @@ -252,7 +251,7 @@ abstract class DataSet( return mEntries!![index] } - override fun getEntryIndex(xValue: kotlin.Float, closestToY: kotlin.Float, rounding: Rounding?): Int { + override fun getEntryIndex(xValue: Float, closestToY: Float, rounding: Rounding?): Int { if (mEntries == null || mEntries!!.isEmpty()) { return -1 } @@ -311,7 +310,7 @@ abstract class DataSet( } // Search by closest to y-value - if (!Float.isNaN(closestToY)) { + if (!closestToY.isNaN()) { while (closest > 0 && mEntries!![closest - 1].x == closestXValue) { closest -= 1 } @@ -342,7 +341,7 @@ abstract class DataSet( return closest } - override fun getEntriesForXValue(xValue: kotlin.Float): MutableList { + override fun getEntriesForXValue(xValue: Float): MutableList { val entries: MutableList = mutableListOf() var low = 0 diff --git a/chartLib/src/main/kotlin/info/appdev/charting/renderer/LegendRenderer.kt b/chartLib/src/main/kotlin/info/appdev/charting/renderer/LegendRenderer.kt index 40e33abd0..555a1254d 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/renderer/LegendRenderer.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/renderer/LegendRenderer.kt @@ -290,7 +290,7 @@ open class LegendRenderer( while (i < entries.size) { val entry = entries[i] val drawingForm = entry.form != LegendForm.NONE - val formSize = if (java.lang.Float.isNaN(entry.formSize)) + val formSize = if (entry.formSize.isNaN()) defaultFormSize else entry.formSize.convertDpToPixel() @@ -369,7 +369,7 @@ open class LegendRenderer( while (i < entries.size) { val entry = entries[i] val drawingForm = entry.form != LegendForm.NONE - val formSize = if (java.lang.Float.isNaN(entry.formSize)) defaultFormSize else entry.formSize.convertDpToPixel() + val formSize = if (entry.formSize.isNaN()) defaultFormSize else entry.formSize.convertDpToPixel() var posX = originPosX @@ -451,7 +451,7 @@ open class LegendRenderer( formPaint.color = entry.formColor val formSize = ( - if (java.lang.Float.isNaN(entry.formSize)) + if (entry.formSize.isNaN()) legend.formSize else entry.formSize @@ -473,7 +473,7 @@ open class LegendRenderer( LegendForm.LINE -> { val formLineWidth = ( - if (java.lang.Float.isNaN(entry.formLineWidth)) + if (entry.formLineWidth.isNaN()) legend.formLineWidth else entry.formLineWidth diff --git a/chartLib/src/main/kotlin/info/appdev/charting/renderer/RadarChartRenderer.kt b/chartLib/src/main/kotlin/info/appdev/charting/renderer/RadarChartRenderer.kt index 1ee3a8c8e..7d4528273 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/renderer/RadarChartRenderer.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/renderer/RadarChartRenderer.kt @@ -78,7 +78,8 @@ open class RadarChartRenderer( sliceAngle * j * phaseX + chart.rotationAngle, pOut ) } - if (java.lang.Float.isNaN(pOut.x)) continue + if (pOut.x.isNaN()) + continue if (!hasMovedToPoint) { surface.moveTo(pOut.x, pOut.y) @@ -324,7 +325,7 @@ open class RadarChartRenderer( drawHighlightLines(canvas, pOut.x, pOut.y, set) if (set.isDrawHighlightCircleEnabled) { - if (!java.lang.Float.isNaN(pOut.x) && !java.lang.Float.isNaN(pOut.y)) { + if (!pOut.x.isNaN() && !pOut.y.isNaN()) { var strokeColor = set.highlightCircleStrokeColor if (strokeColor == ColorTemplate.COLOR_NONE) { strokeColor = set.getColorByIndex(0) diff --git a/chartLib/src/main/kotlin/info/appdev/charting/utils/Transformer.kt b/chartLib/src/main/kotlin/info/appdev/charting/utils/Transformer.kt index 3e1c8f66e..d913e50aa 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/utils/Transformer.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/utils/Transformer.kt @@ -38,10 +38,10 @@ open class Transformer(@JvmField protected var viewPortHandler: ViewPortHandler) var scaleX = viewPortHandler.contentWidth() / deltaX var scaleY = viewPortHandler.contentHeight() / deltaY - if (java.lang.Float.isInfinite(scaleX)) { + if (scaleX.isInfinite()) { scaleX = 0f } - if (java.lang.Float.isInfinite(scaleY)) { + if (scaleY.isInfinite()) { scaleY = 0f } diff --git a/chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt b/chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt index 5d00ff550..4e4c860e2 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt @@ -11,7 +11,6 @@ import android.view.ViewConfiguration import info.appdev.charting.formatter.DefaultValueFormatter import info.appdev.charting.formatter.IValueFormatter import info.appdev.charting.utils.MPPointF.Companion.instance -import java.lang.Float import kotlin.Int import kotlin.IntArray import kotlin.String @@ -30,9 +29,9 @@ object Utils { var minimumFlingVelocity: Int = 50 var maximumFlingVelocity: Int = 8000 const val DEG2RAD: Double = (Math.PI / 180.0) - const val FDEG2RAD: kotlin.Float = (Math.PI.toFloat() / 180f) + const val FDEG2RAD: Float = (Math.PI.toFloat() / 180f) - val FLOAT_EPSILON: kotlin.Float = Float.intBitsToFloat(1) + val FLOAT_EPSILON: Float = java.lang.Float.intBitsToFloat(1) /** * initialize method, called inside the Chart.init() method. @@ -54,20 +53,20 @@ object Utils { private val mFontMetrics = Paint.FontMetrics() - fun getLineHeight(paint: Paint): kotlin.Float { + fun getLineHeight(paint: Paint): Float { return getLineHeight(paint, mFontMetrics) } - fun getLineHeight(paint: Paint, fontMetrics: Paint.FontMetrics): kotlin.Float { + fun getLineHeight(paint: Paint, fontMetrics: Paint.FontMetrics): Float { paint.getFontMetrics(fontMetrics) return fontMetrics.descent - fontMetrics.ascent } - fun getLineSpacing(paint: Paint): kotlin.Float { + fun getLineSpacing(paint: Paint): Float { return getLineSpacing(paint, mFontMetrics) } - fun getLineSpacing(paint: Paint, fontMetrics: Paint.FontMetrics): kotlin.Float { + fun getLineSpacing(paint: Paint, fontMetrics: Paint.FontMetrics): Float { paint.getFontMetrics(fontMetrics) return fontMetrics.ascent - fontMetrics.top + fontMetrics.bottom } @@ -130,13 +129,13 @@ object Utils { * @param angle in degrees, converted to radians internally * @return */ - fun getPosition(center: MPPointF, dist: kotlin.Float, angle: kotlin.Float): MPPointF { + fun getPosition(center: MPPointF, dist: Float, angle: Float): MPPointF { val p = MPPointF.getInstance(0f, 0f) getPosition(center, dist, angle, p) return p } - fun getPosition(center: MPPointF, dist: kotlin.Float, angle: kotlin.Float, outputPoint: MPPointF) { + fun getPosition(center: MPPointF, dist: Float, angle: Float, outputPoint: MPPointF) { outputPoint.x = (center.x + dist * cos(Math.toRadians(angle.toDouble()))).toFloat() outputPoint.y = (center.y + dist * sin(Math.toRadians(angle.toDouble()))).toFloat() } @@ -174,7 +173,7 @@ object Utils { /** * returns an angle between 0.f < 360.f (not less than zero, less than 360) */ - fun getNormalizedAngle(angle: kotlin.Float): kotlin.Float { + fun getNormalizedAngle(angle: Float): Float { var angle = angle while (angle < 0f) { angle += 360f @@ -217,7 +216,7 @@ object Utils { * @param degrees * @return A Recyclable FSize instance */ - fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, degrees: kotlin.Float): FSize { + fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): FSize { val radians = degrees * FDEG2RAD return getSizeOfRotatedRectangleByRadians(rectangleWidth, rectangleHeight, radians) } @@ -231,7 +230,7 @@ object Utils { * @param radians * @return A Recyclable FSize instance */ - fun getSizeOfRotatedRectangleByRadians(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, radians: kotlin.Float): FSize { + fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): FSize { return FSize.getInstance( abs(rectangleWidth * cos(radians.toDouble()).toFloat()) + abs(rectangleHeight * sin(radians.toDouble()).toFloat()), abs(rectangleWidth * sin(radians.toDouble()).toFloat()) + abs(rectangleHeight * cos(radians.toDouble()).toFloat()) diff --git a/chartLib/src/main/kotlin/info/appdev/charting/utils/UtilsKt.kt b/chartLib/src/main/kotlin/info/appdev/charting/utils/UtilsKt.kt index b7f14fb6b..2045e17c7 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/utils/UtilsKt.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/utils/UtilsKt.kt @@ -7,7 +7,6 @@ import android.os.Build import android.util.DisplayMetrics import android.view.ViewConfiguration import timber.log.Timber -import java.lang.Double import kotlin.Boolean import kotlin.Char import kotlin.CharArray @@ -38,7 +37,7 @@ fun Context.initUtils() { fun Float.getDecimals(): Int { val i = this.toDouble().roundToNextSignificant() - if (java.lang.Float.isInfinite(i)) { + if (i.isInfinite()) { return 0 } @@ -49,8 +48,8 @@ fun Float.getDecimals(): Int { * rounds the given number to the next significant number */ fun kotlin.Double.roundToNextSignificant(): Float { - if (Double.isInfinite(this) || - Double.isNaN(this) || this == 0.0 + if (this.isInfinite() || + this.isNaN() || this == 0.0 ) { return 0f }