Ondřej Hruška 11 years ago
commit d8530f2f1a
  1. 24
      .classpath
  2. 3
      src/mightypork/rogue/App.java
  3. 1
      src/mightypork/rogue/AppAccess.java
  4. 1
      src/mightypork/rogue/AppAdapter.java
  5. 1
      src/mightypork/rogue/Config.java
  6. 1
      src/mightypork/rogue/Const.java
  7. 1
      src/mightypork/rogue/CrashHandler.java
  8. 1
      src/mightypork/rogue/Paths.java
  9. 4
      src/mightypork/rogue/bus/DelegatingBusClient.java
  10. 4
      src/mightypork/rogue/bus/SimpleBusClient.java
  11. 1
      src/mightypork/rogue/bus/UpdateReceiver.java
  12. 5
      src/mightypork/rogue/bus/events/KeyboardEvent.java
  13. 17
      src/mightypork/rogue/bus/events/MouseButtonEvent.java
  14. 5
      src/mightypork/rogue/bus/events/MouseMotionEvent.java
  15. 2
      src/mightypork/rogue/bus/events/ScreenChangeEvent.java
  16. 2
      src/mightypork/rogue/bus/events/UpdateEvent.java
  17. 4
      src/mightypork/rogue/display/DisplaySystem.java
  18. 10
      src/mightypork/rogue/display/Screen.java
  19. 1
      src/mightypork/rogue/display/ScreenTestAnimations.java
  20. 1
      src/mightypork/rogue/display/constraints/Bounding.java
  21. 1
      src/mightypork/rogue/display/constraints/Constraint.java
  22. 1
      src/mightypork/rogue/display/rendering/Renderable.java
  23. 1
      src/mightypork/rogue/display/rendering/ScreenLayer.java
  24. 1
      src/mightypork/rogue/fonts/Align.java
  25. 239
      src/mightypork/rogue/fonts/FontManager.java
  26. 1
      src/mightypork/rogue/fonts/Fonts.java
  27. 40
      src/mightypork/rogue/fonts/LoadedFont.java
  28. 1
      src/mightypork/rogue/input/InputSystem.java
  29. 10
      src/mightypork/rogue/input/KeyBinder.java
  30. 1
      src/mightypork/rogue/input/KeyBinding.java
  31. 10
      src/mightypork/rogue/input/KeyBindingPool.java
  32. 7
      src/mightypork/rogue/input/KeyStroke.java
  33. 59
      src/mightypork/rogue/sounds/AudioX.java
  34. 1
      src/mightypork/rogue/sounds/BaseAudioPlayer.java
  35. 1
      src/mightypork/rogue/sounds/EffectPlayer.java
  36. 4
      src/mightypork/rogue/sounds/JointVolume.java
  37. 1
      src/mightypork/rogue/sounds/LoopPlayer.java
  38. 1
      src/mightypork/rogue/sounds/NullAudio.java
  39. 76
      src/mightypork/rogue/sounds/SoundSystem.java
  40. 1
      src/mightypork/rogue/tasks/TaskTakeScreenshot.java
  41. 1
      src/mightypork/rogue/testing/TestConstraints.java
  42. 3
      src/mightypork/rogue/testing/TestMsgbus.java
  43. 7
      src/mightypork/rogue/textures/TextureManager.java
  44. 1
      src/mightypork/rogue/textures/Textures.java
  45. 1
      src/mightypork/rogue/textures/Tx.java
  46. 37
      src/mightypork/rogue/textures/TxQuad.java
  47. 507
      src/mightypork/rogue/util/RenderUtils.java
  48. 1
      src/mightypork/rogue/util/Utils.java
  49. 6
      src/mightypork/utils/files/FileTreeDiff.java
  50. 115
      src/mightypork/utils/files/FileUtils.java
  51. 4
      src/mightypork/utils/files/OsUtils.java
  52. 157
      src/mightypork/utils/files/PropertyManager.java
  53. 20
      src/mightypork/utils/files/SimpleConfig.java
  54. 29
      src/mightypork/utils/files/ZipBuilder.java
  55. 64
      src/mightypork/utils/files/ZipUtils.java
  56. 14
      src/mightypork/utils/files/ion/AbstractIonList.java
  57. 25
      src/mightypork/utils/files/ion/AbstractIonMap.java
  58. 46
      src/mightypork/utils/files/ion/Ion.java
  59. 1
      src/mightypork/utils/files/ion/IonException.java
  60. 1
      src/mightypork/utils/files/ion/IonList.java
  61. 1
      src/mightypork/utils/files/ion/IonMap.java
  62. 1
      src/mightypork/utils/files/ion/IonMarks.java
  63. 7
      src/mightypork/utils/files/ion/Ionizable.java
  64. 1
      src/mightypork/utils/files/ion/IonizableOptional.java
  65. 1
      src/mightypork/utils/files/ion/StreamUtils.java
  66. 47
      src/mightypork/utils/logging/Log.java
  67. 41
      src/mightypork/utils/logging/LogInstance.java
  68. 1
      src/mightypork/utils/logging/LogMonitor.java
  69. 1
      src/mightypork/utils/logging/LogToSysoutMonitor.java
  70. 293
      src/mightypork/utils/math/Calc.java
  71. 34
      src/mightypork/utils/math/Polar.java
  72. 28
      src/mightypork/utils/math/Range.java
  73. 19
      src/mightypork/utils/math/color/HSV.java
  74. 85
      src/mightypork/utils/math/color/RGB.java
  75. 253
      src/mightypork/utils/math/coord/Coord.java
  76. 7
      src/mightypork/utils/math/coord/CoordAnimated.java
  77. 184
      src/mightypork/utils/math/coord/Rect.java
  78. 27
      src/mightypork/utils/math/easing/Easing.java
  79. 79
      src/mightypork/utils/objects/Convertor.java
  80. 10
      src/mightypork/utils/objects/Mutable.java
  81. 14
      src/mightypork/utils/objects/ObjectUtils.java
  82. 13
      src/mightypork/utils/objects/Pair.java
  83. 22
      src/mightypork/utils/objects/Triad.java
  84. 16
      src/mightypork/utils/objects/VarargsParser.java
  85. 1
      src/mightypork/utils/patterns/Destroyable.java
  86. 7
      src/mightypork/utils/patterns/subscription/Handleable.java
  87. 22
      src/mightypork/utils/patterns/subscription/MessageBus.java
  88. 28
      src/mightypork/utils/patterns/subscription/MessageChannel.java
  89. 1
      src/mightypork/utils/patterns/subscription/clients/DelegatingClient.java
  90. 1
      src/mightypork/utils/patterns/subscription/clients/ToggleableClient.java
  91. 28
      src/mightypork/utils/string/StringUtils.java
  92. 1
      src/mightypork/utils/string/validation/CharValidator.java
  93. 1
      src/mightypork/utils/string/validation/CharValidatorRegex.java
  94. 1
      src/mightypork/utils/string/validation/CharValidatorWhitelist.java
  95. 4
      src/mightypork/utils/string/validation/FileSuffixFilter.java
  96. 1
      src/mightypork/utils/string/validation/FilenameCharValidator.java
  97. 1
      src/mightypork/utils/string/validation/StringFilter.java
  98. 4
      src/mightypork/utils/time/FpsMeter.java
  99. 1
      src/mightypork/utils/time/Pauseable.java
  100. 1
      src/mightypork/utils/time/TimerDelta.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -2,34 +2,34 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/jinput.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> <classpathentry kind="lib" path="lib/jinput.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/jogg-0.0.7.jar"> <classpathentry kind="lib" path="lib/jogg-0.0.7.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/jorbis-0.0.15.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> <classpathentry kind="lib" path="lib/jorbis-0.0.15.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/lwjgl_util.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> <classpathentry kind="lib" path="lib/lwjgl_util.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> <classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/slick-util.jar" sourcepath="lib/slick-util-src.zip"> <classpathentry kind="lib" path="lib/slick-util.jar" sourcepath="lib">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="PR2-game/lib"/> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import java.io.File; import java.io.File;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.nio.channels.FileLock; import java.nio.channels.FileLock;
