Skip to content

Commit 5d35513

Browse files
authored
Merge pull request #357 from AppDevNext/ComponentBaseKotlin
ComponentBase Kotlin
2 parents 644a145 + 4778717 commit 5d35513

File tree

3 files changed

+78
-176
lines changed

3 files changed

+78
-176
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,8 @@ public float[] getSpecificPositions()
878878
/**
879879
* Sets the text color to use for the labels. Make sure to use
880880
* getResources().getColor(...) when using a color from the resources.
881-
*
882-
* @param color
883881
*/
884882
public void setTextColor(int color) {
885-
mTextColor = color;
883+
super.setTextColor(color);
886884
}
887885
}

MPChartLib/src/main/java/com/github/mikephil/charting/components/ComponentBase.java

Lines changed: 0 additions & 173 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.github.mikephil.charting.components
2+
3+
import android.graphics.Color
4+
import android.graphics.Typeface
5+
import com.github.mikephil.charting.utils.Utils
6+
7+
/**
8+
* This class encapsulates everything both Axis, Legend and LimitLines have in common.
9+
*/
10+
abstract class ComponentBase {
11+
12+
/**
13+
* flag that indicates if this axis / legend is enabled or not
14+
*/
15+
var isEnabled: Boolean = true
16+
17+
/**
18+
* the offset in pixels this component has on the x-axis
19+
*/
20+
@JvmField
21+
protected var mXOffset: Float = 5f
22+
23+
/**
24+
* the offset in pixels this component has on the Y-axis
25+
*/
26+
@JvmField
27+
protected var mYOffset: Float = 5f
28+
29+
/**
30+
* the typeface used for the labels
31+
*/
32+
var typeface: Typeface? = null
33+
34+
/**
35+
* the text size of the labels
36+
*/
37+
@JvmField
38+
protected var mTextSize: Float = Utils.convertDpToPixel(10f)
39+
40+
/**
41+
* the text color to use for the labels
42+
*/
43+
open var textColor: Int = Color.BLACK
44+
45+
/**
46+
* Returns the used offset on the x-axis for drawing the axis or legend
47+
* labels. This offset is applied before and after the label.
48+
*/
49+
var xOffset: Float
50+
get() = mXOffset
51+
set(xOffset) {
52+
mXOffset = Utils.convertDpToPixel(xOffset)
53+
}
54+
55+
/**
56+
* Returns the used offset on the x-axis for drawing the axis labels. This
57+
* offset is applied before and after the label.
58+
*/
59+
var yOffset: Float
60+
get() = mYOffset
61+
set(yOffset) {
62+
mYOffset = Utils.convertDpToPixel(yOffset)
63+
}
64+
65+
/**
66+
* returns the text size that is currently set for the labels, in pixels
67+
*/
68+
var textSize: Float
69+
get() = mTextSize
70+
set(size) {
71+
var sizeLocal = size
72+
if (sizeLocal > 24f) sizeLocal = 24f
73+
if (sizeLocal < 6f) sizeLocal = 6f
74+
75+
mTextSize = Utils.convertDpToPixel(sizeLocal)
76+
}
77+
}

0 commit comments

Comments
 (0)