Skip to content
Open
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 @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -207,7 +206,7 @@ public List<Integer> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -636,7 +637,7 @@ else if (wasStacked) {
wasStacked = false;
}

width += Utils.calcTextWidth(labelpaint, label);
width += CanvasUtilsKt.calcTextWidth(labelpaint, label);

maxHeight += labelLineHeight + yEntrySpace;
} else {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -65,9 +65,9 @@ protected List<Highlight> 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading
Loading