diff --git a/vtm-app/src/org/osmdroid/location/GeocoderNominatim.java b/vtm-app/src/org/osmdroid/location/GeocoderNominatim.java index 09061e2d..9d751157 100644 --- a/vtm-app/src/org/osmdroid/location/GeocoderNominatim.java +++ b/vtm-app/src/org/osmdroid/location/GeocoderNominatim.java @@ -51,7 +51,7 @@ public class GeocoderNominatim { init(context, Locale.getDefault()); } - static public boolean isPresent() { + public static boolean isPresent() { return true; } diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/editor/ThemeLoader.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/editor/ThemeLoader.java index 81bbfca1..f02ef558 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/editor/ThemeLoader.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/editor/ThemeLoader.java @@ -35,13 +35,13 @@ import java.util.prefs.BackingStoreException; public class ThemeLoader { - final private Logger vtmLog = LoggerFactory.getLogger("org.oscim.ThemeLoader"); - final private Logger mapsforgeLog = LoggerFactory.getLogger("org.mapsforge.ThemeLoader"); + private final Logger vtmLog = LoggerFactory.getLogger("org.oscim.ThemeLoader"); + private final Logger mapsforgeLog = LoggerFactory.getLogger("org.mapsforge.ThemeLoader"); - final private VtmPanel vtmPanel; - final private MapsforgeMapPanel mapsforgeMapPanel; - final private RSyntaxTextArea syntaxTextArea; + private final VtmPanel vtmPanel; + private final MapsforgeMapPanel mapsforgeMapPanel; + private final RSyntaxTextArea syntaxTextArea; private String themePath; private String editorText; diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/location/LocationData.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/location/LocationData.java index 24464dec..a34a709a 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/location/LocationData.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/location/LocationData.java @@ -81,22 +81,22 @@ public final class LocationData { } - public synchronized static double getLatitude() { + public static synchronized double getLatitude() { return latitude; } - synchronized static void setLatitude(double latitude) { + static synchronized void setLatitude(double latitude) { if (LocationData.latitude != latitude) { LocationData.latitude = latitude; notifyChange(); } } - public synchronized static double getLongitude() { + public static synchronized double getLongitude() { return longitude; } - public synchronized static void setLongitude(double longitude) { + public static synchronized void setLongitude(double longitude) { if (LocationData.longitude != longitude) { LocationData.longitude = longitude; notifyChange(); diff --git a/vtm-web/src/org/oscim/gdx/emu/com/badlogic/gdx/backends/gwt/GwtApplication.java b/vtm-web/src/org/oscim/gdx/emu/com/badlogic/gdx/backends/gwt/GwtApplication.java index e34107b7..01bc5c79 100644 --- a/vtm-web/src/org/oscim/gdx/emu/com/badlogic/gdx/backends/gwt/GwtApplication.java +++ b/vtm-web/src/org/oscim/gdx/emu/com/badlogic/gdx/backends/gwt/GwtApplication.java @@ -572,7 +572,7 @@ public abstract class GwtApplication implements EntryPoint, Application { } } - native static public void consoleLog(String message) /*-{ + public static native void consoleLog(String message) /*-{ console.log( "GWT: " + message ); }-*/; diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java b/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java index a6b85726..3d18badc 100644 --- a/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java +++ b/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java @@ -81,7 +81,7 @@ public class JsArrayCollection extends AbstractCollection { protected JsArr() { } - public native final JsArr slice(int start, int end)/*-{ + public final native JsArr slice(int start, int end)/*-{ return this.slice(start, end); }-*/; diff --git a/vtm/src/org/oscim/layers/tile/MapTile.java b/vtm/src/org/oscim/layers/tile/MapTile.java index 6deb26f3..1765bfa7 100644 --- a/vtm/src/org/oscim/layers/tile/MapTile.java +++ b/vtm/src/org/oscim/layers/tile/MapTile.java @@ -150,7 +150,7 @@ public class MapTile extends Tile { */ MapTile holder; - public static abstract class TileData extends Inlist { + public abstract static class TileData extends Inlist { Object id; protected abstract void dispose(); diff --git a/vtm/src/org/oscim/layers/tile/TileLayer.java b/vtm/src/org/oscim/layers/tile/TileLayer.java index 20bbb546..ba99e71a 100644 --- a/vtm/src/org/oscim/layers/tile/TileLayer.java +++ b/vtm/src/org/oscim/layers/tile/TileLayer.java @@ -61,7 +61,7 @@ public abstract class TileLayer extends Layer implements UpdateListener { mRenderer = renderer; } - abstract protected TileLoader createLoader(); + protected abstract TileLoader createLoader(); public TileRenderer tileRenderer() { return (TileRenderer) mRenderer; diff --git a/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java b/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java index 6dc5fda8..f0e74dba 100644 --- a/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java +++ b/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java @@ -78,7 +78,7 @@ public abstract class AbstractVectorLayer extends Layer implements UpdateList mWorker.submit(0); } - abstract protected void processFeatures(Task t, Box b); + protected abstract void processFeatures(Task t, Box b); protected static class Task { public final RenderBuckets buckets = new RenderBuckets(); diff --git a/vtm/src/org/oscim/renderer/GLMatrix.java b/vtm/src/org/oscim/renderer/GLMatrix.java index a77d5c5a..039b591d 100644 --- a/vtm/src/org/oscim/renderer/GLMatrix.java +++ b/vtm/src/org/oscim/renderer/GLMatrix.java @@ -253,52 +253,52 @@ public class GLMatrix { delete(pointer); } - private native static long alloc(); + private static native long alloc(); - private native static void delete(long self); + private static native void delete(long self); - private native static void set(long self, float[] m); + private static native void set(long self, float[] m); - private native static void copy(long self, long other); + private static native void copy(long self, long other); - private native static void identity(long self); + private static native void identity(long self); - private native static void get(long self, float[] m); + private static native void get(long self, float[] m); - private native static void mul(long self, long lhs_ptr); + private static native void mul(long self, long lhs_ptr); - private native static void smul(long self, long rhs_ptr, long lhs_ptr); + private static native void smul(long self, long rhs_ptr, long lhs_ptr); - private native static void smulrhs(long self, long rhs_ptr); + private static native void smulrhs(long self, long rhs_ptr); - private native static void smullhs(long self, long lhs_ptr); + private static native void smullhs(long self, long lhs_ptr); - private native static void strans(long self, long rhs_ptr); + private static native void strans(long self, long rhs_ptr); - private native static void prj(long self, float[] vec3); + private static native void prj(long self, float[] vec3); - private native static void prj3D(long self, float[] vec3, int start, int cnt); + private static native void prj3D(long self, float[] vec3, int start, int cnt); - private native static void prj2D(long self, float[] vec2, int start, int cnt); + private static native void prj2D(long self, float[] vec2, int start, int cnt); - private native static void prj2D2(long self, float[] vec2, int src_offset, + private static native void prj2D2(long self, float[] vec2, int src_offset, float[] dst_vec, int dst_offset, int length); - private native static void setRotation(long self, float a, float x, float y, float z); + private static native void setRotation(long self, float a, float x, float y, float z); - private native static void setScale(long self, float x, float y, float z); + private static native void setScale(long self, float x, float y, float z); - private native static void setTranslation(long self, float x, float y, float z); + private static native void setTranslation(long self, float x, float y, float z); - private native static void setTransScale(long self, float tx, float ty, float scale); + private static native void setTransScale(long self, float tx, float ty, float scale); - //private native static void setAsUniform(long self, int handle); + //private static native void setAsUniform(long self, int handle); - private native static void setValueAt(long self, int pos, float value); + private static native void setValueAt(long self, int pos, float value); - private native static void addDepthOffset(long self, int delta); + private static native void addDepthOffset(long self, int delta); - private native static ByteBuffer getBuffer(long self); + private static native ByteBuffer getBuffer(long self); /* Copyright (C) 2007 The Android Open Source Project * diff --git a/vtm/src/org/oscim/theme/styles/RenderStyle.java b/vtm/src/org/oscim/theme/styles/RenderStyle.java index d2607b6f..7a7c7721 100644 --- a/vtm/src/org/oscim/theme/styles/RenderStyle.java +++ b/vtm/src/org/oscim/theme/styles/RenderStyle.java @@ -27,7 +27,7 @@ import static org.oscim.backend.canvas.Color.parseColor; */ public abstract class RenderStyle> { - public static abstract class StyleBuilder> { + public abstract static class StyleBuilder> { public String cat; public String style; diff --git a/vtm/src/org/oscim/utils/animation/Easing.java b/vtm/src/org/oscim/utils/animation/Easing.java index c5c34ed7..b834ae29 100644 --- a/vtm/src/org/oscim/utils/animation/Easing.java +++ b/vtm/src/org/oscim/utils/animation/Easing.java @@ -32,7 +32,7 @@ public class Easing { QUINT_INOUT } - static public float ease(long start, long current, float duration, Type easingType) { + public static float ease(long start, long current, float duration, Type easingType) { long millisElapsed = current - start; if (millisElapsed > duration) { return 1; @@ -79,42 +79,42 @@ public class Easing { // Following easing functions are copied from https://github.com/danro/jquery-easing/blob/master/jquery.easing.js // Under BSD license - static private float linear(float x, float t, float b, float c, float d) { + private static float linear(float x, float t, float b, float c, float d) { return c * x + b; } - static private float sineInout(float x, float t, float b, float c, float d) { + private static float sineInout(float x, float t, float b, float c, float d) { return -c / 2 * (float) (Math.cos(Math.PI * t / d) - 1) + b; } - static private float sineIn(float x, float t, float b, float c, float d) { + private static float sineIn(float x, float t, float b, float c, float d) { return -c * (float) Math.cos(t / d * (Math.PI / 2)) + c + b; } - static private float sineOut(float x, float t, float b, float c, float d) { + private static float sineOut(float x, float t, float b, float c, float d) { return c * (float) Math.sin(t / d * (Math.PI / 2)) + b; } - static private float expoOut(float x, float t, float b, float c, float d) { + private static float expoOut(float x, float t, float b, float c, float d) { return (t == d) ? b + c : c * (float) (-Math.pow(2, -10 * x) + 1) + b; } - static private float quadInout(float x, float t, float b, float c, float d) { + private static float quadInout(float x, float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t * t + b; return -c / 2 * ((--t) * (t - 2) - 1) + b; } - static private float cubicInout(float x, float t, float b, float c, float d) { + private static float cubicInout(float x, float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; return c / 2 * ((t -= 2) * t * t + 2) + b; } - static private float quartInout(float x, float t, float b, float c, float d) { + private static float quartInout(float x, float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b; return -c / 2 * ((t -= 2) * t * t * t - 2) + b; } - static private float quintInout(float x, float t, float b, float c, float d) { + private static float quintInout(float x, float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b; return c / 2 * ((t -= 2) * t * t * t * t + 2) + b; } diff --git a/vtm/src/org/oscim/utils/math/Interpolation.java b/vtm/src/org/oscim/utils/math/Interpolation.java index 7a3a6ff0..5c5bc0be 100644 --- a/vtm/src/org/oscim/utils/math/Interpolation.java +++ b/vtm/src/org/oscim/utils/math/Interpolation.java @@ -26,7 +26,7 @@ public abstract class Interpolation { /** * @param a Alpha value between 0 and 1. */ - abstract public float apply(float a); + public abstract float apply(float a); /** * @param a Alpha value between 0 and 1. @@ -35,66 +35,66 @@ public abstract class Interpolation { return start + (end - start) * apply(a); } - static public final Interpolation linear = new Interpolation() { + public static final Interpolation linear = new Interpolation() { @Override public float apply(float a) { return a; } }; - static public final Interpolation fade = new Interpolation() { + public static final Interpolation fade = new Interpolation() { @Override public float apply(float a) { return MathUtils.clamp(a * a * a * (a * (a * 6 - 15) + 10), 0, 1); } }; - static public final Pow pow2 = new Pow(2); - static public final PowIn pow2In = new PowIn(2); - static public final PowOut pow2Out = new PowOut(2); + public static final Pow pow2 = new Pow(2); + public static final PowIn pow2In = new PowIn(2); + public static final PowOut pow2Out = new PowOut(2); - static public final Pow pow3 = new Pow(3); - static public final PowIn pow3In = new PowIn(3); - static public final PowOut pow3Out = new PowOut(3); + public static final Pow pow3 = new Pow(3); + public static final PowIn pow3In = new PowIn(3); + public static final PowOut pow3Out = new PowOut(3); - static public final Pow pow4 = new Pow(4); - static public final PowIn pow4In = new PowIn(4); - static public final PowOut pow4Out = new PowOut(4); + public static final Pow pow4 = new Pow(4); + public static final PowIn pow4In = new PowIn(4); + public static final PowOut pow4Out = new PowOut(4); - static public final Pow pow5 = new Pow(5); - static public final PowIn pow5In = new PowIn(5); - static public final PowOut pow5Out = new PowOut(5); + public static final Pow pow5 = new Pow(5); + public static final PowIn pow5In = new PowIn(5); + public static final PowOut pow5Out = new PowOut(5); - static public final Interpolation sine = new Interpolation() { + public static final Interpolation sine = new Interpolation() { @Override public float apply(float a) { return (1 - MathUtils.cos(a * MathUtils.PI)) / 2; } }; - static public final Interpolation sineIn = new Interpolation() { + public static final Interpolation sineIn = new Interpolation() { @Override public float apply(float a) { return 1 - MathUtils.cos(a * MathUtils.PI / 2); } }; - static public final Interpolation sineOut = new Interpolation() { + public static final Interpolation sineOut = new Interpolation() { @Override public float apply(float a) { return MathUtils.sin(a * MathUtils.PI / 2); } }; - static public final Interpolation exp10 = new Exp(2, 10); - static public final Interpolation exp10In = new ExpIn(2, 10); - static public final Interpolation exp10Out = new ExpOut(2, 10); + public static final Interpolation exp10 = new Exp(2, 10); + public static final Interpolation exp10In = new ExpIn(2, 10); + public static final Interpolation exp10Out = new ExpOut(2, 10); - static public final Interpolation exp5 = new Exp(2, 5); - static public final Interpolation exp5In = new ExpIn(2, 5); - static public final Interpolation exp5Out = new ExpOut(2, 5); + public static final Interpolation exp5 = new Exp(2, 5); + public static final Interpolation exp5In = new ExpIn(2, 5); + public static final Interpolation exp5Out = new ExpOut(2, 5); - static public final Interpolation circle = new Interpolation() { + public static final Interpolation circle = new Interpolation() { @Override public float apply(float a) { if (a <= 0.5f) { @@ -107,14 +107,14 @@ public abstract class Interpolation { } }; - static public final Interpolation circleIn = new Interpolation() { + public static final Interpolation circleIn = new Interpolation() { @Override public float apply(float a) { return 1 - (float) Math.sqrt(1 - a * a); } }; - static public final Interpolation circleOut = new Interpolation() { + public static final Interpolation circleOut = new Interpolation() { @Override public float apply(float a) { a--; @@ -122,21 +122,21 @@ public abstract class Interpolation { } }; - static public final Elastic elastic = new Elastic(2, 10); - static public final Elastic elasticIn = new ElasticIn(2, 10); - static public final Elastic elasticOut = new ElasticOut(2, 10); + public static final Elastic elastic = new Elastic(2, 10); + public static final Elastic elasticIn = new ElasticIn(2, 10); + public static final Elastic elasticOut = new ElasticOut(2, 10); - static public final Interpolation swing = new Swing(1.5f); - static public final Interpolation swingIn = new SwingIn(2f); - static public final Interpolation swingOut = new SwingOut(2f); + public static final Interpolation swing = new Swing(1.5f); + public static final Interpolation swingIn = new SwingIn(2f); + public static final Interpolation swingOut = new SwingOut(2f); - static public final Interpolation bounce = new Bounce(4); - static public final Interpolation bounceIn = new BounceIn(4); - static public final Interpolation bounceOut = new BounceOut(4); + public static final Interpolation bounce = new Bounce(4); + public static final Interpolation bounceIn = new BounceIn(4); + public static final Interpolation bounceOut = new BounceOut(4); // - static public class Pow extends Interpolation { + public static class Pow extends Interpolation { final int power; public Pow(int power) { @@ -151,7 +151,7 @@ public abstract class Interpolation { } } - static public class PowIn extends Pow { + public static class PowIn extends Pow { public PowIn(int power) { super(power); } @@ -162,7 +162,7 @@ public abstract class Interpolation { } } - static public class PowOut extends Pow { + public static class PowOut extends Pow { public PowOut(int power) { super(power); } @@ -175,7 +175,7 @@ public abstract class Interpolation { // - static public class Exp extends Interpolation { + public static class Exp extends Interpolation { final float value, power, min, scale; public Exp(float value, float power) { @@ -193,7 +193,7 @@ public abstract class Interpolation { } } - static public class ExpIn extends Exp { + public static class ExpIn extends Exp { public ExpIn(float value, float power) { super(value, power); } @@ -204,7 +204,7 @@ public abstract class Interpolation { } } - static public class ExpOut extends Exp { + public static class ExpOut extends Exp { public ExpOut(float value, float power) { super(value, power); } @@ -217,7 +217,7 @@ public abstract class Interpolation { // - static public class Elastic extends Interpolation { + public static class Elastic extends Interpolation { final float value, power; public Elastic(float value, float power) { @@ -239,7 +239,7 @@ public abstract class Interpolation { } } - static public class ElasticIn extends Elastic { + public static class ElasticIn extends Elastic { public ElasticIn(float value, float power) { super(value, power); } @@ -250,7 +250,7 @@ public abstract class Interpolation { } } - static public class ElasticOut extends Elastic { + public static class ElasticOut extends Elastic { public ElasticOut(float value, float power) { super(value, power); } @@ -264,7 +264,7 @@ public abstract class Interpolation { // - static public class Bounce extends BounceOut { + public static class Bounce extends BounceOut { public Bounce(float[] widths, float[] heights) { super(widths, heights); } @@ -288,7 +288,7 @@ public abstract class Interpolation { } } - static public class BounceOut extends Interpolation { + public static class BounceOut extends Interpolation { final float[] widths, heights; public BounceOut(float[] widths, float[] heights) { @@ -359,7 +359,7 @@ public abstract class Interpolation { } } - static public class BounceIn extends BounceOut { + public static class BounceIn extends BounceOut { public BounceIn(float[] widths, float[] heights) { super(widths, heights); } @@ -376,7 +376,7 @@ public abstract class Interpolation { // - static public class Swing extends Interpolation { + public static class Swing extends Interpolation { private final float scale; public Swing(float scale) { @@ -395,7 +395,7 @@ public abstract class Interpolation { } } - static public class SwingOut extends Interpolation { + public static class SwingOut extends Interpolation { private final float scale; public SwingOut(float scale) { @@ -409,7 +409,7 @@ public abstract class Interpolation { } } - static public class SwingIn extends Interpolation { + public static class SwingIn extends Interpolation { private final float scale; public SwingIn(float scale) { diff --git a/vtm/src/org/oscim/utils/math/MathUtils.java b/vtm/src/org/oscim/utils/math/MathUtils.java index c50b450d..1b33676e 100644 --- a/vtm/src/org/oscim/utils/math/MathUtils.java +++ b/vtm/src/org/oscim/utils/math/MathUtils.java @@ -27,26 +27,26 @@ import java.util.Random; * @author Nathan Sweet */ public class MathUtils { - static public final float nanoToSec = 1 / 1000000000f; + public static final float nanoToSec = 1 / 1000000000f; - static public final float PI = 3.1415927f; + public static final float PI = 3.1415927f; public static final float PI2 = PI * 2; - static private final int SIN_BITS = 13; // Adjust for accuracy. - static private final int SIN_MASK = ~(-1 << SIN_BITS); - static private final int SIN_COUNT = SIN_MASK + 1; + private static final int SIN_BITS = 13; // Adjust for accuracy. + private static final int SIN_MASK = ~(-1 << SIN_BITS); + private static final int SIN_COUNT = SIN_MASK + 1; - static private final float radFull = PI * 2; - static private final float degFull = 360; - static private final float radToIndex = SIN_COUNT / radFull; - static private final float degToIndex = SIN_COUNT / degFull; + private static final float radFull = PI * 2; + private static final float degFull = 360; + private static final float radToIndex = SIN_COUNT / radFull; + private static final float degToIndex = SIN_COUNT / degFull; - static public final float radiansToDegrees = 180f / PI; - static public final float radDeg = radiansToDegrees; - static public final float degreesToRadians = PI / 180; - static public final float degRad = degreesToRadians; + public static final float radiansToDegrees = 180f / PI; + public static final float radDeg = radiansToDegrees; + public static final float degreesToRadians = PI / 180; + public static final float degRad = degreesToRadians; - static private class Sin { + private static class Sin { static final float[] table = new float[SIN_COUNT]; static { @@ -57,7 +57,7 @@ public class MathUtils { } } - static private class Cos { + private static class Cos { static final float[] table = new float[SIN_COUNT]; static { @@ -71,41 +71,41 @@ public class MathUtils { /** * Returns the sine in radians. */ - static public final float sin(float radians) { + public static final float sin(float radians) { return Sin.table[(int) (radians * radToIndex) & SIN_MASK]; } /** * Returns the cosine in radians. */ - static public final float cos(float radians) { + public static final float cos(float radians) { return Cos.table[(int) (radians * radToIndex) & SIN_MASK]; } /** * Returns the sine in radians. */ - static public final float sinDeg(float degrees) { + public static final float sinDeg(float degrees) { return Sin.table[(int) (degrees * degToIndex) & SIN_MASK]; } /** * Returns the cosine in radians. */ - static public final float cosDeg(float degrees) { + public static final float cosDeg(float degrees) { return Cos.table[(int) (degrees * degToIndex) & SIN_MASK]; } // --- - static private final int ATAN2_BITS = 7; // Adjust for accuracy. - static private final int ATAN2_BITS2 = ATAN2_BITS << 1; - static private final int ATAN2_MASK = ~(-1 << ATAN2_BITS2); - static private final int ATAN2_COUNT = ATAN2_MASK + 1; + private static final int ATAN2_BITS = 7; // Adjust for accuracy. + private static final int ATAN2_BITS2 = ATAN2_BITS << 1; + private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2); + private static final int ATAN2_COUNT = ATAN2_MASK + 1; static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT); - static private final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1); + private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1); - static private class Atan2 { + private static class Atan2 { static final float[] table = new float[ATAN2_COUNT]; static { @@ -122,7 +122,7 @@ public class MathUtils { /** * Returns atan2 in radians from a lookup table. */ - static public final float atan2(float y, float x) { + public static final float atan2(float y, float x) { float add, mul; if (x < 0) { if (y < 0) { @@ -148,34 +148,34 @@ public class MathUtils { // --- - static public Random random = new Random(); + public static Random random = new Random(); /** * Returns a random number between 0 (inclusive) and the specified value * (inclusive). */ - static public final int random(int range) { + public static final int random(int range) { return random.nextInt(range + 1); } /** * Returns a random number between start (inclusive) and end (inclusive). */ - static public final int random(int start, int end) { + public static final int random(int start, int end) { return start + random.nextInt(end - start + 1); } /** * Returns a random boolean value. */ - static public final boolean randomBoolean() { + public static final boolean randomBoolean() { return random.nextBoolean(); } /** * Returns random number between 0.0 (inclusive) and 1.0 (exclusive). */ - static public final float random() { + public static final float random() { return random.nextFloat(); } @@ -183,14 +183,14 @@ public class MathUtils { * Returns a random number between 0 (inclusive) and the specified value * (exclusive). */ - static public final float random(float range) { + public static final float random(float range) { return random.nextFloat() * range; } /** * Returns a random number between start (inclusive) and end (exclusive). */ - static public final float random(float start, float end) { + public static final float random(float start, float end) { return start + random.nextFloat() * (end - start); } @@ -200,7 +200,7 @@ public class MathUtils { * Returns the next power of two. Returns the specified value if the value * is already a power of two. */ - static public int nextPowerOfTwo(int value) { + public static int nextPowerOfTwo(int value) { if (value == 0) return 1; value--; @@ -212,13 +212,13 @@ public class MathUtils { return value + 1; } - static public boolean isPowerOfTwo(int value) { + public static boolean isPowerOfTwo(int value) { return value != 0 && (value & value - 1) == 0; } // --- - static public int clamp(int value, int min, int max) { + public static int clamp(int value, int min, int max) { if (value < min) return min; if (value > max) @@ -226,7 +226,7 @@ public class MathUtils { return value; } - static public short clamp(short value, short min, short max) { + public static short clamp(short value, short min, short max) { if (value < min) return min; if (value > max) @@ -234,7 +234,7 @@ public class MathUtils { return value; } - static public float clamp(float value, float min, float max) { + public static float clamp(float value, float min, float max) { if (value < min) return min; if (value > max) @@ -244,18 +244,18 @@ public class MathUtils { // --- - static private final int BIG_ENOUGH_INT = 16 * 1024; - static private final double BIG_ENOUGH_FLOOR = BIG_ENOUGH_INT; - static private final double CEIL = 0.9999999; - static private final double BIG_ENOUGH_CEIL = Double.longBitsToDouble(Double.doubleToLongBits(BIG_ENOUGH_INT + 1) - 1); - static private final double BIG_ENOUGH_ROUND = BIG_ENOUGH_INT + 0.5f; + private static final int BIG_ENOUGH_INT = 16 * 1024; + private static final double BIG_ENOUGH_FLOOR = BIG_ENOUGH_INT; + private static final double CEIL = 0.9999999; + private static final double BIG_ENOUGH_CEIL = Double.longBitsToDouble(Double.doubleToLongBits(BIG_ENOUGH_INT + 1) - 1); + private static final double BIG_ENOUGH_ROUND = BIG_ENOUGH_INT + 0.5f; /** * Returns the largest integer less than or equal to the specified float. * This method will only properly floor floats from * -(2^14) to (Float.MAX_VALUE - 2^14). */ - static public int floor(float x) { + public static int floor(float x) { return (int) (x + BIG_ENOUGH_FLOOR) - BIG_ENOUGH_INT; } @@ -264,7 +264,7 @@ public class MathUtils { * This method will only properly floor floats that are * positive. Note this method simply casts the float to int. */ - static public int floorPositive(float x) { + public static int floorPositive(float x) { return (int) x; } @@ -273,7 +273,7 @@ public class MathUtils { * float. This method will only properly ceil floats from * -(2^14) to (Float.MAX_VALUE - 2^14). */ - static public int ceil(float x) { + public static int ceil(float x) { return (int) (x + BIG_ENOUGH_CEIL) - BIG_ENOUGH_INT; } @@ -282,7 +282,7 @@ public class MathUtils { * float. This method will only properly ceil floats that * are positive. */ - static public int ceilPositive(float x) { + public static int ceilPositive(float x) { return (int) (x + CEIL); } @@ -291,7 +291,7 @@ public class MathUtils { * properly round floats from -(2^14) to * (Float.MAX_VALUE - 2^14). */ - static public int round(float x) { + public static int round(float x) { return (int) (x + BIG_ENOUGH_ROUND) - BIG_ENOUGH_INT; } @@ -299,7 +299,7 @@ public class MathUtils { * Returns the closest integer to the specified float. This method will only * properly round floats that are positive. */ - static public int roundPositive(float x) { + public static int roundPositive(float x) { return (int) (x + 0.5f); } }