Skip to content

Commit 1a94360

Browse files
committed
Kotlin formatter interfaces
1 parent 47d674a commit 1a94360

File tree

5 files changed

+38
-56
lines changed

5 files changed

+38
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
package com.github.mikephil.charting.formatter;
1+
package com.github.mikephil.charting.formatter
22

3-
import com.github.mikephil.charting.data.DataSet;
4-
import com.github.mikephil.charting.data.Entry;
5-
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
3+
import com.github.mikephil.charting.data.Entry
4+
import com.github.mikephil.charting.interfaces.datasets.IDataSet
65

76
/**
8-
* Interface that can be used to return a customized color instead of setting
9-
* colors via the setColor(...) method of the DataSet.
10-
*
11-
* @author Philipp Jahoda
7+
* Interface that can be used to return a customized color instead of setting colors via the setColor(...) method of the DataSet.
128
*/
13-
public interface ColorFormatter {
14-
9+
interface ColorFormatter {
1510
/**
1611
* Returns the color to be used for the given Entry at the given index (in the entries array)
1712
*
@@ -20,5 +15,5 @@ public interface ColorFormatter {
2015
* @param set the DataSet the entry belongs to
2116
* @return
2217
*/
23-
int getColor(int index, Entry e, IDataSet set);
24-
}
18+
fun getColor(index: Int, entry: Entry?, set: IDataSet<*>?): Int
19+
}

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IAxisValueFormatter.java

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.github.mikephil.charting.formatter
2+
3+
import com.github.mikephil.charting.components.AxisBase
4+
5+
/**
6+
* Custom formatter interface that allows formatting of axis labels before they are being drawn.
7+
*/
8+
interface IAxisValueFormatter {
9+
/**
10+
* Called when a value from an axis is to be formatted
11+
* before being drawn. For performance reasons, avoid excessive calculations
12+
* and memory allocations inside this method.
13+
*
14+
* @param value the value to be formatted
15+
* @param axis the axis the value belongs to
16+
* @return
17+
*/
18+
fun getFormattedValue(value: Float, axis: AxisBase?): String?
19+
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
package com.github.mikephil.charting.formatter;
1+
package com.github.mikephil.charting.formatter
22

3-
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
4-
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
3+
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider
4+
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet
55

66
/**
7-
* Interface for providing a custom logic to where the filling line of a LineDataSet
8-
* should end. This of course only works if setFillEnabled(...) is set to true.
9-
*
10-
* @author Philipp Jahoda
7+
* Interface for providing a custom logic to where the filling line of a LineDataSet should end. This of course only works if setFillEnabled(...) is set to true.
118
*/
12-
public interface IFillFormatter
13-
{
14-
9+
interface IFillFormatter {
1510
/**
1611
* Returns the vertical (y-axis) position where the filled-line of the
1712
* LineDataSet should end.
18-
*
13+
*
1914
* @param dataSet the ILineDataSet that is currently drawn
2015
* @param dataProvider
2116
* @return
2217
*/
23-
float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider);
18+
fun getFillLinePosition(dataSet: ILineDataSet?, dataProvider: LineDataProvider?): Float
2419
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
package com.github.mikephil.charting.formatter;
1+
package com.github.mikephil.charting.formatter
22

3-
import com.github.mikephil.charting.data.Entry;
4-
import com.github.mikephil.charting.utils.ViewPortHandler;
3+
import com.github.mikephil.charting.data.Entry
4+
import com.github.mikephil.charting.utils.ViewPortHandler
55

66
/**
77
* Interface that allows custom formatting of all values inside the chart before they are
88
* being drawn to the screen. Simply create your own formatting class and let
99
* it implement IValueFormatter. Then override the getFormattedValue(...) method
1010
* and return whatever you want.
11-
*
12-
* @author Philipp Jahoda
1311
*/
14-
public interface IValueFormatter
15-
{
16-
12+
interface IValueFormatter {
1713
/**
1814
* Called when a value (from labels inside the chart) is formatted
1915
* before being drawn. For performance reasons, avoid excessive calculations
@@ -25,5 +21,5 @@ public interface IValueFormatter
2521
* @param viewPortHandler provides information about the current chart state (scale, translation, ...)
2622
* @return the formatted label ready for being drawn
2723
*/
28-
String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler);
24+
fun getFormattedValue(value: Float, entry: Entry?, dataSetIndex: Int, viewPortHandler: ViewPortHandler?): String?
2925
}

0 commit comments

Comments
 (0)