Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package info.appdev.charting.components

import android.graphics.DashPathEffect
import android.graphics.Paint
import android.util.SizeF
import info.appdev.charting.utils.ColorTemplate
import info.appdev.charting.utils.FSize
import info.appdev.charting.utils.ViewPortHandler
import info.appdev.charting.utils.calcTextHeight
import info.appdev.charting.utils.calcTextWidth
Expand Down Expand Up @@ -332,9 +332,9 @@ class Legend() : ComponentBase() {
*/
var isWordWrapEnabled: Boolean = false

val calculatedLabelSizes: MutableList<FSize?> = ArrayList<FSize?>(16)
val calculatedLabelSizes: MutableList<SizeF?> = ArrayList(16)
val calculatedLabelBreakPoints: MutableList<Boolean?> = ArrayList<Boolean?>(16)
val calculatedLineSizes: MutableList<FSize?> = ArrayList<FSize?>(16)
val calculatedLineSizes: MutableList<SizeF?> = ArrayList(16)

init {
this.mTextSize = 10f.convertDpToPixel()
Expand Down Expand Up @@ -456,7 +456,7 @@ class Legend() : ComponentBase() {
requiredWidth += if (drawingForm) formToTextSpace + formSize else 0f
requiredWidth += calculatedLabelSizes.get(i)!!.width
} else {
calculatedLabelSizes.add(FSize.getInstance(0f, 0f))
calculatedLabelSizes.add(SizeF(0f, 0f))
requiredWidth += if (drawingForm) formSize else 0f

if (stackedStartIndex == -1) {
Expand All @@ -480,7 +480,7 @@ class Legend() : ComponentBase() {

// Add current line size to array

calculatedLineSizes.add(FSize.getInstance(currentLineWidth, labelLineHeight))
calculatedLineSizes.add(SizeF(currentLineWidth, labelLineHeight))
maxLineWidth = max(maxLineWidth, currentLineWidth)

// Start a new line
Expand All @@ -495,7 +495,7 @@ class Legend() : ComponentBase() {

if (i == entryCount - 1) {
// Add last line size to array
calculatedLineSizes.add(FSize.getInstance(currentLineWidth, labelLineHeight))
calculatedLineSizes.add(SizeF(currentLineWidth, labelLineHeight))
maxLineWidth = max(maxLineWidth, currentLineWidth)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.content.Context
import android.graphics.Canvas
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.SizeF
import info.appdev.charting.charts.Chart
import info.appdev.charting.data.Entry
import info.appdev.charting.highlight.Highlight
import info.appdev.charting.utils.FSize
import info.appdev.charting.utils.PointF
import java.lang.ref.WeakReference

Expand All @@ -21,7 +21,7 @@ class MarkerImage(private var mContext: Context, drawableResourceId: Int) : IMar
private val mOffset2 = PointF()
private var mWeakChart: WeakReference<Chart<*>?>? = null

private var mSize: FSize? = FSize()
private var mSize: SizeF? = SizeF(0f, 0f)
private val mDrawableBoundsCache = Rect()

/**
Expand All @@ -45,13 +45,13 @@ class MarkerImage(private var mContext: Context, drawableResourceId: Int) : IMar
mOffset = offset
}

var size: FSize?
var size: SizeF?
get() = mSize
set(size) {
mSize = size

if (mSize == null) {
mSize = FSize()
mSize = SizeF(0f, 0f)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import info.appdev.charting.components.LimitLine
import info.appdev.charting.components.LimitLine.LimitLabelPosition
import info.appdev.charting.components.XAxis
import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.utils.FSize
import info.appdev.charting.utils.PointD
import info.appdev.charting.utils.PointF
import info.appdev.charting.utils.Transformer
Expand Down Expand Up @@ -86,9 +85,6 @@ open class XAxisRenderer(

xAxis.mLabelWidth = labelRotatedSize.width.roundToInt()
xAxis.mLabelHeight = labelRotatedSize.height.roundToInt()

FSize.recycleInstance(labelRotatedSize)
FSize.recycleInstance(labelSize)
}

override fun renderAxisLabels(canvas: Canvas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.core.graphics.withSave
import info.appdev.charting.components.LimitLine.LimitLabelPosition
import info.appdev.charting.components.XAxis
import info.appdev.charting.components.XAxis.XAxisPosition
import info.appdev.charting.utils.FSize
import info.appdev.charting.utils.PointD
import info.appdev.charting.utils.PointF
import info.appdev.charting.utils.Transformer
Expand Down Expand Up @@ -72,8 +71,6 @@ open class XAxisRendererHorizontalBarChart(

xAxis.mLabelWidth = labelRotatedSize.width.roundToInt()
xAxis.mLabelHeight = labelRotatedSize.height.roundToInt()

FSize.recycleInstance(labelRotatedSize)
}

override fun renderAxisLabels(canvas: Canvas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.Paint
import android.graphics.Paint.Align
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.SizeF
import info.appdev.charting.utils.Utils.FDEG2RAD
import kotlin.math.abs
import kotlin.math.cos
Expand Down Expand Up @@ -88,7 +89,6 @@ fun Canvas.drawXAxisValue(

translateX -= rotatedSize.width * (anchor.x - 0.5f)
translateY -= rotatedSize.height * (anchor.y - 0.5f)
FSize.recycleInstance(rotatedSize)
}

this.save()
Expand Down Expand Up @@ -130,7 +130,7 @@ fun Paint.calcTextWidth(demoText: String?): Int {
* @param degrees
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): FSize {
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): SizeF {
val radians = degrees * FDEG2RAD
return getSizeOfRotatedRectangleByRadians(rectangleWidth, rectangleHeight, radians)
}
Expand All @@ -144,8 +144,8 @@ fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: F
* @param radians
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): FSize {
return FSize.getInstance(
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): SizeF {
return SizeF(
abs(rectangleWidth * cos(radians.toDouble()).toFloat()) + abs(rectangleHeight * sin(radians.toDouble()).toFloat()),
abs(rectangleWidth * sin(radians.toDouble()).toFloat()) + abs(rectangleHeight * cos(radians.toDouble()).toFloat())
)
Expand Down
76 changes: 0 additions & 76 deletions chartLib/src/main/kotlin/info/appdev/charting/utils/FSize.kt

This file was deleted.

11 changes: 4 additions & 7 deletions chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import android.content.Context
import android.graphics.Canvas
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.SizeF
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.ViewConfiguration
import info.appdev.charting.formatter.DefaultValueFormatter
import info.appdev.charting.formatter.IValueFormatter
import info.appdev.charting.utils.PointF.Companion.instance
import kotlin.Int
import kotlin.IntArray
import kotlin.Suppress
import kotlin.intArrayOf
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sin
Expand Down Expand Up @@ -153,7 +150,7 @@ object Utils {
* @param degrees
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): FSize {
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): SizeF {
val radians = degrees * FDEG2RAD
return getSizeOfRotatedRectangleByRadians(rectangleWidth, rectangleHeight, radians)
}
Expand All @@ -167,8 +164,8 @@ object Utils {
* @param radians
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): FSize {
return FSize.getInstance(
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): SizeF {
return SizeF(
abs(rectangleWidth * cos(radians.toDouble()).toFloat()) + abs(rectangleHeight * sin(radians.toDouble()).toFloat()),
abs(rectangleWidth * sin(radians.toDouble()).toFloat()) + abs(rectangleHeight * cos(radians.toDouble()).toFloat())
)
Expand Down
10 changes: 5 additions & 5 deletions chartLib/src/main/kotlin/info/appdev/charting/utils/UtilsKt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.Paint
import android.graphics.Rect
import android.os.Build
import android.util.DisplayMetrics
import android.util.SizeF
import android.view.ViewConfiguration
import timber.log.Timber
import kotlin.Boolean
Expand Down Expand Up @@ -195,8 +196,8 @@ fun Paint.getLineSpacing(fontMetrics: Paint.FontMetrics): Float {
*
* @return A Recyclable FSize instance
*/
fun Paint.calcTextSize(demoText: String): FSize {
val result = FSize.getInstance(0f, 0f)
fun Paint.calcTextSize(demoText: String): SizeF {
val result = SizeF(0f, 0f)
calcTextSize(demoText, result)
return result
}
Expand All @@ -209,10 +210,9 @@ private val mCalcTextSizeRect = Rect()
*
* @param outputFSize An output variable, modified by the function.
*/
fun Paint.calcTextSize(demoText: String, outputFSize: FSize) {
fun Paint.calcTextSize(demoText: String, outputFSize: SizeF): SizeF {
val r = mCalcTextSizeRect
r.set(0, 0, 0, 0)
this.getTextBounds(demoText, 0, demoText.length, r)
outputFSize.width = r.width().toFloat()
outputFSize.height = r.height().toFloat()
return SizeF(r.width().toFloat(),r.height().toFloat())
}
Loading