Skip to content
Merged
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 @@ -14,8 +14,8 @@ import info.appdev.charting.renderer.PieChartRenderer
import info.appdev.charting.utils.PointF
import info.appdev.charting.utils.PointF.Companion.getInstance
import info.appdev.charting.utils.PointF.Companion.recycleInstance
import info.appdev.charting.utils.Utils
import info.appdev.charting.utils.convertDpToPixel
import info.appdev.charting.utils.getNormalizedAngle
import java.util.Locale
import java.util.Objects
import kotlin.math.abs
Expand Down Expand Up @@ -346,7 +346,7 @@ class PieChart : PieRadarChartBase<PieData> {
override fun getIndexForAngle(angle: Float): Int {
// take the current angle of the chart into consideration

val a = Utils.getNormalizedAngle(angle - rotationAngle)
val a = (angle - rotationAngle).getNormalizedAngle()

for (i in absoluteAngles.indices) {
if (this.absoluteAngles[i] > a)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import info.appdev.charting.listener.PieRadarChartTouchListener
import info.appdev.charting.utils.PointF
import info.appdev.charting.utils.PointF.Companion.getInstance
import info.appdev.charting.utils.PointF.Companion.recycleInstance
import info.appdev.charting.utils.Utils
import info.appdev.charting.utils.convertDpToPixel
import info.appdev.charting.utils.getNormalizedAngle
import timber.log.Timber
import kotlin.math.acos
import kotlin.math.cos
Expand Down Expand Up @@ -378,7 +378,7 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry>>>
*/
set(angle) {
this.rawRotationAngle = angle
mRotationAngle = Utils.getNormalizedAngle(this.rawRotationAngle)
mRotationAngle = this.rawRotationAngle.getNormalizedAngle()
}

val diameter: Float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import info.appdev.charting.highlight.RadarHighlighter
import info.appdev.charting.renderer.RadarChartRenderer
import info.appdev.charting.renderer.XAxisRendererRadarChart
import info.appdev.charting.renderer.YAxisRendererRadarChart
import info.appdev.charting.utils.Utils
import info.appdev.charting.utils.convertDpToPixel
import info.appdev.charting.utils.getNormalizedAngle
import kotlin.math.max
import kotlin.math.min

Expand Down Expand Up @@ -203,16 +203,16 @@ class RadarChart : PieRadarChartBase<RadarData> {
override fun getIndexForAngle(angle: Float): Int {
// take the current angle of the chart into consideration

val a = Utils.getNormalizedAngle(angle - rotationAngle)
val a = (angle - rotationAngle).getNormalizedAngle()

val sliceangle = this.sliceAngle
val sliceAngle = this.sliceAngle

val max = mData?.maxEntryCountSet!!.entryCount

var index = 0

for (i in 0..<max) {
val referenceAngle = sliceangle * (i + 1) - sliceangle / 2f
val referenceAngle = sliceAngle * (i + 1) - sliceAngle / 2f

if (referenceAngle > a) {
index = i
Expand Down
13 changes: 13 additions & 0 deletions chartLib/src/main/kotlin/info/appdev/charting/utils/NumberUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package info.appdev.charting.utils

/**
* returns an angle between 0.f < 360.f (not less than zero, less than 360)
*/
fun Float.getNormalizedAngle(): Float {
var angle = this
while (angle < 0f) {
angle += 360f
}

return angle % 360f
}
12 changes: 0 additions & 12 deletions chartLib/src/main/kotlin/info/appdev/charting/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ object Utils {
}
}

/**
* returns an angle between 0.f < 360.f (not less than zero, less than 360)
*/
fun getNormalizedAngle(angle: Float): Float {
var angle = angle
while (angle < 0f) {
angle += 360f
}

return angle % 360f
}

private val mDrawableBoundsCache = Rect()

fun drawImage(canvas: Canvas, drawable: Drawable, x: Int, y: Int) {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.