Cleanup and minor javadoc fixes

master
Ondřej Hruška 11 years ago
parent e973aab384
commit 16956fa927
  1. 8
      src/mightypork/utils/MapSort.java
  2. 12
      src/mightypork/utils/Reflect.java
  3. 7
      src/mightypork/utils/Support.java
  4. 7
      src/mightypork/utils/annotations/Alias.java
  5. 10
      src/mightypork/utils/config/propmgr/Property.java
  6. 8
      src/mightypork/utils/config/propmgr/PropertyManager.java
  7. 6
      src/mightypork/utils/config/propmgr/properties/BooleanProperty.java
  8. 6
      src/mightypork/utils/config/propmgr/properties/DoubleProperty.java
  9. 6
      src/mightypork/utils/config/propmgr/properties/IntegerProperty.java
  10. 6
      src/mightypork/utils/config/propmgr/properties/StringProperty.java
  11. 12
      src/mightypork/utils/config/propmgr/store/PropertyFile.java
  12. 8
      src/mightypork/utils/config/propmgr/store/SortedProperties.java
  13. 9
      src/mightypork/utils/eventbus/EventBus.java
  14. 3
      src/mightypork/utils/eventbus/EventChannel.java
  15. 3
      src/mightypork/utils/eventbus/clients/ClientList.java
  16. 6
      src/mightypork/utils/eventbus/clients/DelegatingList.java
  17. 3
      src/mightypork/utils/eventbus/events/UpdateEvent.java
  18. 7
      src/mightypork/utils/eventbus/events/flags/DelayedEvent.java
  19. 7
      src/mightypork/utils/eventbus/events/flags/DirectEvent.java
  20. 7
      src/mightypork/utils/eventbus/events/flags/NotLoggedEvent.java
  21. 7
      src/mightypork/utils/eventbus/events/flags/SingleReceiverEvent.java
  22. 12
      src/mightypork/utils/exceptions/CorruptDataException.java
  23. 12
      src/mightypork/utils/exceptions/IllegalValueException.java
  24. 12
      src/mightypork/utils/exceptions/KeyAlreadyExistsException.java
  25. 3
      src/mightypork/utils/files/FileSuffixFilter.java
  26. 12
      src/mightypork/utils/files/FileTreeDiff.java
  27. 26
      src/mightypork/utils/files/FileUtil.java
  28. 96
      src/mightypork/utils/files/WorkDir.java
  29. 3
      src/mightypork/utils/files/zip/ZipBuilder.java
  30. 12
      src/mightypork/utils/files/zip/ZipUtils.java
  31. 7
      src/mightypork/utils/ion/Ion.java
  32. 15
      src/mightypork/utils/ion/IonInput.java
  33. 6
      src/mightypork/utils/ion/IonMapWrapper.java
  34. 15
      src/mightypork/utils/ion/IonOutput.java
  35. 6
      src/mightypork/utils/ion/IonSequenceWrapper.java
  36. 6
      src/mightypork/utils/logging/writers/ArchivingLog.java
  37. 3
      src/mightypork/utils/logging/writers/SimpleLog.java
  38. 3
      src/mightypork/utils/math/Calc.java
  39. 6
      src/mightypork/utils/math/Polar.java
  40. 9
      src/mightypork/utils/math/Range.java
  41. 9
      src/mightypork/utils/math/algo/Coord.java
  42. 3
      src/mightypork/utils/math/algo/Move.java
  43. 3
      src/mightypork/utils/math/algo/pathfinding/PathFinder.java
  44. 3
      src/mightypork/utils/math/algo/pathfinding/PathFinderProxy.java
  45. 12
      src/mightypork/utils/math/animation/Animator.java
  46. 12
      src/mightypork/utils/math/animation/AnimatorBounce.java
  47. 12
      src/mightypork/utils/math/animation/AnimatorRewind.java
  48. 6
      src/mightypork/utils/math/animation/Easing.java
  49. 18
      src/mightypork/utils/math/animation/NumAnimated.java
  50. 9
      src/mightypork/utils/math/animation/NumAnimatedDeg.java
  51. 9
      src/mightypork/utils/math/animation/NumAnimatedRad.java
  52. 6
      src/mightypork/utils/math/animation/VectAnimated.java
  53. 2
      src/mightypork/utils/math/color/Color.java
  54. 3
      src/mightypork/utils/math/color/ColorAlphaAdjuster.java
  55. 3
      src/mightypork/utils/math/color/ColorHsb.java
  56. 3
      src/mightypork/utils/math/color/ColorRgb.java
  57. 5
      src/mightypork/utils/math/color/Grad.java
  58. 5
      src/mightypork/utils/math/color/GradH.java
  59. 5
      src/mightypork/utils/math/color/GradV.java
  60. 6
      src/mightypork/utils/math/constraints/num/NumConst.java
  61. 3
      src/mightypork/utils/math/constraints/num/caching/AbstractNumCache.java
  62. 3
      src/mightypork/utils/math/constraints/num/caching/NumCache.java
  63. 3
      src/mightypork/utils/math/constraints/num/caching/NumDigest.java
  64. 6
      src/mightypork/utils/math/constraints/num/proxy/NumProxy.java
  65. 6
      src/mightypork/utils/math/constraints/num/var/NumVar.java
  66. 9
      src/mightypork/utils/math/constraints/rect/RectConst.java
  67. 3
      src/mightypork/utils/math/constraints/rect/builders/TiledRect.java
  68. 3
      src/mightypork/utils/math/constraints/rect/caching/AbstractRectCache.java
  69. 3
      src/mightypork/utils/math/constraints/rect/caching/RectCache.java
  70. 6
      src/mightypork/utils/math/constraints/rect/caching/RectDigest.java
  71. 6
      src/mightypork/utils/math/constraints/rect/proxy/RectProxy.java
  72. 3
      src/mightypork/utils/math/constraints/rect/proxy/RectVectAdapter.java
  73. 3
      src/mightypork/utils/math/constraints/rect/var/RectVar.java
  74. 6
      src/mightypork/utils/math/constraints/vect/VectConst.java
  75. 3
      src/mightypork/utils/math/constraints/vect/caching/AbstractVectCache.java
  76. 3
      src/mightypork/utils/math/constraints/vect/caching/VectCache.java
  77. 3
      src/mightypork/utils/math/constraints/vect/caching/VectDigest.java
  78. 6
      src/mightypork/utils/math/constraints/vect/proxy/VectNumAdapter.java
  79. 6
      src/mightypork/utils/math/constraints/vect/proxy/VectProxy.java
  80. 3
      src/mightypork/utils/math/constraints/vect/var/VectVar.java
  81. 6
      src/mightypork/utils/math/noise/NoiseGen.java
  82. 11
      src/mightypork/utils/math/noise/PerlinNoiseGenerator.java
  83. 35
      src/mightypork/utils/math/timing/Profiler.java
  84. 3
      src/mightypork/utils/math/timing/TaskRepeater.java
  85. 3
      src/mightypork/utils/math/timing/TimerDelta.java
  86. 3
      src/mightypork/utils/math/timing/TimerFps.java
  87. 23
      src/mightypork/utils/string/StringWrapper.java
  88. 3
      src/mightypork/utils/string/validation/CharFilterRegex.java
  89. 3
      src/mightypork/utils/string/validation/CharFilterWhitelist.java
  90. 3
      src/mightypork/utils/struct/Mutable.java
  91. 3
      src/mightypork/utils/struct/Pair.java
  92. 3
      src/mightypork/utils/struct/Triad.java