@ -288,7 +287,7 @@ public class App implements Destroyable, AppAccess {
// //
// static accessors // static accessors
// //
/** /**

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import mightypork.rogue.display.DisplaySystem; import mightypork.rogue.display.DisplaySystem;
import mightypork.rogue.input.InputSystem; import mightypork.rogue.input.InputSystem;
import mightypork.rogue.sounds.SoundSystem; import mightypork.rogue.sounds.SoundSystem;

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import mightypork.rogue.display.DisplaySystem; import mightypork.rogue.display.DisplaySystem;
import mightypork.rogue.input.InputSystem; import mightypork.rogue.input.InputSystem;
import mightypork.rogue.sounds.SoundSystem; import mightypork.rogue.sounds.SoundSystem;

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import mightypork.utils.files.PropertyManager; import mightypork.utils.files.PropertyManager;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
/** /**
* Application constants * Application constants
* *

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import java.lang.Thread.UncaughtExceptionHandler; import java.lang.Thread.UncaughtExceptionHandler;

@ -1,6 +1,5 @@
package mightypork.rogue; package mightypork.rogue;
import java.io.File; import java.io.File;
import mightypork.utils.files.OsUtils; import mightypork.utils.files.OsUtils;

@ -1,6 +1,5 @@
package mightypork.rogue.bus; package mightypork.rogue.bus;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -61,7 +60,8 @@ public abstract class DelegatingBusClient extends AppAdapter implements Delegati
/** /**
* Remove a child subscriber * Remove a child subscriber
* *
* @param client subscriber to remove * @param client
* subscriber to remove
*/ */
public final void removeChildSubscriber(Object client) public final void removeChildSubscriber(Object client)
{ {

@ -1,6 +1,5 @@
package mightypork.rogue.bus; package mightypork.rogue.bus;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;
import mightypork.rogue.AppAdapter; import mightypork.rogue.AppAdapter;
@ -13,7 +12,8 @@ import mightypork.rogue.AppAdapter;
public class SimpleBusClient extends AppAdapter { public class SimpleBusClient extends AppAdapter {
/** /**
* @param app app access * @param app
* app access
*/ */
public SimpleBusClient(AppAccess app) { public SimpleBusClient(AppAccess app) {
super(app); super(app);

@ -1,6 +1,5 @@
package mightypork.rogue.bus; package mightypork.rogue.bus;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;
import mightypork.rogue.bus.events.UpdateEvent; import mightypork.rogue.bus.events.UpdateEvent;
import mightypork.utils.time.Updateable; import mightypork.utils.time.Updateable;

@ -1,6 +1,5 @@
package mightypork.rogue.bus.events; package mightypork.rogue.bus.events;
import mightypork.utils.patterns.subscription.Handleable; import mightypork.utils.patterns.subscription.Handleable;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
@ -67,12 +66,14 @@ public class KeyboardEvent implements Handleable<KeyboardEvent.Listener> {
keh.receive(this); keh.receive(this);
} }
public interface Listener { public interface Listener {
/** /**
* Handle an event * Handle an event
* *
* @param event event * @param event
* event
*/ */
public void receive(KeyboardEvent event); public void receive(KeyboardEvent event);
} }

@ -1,6 +1,5 @@
package mightypork.rogue.bus.events; package mightypork.rogue.bus.events;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.patterns.subscription.Handleable; import mightypork.utils.patterns.subscription.Handleable;
@ -25,10 +24,14 @@ public class MouseButtonEvent implements Handleable<MouseButtonEvent.Listener> {
/** /**
* Mouse button event * Mouse button event
* *
* @param pos event position * @param pos
* @param button button id * event position
* @param down button pressed * @param button
* @param wheeld wheel change * button id
* @param down
* button pressed
* @param wheeld
* wheel change
*/ */
public MouseButtonEvent(Coord pos, int button, boolean down, int wheeld) { public MouseButtonEvent(Coord pos, int button, boolean down, int wheeld) {
this.button = button; this.button = button;
@ -107,12 +110,14 @@ public class MouseButtonEvent implements Handleable<MouseButtonEvent.Listener> {
handler.receive(this); handler.receive(this);
} }
public interface Listener { public interface Listener {
/** /**
* Handle an event * Handle an event
* *
* @param event event * @param event
* event
*/ */
public void receive(MouseButtonEvent event); public void receive(MouseButtonEvent event);
} }

@ -1,6 +1,5 @@
package mightypork.rogue.bus.events; package mightypork.rogue.bus.events;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.patterns.subscription.Handleable; import mightypork.utils.patterns.subscription.Handleable;
@ -41,12 +40,14 @@ public class MouseMotionEvent implements Handleable<MouseMotionEvent.Listener> {
keh.receive(this); keh.receive(this);
} }
public interface Listener { public interface Listener {
/** /**
* Handle an event * Handle an event
* *
* @param event event * @param event
* event
*/ */
public void receive(MouseMotionEvent event); public void receive(MouseMotionEvent event);
} }

@ -1,6 +1,5 @@
package mightypork.rogue.bus.events; package mightypork.rogue.bus.events;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.patterns.subscription.Handleable; import mightypork.utils.patterns.subscription.Handleable;
@ -43,6 +42,7 @@ public class ScreenChangeEvent implements Handleable<ScreenChangeEvent.Listener>
handler.receive(this); handler.receive(this);
} }
public interface Listener { public interface Listener {
public void receive(ScreenChangeEvent event); public void receive(ScreenChangeEvent event);

@ -1,6 +1,5 @@
package mightypork.rogue.bus.events; package mightypork.rogue.bus.events;
import mightypork.utils.patterns.subscription.Handleable; import mightypork.utils.patterns.subscription.Handleable;
@ -26,6 +25,7 @@ public class UpdateEvent implements Handleable<UpdateEvent.Listener> {
handler.receive(this); handler.receive(this);
} }
public interface Listener { public interface Listener {
public void receive(UpdateEvent event); public void receive(UpdateEvent event);

@ -1,6 +1,5 @@
package mightypork.rogue.display; package mightypork.rogue.display;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -120,7 +119,8 @@ public class DisplaySystem extends DelegatingBusClient implements Bounding {
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
int width = Display.getDisplayMode().getWidth(); int width = Display.getDisplayMode().getWidth();
int height = Display.getDisplayMode().getHeight(); int height = Display.getDisplayMode().getHeight();
int bpp = 4; // Assuming a 32-bit display with a byte each for red, green, blue, and alpha. int bpp = 4; // Assuming a 32-bit display with a byte each for red,
// green, blue, and alpha.
ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

@ -1,6 +1,5 @@
package mightypork.rogue.display; package mightypork.rogue.display;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;
import mightypork.rogue.bus.DelegatingBusClient; import mightypork.rogue.bus.DelegatingBusClient;
@ -52,7 +51,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
/** /**
* Prepare for being shown * Prepare for being shown
* *
* @param shown true to show, false to hide * @param shown
* true to show, false to hide
*/ */
public final void setActive(boolean shown) public final void setActive(boolean shown)
{ {
@ -161,7 +161,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
/** /**
* Update GUI for new screen size * Update GUI for new screen size
* *
* @param size screen size * @param size
* screen size
*/ */
protected void onSizeChanged(Coord size) protected void onSizeChanged(Coord size)
{ {
@ -178,7 +179,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
/** /**
* Update animations and timing * Update animations and timing
* *
* @param delta time elapsed * @param delta
* time elapsed
*/ */
protected abstract void updateScreen(double delta); protected abstract void updateScreen(double delta);

@ -1,6 +1,5 @@
package mightypork.rogue.display; package mightypork.rogue.display;
import java.util.Random; import java.util.Random;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;

@ -1,6 +1,5 @@
package mightypork.rogue.display.constraints; package mightypork.rogue.display.constraints;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,6 +1,5 @@
package mightypork.rogue.display.constraints; package mightypork.rogue.display.constraints;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,6 +1,5 @@
package mightypork.rogue.display.rendering; package mightypork.rogue.display.rendering;
public interface Renderable { public interface Renderable {
public void render(); public void render();

@ -1,6 +1,5 @@
package mightypork.rogue.display.rendering; package mightypork.rogue.display.rendering;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;
import mightypork.rogue.bus.DelegatingBusClient; import mightypork.rogue.bus.DelegatingBusClient;

@ -1,6 +1,5 @@
package mightypork.rogue.fonts; package mightypork.rogue.fonts;
/** /**
* Alignment * Alignment
* *

@ -1,6 +1,5 @@
package mightypork.rogue.fonts; package mightypork.rogue.fonts;
import java.awt.Font; import java.awt.Font;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
@ -21,6 +20,7 @@ public class FontManager {
private static final boolean DEBUG = Config.LOG_FONTS; private static final boolean DEBUG = Config.LOG_FONTS;
/** /**
* Glyph tables. * Glyph tables.
* *
@ -75,13 +75,13 @@ public class FontManager {
//@formatter:on //@formatter:on
} }
/** /**
* Font style * Font style
* *
* @author MightyPork * @author MightyPork
*/ */
public static enum Style public static enum Style {
{
/** Normal */ /** Normal */
NORMAL, NORMAL,
/** Italic */ /** Italic */
@ -112,96 +112,100 @@ public class FontManager {
OUTLINE; OUTLINE;
} }
// /**
// * Preloaded font identifier [name, size, style] // /**
// * // * Preloaded font identifier [name, size, style]
// * @author MightyPork // *
// */ // * @author MightyPork
// public static class FontId { // */
// // public static class FontId {
// /** font size (pt) */ //
// public float size = 24; // /** font size (pt) */
// /** font name, registered with registerFile */ // public float size = 24;
// public String name = ""; // /** font name, registered with registerFile */
// /** font style. The given style must be in a file. */ // public String name = "";
// public Style style; // /** font style. The given style must be in a file. */
// // public Style style;
// /** Set of glyphs in this ID */ //
// public String glyphs = ""; // /** Set of glyphs in this ID */
// // public String glyphs = "";
// /** Index for faster comparision of glyph ids. */ //
// public int glyphset_id = 0; // /** Index for faster comparision of glyph ids. */
// // public int glyphset_id = 0;
// //
// /** //
// * Preloaded font identifier // /**
// * // * Preloaded font identifier
// * @param name font name (registerFile) // *
// * @param size font size (pt) // * @param name font name (registerFile)
// * @param style font style // * @param size font size (pt)
// * @param glyphs glyphs to load // * @param style font style
// */ // * @param glyphs glyphs to load
// public FontId(String name, double size, Style style, String glyphs) { // */
// this.name = name; // public FontId(String name, double size, Style style, String glyphs) {
// this.size = (float) size; // this.name = name;
// this.style = style; // this.size = (float) size;
// // this.style = style;
// if (glyphs.equals(Glyphs.basic)) { //
// glyphset_id = 1; // if (glyphs.equals(Glyphs.basic)) {
// } else if (glyphs.equals(Glyphs.alnum)) { // glyphset_id = 1;
// glyphset_id = 2; // } else if (glyphs.equals(Glyphs.alnum)) {
// } else if (glyphs.equals(Glyphs.basic_text)) { // glyphset_id = 2;
// glyphset_id = 3; // } else if (glyphs.equals(Glyphs.basic_text)) {
// } else if (glyphs.equals(Glyphs.numbers)) { // glyphset_id = 3;
// glyphset_id = 4; // } else if (glyphs.equals(Glyphs.numbers)) {
// } else if (glyphs.equals(Glyphs.alpha)) { // glyphset_id = 4;
// glyphset_id = 5; // } else if (glyphs.equals(Glyphs.alpha)) {
// } else if (glyphs.equals(Glyphs.all)) { // glyphset_id = 5;
// glyphset_id = 6; // } else if (glyphs.equals(Glyphs.all)) {
// } else if (glyphs.equals(Glyphs.alnum_extra)) { // glyphset_id = 6;
// glyphset_id = 7; // } else if (glyphs.equals(Glyphs.alnum_extra)) {
// } else if (glyphs.equals(Glyphs.signs)) { // glyphset_id = 7;
// glyphset_id = 8; // } else if (glyphs.equals(Glyphs.signs)) {
// } else if (glyphs.equals(Glyphs.signs_extra)) { // glyphset_id = 8;
// glyphset_id = 9; // } else if (glyphs.equals(Glyphs.signs_extra)) {
// } else { // glyphset_id = 9;
// this.glyphs = glyphs; // } else {
// } // this.glyphs = glyphs;
// } // }
// // }
// //
// @Override //
// public boolean equals(Object obj) // @Override
// { // public boolean equals(Object obj)
// if (obj == null) return false; // {
// if (!(obj.getClass().isAssignableFrom(getClass()))) return false; // if (obj == null) return false;
// if (obj instanceof FontId) { // if (!(obj.getClass().isAssignableFrom(getClass()))) return false;
// if (obj == this) return true; // if (obj instanceof FontId) {
// FontId id2 = ((FontId) obj); // if (obj == this) return true;
// boolean flag = true; // FontId id2 = ((FontId) obj);
// flag &= id2.size == size; // boolean flag = true;
// flag &= id2.name.equals(name); // flag &= id2.size == size;
// flag &= id2.style == style; // flag &= id2.name.equals(name);
// flag &= ((id2.glyphset_id != -1 && id2.glyphset_id == glyphset_id) || id2.glyphs.equals(glyphs)); // flag &= id2.style == style;
// return flag; // flag &= ((id2.glyphset_id != -1 && id2.glyphset_id == glyphset_id) ||
// } // id2.glyphs.equals(glyphs));
// return false; // return flag;
// } // }
// // return false;
// // }
// @Override //
// public int hashCode() //
// { // @Override
// return (new Float(size).hashCode()) ^ name.hashCode() ^ style.hashCode() ^ glyphset_id; // public int hashCode()
// } // {
// // return (new Float(size).hashCode()) ^ name.hashCode() ^ style.hashCode()
// // ^ glyphset_id;
// @Override // }
// public String toString() //
// { //
// return "[" + name + ", " + size + ", " + style + (glyphset_id > 0 ? ", g=" + glyphset_id : ", g=custom") + "]"; // @Override
// } // public String toString()
// } // {
// return "[" + name + ", " + size + ", " + style + (glyphset_id > 0 ?
// ", g=" + glyphset_id : ", g=custom") + "]";
// }
// }
/** /**
* Group of styles of one font. * Group of styles of one font.
@ -220,9 +224,12 @@ public class FontManager {
/** /**
* Register font file. * Register font file.
* *
* @param path resource path (res/fonts/...) * @param path
* @param name font name (for binding) * resource path (res/fonts/...)
* @param style font style in this file * @param name
* font name (for binding)
* @param style
* font style in this file
*/ */
public static void registerFile(String path, String name, Style style) public static void registerFile(String path, String name, Style style)
{ {
@ -247,10 +254,14 @@ public class FontManager {
* Preload font if needed, get preloaded font.<br> * Preload font if needed, get preloaded font.<br>
* If needed file is not available, throws runtime exception. * If needed file is not available, throws runtime exception.
* *
* @param name font name (registerFile) * @param name
* @param size font size (pt) * font name (registerFile)
* @param style font style * @param size
* @param glyphs glyphs needed * font size (pt)
* @param style
* font style
* @param glyphs
* glyphs needed
* @return the loaded font. * @return the loaded font.
*/ */
public static LoadedFont loadFont(String name, double size, Style style, String glyphs) public static LoadedFont loadFont(String name, double size, Style style, String glyphs)
@ -263,16 +274,24 @@ public class FontManager {
* Preload font if needed, get preloaded font.<br> * Preload font if needed, get preloaded font.<br>
* If needed file is not available, throws runtime exception. * If needed file is not available, throws runtime exception.
* *
* @param name font name (registerFile) * @param name
* @param size font size (pt) * font name (registerFile)
* @param style font style * @param size
* @param glyphs glyphs needed * font size (pt)
* @param correctLeft left horizontal correction * @param style
* @param correctRight right horizontal correction * font style
* @param scale font scale (changing aspect ratio) * @param glyphs
* @param clipTop top clip (0-1) - top part of the font to be cut off * glyphs needed
* @param clipBottom bottom clip (0-1) - bottom part of the font to be cut * @param correctLeft
* off * left horizontal correction
* @param correctRight
* right horizontal correction
* @param scale
* font scale (changing aspect ratio)
* @param clipTop
* top clip (0-1) - top part of the font to be cut off
* @param clipBottom
* bottom clip (0-1) - bottom part of the font to be cut off
* @return the loaded font. * @return the loaded font.
*/ */
public static LoadedFont loadFont(String name, double size, Style style, String glyphs, int correctLeft, int correctRight, Coord scale, double clipTop, double clipBottom) public static LoadedFont loadFont(String name, double size, Style style, String glyphs, int correctLeft, int correctRight, Coord scale, double clipTop, double clipBottom)

@ -1,6 +1,5 @@
package mightypork.rogue.fonts; package mightypork.rogue.fonts;
import static mightypork.rogue.fonts.FontManager.Style.*; import static mightypork.rogue.fonts.FontManager.Style.*;
import mightypork.rogue.fonts.FontManager.Glyphs; import mightypork.rogue.fonts.FontManager.Glyphs;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,6 +1,5 @@
package mightypork.rogue.fonts; package mightypork.rogue.fonts;
import static mightypork.rogue.fonts.Align.*; import static mightypork.rogue.fonts.Align.*;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
@ -75,6 +74,7 @@ public class LoadedFont {
private double clipVerticalT = 0; private double clipVerticalT = 0;
private double clipVerticalB = 0; private double clipVerticalB = 0;
private class CharStorageEntry { private class CharStorageEntry {
/** Character's width */ /** Character's width */
@ -106,8 +106,8 @@ public class LoadedFont {
public void setCorrection(boolean on) public void setCorrection(boolean on)
{ {
if (on) { if (on) {
correctL = 9;//2 correctL = 9;// 2
correctR = 8;//1 correctR = 8;// 1
} else { } else {
correctL = 0; correctL = 0;
correctR = 0; correctR = 0;
@ -422,7 +422,7 @@ public class LoadedFont {
} }
totalwidth /= -2; totalwidth /= -2;
} }
//if center get next lines total width/2; // if center get next lines total width/2;
} else { } else {
//@formatter:off //@formatter:off
drawQuad( drawQuad(
@ -450,7 +450,8 @@ public class LoadedFont {
try { try {
short width = (short) bufferedImage.getWidth(); short width = (short) bufferedImage.getWidth();
short height = (short) bufferedImage.getHeight(); short height = (short) bufferedImage.getHeight();
//textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24; // textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ?
// (byte)32 : (byte)24;
int bpp = (byte) bufferedImage.getColorModel().getPixelSize(); int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
ByteBuffer byteBuffer; ByteBuffer byteBuffer;
DataBuffer db = bufferedImage.getData().getDataBuffer(); DataBuffer db = bufferedImage.getData().getDataBuffer();
@ -571,11 +572,16 @@ public class LoadedFont {
/** /**
* Draw string with font. * Draw string with font.
* *
* @param x x coord * @param x
* @param y y coord * x coord
* @param text text to draw * @param y
* @param color render color * y coord
* @param align (-1,0,1) * @param text
* text to draw
* @param color
* render color
* @param align
* (-1,0,1)
*/ */
public void draw(double x, double y, String text, RGB color, int align) public void draw(double x, double y, String text, RGB color, int align)
{ {
@ -586,10 +592,14 @@ public class LoadedFont {
/** /**
* Draw string with font. * Draw string with font.
* *
* @param pos coord * @param pos
* @param text text to draw * coord
* @param color render color * @param text
* @param align (-1,0,1) * text to draw
* @param color
* render color
* @param align
* (-1,0,1)
*/ */
public void draw(Coord pos, String text, RGB color, int align) public void draw(Coord pos, String text, RGB color, int align)
{ {
@ -609,7 +619,7 @@ public class LoadedFont {
glTranslated(pos.x, pos.y, pos.z); glTranslated(pos.x, pos.y, pos.z);
//shadow // shadow
int sh = blurSize; int sh = blurSize;
int l = glGenLists(1); int l = glGenLists(1);

@ -1,6 +1,5 @@
package mightypork.rogue.input; package mightypork.rogue.input;
import mightypork.rogue.AppAccess; import mightypork.rogue.AppAccess;
import mightypork.rogue.bus.DelegatingBusClient; import mightypork.rogue.bus.DelegatingBusClient;
import mightypork.rogue.bus.events.KeyboardEvent; import mightypork.rogue.bus.events.KeyboardEvent;

@ -1,13 +1,14 @@
package mightypork.rogue.input; package mightypork.rogue.input;
public interface KeyBinder { public interface KeyBinder {
/** /**
* Bind handler to a keystroke, replace current handler if any * Bind handler to a keystroke, replace current handler if any
* *
* @param stroke trigger keystroke * @param stroke
* @param task handler * trigger keystroke
* @param task
* handler
*/ */
abstract void bindKeyStroke(KeyStroke stroke, Runnable task); abstract void bindKeyStroke(KeyStroke stroke, Runnable task);
@ -15,7 +16,8 @@ public interface KeyBinder {
/** /**
* Remove handler from a keystroke (id any) * Remove handler from a keystroke (id any)
* *
* @param stroke stroke * @param stroke
* stroke
*/ */
abstract void unbindKeyStroke(KeyStroke stroke); abstract void unbindKeyStroke(KeyStroke stroke);

@ -1,6 +1,5 @@
package mightypork.rogue.input; package mightypork.rogue.input;
import mightypork.rogue.bus.events.KeyboardEvent; import mightypork.rogue.bus.events.KeyboardEvent;

@ -1,6 +1,5 @@
package mightypork.rogue.input; package mightypork.rogue.input;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@ -22,8 +21,10 @@ public class KeyBindingPool implements KeyBinder, KeyboardEvent.Listener {
/** /**
* Bind handler to a keystroke, replace current handler if any * Bind handler to a keystroke, replace current handler if any
* *
* @param stroke trigger keystroke * @param stroke
* @param task handler * trigger keystroke
* @param task
* handler
*/ */
@Override @Override
public void bindKeyStroke(KeyStroke stroke, Runnable task) public void bindKeyStroke(KeyStroke stroke, Runnable task)
@ -43,7 +44,8 @@ public class KeyBindingPool implements KeyBinder, KeyboardEvent.Listener {
/** /**
* Remove handler from keystroke (id any) * Remove handler from keystroke (id any)
* *
* @param stroke stroke * @param stroke
* stroke
*/ */
@Override @Override
public void unbindKeyStroke(KeyStroke stroke) public void unbindKeyStroke(KeyStroke stroke)

@ -1,6 +1,5 @@
package mightypork.rogue.input; package mightypork.rogue.input;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
@ -17,8 +16,10 @@ public class KeyStroke {
/** /**
* KeyStroke * KeyStroke
* *
* @param down true for falling edge, up for rising edge * @param down
* @param keys keys that must be pressed * true for falling edge, up for rising edge
* @param keys
* keys that must be pressed
*/ */
public KeyStroke(boolean down, int... keys) { public KeyStroke(boolean down, int... keys) {
this.down = down; this.down = down;

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import mightypork.utils.files.FileUtils; import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -17,8 +16,7 @@ import org.newdawn.slick.openal.SoundStore;
*/ */
public class AudioX implements Destroyable { public class AudioX implements Destroyable {
private enum PlayMode private enum PlayMode {
{
EFFECT, MUSIC; EFFECT, MUSIC;
}; };
@ -37,7 +35,8 @@ public class AudioX implements Destroyable {
/** /**
* Create deferred primitive audio player * Create deferred primitive audio player
* *
* @param resourceName resource to load when needed * @param resourceName
* resource to load when needed
*/ */
public AudioX(String resourceName) { public AudioX(String resourceName) {
this.audio = null; this.audio = null;
@ -102,7 +101,9 @@ public class AudioX implements Destroyable {
public boolean load() public boolean load()
{ {
if (isLoaded()) return true; // already loaded if (isLoaded()) return true; // already loaded
if (loadFailed || resourcePath == null) return false; // not loaded, but can't load anyway if (loadFailed || resourcePath == null) return false; // not loaded, but
// can't load
// anyway
loadFailed = false; loadFailed = false;
try { try {
@ -159,9 +160,12 @@ public class AudioX implements Destroyable {
/** /**
* Play as sound effect at listener position * Play as sound effect at listener position
* *
* @param pitch pitch (1 = default) * @param pitch
* @param gain gain (0-1) * pitch (1 = default)
* @param loop looping * @param gain
* gain (0-1)
* @param loop
* looping
* @return source id * @return source id
*/ */
public int playAsEffect(double pitch, double gain, boolean loop) public int playAsEffect(double pitch, double gain, boolean loop)
@ -173,9 +177,12 @@ public class AudioX implements Destroyable {
/** /**
* Play as sound effect at given X-Y position * Play as sound effect at given X-Y position
* *
* @param pitch pitch (1 = default) * @param pitch
* @param gain gain (0-1) * pitch (1 = default)
* @param loop looping * @param gain
* gain (0-1)
* @param loop
* looping
* @param x * @param x
* @param y * @param y
* @return source id * @return source id
@ -189,9 +196,12 @@ public class AudioX implements Destroyable {
/** /**
* Play as sound effect at given position * Play as sound effect at given position
* *
* @param pitch pitch (1 = default) * @param pitch
* @param gain gain (0-1) * pitch (1 = default)
* @param loop looping * @param gain
* gain (0-1)
* @param loop
* looping
* @param x * @param x
* @param y * @param y
* @param z * @param z
@ -212,10 +222,14 @@ public class AudioX implements Destroyable {
/** /**
* Play as sound effect at given position * Play as sound effect at given position
* *
* @param pitch pitch (1 = default) * @param pitch
* @param gain gain (0-1) * pitch (1 = default)
* @param loop looping * @param gain
* @param pos coord * gain (0-1)
* @param loop
* looping
* @param pos
* coord
* @return source id * @return source id
*/ */
public int playAsEffect(double pitch, double gain, boolean loop, Coord pos) public int playAsEffect(double pitch, double gain, boolean loop, Coord pos)
@ -230,9 +244,12 @@ public class AudioX implements Destroyable {
* Play as music using source 0.<br> * Play as music using source 0.<br>
* Discouraged, since this does not allow cross-fading. * Discouraged, since this does not allow cross-fading.
* *
* @param pitch play pitch * @param pitch
* @param gain play gain * play pitch
* @param loop looping * @param gain
* play gain
* @param loop
* looping
* @return source * @return source
*/ */
public int playAsMusic(double pitch, double gain, boolean loop) public int playAsMusic(double pitch, double gain, boolean loop)

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;
@ -18,7 +17,8 @@ public class JointVolume extends Mutable<Double> {
/** /**
* Create joint volume with master gain of 1 * Create joint volume with master gain of 1
* *
* @param volumes individual volumes to join * @param volumes
* individual volumes to join
*/ */
public JointVolume(Mutable<Double>... volumes) { public JointVolume(Mutable<Double>... volumes) {
super(1D); super(1D);

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;
import mightypork.utils.time.Pauseable; import mightypork.utils.time.Pauseable;
import mightypork.utils.time.Updateable; import mightypork.utils.time.Updateable;

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
public class NullAudio extends AudioX { public class NullAudio extends AudioX {
public NullAudio() { public NullAudio() {

@ -1,6 +1,5 @@
package mightypork.rogue.sounds; package mightypork.rogue.sounds;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -119,10 +118,14 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Register effect resource * Register effect resource
* *
* @param key sound key * @param key
* @param resource resource path * sound key
* @param pitch default pitch (1 = unchanged) * @param resource
* @param gain default gain (0-1) * resource path
* @param pitch
* default pitch (1 = unchanged)
* @param gain
* default gain (0-1)
*/ */
public void addEffect(String key, String resource, double pitch, double gain) public void addEffect(String key, String resource, double pitch, double gain)
{ {
@ -134,12 +137,18 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Register loop resource (music / effect loop) * Register loop resource (music / effect loop)
* *
* @param key sound key * @param key
* @param resource resource path * sound key
* @param pitch default pitch (1 = unchanged) * @param resource
* @param gain default gain (0-1) * resource path
* @param fadeIn default time for fadeIn * @param pitch
* @param fadeOut default time for fadeOut * default pitch (1 = unchanged)
* @param gain
* default gain (0-1)
* @param fadeIn
* default time for fadeIn
* @param fadeOut
* default time for fadeOut
*/ */
public void addLoop(String key, String resource, double pitch, double gain, double fadeIn, double fadeOut) public void addLoop(String key, String resource, double pitch, double gain, double fadeIn, double fadeOut)
{ {
@ -152,9 +161,11 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Create {@link AudioX} for a resource * Create {@link AudioX} for a resource
* *
* @param res a resource name * @param res
* a resource name
* @return the resource * @return the resource
* @throws IllegalArgumentException if resource is already registered * @throws IllegalArgumentException
* if resource is already registered
*/ */
private AudioX getResource(String res) private AudioX getResource(String res)
{ {
@ -168,7 +179,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Get a loop player for key * Get a loop player for key
* *
* @param key sound key * @param key
* sound key
* @return loop player * @return loop player
*/ */
public LoopPlayer getLoop(String key) public LoopPlayer getLoop(String key)
@ -185,7 +197,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Get a effect player for key * Get a effect player for key
* *
* @param key sound key * @param key
* sound key
* @return effect player * @return effect player
*/ */
public EffectPlayer getEffect(String key) public EffectPlayer getEffect(String key)
@ -213,7 +226,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Fade in a loop (with default time) * Fade in a loop (with default time)
* *
* @param key sound key * @param key
* sound key
*/ */
public void fadeInLoop(String key) public void fadeInLoop(String key)
{ {
@ -224,8 +238,10 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Fade in a loop * Fade in a loop
* *
* @param key sound key * @param key
* @param seconds fade-in duration * sound key
* @param seconds
* fade-in duration
*/ */
public void fadeInLoop(String key, double seconds) public void fadeInLoop(String key, double seconds)
{ {
@ -236,7 +252,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Fade out a loop (with default time) * Fade out a loop (with default time)
* *
* @param key sound key * @param key
* sound key
*/ */
public void fadeOutLoop(String key) public void fadeOutLoop(String key)
{ {
@ -247,8 +264,10 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Fade out a loop * Fade out a loop
* *
* @param key sound key * @param key
* @param seconds fade-out duration * sound key
* @param seconds
* fade-out duration
*/ */
public void fadeOutLoop(String key, double seconds) public void fadeOutLoop(String key, double seconds)
{ {
@ -259,7 +278,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Pause a loop * Pause a loop
* *
* @param key sound key * @param key
* sound key
*/ */
public void pauseLoop(String key) public void pauseLoop(String key)
{ {
@ -281,7 +301,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Resume a loop * Resume a loop
* *
* @param key sound key * @param key
* sound key
*/ */
public void resumeLoop(String key) public void resumeLoop(String key)
{ {
@ -292,7 +313,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Set level of master volume * Set level of master volume
* *
* @param d level * @param d
* level
*/ */
public void setMasterVolume(double d) public void setMasterVolume(double d)
{ {
@ -303,7 +325,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Set level of effects volume * Set level of effects volume
* *
* @param d level * @param d
* level
*/ */
public void setEffectsVolume(double d) public void setEffectsVolume(double d)
{ {
@ -314,7 +337,8 @@ public class SoundSystem extends DelegatingBusClient {
/** /**
* Set level of music volume * Set level of music volume
* *
* @param d level * @param d
* level
*/ */
public void setMusicVolume(double d) public void setMusicVolume(double d)
{ {

@ -1,6 +1,5 @@
package mightypork.rogue.tasks; package mightypork.rogue.tasks;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;

@ -1,6 +1,5 @@
package mightypork.rogue.testing; package mightypork.rogue.testing;
import mightypork.rogue.display.constraints.Bounding; import mightypork.rogue.display.constraints.Bounding;
import mightypork.rogue.display.constraints.Constraint; import mightypork.rogue.display.constraints.Constraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,6 +1,5 @@
package mightypork.rogue.testing; package mightypork.rogue.testing;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -182,6 +181,7 @@ class StringMessage implements Handleable<StringMessage.Listener> {
this.s = str; this.s = str;
} }
public interface Listener { public interface Listener {
public void receive(StringMessage message); public void receive(StringMessage message);
@ -205,6 +205,7 @@ class IntMessage implements Handleable<IntMessage.Listener> {
this.i = i; this.i = i;
} }
public interface Listener { public interface Listener {
public void receive(IntMessage message); public void receive(IntMessage message);

@ -1,6 +1,5 @@
package mightypork.rogue.textures; package mightypork.rogue.textures;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import java.io.IOException; import java.io.IOException;
@ -52,8 +51,10 @@ public class TextureManager {
/** /**
* Bind texture * Bind texture
* *
* @param texture the texture * @param texture
* @throws RuntimeException if not loaded yet * the texture
* @throws RuntimeException
* if not loaded yet
*/ */
public static void bind(Texture texture) throws RuntimeException public static void bind(Texture texture) throws RuntimeException
{ {

@ -1,6 +1,5 @@
package mightypork.rogue.textures; package mightypork.rogue.textures;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -1,6 +1,5 @@
package mightypork.rogue.textures; package mightypork.rogue.textures;
// TODO rewrite // TODO rewrite
/** /**

@ -1,6 +1,5 @@
package mightypork.rogue.textures; package mightypork.rogue.textures;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -25,11 +24,16 @@ public class TxQuad {
/** /**
* Create TxQuad from left top coord and rect size * Create TxQuad from left top coord and rect size
* *
* @param tx texture * @param tx
* @param x1 left top X * texture
* @param y1 left top Y * @param x1
* @param width area width * left top X
* @param height area height * @param y1
* left top Y
* @param width
* area width
* @param height
* area height
* @return new TxQuad * @return new TxQuad
*/ */
public static TxQuad fromSize(Texture tx, int x1, int y1, int width, int height) public static TxQuad fromSize(Texture tx, int x1, int y1, int width, int height)
@ -39,8 +43,10 @@ public class TxQuad {
/** /**
* @param tx Texture * @param tx
* @param uvs Rect of texturwe UVs (pixels - from left top) * Texture
* @param uvs
* Rect of texturwe UVs (pixels - from left top)
*/ */
public TxQuad(Texture tx, Rect uvs) { public TxQuad(Texture tx, Rect uvs) {
this.tx = tx; this.tx = tx;
@ -52,11 +58,16 @@ public class TxQuad {
/** /**
* Make of coords * Make of coords
* *
* @param tx texture * @param tx
* @param x1 x1 * texture
* @param y1 y1 * @param x1
* @param x2 x2 * x1
* @param y2 y2 * @param y1
* y1
* @param x2
* x2
* @param y2
* y2
*/ */
public TxQuad(Texture tx, int x1, int y1, int x2, int y2) { public TxQuad(Texture tx, int x1, int y1, int x2, int y2) {
this.tx = tx; this.tx = tx;

@ -1,6 +1,5 @@
package mightypork.rogue.util; package mightypork.rogue.util;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import mightypork.rogue.textures.TextureManager; import mightypork.rogue.textures.TextureManager;
import mightypork.rogue.textures.TxQuad; import mightypork.rogue.textures.TxQuad;
@ -27,8 +26,10 @@ public class RenderUtils {
/** /**
* Render quad 2D * Render quad 2D
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param max
* max coord
*/ */
public static void quadCoord(Coord min, Coord max) public static void quadCoord(Coord min, Coord max)
{ {
@ -39,10 +40,14 @@ public class RenderUtils {
/** /**
* Render quad with absolute coords (from screen bottom) * Render quad with absolute coords (from screen bottom)
* *
* @param left left x * @param left
* @param bottom bottom y * left x
* @param right right x * @param bottom
* @param top top y * bottom y
* @param right
* right x
* @param top
* top y
*/ */
public static void quadCoord(double left, double bottom, double right, double top) public static void quadCoord(double left, double bottom, double right, double top)
{ {
@ -58,11 +63,16 @@ public class RenderUtils {
/** /**
* Render quad with coloured border * Render quad with coloured border
* *
* @param min min * @param min
* @param max max * min
* @param border border width * @param max
* @param borderColor border color * max
* @param insideColor filling color * @param border
* border width
* @param borderColor
* border color
* @param insideColor
* filling color
*/ */
public static void quadCoordBorder(Coord min, Coord max, double border, RGB borderColor, RGB insideColor) public static void quadCoordBorder(Coord min, Coord max, double border, RGB borderColor, RGB insideColor)
{ {
@ -73,13 +83,20 @@ public class RenderUtils {
/** /**
* Render quad with coloured border * Render quad with coloured border
* *
* @param minX min x * @param minX
* @param minY min y * min x
* @param maxX max x * @param minY
* @param maxY max y * min y
* @param border border width * @param maxX
* @param borderColor border color * max x
* @param insideColor filling color * @param maxY
* max y
* @param border
* border width
* @param borderColor
* border color
* @param insideColor
* filling color
*/ */
public static void quadCoordBorder(double minX, double minY, double maxX, double maxY, double border, RGB borderColor, RGB insideColor) public static void quadCoordBorder(double minX, double minY, double maxX, double maxY, double border, RGB borderColor, RGB insideColor)
{ {
@ -104,10 +121,14 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param colorLeft color left * @param max
* @param colorRight color right * max coord
* @param colorLeft
* color left
* @param colorRight
* color right
*/ */
public static void quadCoordGradH(Coord min, Coord max, RGB colorLeft, RGB colorRight) public static void quadCoordGradH(Coord min, Coord max, RGB colorLeft, RGB colorRight)
{ {
@ -118,12 +139,18 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param minX units from left * @param minX
* @param minY units from bottom * units from left
* @param maxX quad width * @param minY
* @param maxY quad height * units from bottom
* @param colorLeft color left * @param maxX
* @param colorRight color right * quad width
* @param maxY
* quad height
* @param colorLeft
* color left
* @param colorRight
* color right
*/ */
public static void quadCoordGradH(double minX, double minY, double maxX, double maxY, RGB colorLeft, RGB colorRight) public static void quadCoordGradH(double minX, double minY, double maxX, double maxY, RGB colorLeft, RGB colorRight)
{ {
@ -144,10 +171,14 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param colorOuter color outer * @param max
* @param colorMiddle color inner * max coord
* @param colorOuter
* color outer
* @param colorMiddle
* color inner
*/ */
public static void quadCoordGradHBilinear(Coord min, Coord max, RGB colorOuter, RGB colorMiddle) public static void quadCoordGradHBilinear(Coord min, Coord max, RGB colorOuter, RGB colorMiddle)
{ {
@ -158,12 +189,18 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param minX min x * @param minX
* @param minY min y * min x
* @param maxX max x * @param minY
* @param maxY max y * min y
* @param colorOuter color outer * @param maxX
* @param colorMiddle color inner * max x
* @param maxY
* max y
* @param colorOuter
* color outer
* @param colorMiddle
* color inner
*/ */
public static void quadCoordGradHBilinear(double minX, double minY, double maxX, double maxY, RGB colorOuter, RGB colorMiddle) public static void quadCoordGradHBilinear(double minX, double minY, double maxX, double maxY, RGB colorOuter, RGB colorMiddle)
{ {
@ -194,10 +231,14 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param colorTop top color * @param max
* @param colorBottom bottom color * max coord
* @param colorTop
* top color
* @param colorBottom
* bottom color
*/ */
public static void quadCoordGradV(Coord min, Coord max, RGB colorTop, RGB colorBottom) public static void quadCoordGradV(Coord min, Coord max, RGB colorTop, RGB colorBottom)
{ {
@ -208,12 +249,18 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param minX min X * @param minX
* @param minY min Y * min X
* @param maxX max X * @param minY
* @param maxY max Y * min Y
* @param colorTop top color * @param maxX
* @param colorBottom bottom color * max X
* @param maxY
* max Y
* @param colorTop
* top color
* @param colorBottom
* bottom color
*/ */
public static void quadCoordGradV(double minX, double minY, double maxX, double maxY, RGB colorTop, RGB colorBottom) public static void quadCoordGradV(double minX, double minY, double maxX, double maxY, RGB colorTop, RGB colorBottom)
{ {
@ -233,10 +280,14 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param colorOuter outer color * @param max
* @param colorMiddle middle color * max coord
* @param colorOuter
* outer color
* @param colorMiddle
* middle color
*/ */
public static void quadCoordGradVBilinear(Coord min, Coord max, RGB colorOuter, RGB colorMiddle) public static void quadCoordGradVBilinear(Coord min, Coord max, RGB colorOuter, RGB colorMiddle)
{ {
@ -247,12 +298,18 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param minX min X * @param minX
* @param minY min Y * min X
* @param maxX max X * @param minY
* @param maxY max Y * min Y
* @param colorOuter outer color * @param maxX
* @param colorMiddle middle color * max X
* @param maxY
* max Y
* @param colorOuter
* outer color
* @param colorMiddle
* middle color
*/ */
public static void quadCoordGradVBilinear(double minX, double minY, double maxX, double maxY, RGB colorOuter, RGB colorMiddle) public static void quadCoordGradVBilinear(double minX, double minY, double maxX, double maxY, RGB colorOuter, RGB colorMiddle)
{ {
@ -281,11 +338,16 @@ public class RenderUtils {
/** /**
* Render quad with coloured border with outset effect * Render quad with coloured border with outset effect
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param border border width * @param max
* @param fill fill color * max coord
* @param inset true for inset, false for outset * @param border
* border width
* @param fill
* fill color
* @param inset
* true for inset, false for outset
*/ */
public static void quadCoordOutset(Coord min, Coord max, double border, RGB fill, boolean inset) public static void quadCoordOutset(Coord min, Coord max, double border, RGB fill, boolean inset)
{ {
@ -296,13 +358,20 @@ public class RenderUtils {
/** /**
* Render quad with coloured border with outset effect * Render quad with coloured border with outset effect
* *
* @param minX left X * @param minX
* @param minY bottom Y * left X
* @param maxX right X * @param minY
* @param maxY top Y * bottom Y
* @param border border width * @param maxX
* @param fill fill color * right X
* @param inset true for inset, false for outset * @param maxY
* top Y
* @param border
* border width
* @param fill
* fill color
* @param inset
* true for inset, false for outset
*/ */
public static void quadCoordOutset(double minX, double minY, double maxX, double maxY, double border, RGB fill, boolean inset) public static void quadCoordOutset(double minX, double minY, double maxX, double maxY, double border, RGB fill, boolean inset)
{ {
@ -367,7 +436,8 @@ public class RenderUtils {
/** /**
* Render quad 2D * Render quad 2D
* *
* @param rect rectangle * @param rect
* rectangle
*/ */
public static void quadRect(Rect rect) public static void quadRect(Rect rect)
{ {
@ -378,8 +448,10 @@ public class RenderUtils {
/** /**
* Render quad 2D * Render quad 2D
* *
* @param rect rectangle * @param rect
* @param color draw color * rectangle
* @param color
* draw color
*/ */
public static void quadRect(Rect rect, RGB color) public static void quadRect(Rect rect, RGB color)
{ {
@ -391,10 +463,14 @@ public class RenderUtils {
/** /**
* Render quad with coloured border * Render quad with coloured border
* *
* @param rect rect * @param rect
* @param border border width * rect
* @param borderColor border color * @param border
* @param insideColor filling color * border width
* @param borderColor
* border color
* @param insideColor
* filling color
*/ */
public static void quadBorder(Rect rect, double border, RGB borderColor, RGB insideColor) public static void quadBorder(Rect rect, double border, RGB borderColor, RGB insideColor)
{ {
@ -405,9 +481,12 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param rect rect * @param rect
* @param colorLeft color left * rect
* @param colorRight color right * @param colorLeft
* color left
* @param colorRight
* color right
*/ */
public static void quadGradH(Rect rect, RGB colorLeft, RGB colorRight) public static void quadGradH(Rect rect, RGB colorLeft, RGB colorRight)
{ {
@ -418,9 +497,12 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient horizontal * Render quad 2D with gradient horizontal
* *
* @param rect rect * @param rect
* @param colorOuter color outer * rect
* @param colorMiddle color inner * @param colorOuter
* color outer
* @param colorMiddle
* color inner
*/ */
public static void quadGradHBilinear(Rect rect, RGB colorOuter, RGB colorMiddle) public static void quadGradHBilinear(Rect rect, RGB colorOuter, RGB colorMiddle)
{ {
@ -431,9 +513,12 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param rect rect * @param rect
* @param colorTop top color * rect
* @param colorBottom bottom color * @param colorTop
* top color
* @param colorBottom
* bottom color
*/ */
public static void quadGradV(Rect rect, RGB colorTop, RGB colorBottom) public static void quadGradV(Rect rect, RGB colorTop, RGB colorBottom)
{ {
@ -444,9 +529,12 @@ public class RenderUtils {
/** /**
* Render quad 2D with gradient vertical * Render quad 2D with gradient vertical
* *
* @param rect rect * @param rect
* @param colorOuter outer color * rect
* @param colorMiddle middle color * @param colorOuter
* outer color
* @param colorMiddle
* middle color
*/ */
public static void quadGradVBilinear(Rect rect, RGB colorOuter, RGB colorMiddle) public static void quadGradVBilinear(Rect rect, RGB colorOuter, RGB colorMiddle)
{ {
@ -457,10 +545,14 @@ public class RenderUtils {
/** /**
* Render quad with coloured border with outset effect * Render quad with coloured border with outset effect
* *
* @param rect rectangle * @param rect
* @param border border width * rectangle
* @param fill fill color * @param border
* @param inset true for inset, false for outset * border width
* @param fill
* fill color
* @param inset
* true for inset, false for outset
*/ */
public static void quadRectOutset(Rect rect, double border, RGB fill, boolean inset) public static void quadRectOutset(Rect rect, double border, RGB fill, boolean inset)
{ {
@ -471,8 +563,10 @@ public class RenderUtils {
/** /**
* Render textured rect (texture must be binded already) * Render textured rect (texture must be binded already)
* *
* @param quad rectangle (px) * @param quad
* @param textureCoords texture coords (0-1) * rectangle (px)
* @param textureCoords
* texture coords (0-1)
*/ */
public static void quadTexturedAbs(Rect quad, Rect textureCoords) public static void quadTexturedAbs(Rect quad, Rect textureCoords)
{ {
@ -502,9 +596,12 @@ public class RenderUtils {
/** /**
* Render textured rect * Render textured rect
* *
* @param quad rectangle (px) * @param quad
* @param txCoords texture coords rectangle (px) * rectangle (px)
* @param texture texture instance * @param txCoords
* texture coords rectangle (px)
* @param texture
* texture instance
*/ */
public static void quadTextured(Rect quad, Rect txCoords, Texture texture) public static void quadTextured(Rect quad, Rect txCoords, Texture texture)
{ {
@ -515,10 +612,14 @@ public class RenderUtils {
/** /**
* Render textured rect * Render textured rect
* *
* @param quad rectangle (px) * @param quad
* @param txCoords texture coords rectangle (px) * rectangle (px)
* @param texture texture instance * @param txCoords
* @param tint color tint * texture coords rectangle (px)
* @param texture
* texture instance
* @param tint
* color tint
*/ */
public static void quadTextured(Rect quad, Rect txCoords, Texture texture, RGB tint) public static void quadTextured(Rect quad, Rect txCoords, Texture texture, RGB tint)
{ {
@ -536,8 +637,10 @@ public class RenderUtils {
/** /**
* Render textured rect * Render textured rect
* *
* @param quad rectangle (px) * @param quad
* @param txquad texture quad * rectangle (px)
* @param txquad
* texture quad
*/ */
public static void quadTextured(Rect quad, TxQuad txquad) public static void quadTextured(Rect quad, TxQuad txquad)
{ {
@ -548,9 +651,12 @@ public class RenderUtils {
/** /**
* Render textured rect * Render textured rect
* *
* @param quad rectangle (px) * @param quad
* @param txquad texture instance * rectangle (px)
* @param tint color tint * @param txquad
* texture instance
* @param tint
* color tint
*/ */
public static void quadTextured(Rect quad, TxQuad txquad, RGB tint) public static void quadTextured(Rect quad, TxQuad txquad, RGB tint)
{ {
@ -561,10 +667,14 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param yOffsetTimes offset count (move frame down n times) * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param yOffsetTimes
* offset count (move frame down n times)
* @param texture
* the texture
*/ */
public static void quadTexturedFrame(Rect quadRect, Rect textureRect, int yOffsetTimes, Texture texture) public static void quadTexturedFrame(Rect quadRect, Rect textureRect, int yOffsetTimes, Texture texture)
{ {
@ -575,11 +685,16 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param yOffsetTimes offset count (move frame down n times) * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param tint color tint * @param yOffsetTimes
* offset count (move frame down n times)
* @param texture
* the texture
* @param tint
* color tint
*/ */
public static void quadTexturedFrame(Rect quadRect, Rect textureRect, int yOffsetTimes, Texture texture, RGB tint) public static void quadTexturedFrame(Rect quadRect, Rect textureRect, int yOffsetTimes, Texture texture, RGB tint)
{ {
@ -640,9 +755,12 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param texture the texture * @param textureRect
* rectangle in texture with the basic frame (px)
* @param texture
* the texture
*/ */
public static void quadTexturedFrame(Rect quadRect, Rect textureRect, Texture texture) public static void quadTexturedFrame(Rect quadRect, Rect textureRect, Texture texture)
{ {
@ -653,8 +771,10 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param txquad
* texture quad
*/ */
public static void quadTexturedFrame(Rect quadRect, TxQuad txquad) public static void quadTexturedFrame(Rect quadRect, TxQuad txquad)
{ {
@ -665,9 +785,12 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param yOffsetTimes offset count (move frame down n times) * @param txquad
* texture quad
* @param yOffsetTimes
* offset count (move frame down n times)
*/ */
public static void quadTexturedFrame(Rect quadRect, TxQuad txquad, int yOffsetTimes) public static void quadTexturedFrame(Rect quadRect, TxQuad txquad, int yOffsetTimes)
{ {
@ -678,10 +801,14 @@ public class RenderUtils {
/** /**
* Render textured frame with borders * Render textured frame with borders
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param yOffsetTimes offset count (move frame down n times) * @param txquad
* @param tint color tint * texture quad
* @param yOffsetTimes
* offset count (move frame down n times)
* @param tint
* color tint
*/ */
public static void quadTexturedFrame(Rect quadRect, TxQuad txquad, int yOffsetTimes, RGB tint) public static void quadTexturedFrame(Rect quadRect, TxQuad txquad, int yOffsetTimes, RGB tint)
{ {
@ -693,10 +820,14 @@ public class RenderUtils {
* Render textured frame stretching horizontally (rect height = texture rect * Render textured frame stretching horizontally (rect height = texture rect
* height) * height)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param borderSize
* size of the unstretched horizontal border
* @param texture
* the texture
*/ */
public static void quadTexturedStretchH(Rect quadRect, Rect textureRect, int borderSize, Texture texture) public static void quadTexturedStretchH(Rect quadRect, Rect textureRect, int borderSize, Texture texture)
{ {
@ -708,11 +839,16 @@ public class RenderUtils {
* Render textured frame stretching horizontally (rect height = texture rect * Render textured frame stretching horizontally (rect height = texture rect
* height) * height)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param tint color tint * @param borderSize
* size of the unstretched horizontal border
* @param texture
* the texture
* @param tint
* color tint
*/ */
public static void quadTexturedStretchH(Rect quadRect, Rect textureRect, int borderSize, Texture texture, RGB tint) public static void quadTexturedStretchH(Rect quadRect, Rect textureRect, int borderSize, Texture texture, RGB tint)
{ {
@ -737,7 +873,7 @@ public class RenderUtils {
uvs = new Rect(tx1, ty1, tx1 + borderSize, ty2); uvs = new Rect(tx1, ty1, tx1 + borderSize, ty2);
quadTextured(verts, uvs, tx, tint); quadTextured(verts, uvs, tx, tint);
// // mi // // mi
verts = new Rect(x1 + borderSize, y2, x2 - borderSize, y1); verts = new Rect(x1 + borderSize, y2, x2 - borderSize, y1);
uvs = new Rect(tx1 + borderSize, ty1, tx2 - borderSize, ty2); uvs = new Rect(tx1 + borderSize, ty1, tx2 - borderSize, ty2);
quadTextured(verts, uvs, tx, tint); quadTextured(verts, uvs, tx, tint);
@ -753,9 +889,12 @@ public class RenderUtils {
* Render textured frame stretching horizontally (rect height = texture rect * Render textured frame stretching horizontally (rect height = texture rect
* height) * height)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param txquad
* texture quad
* @param borderSize
* size of the unstretched horizontal border
*/ */
public static void quadTexturedStretchH(Rect quadRect, TxQuad txquad, int borderSize) public static void quadTexturedStretchH(Rect quadRect, TxQuad txquad, int borderSize)
{ {
@ -767,10 +906,14 @@ public class RenderUtils {
* Render textured frame stretching horizontally (rect height = texture rect * Render textured frame stretching horizontally (rect height = texture rect
* height) * height)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param txquad
* @param tint color tint * texture quad
* @param borderSize
* size of the unstretched horizontal border
* @param tint
* color tint
*/ */
public static void quadTexturedStretchH(Rect quadRect, TxQuad txquad, int borderSize, RGB tint) public static void quadTexturedStretchH(Rect quadRect, TxQuad txquad, int borderSize, RGB tint)
{ {
@ -782,10 +925,14 @@ public class RenderUtils {
* Render textured frame stretching vertically (rect width = texture rect * Render textured frame stretching vertically (rect width = texture rect
* width) * width)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param borderSize
* size of the unstretched horizontal border
* @param texture
* the texture
*/ */
public static void quadTexturedStretchV(Rect quadRect, Rect textureRect, int borderSize, Texture texture) public static void quadTexturedStretchV(Rect quadRect, Rect textureRect, int borderSize, Texture texture)
{ {
@ -797,11 +944,16 @@ public class RenderUtils {
* Render textured frame stretching vertically (rect width = texture rect * Render textured frame stretching vertically (rect width = texture rect
* width) * width)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param textureRect rectangle in texture with the basic frame (px) * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param textureRect
* @param texture the texture * rectangle in texture with the basic frame (px)
* @param tint color tint * @param borderSize
* size of the unstretched horizontal border
* @param texture
* the texture
* @param tint
* color tint
*/ */
public static void quadTexturedStretchV(Rect quadRect, Rect textureRect, int borderSize, Texture texture, RGB tint) public static void quadTexturedStretchV(Rect quadRect, Rect textureRect, int borderSize, Texture texture, RGB tint)
{ {
@ -844,9 +996,12 @@ public class RenderUtils {
* Render textured frame stretching vertically (rect width = texture rect * Render textured frame stretching vertically (rect width = texture rect
* width) * width)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param txquad
* texture quad
* @param borderSize
* size of the unstretched horizontal border
*/ */
public static void quadTexturedStretchV(Rect quadRect, TxQuad txquad, int borderSize) public static void quadTexturedStretchV(Rect quadRect, TxQuad txquad, int borderSize)
{ {
@ -858,10 +1013,14 @@ public class RenderUtils {
* Render textured frame stretching vertically (rect width = texture rect * Render textured frame stretching vertically (rect width = texture rect
* width) * width)
* *
* @param quadRect drawn rectangle (px) * @param quadRect
* @param txquad texture quad * drawn rectangle (px)
* @param borderSize size of the unstretched horizontal border * @param txquad
* @param tint color tint * texture quad
* @param borderSize
* size of the unstretched horizontal border
* @param tint
* color tint
*/ */
public static void quadTexturedStretchV(Rect quadRect, TxQuad txquad, int borderSize, RGB tint) public static void quadTexturedStretchV(Rect quadRect, TxQuad txquad, int borderSize, RGB tint)
{ {
@ -873,10 +1032,14 @@ public class RenderUtils {
/** /**
* Render quad 2D * Render quad 2D
* *
* @param left units from left * @param left
* @param bottom units from bottom * units from left
* @param width quad width * @param bottom
* @param height quad height * units from bottom
* @param width
* quad width
* @param height
* quad height
*/ */
public static void quadSize(double left, double bottom, double width, double height) public static void quadSize(double left, double bottom, double width, double height)
{ {
@ -892,7 +1055,8 @@ public class RenderUtils {
/** /**
* Bind GL color * Bind GL color
* *
* @param color RGB color * @param color
* RGB color
*/ */
public static void setColor(RGB color) public static void setColor(RGB color)
{ {
@ -903,8 +1067,10 @@ public class RenderUtils {
/** /**
* Bind GL color * Bind GL color
* *
* @param color RGB color * @param color
* @param alpha alpha multiplier * RGB color
* @param alpha
* alpha multiplier
*/ */
public static void setColor(RGB color, double alpha) public static void setColor(RGB color, double alpha)
{ {
@ -915,7 +1081,8 @@ public class RenderUtils {
/** /**
* Translate with coord * Translate with coord
* *
* @param coord coord * @param coord
* coord
*/ */
public static void translate(Coord coord) public static void translate(Coord coord)
{ {

@ -1,6 +1,5 @@
package mightypork.rogue.util; package mightypork.rogue.util;
/** /**
* Utils class * Utils class
* *

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -92,7 +91,8 @@ public class FileTreeDiff {
if (read1 == -1) break; if (read1 == -1) break;
} }
} catch (IOException e) {} finally { } catch (IOException e) {
} finally {
try { try {
if (cin1 != null) cin1.close(); if (cin1 != null) cin1.close();
} catch (IOException e) { } catch (IOException e) {
@ -140,6 +140,7 @@ public class FileTreeDiff {
} }
} }
private class NotEqualException extends Exception { private class NotEqualException extends Exception {
public NotEqualException(String msg) { public NotEqualException(String msg) {
@ -148,6 +149,7 @@ public class FileTreeDiff {
} }
private class Tuple<T> { private class Tuple<T> {
public T a; public T a;

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,9 +14,12 @@ public class FileUtils {
/** /**
* Copy directory recursively. * Copy directory recursively.
* *
* @param source source file * @param source
* @param target target file * source file
* @throws IOException on error * @param target
* target file
* @throws IOException
* on error
*/ */
public static void copyDirectory(File source, File target) throws IOException public static void copyDirectory(File source, File target) throws IOException
{ {
@ -28,11 +30,16 @@ public class FileUtils {
/** /**
* Copy directory recursively - advanced variant. * Copy directory recursively - advanced variant.
* *
* @param source source file * @param source
* @param target target file * source file
* @param filter filter accepting only files and dirs to be copied * @param target
* @param filesCopied list into which all the target files will be added * target file
* @throws IOException on error * @param filter
* filter accepting only files and dirs to be copied
* @param filesCopied
* list into which all the target files will be added
* @throws IOException
* on error
*/ */
public static void copyDirectory(File source, File target, FileFilter filter, List<File> filesCopied) throws IOException public static void copyDirectory(File source, File target, FileFilter filter, List<File> filesCopied) throws IOException
{ {
@ -62,10 +69,14 @@ public class FileUtils {
/** /**
* List directory recursively * List directory recursively
* *
* @param source source file * @param source
* @param filter filter accepting only files and dirs to be copied (or null) * source file
* @param files list of the found files * @param filter
* @throws IOException on error * filter accepting only files and dirs to be copied (or null)
* @param files
* list of the found files
* @throws IOException
* on error
*/ */
public static void listDirectoryRecursive(File source, StringFilter filter, List<File> files) throws IOException public static void listDirectoryRecursive(File source, StringFilter filter, List<File> files) throws IOException
{ {
@ -88,9 +99,12 @@ public class FileUtils {
/** /**
* Copy file using streams. Make sure target directory exists! * Copy file using streams. Make sure target directory exists!
* *
* @param source source file * @param source
* @param target target file * source file
* @throws IOException on error * @param target
* target file
* @throws IOException
* on error
*/ */
public static void copyFile(File source, File target) throws IOException public static void copyFile(File source, File target) throws IOException
{ {
@ -120,9 +134,12 @@ public class FileUtils {
/** /**
* Copy bytes from input to output stream, leaving out stream open * Copy bytes from input to output stream, leaving out stream open
* *
* @param in input stream * @param in
* @param out output stream * input stream
* @throws IOException on error * @param out
* output stream
* @throws IOException
* on error
*/ */
public static void copyStream(InputStream in, OutputStream out) throws IOException public static void copyStream(InputStream in, OutputStream out) throws IOException
{ {
@ -145,8 +162,10 @@ public class FileUtils {
/** /**
* Improved delete * Improved delete
* *
* @param path deleted path * @param path
* @param recursive recursive delete * deleted path
* @param recursive
* recursive delete
* @return success * @return success
*/ */
public static boolean delete(File path, boolean recursive) public static boolean delete(File path, boolean recursive)
@ -169,7 +188,8 @@ public class FileUtils {
/** /**
* Read entire file to a string. * Read entire file to a string.
* *
* @param file file * @param file
* file
* @return file contents * @return file contents
* @throws IOException * @throws IOException
*/ */
@ -184,7 +204,8 @@ public class FileUtils {
/** /**
* Get files in a folder (create folder if needed) * Get files in a folder (create folder if needed)
* *
* @param dir folder * @param dir
* folder
* @return list of files * @return list of files
*/ */
public static List<File> listDirectory(File dir) public static List<File> listDirectory(File dir)
@ -196,8 +217,10 @@ public class FileUtils {
/** /**
* Get files in a folder (create folder if needed) * Get files in a folder (create folder if needed)
* *
* @param dir folder * @param dir
* @param filter file filter * folder
* @param filter
* file filter
* @return list of files * @return list of files
*/ */
public static List<File> listDirectory(File dir, FileFilter filter) public static List<File> listDirectory(File dir, FileFilter filter)
@ -225,7 +248,8 @@ public class FileUtils {
/** /**
* Remove extension. * Remove extension.
* *
* @param file file * @param file
* file
* @return filename without extension * @return filename without extension
*/ */
public static String[] getFilenameParts(File file) public static String[] getFilenameParts(File file)
@ -276,7 +300,8 @@ public class FileUtils {
/** /**
* Read entire input stream to a string, and close it. * Read entire input stream to a string, and close it.
* *
* @param in input stream * @param in
* input stream
* @return file contents * @return file contents
*/ */
public static String streamToString(InputStream in) public static String streamToString(InputStream in)
@ -288,8 +313,10 @@ public class FileUtils {
/** /**
* Read input stream to a string, and close it. * Read input stream to a string, and close it.
* *
* @param in input stream * @param in
* @param lines max number of lines (-1 to disable limit) * input stream
* @param lines
* max number of lines (-1 to disable limit)
* @return file contents * @return file contents
*/ */
public static String streamToString(InputStream in, int lines) public static String streamToString(InputStream in, int lines)
@ -357,9 +384,12 @@ public class FileUtils {
/** /**
* Save string to file * Save string to file
* *
* @param file file * @param file
* @param text string * file
* @throws IOException on error * @param text
* string
* @throws IOException
* on error
*/ */
public static void stringToFile(File file, String text) throws IOException public static void stringToFile(File file, String text) throws IOException
{ {
@ -397,7 +427,8 @@ public class FileUtils {
/** /**
* Replace special characters with place holders in a filename. * Replace special characters with place holders in a filename.
* *
* @param filestring filename string * @param filestring
* filename string
* @return escaped * @return escaped
*/ */
public static String escapeFileString(String filestring) public static String escapeFileString(String filestring)
@ -427,7 +458,8 @@ public class FileUtils {
/** /**
* Unescape filename string obtained by escapeFileString(). * Unescape filename string obtained by escapeFileString().
* *
* @param filestring escaped string * @param filestring
* escaped string
* @return clean string * @return clean string
*/ */
public static String unescapeFileString(String filestring) public static String unescapeFileString(String filestring)
@ -442,7 +474,8 @@ public class FileUtils {
/** /**
* Escape filename, keeping the same extension * Escape filename, keeping the same extension
* *
* @param filename filename * @param filename
* filename
* @return escaped * @return escaped
*/ */
public static String escapeFilename(String filename) public static String escapeFilename(String filename)
@ -456,7 +489,8 @@ public class FileUtils {
/** /**
* Unescape filename, keeping the same extension * Unescape filename, keeping the same extension
* *
* @param filename escaped filename * @param filename
* escaped filename
* @return unesaped * @return unesaped
*/ */
public static String unescapeFilename(String filename) public static String unescapeFilename(String filename)
@ -482,8 +516,10 @@ public class FileUtils {
/** /**
* Copy resource to file * Copy resource to file
* *
* @param resname resource name * @param resname
* @param file out file * resource name
* @param file
* out file
* @throws IOException * @throws IOException
*/ */
public static void resourceToFile(String resname, File file) throws IOException public static void resourceToFile(String resname, File file) throws IOException
@ -516,7 +552,8 @@ public class FileUtils {
/** /**
* Get resource as string, safely closing streams. * Get resource as string, safely closing streams.
* *
* @param resname resource name * @param resname
* resource name
* @return resource as string, empty string on failure * @return resource as string, empty string on failure
*/ */
public static String resourceToString(String resname) public static String resourceToString(String resname)

@ -1,13 +1,11 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.File; import java.io.File;
public class OsUtils { public class OsUtils {
public static enum EnumOS public static enum EnumOS {
{
linux, macos, solaris, unknown, windows; linux, macos, solaris, unknown, windows;
public boolean isLinux() public boolean isLinux()

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -196,8 +195,10 @@ public class PropertyManager {
/** /**
* Set additional comment to a key * Set additional comment to a key
* *
* @param key key for comment * @param key
* @param comment the comment * key for comment
* @param comment
* the comment
*/ */
public void setKeyComment(String key, String comment) public void setKeyComment(String key, String comment)
{ {
@ -263,6 +264,7 @@ public class PropertyManager {
} }
} }
/** /**
* Helper class which loads Properties from UTF-8 file (Properties use * Helper class which loads Properties from UTF-8 file (Properties use
* "ISO-8859-1" by default) * "ISO-8859-1" by default)
@ -337,6 +339,7 @@ public class PropertyManager {
} }
} }
/** /**
* Property entry in Property manager. * Property entry in Property manager.
* *
@ -363,10 +366,14 @@ public class PropertyManager {
/** /**
* Property * Property
* *
* @param key key * @param key
* @param default_value default value * key
* @param entry_type type * @param default_value
* @param entry_comment entry comment * default value
* @param entry_type
* type
* @param entry_comment
* entry comment
*/ */
public Property(String key, boolean default_value, PropertyType entry_type, String entry_comment) { public Property(String key, boolean default_value, PropertyType entry_type, String entry_comment) {
name = key; name = key;
@ -379,10 +386,14 @@ public class PropertyManager {
/** /**
* Property entry * Property entry
* *
* @param key property key * @param key
* @param default_value default value * property key
* @param entry_type property type from enum * @param default_value
* @param entry_comment property comment or null * default value
* @param entry_type
* property type from enum
* @param entry_comment
* property comment or null
*/ */
public Property(String key, double default_value, PropertyType entry_type, String entry_comment) { public Property(String key, double default_value, PropertyType entry_type, String entry_comment) {
name = key; name = key;
@ -395,10 +406,14 @@ public class PropertyManager {
/** /**
* Property * Property
* *
* @param key key * @param key
* @param default_value default value * key
* @param entry_type type * @param default_value
* @param entry_comment entry comment * default value
* @param entry_type
* type
* @param entry_comment
* entry comment
*/ */
public Property(String key, String default_value, PropertyType entry_type, String entry_comment) { public Property(String key, String default_value, PropertyType entry_type, String entry_comment) {
name = key; name = key;
@ -476,7 +491,8 @@ public class PropertyManager {
/** /**
* Load property value from a file * Load property value from a file
* *
* @param string the string loaded * @param string
* the string loaded
* @return was OK * @return was OK
*/ */
public boolean parse(String string) public boolean parse(String string)
@ -581,11 +597,11 @@ public class PropertyManager {
} }
} }
/** /**
* Property types * Property types
*/ */
private enum PropertyType private enum PropertyType {
{
BOOLEAN, INT, STRING, DOUBLE; BOOLEAN, INT, STRING, DOUBLE;
} }
@ -610,8 +626,10 @@ public class PropertyManager {
/** /**
* Create property manager from file path and an initial comment. * Create property manager from file path and an initial comment.
* *
* @param file file with the props * @param file
* @param comment the initial comment. Use \n in it if you want. * 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.file = file;
@ -711,7 +729,8 @@ public class PropertyManager {
/** /**
* @param newlineBeforeComments put newline before comments * @param newlineBeforeComments
* put newline before comments
*/ */
public void cfgNewlineBeforeComments(boolean newlineBeforeComments) public void cfgNewlineBeforeComments(boolean newlineBeforeComments)
{ {
@ -720,7 +739,8 @@ public class PropertyManager {
/** /**
* @param separateSections do separate sections by newline * @param separateSections
* do separate sections by newline
*/ */
public void cfgSeparateSections(boolean separateSections) public void cfgSeparateSections(boolean separateSections)
{ {
@ -729,7 +749,8 @@ public class PropertyManager {
/** /**
* @param forceSave save even if unchanged. * @param forceSave
* save even if unchanged.
*/ */
public void cfgForceSave(boolean forceSave) public void cfgForceSave(boolean forceSave)
{ {
@ -738,7 +759,8 @@ public class PropertyManager {
/** /**
* @param validate enable validation * @param validate
* enable validation
*/ */
public void enableValidation(boolean validate) public void enableValidation(boolean validate)
{ {
@ -749,7 +771,8 @@ public class PropertyManager {
/** /**
* Get a property entry (rarely used) * Get a property entry (rarely used)
* *
* @param n key * @param n
* key
* @return the entry * @return the entry
*/ */
private Property get(String n) private Property get(String n)
@ -765,7 +788,8 @@ public class PropertyManager {
/** /**
* Get boolean property * Get boolean property
* *
* @param n key * @param n
* key
* @return the boolean found, or false * @return the boolean found, or false
*/ */
public Boolean getBoolean(String n) public Boolean getBoolean(String n)
@ -781,7 +805,8 @@ public class PropertyManager {
/** /**
* Get numeric property * Get numeric property
* *
* @param n key * @param n
* key
* @return the int found, or null * @return the int found, or null
*/ */
public Integer getInteger(String n) public Integer getInteger(String n)
@ -797,7 +822,8 @@ public class PropertyManager {
/** /**
* Get numeric property as double * Get numeric property as double
* *
* @param n key * @param n
* key
* @return the double found, or null * @return the double found, or null
*/ */
public Double getDouble(String n) public Double getDouble(String n)
@ -813,7 +839,8 @@ public class PropertyManager {
/** /**
* Get string property * Get string property
* *
* @param n key * @param n
* key
* @return the string found, or null * @return the string found, or null
*/ */
public String getString(String n) public String getString(String n)
@ -829,8 +856,10 @@ public class PropertyManager {
/** /**
* Add a boolean property * Add a boolean property
* *
* @param n key * @param n
* @param d default value * key
* @param d
* default value
*/ */
public void putBoolean(String n, boolean d) public void putBoolean(String n, boolean d)
{ {
@ -842,9 +871,12 @@ public class PropertyManager {
/** /**
* Add a boolean property * Add a boolean property
* *
* @param n key * @param n
* @param d default value * key
* @param comment the in-file comment * @param d
* default value
* @param comment
* the in-file comment
*/ */
public void putBoolean(String n, boolean d, String comment) public void putBoolean(String n, boolean d, String comment)
{ {
@ -856,8 +888,10 @@ public class PropertyManager {
/** /**
* Add a numeric property (double) * Add a numeric property (double)
* *
* @param n key * @param n
* @param d default value * key
* @param d
* default value
*/ */
public void putDouble(String n, int d) public void putDouble(String n, int d)
{ {
@ -869,9 +903,12 @@ public class PropertyManager {
/** /**
* Add a numeric property (double) * Add a numeric property (double)
* *
* @param n key * @param n
* @param d default value * key
* @param comment the in-file comment * @param d
* default value
* @param comment
* the in-file comment
*/ */
public void putDouble(String n, int d, String comment) public void putDouble(String n, int d, String comment)
{ {
@ -883,8 +920,10 @@ public class PropertyManager {
/** /**
* Add a numeric property * Add a numeric property
* *
* @param n key * @param n
* @param d default value * key
* @param d
* default value
*/ */
public void putInteger(String n, int d) public void putInteger(String n, int d)
{ {
@ -896,9 +935,12 @@ public class PropertyManager {
/** /**
* Add a numeric property * Add a numeric property
* *
* @param n key * @param n
* @param d default value * key
* @param comment the in-file comment * @param d
* default value
* @param comment
* the in-file comment
*/ */
public void putInteger(String n, int d, String comment) public void putInteger(String n, int d, String comment)
{ {
@ -910,8 +952,10 @@ public class PropertyManager {
/** /**
* Add a string property * Add a string property
* *
* @param n key * @param n
* @param d default value * key
* @param d
* default value
*/ */
public void putString(String n, String d) public void putString(String n, String d)
{ {
@ -923,9 +967,12 @@ public class PropertyManager {
/** /**
* Add a string property * Add a string property
* *
* @param n key * @param n
* @param d default value * key
* @param comment the in-file comment * @param d
* default value
* @param comment
* the in-file comment
*/ */
public void putString(String n, String d, String comment) public void putString(String n, String d, String comment)
{ {
@ -937,8 +984,10 @@ public class PropertyManager {
/** /**
* Rename key before doing "apply"; value is preserved * Rename key before doing "apply"; value is preserved
* *
* @param oldKey old key * @param oldKey
* @param newKey new key * old key
* @param newKey
* new key
*/ */
public void renameKey(String oldKey, String newKey) public void renameKey(String oldKey, String newKey)
{ {
@ -951,8 +1000,10 @@ public class PropertyManager {
* Set value saved to certain key; use to save runtime-changed configuration * Set value saved to certain key; use to save runtime-changed configuration
* values. * values.
* *
* @param key key * @param key
* @param value the saved value * key
* @param value
* the saved value
*/ */
public void setValue(String key, Object value) public void setValue(String key, Object value)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -26,7 +25,8 @@ public class SimpleConfig {
/** /**
* Load list from file * Load list from file
* *
* @param file file * @param file
* file
* @return map of keys and values * @return map of keys and values
* @throws IOException * @throws IOException
*/ */
@ -41,7 +41,8 @@ public class SimpleConfig {
/** /**
* Load map from file * Load map from file
* *
* @param file file * @param file
* file
* @return map of keys and values * @return map of keys and values
* @throws IOException * @throws IOException
*/ */
@ -56,7 +57,8 @@ public class SimpleConfig {
/** /**
* Load list from string * Load list from string
* *
* @param text text of the file * @param text
* text of the file
* @return map of keys and values * @return map of keys and values
*/ */
public static List<String> listFromString(String text) public static List<String> listFromString(String text)
@ -86,7 +88,8 @@ public class SimpleConfig {
/** /**
* Load map from string * Load map from string
* *
* @param text text of the file * @param text
* text of the file
* @return map of keys and values * @return map of keys and values
*/ */
public static Map<String, String> mapFromString(String text) public static Map<String, String> mapFromString(String text)
@ -142,7 +145,8 @@ public class SimpleConfig {
* *
* @param target * @param target
* @param data * @param data
* @param allowNulls allow nulls. * @param allowNulls
* allow nulls.
* @throws IOException * @throws IOException
*/ */
public static void mapToFile(File target, Map<String, String> data, boolean allowNulls) throws IOException public static void mapToFile(File target, Map<String, String> data, boolean allowNulls) throws IOException
@ -164,7 +168,7 @@ public class SimpleConfig {
lines.add(key + " = " + value); lines.add(key + " = " + value);
} }
String text = ""; //# File written by SimpleConfig String text = ""; // # File written by SimpleConfig
for (String s : lines) { for (String s : lines) {
if (text.length() > 0) text += "\n"; if (text.length() > 0) text += "\n";
@ -186,7 +190,7 @@ public class SimpleConfig {
*/ */
public static void listToFile(File target, List<String> data) throws IOException public static void listToFile(File target, List<String> data) throws IOException
{ {
String text = ""; //# File written by SimpleConfig String text = ""; // # File written by SimpleConfig
for (String s : data) { for (String s : data) {
if (text.length() > 0) text += "\n"; if (text.length() > 0) text += "\n";

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.*; import java.io.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -21,9 +20,10 @@ public class ZipBuilder {
/** /**
* @param target target zip file * @param target
* @throws FileNotFoundException if the file is directory or cannot be * target zip file
* created * @throws FileNotFoundException
* if the file is directory or cannot be created
*/ */
public ZipBuilder(File target) throws FileNotFoundException { public ZipBuilder(File target) throws FileNotFoundException {
target.getParentFile().mkdirs(); target.getParentFile().mkdirs();
@ -36,8 +36,10 @@ public class ZipBuilder {
/** /**
* Add stream to a path * Add stream to a path
* *
* @param path path * @param path
* @param in stream * path
* @param in
* stream
* @throws IOException * @throws IOException
*/ */
public void addStream(String path, InputStream in) throws IOException public void addStream(String path, InputStream in) throws IOException
@ -58,8 +60,10 @@ public class ZipBuilder {
/** /**
* Add string as a file * Add string as a file
* *
* @param path path * @param path
* @param text text to write * path
* @param text
* text to write
* @throws IOException * @throws IOException
*/ */
public void addString(String path, String text) throws IOException public void addString(String path, String text) throws IOException
@ -78,8 +82,10 @@ public class ZipBuilder {
/** /**
* Add resource obtained via FileUtils.getResource() * Add resource obtained via FileUtils.getResource()
* *
* @param path path * @param path
* @param resPath resource path * path
* @param resPath
* resource path
* @throws IOException * @throws IOException
*/ */
public void addResource(String path, String resPath) throws IOException public void addResource(String path, String resPath) throws IOException
@ -98,7 +104,8 @@ public class ZipBuilder {
/** /**
* Normalize path * Normalize path
* *
* @param path original path * @param path
* original path
* @return normalized path * @return normalized path
*/ */
private String preparePath(String path) private String preparePath(String path)

@ -1,6 +1,5 @@
package mightypork.utils.files; package mightypork.utils.files;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
@ -28,9 +27,12 @@ public class ZipUtils {
/** /**
* Extract zip file to target directory * Extract zip file to target directory
* *
* @param file zip file * @param file
* @param outputDir target directory * zip file
* @param filter string filter (will be used to test entry names (paths)) * @param outputDir
* target directory
* @param filter
* string filter (will be used to test entry names (paths))
* @return list of entries extracted (paths) * @return list of entries extracted (paths)
* @throws IOException * @throws IOException
*/ */
@ -46,7 +48,7 @@ public class ZipUtils {
try { try {
if (zip != null) zip.close(); if (zip != null) zip.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
} }
} }
@ -55,9 +57,12 @@ public class ZipUtils {
/** /**
* Extract zip file to target directory * Extract zip file to target directory
* *
* @param zip open zip file * @param zip
* @param outputDir target directory * open zip file
* @param filter string filter (will be used to test entry names (paths)) * @param outputDir
* target directory
* @param filter
* string filter (will be used to test entry names (paths))
* @return list of entries extracted (paths) * @return list of entries extracted (paths)
* @throws IOException * @throws IOException
*/ */
@ -96,9 +101,11 @@ public class ZipUtils {
/** /**
* Read zip entries and add their paths to a list * Read zip entries and add their paths to a list
* *
* @param zipFile open zip file * @param zipFile
* open zip file
* @return list of entry names * @return list of entry names
* @throws IOException on error * @throws IOException
* on error
*/ */
public static List<String> listZip(File zipFile) throws IOException public static List<String> listZip(File zipFile) throws IOException
{ {
@ -110,7 +117,7 @@ public class ZipUtils {
try { try {
if (zip != null) zip.close(); if (zip != null) zip.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
} }
} }
@ -119,9 +126,11 @@ public class ZipUtils {
/** /**
* Read zip entries and add their paths to a list * Read zip entries and add their paths to a list
* *
* @param zip open zip file * @param zip
* open zip file
* @return list of entry names * @return list of entry names
* @throws IOException on error * @throws IOException
* on error
*/ */
public static List<String> listZip(ZipFile zip) throws IOException public static List<String> listZip(ZipFile zip) throws IOException
{ {
@ -145,10 +154,14 @@ public class ZipUtils {
/** /**
* Extract one zip entry to target file * Extract one zip entry to target file
* *
* @param zip open zip file * @param zip
* @param entry entry from the zip file * open zip file
* @param destFile destination file ((NOT directory!) * @param entry
* @throws IOException on error * entry from the zip file
* @param destFile
* destination file ((NOT directory!)
* @throws IOException
* on error
*/ */
public static void extractZipEntry(ZipFile zip, ZipEntry entry, File destFile) throws IOException public static void extractZipEntry(ZipFile zip, ZipEntry entry, File destFile) throws IOException
{ {
@ -168,13 +181,13 @@ public class ZipUtils {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
try { try {
if (dest != null) dest.close(); if (dest != null) dest.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
} }
@ -184,10 +197,13 @@ public class ZipUtils {
/** /**
* Load zip entry to String * Load zip entry to String
* *
* @param zip open zip file * @param zip
* @param entry entry from the zip file * open zip file
* @param entry
* entry from the zip file
* @return loaded string * @return loaded string
* @throws IOException on error * @throws IOException
* on error
*/ */
public static String zipEntryToString(ZipFile zip, ZipEntry entry) throws IOException public static String zipEntryToString(ZipFile zip, ZipEntry entry) throws IOException
{ {
@ -200,7 +216,7 @@ public class ZipUtils {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
} }
} }
@ -219,7 +235,7 @@ public class ZipUtils {
try { try {
if (zf != null) zf.close(); if (zf != null) zf.close();
} catch (IOException e) { } catch (IOException e) {
//ignore // ignore
} }
} }

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -23,6 +22,7 @@ public abstract class AbstractIonList<T> extends ArrayList<T> implements Ionizab
byte b = StreamUtils.readByte(in); byte b = StreamUtils.readByte(in);
if (b == IonMarks.ENTRY) { if (b == IonMarks.ENTRY) {
@SuppressWarnings("unchecked")
T value = (T) Ion.readObject(in); T value = (T) Ion.readObject(in);
add(value); add(value);
} else if (b == IonMarks.END) { } else if (b == IonMarks.END) {
@ -58,19 +58,23 @@ public abstract class AbstractIonList<T> extends ArrayList<T> implements Ionizab
/** /**
* Read custom data of this AbstractIonList implementation * Read custom data of this AbstractIonList implementation
* *
* @param in input stream * @param in
* input stream
*/ */
public void ionReadCustomData(InputStream in) public void ionReadCustomData(InputStream in)
{} {
}
/** /**
* Write custom data of this AbstractIonList implementation * Write custom data of this AbstractIonList implementation
* *
* @param out output stream * @param out
* output stream
*/ */
public void ionWriteCustomData(OutputStream out) public void ionWriteCustomData(OutputStream out)
{} {
}
@Override @Override

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -37,13 +36,11 @@ public abstract class AbstractIonMap<V> extends LinkedHashMap<String, V> impleme
byte b = StreamUtils.readByte(in); byte b = StreamUtils.readByte(in);
if (b == IonMarks.ENTRY) { if (b == IonMarks.ENTRY) {
String key = StreamUtils.readStringBytes(in); String key = StreamUtils.readStringBytes(in);
V value;
try { @SuppressWarnings("unchecked")
value = (V) Ion.readObject(in); V value = (V) Ion.readObject(in);
put(key, value); put(key, value);
} catch (IonException e) {
e.printStackTrace();
}
} else if (b == IonMarks.END) { } else if (b == IonMarks.END) {
break; break;
} else { } else {
@ -77,19 +74,23 @@ public abstract class AbstractIonMap<V> extends LinkedHashMap<String, V> impleme
/** /**
* Read custom data of this AbstractIonMap implementation * Read custom data of this AbstractIonMap implementation
* *
* @param in input stream * @param in
* input stream
*/ */
public void ionReadCustomData(InputStream in) public void ionReadCustomData(InputStream in)
{} {
}
/** /**
* Write custom data of this AbstractIonMap implementation * Write custom data of this AbstractIonMap implementation
* *
* @param out output stream * @param out
* output stream
*/ */
public void ionWriteCustomData(OutputStream out) public void ionWriteCustomData(OutputStream out)
{} {
}
@Override @Override

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -32,8 +31,10 @@ public class Ion {
/** /**
* Register new Ionizable for direct reconstructing. * Register new Ionizable for direct reconstructing.
* *
* @param mark byte mark to be used, see {@link IonMarks} for reference. * @param mark
* @param objClass class of the registered Ionizable * byte mark to be used, see {@link IonMarks} for reference.
* @param objClass
* class of the registered Ionizable
* @throws IonException * @throws IonException
*/ */
public static void registerIonizable(byte mark, Class<?> objClass) throws IonException public static void registerIonizable(byte mark, Class<?> objClass) throws IonException
@ -48,7 +49,8 @@ public class Ion {
/** /**
* Load Ion object from file. * Load Ion object from file.
* *
* @param file file path * @param file
* file path
* @return the loaded object * @return the loaded object
* @throws IonException * @throws IonException
*/ */
@ -61,9 +63,11 @@ public class Ion {
/** /**
* Load Ion object from file. * Load Ion object from file.
* *
* @param file file * @param file
* file
* @return the loaded object * @return the loaded object
* @throws IonException on failure * @throws IonException
* on failure
*/ */
public static Object fromFile(File file) throws IonException public static Object fromFile(File file) throws IonException
{ {
@ -90,7 +94,8 @@ public class Ion {
/** /**
* Load Ion object from stream. * Load Ion object from stream.
* *
* @param in input stream * @param in
* input stream
* @return the loaded object * @return the loaded object
* @throws IonException * @throws IonException
*/ */
@ -103,8 +108,10 @@ public class Ion {
/** /**
* Store Ion object to file. * Store Ion object to file.
* *
* @param path file path * @param path
* @param obj object to store * file path
* @param obj
* object to store
* @throws IonException * @throws IonException
*/ */
public static void toFile(String path, Object obj) throws IonException public static void toFile(String path, Object obj) throws IonException
@ -116,8 +123,10 @@ public class Ion {
/** /**
* Store Ion object to file. * Store Ion object to file.
* *
* @param path file path * @param path
* @param obj object to store * file path
* @param obj
* object to store
* @throws IonException * @throws IonException
*/ */
public static void toFile(File path, Object obj) throws IonException public static void toFile(File path, Object obj) throws IonException
@ -153,8 +162,10 @@ public class Ion {
/** /**
* Store Ion object to output stream. * Store Ion object to output stream.
* *
* @param out output stream * * @param out
* @param obj object to store * output stream *
* @param obj
* object to store
* @throws IonException * @throws IonException
*/ */
public static void toStream(OutputStream out, Object obj) throws IonException public static void toStream(OutputStream out, Object obj) throws IonException
@ -166,7 +177,8 @@ public class Ion {
/** /**
* Read single ionizable or primitive object from input stream * Read single ionizable or primitive object from input stream
* *
* @param in input stream * @param in
* input stream
* @return the loaded object * @return the loaded object
* @throws IonException * @throws IonException
*/ */
@ -221,8 +233,10 @@ public class Ion {
/** /**
* Write single ionizable or primitive object to output stream * Write single ionizable or primitive object to output stream
* *
* @param out output stream * @param out
* @param obj stored object * output stream
* @param obj
* stored object
* @throws IonException * @throws IonException
*/ */
public static void writeObject(OutputStream out, Object obj) throws IonException public static void writeObject(OutputStream out, Object obj) throws IonException

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
public class IonException extends Exception { public class IonException extends Exception {
public IonException() { public IonException() {

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
/** /**
* Ionizable Arraylist * Ionizable Arraylist
* *

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
/** /**
* Ionizable HashMap * Ionizable HashMap
* *

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
/** /**
* Byte marks used to structure data in Ion files. * Byte marks used to structure data in Ion files.
* *

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -18,7 +17,8 @@ public interface Ionizable {
* Load data from the input stream. Mark has already been read, begin * Load data from the input stream. Mark has already been read, begin
* reading right after it. * reading right after it.
* *
* @param in input stream * @param in
* input stream
* @throws IonException * @throws IonException
*/ */
public void ionRead(InputStream in) throws IonException; public void ionRead(InputStream in) throws IonException;
@ -28,7 +28,8 @@ public interface Ionizable {
* Store data to output stream. mark has already been written, begin right * Store data to output stream. mark has already been written, begin right
* after it. * after it.
* *
* @param out Output stream * @param out
* Output stream
* @throws IonException * @throws IonException
*/ */
public void ionWrite(OutputStream out) throws IonException; public void ionWrite(OutputStream out) throws IonException;

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
/** /**
* Optional ionizable * Optional ionizable
* *

@ -1,6 +1,5 @@
package mightypork.utils.files.ion; package mightypork.utils.files.ion;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;

@ -1,6 +1,5 @@
package mightypork.utils.logging; package mightypork.utils.logging;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -14,7 +13,8 @@ public class Log {
/** /**
* Log FINE message in main logger * Log FINE message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void f1(String msg) public static void f1(String msg)
{ {
@ -25,7 +25,8 @@ public class Log {
/** /**
* Log FINER message in main logger * Log FINER message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void f2(String msg) public static void f2(String msg)
{ {
@ -36,7 +37,8 @@ public class Log {
/** /**
* Log FINEST message in main logger * Log FINEST message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void f3(String msg) public static void f3(String msg)
{ {
@ -47,7 +49,8 @@ public class Log {
/** /**
* Log INFO message in main logger * Log INFO message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void i(String msg) public static void i(String msg)
{ {
@ -58,7 +61,8 @@ public class Log {
/** /**
* Log WARNING message in main logger * Log WARNING message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void w(String msg) public static void w(String msg)
{ {
@ -69,7 +73,8 @@ public class Log {
/** /**
* Log ERROR message in main logger * Log ERROR message in main logger
* *
* @param msg message * @param msg
* message
*/ */
public static void e(String msg) public static void e(String msg)
{ {
@ -80,8 +85,10 @@ public class Log {
/** /**
* Log EXCEPTION and ERROR message in main logger * Log EXCEPTION and ERROR message in main logger
* *
* @param msg message * @param msg
* @param thrown thrown exception * message
* @param thrown
* thrown exception
*/ */
public static void e(String msg, Throwable thrown) public static void e(String msg, Throwable thrown)
{ {
@ -92,7 +99,8 @@ public class Log {
/** /**
* Log EXCEPTION in main logger * Log EXCEPTION in main logger
* *
* @param thrown thrown exception * @param thrown
* thrown exception
*/ */
public static void e(Throwable thrown) public static void e(Throwable thrown)
{ {
@ -109,7 +117,8 @@ public class Log {
/** /**
* Enable / disable static log delegate methods * Enable / disable static log delegate methods
* *
* @param flag enable * @param flag
* enable
*/ */
public static void enableStaticLogging(boolean flag) public static void enableStaticLogging(boolean flag)
{ {
@ -124,10 +133,12 @@ public class Log {
* Create a logger. If this is the first logger made, then it'll be made * Create a logger. If this is the first logger made, then it'll be made
* available via the static methods. * available via the static methods.
* *
* @param logName log name (used for filename, must be application-unique) * @param logName
* @param logsDir directory to store logs in * log name (used for filename, must be application-unique)
* @param oldLogsCount number of old logs to keep, -1 for infinite, 0 for * @param logsDir
* none. * directory to store logs in
* @param oldLogsCount
* number of old logs to keep, -1 for infinite, 0 for none.
* @return the created Log instance * @return the created Log instance
*/ */
public static synchronized LogInstance create(String logName, File logsDir, int oldLogsCount) public static synchronized LogInstance create(String logName, File logsDir, int oldLogsCount)
@ -146,8 +157,10 @@ public class Log {
* available via the static methods.<br> * available via the static methods.<br>
* Old logs will be kept. * Old logs will be kept.
* *
* @param logName log name (used for filename, must be application-unique) * @param logName
* @param logsDir directory to store logs in * log name (used for filename, must be application-unique)
* @param logsDir
* directory to store logs in
* @return the created Log instance * @return the created Log instance
*/ */
public static synchronized LogInstance create(String logName, File logsDir) public static synchronized LogInstance create(String logName, File logsDir)

@ -1,6 +1,5 @@
package mightypork.utils.logging; package mightypork.utils.logging;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -151,7 +150,8 @@ public class LogInstance {
/** /**
* Add log monitor * Add log monitor
* *
* @param mon monitor * @param mon
* monitor
* @return assigned ID * @return assigned ID
*/ */
public synchronized int addMonitor(LogMonitor mon) public synchronized int addMonitor(LogMonitor mon)
@ -166,7 +166,8 @@ public class LogInstance {
/** /**
* Remove a monitor by ID * Remove a monitor by ID
* *
* @param id monitor ID * @param id
* monitor ID
*/ */
public synchronized void removeMonitor(int id) public synchronized void removeMonitor(int id)
{ {
@ -177,7 +178,8 @@ public class LogInstance {
/** /**
* Enable logging. * Enable logging.
* *
* @param flag do enable logging * @param flag
* do enable logging
*/ */
public void enable(boolean flag) public void enable(boolean flag)
{ {
@ -188,7 +190,8 @@ public class LogInstance {
/** /**
* Enable printing logs to sysout * Enable printing logs to sysout
* *
* @param flag do enable logging * @param flag
* do enable logging
*/ */
public void enableSysout(boolean flag) public void enableSysout(boolean flag)
{ {
@ -200,7 +203,8 @@ public class LogInstance {
/** /**
* Log FINE message * Log FINE message
* *
* @param msg message * @param msg
* message
*/ */
public void f1(String msg) public void f1(String msg)
{ {
@ -211,7 +215,8 @@ public class LogInstance {
/** /**
* Log FINER message * Log FINER message
* *
* @param msg message * @param msg
* message
*/ */
public void f2(String msg) public void f2(String msg)
{ {
@ -222,7 +227,8 @@ public class LogInstance {
/** /**
* Log FINEST message * Log FINEST message
* *
* @param msg message * @param msg
* message
*/ */
public void f3(String msg) public void f3(String msg)
{ {
@ -233,7 +239,8 @@ public class LogInstance {
/** /**
* Log INFO message * Log INFO message
* *
* @param msg message * @param msg
* message
*/ */
public void i(String msg) public void i(String msg)
{ {
@ -244,7 +251,8 @@ public class LogInstance {
/** /**
* Log WARNING message (less severe than ERROR) * Log WARNING message (less severe than ERROR)
* *
* @param msg message * @param msg
* message
*/ */
public void w(String msg) public void w(String msg)
{ {
@ -255,7 +263,8 @@ public class LogInstance {
/** /**
* Log ERROR message * Log ERROR message
* *
* @param msg message * @param msg
* message
*/ */
public void e(String msg) public void e(String msg)
{ {
@ -266,8 +275,10 @@ public class LogInstance {
/** /**
* Log THROWING message * Log THROWING message
* *
* @param msg message * @param msg
* @param thrown thrown exception * message
* @param thrown
* thrown exception
*/ */
public void e(String msg, Throwable thrown) public void e(String msg, Throwable thrown)
{ {
@ -278,7 +289,8 @@ public class LogInstance {
/** /**
* Log exception thrown * Log exception thrown
* *
* @param thrown thrown exception * @param thrown
* thrown exception
*/ */
public void e(Throwable thrown) public void e(Throwable thrown)
{ {
@ -302,6 +314,7 @@ public class LogInstance {
return sw.toString(); return sw.toString();
} }
/** /**
* PowerCraft Log file formatter. * PowerCraft Log file formatter.
* *

@ -1,6 +1,5 @@
package mightypork.utils.logging; package mightypork.utils.logging;
import java.util.logging.Level; import java.util.logging.Level;

@ -1,6 +1,5 @@
package mightypork.utils.logging; package mightypork.utils.logging;
import java.util.logging.Level; import java.util.logging.Level;

@ -1,6 +1,5 @@
package mightypork.utils.math; package mightypork.utils.math;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -26,9 +25,12 @@ public class Calc {
/** /**
* Get distance from 2D line to 2D point [X,Y] * Get distance from 2D line to 2D point [X,Y]
* *
* @param lineDirVec line directional vector * @param lineDirVec
* @param linePoint point of line * line directional vector
* @param point point coordinate * @param linePoint
* point of line
* @param point
* point coordinate
* @return distance * @return distance
*/ */
public static double linePointDist(Coord lineDirVec, Coord linePoint, Coord point) public static double linePointDist(Coord lineDirVec, Coord linePoint, Coord point)
@ -54,9 +56,12 @@ public class Calc {
/** /**
* Get distance from 2D line to 2D point [X,Z] * Get distance from 2D line to 2D point [X,Z]
* *
* @param lineDirVec line directional vector * @param lineDirVec
* @param linePoint point of line * line directional vector
* @param point point coordinate * @param linePoint
* point of line
* @param point
* point coordinate
* @return distance * @return distance
*/ */
public static double linePointDistXZ(Coord lineDirVec, Coord linePoint, Coord point) public static double linePointDistXZ(Coord lineDirVec, Coord linePoint, Coord point)
@ -68,8 +73,10 @@ public class Calc {
/** /**
* Get longest side of a right-angled triangle * Get longest side of a right-angled triangle
* *
* @param a side a (opposite) * @param a
* @param b side b (adjacent) * side a (opposite)
* @param b
* side b (adjacent)
* @return longest side (hypotenuse) * @return longest side (hypotenuse)
*/ */
public static double pythC(double a, double b) public static double pythC(double a, double b)
@ -81,8 +88,10 @@ public class Calc {
/** /**
* Get adjacent side of a right-angled triangle * Get adjacent side of a right-angled triangle
* *
* @param a side a (opposite) * @param a
* @param c side c (hypotenuse) * side a (opposite)
* @param c
* side c (hypotenuse)
* @return side b (adjacent) * @return side b (adjacent)
*/ */
public static double pythB(double a, double c) public static double pythB(double a, double c)
@ -94,8 +103,10 @@ public class Calc {
/** /**
* Get opposite side of a right-angled triangle * Get opposite side of a right-angled triangle
* *
* @param b side b (adjacent) * @param b
* @param c side c (hypotenuse) * side b (adjacent)
* @param c
* side c (hypotenuse)
* @return side a (opposite) * @return side a (opposite)
*/ */
public static double pythA(double b, double c) public static double pythA(double b, double c)
@ -103,6 +114,7 @@ public class Calc {
return Math.sqrt(square(c) - square(b)); return Math.sqrt(square(c) - square(b));
} }
private static class Angles { private static class Angles {
public static double delta(double alpha, double beta, double a360) public static double delta(double alpha, double beta, double a360)
@ -126,6 +138,7 @@ public class Calc {
} }
} }
/** /**
* Calc subclass with buffer utils. * Calc subclass with buffer utils.
* *
@ -136,7 +149,8 @@ public class Calc {
/** /**
* Create java.nio.FloatBuffer of given floats, and flip it. * Create java.nio.FloatBuffer of given floats, and flip it.
* *
* @param obj floats or float array * @param obj
* floats or float array
* @return float buffer * @return float buffer
*/ */
public static FloatBuffer mkFillBuff(float... obj) public static FloatBuffer mkFillBuff(float... obj)
@ -161,7 +175,8 @@ public class Calc {
/** /**
* Create new java.nio.FloatBuffer of given length * Create new java.nio.FloatBuffer of given length
* *
* @param count elements * @param count
* elements
* @return the new java.nio.FloatBuffer * @return the new java.nio.FloatBuffer
*/ */
public static FloatBuffer alloc(int count) public static FloatBuffer alloc(int count)
@ -171,6 +186,7 @@ public class Calc {
} }
/** /**
* Angle calculations for degrees. * Angle calculations for degrees.
* *
@ -193,8 +209,10 @@ public class Calc {
/** /**
* Subtract two angles alpha - beta * Subtract two angles alpha - beta
* *
* @param alpha first angle * @param alpha
* @param beta second angle * first angle
* @param beta
* second angle
* @return (alpha - beta) in degrees * @return (alpha - beta) in degrees
*/ */
public static double delta(double alpha, double beta) public static double delta(double alpha, double beta)
@ -206,8 +224,10 @@ public class Calc {
/** /**
* Difference of two angles (absolute value of delta) * Difference of two angles (absolute value of delta)
* *
* @param alpha first angle * @param alpha
* @param beta second angle * first angle
* @param beta
* second angle
* @return difference in radians * @return difference in radians
*/ */
public static double diff(double alpha, double beta) public static double diff(double alpha, double beta)
@ -219,7 +239,8 @@ public class Calc {
/** /**
* Cosinus in degrees * Cosinus in degrees
* *
* @param deg angle in degrees * @param deg
* angle in degrees
* @return cosinus * @return cosinus
*/ */
public static double cos(double deg) public static double cos(double deg)
@ -231,7 +252,8 @@ public class Calc {
/** /**
* Sinus in degrees * Sinus in degrees
* *
* @param deg angle in degrees * @param deg
* angle in degrees
* @return sinus * @return sinus
*/ */
public static double sin(double deg) public static double sin(double deg)
@ -243,7 +265,8 @@ public class Calc {
/** /**
* Tangents in degrees * Tangents in degrees
* *
* @param deg angle in degrees * @param deg
* angle in degrees
* @return tangents * @return tangents
*/ */
public static double tan(double deg) public static double tan(double deg)
@ -255,7 +278,8 @@ public class Calc {
/** /**
* Angle normalized to 0-360 range * Angle normalized to 0-360 range
* *
* @param angle angle to normalize * @param angle
* angle to normalize
* @return normalized angle * @return normalized angle
*/ */
public static double norm(double angle) public static double norm(double angle)
@ -267,7 +291,8 @@ public class Calc {
/** /**
* Convert to radians * Convert to radians
* *
* @param deg degrees * @param deg
* degrees
* @return radians * @return radians
*/ */
public static double toRad(double deg) public static double toRad(double deg)
@ -279,8 +304,10 @@ public class Calc {
/** /**
* Round angle to 0,45,90,135... * Round angle to 0,45,90,135...
* *
* @param deg angle in deg. to round * @param deg
* @param x rounding increment (45 - round to 0,45,90...) * angle in deg. to round
* @param x
* rounding increment (45 - round to 0,45,90...)
* @return rounded * @return rounded
*/ */
public static int roundX(double deg, double x) public static int roundX(double deg, double x)
@ -298,7 +325,8 @@ public class Calc {
/** /**
* Round angle to 0,45,90,135... * Round angle to 0,45,90,135...
* *
* @param deg angle in deg. to round * @param deg
* angle in deg. to round
* @return rounded * @return rounded
*/ */
public static int round45(double deg) public static int round45(double deg)
@ -310,7 +338,8 @@ public class Calc {
/** /**
* Round angle to 0,90,180,270 * Round angle to 0,90,180,270
* *
* @param deg angle in deg. to round * @param deg
* angle in deg. to round
* @return rounded * @return rounded
*/ */
public static int round90(double deg) public static int round90(double deg)
@ -322,7 +351,8 @@ public class Calc {
/** /**
* Round angle to 0,15,30,45,60,75,90... * Round angle to 0,15,30,45,60,75,90...
* *
* @param deg angle in deg to round * @param deg
* angle in deg to round
* @return rounded * @return rounded
*/ */
public static int round15(double deg) public static int round15(double deg)
@ -331,6 +361,7 @@ public class Calc {
} }
} }
/** /**
* Angle calculations for radians. * Angle calculations for radians.
* *
@ -353,8 +384,10 @@ public class Calc {
/** /**
* Subtract two angles alpha - beta * Subtract two angles alpha - beta
* *
* @param alpha first angle * @param alpha
* @param beta second angle * first angle
* @param beta
* second angle
* @return (alpha - beta) in radians * @return (alpha - beta) in radians
*/ */
public static double delta(double alpha, double beta) public static double delta(double alpha, double beta)
@ -366,8 +399,10 @@ public class Calc {
/** /**
* Difference of two angles (absolute value of delta) * Difference of two angles (absolute value of delta)
* *
* @param alpha first angle * @param alpha
* @param beta second angle * first angle
* @param beta
* second angle
* @return difference in radians * @return difference in radians
*/ */
public static double diff(double alpha, double beta) public static double diff(double alpha, double beta)
@ -379,7 +414,8 @@ public class Calc {
/** /**
* Cos * Cos
* *
* @param rad angle in rads * @param rad
* angle in rads
* @return cos * @return cos
*/ */
public static double cos(double rad) public static double cos(double rad)
@ -391,7 +427,8 @@ public class Calc {
/** /**
* Sin * Sin
* *
* @param rad angle in rads * @param rad
* angle in rads
* @return sin * @return sin
*/ */
public static double sin(double rad) public static double sin(double rad)
@ -403,7 +440,8 @@ public class Calc {
/** /**
* Tan * Tan
* *
* @param rad angle in rads * @param rad
* angle in rads
* @return tan * @return tan
*/ */
public static double tan(double rad) public static double tan(double rad)
@ -415,7 +453,8 @@ public class Calc {
/** /**
* Angle normalized to 0-2*PI range * Angle normalized to 0-2*PI range
* *
* @param angle angle to normalize * @param angle
* angle to normalize
* @return normalized angle * @return normalized angle
*/ */
public static double norm(double angle) public static double norm(double angle)
@ -427,7 +466,8 @@ public class Calc {
/** /**
* Convert to degrees * Convert to degrees
* *
* @param rad radians * @param rad
* radians
* @return degrees * @return degrees
*/ */
public static double toDeg(double rad) public static double toDeg(double rad)
@ -442,7 +482,8 @@ public class Calc {
/** /**
* Get volume of a sphere * Get volume of a sphere
* *
* @param radius sphere radius * @param radius
* sphere radius
* @return volume in cubic units * @return volume in cubic units
*/ */
public static double sphereGetVolume(double radius) public static double sphereGetVolume(double radius)
@ -454,7 +495,8 @@ public class Calc {
/** /**
* Get radius of a sphere * Get radius of a sphere
* *
* @param volume sphere volume * @param volume
* sphere volume
* @return radius in units * @return radius in units
*/ */
public static double sphereGetRadius(double volume) public static double sphereGetRadius(double volume)
@ -466,7 +508,8 @@ public class Calc {
/** /**
* Get surface of a circle * Get surface of a circle
* *
* @param radius circle radius * @param radius
* circle radius
* @return volume in square units * @return volume in square units
*/ */
public static double circleGetSurface(double radius) public static double circleGetSurface(double radius)
@ -478,7 +521,8 @@ public class Calc {
/** /**
* Get radius of a circle * Get radius of a circle
* *
* @param surface circle volume * @param surface
* circle volume
* @return radius in units * @return radius in units
*/ */
public static double circleGetRadius(double surface) public static double circleGetRadius(double surface)
@ -503,9 +547,12 @@ public class Calc {
/** /**
* Private clamping helper. * Private clamping helper.
* *
* @param number number to be clamped * @param number
* @param min min value * number to be clamped
* @param max max value * @param min
* min value
* @param max
* max value
* @return clamped double * @return clamped double
*/ */
private static double clamp_double(Number number, Number min, Number max) private static double clamp_double(Number number, Number min, Number max)
@ -523,8 +570,10 @@ public class Calc {
/** /**
* Private clamping helper. * Private clamping helper.
* *
* @param number number to be clamped * @param number
* @param min min value * number to be clamped
* @param min
* min value
* @return clamped double * @return clamped double
*/ */
private static double clamp_double(Number number, Number min) private static double clamp_double(Number number, Number min)
@ -540,9 +589,12 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* DOUBLE version * DOUBLE version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param max maximal allowed value * @param min
* minimal allowed value
* @param max
* maximal allowed value
* @return result * @return result
*/ */
public static double clampd(Number number, Number min, Number max) public static double clampd(Number number, Number min, Number max)
@ -555,9 +607,12 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* FLOAT version * FLOAT version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param max maximal allowed value * @param min
* minimal allowed value
* @param max
* maximal allowed value
* @return result * @return result
*/ */
public static float clampf(Number number, Number min, Number max) public static float clampf(Number number, Number min, Number max)
@ -570,9 +625,12 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* INTEGER version * INTEGER version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param max maximal allowed value * @param min
* minimal allowed value
* @param max
* maximal allowed value
* @return result * @return result
*/ */
public static int clampi(Number number, Number min, Number max) public static int clampi(Number number, Number min, Number max)
@ -585,8 +643,10 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* INTEGER version * INTEGER version
* *
* @param number clamped number * @param number
* @param range range * clamped number
* @param range
* range
* @return result * @return result
*/ */
public static int clampi(Number number, Range range) public static int clampi(Number number, Range range)
@ -599,8 +659,10 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* DOUBLE version * DOUBLE version
* *
* @param number clamped number * @param number
* @param range range * clamped number
* @param range
* range
* @return result * @return result
*/ */
public static double clampd(Number number, Range range) public static double clampd(Number number, Range range)
@ -613,8 +675,10 @@ public class Calc {
* Clamp number to min and max bounds, inclusive.<br> * Clamp number to min and max bounds, inclusive.<br>
* FLOAT version * FLOAT version
* *
* @param number clamped number * @param number
* @param range range * clamped number
* @param range
* range
* @return result * @return result
*/ */
public static float clampf(Number number, Range range) public static float clampf(Number number, Range range)
@ -627,8 +691,10 @@ public class Calc {
* Clamp number to min and infinite bounds, inclusive.<br> * Clamp number to min and infinite bounds, inclusive.<br>
* DOUBLE version * DOUBLE version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param min
* minimal allowed value
* @return result * @return result
*/ */
public static double clampd(Number number, Number min) public static double clampd(Number number, Number min)
@ -641,8 +707,10 @@ public class Calc {
* Clamp number to min and infinite bounds, inclusive.<br> * Clamp number to min and infinite bounds, inclusive.<br>
* FLOAT version * FLOAT version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param min
* minimal allowed value
* @return result * @return result
*/ */
public static float clampf(Number number, Number min) public static float clampf(Number number, Number min)
@ -655,8 +723,10 @@ public class Calc {
* Clamp number to min and infinite bounds, inclusive.<br> * Clamp number to min and infinite bounds, inclusive.<br>
* INTEGER version * INTEGER version
* *
* @param number clamped number * @param number
* @param min minimal allowed value * clamped number
* @param min
* minimal allowed value
* @return result * @return result
*/ */
public static int clampi(Number number, Number min) public static int clampi(Number number, Number min)
@ -668,7 +738,8 @@ public class Calc {
/** /**
* Get class simple name * Get class simple name
* *
* @param obj object * @param obj
* object
* @return simple name * @return simple name
*/ */
public static String cname(Object obj) public static String cname(Object obj)
@ -681,7 +752,8 @@ public class Calc {
/** /**
* Cube a double * Cube a double
* *
* @param a squared double * @param a
* squared double
* @return square * @return square
*/ */
public static double cube(double a) public static double cube(double a)
@ -693,7 +765,8 @@ public class Calc {
/** /**
* Convert double to string, remove the mess at the end. * Convert double to string, remove the mess at the end.
* *
* @param d double * @param d
* double
* @return string * @return string
*/ */
public static String doubleToString(double d) public static String doubleToString(double d)
@ -709,7 +782,8 @@ public class Calc {
/** /**
* Convert float to string, remove the mess at the end. * Convert float to string, remove the mess at the end.
* *
* @param f float * @param f
* float
* @return string * @return string
*/ */
public static String floatToString(float f) public static String floatToString(float f)
@ -725,9 +799,12 @@ public class Calc {
/** /**
* Check if number is in range * Check if number is in range
* *
* @param number checked * @param number
* @param left lower end * checked
* @param right upper end * @param left
* lower end
* @param right
* upper end
* @return is in range * @return is in range
*/ */
public static boolean inRange(double number, double left, double right) public static boolean inRange(double number, double left, double right)
@ -739,10 +816,14 @@ public class Calc {
/** /**
* Get number from A to B at delta time (tween A to B) * Get number from A to B at delta time (tween A to B)
* *
* @param from last number * @param from
* @param to new number * last number
* @param time time 0..1 * @param to
* @param easing easing function * new number
* @param time
* time 0..1
* @param easing
* easing function
* @return current number to render * @return current number to render
*/ */
public static double interpolate(double from, double to, double time, Easing easing) public static double interpolate(double from, double to, double time, Easing easing)
@ -754,10 +835,14 @@ public class Calc {
/** /**
* Get angle [degrees] from A to B at delta time (tween A to B) * Get angle [degrees] from A to B at delta time (tween A to B)
* *
* @param from last angle * @param from
* @param to new angle * last angle
* @param time time 0..1 * @param to
* @param easing easing function * new angle
* @param time
* time 0..1
* @param easing
* easing function
* @return current angle to render * @return current angle to render
*/ */
public static double interpolateDeg(double from, double to, double time, Easing easing) public static double interpolateDeg(double from, double to, double time, Easing easing)
@ -769,10 +854,14 @@ public class Calc {
/** /**
* Get angle [radians] from A to B at delta time (tween A to B) * Get angle [radians] from A to B at delta time (tween A to B)
* *
* @param from last angle * @param from
* @param to new angle * last angle
* @param time time 0..1 * @param to
* @param easing easing function * new angle
* @param time
* time 0..1
* @param easing
* easing function
* @return current angle to render * @return current angle to render
*/ */
public static double interpolateRad(double from, double to, double time, Easing easing) public static double interpolateRad(double from, double to, double time, Easing easing)
@ -784,7 +873,8 @@ public class Calc {
/** /**
* Get highest number of a list * Get highest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static double max(double... numbers) public static double max(double... numbers)
@ -800,7 +890,8 @@ public class Calc {
/** /**
* Get highest number of a list * Get highest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static float max(float... numbers) public static float max(float... numbers)
@ -816,7 +907,8 @@ public class Calc {
/** /**
* Get highest number of a list * Get highest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static int max(int... numbers) public static int max(int... numbers)
@ -832,7 +924,8 @@ public class Calc {
/** /**
* Get lowest number of a list * Get lowest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static double min(double... numbers) public static double min(double... numbers)
@ -848,7 +941,8 @@ public class Calc {
/** /**
* Get lowest number of a list * Get lowest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static float min(float... numbers) public static float min(float... numbers)
@ -864,7 +958,8 @@ public class Calc {
/** /**
* Get lowest number of a list * Get lowest number of a list
* *
* @param numbers numbers * @param numbers
* numbers
* @return lowest * @return lowest
*/ */
public static int min(int... numbers) public static int min(int... numbers)
@ -880,7 +975,8 @@ public class Calc {
/** /**
* Split comma separated list of integers. * Split comma separated list of integers.
* *
* @param list String containing the list. * @param list
* String containing the list.
* @return array of integers or null. * @return array of integers or null.
*/ */
public static List<Integer> parseIntList(String list) public static List<Integer> parseIntList(String list)
@ -895,7 +991,8 @@ public class Calc {
for (String part : parts) { for (String part : parts) {
try { try {
intList.add(Integer.parseInt(part)); intList.add(Integer.parseInt(part));
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
} }
return intList; return intList;
@ -906,7 +1003,8 @@ public class Calc {
/** /**
* Pick random element from a given list. * Pick random element from a given list.
* *
* @param list list of choices * @param list
* list of choices
* @return picked element * @return picked element
*/ */
public static Object pick(List<?> list) public static Object pick(List<?> list)
@ -919,7 +1017,8 @@ public class Calc {
/** /**
* Square a double * Square a double
* *
* @param a squared double * @param a
* squared double
* @return square * @return square
*/ */
public static double square(double a) public static double square(double a)

@ -1,6 +1,5 @@
package mightypork.utils.math; package mightypork.utils.math;
import mightypork.utils.math.Calc.Deg; import mightypork.utils.math.Calc.Deg;
import mightypork.utils.math.Calc.Rad; import mightypork.utils.math.Calc.Rad;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -23,8 +22,10 @@ public class Polar {
/** /**
* Create a polar * Create a polar
* *
* @param angle angle in RAD * @param angle
* @param distance distance from origin * angle in RAD
* @param distance
* distance from origin
*/ */
public Polar(double angle, double distance) { public Polar(double angle, double distance) {
this(angle, false, distance); this(angle, false, distance);
@ -34,9 +35,12 @@ public class Polar {
/** /**
* Create a polar * Create a polar
* *
* @param angle angle * @param angle
* @param deg angle is in DEG * angle
* @param distance radius * @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.radius = distance;
@ -63,7 +67,8 @@ public class Polar {
/** /**
* @param angle angle in RAD * @param angle
* angle in RAD
*/ */
public void setAngle(double angle) public void setAngle(double angle)
{ {
@ -72,7 +77,8 @@ public class Polar {
/** /**
* @param angle angle in DEG * @param angle
* angle in DEG
*/ */
public void setAngleDeg(double angle) public void setAngleDeg(double angle)
{ {
@ -90,7 +96,8 @@ public class Polar {
/** /**
* @param r radius * @param r
* radius
*/ */
public void setRadius(double r) public void setRadius(double r)
{ {
@ -101,7 +108,8 @@ public class Polar {
/** /**
* Make polar from coord * Make polar from coord
* *
* @param coord coord * @param coord
* coord
* @return polar * @return polar
*/ */
public static Polar fromCoord(Coord coord) public static Polar fromCoord(Coord coord)
@ -113,8 +121,10 @@ public class Polar {
/** /**
* Make polar from coords * Make polar from coords
* *
* @param x x coord * @param x
* @param y y coord * x coord
* @param y
* y coord
* @return polar * @return polar
*/ */
public static Polar fromCoord(double x, double y) public static Polar fromCoord(double x, double y)

@ -1,6 +1,5 @@
package mightypork.utils.math; package mightypork.utils.math;
import java.util.Random; import java.util.Random;
@ -20,14 +19,17 @@ public class Range {
/** /**
* Implicit range constructor 0-1 * Implicit range constructor 0-1
*/ */
public Range() {} public Range() {
}
/** /**
* Create new range * Create new range
* *
* @param min min number * @param min
* @param max max number * min number
* @param max
* max number
*/ */
public Range(double min, double max) { public Range(double min, double max) {
if (min > max) { if (min > max) {
@ -43,7 +45,8 @@ public class Range {
/** /**
* Create new range * Create new range
* *
* @param minmax min = max number * @param minmax
* min = max number
*/ */
public Range(double minmax) { public Range(double minmax) {
this.min = minmax; this.min = minmax;
@ -120,7 +123,8 @@ public class Range {
/** /**
* Set min * Set min
* *
* @param min min value * @param min
* min value
*/ */
public void setMin(double min) public void setMin(double min)
{ {
@ -131,7 +135,8 @@ public class Range {
/** /**
* Set max * Set max
* *
* @param max max value * @param max
* max value
*/ */
public void setMax(double max) public void setMax(double max)
{ {
@ -160,7 +165,8 @@ public class Range {
/** /**
* Set to value of other range * Set to value of other range
* *
* @param other copied range * @param other
* copied range
*/ */
public void setTo(Range other) public void setTo(Range other)
{ {
@ -179,8 +185,10 @@ public class Range {
/** /**
* Set to min-max values * Set to min-max values
* *
* @param min min value * @param min
* @param max max value * min value
* @param max
* max value
*/ */
public void setTo(double min, double max) public void setTo(double min, double max)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.math.color; package mightypork.utils.math.color;
import java.awt.Color; import java.awt.Color;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -24,7 +23,8 @@ public class HSV {
/** /**
* Create black color 0,0,0 * Create black color 0,0,0
*/ */
public HSV() {} public HSV() {
}
/** /**
@ -72,7 +72,8 @@ public class HSV {
/** /**
* Set color to other color * Set color to other color
* *
* @param copied copied color * @param copied
* copied color
* @return this * @return this
*/ */
public HSV setTo(HSV copied) public HSV setTo(HSV copied)
@ -89,9 +90,12 @@ public class HSV {
/** /**
* Set to H,S,V 0-1 * Set to H,S,V 0-1
* *
* @param h hue * @param h
* @param s saturation * hue
* @param v value * @param s
* saturation
* @param v
* value
* @return this * @return this
*/ */
public HSV setTo(Number h, Number s, Number v) public HSV setTo(Number h, Number s, Number v)
@ -133,7 +137,8 @@ public class HSV {
/** /**
* Make from RGB * Make from RGB
* *
* @param color RGB * @param color
* RGB
* @return HSV * @return HSV
*/ */
public static HSV fromRGB(RGB color) public static HSV fromRGB(RGB color)

@ -1,6 +1,5 @@
package mightypork.utils.math.color; package mightypork.utils.math.color;
import java.awt.Color; import java.awt.Color;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -47,13 +46,15 @@ public class RGB {
/** /**
* Create black color 0,0,0 * Create black color 0,0,0
*/ */
public RGB() {} public RGB() {
}
/** /**
* Get copy with custom alpha * Get copy with custom alpha
* *
* @param alpha alpha to set * @param alpha
* alpha to set
* @return copy w/ alpha * @return copy w/ alpha
*/ */
public RGB setAlpha(double alpha) public RGB setAlpha(double alpha)
@ -65,7 +66,8 @@ public class RGB {
/** /**
* set alpha IP * set alpha IP
* *
* @param alpha alpha to set * @param alpha
* alpha to set
* @return this * @return this
*/ */
public RGB setAlpha_ip(double alpha) public RGB setAlpha_ip(double alpha)
@ -90,7 +92,8 @@ public class RGB {
/** /**
* Get copy with alpha multiplied by custom value * Get copy with alpha multiplied by custom value
* *
* @param alpha alpha to set * @param alpha
* alpha to set
* @return copy w/ alpha * @return copy w/ alpha
*/ */
public RGB mulAlpha(double alpha) public RGB mulAlpha(double alpha)
@ -102,7 +105,8 @@ public class RGB {
/** /**
* Multiply alpha by given number * Multiply alpha by given number
* *
* @param alpha alpha multiplier * @param alpha
* alpha multiplier
* @return this * @return this
*/ */
public RGB mulAlpha_ip(double alpha) public RGB mulAlpha_ip(double alpha)
@ -116,9 +120,12 @@ public class RGB {
/** /**
* Color from RGB 0-1 * Color from RGB 0-1
* *
* @param r red * @param r
* @param g green * red
* @param b blue * @param g
* green
* @param b
* blue
*/ */
public RGB(Number r, Number g, Number b) { public RGB(Number r, Number g, Number b) {
this.r = r.doubleValue(); this.r = r.doubleValue();
@ -131,10 +138,14 @@ public class RGB {
/** /**
* Color from RGB 0-1 * Color from RGB 0-1
* *
* @param r red * @param r
* @param g green * red
* @param b blue * @param g
* @param a alpha * green
* @param b
* blue
* @param a
* alpha
*/ */
public RGB(Number r, Number g, Number b, Number a) { public RGB(Number r, Number g, Number b, Number a) {
this.r = r.doubleValue(); this.r = r.doubleValue();
@ -148,7 +159,8 @@ public class RGB {
/** /**
* Color from hex 0xRRGGBB * Color from hex 0xRRGGBB
* *
* @param hex hex integer * @param hex
* hex integer
*/ */
public RGB(int hex) { public RGB(int hex) {
setTo(RGB.fromHex(hex)); setTo(RGB.fromHex(hex));
@ -159,8 +171,10 @@ public class RGB {
/** /**
* Color from hex 0xRRGGBB * Color from hex 0xRRGGBB
* *
* @param hex hex integer * @param hex
* @param alpha alpha color * hex integer
* @param alpha
* alpha color
*/ */
public RGB(int hex, double alpha) { public RGB(int hex, double alpha) {
setTo(RGB.fromHex(hex)); setTo(RGB.fromHex(hex));
@ -172,8 +186,10 @@ public class RGB {
/** /**
* Color from other RGB and alpha channel * Color from other RGB and alpha channel
* *
* @param color other RGB color * @param color
* @param alpha new alpha channel * other RGB color
* @param alpha
* new alpha channel
*/ */
public RGB(RGB color, double alpha) { public RGB(RGB color, double alpha) {
setTo(color); setTo(color);
@ -220,7 +236,8 @@ public class RGB {
/** /**
* Set color to other color * Set color to other color
* *
* @param copied copied color * @param copied
* copied color
* @return this * @return this
*/ */
public RGB setTo(RGB copied) public RGB setTo(RGB copied)
@ -238,7 +255,8 @@ public class RGB {
/** /**
* Set to represent hex color * Set to represent hex color
* *
* @param hex hex integer RRGGBB * @param hex
* hex integer RRGGBB
* @return this * @return this
*/ */
public RGB setTo(int hex) public RGB setTo(int hex)
@ -252,10 +270,14 @@ public class RGB {
/** /**
* Set to R,G,B 0-1 * Set to R,G,B 0-1
* *
* @param r red * @param r
* @param g green * red
* @param b blue * @param g
* @param a alpha * green
* @param b
* blue
* @param a
* alpha
* @return this * @return this
*/ */
public RGB setTo(Number r, Number g, Number b, Number a) public RGB setTo(Number r, Number g, Number b, Number a)
@ -272,9 +294,12 @@ public class RGB {
/** /**
* Set to R,G,B 0-1 * Set to R,G,B 0-1
* *
* @param r red * @param r
* @param g green * red
* @param b blue * @param g
* green
* @param b
* blue
* @return this * @return this
*/ */
public RGB setTo(Number r, Number g, Number b) public RGB setTo(Number r, Number g, Number b)
@ -333,7 +358,8 @@ public class RGB {
/** /**
* Create color from hex 0xRRGGBB * Create color from hex 0xRRGGBB
* *
* @param hex hex RRGGBB * @param hex
* hex RRGGBB
* @return the new color * @return the new color
*/ */
public static RGB fromHex(int hex) public static RGB fromHex(int hex)
@ -348,7 +374,8 @@ public class RGB {
/** /**
* Make from HSV * Make from HSV
* *
* @param color HSV color * @param color
* HSV color
* @return RGB * @return RGB
*/ */
public static RGB fromHSV(HSV color) public static RGB fromHSV(HSV color)

@ -1,6 +1,5 @@
package mightypork.utils.math.coord; package mightypork.utils.math.coord;
import java.util.Random; import java.util.Random;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -19,8 +18,10 @@ public class Coord {
/** /**
* Get distance to other point * Get distance to other point
* *
* @param a point a * @param a
* @param b point b * point a
* @param b
* point b
* @return distance in units * @return distance in units
*/ */
public static double dist(Coord a, Coord b) public static double dist(Coord a, Coord b)
@ -41,13 +42,15 @@ public class Coord {
/** /**
* Create zero coord * Create zero coord
*/ */
public Coord() {} public Coord() {
}
/** /**
* Create coord as a copy of another * Create coord as a copy of another
* *
* @param copied copied coord * @param copied
* copied coord
*/ */
public Coord(Coord copied) { public Coord(Coord copied) {
setTo(copied); setTo(copied);
@ -57,8 +60,10 @@ public class Coord {
/** /**
* Create 2D coord * Create 2D coord
* *
* @param x x coordinate * @param x
* @param y y coordinate * x coordinate
* @param y
* y coordinate
*/ */
public Coord(Number x, Number y) { public Coord(Number x, Number y) {
setTo(x, y); setTo(x, y);
@ -68,9 +73,12 @@ public class Coord {
/** /**
* Create 3D coord * Create 3D coord
* *
* @param x x coordinate * @param x
* @param y y coordinate * x coordinate
* @param z z coordinate * @param y
* y coordinate
* @param z
* z coordinate
*/ */
public Coord(Number x, Number y, Number z) { public Coord(Number x, Number y, Number z) {
setTo(x, y, z); setTo(x, y, z);
@ -80,7 +88,8 @@ public class Coord {
/** /**
* Add a vector, in a copy * Add a vector, in a copy
* *
* @param vec offset * @param vec
* offset
* @return changed copy * @return changed copy
*/ */
public Coord add(Coord vec) public Coord add(Coord vec)
@ -92,7 +101,8 @@ public class Coord {
/** /**
* Add a vector, in place * Add a vector, in place
* *
* @param vec offset * @param vec
* offset
* @return this * @return this
*/ */
public Coord add_ip(Coord vec) public Coord add_ip(Coord vec)
@ -105,8 +115,10 @@ public class Coord {
* Add to each component, in a copy.<br> * Add to each component, in a copy.<br>
* Z is unchanged. * Z is unchanged.
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param y
* y offset
* @return changed copy * @return changed copy
*/ */
public Coord add(Number x, Number y) public Coord add(Number x, Number y)
@ -119,8 +131,10 @@ public class Coord {
* Add to each component, in place.<br> * Add to each component, in place.<br>
* Z is unchanged. * Z is unchanged.
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param y
* y offset
* @return this * @return this
*/ */
public Coord add_ip(Number x, Number y) public Coord add_ip(Number x, Number y)
@ -132,9 +146,12 @@ public class Coord {
/** /**
* Add to each component, in a copy. * Add to each component, in a copy.
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param z z offset * @param y
* y offset
* @param z
* z offset
* @return changed copy * @return changed copy
*/ */
public Coord add(Number x, Number y, Number z) public Coord add(Number x, Number y, Number z)
@ -146,9 +163,12 @@ public class Coord {
/** /**
* Add to each component, in place. * Add to each component, in place.
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param z z offset * @param y
* y offset
* @param z
* z offset
* @return this * @return this
*/ */
public Coord add_ip(Number x, Number y, Number z) public Coord add_ip(Number x, Number y, Number z)
@ -174,7 +194,8 @@ public class Coord {
/** /**
* Get distance to other point * Get distance to other point
* *
* @param point other point * @param point
* other point
* @return distance in units * @return distance in units
*/ */
public double distTo(Coord point) public double distTo(Coord point)
@ -186,7 +207,8 @@ public class Coord {
/** /**
* Check if this rectangle in inside a rectangular zone * Check if this rectangle in inside a rectangular zone
* *
* @param rect checked rect. * @param rect
* checked rect.
* @return is inside * @return is inside
*/ */
public boolean isInRect(Rect rect) public boolean isInRect(Rect rect)
@ -198,8 +220,10 @@ public class Coord {
/** /**
* Check if this rectangle in inside a rectangular zone * Check if this rectangle in inside a rectangular zone
* *
* @param min min coord * @param min
* @param max max coord * min coord
* @param max
* max coord
* @return is inside * @return is inside
*/ */
public boolean isInRect(Coord min, Coord max) public boolean isInRect(Coord min, Coord max)
@ -211,7 +235,8 @@ public class Coord {
/** /**
* Get middle of line to other point * Get middle of line to other point
* *
* @param other other point * @param other
* other point
* @return middle * @return middle
*/ */
public Coord midTo(Coord other) public Coord midTo(Coord other)
@ -246,7 +271,8 @@ public class Coord {
/** /**
* Multiply each component, in a copy. * Multiply each component, in a copy.
* *
* @param d multiplier * @param d
* multiplier
* @return changed copy * @return changed copy
*/ */
public Coord mul(double d) public Coord mul(double d)
@ -258,7 +284,8 @@ public class Coord {
/** /**
* Multiply each component, in place. * Multiply each component, in place.
* *
* @param d multiplier * @param d
* multiplier
* @return this * @return this
*/ */
public Coord mul_ip(double d) public Coord mul_ip(double d)
@ -270,7 +297,8 @@ public class Coord {
/** /**
* Multiply each component, in a copy. * Multiply each component, in a copy.
* *
* @param vec vector of multipliers * @param vec
* vector of multipliers
* @return changed copy * @return changed copy
*/ */
public Coord mul(Coord vec) public Coord mul(Coord vec)
@ -283,8 +311,10 @@ public class Coord {
* Multiply each component, in a copy.<br> * Multiply each component, in a copy.<br>
* Z is unchanged. * Z is unchanged.
* *
* @param x x multiplier * @param x
* @param y y multiplier * x multiplier
* @param y
* y multiplier
* @return changed copy * @return changed copy
*/ */
public Coord mul(double x, int y) public Coord mul(double x, int y)
@ -297,8 +327,10 @@ public class Coord {
* Multiply each component, in place.<br> * Multiply each component, in place.<br>
* Z is unchanged. * Z is unchanged.
* *
* @param x x multiplier * @param x
* @param y y multiplier * x multiplier
* @param y
* y multiplier
* @return this * @return this
*/ */
public Coord mul_ip(double x, double y) public Coord mul_ip(double x, double y)
@ -310,9 +342,12 @@ public class Coord {
/** /**
* Multiply each component, in a copy. * Multiply each component, in a copy.
* *
* @param x x multiplier * @param x
* @param y y multiplier * x multiplier
* @param z z multiplier * @param y
* y multiplier
* @param z
* z multiplier
* @return changed copy * @return changed copy
*/ */
public Coord mul(double x, double y, double z) public Coord mul(double x, double y, double z)
@ -324,7 +359,8 @@ public class Coord {
/** /**
* Multiply each component, in place. * Multiply each component, in place.
* *
* @param vec vector of multipliers * @param vec
* vector of multipliers
* @return this * @return this
*/ */
public Coord mul_ip(Coord vec) public Coord mul_ip(Coord vec)
@ -336,9 +372,12 @@ public class Coord {
/** /**
* Multiply each component, in place. * Multiply each component, in place.
* *
* @param x x multiplier * @param x
* @param y y multiplier * x multiplier
* @param z z multiplier * @param y
* y multiplier
* @param z
* z multiplier
* @return this * @return this
*/ */
public Coord mul_ip(double x, double y, double z) public Coord mul_ip(double x, double y, double z)
@ -359,7 +398,8 @@ public class Coord {
/** /**
* offset randomly in place * offset randomly in place
* *
* @param max max +- offset * @param max
* max +- offset
* @return this * @return this
*/ */
public Coord random_offset_ip(double max) public Coord random_offset_ip(double max)
@ -371,8 +411,10 @@ public class Coord {
/** /**
* offset randomly * offset randomly
* *
* @param min min offset * @param min
* @param max max offset * min offset
* @param max
* max offset
* @return offset coord * @return offset coord
*/ */
public Coord random_offset(double min, double max) public Coord random_offset(double min, double max)
@ -384,8 +426,10 @@ public class Coord {
/** /**
* offset randomly in place * offset randomly in place
* *
* @param min min offset * @param min
* @param max max offset * min offset
* @param max
* max offset
* @return this * @return this
*/ */
public Coord random_offset_ip(double min, double max) public Coord random_offset_ip(double min, double max)
@ -423,7 +467,8 @@ public class Coord {
/** /**
* Set to max values of this and other coord * Set to max values of this and other coord
* *
* @param other other coord * @param other
* other coord
*/ */
public void setToMax(Coord other) public void setToMax(Coord other)
{ {
@ -436,7 +481,8 @@ public class Coord {
/** /**
* Set to min values of this and other coord * Set to min values of this and other coord
* *
* @param other other coord * @param other
* other coord
*/ */
public void setToMin(Coord other) public void setToMin(Coord other)
{ {
@ -449,7 +495,8 @@ public class Coord {
/** /**
* Set coordinates to match other coord * Set coordinates to match other coord
* *
* @param copied coord whose coordinates are used * @param copied
* coord whose coordinates are used
* @return this * @return this
*/ */
public Coord setTo(Coord copied) public Coord setTo(Coord copied)
@ -461,8 +508,10 @@ public class Coord {
/** /**
* Set 2D coordinates to * Set 2D coordinates to
* *
* @param x x coordinate * @param x
* @param y y coordinate * x coordinate
* @param y
* y coordinate
* @return this * @return this
*/ */
public Coord setTo(Number x, Number y) public Coord setTo(Number x, Number y)
@ -474,9 +523,12 @@ public class Coord {
/** /**
* Set 3D coordinates to * Set 3D coordinates to
* *
* @param x x coordinate * @param x
* @param y y coordinate * x coordinate
* @param z z coordinate * @param y
* y coordinate
* @param z
* z coordinate
* @return this * @return this
*/ */
public Coord setTo(Number x, Number y, Number z) public Coord setTo(Number x, Number y, Number z)
@ -491,7 +543,8 @@ public class Coord {
/** /**
* Set X coordinate in a copy * Set X coordinate in a copy
* *
* @param x x coordinate * @param x
* x coordinate
* @return copy with set coordinate * @return copy with set coordinate
*/ */
public Coord setX(Number x) public Coord setX(Number x)
@ -503,7 +556,8 @@ public class Coord {
/** /**
* Set X coordinate in place * Set X coordinate in place
* *
* @param x x coordinate * @param x
* x coordinate
* @return this * @return this
*/ */
public Coord setX_ip(Number x) public Coord setX_ip(Number x)
@ -516,7 +570,8 @@ public class Coord {
/** /**
* Set Y coordinate in a copy * Set Y coordinate in a copy
* *
* @param y y coordinate * @param y
* y coordinate
* @return copy with set coordinate * @return copy with set coordinate
*/ */
public Coord setY(Number y) public Coord setY(Number y)
@ -528,7 +583,8 @@ public class Coord {
/** /**
* Set Y coordinate in place * Set Y coordinate in place
* *
* @param y y coordinate * @param y
* y coordinate
* @return this * @return this
*/ */
public Coord setY_ip(Number y) public Coord setY_ip(Number y)
@ -541,7 +597,8 @@ public class Coord {
/** /**
* Set Z coordinate in a copy * Set Z coordinate in a copy
* *
* @param z z coordinate * @param z
* z coordinate
* @return copy with set coordinate * @return copy with set coordinate
*/ */
public Coord setZ(Number z) public Coord setZ(Number z)
@ -553,7 +610,8 @@ public class Coord {
/** /**
* Set Z coordinate in place * Set Z coordinate in place
* *
* @param z z coordinate * @param z
* z coordinate
* @return this * @return this
*/ */
public Coord setZ_ip(Number z) public Coord setZ_ip(Number z)
@ -566,7 +624,8 @@ public class Coord {
/** /**
* Get a copy subtracted by vector * Get a copy subtracted by vector
* *
* @param vec offset * @param vec
* offset
* @return the offset copy * @return the offset copy
*/ */
public Coord sub(Coord vec) public Coord sub(Coord vec)
@ -578,8 +637,10 @@ public class Coord {
/** /**
* Get a copy subtracted by 2D coordinate * Get a copy subtracted by 2D coordinate
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param y
* y offset
* @return the offset copy * @return the offset copy
*/ */
public Coord sub(Number x, Number y) public Coord sub(Number x, Number y)
@ -591,9 +652,12 @@ public class Coord {
/** /**
* Get a copy subtracted by 3D coordinate * Get a copy subtracted by 3D coordinate
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param z z offset * @param y
* y offset
* @param z
* z offset
* @return the offset copy * @return the offset copy
*/ */
public Coord sub(Number x, Number y, Number z) public Coord sub(Number x, Number y, Number z)
@ -605,7 +669,8 @@ public class Coord {
/** /**
* Offset by vector in place * Offset by vector in place
* *
* @param vec offset * @param vec
* offset
* @return this * @return this
*/ */
public Coord sub_ip(Coord vec) public Coord sub_ip(Coord vec)
@ -617,8 +682,10 @@ public class Coord {
/** /**
* Offset by 2D coordinate in place * Offset by 2D coordinate in place
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param y
* y offset
* @return this * @return this
*/ */
public Coord sub_ip(Number x, Number y) public Coord sub_ip(Number x, Number y)
@ -630,9 +697,12 @@ public class Coord {
/** /**
* Offset by 3D coordinate in place * Offset by 3D coordinate in place
* *
* @param x x offset * @param x
* @param y y offset * x offset
* @param z z offset * @param y
* y offset
* @param z
* z offset
* @return this * @return this
*/ */
public Coord sub_ip(Number x, Number y, Number z) public Coord sub_ip(Number x, Number y, Number z)
@ -647,7 +717,8 @@ public class Coord {
/** /**
* Create vector from this point to other point * Create vector from this point to other point
* *
* @param point second point * @param point
* second point
* @return vector * @return vector
*/ */
public Coord vecTo(Coord point) public Coord vecTo(Coord point)
@ -713,8 +784,10 @@ public class Coord {
/** /**
* Get cross product of two vectors * Get cross product of two vectors
* *
* @param a 1st vector * @param a
* @param b 2nd vector * 1st vector
* @param b
* 2nd vector
* @return cross product * @return cross product
*/ */
public static Coord cross(Coord a, Coord b) public static Coord cross(Coord a, Coord b)
@ -726,8 +799,10 @@ public class Coord {
/** /**
* Get dot product of two vectors * Get dot product of two vectors
* *
* @param a 1st vector * @param a
* @param b 2nd vector * 1st vector
* @param b
* 2nd vector
* @return dot product * @return dot product
*/ */
public static double dot(Coord a, Coord b) public static double dot(Coord a, Coord b)
@ -739,7 +814,8 @@ public class Coord {
/** /**
* Multiply by other vector, vector multiplication * Multiply by other vector, vector multiplication
* *
* @param vec other vector * @param vec
* other vector
* @return changed copy * @return changed copy
*/ */
public Coord cross(Coord vec) public Coord cross(Coord vec)
@ -751,7 +827,8 @@ public class Coord {
/** /**
* Multiply by other vector, vector multiplication; in place * Multiply by other vector, vector multiplication; in place
* *
* @param vec other vector * @param vec
* other vector
* @return this * @return this
*/ */
public Coord cross_ip(Coord vec) public Coord cross_ip(Coord vec)
@ -770,7 +847,8 @@ public class Coord {
/** /**
* Get dot product * Get dot product
* *
* @param vec other vector * @param vec
* other vector
* @return dot product * @return dot product
*/ */
public double dot(Coord vec) public double dot(Coord vec)
@ -805,7 +883,8 @@ public class Coord {
/** /**
* Scale vector to given size * Scale vector to given size
* *
* @param size size we need * @param size
* size we need
* @return scaled vector * @return scaled vector
*/ */
public Coord norm(double size) public Coord norm(double size)
@ -818,7 +897,8 @@ public class Coord {
* Scale vector to given size, in place.<br> * Scale vector to given size, in place.<br>
* Zero vector remains zero. * Zero vector remains zero.
* *
* @param size size we need * @param size
* size we need
* @return scaled vector * @return scaled vector
*/ */
public Coord norm_ip(double size) public Coord norm_ip(double size)
@ -914,7 +994,8 @@ public class Coord {
/** /**
* Generate random coord (gaussian) * Generate random coord (gaussian)
* *
* @param max max distance from 0 * @param max
* max distance from 0
* @return new coord * @return new coord
*/ */
public static Coord random(double max) public static Coord random(double max)
@ -932,8 +1013,10 @@ public class Coord {
/** /**
* Generate random coord (min-max) * Generate random coord (min-max)
* *
* @param min min offset * @param min
* @param max max offset * min offset
* @param max
* max offset
* @return new coord * @return new coord
*/ */
public static Coord random(double min, double max) public static Coord random(double min, double max)

@ -1,6 +1,5 @@
package mightypork.utils.math.coord; package mightypork.utils.math.coord;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
import mightypork.utils.time.Updateable; import mightypork.utils.time.Updateable;
@ -21,7 +20,8 @@ public class CoordAnimated extends Coord implements Updateable {
/** /**
* Update delta timing * Update delta timing
* *
* @param delta delta time to add * @param delta
* delta time to add
*/ */
@Override @Override
public void update(double delta) public void update(double delta)
@ -52,7 +52,8 @@ public class CoordAnimated extends Coord implements Updateable {
/** /**
* Start animation * Start animation
* *
* @param time anim length * @param time
* anim length
*/ */
public void animStart(double time) public void animStart(double time)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.math.coord; package mightypork.utils.math.coord;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -20,8 +19,10 @@ public class Rect {
/** /**
* Rectangle from size * Rectangle from size
* *
* @param min min coord * @param min
* @param size rect size * min coord
* @param size
* rect size
* @return the rect * @return the rect
*/ */
public static Rect fromSize(Coord min, Coord size) public static Rect fromSize(Coord min, Coord size)
@ -33,9 +34,12 @@ public class Rect {
/** /**
* Make rect from min coord and size * Make rect from min coord and size
* *
* @param min min coord * @param min
* @param width size x * min coord
* @param height size y * @param width
* size x
* @param height
* size y
* @return the new rect * @return the new rect
*/ */
public static Rect fromSize(Coord min, double width, double height) public static Rect fromSize(Coord min, double width, double height)
@ -47,9 +51,12 @@ public class Rect {
/** /**
* Rectangle from size * Rectangle from size
* *
* @param x min X * @param x
* @param y min Y * min X
* @param size rect size * @param y
* min Y
* @param size
* rect size
* @return the rect * @return the rect
*/ */
public static Rect fromSize(int x, int y, Coord size) public static Rect fromSize(int x, int y, Coord size)
@ -61,10 +68,14 @@ public class Rect {
/** /**
* Make rect from min coord and size * Make rect from min coord and size
* *
* @param xMin min x * @param xMin
* @param yMin min y * min x
* @param width size x * @param yMin
* @param height size y * min y
* @param width
* size x
* @param height
* size y
* @return the new rect * @return the new rect
*/ */
public static Rect fromSize(double xMin, double yMin, double width, double height) public static Rect fromSize(double xMin, double yMin, double width, double height)
@ -90,7 +101,8 @@ public class Rect {
/** /**
* Rect [0, 0, size.x, size.y] * Rect [0, 0, size.x, size.y]
* *
* @param size size coord * @param size
* size coord
*/ */
public Rect(Coord size) { public Rect(Coord size) {
this(0, 0, size.x, size.y); this(0, 0, size.x, size.y);
@ -100,8 +112,10 @@ public class Rect {
/** /**
* New rect of two coords * New rect of two coords
* *
* @param c1 coord 1 * @param c1
* @param c2 coord 2 * coord 1
* @param c2
* coord 2
*/ */
public Rect(Coord c1, Coord c2) { public Rect(Coord c1, Coord c2) {
this(c1.x, c1.y, c2.x, c2.y); this(c1.x, c1.y, c2.x, c2.y);
@ -111,10 +125,14 @@ public class Rect {
/** /**
* New Rect * New Rect
* *
* @param x1 lower x * @param x1
* @param y1 lower y * lower x
* @param x2 upper x * @param y1
* @param y2 upper y * lower y
* @param x2
* upper x
* @param y2
* upper y
*/ */
public Rect(double x1, double y1, double x2, double y2) { public Rect(double x1, double y1, double x2, double y2) {
setTo(x1, y1, x2, y2); setTo(x1, y1, x2, y2);
@ -124,8 +142,10 @@ public class Rect {
/** /**
* Rect [0, 0, x, y] * Rect [0, 0, x, y]
* *
* @param x width * @param x
* @param y height * width
* @param y
* height
*/ */
public Rect(double x, double y) { public Rect(double x, double y) {
this(0, 0, x, y); this(0, 0, x, y);
@ -135,7 +155,8 @@ public class Rect {
/** /**
* New rect as a copy of other rect * New rect as a copy of other rect
* *
* @param r other rect * @param r
* other rect
*/ */
public Rect(Rect r) { public Rect(Rect r) {
this(r.min.x, r.min.y, r.max.x, r.max.y); this(r.min.x, r.min.y, r.max.x, r.max.y);
@ -145,7 +166,8 @@ public class Rect {
/** /**
* Get offset copy (add) * Get offset copy (add)
* *
* @param move offset vector * @param move
* offset vector
* @return offset copy * @return offset copy
*/ */
public Rect add(Coord move) public Rect add(Coord move)
@ -157,8 +179,10 @@ public class Rect {
/** /**
* Add X and Y to all coordinates in a copy * Add X and Y to all coordinates in a copy
* *
* @param x x to add * @param x
* @param y y to add * x to add
* @param y
* y to add
* @return copy changed * @return copy changed
*/ */
public Rect add(double x, double y) public Rect add(double x, double y)
@ -170,7 +194,8 @@ public class Rect {
/** /**
* Offset in place (add) * Offset in place (add)
* *
* @param move offset vector * @param move
* offset vector
* @return this * @return this
*/ */
public Rect add_ip(Coord move) public Rect add_ip(Coord move)
@ -184,8 +209,10 @@ public class Rect {
/** /**
* Add X and Y to all coordinates in place * Add X and Y to all coordinates in place
* *
* @param x x to add * @param x
* @param y y to add * x to add
* @param y
* y to add
* @return this * @return this
*/ */
public Rect add_ip(double x, double y) public Rect add_ip(double x, double y)
@ -402,7 +429,8 @@ public class Rect {
/** /**
* Grow to sides in copy * Grow to sides in copy
* *
* @param grow grow size (added to each side) * @param grow
* grow size (added to each side)
* @return grown copy * @return grown copy
*/ */
public Rect grow(Coord grow) public Rect grow(Coord grow)
@ -414,8 +442,10 @@ public class Rect {
/** /**
* Grow to sides in copy * Grow to sides in copy
* *
* @param x x to add * @param x
* @param y y to add * x to add
* @param y
* y to add
* @return grown copy * @return grown copy
*/ */
public Rect grow(double x, double y) public Rect grow(double x, double y)
@ -427,7 +457,8 @@ public class Rect {
/** /**
* Grow to sides in place * Grow to sides in place
* *
* @param grow grow size (added to each side) * @param grow
* grow size (added to each side)
* @return this * @return this
*/ */
public Rect grow_ip(Coord grow) public Rect grow_ip(Coord grow)
@ -441,8 +472,10 @@ public class Rect {
/** /**
* Grow to sides in place * Grow to sides in place
* *
* @param x x to add * @param x
* @param y y to add * x to add
* @param y
* y to add
* @return this * @return this
*/ */
public Rect grow_ip(double x, double y) public Rect grow_ip(double x, double y)
@ -456,7 +489,8 @@ public class Rect {
/** /**
* Grow down in copy * Grow down in copy
* *
* @param down added pixels * @param down
* added pixels
* @return grown copy * @return grown copy
*/ */
public Rect growDown(double down) public Rect growDown(double down)
@ -468,7 +502,8 @@ public class Rect {
/** /**
* Grow down in place * Grow down in place
* *
* @param down added pixels * @param down
* added pixels
* @return this * @return this
*/ */
public Rect growDown_ip(double down) public Rect growDown_ip(double down)
@ -481,7 +516,8 @@ public class Rect {
/** /**
* Grow to left in copy * Grow to left in copy
* *
* @param left added pixels * @param left
* added pixels
* @return grown copy * @return grown copy
*/ */
public Rect growLeft(double left) public Rect growLeft(double left)
@ -493,7 +529,8 @@ public class Rect {
/** /**
* Grow to left in place * Grow to left in place
* *
* @param left added pixels * @param left
* added pixels
* @return this * @return this
*/ */
public Rect growLeft_ip(double left) public Rect growLeft_ip(double left)
@ -506,7 +543,8 @@ public class Rect {
/** /**
* Grow to right in copy * Grow to right in copy
* *
* @param right added pixels * @param right
* added pixels
* @return grown copy * @return grown copy
*/ */
public Rect growRight(double right) public Rect growRight(double right)
@ -518,7 +556,8 @@ public class Rect {
/** /**
* Grow to right in place * Grow to right in place
* *
* @param right added pixels * @param right
* added pixels
* @return this * @return this
*/ */
public Rect growRight_ip(double right) public Rect growRight_ip(double right)
@ -531,7 +570,8 @@ public class Rect {
/** /**
* Grow up in copy * Grow up in copy
* *
* @param add added pixels * @param add
* added pixels
* @return grown copy * @return grown copy
*/ */
public Rect growUp(double add) public Rect growUp(double add)
@ -543,7 +583,8 @@ public class Rect {
/** /**
* Grow up in place * Grow up in place
* *
* @param add added pixels * @param add
* added pixels
* @return this * @return this
*/ */
public Rect growUp_ip(double add) public Rect growUp_ip(double add)
@ -556,7 +597,8 @@ public class Rect {
/** /**
* Check if point is inside this rectangle * Check if point is inside this rectangle
* *
* @param point point to test * @param point
* point to test
* @return is inside * @return is inside
*/ */
public boolean isInside(Coord point) public boolean isInside(Coord point)
@ -568,7 +610,8 @@ public class Rect {
/** /**
* Multiply in copy * Multiply in copy
* *
* @param factor multiplier * @param factor
* multiplier
* @return offset copy * @return offset copy
*/ */
public Rect mul(double factor) public Rect mul(double factor)
@ -580,8 +623,10 @@ public class Rect {
/** /**
* Multiply by number (useful for centered rects) * Multiply by number (useful for centered rects)
* *
* @param x x multiplier * @param x
* @param y y multiplier * x multiplier
* @param y
* y multiplier
* @return copy multiplied * @return copy multiplied
*/ */
public Rect mul(double x, double y) public Rect mul(double x, double y)
@ -593,7 +638,8 @@ public class Rect {
/** /**
* Multiply coord in place * Multiply coord in place
* *
* @param factor multiplier * @param factor
* multiplier
* @return this * @return this
*/ */
public Rect mul_ip(double factor) public Rect mul_ip(double factor)
@ -607,8 +653,10 @@ public class Rect {
/** /**
* Multiply coord in place * Multiply coord in place
* *
* @param x multiplier x * @param x
* @param y multiplier y * multiplier x
* @param y
* multiplier y
* @return this * @return this
*/ */
public Rect mul_ip(double x, double y) public Rect mul_ip(double x, double y)
@ -646,7 +694,8 @@ public class Rect {
/** /**
* Set to [0,0,coord.x,coord.y] * Set to [0,0,coord.x,coord.y]
* *
* @param coord size coord * @param coord
* size coord
*/ */
public void setTo(Coord coord) public void setTo(Coord coord)
{ {
@ -657,10 +706,14 @@ public class Rect {
/** /**
* Set to coordinates * Set to coordinates
* *
* @param x1 lower x * @param x1
* @param y1 lower y * lower x
* @param x2 upper x * @param y1
* @param y2 upper y * lower y
* @param x2
* upper x
* @param y2
* upper y
*/ */
public void setTo(double x1, double y1, double x2, double y2) public void setTo(double x1, double y1, double x2, double y2)
{ {
@ -674,7 +727,8 @@ public class Rect {
/** /**
* Set to other rect's coordinates * Set to other rect's coordinates
* *
* @param r other rect * @param r
* other rect
*/ */
public void setTo(Rect r) public void setTo(Rect r)
{ {
@ -686,8 +740,10 @@ public class Rect {
/** /**
* Subtract X and Y from all coordinates in a copy * Subtract X and Y from all coordinates in a copy
* *
* @param x x to subtract * @param x
* @param y y to subtract * x to subtract
* @param y
* y to subtract
* @return copy changed * @return copy changed
*/ */
public Rect sub(double x, double y) public Rect sub(double x, double y)
@ -699,7 +755,8 @@ public class Rect {
/** /**
* Get offset copy (subtract) * Get offset copy (subtract)
* *
* @param move offset vector * @param move
* offset vector
* @return offset copy * @return offset copy
*/ */
public Rect sub(Coord move) public Rect sub(Coord move)
@ -711,8 +768,10 @@ public class Rect {
/** /**
* Subtract X and Y from all coordinates in place * Subtract X and Y from all coordinates in place
* *
* @param x x to subtract * @param x
* @param y y to subtract * x to subtract
* @param y
* y to subtract
* @return this * @return this
*/ */
public Rect sub_ip(double x, double y) public Rect sub_ip(double x, double y)
@ -724,7 +783,8 @@ public class Rect {
/** /**
* Offset in place (subtract) * Offset in place (subtract)
* *
* @param move offset vector * @param move
* offset vector
* @return this * @return this
*/ */
public Rect sub_ip(Coord move) public Rect sub_ip(Coord move)

@ -1,6 +1,5 @@
package mightypork.utils.math.easing; package mightypork.utils.math.easing;
/** /**
* EasingFunction function. * EasingFunction function.
* *
@ -11,7 +10,8 @@ public abstract class Easing {
/** /**
* Get value at time t. * Get value at time t.
* *
* @param t time parameter (t = 1..1) * @param t
* time parameter (t = 1..1)
* @return value at given t (0..1, can exceed if needed) * @return value at given t (0..1, can exceed if needed)
*/ */
public abstract double get(double t); public abstract double get(double t);
@ -20,7 +20,8 @@ public abstract class Easing {
/** /**
* Reverse an easing * Reverse an easing
* *
* @param original original easing * @param original
* original easing
* @return reversed easing * @return reversed easing
*/ */
public static Easing reverse(Easing original) public static Easing reverse(Easing original)
@ -32,8 +33,10 @@ public abstract class Easing {
/** /**
* Combine two easings * Combine two easings
* *
* @param in initial easing * @param in
* @param out terminal easing * initial easing
* @param out
* terminal easing
* @return product * @return product
*/ */
public static Easing combine(Easing in, Easing out) public static Easing combine(Easing in, Easing out)
@ -45,7 +48,8 @@ public abstract class Easing {
/** /**
* Create "bilinear" easing - compose of straight and reverse. * Create "bilinear" easing - compose of straight and reverse.
* *
* @param in initial easing * @param in
* initial easing
* @return product * @return product
*/ */
public static Easing inOut(Easing in) public static Easing inOut(Easing in)
@ -53,6 +57,7 @@ public abstract class Easing {
return combine(in, reverse(in)); return combine(in, reverse(in));
} }
/** /**
* Reverse EasingFunction * Reverse EasingFunction
* *
@ -64,7 +69,8 @@ public abstract class Easing {
/** /**
* @param in Easing to reverse * @param in
* Easing to reverse
*/ */
public Reverse(Easing in) { public Reverse(Easing in) {
this.ea = in; this.ea = in;
@ -78,6 +84,7 @@ public abstract class Easing {
} }
} }
/** /**
* Composite EasingFunction (0-0.5 EasingFunction A, 0.5-1 EasingFunction B) * Composite EasingFunction (0-0.5 EasingFunction A, 0.5-1 EasingFunction B)
* *
@ -92,8 +99,10 @@ public abstract class Easing {
/** /**
* Create a composite EasingFunction * Create a composite EasingFunction
* *
* @param in initial EasingFunction * @param in
* @param out terminal EasingFunction * initial EasingFunction
* @param out
* terminal EasingFunction
*/ */
public Composite(Easing in, Easing out) { public Composite(Easing in, Easing out) {
this.in = in; this.in = in;

@ -1,6 +1,5 @@
package mightypork.utils.objects; package mightypork.utils.objects;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.Range; import mightypork.utils.math.Range;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -17,8 +16,10 @@ public class Convertor {
/** /**
* Get INTEGER * Get INTEGER
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return integer * @return integer
*/ */
public static int getInteger(Object o, Integer def) public static int getInteger(Object o, Integer def)
@ -29,7 +30,8 @@ public class Convertor {
if (o instanceof Number) return ((Number) o).intValue(); if (o instanceof Number) return ((Number) o).intValue();
if (o instanceof Range) return ((Range) o).randInt(); if (o instanceof Range) return ((Range) o).randInt();
if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0; if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0;
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
Log.w("Cannot convert " + o + " to Integer."); Log.w("Cannot convert " + o + " to Integer.");
return def; return def;
} }
@ -38,8 +40,10 @@ public class Convertor {
/** /**
* Get DOUBLE * Get DOUBLE
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return double * @return double
*/ */
public static double getDouble(Object o, Double def) public static double getDouble(Object o, Double def)
@ -50,7 +54,8 @@ public class Convertor {
if (o instanceof Number) return ((Number) o).doubleValue(); if (o instanceof Number) return ((Number) o).doubleValue();
if (o instanceof Range) return ((Range) o).randDouble(); if (o instanceof Range) return ((Range) o).randDouble();
if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0; if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0;
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
Log.w("Cannot convert " + o + " to Double."); Log.w("Cannot convert " + o + " to Double.");
return def; return def;
} }
@ -59,8 +64,10 @@ public class Convertor {
/** /**
* Get FLOAT * Get FLOAT
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return float * @return float
*/ */
public static double getFloat(Object o, Float def) public static double getFloat(Object o, Float def)
@ -68,7 +75,8 @@ public class Convertor {
try { try {
if (o == null) return def; if (o == null) return def;
if (o instanceof Number) return ((Number) o).floatValue(); if (o instanceof Number) return ((Number) o).floatValue();
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
Log.w("Cannot convert " + o + " to Float."); Log.w("Cannot convert " + o + " to Float.");
return def; return def;
} }
@ -77,8 +85,10 @@ public class Convertor {
/** /**
* Get BOOLEAN * Get BOOLEAN
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return boolean * @return boolean
*/ */
public static boolean getBoolean(Object o, Boolean def) public static boolean getBoolean(Object o, Boolean def)
@ -92,7 +102,8 @@ public class Convertor {
try { try {
double n = Double.parseDouble(s); double n = Double.parseDouble(s);
return n != 0; return n != 0;
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
if (s.equals("true")) return true; if (s.equals("true")) return true;
if (s.equals("yes")) return true; if (s.equals("yes")) return true;
@ -115,8 +126,10 @@ public class Convertor {
/** /**
* Get STRING * Get STRING
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return String * @return String
*/ */
public static String getString(Object o, String def) public static String getString(Object o, String def)
@ -132,8 +145,10 @@ public class Convertor {
* Get AI_COORD<br> * Get AI_COORD<br>
* Converts special constants to magic coordinate instances. * Converts special constants to magic coordinate instances.
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return AiCoord * @return AiCoord
*/ */
public static Coord getCoord(Object o, Coord def) public static Coord getCoord(Object o, Coord def)
@ -164,8 +179,10 @@ public class Convertor {
/** /**
* Get RANGE * Get RANGE
* *
* @param o object * @param o
* @param def default value * object
* @param def
* default value
* @return AiCoord * @return AiCoord
*/ */
public static Range getRange(Object o, Range def) public static Range getRange(Object o, Range def)
@ -190,7 +207,8 @@ public class Convertor {
} }
if (o instanceof Range) return (Range) o; if (o instanceof Range) return (Range) o;
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {
}
Log.w("Cannot convert " + o + " to Range."); Log.w("Cannot convert " + o + " to Range.");
return def; return def;
} }
@ -199,7 +217,8 @@ public class Convertor {
/** /**
* Get INTEGER * Get INTEGER
* *
* @param o object * @param o
* object
* @return integer * @return integer
*/ */
public static int getInteger(Object o) public static int getInteger(Object o)
@ -211,7 +230,8 @@ public class Convertor {
/** /**
* Get DOUBLE * Get DOUBLE
* *
* @param o object * @param o
* object
* @return double * @return double
*/ */
public static double getDouble(Object o) public static double getDouble(Object o)
@ -223,7 +243,8 @@ public class Convertor {
/** /**
* Get FLOAT * Get FLOAT
* *
* @param o object * @param o
* object
* @return float * @return float
*/ */
public static double getFloat(Object o) public static double getFloat(Object o)
@ -235,7 +256,8 @@ public class Convertor {
/** /**
* Get BOOLEAN * Get BOOLEAN
* *
* @param o object * @param o
* object
* @return boolean * @return boolean
*/ */
public static boolean getBoolean(Object o) public static boolean getBoolean(Object o)
@ -247,7 +269,8 @@ public class Convertor {
/** /**
* Get STRING * Get STRING
* *
* @param o object * @param o
* object
* @return String * @return String
*/ */
public static String getString(Object o) public static String getString(Object o)
@ -260,7 +283,8 @@ public class Convertor {
* Get AI_COORD (if special string constant is present instead, build coord * Get AI_COORD (if special string constant is present instead, build coord
* of it) * of it)
* *
* @param o object * @param o
* object
* @return AiCoord * @return AiCoord
*/ */
public static Coord getCoord(Object o) public static Coord getCoord(Object o)
@ -272,7 +296,8 @@ public class Convertor {
/** /**
* Get RANGE * Get RANGE
* *
* @param o object * @param o
* object
* @return AiCoord * @return AiCoord
*/ */
public static Range getRange(Object o) public static Range getRange(Object o)

@ -1,11 +1,11 @@
package mightypork.utils.objects; package mightypork.utils.objects;
/** /**
* Mutable object * Mutable object
* *
* @author MightyPork * @author MightyPork
* @param <T> type * @param <T>
* type
*/ */
public class Mutable<T> { public class Mutable<T> {
@ -16,7 +16,8 @@ public class Mutable<T> {
/** /**
* New mutable object * New mutable object
* *
* @param o value * @param o
* value
*/ */
public Mutable(T o) { public Mutable(T o) {
this.o = o; this.o = o;
@ -37,7 +38,8 @@ public class Mutable<T> {
/** /**
* Set value * Set value
* *
* @param o new value to set * @param o
* new value to set
*/ */
public void set(T o) public void set(T o)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.objects; package mightypork.utils.objects;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -24,8 +23,10 @@ public class ObjectUtils {
/** /**
* Sort a map by keys, maintaining key-value pairs. * Sort a map by keys, maintaining key-value pairs.
* *
* @param map map to be sorted * @param map
* @param comparator a comparator, or null for natural ordering * map to be sorted
* @param comparator
* a comparator, or null for natural ordering
* @return linked hash map with sorted entries * @return linked hash map with sorted entries
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
@ -53,8 +54,10 @@ public class ObjectUtils {
/** /**
* Sort a map by values, maintaining key-value pairs. * Sort a map by values, maintaining key-value pairs.
* *
* @param map map to be sorted * @param map
* @param comparator a comparator, or null for natural ordering * map to be sorted
* @param comparator
* a comparator, or null for natural ordering
* @return linked hash map with sorted entries * @return linked hash map with sorted entries
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -64,6 +67,7 @@ public class ObjectUtils {
Collections.sort(entries, new Comparator<Map.Entry<K, V>>() { Collections.sort(entries, new Comparator<Map.Entry<K, V>>() {
@SuppressWarnings("unchecked")
@Override @Override
public int compare(Entry<K, V> o1, Entry<K, V> o2) public int compare(Entry<K, V> o1, Entry<K, V> o2)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.objects; package mightypork.utils.objects;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -9,8 +8,10 @@ import mightypork.utils.math.Calc;
* *
* @author MightyPork * @author MightyPork
* @copy (c) 2012 * @copy (c) 2012
* @param <T1> 1st object class * @param <T1>
* @param <T2> 2nd object class * 1st object class
* @param <T2>
* 2nd object class
*/ */
public class Pair<T1, T2> { public class Pair<T1, T2> {
@ -28,8 +29,10 @@ public class Pair<T1, T2> {
/** /**
* Make structure of 2 objects * Make structure of 2 objects
* *
* @param first 1st object * @param first
* @param second 2nd object * 1st object
* @param second
* 2nd object
*/ */
public Pair(T1 first, T2 second) { public Pair(T1 first, T2 second) {
this.first = first; this.first = first;

@ -1,6 +1,5 @@
package mightypork.utils.objects; package mightypork.utils.objects;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
@ -9,9 +8,12 @@ import mightypork.utils.math.Calc;
* *
* @author MightyPork * @author MightyPork
* @copy (c) 2012 * @copy (c) 2012
* @param <T1> 1st object class * @param <T1>
* @param <T2> 2nd object class * 1st object class
* @param <T3> 3rd object class * @param <T2>
* 2nd object class
* @param <T3>
* 3rd object class
*/ */
public class Triad<T1, T2, T3> extends Pair<T1, T2> { public class Triad<T1, T2, T3> extends Pair<T1, T2> {
@ -24,9 +26,12 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
/** /**
* Make structure of 3 objects * Make structure of 3 objects
* *
* @param objA 1st object * @param objA
* @param objB 2nd object * 1st object
* @param objC 3rd object * @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); super(objA, objB);
@ -46,7 +51,8 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
/** /**
* Set 1st object * Set 1st object
* *
* @param obj 1st object * @param obj
* 1st object
*/ */
public void setThird(T3 obj) public void setThird(T3 obj)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.objects; package mightypork.utils.objects;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@ -26,18 +25,23 @@ import java.util.Map;
* </pre> * </pre>
* *
* @author MightyPork * @author MightyPork
* @param <K> Type for Map keys * @param <K>
* @param <V> Type for Map values * Type for Map keys
* @param <V>
* Type for Map values
*/ */
public class VarargsParser<K, V> { public class VarargsParser<K, V> {
/** /**
* Parse array of vararg key, value pairs to a LinkedHashMap. * Parse array of vararg key, value pairs to a LinkedHashMap.
* *
* @param args varargs * @param args
* varargs
* @return LinkedHashMap * @return LinkedHashMap
* @throws ClassCastException in case of incompatible type in the array * @throws ClassCastException
* @throws IllegalArgumentException in case of invalid array length (odd) * in case of incompatible type in the array
* @throws IllegalArgumentException
* in case of invalid array length (odd)
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Map<K, V> parse(Object... args) throws ClassCastException, IllegalArgumentException public Map<K, V> parse(Object... args) throws ClassCastException, IllegalArgumentException

@ -1,6 +1,5 @@
package mightypork.utils.patterns; package mightypork.utils.patterns;
/** /**
* Object that can be destroyed (free resources etc) * Object that can be destroyed (free resources etc)
* *

@ -1,18 +1,19 @@
package mightypork.utils.patterns.subscription; package mightypork.utils.patterns.subscription;
/** /**
* Something that can be handled by HANDLER. * Something that can be handled by HANDLER.
* *
* @author MightyPork * @author MightyPork
* @param <HANDLER> handler type * @param <HANDLER>
* handler type
*/ */
public interface Handleable<HANDLER> { public interface Handleable<HANDLER> {
/** /**
* Ask handler to handle this message. * Ask handler to handle this message.
* *
* @param handler handler instance * @param handler
* handler instance
*/ */
public void handleBy(HANDLER handler); public void handleBy(HANDLER handler);
} }

@ -1,6 +1,5 @@
package mightypork.utils.patterns.subscription; package mightypork.utils.patterns.subscription;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
@ -25,7 +24,8 @@ final public class MessageBus {
* Add a {@link MessageChannel} to this bus.<br> * Add a {@link MessageChannel} to this bus.<br>
* If a channel of matching types is already added, it is returned instead. * If a channel of matching types is already added, it is returned instead.
* *
* @param channel channel to be added * @param channel
* channel to be added
* @return the channel that's now in the bus * @return the channel that's now in the bus
*/ */
public MessageChannel<?, ?> addChannel(MessageChannel<?, ?> channel) public MessageChannel<?, ?> addChannel(MessageChannel<?, ?> channel)
@ -47,7 +47,8 @@ final public class MessageBus {
/** /**
* Remove a {@link MessageChannel} from this bus * Remove a {@link MessageChannel} from this bus
* *
* @param channel true if channel was removed * @param channel
* true if channel was removed
*/ */
public void removeChannel(MessageChannel<?, ?> channel) public void removeChannel(MessageChannel<?, ?> channel)
{ {
@ -58,7 +59,8 @@ final public class MessageBus {
/** /**
* Broadcast a message * Broadcast a message
* *
* @param message message * @param message
* message
* @return true if message was accepted by at least one channel * @return true if message was accepted by at least one channel
*/ */
public boolean broadcast(Object message) public boolean broadcast(Object message)
@ -79,7 +81,8 @@ final public class MessageBus {
* Connect a client to the bus. The client will be connected to all current * Connect a client to the bus. The client will be connected to all current
* and future channels, until removed from the bus. * and future channels, until removed from the bus.
* *
* @param client the client * @param client
* the client
* @return true on success * @return true on success
*/ */
public boolean subscribe(Object client) public boolean subscribe(Object client)
@ -95,7 +98,8 @@ final public class MessageBus {
/** /**
* Disconnect a client from the bus. * Disconnect a client from the bus.
* *
* @param client the client * @param client
* the client
*/ */
public void unsubscribe(Object client) public void unsubscribe(Object client)
{ {
@ -117,8 +121,10 @@ final public class MessageBus {
/** /**
* Add a channel for given message and client type. * Add a channel for given message and client type.
* *
* @param messageClass message type * @param messageClass
* @param clientClass client type * message type
* @param clientClass
* client type
* @return the created channel instance * @return the created channel instance
*/ */
public <F_MESSAGE extends Handleable<F_CLIENT>, F_CLIENT> MessageChannel<?, ?> createChannel(Class<F_MESSAGE> messageClass, Class<F_CLIENT> clientClass) public <F_MESSAGE extends Handleable<F_CLIENT>, F_CLIENT> MessageChannel<?, ?> createChannel(Class<F_MESSAGE> messageClass, Class<F_CLIENT> clientClass)

@ -1,6 +1,5 @@
package mightypork.utils.patterns.subscription; package mightypork.utils.patterns.subscription;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@ -13,8 +12,10 @@ import mightypork.utils.patterns.subscription.clients.ToggleableClient;
* Message channel, module of {@link MessageBus} * Message channel, module of {@link MessageBus}
* *
* @author MightyPork * @author MightyPork
* @param <MESSAGE> message type * @param <MESSAGE>
* @param <CLIENT> client (subscriber) type * message type
* @param <CLIENT>
* client (subscriber) type
*/ */
final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> { final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
@ -35,8 +36,10 @@ final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
* Try to broadcast a message.<br> * Try to broadcast a message.<br>
* If message is of wrong type, <code>false</code> is returned. * If message is of wrong type, <code>false</code> is returned.
* *
* @param message a message to be sent * @param message
* @param clients collection of clients * a message to be sent
* @param clients
* collection of clients
* @return true if message was accepted by this channel * @return true if message was accepted by this channel
*/ */
public boolean broadcast(Object message, Collection<Object> clients) public boolean broadcast(Object message, Collection<Object> clients)
@ -83,8 +86,10 @@ final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
/** /**
* Send a message to a client. * Send a message to a client.
* *
* @param client target client * @param client
* @param message message to send * target client
* @param message
* message to send
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void sendTo(Object client, MESSAGE message) private void sendTo(Object client, MESSAGE message)
@ -99,7 +104,8 @@ final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
* Check if the given message can be broadcasted by this * Check if the given message can be broadcasted by this
* {@link MessageChannel} * {@link MessageChannel}
* *
* @param message event object * @param message
* event object
* @return can be broadcasted * @return can be broadcasted
*/ */
public boolean canBroadcast(Object message) public boolean canBroadcast(Object message)
@ -146,8 +152,10 @@ final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
/** /**
* Create an instance for given types * Create an instance for given types
* *
* @param messageClass event class * @param messageClass
* @param clientClass client class * event class
* @param clientClass
* client class
* @return the broadcaster * @return the broadcaster
*/ */
public static <F_MESSAGE extends Handleable<F_CLIENT>, F_CLIENT> MessageChannel<F_MESSAGE, F_CLIENT> create(Class<F_MESSAGE> messageClass, Class<F_CLIENT> clientClass) public static <F_MESSAGE extends Handleable<F_CLIENT>, F_CLIENT> MessageChannel<F_MESSAGE, F_CLIENT> create(Class<F_MESSAGE> messageClass, Class<F_CLIENT> clientClass)

@ -1,6 +1,5 @@
package mightypork.utils.patterns.subscription.clients; package mightypork.utils.patterns.subscription.clients;
import java.util.Collection; import java.util.Collection;

@ -1,6 +1,5 @@
package mightypork.utils.patterns.subscription.clients; package mightypork.utils.patterns.subscription.clients;
/** /**
* Client that can toggle receiving messages. * Client that can toggle receiving messages.
* *

@ -1,6 +1,5 @@
package mightypork.utils.string; package mightypork.utils.string;
/** /**
* General purpose string utilities * General purpose string utilities
* *
@ -11,9 +10,12 @@ public class StringUtils {
/** /**
* Get if string is in array * Get if string is in array
* *
* @param needle checked string * @param needle
* @param case_sensitive case sensitive comparision * checked string
* @param haystack array of possible values * @param case_sensitive
* case sensitive comparision
* @param haystack
* array of possible values
* @return is in array * @return is in array
*/ */
public static boolean isInArray(String needle, boolean case_sensitive, String... haystack) public static boolean isInArray(String needle, boolean case_sensitive, String... haystack)
@ -61,7 +63,8 @@ public class StringUtils {
/** /**
* Repeat a string * Repeat a string
* *
* @param repeated string * @param repeated
* string
* @param count * @param count
* @return output * @return output
*/ */
@ -77,7 +80,8 @@ public class StringUtils {
/** /**
* convert string to a same-length sequence of # marks * convert string to a same-length sequence of # marks
* *
* @param password password * @param password
* password
* @return encoded * @return encoded
*/ */
public static String passwordify(String password) public static String passwordify(String password)
@ -89,8 +93,10 @@ public class StringUtils {
/** /**
* convert string to a same-length sequence of chars * convert string to a same-length sequence of chars
* *
* @param password password * @param password
* @param replacing character used in output * password
* @param replacing
* character used in output
* @return encoded * @return encoded
*/ */
public static String passwordify(String password, String replacing) public static String passwordify(String password, String replacing)
@ -102,7 +108,8 @@ public class StringUtils {
/** /**
* Get ordinal version of numbers (1 = 1st, 5 = 5th etc.) * Get ordinal version of numbers (1 = 1st, 5 = 5th etc.)
* *
* @param number number * @param number
* number
* @return ordinal, string * @return ordinal, string
*/ */
public static String numberToOrdinal(int number) public static String numberToOrdinal(int number)
@ -119,7 +126,8 @@ public class StringUtils {
/** /**
* Format number with thousands separated by a dot. * Format number with thousands separated by a dot.
* *
* @param number number * @param number
* number
* @return string 12.004.225 * @return string 12.004.225
*/ */
public static String formatInt(long number) public static String formatInt(long number)

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
public interface CharValidator { public interface CharValidator {
public boolean isValid(char c); public boolean isValid(char c);

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
public class CharValidatorRegex implements CharValidator { public class CharValidatorRegex implements CharValidator {
private String formula; private String formula;

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
public class CharValidatorWhitelist implements CharValidator { public class CharValidatorWhitelist implements CharValidator {
private String whitelist; private String whitelist;

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
@ -19,7 +18,8 @@ public class FileSuffixFilter implements FileFilter {
/** /**
* Suffix filter * Suffix filter
* *
* @param suffixes var-args allowed suffixes, case insensitive * @param suffixes
* var-args allowed suffixes, case insensitive
*/ */
public FileSuffixFilter(String... suffixes) { public FileSuffixFilter(String... suffixes) {
this.suffixes = suffixes; this.suffixes = suffixes;

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
public class FilenameCharValidator extends CharValidatorRegex { public class FilenameCharValidator extends CharValidatorRegex {
public FilenameCharValidator() { public FilenameCharValidator() {

@ -1,6 +1,5 @@
package mightypork.utils.string.validation; package mightypork.utils.string.validation;
/** /**
* Utility interface for string filters (accepting filepaths and similar) * Utility interface for string filters (accepting filepaths and similar)
* *

@ -1,6 +1,5 @@
package mightypork.utils.time; package mightypork.utils.time;
/** /**
* Class for counting FPS in games.<br> * Class for counting FPS in games.<br>
* This class can be used also as a simple frequency meter - output is in Hz. * This class can be used also as a simple frequency meter - output is in Hz.
@ -44,7 +43,8 @@ public class FpsMeter {
/** /**
* Notification that some frames have been dropped * Notification that some frames have been dropped
* *
* @param dropped dropped frames * @param dropped
* dropped frames
*/ */
public void drop(int dropped) public void drop(int dropped)
{ {

@ -1,6 +1,5 @@
package mightypork.utils.time; package mightypork.utils.time;
public interface Pauseable { public interface Pauseable {
/** /**

@ -1,6 +1,5 @@
package mightypork.utils.time; package mightypork.utils.time;
/** /**
* Timer for delta timing * Timer for delta timing
* *

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save