Skip to content

Commit b59e78e

Browse files
authored
Merge pull request #447 from AppDevNext/Cosmetic
Cosmetic
2 parents 51a5cae + da36a54 commit b59e78e

File tree

12 files changed

+512
-641
lines changed

12 files changed

+512
-641
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/utils/CanvasUtils.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import kotlin.math.cos
1313
import kotlin.math.sin
1414

1515
private val mDrawableBoundsCache = Rect()
16-
val DEG2RAD: kotlin.Double = (Math.PI / 180.0)
17-
val FDEG2RAD: kotlin.Float = (Math.PI.toFloat() / 180f)
16+
val DEG2RAD: Double = (Math.PI / 180.0)
17+
val FDEG2RAD: Float = (Math.PI.toFloat() / 180f)
1818

1919
/**
2020
* Utilities class that has some helper methods. Needs to be initialized by
@@ -51,9 +51,9 @@ private val mDrawTextRectBuffer = Rect()
5151
private val mFontMetricsBuffer = Paint.FontMetrics()
5252

5353
fun Canvas.drawXAxisValue(
54-
text: String?, x: kotlin.Float, y: kotlin.Float,
54+
text: String?, x: Float, y: Float,
5555
paint: Paint,
56-
anchor: MPPointF, angleDegrees: kotlin.Float
56+
anchor: MPPointF, angleDegrees: Float
5757
) {
5858
var drawOffsetX = 0f
5959
var drawOffsetY = 0f
@@ -119,14 +119,14 @@ fun Canvas.drawXAxisValue(
119119

120120
fun Canvas.drawMultilineText(
121121
textLayout: StaticLayout,
122-
x: kotlin.Float, y: kotlin.Float,
122+
x: Float, y: Float,
123123
paint: TextPaint,
124-
anchor: MPPointF, angleDegrees: kotlin.Float
124+
anchor: MPPointF, angleDegrees: Float
125125
) {
126126
var drawOffsetX = 0f
127127
var drawOffsetY = 0f
128-
val drawWidth: kotlin.Float
129-
val drawHeight: kotlin.Float
128+
val drawWidth: Float
129+
val drawHeight: Float
130130

131131
val lineHeight = paint.getFontMetrics(mFontMetricsBuffer)
132132

@@ -204,7 +204,7 @@ fun Canvas.drawMultilineText(
204204
* @param degrees
205205
* @return A Recyclable FSize instance
206206
*/
207-
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, degrees: kotlin.Float): FSize {
207+
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): FSize {
208208
val radians = degrees * FDEG2RAD
209209
return getSizeOfRotatedRectangleByRadians(rectangleWidth, rectangleHeight, radians)
210210
}
@@ -218,7 +218,7 @@ fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: kotlin.Float, rectangleHe
218218
* @param radians
219219
* @return A Recyclable FSize instance
220220
*/
221-
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, radians: kotlin.Float): FSize {
221+
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): FSize {
222222
return FSize.getInstance(
223223
abs(rectangleWidth * cos(radians.toDouble()).toFloat()) + abs(rectangleHeight * sin(radians.toDouble()).toFloat()),
224224
abs(rectangleWidth * sin(radians.toDouble()).toFloat()) + abs(rectangleHeight * cos(radians.toDouble()).toFloat())

MPChartLib/src/main/java/com/github/mikephil/charting/utils/ColorTemplate.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ public class ColorTemplate {
5757

5858
/**
5959
* Converts the given hex-color-string to rgb.
60-
*
61-
* @param hex
62-
* @return
6360
*/
6461
public static int rgb(String hex) {
6562
int color = (int) Long.parseLong(hex.replace("#", ""), 16);
@@ -71,19 +68,14 @@ public static int rgb(String hex) {
7168

7269
/**
7370
* Returns the Android ICS holo blue light color.
74-
*
75-
* @return
7671
*/
7772
public static int getHoloBlue() {
7873
return Color.rgb(51, 181, 229);
7974
}
8075

8176
/**
8277
* Sets the alpha component of the given color.
83-
*
84-
* @param color
8578
* @param alpha 0 - 255
86-
* @return
8779
*/
8880
public static int colorWithAlpha(int color, int alpha) {
8981
return (color & 0xffffff) | ((alpha & 0xff) << 24);
@@ -92,14 +84,11 @@ public static int colorWithAlpha(int color, int alpha) {
9284
/**
9385
* turn an array of resource-colors (contains resource-id integers) into an
9486
* array list of actual color integers
95-
*
96-
* @param r
9787
* @param colors an integer array of resource id's of colors
98-
* @return
9988
*/
10089
public static List<Integer> createColors(Resources r, int[] colors) {
10190

102-
List<Integer> result = new ArrayList<Integer>();
91+
List<Integer> result = new ArrayList<>();
10392

10493
for (int i : colors) {
10594
result.add(r.getColor(i));
@@ -109,15 +98,11 @@ public static List<Integer> createColors(Resources r, int[] colors) {
10998
}
11099

111100
/**
112-
* Turns an array of colors (integer color values) into an ArrayList of
113-
* colors.
114-
*
115-
* @param colors
116-
* @return
101+
* Turns an array of colors (integer color values) into an ArrayList of colors.
117102
*/
118103
public static List<Integer> createColors(int[] colors) {
119104

120-
List<Integer> result = new ArrayList<Integer>();
105+
List<Integer> result = new ArrayList<>();
121106

122107
for (int i : colors) {
123108
result.add(i);

MPChartLib/src/main/java/com/github/mikephil/charting/utils/EntryXComparator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ public class EntryXComparator implements Comparator<Entry> {
1313
public int compare(Entry entry1, Entry entry2) {
1414
float diff = entry1.getX() - entry2.getX();
1515

16-
if (diff == 0f) return 0;
17-
else {
18-
if (diff > 0f) return 1;
19-
else return -1;
20-
}
16+
return Float.compare(diff, 0f);
2117
}
2218
}

MPChartLib/src/main/java/com/github/mikephil/charting/utils/FSize.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import java.util.List;
55

6+
import androidx.annotation.NonNull;
7+
68
/**
79
* Class for describing width and height dimensions in some arbitrary
810
* unit. Replacement for the android.Util.SizeF which is available only on API >= 21.
@@ -14,7 +16,7 @@ public final class FSize extends ObjectPool.Poolable{
1416
public float width;
1517
public float height;
1618

17-
private static ObjectPool<FSize> pool;
19+
private static final ObjectPool<FSize> pool;
1820

1921
static {
2022
pool = ObjectPool.create(256, new FSize(0,0));
@@ -57,14 +59,14 @@ public boolean equals(final Object obj) {
5759
if (this == obj) {
5860
return true;
5961
}
60-
if (obj instanceof FSize) {
61-
final FSize other = (FSize) obj;
62-
return width == other.width && height == other.height;
62+
if (obj instanceof FSize other) {
63+
return width == other.width && height == other.height;
6364
}
6465
return false;
6566
}
6667

67-
@Override
68+
@NonNull
69+
@Override
6870
public String toString() {
6971
return width + "x" + height;
7072
}

0 commit comments

Comments
 (0)