@ -1,7 +1,12 @@
package mightypork.utils;
import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -85,6 +90,7 @@ public class MapSort {
Collections.sort(entries, new Comparator<Map.Entry<K, V>>() {
@SuppressWarnings("unchecked")
@Override
public int compare(Entry<K, V> o1, Entry<K, V> o2)
{

@ -69,6 +69,16 @@ public class Reflect {
}
/**
* Get value of a public static final field. If the modifiers don't match,
* an exception is thrown.
*
* @param objClass the class
* @param fieldName field to retrieve
* @return the field value
* @throws ReflectiveOperationException if the field is not constant, or if
* the value could not be retrieved.
*/
public static Object getConstantFieldValue(Class<?> objClass, String fieldName) throws ReflectiveOperationException
{
final Field fld = objClass.getDeclaredField(fieldName);
@ -76,7 +86,7 @@ public class Reflect {
final int modif = fld.getModifiers();
if (!Modifier.isFinal(modif) || !Modifier.isStatic(modif)) {
throw new RuntimeException("The " + fieldName + " field of " + Support.str(objClass) + " must be static and final!");
throw new ReflectiveOperationException("The " + fieldName + " field of " + Support.str(objClass) + " must be static and final!");
}
fld.setAccessible(true);

@ -167,7 +167,8 @@ public final class Support {
/**
* @param enumeration the iterated enumeration
*/
public IterableEnumerationWrapper(Enumeration<? extends T> enumeration) {
public IterableEnumerationWrapper(Enumeration<? extends T> enumeration)
{
this.enumeration = enumeration;
}
@ -206,8 +207,8 @@ public final class Support {
* Convert a class to string, preserving name and outer class, but excluding
* path.
*
* @param cls
* @return
* @param cls the class
* @return class name
*/
public static String str(Class<?> cls)
{

@ -1,7 +1,12 @@
package mightypork.utils.annotations;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**

@ -29,7 +29,8 @@ public abstract class Property<T> {
* @param defaultValue defualt property value (used as fallback when
* parsing)
*/
public Property(String key, T defaultValue) {
public Property(String key, T defaultValue)
{
this(key, defaultValue, null);
}
@ -38,12 +39,13 @@ public abstract class Property<T> {
* Create a property with a comment
*
* @param key key in the config file
* @param defaultValue defualt property value (used as fallback when
* parsing)
* @param defaultValue default property value, used as fallback when
* parsing. Initially the value is assigned to defaultValue.
* @param comment optional property comment included above the property in
* the config file. Can be null.
*/
public Property(String key, T defaultValue, String comment) {
public Property(String key, T defaultValue, String comment)
{
this.comment = comment;
this.key = key;
this.value = defaultValue;

@ -25,7 +25,7 @@ public class PropertyManager {
private final TreeMap<String, Property<?>> entries = new TreeMap<>();
private final TreeMap<String, String> renameTable = new TreeMap<>();
private PropertyStore props;
private final PropertyStore props;
/**
@ -35,7 +35,8 @@ public class PropertyManager {
* @param file property file
* @param comment header comment.
*/
public PropertyManager(File file, String comment) {
public PropertyManager(File file, String comment)
{
this(new PropertyFile(file, comment));
}
@ -46,7 +47,8 @@ public class PropertyManager {
* @param props a property store implementation backing this property
* manager
*/
public PropertyManager(PropertyStore props) {
public PropertyManager(PropertyStore props)
{
this.props = props;
}

@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
*/
public class BooleanProperty extends Property<Boolean> {
public BooleanProperty(String key, Boolean defaultValue) {
public BooleanProperty(String key, Boolean defaultValue)
{
super(key, defaultValue);
}
public BooleanProperty(String key, Boolean defaultValue, String comment) {
public BooleanProperty(String key, Boolean defaultValue, String comment)
{
super(key, defaultValue, comment);
}

@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
*/
public class DoubleProperty extends Property<Double> {
public DoubleProperty(String key, Double defaultValue) {
public DoubleProperty(String key, Double defaultValue)
{
super(key, defaultValue);
}
public DoubleProperty(String key, Double defaultValue, String comment) {
public DoubleProperty(String key, Double defaultValue, String comment)
{
super(key, defaultValue, comment);
}

@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
*/
public class IntegerProperty extends Property<Integer> {
public IntegerProperty(String key, Integer defaultValue) {
public IntegerProperty(String key, Integer defaultValue)
{
super(key, defaultValue);
}
public IntegerProperty(String key, Integer defaultValue, String comment) {
public IntegerProperty(String key, Integer defaultValue, String comment)
{
super(key, defaultValue, comment);
}

@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
*/
public class StringProperty extends Property<String> {
public StringProperty(String key, String defaultValue) {
public StringProperty(String key, String defaultValue)
{
super(key, defaultValue);
}
public StringProperty(String key, String defaultValue, String comment) {
public StringProperty(String key, String defaultValue, String comment)
{
super(key, defaultValue, comment);
}

@ -19,18 +19,20 @@ import mightypork.utils.config.propmgr.PropertyStore;
public class PropertyFile implements PropertyStore {
private String comment;
private File file;
private SortedProperties props;
private final File file;
private final SortedProperties props;
public PropertyFile(File file) {
public PropertyFile(File file)
{
this.file = file;
this.comment = null;
this.props = new SortedProperties();
}
public PropertyFile(File file, String comment) {
public PropertyFile(File file, String comment)
{
this.file = file;
this.comment = comment;
this.props = new SortedProperties();
@ -51,7 +53,7 @@ public class PropertyFile implements PropertyStore {
try(FileInputStream in = new FileInputStream(file)) {
props.load(in);
} catch (IOException e) {
} catch (final IOException e) {
// ignore
}
}

@ -1,7 +1,13 @@
package mightypork.utils.config.propmgr.store;
import java.io.*;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;

@ -36,7 +36,8 @@ final public class EventBus implements Destroyable {
private final BusEvent<?> evt;
public DelayQueueEntry(double seconds, BusEvent<?> event) {
public DelayQueueEntry(double seconds, BusEvent<?> event)
{
super();
this.due = System.currentTimeMillis() + (long) (seconds * 1000);
this.evt = event;
@ -72,7 +73,8 @@ final public class EventBus implements Destroyable {
public volatile boolean stopped = false;
public QueuePollingThread() {
public QueuePollingThread()
{
super("Queue Polling Thread");
}
@ -133,7 +135,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();

@ -31,7 +31,8 @@ class EventChannel<EVENT extends BusEvent<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.");

@ -12,7 +12,8 @@ import java.util.ArrayList;
*/
public class ClientList extends ArrayList<Object> {
public ClientList(Object... clients) {
public ClientList(Object... clients)
{
for (final Object c : clients) {
super.add(c);
}

@ -21,7 +21,8 @@ public class DelegatingList extends ClientList implements DelegatingClient, Enab
*
* @param clients initial list members (clients)
*/
public DelegatingList(Object... clients) {
public DelegatingList(Object... clients)
{
super(clients);
}
@ -29,7 +30,8 @@ public class DelegatingList extends ClientList implements DelegatingClient, Enab
/**
* Empty delegating list.
*/
public DelegatingList() {
public DelegatingList()
{
}

@ -24,7 +24,8 @@ public class UpdateEvent extends BusEvent<Updateable> {
/**
* @param deltaTime time since last update (sec)
*/
public UpdateEvent(double deltaTime) {
public UpdateEvent(double deltaTime)
{
this.deltaTime = deltaTime;
}

@ -1,7 +1,12 @@
package mightypork.utils.eventbus.events.flags;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**

@ -1,7 +1,12 @@
package mightypork.utils.eventbus.events.flags;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**

@ -1,7 +1,12 @@
package mightypork.utils.eventbus.events.flags;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**

@ -1,7 +1,12 @@
package mightypork.utils.eventbus.events.flags;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**

@ -11,22 +11,26 @@ import java.io.IOException;
*/
public class CorruptDataException extends IOException {
public CorruptDataException() {
public CorruptDataException()
{
super();
}
public CorruptDataException(String message, Throwable cause) {
public CorruptDataException(String message, Throwable cause)
{
super(message, cause);
}
public CorruptDataException(String message) {
public CorruptDataException(String message)
{
super(message);
}
public CorruptDataException(Throwable cause) {
public CorruptDataException(Throwable cause)
{
super(cause);
}

@ -9,21 +9,25 @@ package mightypork.utils.exceptions;
*/
public class IllegalValueException extends RuntimeException {
public IllegalValueException() {
public IllegalValueException()
{
}
public IllegalValueException(String message) {
public IllegalValueException(String message)
{
super(message);
}
public IllegalValueException(Throwable cause) {
public IllegalValueException(Throwable cause)
{
super(cause);
}
public IllegalValueException(String message, Throwable cause) {
public IllegalValueException(String message, Throwable cause)
{
super(message, cause);
}

@ -8,22 +8,26 @@ package mightypork.utils.exceptions;
*/
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);
}

@ -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;
}

@ -72,9 +72,11 @@ public class FileTreeDiff {
ck1.reset();
ck2.reset();
try (FileInputStream in1 = new FileInputStream(pair.a); FileInputStream in2 = new FileInputStream(pair.b)) {
try(FileInputStream in1 = new FileInputStream(pair.a);
FileInputStream in2 = new FileInputStream(pair.b)) {
try (CheckedInputStream cin1 = new CheckedInputStream(in1, ck1); CheckedInputStream cin2 = new CheckedInputStream(in2, ck2)) {
try(CheckedInputStream cin1 = new CheckedInputStream(in1, ck1);
CheckedInputStream cin2 = new CheckedInputStream(in2, ck2)) {
while (true) {
final int read1 = cin1.read(BUFFER);
@ -128,7 +130,8 @@ public class FileTreeDiff {
private class NotEqualException extends Exception {
public NotEqualException(String msg) {
public NotEqualException(String msg)
{
super(msg);
}
@ -140,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;
}

@ -1,7 +1,19 @@
package mightypork.utils.files;
import java.io.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
@ -12,6 +24,7 @@ import mightypork.utils.string.validation.StringFilter;
public class FileUtil {
/**
* Copy directory recursively.
*
@ -95,7 +108,8 @@ public class FileUtil {
public static void copyFile(File source, File target) throws IOException
{
try (InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(target)) {
try(InputStream in = new FileInputStream(source);
OutputStream out = new FileOutputStream(target)) {
copyStream(in, out);
}
@ -327,9 +341,8 @@ public class FileUtil {
if (in != null) return in;
try {
return new FileInputStream(new File(".", path));
return new FileInputStream(WorkDir.getFile(path));
} catch (final FileNotFoundException e) {
// error
Log.w("Could not open resource stream: " + path);
return null;
}
@ -339,7 +352,7 @@ public class FileUtil {
public static String getResourceAsString(String path)
{
return streamToString(FileUtil.class.getResourceAsStream(path));
return streamToString(getResource(path));
}
@ -400,7 +413,8 @@ public class FileUtil {
*/
public static void resourceToFile(String resname, File file) throws IOException
{
try (InputStream in = FileUtil.getResource(resname); OutputStream out = new FileOutputStream(file)) {
try(InputStream in = FileUtil.getResource(resname);
OutputStream out = new FileOutputStream(file)) {
FileUtil.copyStream(in, out);
}

@ -0,0 +1,96 @@
package mightypork.utils.files;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import mightypork.utils.logging.Log;
/**
* Working directory helper.
*
* @author Ondřej Hruška (MightyPork)
*/
public class WorkDir {
private static File baseDir = new File(".");
private static Map<String, String> namedPaths = new HashMap<>();
/**
* Initialize the workdir for the given root path
*
* @param workdir workdir root path
*/
public static void setBaseDir(File workdir)
{
WorkDir.baseDir = workdir;
}
/**
* Add a path alias (dir or file), relative to the workdir.
*
* @param alias path alias
* @param path path relative to workdir
*/
public static void addPath(String alias, String path)
{
namedPaths.put(alias, path);
}
/**
* Get workdir folder, create if not exists.
*
* @param path dir path relative to workdir
* @return dir file
*/
public static File getDir(String path)
{
if (namedPaths.containsKey(path)) path = namedPaths.get(path);
final File f = new File(baseDir, path);
if (!f.exists()) {
if (!f.mkdirs()) {
Log.w("Could not create a directory: " + f + " (path: " + path + ")");
}
}
return f;
}
/**
* Get workdir file, create parent if not exists.
*
* @param path dir path relative to workdir
* @return dir file
*/
public static File getFile(String path)
{
if (namedPaths.containsKey(path)) path = namedPaths.get(path);
final File f = new File(baseDir, path);
// create the parent dir
if (!f.getParent().equals(baseDir)) {
f.getParentFile().mkdirs();
}
return f;
}
/**
* @return the workdir File
*/
public static File getBaseDir()
{
return baseDir;
}
}

@ -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.");

@ -1,7 +1,12 @@
package mightypork.utils.files.zip;
import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@ -134,7 +139,10 @@ public class ZipUtils {
{
if (!destFile.getParentFile().mkdirs()) throw new IOException("Could not create output directory.");
try (InputStream in = zip.getInputStream(entry); BufferedInputStream is = new BufferedInputStream(in); FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE)) {
try(InputStream in = zip.getInputStream(entry);
BufferedInputStream is = new BufferedInputStream(in);
FileOutputStream fos = new FileOutputStream(destFile);
BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE)) {
FileUtil.copyStream(is, dest);
}

@ -1,7 +1,12 @@
package mightypork.utils.ion;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@ -1,7 +1,14 @@
package mightypork.utils.ion;
import java.io.*;
import java.io.Closeable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -22,12 +29,14 @@ public class IonInput implements Closeable {
@SuppressWarnings("resource")
public IonInput(File inFile) throws FileNotFoundException {
public IonInput(File inFile) throws FileNotFoundException
{
this(new FileInputStream(inFile));
}
public IonInput(InputStream in) {
public IonInput(InputStream in)
{
this.stream = in;
this.in = new DataInputStream(in);
}

@ -12,12 +12,14 @@ class IonMapWrapper implements IonBinary {
private final Map map;
public IonMapWrapper() {
public IonMapWrapper()
{
map = new LinkedHashMap<>();
}
public IonMapWrapper(Map saved) {
public IonMapWrapper(Map saved)
{
map = saved;
}

@ -1,7 +1,14 @@
package mightypork.utils.ion;
import java.io.*;
import java.io.Closeable;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@ -19,12 +26,14 @@ public class IonOutput implements Closeable {
@SuppressWarnings("resource")
public IonOutput(File outFile) throws FileNotFoundException {
public IonOutput(File outFile) throws FileNotFoundException
{
this(new FileOutputStream(outFile));
}
public IonOutput(OutputStream out) {
public IonOutput(OutputStream out)
{
this.stream = out;
this.out = new DataOutputStream(out);
}

@ -12,12 +12,14 @@ class IonSequenceWrapper implements IonBinary {
private Collection collection = new ArrayList();
public IonSequenceWrapper() {
public IonSequenceWrapper()
{
collection = new ArrayList();
}
public IonSequenceWrapper(Collection saved) {
public IonSequenceWrapper(Collection saved)
{
collection = saved;
}

@ -32,7 +32,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;
}
@ -44,7 +45,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();

@ -18,7 +18,8 @@ import mightypork.utils.math.constraints.vect.Vect;
*/
public final class Calc {
private Calc() {
private Calc()
{
// not instantiable
}

@ -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;
}

@ -23,7 +23,8 @@ public class Range {
/**
* Implicit range constructor 0-1
*/
public Range() {
public Range()
{
}
@ -33,7 +34,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();
@ -45,7 +47,8 @@ public class Range {
*
* @param minmax min = max number
*/
public Range(double minmax) {
public Range(double minmax)
{
this.min = minmax;
this.max = minmax;
}

@ -39,19 +39,22 @@ public class Coord {
}
public Coord() {
public Coord()
{
// for ion
}
public Coord(int x, int y) {
public Coord(int x, int y)
{
super();
this.x = x;
this.y = y;
}
public Coord(Coord other) {
public Coord(Coord other)
{
this.x = other.x;
this.y = other.y;
}

@ -34,7 +34,8 @@ public class Move {
private final byte y;
public Move(int x, int y) {
public Move(int x, int y)
{
this.x = (byte) (x < 0 ? -1 : x > 0 ? 1 : 0);
this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0);
}

@ -151,7 +151,8 @@ public abstract class PathFinder {
Node parent;
public Node(Coord pos) {
public Node(Coord pos)
{
this.pos = pos;
}

@ -18,7 +18,8 @@ public class PathFinderProxy extends PathFinder {
private final PathFinder source;
public PathFinderProxy(PathFinder other) {
public PathFinderProxy(PathFinder other)
{
this.source = other;
}

@ -17,22 +17,26 @@ public abstract class Animator implements NumBound, Updateable, Pauseable {
private final double lowValue;
public Animator(double period) {
public Animator(double period)
{
this(0, 1, period, Easing.LINEAR);
}
public Animator(double start, double end, double period) {
public Animator(double start, double end, double period)
{
this(start, end, period, Easing.LINEAR);
}
public Animator(double period, Easing easing) {
public Animator(double period, Easing easing)
{
this(0, 1, period, easing);
}
public Animator(double start, double end, double period, Easing easing) {
public Animator(double start, double end, double period, Easing easing)
{
numAnim = new NumAnimated(0, easing);
numAnim.setDefaultDuration(period);

@ -11,22 +11,26 @@ public class AnimatorBounce extends Animator {
private boolean wasUp = false;
public AnimatorBounce(double start, double end, double period, Easing easing) {
public AnimatorBounce(double start, double end, double period, Easing easing)
{
super(start, end, period, easing);
}
public AnimatorBounce(double start, double end, double period) {
public AnimatorBounce(double start, double end, double period)
{
super(start, end, period);
}
public AnimatorBounce(double period, Easing easing) {
public AnimatorBounce(double period, Easing easing)
{
super(period, easing);
}
public AnimatorBounce(double period) {
public AnimatorBounce(double period)
{
super(period);
}

@ -9,22 +9,26 @@ package mightypork.utils.math.animation;
*/
public class AnimatorRewind extends Animator {
public AnimatorRewind(double start, double end, double period, Easing easing) {
public AnimatorRewind(double start, double end, double period, Easing easing)
{
super(start, end, period, easing);
}
public AnimatorRewind(double start, double end, double period) {
public AnimatorRewind(double start, double end, double period)
{
super(start, end, period);
}
public AnimatorRewind(double period, Easing easing) {
public AnimatorRewind(double period, Easing easing)
{
super(period, easing);
}
public AnimatorRewind(double period) {
public AnimatorRewind(double period)
{
super(period);
}

@ -67,7 +67,8 @@ public abstract class Easing {
/**
* @param in Easing to reverse
*/
public Reverse(Easing in) {
public Reverse(Easing in)
{
this.ea = in;
}
@ -96,7 +97,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;
}

@ -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);
}
@ -82,7 +85,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
* @param easing easing function
* @param defaultDuration default fade duration
*/
public NumAnimated(double value, Easing easing, double defaultDuration) {
public NumAnimated(double value, Easing easing, double defaultDuration)
{
this(value);
setEasing(easing);
setDefaultDuration(defaultDuration);
@ -97,7 +101,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
* @param easingOut easing function (fade out)
* @param defaultDuration default fade duration
*/
public NumAnimated(double value, Easing easingIn, Easing easingOut, double defaultDuration) {
public NumAnimated(double value, Easing easingIn, Easing easingOut, double defaultDuration)
{
this(value);
setEasing(easingIn, easingOut);
setDefaultDuration(defaultDuration);
@ -109,7 +114,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
*
* @param other other animator
*/
public NumAnimated(NumAnimated other) {
public NumAnimated(NumAnimated other)
{
setTo(other);
}

@ -12,17 +12,20 @@ import mightypork.utils.math.angles.Deg;
*/
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);
}

@ -12,17 +12,20 @@ import mightypork.utils.math.angles.Rad;
*/
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);
}

@ -27,7 +27,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;
@ -40,7 +41,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);

@ -270,7 +270,7 @@ public abstract class Color {
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof Color)) return false;
Color other = (Color) obj;
final Color other = (Color) obj;
if (Double.doubleToLongBits(b()) != Double.doubleToLongBits(other.b())) return false;
if (Double.doubleToLongBits(g()) != Double.doubleToLongBits(other.g())) return false;
if (Double.doubleToLongBits(r()) != Double.doubleToLongBits(other.r())) return false;

@ -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;

@ -1,8 +1,6 @@
package mightypork.utils.math.color;
/**
* Linear gradient (each corner can have different color)
*
@ -21,7 +19,8 @@ public class Grad {
* @param rightBottom right bottom color
* @param leftBottom left bottom color
*/
public Grad(Color leftTop, Color rightTop, Color rightBottom, Color leftBottom) {
public Grad(Color leftTop, Color rightTop, Color rightBottom, Color leftBottom)
{
this.leftTop = leftTop;
this.rightTop = rightTop;
this.rightBottom = rightBottom;

@ -1,8 +1,6 @@
package mightypork.utils.math.color;
/**
* Linear horizontal gradient
*
@ -10,7 +8,8 @@ package mightypork.utils.math.color;
*/
public class GradH extends Grad {
public GradH(Color left, Color right) {
public GradH(Color left, Color right)
{
super(left, right, right, left);
}
}

@ -1,8 +1,6 @@
package mightypork.utils.math.color;
/**
* Linear vertical gradient
*
@ -10,7 +8,8 @@ package mightypork.utils.math.color;
*/
public class GradV extends Grad {
public GradV(Color top, Color bottom) {
public GradV(Color top, Color bottom)
{
super(top, top, bottom, bottom);
}
}

@ -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 CachedConst
private boolean cachingEnabled = true;
public AbstractNumCache() {
public AbstractNumCache()
{
enableDigestCaching(true); // it changes only on poll
}

@ -14,7 +14,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();
}

@ -16,11 +16,13 @@ public class NumProxy extends NumAdapter implements PluggableNumBound {
private NumBound backing = null;
public NumProxy() {
public NumProxy()
{
}
public NumProxy(NumBound bound) {
public NumProxy(NumBound bound)
{
backing = bound;
}

@ -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;
}

@ -50,7 +50,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);
}
@ -62,7 +63,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();
}
@ -73,7 +75,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();
}

@ -23,7 +23,8 @@ public class TiledRect extends RectProxy {
private Rect aTile;
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 CachedCon
private boolean cachingEnabled = true;
public AbstractRectCache() {
public AbstractRectCache()
{
enableDigestCaching(true); // it changes only on poll
}

@ -14,7 +14,8 @@ public class RectCache extends AbstractRectCache {
private final Rect source;
public RectCache(Rect source) {
public RectCache(Rect source)
{
this.source = source;
}

@ -17,7 +17,8 @@ public class RectDigest {
public final double bottom;
public RectDigest(Rect rect) {
public RectDigest(Rect rect)
{
this.x = rect.origin().x();
this.y = rect.origin().y();
@ -34,6 +35,7 @@ public class RectDigest {
@Override
public String toString()
{
return String.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom);
return String
.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom);
}
}

@ -16,11 +16,13 @@ public class RectProxy extends RectAdapter implements PluggableRectBound {
private RectBound backing = null;
public RectProxy() {
public RectProxy()
{
}
public RectProxy(RectBound proxied) {
public RectProxy(RectBound proxied)
{
backing = proxied;
}

@ -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;
}

@ -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);
}

@ -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;

@ -25,7 +25,8 @@ public abstract class AbstractVectCache extends VectAdapter implements CachedCon
private boolean cachingEnabled = true;
public AbstractVectCache() {
public AbstractVectCache()
{
enableDigestCaching(true); // it changes only on poll
}

@ -14,7 +14,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();

@ -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;

@ -16,11 +16,13 @@ public class VectProxy extends VectAdapter implements PluggableVectBound {
private VectBound backing = null;
public VectProxy() {
public VectProxy()
{
}
public VectProxy(VectBound proxied) {
public VectProxy(VectBound proxied)
{
backing = proxied;
}

@ -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;

@ -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;
@ -408,7 +410,10 @@ public class PerlinNoiseGenerator {
*/
public double tileableNoise3(double x, double y, double z, double w, double h, double d)
{
return (noise3(x, y, z) * (w - x) * (h - y) * (d - z) + noise3(x - w, y, z) * x * (h - y) * (d - z) + noise3(x, y - h, z) * (w - x) * y * (d - z) + noise3(x - w, y - h, z) * x * y * (d - z) + noise3(x, y, z - d) * (w - x) * (h - y) * z + noise3(x - w, y, z - d) * x * (h - y) * z + noise3(x, y - h, z - d) * (w - x) * y * z + noise3(x - w, y - h, z - d) * x * y * z) / (w * h * d);
return (noise3(x, y, z) * (w - x) * (h - y) * (d - z) + noise3(x - w, y, z) * x * (h - y) * (d - z) + noise3(x, y - h, z) * (w - x) * y * (d - z)
+ noise3(x - w, y - h, z) * x * y * (d - z) + noise3(x, y, z - d) * (w - x) * (h - y) * z + noise3(x - w, y, z - d) * x * (h - y) * z
+ noise3(x, y - h, z - d) * (w - x) * y * z + noise3(x - w, y - h, z - d) * x * y * z)
/ (w * h * d);
}

@ -4,26 +4,57 @@ package mightypork.utils.math.timing;
import mightypork.utils.Support;
/**
* Time metering utils for profiling.<br>
* The profiler work with long (starting ms time), so it has very little
* overhead and you can easily have multiple "profilers" running at the same
* time.
*
* @author Ondřej Hruška (MightyPork)
*/
public class Profiler {
/**
* Get current time, to be later used in the end*() methods
*
* @return current time (ms)
*/
public static long begin()
{
return System.currentTimeMillis();
}
/**
* Get seconds since begin.
*
* @param begun profiling start time (ms), obtained using begin()
* @return seconds elapsed
*/
public static double end(long begun)
{
return endLong(begun) / 1000D;
return endMs(begun) / 1000D;
}
public static long endLong(long begun)
/**
* Get milliseconds since begin.
*
* @param begun profiling start time (ms), obtained using begin()
* @return milliseconds elapsed
*/
public static long endMs(long begun)
{
return System.currentTimeMillis() - begun;
}
/**
* Elapsed time in human readable format, in seconds.
*
* @param begun profiling start time (ms), obtained using begin()
* @return something like "0.121 s"
*/
public static String endStr(long begun)
{
return Support.str(end(begun)) + " s";

@ -11,7 +11,8 @@ public abstract class TaskRepeater extends AnimatorRewind implements Runnable, E
private boolean enabled = true;
public TaskRepeater(double period) {
public TaskRepeater(double period)
{
super(period);
}

@ -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,16 +2,33 @@ package mightypork.utils.string;
/**
* String provider with constant string
* String provider that holds a string.
*
* @author Ondřej Hruška (MightyPork)
*/
public class StringWrapper implements StringProvider {
private final String value;
private String value;
public StringWrapper(String value) {
/**
* Create a string wrapper
*
* @param value original value
*/
public StringWrapper(String value)
{
this.value = value;
}
/**
* Set the string
*
* @param value string to set
*/
public void setString(String value)
{
this.value = value;
}

@ -6,7 +6,8 @@ public class CharFilterRegex implements CharFilter {
private final String formula;
public CharFilterRegex(String regex) {
public CharFilterRegex(String regex)
{
this.formula = regex;
}

@ -6,7 +6,8 @@ public class CharFilterWhitelist implements CharFilter {
private final String whitelist;
public CharFilterWhitelist(String allowed) {
public CharFilterWhitelist(String allowed)
{
this.whitelist = allowed;
}

@ -18,7 +18,8 @@ public class Mutable<T> {
*
* @param o value
*/
public Mutable(T o) {
public Mutable(T o)
{
this.o = o;
}

@ -28,7 +28,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;
}

@ -25,7 +25,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;
}

Loading…
Cancel
Save