Made calculation of Markers on GuiTimeline dynamic

Changed Real Timeline's Length to 30 minutes (request by multiple users)
This commit is contained in:
CrushedPixel
2015-07-19 23:27:15 +02:00
parent 6422558028
commit 702e02db65
5 changed files with 102 additions and 47 deletions

View File

@@ -4,6 +4,10 @@ import java.text.DecimalFormat;
public class RoundUtils {
public static int roundToMultiple(int value, int snap) {
return Math.max(snap, (int)Math.round((float)value/snap) * snap);
}
public static double round2Decimals(double val) {
return round(val, 2);
}
@@ -20,4 +24,20 @@ public class RoundUtils {
return Double.valueOf(df.format(value));
}
public static int getClosestInt(int base, int[] snap) {
int min = Integer.MAX_VALUE;
int closest = base;
for (int v : snap) {
final int diff = Math.abs(v - base);
if (diff < min) {
min = diff;
closest = v;
}
}
return closest;
}
}