Made calculation of Markers on GuiTimeline dynamic
Changed Real Timeline's Length to 30 minutes (request by multiple users)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user