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 @@ -13,8 +13,8 @@ import kotlin.math.cos
import kotlin.math.sin

private val mDrawableBoundsCache = Rect()
val DEG2RAD: kotlin.Double = (Math.PI / 180.0)
val FDEG2RAD: kotlin.Float = (Math.PI.toFloat() / 180f)
val DEG2RAD: Double = (Math.PI / 180.0)
val FDEG2RAD: Float = (Math.PI.toFloat() / 180f)

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

fun Canvas.drawXAxisValue(
text: String?, x: kotlin.Float, y: kotlin.Float,
text: String?, x: Float, y: Float,
paint: Paint,
anchor: MPPointF, angleDegrees: kotlin.Float
anchor: MPPointF, angleDegrees: Float
) {
var drawOffsetX = 0f
var drawOffsetY = 0f
Expand Down Expand Up @@ -119,14 +119,14 @@ fun Canvas.drawXAxisValue(

fun Canvas.drawMultilineText(
textLayout: StaticLayout,
x: kotlin.Float, y: kotlin.Float,
x: Float, y: Float,
paint: TextPaint,
anchor: MPPointF, angleDegrees: kotlin.Float
anchor: MPPointF, angleDegrees: Float
) {
var drawOffsetX = 0f
var drawOffsetY = 0f
val drawWidth: kotlin.Float
val drawHeight: kotlin.Float
val drawWidth: Float
val drawHeight: Float

val lineHeight = paint.getFontMetrics(mFontMetricsBuffer)

Expand Down Expand Up @@ -204,7 +204,7 @@ fun Canvas.drawMultilineText(
* @param degrees
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, degrees: kotlin.Float): FSize {
fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: Float, rectangleHeight: Float, degrees: Float): FSize {
val radians = degrees * FDEG2RAD
return getSizeOfRotatedRectangleByRadians(rectangleWidth, rectangleHeight, radians)
}
Expand All @@ -218,7 +218,7 @@ fun getSizeOfRotatedRectangleByDegrees(rectangleWidth: kotlin.Float, rectangleHe
* @param radians
* @return A Recyclable FSize instance
*/
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: kotlin.Float, rectangleHeight: kotlin.Float, radians: kotlin.Float): FSize {
fun getSizeOfRotatedRectangleByRadians(rectangleWidth: Float, rectangleHeight: Float, radians: Float): FSize {
return FSize.getInstance(
abs(rectangleWidth * cos(radians.toDouble()).toFloat()) + abs(rectangleHeight * sin(radians.toDouble()).toFloat()),
abs(rectangleWidth * sin(radians.toDouble()).toFloat()) + abs(rectangleHeight * cos(radians.toDouble()).toFloat())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public class ColorTemplate {

/**
* Converts the given hex-color-string to rgb.
*
* @param hex
* @return
*/
public static int rgb(String hex) {
int color = (int) Long.parseLong(hex.replace("#", ""), 16);
Expand All @@ -71,19 +68,14 @@ public static int rgb(String hex) {

/**
* Returns the Android ICS holo blue light color.
*
* @return
*/
public static int getHoloBlue() {
return Color.rgb(51, 181, 229);
}

/**
* Sets the alpha component of the given color.
*
* @param color
* @param alpha 0 - 255
* @return
*/
public static int colorWithAlpha(int color, int alpha) {
return (color & 0xffffff) | ((alpha & 0xff) << 24);
Expand All @@ -92,14 +84,11 @@ public static int colorWithAlpha(int color, int alpha) {
/**
* turn an array of resource-colors (contains resource-id integers) into an
* array list of actual color integers
*
* @param r
* @param colors an integer array of resource id's of colors
* @return
*/
public static List<Integer> createColors(Resources r, int[] colors) {

List<Integer> result = new ArrayList<Integer>();
List<Integer> result = new ArrayList<>();

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

/**
* Turns an array of colors (integer color values) into an ArrayList of
* colors.
*
* @param colors
* @return
* Turns an array of colors (integer color values) into an ArrayList of colors.
*/
public static List<Integer> createColors(int[] colors) {

List<Integer> result = new ArrayList<Integer>();
List<Integer> result = new ArrayList<>();

for (int i : colors) {
result.add(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public class EntryXComparator implements Comparator<Entry> {
public int compare(Entry entry1, Entry entry2) {
float diff = entry1.getX() - entry2.getX();

if (diff == 0f) return 0;
else {
if (diff > 0f) return 1;
else return -1;
}
return Float.compare(diff, 0f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import java.util.List;

import androidx.annotation.NonNull;

/**
* Class for describing width and height dimensions in some arbitrary
* unit. Replacement for the android.Util.SizeF which is available only on API >= 21.
Expand All @@ -14,7 +16,7 @@ public final class FSize extends ObjectPool.Poolable{
public float width;
public float height;

private static ObjectPool<FSize> pool;
private static final ObjectPool<FSize> pool;

static {
pool = ObjectPool.create(256, new FSize(0,0));
Expand Down Expand Up @@ -57,14 +59,14 @@ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof FSize) {
final FSize other = (FSize) obj;
return width == other.width && height == other.height;
if (obj instanceof FSize other) {
return width == other.width && height == other.height;
}
return false;
}

@Override
@NonNull
@Override
public String toString() {
return width + "x" + height;
}
Expand Down
Loading
Loading