Remade item and tile basic system.
Still not funcitonal but the shape is final. Sort of.
This commit is contained in:
@@ -10,7 +10,8 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marked method can be safely overriden; it's left blank (or with default
|
||||
* implementation) as a convenience.
|
||||
* implementation) as a convenience.<br>
|
||||
* This is a description annotation and has no other function.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,8 @@ import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Marks a static factory method
|
||||
* Marks a static factory method. This is a description annotation and has no
|
||||
* other function.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,8 @@ public class PropertyManager {
|
||||
public T defaultValue;
|
||||
|
||||
|
||||
public Property(String key, T defaultValue, String comment) {
|
||||
public Property(String key, T defaultValue, String comment)
|
||||
{
|
||||
super();
|
||||
this.comment = comment;
|
||||
this.key = key;
|
||||
@@ -54,7 +55,8 @@ public class PropertyManager {
|
||||
|
||||
private class BooleanProperty extends Property<Boolean> {
|
||||
|
||||
public BooleanProperty(String key, Boolean defaultValue, String comment) {
|
||||
public BooleanProperty(String key, Boolean defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -68,7 +70,8 @@ public class PropertyManager {
|
||||
|
||||
private class IntegerProperty extends Property<Integer> {
|
||||
|
||||
public IntegerProperty(String key, Integer defaultValue, String comment) {
|
||||
public IntegerProperty(String key, Integer defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -82,7 +85,8 @@ public class PropertyManager {
|
||||
|
||||
private class DoubleProperty extends Property<Double> {
|
||||
|
||||
public DoubleProperty(String key, Double defaultValue, String comment) {
|
||||
public DoubleProperty(String key, Double defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -96,7 +100,8 @@ public class PropertyManager {
|
||||
|
||||
private class StringProperty extends Property<String> {
|
||||
|
||||
public StringProperty(String key, String defaultValue, String comment) {
|
||||
public StringProperty(String key, String defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -110,7 +115,8 @@ public class PropertyManager {
|
||||
|
||||
private class RangeProperty extends Property<Range> {
|
||||
|
||||
public RangeProperty(String key, Range defaultValue, String comment) {
|
||||
public RangeProperty(String key, Range defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -124,7 +130,8 @@ public class PropertyManager {
|
||||
|
||||
private class CoordProperty extends Property<Vect> {
|
||||
|
||||
public CoordProperty(String key, Vect defaultValue, String comment) {
|
||||
public CoordProperty(String key, Vect defaultValue, String comment)
|
||||
{
|
||||
super(key, defaultValue, comment);
|
||||
}
|
||||
|
||||
@@ -158,7 +165,8 @@ public class PropertyManager {
|
||||
* @param file file with the props
|
||||
* @param comment the initial comment. Use \n in it if you want.
|
||||
*/
|
||||
public PropertyManager(File file, String comment) {
|
||||
public PropertyManager(File file, String comment)
|
||||
{
|
||||
this.file = file;
|
||||
this.entries = new TreeMap<>();
|
||||
this.overrideValues = new TreeMap<>();
|
||||
|
||||
@@ -17,12 +17,14 @@ public class NumConst extends Num {
|
||||
private NumDigest digest;
|
||||
|
||||
|
||||
NumConst(Num copied) {
|
||||
NumConst(Num copied)
|
||||
{
|
||||
this.value = copied.value();
|
||||
}
|
||||
|
||||
|
||||
NumConst(double value) {
|
||||
NumConst(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ public abstract class AbstractNumCache extends NumAdapter implements ConstraintC
|
||||
private boolean cachingEnabled = true;
|
||||
|
||||
|
||||
public AbstractNumCache() {
|
||||
public AbstractNumCache()
|
||||
{
|
||||
enableDigestCaching(true); // it changes only on poll
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public class NumCache extends AbstractNumCache {
|
||||
private final Num source;
|
||||
|
||||
|
||||
public NumCache(Num source) {
|
||||
public NumCache(Num source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ public class NumDigest {
|
||||
public final double value;
|
||||
|
||||
|
||||
public NumDigest(Num num) {
|
||||
public NumDigest(Num num)
|
||||
{
|
||||
this.value = num.value();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
||||
*
|
||||
* @param value initial value
|
||||
*/
|
||||
public NumAnimated(double value) {
|
||||
public NumAnimated(double value)
|
||||
{
|
||||
setTo(value);
|
||||
}
|
||||
|
||||
@@ -56,7 +57,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
||||
* @param value initial value
|
||||
* @param easing easing function
|
||||
*/
|
||||
public NumAnimated(double value, Easing easing) {
|
||||
public NumAnimated(double value, Easing easing)
|
||||
{
|
||||
this(value);
|
||||
setEasing(easing);
|
||||
}
|
||||
@@ -69,7 +71,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
||||
* @param easingIn easing function (fade in)
|
||||
* @param easingOut easing function (fade out)
|
||||
*/
|
||||
public NumAnimated(double value, Easing easingIn, Easing easingOut) {
|
||||
public NumAnimated(double value, Easing easingIn, Easing easingOut)
|
||||
{
|
||||
this(value);
|
||||
setEasing(easingIn, easingOut);
|
||||
}
|
||||
@@ -80,7 +83,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
||||
*
|
||||
* @param other other animator
|
||||
*/
|
||||
public NumAnimated(NumAnimated other) {
|
||||
public NumAnimated(NumAnimated other)
|
||||
{
|
||||
setTo(other);
|
||||
}
|
||||
|
||||
@@ -194,7 +198,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
||||
{
|
||||
if (paused || isFinished()) return;
|
||||
|
||||
elapsedTime = Calc.clampd(elapsedTime + delta, 0, duration);
|
||||
elapsedTime = Calc.clamp(elapsedTime + delta, 0, duration);
|
||||
if (isFinished()) {
|
||||
duration = 0;
|
||||
elapsedTime = 0;
|
||||
|
||||
@@ -13,17 +13,20 @@ import mightypork.util.math.Easing;
|
||||
*/
|
||||
public class NumAnimatedDeg extends NumAnimated {
|
||||
|
||||
public NumAnimatedDeg(NumAnimated other) {
|
||||
public NumAnimatedDeg(NumAnimated other)
|
||||
{
|
||||
super(other);
|
||||
}
|
||||
|
||||
|
||||
public NumAnimatedDeg(double value) {
|
||||
public NumAnimatedDeg(double value)
|
||||
{
|
||||
super(value);
|
||||
}
|
||||
|
||||
|
||||
public NumAnimatedDeg(double value, Easing easing) {
|
||||
public NumAnimatedDeg(double value, Easing easing)
|
||||
{
|
||||
super(value, easing);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,17 +13,20 @@ import mightypork.util.math.Easing;
|
||||
*/
|
||||
public class NumAnimatedRad extends NumAnimated {
|
||||
|
||||
public NumAnimatedRad(NumAnimated other) {
|
||||
public NumAnimatedRad(NumAnimated other)
|
||||
{
|
||||
super(other);
|
||||
}
|
||||
|
||||
|
||||
public NumAnimatedRad(double value) {
|
||||
public NumAnimatedRad(double value)
|
||||
{
|
||||
super(value);
|
||||
}
|
||||
|
||||
|
||||
public NumAnimatedRad(double value, Easing easing) {
|
||||
public NumAnimatedRad(double value, Easing easing)
|
||||
{
|
||||
super(value, easing);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@ public class NumVar extends NumMutable {
|
||||
private double value;
|
||||
|
||||
|
||||
public NumVar(Num value) {
|
||||
public NumVar(Num value)
|
||||
{
|
||||
this(value.value());
|
||||
}
|
||||
|
||||
|
||||
public NumVar(double value) {
|
||||
public NumVar(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@ public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
|
||||
private NumBound backing = null;
|
||||
|
||||
|
||||
public NumBoundAdapter() {
|
||||
public NumBoundAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public NumBoundAdapter(NumBound bound) {
|
||||
public NumBoundAdapter(NumBound bound)
|
||||
{
|
||||
backing = bound;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ public class NumProxy extends NumAdapter {
|
||||
private final Num source;
|
||||
|
||||
|
||||
public NumProxy(Num source) {
|
||||
public NumProxy(Num source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.util.constraints.rect;
|
||||
|
||||
|
||||
import mightypork.util.annotations.FactoryMethod;
|
||||
import mightypork.util.constraints.DigestCache;
|
||||
import mightypork.util.constraints.Digestable;
|
||||
@@ -952,7 +953,7 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
|
||||
return new TiledRect(this, 1, rows);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check for intersection
|
||||
*
|
||||
@@ -971,10 +972,10 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
|
||||
return false;
|
||||
}
|
||||
|
||||
double tx = this.origin().x();
|
||||
double ty = this.origin().y();
|
||||
double rx = other.origin().x();
|
||||
double ry = other.origin().y();
|
||||
final double tx = this.origin().x();
|
||||
final double ty = this.origin().y();
|
||||
final double rx = other.origin().x();
|
||||
final double ry = other.origin().y();
|
||||
|
||||
rw += rx;
|
||||
rh += ry;
|
||||
|
||||
@@ -46,7 +46,8 @@ public class RectConst extends Rect {
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
RectConst(double x, double y, double width, double height) {
|
||||
RectConst(double x, double y, double width, double height)
|
||||
{
|
||||
this.pos = Vect.make(x, y);
|
||||
this.size = Vect.make(width, height);
|
||||
}
|
||||
@@ -58,7 +59,8 @@ public class RectConst extends Rect {
|
||||
* @param origin
|
||||
* @param size
|
||||
*/
|
||||
RectConst(Vect origin, Vect size) {
|
||||
RectConst(Vect origin, Vect size)
|
||||
{
|
||||
this.pos = origin.freeze();
|
||||
this.size = size.freeze();
|
||||
}
|
||||
@@ -69,7 +71,8 @@ public class RectConst extends Rect {
|
||||
*
|
||||
* @param another other coord
|
||||
*/
|
||||
RectConst(Rect another) {
|
||||
RectConst(Rect another)
|
||||
{
|
||||
this.pos = another.origin().freeze();
|
||||
this.size = another.size().freeze();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ public class TiledRect extends RectProxy {
|
||||
final private Num perCol;
|
||||
|
||||
|
||||
public TiledRect(Rect source, int horizontal, int vertical) {
|
||||
public TiledRect(Rect source, int horizontal, int vertical)
|
||||
{
|
||||
super(source);
|
||||
this.tilesX = horizontal;
|
||||
this.tilesY = vertical;
|
||||
|
||||
@@ -25,7 +25,8 @@ public abstract class AbstractRectCache extends RectAdapter implements Constrain
|
||||
private boolean cachingEnabled = true;
|
||||
|
||||
|
||||
public AbstractRectCache() {
|
||||
public AbstractRectCache()
|
||||
{
|
||||
enableDigestCaching(true); // it changes only on poll
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public class RectCache extends AbstractRectCache {
|
||||
private final Rect source;
|
||||
|
||||
|
||||
public RectCache(Rect source) {
|
||||
public RectCache(Rect source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ public class RectDigest {
|
||||
public final double bottom;
|
||||
|
||||
|
||||
public RectDigest(Rect rect) {
|
||||
public RectDigest(Rect rect)
|
||||
{
|
||||
|
||||
final RectConst frozen = rect.freeze();
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ public class RectVar extends RectMutable {
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
public RectVar(double x, double y, double width, double height) {
|
||||
public RectVar(double x, double y, double width, double height)
|
||||
{
|
||||
this.pos.setTo(x, y);
|
||||
this.size.setTo(width, height);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,13 @@ public class RectBoundAdapter extends RectAdapter implements PluggableRectBound
|
||||
private RectBound backing = null;
|
||||
|
||||
|
||||
public RectBoundAdapter() {
|
||||
public RectBoundAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public RectBoundAdapter(RectBound bound) {
|
||||
public RectBoundAdapter(RectBound bound)
|
||||
{
|
||||
backing = bound;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ public class RectProxy extends RectAdapter {
|
||||
private final Rect source;
|
||||
|
||||
|
||||
public RectProxy(Rect source) {
|
||||
public RectProxy(Rect source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ public class RectVectAdapter extends Rect {
|
||||
private final Vect size;
|
||||
|
||||
|
||||
public RectVectAdapter(Vect origin, Vect size) {
|
||||
public RectVectAdapter(Vect origin, Vect size)
|
||||
{
|
||||
this.origin = origin;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,14 @@ public final class VectConst extends Vect {
|
||||
private VectDigest digest;
|
||||
|
||||
|
||||
VectConst(Vect other) {
|
||||
VectConst(Vect other)
|
||||
{
|
||||
this(other.x(), other.y(), other.z());
|
||||
}
|
||||
|
||||
|
||||
VectConst(double x, double y, double z) {
|
||||
VectConst(double x, double y, double z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
@@ -9,7 +9,8 @@ public class VectProxy extends VectAdapter {
|
||||
private final Vect source;
|
||||
|
||||
|
||||
public VectProxy(Vect source) {
|
||||
public VectProxy(Vect source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ public abstract class AbstractVectCache extends VectAdapter implements Constrain
|
||||
private boolean cachingEnabled = true;
|
||||
|
||||
|
||||
public AbstractVectCache() {
|
||||
public AbstractVectCache()
|
||||
{
|
||||
enableDigestCaching(true); // it changes only on poll
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public class VectCache extends AbstractVectCache {
|
||||
private final Vect source;
|
||||
|
||||
|
||||
public VectCache(Vect source) {
|
||||
public VectCache(Vect source)
|
||||
{
|
||||
this.source = source;
|
||||
enableDigestCaching(true);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ public class VectDigest {
|
||||
public final double z;
|
||||
|
||||
|
||||
public VectDigest(Vect vect) {
|
||||
public VectDigest(Vect vect)
|
||||
{
|
||||
this.x = vect.x();
|
||||
this.y = vect.y();
|
||||
this.z = vect.z();
|
||||
|
||||
@@ -28,7 +28,8 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
|
||||
* @param y y animator
|
||||
* @param z z animator
|
||||
*/
|
||||
public VectAnimated(NumAnimated x, NumAnimated y, NumAnimated z) {
|
||||
public VectAnimated(NumAnimated x, NumAnimated y, NumAnimated z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@@ -41,7 +42,8 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
|
||||
* @param start initial positioon
|
||||
* @param easing animation easing
|
||||
*/
|
||||
public VectAnimated(Vect start, Easing easing) {
|
||||
public VectAnimated(Vect start, Easing easing)
|
||||
{
|
||||
x = new NumAnimated(start.x(), easing);
|
||||
y = new NumAnimated(start.y(), easing);
|
||||
z = new NumAnimated(start.z(), easing);
|
||||
|
||||
@@ -17,7 +17,8 @@ public class VectVar extends VectMutable {
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
*/
|
||||
public VectVar(double x, double y, double z) {
|
||||
public VectVar(double x, double y, double z)
|
||||
{
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
@@ -9,11 +9,13 @@ public class VectBoundAdapter extends VectAdapter implements PluggableVectBound
|
||||
private VectBound backing = null;
|
||||
|
||||
|
||||
public VectBoundAdapter() {
|
||||
public VectBoundAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public VectBoundAdapter(VectBound bound) {
|
||||
public VectBoundAdapter(VectBound bound)
|
||||
{
|
||||
backing = bound;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,16 @@ public class VectNumAdapter extends Vect {
|
||||
private final Num constrZ;
|
||||
|
||||
|
||||
public VectNumAdapter(Num x, Num y, Num z) {
|
||||
public VectNumAdapter(Num x, Num y, Num z)
|
||||
{
|
||||
this.constrX = x;
|
||||
this.constrY = y;
|
||||
this.constrZ = z;
|
||||
}
|
||||
|
||||
|
||||
public VectNumAdapter(Num x, Num y) {
|
||||
public VectNumAdapter(Num x, Num y)
|
||||
{
|
||||
this.constrX = x;
|
||||
this.constrY = y;
|
||||
this.constrZ = Num.ZERO;
|
||||
|
||||
@@ -24,7 +24,8 @@ public class BufferedHashSet<E> extends HashSet<E> {
|
||||
/**
|
||||
* make empty
|
||||
*/
|
||||
public BufferedHashSet() {
|
||||
public BufferedHashSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -34,7 +35,8 @@ public class BufferedHashSet<E> extends HashSet<E> {
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public BufferedHashSet(Collection<? extends E> c) {
|
||||
public BufferedHashSet(Collection<? extends E> c)
|
||||
{
|
||||
super(c);
|
||||
}
|
||||
|
||||
@@ -45,7 +47,8 @@ public class BufferedHashSet<E> extends HashSet<E> {
|
||||
* @param initialCapacity
|
||||
* @param loadFactor
|
||||
*/
|
||||
public BufferedHashSet(int initialCapacity, float loadFactor) {
|
||||
public BufferedHashSet(int initialCapacity, float loadFactor)
|
||||
{
|
||||
super(initialCapacity, loadFactor);
|
||||
}
|
||||
|
||||
@@ -55,7 +58,8 @@ public class BufferedHashSet<E> extends HashSet<E> {
|
||||
*
|
||||
* @param initialCapacity
|
||||
*/
|
||||
public BufferedHashSet(int initialCapacity) {
|
||||
public BufferedHashSet(int initialCapacity)
|
||||
{
|
||||
super(initialCapacity);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ final public class EventBus implements Destroyable {
|
||||
private final Event<?> evt;
|
||||
|
||||
|
||||
public DelayQueueEntry(double seconds, Event<?> event) {
|
||||
public DelayQueueEntry(double seconds, Event<?> event)
|
||||
{
|
||||
super();
|
||||
this.due = System.currentTimeMillis() + (long) (seconds * 1000);
|
||||
this.evt = event;
|
||||
@@ -71,7 +72,8 @@ final public class EventBus implements Destroyable {
|
||||
public volatile boolean stopped = false;
|
||||
|
||||
|
||||
public QueuePollingThread() {
|
||||
public QueuePollingThread()
|
||||
{
|
||||
super("Queue Polling Thread");
|
||||
}
|
||||
|
||||
@@ -141,7 +143,8 @@ final public class EventBus implements Destroyable {
|
||||
/**
|
||||
* Make a new bus and start it's queue thread.
|
||||
*/
|
||||
public EventBus() {
|
||||
public EventBus()
|
||||
{
|
||||
busThread = new QueuePollingThread();
|
||||
busThread.setDaemon(true);
|
||||
busThread.start();
|
||||
|
||||
@@ -30,7 +30,8 @@ class EventChannel<EVENT extends Event<CLIENT>, CLIENT> {
|
||||
* @param eventClass event class
|
||||
* @param clientClass client class
|
||||
*/
|
||||
public EventChannel(Class<EVENT> eventClass, Class<CLIENT> clientClass) {
|
||||
public EventChannel(Class<EVENT> eventClass, Class<CLIENT> clientClass)
|
||||
{
|
||||
|
||||
if (eventClass == null || clientClass == null) {
|
||||
throw new NullPointerException("Null Event or Client class.");
|
||||
|
||||
@@ -27,7 +27,8 @@ public abstract class BusNode implements BusAccess, ClientHub {
|
||||
/**
|
||||
* @param busAccess access to bus
|
||||
*/
|
||||
public BusNode(BusAccess busAccess) {
|
||||
public BusNode(BusAccess busAccess)
|
||||
{
|
||||
this.busAccess = busAccess;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public abstract class RootBusNode extends BusNode implements Destroyable {
|
||||
/**
|
||||
* @param busAccess access to bus
|
||||
*/
|
||||
public RootBusNode(BusAccess busAccess) {
|
||||
public RootBusNode(BusAccess busAccess)
|
||||
{
|
||||
super(busAccess);
|
||||
|
||||
getEventBus().subscribe(this);
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package mightypork.util.control.timing;
|
||||
|
||||
|
||||
import mightypork.util.annotations.DefaultImpl;
|
||||
import mightypork.util.constraints.num.Num;
|
||||
import mightypork.util.constraints.num.mutable.NumAnimated;
|
||||
import mightypork.util.constraints.num.proxy.NumBound;
|
||||
import mightypork.util.math.Easing;
|
||||
|
||||
|
||||
public abstract class Animator implements Updateable, Pauseable, NumBound {
|
||||
|
||||
private final NumAnimated animator;
|
||||
private final Num num;
|
||||
|
||||
|
||||
public Animator(double period)
|
||||
{
|
||||
this(0, 1, period, Easing.LINEAR);
|
||||
}
|
||||
|
||||
|
||||
public Animator(double start, double end, double period)
|
||||
{
|
||||
this(start, end, period, Easing.LINEAR);
|
||||
}
|
||||
|
||||
|
||||
public Animator(double period, Easing easing)
|
||||
{
|
||||
this(0, 1, period, easing);
|
||||
}
|
||||
|
||||
|
||||
public Animator(double start, double end, double period, Easing easing)
|
||||
{
|
||||
animator = new NumAnimated(0, easing);
|
||||
animator.setDefaultDuration(period);
|
||||
|
||||
this.num = animator.mul(end - start).add(start);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void pause()
|
||||
{
|
||||
animator.pause();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void resume()
|
||||
{
|
||||
animator.resume();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean isPaused()
|
||||
{
|
||||
return animator.isPaused();
|
||||
}
|
||||
|
||||
|
||||
public final void reset()
|
||||
{
|
||||
animator.reset();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void update(double delta)
|
||||
{
|
||||
animator.update(delta);
|
||||
if (animator.isFinished()) nextCycle(animator);
|
||||
}
|
||||
|
||||
|
||||
@DefaultImpl
|
||||
protected abstract void nextCycle(NumAnimated anim);
|
||||
|
||||
|
||||
@Override
|
||||
public final Num getNum()
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
public final double value()
|
||||
{
|
||||
return num.value();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package mightypork.util.control.timing;
|
||||
|
||||
|
||||
import mightypork.util.constraints.num.mutable.NumAnimated;
|
||||
import mightypork.util.math.Easing;
|
||||
|
||||
|
||||
/**
|
||||
* Animator that upon reaching max, animates back down and then up again
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class AnimatorBounce extends Animator {
|
||||
|
||||
private final boolean wasUp = false;
|
||||
|
||||
|
||||
public AnimatorBounce(double start, double end, double period, Easing easing)
|
||||
{
|
||||
super(start, end, period, easing);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorBounce(double start, double end, double period)
|
||||
{
|
||||
super(start, end, period);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorBounce(double period, Easing easing)
|
||||
{
|
||||
super(period, easing);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorBounce(double period)
|
||||
{
|
||||
super(period);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void nextCycle(NumAnimated anim)
|
||||
{
|
||||
if (wasUp) {
|
||||
anim.fadeOut();
|
||||
} else {
|
||||
anim.fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package mightypork.util.control.timing;
|
||||
|
||||
|
||||
import mightypork.util.constraints.num.mutable.NumAnimated;
|
||||
import mightypork.util.math.Easing;
|
||||
|
||||
|
||||
/**
|
||||
* Animator that upon reaching top, jumps straight to zero and continues another
|
||||
* cycle.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class AnimatorRewind extends Animator {
|
||||
|
||||
public AnimatorRewind(double start, double end, double period, Easing easing)
|
||||
{
|
||||
super(start, end, period, easing);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorRewind(double start, double end, double period)
|
||||
{
|
||||
super(start, end, period);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorRewind(double period, Easing easing)
|
||||
{
|
||||
super(period, easing);
|
||||
}
|
||||
|
||||
|
||||
public AnimatorRewind(double period)
|
||||
{
|
||||
super(period);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void nextCycle(NumAnimated anim)
|
||||
{
|
||||
anim.reset();
|
||||
anim.fadeIn();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,8 @@ public class TimerDelta {
|
||||
/**
|
||||
* New delta timer
|
||||
*/
|
||||
public TimerDelta() {
|
||||
public TimerDelta()
|
||||
{
|
||||
lastFrame = System.nanoTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ public class TimerFps {
|
||||
*
|
||||
* @param fps target FPS
|
||||
*/
|
||||
public TimerFps(long fps) {
|
||||
public TimerFps(long fps)
|
||||
{
|
||||
FRAME = Math.round(SECOND / (double) fps);
|
||||
|
||||
lastFrame = System.nanoTime();
|
||||
|
||||
@@ -2,20 +2,27 @@ package mightypork.util.error;
|
||||
|
||||
|
||||
public class KeyAlreadyExistsException extends RuntimeException {
|
||||
|
||||
public KeyAlreadyExistsException() {
|
||||
|
||||
public KeyAlreadyExistsException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public KeyAlreadyExistsException(String message, Throwable cause) {
|
||||
|
||||
|
||||
public KeyAlreadyExistsException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public KeyAlreadyExistsException(String message) {
|
||||
|
||||
|
||||
public KeyAlreadyExistsException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public KeyAlreadyExistsException(Throwable cause) {
|
||||
|
||||
|
||||
public KeyAlreadyExistsException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,8 @@ public class FileTreeDiff {
|
||||
|
||||
private class NotEqualException extends Exception {
|
||||
|
||||
public NotEqualException(String msg) {
|
||||
public NotEqualException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@@ -142,7 +143,8 @@ public class FileTreeDiff {
|
||||
public T b;
|
||||
|
||||
|
||||
public Tuple(T a, T b) {
|
||||
public Tuple(T a, T b)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package mightypork.util.files.ion;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mightypork.util.logging.Log;
|
||||
|
||||
@@ -108,8 +108,7 @@ public class Ion {
|
||||
static {
|
||||
markRangeChecking = false;
|
||||
|
||||
registerIonizable(DATA_BUNDLE, IonDataBundle.class);
|
||||
registerIonizable(DATA_LIST, IonDataList.class);
|
||||
registerIonizable(DATA_BUNDLE, IonBundle.class);
|
||||
|
||||
markRangeChecking = true;
|
||||
}
|
||||
@@ -248,131 +247,130 @@ public class Ion {
|
||||
*/
|
||||
public static Object readObject(InputStream in) throws IOException
|
||||
{
|
||||
try {
|
||||
final short mark = readMark(in);
|
||||
if (customIonizables.containsKey(mark)) {
|
||||
Ionizable ionObj;
|
||||
final short mark = readMark(in);
|
||||
if (customIonizables.containsKey(mark)) {
|
||||
Ionizable loaded;
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
ionObj = ((Ionizable) customIonizables.get(mark).newInstance());
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new IOException("Cound not instantiate: " + Log.str(customIonizables.get(mark)), e);
|
||||
final Class<?> clz = customIonizables.get(mark);
|
||||
loaded = ((Ionizable) clz.newInstance());
|
||||
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new IOException("Cound not instantiate: " + Log.str(customIonizables.get(mark)), e);
|
||||
}
|
||||
|
||||
loaded.load(in);
|
||||
return loaded;
|
||||
}
|
||||
|
||||
int length;
|
||||
|
||||
switch (mark) {
|
||||
case NULL:
|
||||
return null;
|
||||
|
||||
case BOOLEAN:
|
||||
return readBoolean(in);
|
||||
|
||||
case BYTE:
|
||||
return readByte(in);
|
||||
|
||||
case CHAR:
|
||||
return readChar(in);
|
||||
|
||||
case SHORT:
|
||||
return readShort(in);
|
||||
|
||||
case INT:
|
||||
return readInt(in);
|
||||
|
||||
case LONG:
|
||||
return readLong(in);
|
||||
|
||||
case FLOAT:
|
||||
return readFloat(in);
|
||||
|
||||
case DOUBLE:
|
||||
return readDouble(in);
|
||||
|
||||
case STRING:
|
||||
return readString(in);
|
||||
|
||||
case BOOLEAN_ARRAY:
|
||||
length = readInt(in);
|
||||
final boolean[] bools = new boolean[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
bools[i] = readBoolean(in);
|
||||
}
|
||||
return bools;
|
||||
|
||||
ionObj.loadFrom(in);
|
||||
return ionObj;
|
||||
}
|
||||
|
||||
int length;
|
||||
|
||||
switch (mark) {
|
||||
case NULL:
|
||||
return null;
|
||||
|
||||
case BOOLEAN:
|
||||
return readBoolean(in);
|
||||
|
||||
case BYTE:
|
||||
return readByte(in);
|
||||
|
||||
case CHAR:
|
||||
return readChar(in);
|
||||
|
||||
case SHORT:
|
||||
return readShort(in);
|
||||
|
||||
case INT:
|
||||
return readInt(in);
|
||||
|
||||
case LONG:
|
||||
return readLong(in);
|
||||
|
||||
case FLOAT:
|
||||
return readFloat(in);
|
||||
|
||||
case DOUBLE:
|
||||
return readDouble(in);
|
||||
|
||||
case STRING:
|
||||
return readString(in);
|
||||
|
||||
case BOOLEAN_ARRAY:
|
||||
length = readInt(in);
|
||||
final boolean[] bools = new boolean[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
bools[i] = readBoolean(in);
|
||||
}
|
||||
return bools;
|
||||
|
||||
case BYTE_ARRAY:
|
||||
length = readInt(in);
|
||||
final byte[] bytes = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
bytes[i] = readByte(in);
|
||||
}
|
||||
return bytes;
|
||||
|
||||
case CHAR_ARRAY:
|
||||
length = readInt(in);
|
||||
final char[] chars = new char[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
chars[i] = readChar(in);
|
||||
}
|
||||
return chars;
|
||||
|
||||
case SHORT_ARRAY:
|
||||
length = readInt(in);
|
||||
final short[] shorts = new short[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
shorts[i] = readShort(in);
|
||||
}
|
||||
return shorts;
|
||||
|
||||
case INT_ARRAY:
|
||||
length = readInt(in);
|
||||
final int[] ints = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ints[i] = readInt(in);
|
||||
}
|
||||
return ints;
|
||||
|
||||
case LONG_ARRAY:
|
||||
length = readInt(in);
|
||||
final long[] longs = new long[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
longs[i] = readLong(in);
|
||||
}
|
||||
return longs;
|
||||
|
||||
case FLOAT_ARRAY:
|
||||
length = readInt(in);
|
||||
final float[] floats = new float[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
floats[i] = readFloat(in);
|
||||
}
|
||||
return floats;
|
||||
|
||||
case DOUBLE_ARRAY:
|
||||
length = readInt(in);
|
||||
final double[] doubles = new double[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
doubles[i] = readDouble(in);
|
||||
}
|
||||
return doubles;
|
||||
|
||||
case STRING_ARRAY:
|
||||
length = readInt(in);
|
||||
final String[] Strings = new String[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
Strings[i] = readString(in);
|
||||
}
|
||||
return Strings;
|
||||
|
||||
default:
|
||||
throw new IOException("Invalid Ion mark: " + mark);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new IOException("Error loading ION file: ", e);
|
||||
case BYTE_ARRAY:
|
||||
length = readInt(in);
|
||||
final byte[] bytes = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
bytes[i] = readByte(in);
|
||||
}
|
||||
return bytes;
|
||||
|
||||
case CHAR_ARRAY:
|
||||
length = readInt(in);
|
||||
final char[] chars = new char[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
chars[i] = readChar(in);
|
||||
}
|
||||
return chars;
|
||||
|
||||
case SHORT_ARRAY:
|
||||
length = readInt(in);
|
||||
final short[] shorts = new short[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
shorts[i] = readShort(in);
|
||||
}
|
||||
return shorts;
|
||||
|
||||
case INT_ARRAY:
|
||||
length = readInt(in);
|
||||
final int[] ints = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ints[i] = readInt(in);
|
||||
}
|
||||
return ints;
|
||||
|
||||
case LONG_ARRAY:
|
||||
length = readInt(in);
|
||||
final long[] longs = new long[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
longs[i] = readLong(in);
|
||||
}
|
||||
return longs;
|
||||
|
||||
case FLOAT_ARRAY:
|
||||
length = readInt(in);
|
||||
final float[] floats = new float[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
floats[i] = readFloat(in);
|
||||
}
|
||||
return floats;
|
||||
|
||||
case DOUBLE_ARRAY:
|
||||
length = readInt(in);
|
||||
final double[] doubles = new double[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
doubles[i] = readDouble(in);
|
||||
}
|
||||
return doubles;
|
||||
|
||||
case STRING_ARRAY:
|
||||
length = readInt(in);
|
||||
final String[] Strings = new String[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
Strings[i] = readString(in);
|
||||
}
|
||||
return Strings;
|
||||
|
||||
default:
|
||||
throw new IOException("Invalid Ion mark: " + mark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,126 +402,121 @@ public class Ion {
|
||||
*/
|
||||
public static void writeObject(OutputStream out, Object obj) throws IOException
|
||||
{
|
||||
try {
|
||||
if (obj instanceof Ionizable) {
|
||||
writeMark(out, ((Ionizable) obj).getIonMark());
|
||||
((Ionizable) obj).saveTo(out);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Boolean) {
|
||||
writeMark(out, BOOLEAN);
|
||||
writeBoolean(out, (Boolean) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Byte) {
|
||||
writeMark(out, BYTE);
|
||||
writeByte(out, (Byte) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Character) {
|
||||
writeMark(out, CHAR);
|
||||
writeChar(out, (Character) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Short) {
|
||||
writeMark(out, SHORT);
|
||||
writeShort(out, (Short) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Integer) {
|
||||
writeMark(out, INT);
|
||||
writeInt(out, (Integer) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Long) {
|
||||
writeMark(out, LONG);
|
||||
writeLong(out, (Long) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Float) {
|
||||
writeMark(out, FLOAT);
|
||||
writeFloat(out, (Float) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Double) {
|
||||
writeMark(out, DOUBLE);
|
||||
writeDouble(out, (Double) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
writeMark(out, STRING);
|
||||
writeString(out, (String) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof boolean[]) {
|
||||
writeMark(out, BOOLEAN_ARRAY);
|
||||
writeBooleanArray(out, (boolean[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof byte[]) {
|
||||
writeMark(out, BYTE_ARRAY);
|
||||
writeByteArray(out, (byte[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof char[]) {
|
||||
writeMark(out, CHAR_ARRAY);
|
||||
writeCharArray(out, (char[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof short[]) {
|
||||
writeMark(out, SHORT_ARRAY);
|
||||
writeShortArray(out, (short[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof int[]) {
|
||||
writeMark(out, INT_ARRAY);
|
||||
writeIntArray(out, (int[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof long[]) {
|
||||
writeMark(out, LONG_ARRAY);
|
||||
writeLongArray(out, (long[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof float[]) {
|
||||
writeMark(out, FLOAT_ARRAY);
|
||||
writeFloatArray(out, (float[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof double[]) {
|
||||
writeMark(out, DOUBLE_ARRAY);
|
||||
writeDoubleArray(out, (double[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof String[]) {
|
||||
writeMark(out, STRING_ARRAY);
|
||||
writeStringArray(out, (String[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IOException("Object " + Log.str(obj) + " could not be be ionized.");
|
||||
|
||||
} catch (final IOException e) {
|
||||
throw new IOException("Could not store: " + obj, e);
|
||||
if (obj instanceof Ionizable) {
|
||||
writeMark(out, ((Ionizable) obj).getIonMark());
|
||||
((Ionizable) obj).save(out);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Boolean) {
|
||||
writeMark(out, BOOLEAN);
|
||||
writeBoolean(out, (Boolean) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Byte) {
|
||||
writeMark(out, BYTE);
|
||||
writeByte(out, (Byte) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Character) {
|
||||
writeMark(out, CHAR);
|
||||
writeChar(out, (Character) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Short) {
|
||||
writeMark(out, SHORT);
|
||||
writeShort(out, (Short) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Integer) {
|
||||
writeMark(out, INT);
|
||||
writeInt(out, (Integer) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Long) {
|
||||
writeMark(out, LONG);
|
||||
writeLong(out, (Long) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Float) {
|
||||
writeMark(out, FLOAT);
|
||||
writeFloat(out, (Float) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof Double) {
|
||||
writeMark(out, DOUBLE);
|
||||
writeDouble(out, (Double) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
writeMark(out, STRING);
|
||||
writeString(out, (String) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof boolean[]) {
|
||||
writeMark(out, BOOLEAN_ARRAY);
|
||||
writeBooleanArray(out, (boolean[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof byte[]) {
|
||||
writeMark(out, BYTE_ARRAY);
|
||||
writeByteArray(out, (byte[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof char[]) {
|
||||
writeMark(out, CHAR_ARRAY);
|
||||
writeCharArray(out, (char[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof short[]) {
|
||||
writeMark(out, SHORT_ARRAY);
|
||||
writeShortArray(out, (short[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof int[]) {
|
||||
writeMark(out, INT_ARRAY);
|
||||
writeIntArray(out, (int[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof long[]) {
|
||||
writeMark(out, LONG_ARRAY);
|
||||
writeLongArray(out, (long[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof float[]) {
|
||||
writeMark(out, FLOAT_ARRAY);
|
||||
writeFloatArray(out, (float[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof double[]) {
|
||||
writeMark(out, DOUBLE_ARRAY);
|
||||
writeDoubleArray(out, (double[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof String[]) {
|
||||
writeMark(out, STRING_ARRAY);
|
||||
writeStringArray(out, (String[]) obj);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IOException("Object " + Log.str(obj) + " could not be be ionized.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1164,4 +1157,130 @@ public class Ion {
|
||||
return Strings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads mark and returns true if the mark is ENTRY, false if the mark is
|
||||
* END. Throws an exception otherwise.
|
||||
*
|
||||
* @param in input stream
|
||||
* @return mark was ENTRY
|
||||
* @throws IOException when the mark is neither ENTRY or END.
|
||||
*/
|
||||
public static boolean hasNextEntry(InputStream in) throws IOException
|
||||
{
|
||||
final short mark = readMark(in);
|
||||
if (mark == ENTRY) return true;
|
||||
if (mark == END) return false;
|
||||
|
||||
throw new IOException("Unexpected mark encountered while reading sequence.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a sequence of elements
|
||||
*
|
||||
* @param in input stream
|
||||
* @return the collection
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> Collection<T> readSequence(InputStream in) throws IOException
|
||||
{
|
||||
return readSequence(in, new LinkedList<T>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load entries into a collection
|
||||
*
|
||||
* @param in input stream
|
||||
* @param filled collection to populate
|
||||
* @return the collection
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Collection<T> readSequence(InputStream in, Collection<T> filled) throws IOException
|
||||
{
|
||||
try {
|
||||
while (hasNextEntry(in)) {
|
||||
filled.add((T) readObject(in));
|
||||
}
|
||||
return filled;
|
||||
} catch (final ClassCastException e) {
|
||||
throw new IOException("Unexpected element type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write collection entries to a stream
|
||||
*
|
||||
* @param out output stream
|
||||
* @param sequence written collection
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> void writeSequence(OutputStream out, Collection<T> sequence) throws IOException
|
||||
{
|
||||
for (final T element : sequence) {
|
||||
writeMark(out, ENTRY);
|
||||
writeObject(out, element);
|
||||
}
|
||||
writeMark(out, END);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a map of elements
|
||||
*
|
||||
* @param in input stream
|
||||
* @return the map
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <K, V> Map<K, V> readMap(InputStream in) throws IOException
|
||||
{
|
||||
return readMap(in, new LinkedHashMap<K, V>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load data into a map
|
||||
*
|
||||
* @param in input stream
|
||||
* @param filled filled map
|
||||
* @return the map
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <K, V> Map<K, V> readMap(InputStream in, Map<K, V> filled) throws IOException
|
||||
{
|
||||
try {
|
||||
while (hasNextEntry(in)) {
|
||||
final K key = (K) readObject(in);
|
||||
final V value = (V) readObject(in);
|
||||
|
||||
filled.put(key, value);
|
||||
}
|
||||
return filled;
|
||||
} catch (final ClassCastException e) {
|
||||
throw new IOException("Unexpected element type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a map
|
||||
*
|
||||
* @param out output stream
|
||||
* @param map map to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <K, V> void writeMap(OutputStream out, Map<K, V> map) throws IOException
|
||||
{
|
||||
for (final Entry<K, V> e : map.entrySet()) {
|
||||
writeMark(out, ENTRY);
|
||||
writeObject(out, e.getKey());
|
||||
writeObject(out, e.getValue());
|
||||
}
|
||||
writeMark(out, END);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Data bundle.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class IonBundle extends LinkedHashMap<String, Object> implements Ionizable {
|
||||
|
||||
/**
|
||||
* Get an object. If not found, fallback is returned.
|
||||
*
|
||||
* @param key key
|
||||
* @param fallback fallback
|
||||
* @return element
|
||||
*/
|
||||
public <T> T get(String key, T fallback)
|
||||
{
|
||||
try {
|
||||
final T itm = (T) super.get(key);
|
||||
if (itm == null) return fallback;
|
||||
return itm;
|
||||
} catch (final ClassCastException e) {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store an element. It's allowed to store any object, but only primitive
|
||||
* types, String, their arrays, and Ionizable objects can be successfully
|
||||
* stored to stream..
|
||||
*/
|
||||
@Override
|
||||
public Object put(String key, Object value)
|
||||
{
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getIonMark()
|
||||
{
|
||||
return Ion.DATA_BUNDLE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(InputStream in) throws IOException
|
||||
{
|
||||
clear();
|
||||
Ion.readMap(in, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save(OutputStream out) throws IOException
|
||||
{
|
||||
Ion.writeMap(out, this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Implicit constructor marked like this is intended to be solely used for ION
|
||||
* de-serialization. This is a description annotation and has no other function.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.CONSTRUCTOR)
|
||||
@Documented
|
||||
public @interface IonConstructor {
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable HashMap<String, Object> with getters and setters for individual
|
||||
* supported types.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class IonDataBundle extends IonMap<String, Object> {
|
||||
|
||||
public boolean getBoolean(String key)
|
||||
{
|
||||
return (Boolean) getOfType(key, Boolean.class);
|
||||
}
|
||||
|
||||
|
||||
public byte getByte(String key)
|
||||
{
|
||||
return (Byte) getOfType(key, Byte.class);
|
||||
}
|
||||
|
||||
|
||||
public char getChar(String key)
|
||||
{
|
||||
return (Character) getOfType(key, Character.class);
|
||||
}
|
||||
|
||||
|
||||
public short getShort(String key)
|
||||
{
|
||||
return (Short) getOfType(key, Short.class);
|
||||
}
|
||||
|
||||
|
||||
public int getInt(String key)
|
||||
{
|
||||
return (Integer) getOfType(key, Integer.class);
|
||||
}
|
||||
|
||||
|
||||
public long getLong(String key)
|
||||
{
|
||||
return (Long) getOfType(key, Long.class);
|
||||
}
|
||||
|
||||
|
||||
public float getFloat(String key)
|
||||
{
|
||||
return (Float) getOfType(key, Float.class);
|
||||
}
|
||||
|
||||
|
||||
public double getDouble(String key)
|
||||
{
|
||||
return (Double) getOfType(key, Double.class);
|
||||
}
|
||||
|
||||
|
||||
public String getString(String key)
|
||||
{
|
||||
return (String) getOfType(key, String.class);
|
||||
}
|
||||
|
||||
|
||||
public void putBoolean(String key, boolean num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putByte(String key, int num)
|
||||
{
|
||||
super.put(key, (byte) num);
|
||||
}
|
||||
|
||||
|
||||
public void putChar(String key, char num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putShort(String key, int num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putInt(String key, int num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putLong(String key, long num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putFloat(String key, double num)
|
||||
{
|
||||
super.put(key, (float) num);
|
||||
}
|
||||
|
||||
|
||||
public void putDouble(String key, double num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public void putString(String key, String num)
|
||||
{
|
||||
super.put(key, num);
|
||||
}
|
||||
|
||||
|
||||
public Object getOfType(String key, Class<?> type)
|
||||
{
|
||||
final Object o = super.get(key);
|
||||
if (o == null || !o.getClass().isAssignableFrom(type)) {
|
||||
throw new RuntimeException("Incorrect object type");
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getIonMark()
|
||||
{
|
||||
return Ion.DATA_BUNDLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable Arraylist
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class IonDataList extends IonList<Object> {
|
||||
|
||||
public Ionizable getIonizable(int index)
|
||||
{
|
||||
return (Ionizable) getOfType(index, Ionizable.class);
|
||||
}
|
||||
|
||||
|
||||
public boolean getBoolean(int index)
|
||||
{
|
||||
return (Boolean) getOfType(index, Boolean.class);
|
||||
}
|
||||
|
||||
|
||||
public byte getByte(int index)
|
||||
{
|
||||
return (Byte) getOfType(index, Byte.class);
|
||||
}
|
||||
|
||||
|
||||
public char getChar(int index)
|
||||
{
|
||||
return (Character) getOfType(index, Character.class);
|
||||
}
|
||||
|
||||
|
||||
public short getShort(int index)
|
||||
{
|
||||
return (Short) getOfType(index, Short.class);
|
||||
}
|
||||
|
||||
|
||||
public int getInt(int index)
|
||||
{
|
||||
return (Integer) getOfType(index, Integer.class);
|
||||
}
|
||||
|
||||
|
||||
public long getLong(int index)
|
||||
{
|
||||
return (Long) getOfType(index, Long.class);
|
||||
}
|
||||
|
||||
|
||||
public float getFloat(int index)
|
||||
{
|
||||
return (Float) getOfType(index, Float.class);
|
||||
}
|
||||
|
||||
|
||||
public double getDouble(int index)
|
||||
{
|
||||
return (Double) getOfType(index, Double.class);
|
||||
}
|
||||
|
||||
|
||||
public String getString(int index)
|
||||
{
|
||||
return (String) getOfType(index, String.class);
|
||||
}
|
||||
|
||||
|
||||
public void addIonizable(Ionizable o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addBoolean(boolean o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addByte(byte o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addChar(char o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addShort(short o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addInt(int o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addLong(long o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addFloat(float o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addDouble(double o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public void addString(String o)
|
||||
{
|
||||
super.add(o);
|
||||
}
|
||||
|
||||
|
||||
public Object getOfType(int index, Class<?> type)
|
||||
{
|
||||
final Object o = super.get(index);
|
||||
if (o == null || !o.getClass().isAssignableFrom(type)) {
|
||||
throw new RuntimeException("Incorrect object type");
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getIonMark()
|
||||
{
|
||||
return Ion.DATA_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable Arraylist
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class IonList<T> extends ArrayList<T> implements Ionizable {
|
||||
|
||||
@Override
|
||||
public void loadFrom(InputStream in) throws IOException
|
||||
{
|
||||
try {
|
||||
while (true) {
|
||||
final short mark = Ion.readMark(in);
|
||||
|
||||
if (mark == Ion.ENTRY) {
|
||||
final T value = (T) Ion.readObject(in);
|
||||
add(value);
|
||||
} else if (mark == Ion.END) {
|
||||
break;
|
||||
} else {
|
||||
throw new IOException("Unexpected mark in IonList: " + mark);
|
||||
}
|
||||
}
|
||||
readCustomData(in);
|
||||
} catch (final IOException e) {
|
||||
throw new IOException("Error reading ion list", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveTo(OutputStream out) throws IOException
|
||||
{
|
||||
try {
|
||||
for (final T entry : this) {
|
||||
Ion.writeMark(out, Ion.ENTRY);
|
||||
Ion.writeObject(out, entry);
|
||||
}
|
||||
Ion.writeMark(out, Ion.END);
|
||||
writeCustomData(out);
|
||||
} catch (final IOException e) {
|
||||
throw new IOException("Error reading ion map", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read custom data of this AbstractIonList implementation
|
||||
*
|
||||
* @param in input stream
|
||||
*/
|
||||
public void readCustomData(InputStream in)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write custom data of this AbstractIonList implementation
|
||||
*
|
||||
* @param out output stream
|
||||
*/
|
||||
public void writeCustomData(OutputStream out)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public abstract short getIonMark();
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package mightypork.util.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import mightypork.util.annotations.DefaultImpl;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable HashMap
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <K> key
|
||||
* @param <V> value
|
||||
*/
|
||||
public abstract class IonMap<K, V> extends LinkedHashMap<K, V> implements Ionizable {
|
||||
|
||||
@Override
|
||||
public V get(Object key)
|
||||
{
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public V put(K key, V value)
|
||||
{
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadFrom(InputStream in) throws IOException
|
||||
{
|
||||
try {
|
||||
while (true) {
|
||||
final short mark = Ion.readMark(in);
|
||||
if (mark == Ion.ENTRY) {
|
||||
final K key = (K) Ion.readObject(in);
|
||||
final V value = (V) Ion.readObject(in);
|
||||
put(key, value);
|
||||
|
||||
} else if (mark == Ion.END) {
|
||||
break;
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected mark in IonMap: " + mark);
|
||||
}
|
||||
}
|
||||
readCustomData(in);
|
||||
} catch (final IOException | ClassCastException e) {
|
||||
throw new IOException("Error reading ion map", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveTo(OutputStream out) throws IOException
|
||||
{
|
||||
try {
|
||||
for (final java.util.Map.Entry<K, V> entry : entrySet()) {
|
||||
Ion.writeMark(out, Ion.ENTRY);
|
||||
Ion.writeObject(out, entry.getKey());
|
||||
Ion.writeObject(out, entry.getValue());
|
||||
}
|
||||
Ion.writeMark(out, Ion.END);
|
||||
writeCustomData(out);
|
||||
} catch (final IOException e) {
|
||||
throw new IOException("Error writing ion map", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read custom data of this AbstractIonMap implementation
|
||||
*
|
||||
* @param in input stream
|
||||
*/
|
||||
@DefaultImpl
|
||||
public void readCustomData(InputStream in)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write custom data of this AbstractIonMap implementation
|
||||
*
|
||||
* @param out output stream
|
||||
*/
|
||||
@DefaultImpl
|
||||
public void writeCustomData(OutputStream out)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getIonMark()
|
||||
{
|
||||
return Ion.DATA_BUNDLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public interface Ionizable {
|
||||
* @param in input stream
|
||||
* @throws IOException
|
||||
*/
|
||||
void loadFrom(InputStream in) throws IOException;
|
||||
void load(InputStream in) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ public interface Ionizable {
|
||||
* @param out Output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
void saveTo(OutputStream out) throws IOException;
|
||||
void save(OutputStream out) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,8 @@ public class ZipBuilder {
|
||||
* @param target target zip file
|
||||
* @throws IOException if the file is directory or cannot be created
|
||||
*/
|
||||
public ZipBuilder(File target) throws IOException {
|
||||
public ZipBuilder(File target) throws IOException
|
||||
{
|
||||
|
||||
if (!target.getParentFile().mkdirs()) throw new IOException("Could not create output directory.");
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ public class ArchivingLog extends SimpleLog {
|
||||
* @param file log file (in log directory)
|
||||
* @param oldLogCount number of old log files to keep: -1 all, 0 none.
|
||||
*/
|
||||
public ArchivingLog(String name, File file, int oldLogCount) {
|
||||
public ArchivingLog(String name, File file, int oldLogCount)
|
||||
{
|
||||
super(name, file);
|
||||
this.logs_to_keep = oldLogCount;
|
||||
}
|
||||
@@ -43,7 +44,8 @@ public class ArchivingLog extends SimpleLog {
|
||||
* @param name log name
|
||||
* @param file log file (in log directory)
|
||||
*/
|
||||
public ArchivingLog(String name, File file) {
|
||||
public ArchivingLog(String name, File file)
|
||||
{
|
||||
super(name, file);
|
||||
this.logs_to_keep = 5;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ public class SimpleLog implements LogWriter {
|
||||
private final long started_ms;
|
||||
|
||||
|
||||
public SimpleLog(String name, File file) {
|
||||
public SimpleLog(String name, File file)
|
||||
{
|
||||
this.name = name;
|
||||
this.file = file;
|
||||
this.started_ms = System.currentTimeMillis();
|
||||
|
||||
@@ -49,7 +49,6 @@ public class Calc {
|
||||
return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
||||
}
|
||||
|
||||
|
||||
private static class Angles {
|
||||
|
||||
public static double delta(double alpha, double beta, double a360)
|
||||
@@ -384,7 +383,8 @@ public class Calc {
|
||||
}
|
||||
|
||||
private static Random rand = new Random();
|
||||
|
||||
|
||||
|
||||
public static double sphereSurface(double radius)
|
||||
{
|
||||
return 4D * Math.PI * square(radius);
|
||||
|
||||
@@ -72,7 +72,8 @@ public abstract class Easing {
|
||||
/**
|
||||
* @param in Easing to reverse
|
||||
*/
|
||||
public Reverse(Easing in) {
|
||||
public Reverse(Easing in)
|
||||
{
|
||||
this.ea = in;
|
||||
}
|
||||
|
||||
@@ -101,7 +102,8 @@ public abstract class Easing {
|
||||
* @param in initial EasingFunction
|
||||
* @param out terminal EasingFunction
|
||||
*/
|
||||
public Composite(Easing in, Easing out) {
|
||||
public Composite(Easing in, Easing out)
|
||||
{
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public class Polar {
|
||||
* @param angle angle in RAD
|
||||
* @param distance distance from origin
|
||||
*/
|
||||
public Polar(double angle, double distance) {
|
||||
public Polar(double angle, double distance)
|
||||
{
|
||||
this(angle, false, distance);
|
||||
}
|
||||
|
||||
@@ -38,7 +39,8 @@ public class Polar {
|
||||
* @param deg angle is in DEG
|
||||
* @param distance radius
|
||||
*/
|
||||
public Polar(double angle, boolean deg, double distance) {
|
||||
public Polar(double angle, boolean deg, double distance)
|
||||
{
|
||||
this.radius = distance;
|
||||
this.angle = deg ? Math.toRadians(angle) : angle;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public class Range {
|
||||
/**
|
||||
* Implicit range constructor 0-1
|
||||
*/
|
||||
public Range() {
|
||||
public Range()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +36,8 @@ public class Range {
|
||||
* @param min min number
|
||||
* @param max max number
|
||||
*/
|
||||
public Range(double min, double max) {
|
||||
public Range(double min, double max)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
norm();
|
||||
@@ -47,7 +49,8 @@ public class Range {
|
||||
*
|
||||
* @param minmax min = max number
|
||||
*/
|
||||
public Range(double minmax) {
|
||||
public Range(double minmax)
|
||||
{
|
||||
this.min = minmax;
|
||||
this.max = minmax;
|
||||
}
|
||||
@@ -178,5 +181,4 @@ public class Range {
|
||||
this.max = max;
|
||||
norm();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,13 +137,13 @@ public abstract class Color {
|
||||
|
||||
protected static final double clamp(Num n)
|
||||
{
|
||||
return Calc.clampd(n.value(), 0, 1);
|
||||
return Calc.clamp(n.value(), 0, 1);
|
||||
}
|
||||
|
||||
|
||||
protected static final double clamp(double n)
|
||||
{
|
||||
return Calc.clampd(n, 0, 1);
|
||||
return Calc.clamp(n, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ public class ColorAlphaAdjuster extends Color {
|
||||
private final Num alphaAdjust;
|
||||
|
||||
|
||||
public ColorAlphaAdjuster(Color source, Num alphaMul) {
|
||||
public ColorAlphaAdjuster(Color source, Num alphaMul)
|
||||
{
|
||||
this.source = source;
|
||||
this.alphaAdjust = alphaMul;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ public class ColorHsb extends Color {
|
||||
private final Num a;
|
||||
|
||||
|
||||
public ColorHsb(Num h, Num s, Num b, Num a) {
|
||||
public ColorHsb(Num h, Num s, Num b, Num a)
|
||||
{
|
||||
this.h = h;
|
||||
this.s = s;
|
||||
this.b = b;
|
||||
|
||||
@@ -12,7 +12,8 @@ public class ColorRgb extends Color {
|
||||
private final Num a;
|
||||
|
||||
|
||||
public ColorRgb(Num r, Num g, Num b, Num a) {
|
||||
public ColorRgb(Num r, Num g, Num b, Num a)
|
||||
{
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
|
||||
@@ -27,7 +27,8 @@ public class NoiseGen {
|
||||
* @param middle middle bound ("surface")
|
||||
* @param high high bound ("hill")
|
||||
*/
|
||||
public NoiseGen(double density, double low, double middle, double high) {
|
||||
public NoiseGen(double density, double low, double middle, double high)
|
||||
{
|
||||
this(density, low, middle, high, Double.doubleToLongBits(Math.random()));
|
||||
}
|
||||
|
||||
@@ -41,7 +42,8 @@ public class NoiseGen {
|
||||
* @param high high bound ("hill")
|
||||
* @param seed random seed to use
|
||||
*/
|
||||
public NoiseGen(double density, double low, double middle, double high, long seed) {
|
||||
public NoiseGen(double density, double low, double middle, double high, long seed)
|
||||
{
|
||||
if (low > middle || middle > high) throw new IllegalArgumentException("Invalid value range.");
|
||||
|
||||
this.density = density;
|
||||
|
||||
@@ -60,7 +60,8 @@ public class PerlinNoiseGenerator {
|
||||
/**
|
||||
* Create a new noise creator with the default seed value
|
||||
*/
|
||||
public PerlinNoiseGenerator() {
|
||||
public PerlinNoiseGenerator()
|
||||
{
|
||||
this(DEFAULT_SEED);
|
||||
}
|
||||
|
||||
@@ -70,7 +71,8 @@ public class PerlinNoiseGenerator {
|
||||
*
|
||||
* @param seed The seed value to use
|
||||
*/
|
||||
public PerlinNoiseGenerator(long seed) {
|
||||
public PerlinNoiseGenerator(long seed)
|
||||
{
|
||||
p_imp = new int[DEFAULT_SAMPLE_SIZE << 1];
|
||||
|
||||
int i, j, k;
|
||||
|
||||
@@ -18,7 +18,8 @@ public class Mutable<T> {
|
||||
*
|
||||
* @param o value
|
||||
*/
|
||||
public Mutable(T o) {
|
||||
public Mutable(T o)
|
||||
{
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ public class Pair<T1, T2> {
|
||||
* @param first 1st object
|
||||
* @param second 2nd object
|
||||
*/
|
||||
public Pair(T1 first, T2 second) {
|
||||
public Pair(T1 first, T2 second)
|
||||
{
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class Pair<T1, T2> {
|
||||
|
||||
final Pair<?, ?> t = (Pair<?, ?>) obj;
|
||||
|
||||
return Calc.areObjectsEqual(first, t.first) && Calc.areObjectsEqual(second, t.second);
|
||||
return Calc.areEqual(first, t.first) && Calc.areEqual(second, t.second);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
|
||||
* @param objB 2nd object
|
||||
* @param objC 3rd object
|
||||
*/
|
||||
public Triad(T1 objA, T2 objB, T3 objC) {
|
||||
public Triad(T1 objA, T2 objB, T3 objC)
|
||||
{
|
||||
super(objA, objB);
|
||||
third = objC;
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
|
||||
{
|
||||
if (!super.equals(obj)) return false;
|
||||
|
||||
return Calc.areObjectsEqual(third, ((Triad<?, ?, ?>) obj).third);
|
||||
return Calc.areEqual(third, ((Triad<?, ?, ?>) obj).third);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ public interface StringProvider {
|
||||
private final String value;
|
||||
|
||||
|
||||
public StringWrapper(String value) {
|
||||
public StringWrapper(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ public class FileSuffixFilter implements FileFilter {
|
||||
*
|
||||
* @param suffixes var-args allowed suffixes, case insensitive
|
||||
*/
|
||||
public FileSuffixFilter(String... suffixes) {
|
||||
public FileSuffixFilter(String... suffixes)
|
||||
{
|
||||
this.suffixes = suffixes;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ public class RegexCharFilter implements CharFilter {
|
||||
private final String formula;
|
||||
|
||||
|
||||
public RegexCharFilter(String regex) {
|
||||
public RegexCharFilter(String regex)
|
||||
{
|
||||
this.formula = regex;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ public class WhitelistCharFilter implements CharFilter {
|
||||
private final String whitelist;
|
||||
|
||||
|
||||
public WhitelistCharFilter(String allowed) {
|
||||
public WhitelistCharFilter(String allowed)
|
||||
{
|
||||
this.whitelist = allowed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user