Merge branch 'master' of https://gitlab.fel.cvut.cz/B132_a0b36pr2/hruskon5
This commit is contained in:
+12
-12
@@ -2,34 +2,34 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<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>
|
||||
<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>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jogg-0.0.7.jar">
|
||||
<classpathentry kind="lib" path="lib/jogg-0.0.7.jar" sourcepath="lib">
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileLock;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.rogue.display.DisplaySystem;
|
||||
import mightypork.rogue.input.InputSystem;
|
||||
import mightypork.rogue.sounds.SoundSystem;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.rogue.display.DisplaySystem;
|
||||
import mightypork.rogue.input.InputSystem;
|
||||
import mightypork.rogue.sounds.SoundSystem;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.utils.files.PropertyManager;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
/**
|
||||
* Application constants
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import mightypork.utils.files.OsUtils;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -61,7 +60,8 @@ public abstract class DelegatingBusClient extends AppAdapter implements Delegati
|
||||
/**
|
||||
* Remove a child subscriber
|
||||
*
|
||||
* @param client subscriber to remove
|
||||
* @param client
|
||||
* subscriber to remove
|
||||
*/
|
||||
public final void removeChildSubscriber(Object client)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.AppAdapter;
|
||||
|
||||
@@ -13,7 +12,8 @@ import mightypork.rogue.AppAdapter;
|
||||
public class SimpleBusClient extends AppAdapter {
|
||||
|
||||
/**
|
||||
* @param app app access
|
||||
* @param app
|
||||
* app access
|
||||
*/
|
||||
public SimpleBusClient(AppAccess app) {
|
||||
super(app);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.events.UpdateEvent;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -67,12 +66,14 @@ public class KeyboardEvent implements Handleable<KeyboardEvent.Listener> {
|
||||
keh.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Handle an event
|
||||
*
|
||||
* @param event event
|
||||
* @param event
|
||||
* event
|
||||
*/
|
||||
public void receive(KeyboardEvent event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -25,10 +24,14 @@ public class MouseButtonEvent implements Handleable<MouseButtonEvent.Listener> {
|
||||
/**
|
||||
* Mouse button event
|
||||
*
|
||||
* @param pos event position
|
||||
* @param button button id
|
||||
* @param down button pressed
|
||||
* @param wheeld wheel change
|
||||
* @param pos
|
||||
* event position
|
||||
* @param button
|
||||
* button id
|
||||
* @param down
|
||||
* button pressed
|
||||
* @param wheeld
|
||||
* wheel change
|
||||
*/
|
||||
public MouseButtonEvent(Coord pos, int button, boolean down, int wheeld) {
|
||||
this.button = button;
|
||||
@@ -107,12 +110,14 @@ public class MouseButtonEvent implements Handleable<MouseButtonEvent.Listener> {
|
||||
handler.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Handle an event
|
||||
*
|
||||
* @param event event
|
||||
* @param event
|
||||
* event
|
||||
*/
|
||||
public void receive(MouseButtonEvent event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -41,12 +40,14 @@ public class MouseMotionEvent implements Handleable<MouseMotionEvent.Listener> {
|
||||
keh.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Handle an event
|
||||
*
|
||||
* @param event event
|
||||
* @param event
|
||||
* event
|
||||
*/
|
||||
public void receive(MouseMotionEvent event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -43,6 +42,7 @@ public class ScreenChangeEvent implements Handleable<ScreenChangeEvent.Listener>
|
||||
handler.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(ScreenChangeEvent event);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
|
||||
@@ -26,6 +25,7 @@ public class UpdateEvent implements Handleable<UpdateEvent.Listener> {
|
||||
handler.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(UpdateEvent event);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -120,7 +119,8 @@ public class DisplaySystem extends DelegatingBusClient implements Bounding {
|
||||
glReadBuffer(GL_FRONT);
|
||||
int width = Display.getDisplayMode().getWidth();
|
||||
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);
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
@@ -52,7 +51,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
@@ -161,7 +161,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
|
||||
/**
|
||||
* Update GUI for new screen size
|
||||
*
|
||||
* @param size screen size
|
||||
* @param size
|
||||
* screen size
|
||||
*/
|
||||
protected void onSizeChanged(Coord size)
|
||||
{
|
||||
@@ -178,7 +179,8 @@ public abstract class Screen extends DelegatingBusClient implements KeyBinder, B
|
||||
/**
|
||||
* Update animations and timing
|
||||
*
|
||||
* @param delta time elapsed
|
||||
* @param delta
|
||||
* time elapsed
|
||||
*/
|
||||
protected abstract void updateScreen(double delta);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display.constraints;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display.constraints;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display.rendering;
|
||||
|
||||
|
||||
public interface Renderable {
|
||||
|
||||
public void render();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.display.rendering;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
@@ -21,6 +20,7 @@ public class FontManager {
|
||||
|
||||
private static final boolean DEBUG = Config.LOG_FONTS;
|
||||
|
||||
|
||||
/**
|
||||
* Glyph tables.
|
||||
*
|
||||
@@ -75,13 +75,13 @@ public class FontManager {
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Font style
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public static enum Style
|
||||
{
|
||||
public static enum Style {
|
||||
/** Normal */
|
||||
NORMAL,
|
||||
/** Italic */
|
||||
@@ -112,96 +112,100 @@ public class FontManager {
|
||||
OUTLINE;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Preloaded font identifier [name, size, style]
|
||||
// *
|
||||
// * @author MightyPork
|
||||
// */
|
||||
// public static class FontId {
|
||||
//
|
||||
// /** font size (pt) */
|
||||
// public float size = 24;
|
||||
// /** font name, registered with registerFile */
|
||||
// public String name = "";
|
||||
// /** font style. The given style must be in a file. */
|
||||
// public Style style;
|
||||
//
|
||||
// /** Set of glyphs in this ID */
|
||||
// public String glyphs = "";
|
||||
//
|
||||
// /** Index for faster comparision of glyph ids. */
|
||||
// public int glyphset_id = 0;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Preloaded font identifier
|
||||
// *
|
||||
// * @param name font name (registerFile)
|
||||
// * @param size font size (pt)
|
||||
// * @param style font style
|
||||
// * @param glyphs glyphs to load
|
||||
// */
|
||||
// public FontId(String name, double size, Style style, String glyphs) {
|
||||
// this.name = name;
|
||||
// this.size = (float) size;
|
||||
// this.style = style;
|
||||
//
|
||||
// if (glyphs.equals(Glyphs.basic)) {
|
||||
// glyphset_id = 1;
|
||||
// } else if (glyphs.equals(Glyphs.alnum)) {
|
||||
// glyphset_id = 2;
|
||||
// } else if (glyphs.equals(Glyphs.basic_text)) {
|
||||
// glyphset_id = 3;
|
||||
// } else if (glyphs.equals(Glyphs.numbers)) {
|
||||
// glyphset_id = 4;
|
||||
// } else if (glyphs.equals(Glyphs.alpha)) {
|
||||
// glyphset_id = 5;
|
||||
// } else if (glyphs.equals(Glyphs.all)) {
|
||||
// glyphset_id = 6;
|
||||
// } else if (glyphs.equals(Glyphs.alnum_extra)) {
|
||||
// glyphset_id = 7;
|
||||
// } else if (glyphs.equals(Glyphs.signs)) {
|
||||
// glyphset_id = 8;
|
||||
// } else if (glyphs.equals(Glyphs.signs_extra)) {
|
||||
// glyphset_id = 9;
|
||||
// } else {
|
||||
// this.glyphs = glyphs;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public boolean equals(Object obj)
|
||||
// {
|
||||
// if (obj == null) return false;
|
||||
// if (!(obj.getClass().isAssignableFrom(getClass()))) return false;
|
||||
// if (obj instanceof FontId) {
|
||||
// if (obj == this) return true;
|
||||
// FontId id2 = ((FontId) obj);
|
||||
// boolean flag = true;
|
||||
// flag &= id2.size == size;
|
||||
// flag &= id2.name.equals(name);
|
||||
// flag &= id2.style == style;
|
||||
// flag &= ((id2.glyphset_id != -1 && id2.glyphset_id == glyphset_id) || id2.glyphs.equals(glyphs));
|
||||
// return flag;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// 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") + "]";
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Preloaded font identifier [name, size, style]
|
||||
// *
|
||||
// * @author MightyPork
|
||||
// */
|
||||
// public static class FontId {
|
||||
//
|
||||
// /** font size (pt) */
|
||||
// public float size = 24;
|
||||
// /** font name, registered with registerFile */
|
||||
// public String name = "";
|
||||
// /** font style. The given style must be in a file. */
|
||||
// public Style style;
|
||||
//
|
||||
// /** Set of glyphs in this ID */
|
||||
// public String glyphs = "";
|
||||
//
|
||||
// /** Index for faster comparision of glyph ids. */
|
||||
// public int glyphset_id = 0;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Preloaded font identifier
|
||||
// *
|
||||
// * @param name font name (registerFile)
|
||||
// * @param size font size (pt)
|
||||
// * @param style font style
|
||||
// * @param glyphs glyphs to load
|
||||
// */
|
||||
// public FontId(String name, double size, Style style, String glyphs) {
|
||||
// this.name = name;
|
||||
// this.size = (float) size;
|
||||
// this.style = style;
|
||||
//
|
||||
// if (glyphs.equals(Glyphs.basic)) {
|
||||
// glyphset_id = 1;
|
||||
// } else if (glyphs.equals(Glyphs.alnum)) {
|
||||
// glyphset_id = 2;
|
||||
// } else if (glyphs.equals(Glyphs.basic_text)) {
|
||||
// glyphset_id = 3;
|
||||
// } else if (glyphs.equals(Glyphs.numbers)) {
|
||||
// glyphset_id = 4;
|
||||
// } else if (glyphs.equals(Glyphs.alpha)) {
|
||||
// glyphset_id = 5;
|
||||
// } else if (glyphs.equals(Glyphs.all)) {
|
||||
// glyphset_id = 6;
|
||||
// } else if (glyphs.equals(Glyphs.alnum_extra)) {
|
||||
// glyphset_id = 7;
|
||||
// } else if (glyphs.equals(Glyphs.signs)) {
|
||||
// glyphset_id = 8;
|
||||
// } else if (glyphs.equals(Glyphs.signs_extra)) {
|
||||
// glyphset_id = 9;
|
||||
// } else {
|
||||
// this.glyphs = glyphs;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public boolean equals(Object obj)
|
||||
// {
|
||||
// if (obj == null) return false;
|
||||
// if (!(obj.getClass().isAssignableFrom(getClass()))) return false;
|
||||
// if (obj instanceof FontId) {
|
||||
// if (obj == this) return true;
|
||||
// FontId id2 = ((FontId) obj);
|
||||
// boolean flag = true;
|
||||
// flag &= id2.size == size;
|
||||
// flag &= id2.name.equals(name);
|
||||
// flag &= id2.style == style;
|
||||
// flag &= ((id2.glyphset_id != -1 && id2.glyphset_id == glyphset_id) ||
|
||||
// id2.glyphs.equals(glyphs));
|
||||
// return flag;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// 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") + "]";
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Group of styles of one font.
|
||||
@@ -220,9 +224,12 @@ public class FontManager {
|
||||
/**
|
||||
* Register font file.
|
||||
*
|
||||
* @param path resource path (res/fonts/...)
|
||||
* @param name font name (for binding)
|
||||
* @param style font style in this file
|
||||
* @param path
|
||||
* resource path (res/fonts/...)
|
||||
* @param name
|
||||
* font name (for binding)
|
||||
* @param style
|
||||
* font style in this file
|
||||
*/
|
||||
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>
|
||||
* If needed file is not available, throws runtime exception.
|
||||
*
|
||||
* @param name font name (registerFile)
|
||||
* @param size font size (pt)
|
||||
* @param style font style
|
||||
* @param glyphs glyphs needed
|
||||
* @param name
|
||||
* font name (registerFile)
|
||||
* @param size
|
||||
* font size (pt)
|
||||
* @param style
|
||||
* font style
|
||||
* @param glyphs
|
||||
* glyphs needed
|
||||
* @return the loaded font.
|
||||
*/
|
||||
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>
|
||||
* If needed file is not available, throws runtime exception.
|
||||
*
|
||||
* @param name font name (registerFile)
|
||||
* @param size font size (pt)
|
||||
* @param style font style
|
||||
* @param glyphs glyphs needed
|
||||
* @param correctLeft 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
|
||||
* @param name
|
||||
* font name (registerFile)
|
||||
* @param size
|
||||
* font size (pt)
|
||||
* @param style
|
||||
* font style
|
||||
* @param glyphs
|
||||
* glyphs needed
|
||||
* @param correctLeft
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
import static mightypork.rogue.fonts.FontManager.Style.*;
|
||||
import mightypork.rogue.fonts.FontManager.Glyphs;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
import static mightypork.rogue.fonts.Align.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@@ -75,6 +74,7 @@ public class LoadedFont {
|
||||
private double clipVerticalT = 0;
|
||||
private double clipVerticalB = 0;
|
||||
|
||||
|
||||
private class CharStorageEntry {
|
||||
|
||||
/** Character's width */
|
||||
@@ -106,8 +106,8 @@ public class LoadedFont {
|
||||
public void setCorrection(boolean on)
|
||||
{
|
||||
if (on) {
|
||||
correctL = 9;//2
|
||||
correctR = 8;//1
|
||||
correctL = 9;// 2
|
||||
correctR = 8;// 1
|
||||
} else {
|
||||
correctL = 0;
|
||||
correctR = 0;
|
||||
@@ -422,7 +422,7 @@ public class LoadedFont {
|
||||
}
|
||||
totalwidth /= -2;
|
||||
}
|
||||
//if center get next lines total width/2;
|
||||
// if center get next lines total width/2;
|
||||
} else {
|
||||
//@formatter:off
|
||||
drawQuad(
|
||||
@@ -450,7 +450,8 @@ public class LoadedFont {
|
||||
try {
|
||||
short width = (short) bufferedImage.getWidth();
|
||||
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();
|
||||
ByteBuffer byteBuffer;
|
||||
DataBuffer db = bufferedImage.getData().getDataBuffer();
|
||||
@@ -571,11 +572,16 @@ public class LoadedFont {
|
||||
/**
|
||||
* Draw string with font.
|
||||
*
|
||||
* @param x x coord
|
||||
* @param y y coord
|
||||
* @param text text to draw
|
||||
* @param color render color
|
||||
* @param align (-1,0,1)
|
||||
* @param x
|
||||
* x coord
|
||||
* @param y
|
||||
* y coord
|
||||
* @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)
|
||||
{
|
||||
@@ -586,10 +592,14 @@ public class LoadedFont {
|
||||
/**
|
||||
* Draw string with font.
|
||||
*
|
||||
* @param pos coord
|
||||
* @param text text to draw
|
||||
* @param color render color
|
||||
* @param align (-1,0,1)
|
||||
* @param pos
|
||||
* coord
|
||||
* @param text
|
||||
* text to draw
|
||||
* @param color
|
||||
* render color
|
||||
* @param align
|
||||
* (-1,0,1)
|
||||
*/
|
||||
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);
|
||||
|
||||
//shadow
|
||||
// shadow
|
||||
int sh = blurSize;
|
||||
|
||||
int l = glGenLists(1);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
import mightypork.rogue.bus.events.KeyboardEvent;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
public interface KeyBinder {
|
||||
|
||||
/**
|
||||
* Bind handler to a keystroke, replace current handler if any
|
||||
*
|
||||
* @param stroke trigger keystroke
|
||||
* @param task handler
|
||||
* @param stroke
|
||||
* trigger keystroke
|
||||
* @param task
|
||||
* handler
|
||||
*/
|
||||
abstract void bindKeyStroke(KeyStroke stroke, Runnable task);
|
||||
|
||||
@@ -15,7 +16,8 @@ public interface KeyBinder {
|
||||
/**
|
||||
* Remove handler from a keystroke (id any)
|
||||
*
|
||||
* @param stroke stroke
|
||||
* @param stroke
|
||||
* stroke
|
||||
*/
|
||||
abstract void unbindKeyStroke(KeyStroke stroke);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import mightypork.rogue.bus.events.KeyboardEvent;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
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
|
||||
*
|
||||
* @param stroke trigger keystroke
|
||||
* @param task handler
|
||||
* @param stroke
|
||||
* trigger keystroke
|
||||
* @param task
|
||||
* handler
|
||||
*/
|
||||
@Override
|
||||
public void bindKeyStroke(KeyStroke stroke, Runnable task)
|
||||
@@ -43,7 +44,8 @@ public class KeyBindingPool implements KeyBinder, KeyboardEvent.Listener {
|
||||
/**
|
||||
* Remove handler from keystroke (id any)
|
||||
*
|
||||
* @param stroke stroke
|
||||
* @param stroke
|
||||
* stroke
|
||||
*/
|
||||
@Override
|
||||
public void unbindKeyStroke(KeyStroke stroke)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@@ -17,8 +16,10 @@ public class KeyStroke {
|
||||
/**
|
||||
* KeyStroke
|
||||
*
|
||||
* @param down true for falling edge, up for rising edge
|
||||
* @param keys keys that must be pressed
|
||||
* @param down
|
||||
* true for falling edge, up for rising edge
|
||||
* @param keys
|
||||
* keys that must be pressed
|
||||
*/
|
||||
public KeyStroke(boolean down, int... keys) {
|
||||
this.down = down;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -17,8 +16,7 @@ import org.newdawn.slick.openal.SoundStore;
|
||||
*/
|
||||
public class AudioX implements Destroyable {
|
||||
|
||||
private enum PlayMode
|
||||
{
|
||||
private enum PlayMode {
|
||||
EFFECT, MUSIC;
|
||||
};
|
||||
|
||||
@@ -37,7 +35,8 @@ public class AudioX implements Destroyable {
|
||||
/**
|
||||
* Create deferred primitive audio player
|
||||
*
|
||||
* @param resourceName resource to load when needed
|
||||
* @param resourceName
|
||||
* resource to load when needed
|
||||
*/
|
||||
public AudioX(String resourceName) {
|
||||
this.audio = null;
|
||||
@@ -102,7 +101,9 @@ public class AudioX implements Destroyable {
|
||||
public boolean load()
|
||||
{
|
||||
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;
|
||||
try {
|
||||
@@ -159,9 +160,12 @@ public class AudioX implements Destroyable {
|
||||
/**
|
||||
* Play as sound effect at listener position
|
||||
*
|
||||
* @param pitch pitch (1 = default)
|
||||
* @param gain gain (0-1)
|
||||
* @param loop looping
|
||||
* @param pitch
|
||||
* pitch (1 = default)
|
||||
* @param gain
|
||||
* gain (0-1)
|
||||
* @param loop
|
||||
* looping
|
||||
* @return source id
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param pitch pitch (1 = default)
|
||||
* @param gain gain (0-1)
|
||||
* @param loop looping
|
||||
* @param pitch
|
||||
* pitch (1 = default)
|
||||
* @param gain
|
||||
* gain (0-1)
|
||||
* @param loop
|
||||
* looping
|
||||
* @param x
|
||||
* @param y
|
||||
* @return source id
|
||||
@@ -189,9 +196,12 @@ public class AudioX implements Destroyable {
|
||||
/**
|
||||
* Play as sound effect at given position
|
||||
*
|
||||
* @param pitch pitch (1 = default)
|
||||
* @param gain gain (0-1)
|
||||
* @param loop looping
|
||||
* @param pitch
|
||||
* pitch (1 = default)
|
||||
* @param gain
|
||||
* gain (0-1)
|
||||
* @param loop
|
||||
* looping
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
@@ -212,10 +222,14 @@ public class AudioX implements Destroyable {
|
||||
/**
|
||||
* Play as sound effect at given position
|
||||
*
|
||||
* @param pitch pitch (1 = default)
|
||||
* @param gain gain (0-1)
|
||||
* @param loop looping
|
||||
* @param pos coord
|
||||
* @param pitch
|
||||
* pitch (1 = default)
|
||||
* @param gain
|
||||
* gain (0-1)
|
||||
* @param loop
|
||||
* looping
|
||||
* @param pos
|
||||
* coord
|
||||
* @return source id
|
||||
*/
|
||||
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>
|
||||
* Discouraged, since this does not allow cross-fading.
|
||||
*
|
||||
* @param pitch play pitch
|
||||
* @param gain play gain
|
||||
* @param loop looping
|
||||
* @param pitch
|
||||
* play pitch
|
||||
* @param gain
|
||||
* play gain
|
||||
* @param loop
|
||||
* looping
|
||||
* @return source
|
||||
*/
|
||||
public int playAsMusic(double pitch, double gain, boolean loop)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
@@ -18,7 +17,8 @@ public class JointVolume extends Mutable<Double> {
|
||||
/**
|
||||
* 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) {
|
||||
super(1D);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.objects.Mutable;
|
||||
import mightypork.utils.time.Pauseable;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
public class NullAudio extends AudioX {
|
||||
|
||||
public NullAudio() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -119,10 +118,14 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Register effect resource
|
||||
*
|
||||
* @param key sound key
|
||||
* @param resource resource path
|
||||
* @param pitch default pitch (1 = unchanged)
|
||||
* @param gain default gain (0-1)
|
||||
* @param key
|
||||
* sound key
|
||||
* @param resource
|
||||
* 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)
|
||||
{
|
||||
@@ -134,12 +137,18 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Register loop resource (music / effect loop)
|
||||
*
|
||||
* @param key sound key
|
||||
* @param resource resource path
|
||||
* @param pitch default pitch (1 = unchanged)
|
||||
* @param gain default gain (0-1)
|
||||
* @param fadeIn default time for fadeIn
|
||||
* @param fadeOut default time for fadeOut
|
||||
* @param key
|
||||
* sound key
|
||||
* @param resource
|
||||
* resource path
|
||||
* @param pitch
|
||||
* 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)
|
||||
{
|
||||
@@ -152,9 +161,11 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Create {@link AudioX} for a resource
|
||||
*
|
||||
* @param res a resource name
|
||||
* @param res
|
||||
* a resource name
|
||||
* @return the resource
|
||||
* @throws IllegalArgumentException if resource is already registered
|
||||
* @throws IllegalArgumentException
|
||||
* if resource is already registered
|
||||
*/
|
||||
private AudioX getResource(String res)
|
||||
{
|
||||
@@ -168,7 +179,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Get a loop player for key
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
* @return loop player
|
||||
*/
|
||||
public LoopPlayer getLoop(String key)
|
||||
@@ -185,7 +197,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Get a effect player for key
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
* @return effect player
|
||||
*/
|
||||
public EffectPlayer getEffect(String key)
|
||||
@@ -213,7 +226,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Fade in a loop (with default time)
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
*/
|
||||
public void fadeInLoop(String key)
|
||||
{
|
||||
@@ -224,8 +238,10 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Fade in a loop
|
||||
*
|
||||
* @param key sound key
|
||||
* @param seconds fade-in duration
|
||||
* @param key
|
||||
* sound key
|
||||
* @param seconds
|
||||
* fade-in duration
|
||||
*/
|
||||
public void fadeInLoop(String key, double seconds)
|
||||
{
|
||||
@@ -236,7 +252,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Fade out a loop (with default time)
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
*/
|
||||
public void fadeOutLoop(String key)
|
||||
{
|
||||
@@ -247,8 +264,10 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Fade out a loop
|
||||
*
|
||||
* @param key sound key
|
||||
* @param seconds fade-out duration
|
||||
* @param key
|
||||
* sound key
|
||||
* @param seconds
|
||||
* fade-out duration
|
||||
*/
|
||||
public void fadeOutLoop(String key, double seconds)
|
||||
{
|
||||
@@ -259,7 +278,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Pause a loop
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
*/
|
||||
public void pauseLoop(String key)
|
||||
{
|
||||
@@ -281,7 +301,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Resume a loop
|
||||
*
|
||||
* @param key sound key
|
||||
* @param key
|
||||
* sound key
|
||||
*/
|
||||
public void resumeLoop(String key)
|
||||
{
|
||||
@@ -292,7 +313,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of master volume
|
||||
*
|
||||
* @param d level
|
||||
* @param d
|
||||
* level
|
||||
*/
|
||||
public void setMasterVolume(double d)
|
||||
{
|
||||
@@ -303,7 +325,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of effects volume
|
||||
*
|
||||
* @param d level
|
||||
* @param d
|
||||
* level
|
||||
*/
|
||||
public void setEffectsVolume(double d)
|
||||
{
|
||||
@@ -314,7 +337,8 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of music volume
|
||||
*
|
||||
* @param d level
|
||||
* @param d
|
||||
* level
|
||||
*/
|
||||
public void setMusicVolume(double d)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.tasks;
|
||||
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.testing;
|
||||
|
||||
|
||||
import mightypork.rogue.display.constraints.Bounding;
|
||||
import mightypork.rogue.display.constraints.Constraint;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.testing;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -182,6 +181,7 @@ class StringMessage implements Handleable<StringMessage.Listener> {
|
||||
this.s = str;
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(StringMessage message);
|
||||
@@ -205,6 +205,7 @@ class IntMessage implements Handleable<IntMessage.Listener> {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(IntMessage message);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -52,8 +51,10 @@ public class TextureManager {
|
||||
/**
|
||||
* Bind texture
|
||||
*
|
||||
* @param texture the texture
|
||||
* @throws RuntimeException if not loaded yet
|
||||
* @param texture
|
||||
* the texture
|
||||
* @throws RuntimeException
|
||||
* if not loaded yet
|
||||
*/
|
||||
public static void bind(Texture texture) throws RuntimeException
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
// TODO rewrite
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
@@ -25,11 +24,16 @@ public class TxQuad {
|
||||
/**
|
||||
* Create TxQuad from left top coord and rect size
|
||||
*
|
||||
* @param tx texture
|
||||
* @param x1 left top X
|
||||
* @param y1 left top Y
|
||||
* @param width area width
|
||||
* @param height area height
|
||||
* @param tx
|
||||
* texture
|
||||
* @param x1
|
||||
* left top X
|
||||
* @param y1
|
||||
* left top Y
|
||||
* @param width
|
||||
* area width
|
||||
* @param height
|
||||
* area height
|
||||
* @return new TxQuad
|
||||
*/
|
||||
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 uvs Rect of texturwe UVs (pixels - from left top)
|
||||
* @param tx
|
||||
* Texture
|
||||
* @param uvs
|
||||
* Rect of texturwe UVs (pixels - from left top)
|
||||
*/
|
||||
public TxQuad(Texture tx, Rect uvs) {
|
||||
this.tx = tx;
|
||||
@@ -52,11 +58,16 @@ public class TxQuad {
|
||||
/**
|
||||
* Make of coords
|
||||
*
|
||||
* @param tx texture
|
||||
* @param x1 x1
|
||||
* @param y1 y1
|
||||
* @param x2 x2
|
||||
* @param y2 y2
|
||||
* @param tx
|
||||
* texture
|
||||
* @param x1
|
||||
* x1
|
||||
* @param y1
|
||||
* y1
|
||||
* @param x2
|
||||
* x2
|
||||
* @param y2
|
||||
* y2
|
||||
*/
|
||||
public TxQuad(Texture tx, int x1, int y1, int x2, int y2) {
|
||||
this.tx = tx;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.util;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import mightypork.rogue.textures.TextureManager;
|
||||
import mightypork.rogue.textures.TxQuad;
|
||||
@@ -27,8 +26,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
*/
|
||||
public static void quadCoord(Coord min, Coord max)
|
||||
{
|
||||
@@ -39,10 +40,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with absolute coords (from screen bottom)
|
||||
*
|
||||
* @param left left x
|
||||
* @param bottom bottom y
|
||||
* @param right right x
|
||||
* @param top top y
|
||||
* @param left
|
||||
* left x
|
||||
* @param bottom
|
||||
* bottom y
|
||||
* @param right
|
||||
* right x
|
||||
* @param top
|
||||
* top y
|
||||
*/
|
||||
public static void quadCoord(double left, double bottom, double right, double top)
|
||||
{
|
||||
@@ -58,11 +63,16 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with coloured border
|
||||
*
|
||||
* @param min min
|
||||
* @param max max
|
||||
* @param border border width
|
||||
* @param borderColor border color
|
||||
* @param insideColor filling color
|
||||
* @param min
|
||||
* min
|
||||
* @param max
|
||||
* max
|
||||
* @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)
|
||||
{
|
||||
@@ -73,13 +83,20 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with coloured border
|
||||
*
|
||||
* @param minX min x
|
||||
* @param minY min y
|
||||
* @param maxX max x
|
||||
* @param maxY max y
|
||||
* @param border border width
|
||||
* @param borderColor border color
|
||||
* @param insideColor filling color
|
||||
* @param minX
|
||||
* min x
|
||||
* @param minY
|
||||
* min y
|
||||
* @param maxX
|
||||
* max x
|
||||
* @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)
|
||||
{
|
||||
@@ -104,10 +121,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient horizontal
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param colorLeft color left
|
||||
* @param colorRight color right
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @param colorLeft
|
||||
* color left
|
||||
* @param colorRight
|
||||
* color right
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param minX units from left
|
||||
* @param minY units from bottom
|
||||
* @param maxX quad width
|
||||
* @param maxY quad height
|
||||
* @param colorLeft color left
|
||||
* @param colorRight color right
|
||||
* @param minX
|
||||
* units from left
|
||||
* @param minY
|
||||
* units from bottom
|
||||
* @param maxX
|
||||
* 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)
|
||||
{
|
||||
@@ -144,10 +171,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient horizontal
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param colorOuter color outer
|
||||
* @param colorMiddle color inner
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @param colorOuter
|
||||
* color outer
|
||||
* @param colorMiddle
|
||||
* color inner
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param minX min x
|
||||
* @param minY min y
|
||||
* @param maxX max x
|
||||
* @param maxY max y
|
||||
* @param colorOuter color outer
|
||||
* @param colorMiddle color inner
|
||||
* @param minX
|
||||
* min x
|
||||
* @param minY
|
||||
* min y
|
||||
* @param maxX
|
||||
* 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)
|
||||
{
|
||||
@@ -194,10 +231,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient vertical
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param colorTop top color
|
||||
* @param colorBottom bottom color
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @param colorTop
|
||||
* top color
|
||||
* @param colorBottom
|
||||
* bottom color
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param minX min X
|
||||
* @param minY min Y
|
||||
* @param maxX max X
|
||||
* @param maxY max Y
|
||||
* @param colorTop top color
|
||||
* @param colorBottom bottom color
|
||||
* @param minX
|
||||
* min X
|
||||
* @param minY
|
||||
* min Y
|
||||
* @param maxX
|
||||
* 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)
|
||||
{
|
||||
@@ -233,10 +280,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient vertical
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param colorOuter outer color
|
||||
* @param colorMiddle middle color
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @param colorOuter
|
||||
* outer color
|
||||
* @param colorMiddle
|
||||
* middle color
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param minX min X
|
||||
* @param minY min Y
|
||||
* @param maxX max X
|
||||
* @param maxY max Y
|
||||
* @param colorOuter outer color
|
||||
* @param colorMiddle middle color
|
||||
* @param minX
|
||||
* min X
|
||||
* @param minY
|
||||
* min Y
|
||||
* @param maxX
|
||||
* 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)
|
||||
{
|
||||
@@ -281,11 +338,16 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with coloured border with outset effect
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param border border width
|
||||
* @param fill fill color
|
||||
* @param inset true for inset, false for outset
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @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)
|
||||
{
|
||||
@@ -296,13 +358,20 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with coloured border with outset effect
|
||||
*
|
||||
* @param minX left X
|
||||
* @param minY bottom Y
|
||||
* @param maxX right X
|
||||
* @param maxY top Y
|
||||
* @param border border width
|
||||
* @param fill fill color
|
||||
* @param inset true for inset, false for outset
|
||||
* @param minX
|
||||
* left X
|
||||
* @param minY
|
||||
* bottom Y
|
||||
* @param maxX
|
||||
* right X
|
||||
* @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)
|
||||
{
|
||||
@@ -367,7 +436,8 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D
|
||||
*
|
||||
* @param rect rectangle
|
||||
* @param rect
|
||||
* rectangle
|
||||
*/
|
||||
public static void quadRect(Rect rect)
|
||||
{
|
||||
@@ -378,8 +448,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D
|
||||
*
|
||||
* @param rect rectangle
|
||||
* @param color draw color
|
||||
* @param rect
|
||||
* rectangle
|
||||
* @param color
|
||||
* draw color
|
||||
*/
|
||||
public static void quadRect(Rect rect, RGB color)
|
||||
{
|
||||
@@ -391,10 +463,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad with coloured border
|
||||
*
|
||||
* @param rect rect
|
||||
* @param border border width
|
||||
* @param borderColor border color
|
||||
* @param insideColor filling color
|
||||
* @param rect
|
||||
* rect
|
||||
* @param border
|
||||
* border width
|
||||
* @param borderColor
|
||||
* border color
|
||||
* @param insideColor
|
||||
* filling color
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param rect rect
|
||||
* @param colorLeft color left
|
||||
* @param colorRight color right
|
||||
* @param rect
|
||||
* rect
|
||||
* @param colorLeft
|
||||
* color left
|
||||
* @param colorRight
|
||||
* color right
|
||||
*/
|
||||
public static void quadGradH(Rect rect, RGB colorLeft, RGB colorRight)
|
||||
{
|
||||
@@ -418,9 +497,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient horizontal
|
||||
*
|
||||
* @param rect rect
|
||||
* @param colorOuter color outer
|
||||
* @param colorMiddle color inner
|
||||
* @param rect
|
||||
* rect
|
||||
* @param colorOuter
|
||||
* color outer
|
||||
* @param colorMiddle
|
||||
* color inner
|
||||
*/
|
||||
public static void quadGradHBilinear(Rect rect, RGB colorOuter, RGB colorMiddle)
|
||||
{
|
||||
@@ -431,9 +513,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient vertical
|
||||
*
|
||||
* @param rect rect
|
||||
* @param colorTop top color
|
||||
* @param colorBottom bottom color
|
||||
* @param rect
|
||||
* rect
|
||||
* @param colorTop
|
||||
* top color
|
||||
* @param colorBottom
|
||||
* bottom color
|
||||
*/
|
||||
public static void quadGradV(Rect rect, RGB colorTop, RGB colorBottom)
|
||||
{
|
||||
@@ -444,9 +529,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D with gradient vertical
|
||||
*
|
||||
* @param rect rect
|
||||
* @param colorOuter outer color
|
||||
* @param colorMiddle middle color
|
||||
* @param rect
|
||||
* rect
|
||||
* @param colorOuter
|
||||
* outer color
|
||||
* @param colorMiddle
|
||||
* middle color
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param rect rectangle
|
||||
* @param border border width
|
||||
* @param fill fill color
|
||||
* @param inset true for inset, false for outset
|
||||
* @param rect
|
||||
* rectangle
|
||||
* @param border
|
||||
* 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)
|
||||
{
|
||||
@@ -471,8 +563,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured rect (texture must be binded already)
|
||||
*
|
||||
* @param quad rectangle (px)
|
||||
* @param textureCoords texture coords (0-1)
|
||||
* @param quad
|
||||
* rectangle (px)
|
||||
* @param textureCoords
|
||||
* texture coords (0-1)
|
||||
*/
|
||||
public static void quadTexturedAbs(Rect quad, Rect textureCoords)
|
||||
{
|
||||
@@ -502,9 +596,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured rect
|
||||
*
|
||||
* @param quad rectangle (px)
|
||||
* @param txCoords texture coords rectangle (px)
|
||||
* @param texture texture instance
|
||||
* @param quad
|
||||
* rectangle (px)
|
||||
* @param txCoords
|
||||
* texture coords rectangle (px)
|
||||
* @param texture
|
||||
* texture instance
|
||||
*/
|
||||
public static void quadTextured(Rect quad, Rect txCoords, Texture texture)
|
||||
{
|
||||
@@ -515,10 +612,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured rect
|
||||
*
|
||||
* @param quad rectangle (px)
|
||||
* @param txCoords texture coords rectangle (px)
|
||||
* @param texture texture instance
|
||||
* @param tint color tint
|
||||
* @param quad
|
||||
* rectangle (px)
|
||||
* @param txCoords
|
||||
* texture coords rectangle (px)
|
||||
* @param texture
|
||||
* texture instance
|
||||
* @param tint
|
||||
* color tint
|
||||
*/
|
||||
public static void quadTextured(Rect quad, Rect txCoords, Texture texture, RGB tint)
|
||||
{
|
||||
@@ -536,8 +637,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured rect
|
||||
*
|
||||
* @param quad rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param quad
|
||||
* rectangle (px)
|
||||
* @param txquad
|
||||
* texture quad
|
||||
*/
|
||||
public static void quadTextured(Rect quad, TxQuad txquad)
|
||||
{
|
||||
@@ -548,9 +651,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured rect
|
||||
*
|
||||
* @param quad rectangle (px)
|
||||
* @param txquad texture instance
|
||||
* @param tint color tint
|
||||
* @param quad
|
||||
* rectangle (px)
|
||||
* @param txquad
|
||||
* texture instance
|
||||
* @param tint
|
||||
* color tint
|
||||
*/
|
||||
public static void quadTextured(Rect quad, TxQuad txquad, RGB tint)
|
||||
{
|
||||
@@ -561,10 +667,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param yOffsetTimes offset count (move frame down n times)
|
||||
* @param texture the texture
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* 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)
|
||||
{
|
||||
@@ -575,11 +685,16 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param yOffsetTimes offset count (move frame down n times)
|
||||
* @param texture the texture
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* rectangle in texture with the basic frame (px)
|
||||
* @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)
|
||||
{
|
||||
@@ -640,9 +755,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param texture the texture
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* rectangle in texture with the basic frame (px)
|
||||
* @param texture
|
||||
* the texture
|
||||
*/
|
||||
public static void quadTexturedFrame(Rect quadRect, Rect textureRect, Texture texture)
|
||||
{
|
||||
@@ -653,8 +771,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* texture quad
|
||||
*/
|
||||
public static void quadTexturedFrame(Rect quadRect, TxQuad txquad)
|
||||
{
|
||||
@@ -665,9 +785,12 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param yOffsetTimes offset count (move frame down n times)
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* texture quad
|
||||
* @param yOffsetTimes
|
||||
* offset count (move frame down n times)
|
||||
*/
|
||||
public static void quadTexturedFrame(Rect quadRect, TxQuad txquad, int yOffsetTimes)
|
||||
{
|
||||
@@ -678,10 +801,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render textured frame with borders
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param yOffsetTimes offset count (move frame down n times)
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* 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)
|
||||
{
|
||||
@@ -693,10 +820,14 @@ public class RenderUtils {
|
||||
* Render textured frame stretching horizontally (rect height = texture rect
|
||||
* height)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param texture the texture
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* 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)
|
||||
{
|
||||
@@ -708,11 +839,16 @@ public class RenderUtils {
|
||||
* Render textured frame stretching horizontally (rect height = texture rect
|
||||
* height)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param texture the texture
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* rectangle in texture with the basic frame (px)
|
||||
* @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)
|
||||
{
|
||||
@@ -737,7 +873,7 @@ public class RenderUtils {
|
||||
uvs = new Rect(tx1, ty1, tx1 + borderSize, ty2);
|
||||
quadTextured(verts, uvs, tx, tint);
|
||||
|
||||
// // mi
|
||||
// // mi
|
||||
verts = new Rect(x1 + borderSize, y2, x2 - borderSize, y1);
|
||||
uvs = new Rect(tx1 + borderSize, ty1, tx2 - borderSize, ty2);
|
||||
quadTextured(verts, uvs, tx, tint);
|
||||
@@ -753,9 +889,12 @@ public class RenderUtils {
|
||||
* Render textured frame stretching horizontally (rect height = texture rect
|
||||
* height)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* texture quad
|
||||
* @param borderSize
|
||||
* size of the unstretched horizontal border
|
||||
*/
|
||||
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
|
||||
* height)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* 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)
|
||||
{
|
||||
@@ -782,10 +925,14 @@ public class RenderUtils {
|
||||
* Render textured frame stretching vertically (rect width = texture rect
|
||||
* width)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param texture the texture
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* 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)
|
||||
{
|
||||
@@ -797,11 +944,16 @@ public class RenderUtils {
|
||||
* Render textured frame stretching vertically (rect width = texture rect
|
||||
* width)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param textureRect rectangle in texture with the basic frame (px)
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param texture the texture
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param textureRect
|
||||
* rectangle in texture with the basic frame (px)
|
||||
* @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)
|
||||
{
|
||||
@@ -844,9 +996,12 @@ public class RenderUtils {
|
||||
* Render textured frame stretching vertically (rect width = texture rect
|
||||
* width)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* texture quad
|
||||
* @param borderSize
|
||||
* size of the unstretched horizontal border
|
||||
*/
|
||||
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
|
||||
* width)
|
||||
*
|
||||
* @param quadRect drawn rectangle (px)
|
||||
* @param txquad texture quad
|
||||
* @param borderSize size of the unstretched horizontal border
|
||||
* @param tint color tint
|
||||
* @param quadRect
|
||||
* drawn rectangle (px)
|
||||
* @param txquad
|
||||
* 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)
|
||||
{
|
||||
@@ -873,10 +1032,14 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D
|
||||
*
|
||||
* @param left units from left
|
||||
* @param bottom units from bottom
|
||||
* @param width quad width
|
||||
* @param height quad height
|
||||
* @param left
|
||||
* units from left
|
||||
* @param bottom
|
||||
* units from bottom
|
||||
* @param width
|
||||
* quad width
|
||||
* @param height
|
||||
* quad height
|
||||
*/
|
||||
public static void quadSize(double left, double bottom, double width, double height)
|
||||
{
|
||||
@@ -892,7 +1055,8 @@ public class RenderUtils {
|
||||
/**
|
||||
* Bind GL color
|
||||
*
|
||||
* @param color RGB color
|
||||
* @param color
|
||||
* RGB color
|
||||
*/
|
||||
public static void setColor(RGB color)
|
||||
{
|
||||
@@ -903,8 +1067,10 @@ public class RenderUtils {
|
||||
/**
|
||||
* Bind GL color
|
||||
*
|
||||
* @param color RGB color
|
||||
* @param alpha alpha multiplier
|
||||
* @param color
|
||||
* RGB color
|
||||
* @param alpha
|
||||
* alpha multiplier
|
||||
*/
|
||||
public static void setColor(RGB color, double alpha)
|
||||
{
|
||||
@@ -915,7 +1081,8 @@ public class RenderUtils {
|
||||
/**
|
||||
* Translate with coord
|
||||
*
|
||||
* @param coord coord
|
||||
* @param coord
|
||||
* coord
|
||||
*/
|
||||
public static void translate(Coord coord)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.rogue.util;
|
||||
|
||||
|
||||
/**
|
||||
* Utils class
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -92,7 +91,8 @@ public class FileTreeDiff {
|
||||
if (read1 == -1) break;
|
||||
}
|
||||
|
||||
} catch (IOException e) {} finally {
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
try {
|
||||
if (cin1 != null) cin1.close();
|
||||
} catch (IOException e) {
|
||||
@@ -140,6 +140,7 @@ public class FileTreeDiff {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class NotEqualException extends Exception {
|
||||
|
||||
public NotEqualException(String msg) {
|
||||
@@ -148,6 +149,7 @@ public class FileTreeDiff {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class Tuple<T> {
|
||||
|
||||
public T a;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -15,9 +14,12 @@ public class FileUtils {
|
||||
/**
|
||||
* Copy directory recursively.
|
||||
*
|
||||
* @param source source file
|
||||
* @param target target file
|
||||
* @throws IOException on error
|
||||
* @param source
|
||||
* source file
|
||||
* @param target
|
||||
* target file
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public static void copyDirectory(File source, File target) throws IOException
|
||||
{
|
||||
@@ -28,11 +30,16 @@ public class FileUtils {
|
||||
/**
|
||||
* Copy directory recursively - advanced variant.
|
||||
*
|
||||
* @param source source file
|
||||
* @param target target file
|
||||
* @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
|
||||
* @param source
|
||||
* source file
|
||||
* @param target
|
||||
* target file
|
||||
* @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
|
||||
{
|
||||
@@ -62,10 +69,14 @@ public class FileUtils {
|
||||
/**
|
||||
* List directory recursively
|
||||
*
|
||||
* @param source source file
|
||||
* @param filter filter accepting only files and dirs to be copied (or null)
|
||||
* @param files list of the found files
|
||||
* @throws IOException on error
|
||||
* @param source
|
||||
* source file
|
||||
* @param filter
|
||||
* 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
|
||||
{
|
||||
@@ -88,9 +99,12 @@ public class FileUtils {
|
||||
/**
|
||||
* Copy file using streams. Make sure target directory exists!
|
||||
*
|
||||
* @param source source file
|
||||
* @param target target file
|
||||
* @throws IOException on error
|
||||
* @param source
|
||||
* source file
|
||||
* @param target
|
||||
* target file
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param in input stream
|
||||
* @param out output stream
|
||||
* @throws IOException on error
|
||||
* @param in
|
||||
* input stream
|
||||
* @param out
|
||||
* output stream
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public static void copyStream(InputStream in, OutputStream out) throws IOException
|
||||
{
|
||||
@@ -145,8 +162,10 @@ public class FileUtils {
|
||||
/**
|
||||
* Improved delete
|
||||
*
|
||||
* @param path deleted path
|
||||
* @param recursive recursive delete
|
||||
* @param path
|
||||
* deleted path
|
||||
* @param recursive
|
||||
* recursive delete
|
||||
* @return success
|
||||
*/
|
||||
public static boolean delete(File path, boolean recursive)
|
||||
@@ -169,7 +188,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Read entire file to a string.
|
||||
*
|
||||
* @param file file
|
||||
* @param file
|
||||
* file
|
||||
* @return file contents
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -184,7 +204,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Get files in a folder (create folder if needed)
|
||||
*
|
||||
* @param dir folder
|
||||
* @param dir
|
||||
* folder
|
||||
* @return list of files
|
||||
*/
|
||||
public static List<File> listDirectory(File dir)
|
||||
@@ -196,8 +217,10 @@ public class FileUtils {
|
||||
/**
|
||||
* Get files in a folder (create folder if needed)
|
||||
*
|
||||
* @param dir folder
|
||||
* @param filter file filter
|
||||
* @param dir
|
||||
* folder
|
||||
* @param filter
|
||||
* file filter
|
||||
* @return list of files
|
||||
*/
|
||||
public static List<File> listDirectory(File dir, FileFilter filter)
|
||||
@@ -225,7 +248,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Remove extension.
|
||||
*
|
||||
* @param file file
|
||||
* @param file
|
||||
* file
|
||||
* @return filename without extension
|
||||
*/
|
||||
public static String[] getFilenameParts(File file)
|
||||
@@ -276,7 +300,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Read entire input stream to a string, and close it.
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
* @return file contents
|
||||
*/
|
||||
public static String streamToString(InputStream in)
|
||||
@@ -288,8 +313,10 @@ public class FileUtils {
|
||||
/**
|
||||
* Read input stream to a string, and close it.
|
||||
*
|
||||
* @param in input stream
|
||||
* @param lines max number of lines (-1 to disable limit)
|
||||
* @param in
|
||||
* input stream
|
||||
* @param lines
|
||||
* max number of lines (-1 to disable limit)
|
||||
* @return file contents
|
||||
*/
|
||||
public static String streamToString(InputStream in, int lines)
|
||||
@@ -357,9 +384,12 @@ public class FileUtils {
|
||||
/**
|
||||
* Save string to file
|
||||
*
|
||||
* @param file file
|
||||
* @param text string
|
||||
* @throws IOException on error
|
||||
* @param file
|
||||
* file
|
||||
* @param text
|
||||
* string
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param filestring filename string
|
||||
* @param filestring
|
||||
* filename string
|
||||
* @return escaped
|
||||
*/
|
||||
public static String escapeFileString(String filestring)
|
||||
@@ -427,7 +458,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Unescape filename string obtained by escapeFileString().
|
||||
*
|
||||
* @param filestring escaped string
|
||||
* @param filestring
|
||||
* escaped string
|
||||
* @return clean string
|
||||
*/
|
||||
public static String unescapeFileString(String filestring)
|
||||
@@ -442,7 +474,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Escape filename, keeping the same extension
|
||||
*
|
||||
* @param filename filename
|
||||
* @param filename
|
||||
* filename
|
||||
* @return escaped
|
||||
*/
|
||||
public static String escapeFilename(String filename)
|
||||
@@ -456,7 +489,8 @@ public class FileUtils {
|
||||
/**
|
||||
* Unescape filename, keeping the same extension
|
||||
*
|
||||
* @param filename escaped filename
|
||||
* @param filename
|
||||
* escaped filename
|
||||
* @return unesaped
|
||||
*/
|
||||
public static String unescapeFilename(String filename)
|
||||
@@ -482,8 +516,10 @@ public class FileUtils {
|
||||
/**
|
||||
* Copy resource to file
|
||||
*
|
||||
* @param resname resource name
|
||||
* @param file out file
|
||||
* @param resname
|
||||
* resource name
|
||||
* @param file
|
||||
* out 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.
|
||||
*
|
||||
* @param resname resource name
|
||||
* @param resname
|
||||
* resource name
|
||||
* @return resource as string, empty string on failure
|
||||
*/
|
||||
public static String resourceToString(String resname)
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class OsUtils {
|
||||
|
||||
public static enum EnumOS
|
||||
{
|
||||
public static enum EnumOS {
|
||||
linux, macos, solaris, unknown, windows;
|
||||
|
||||
public boolean isLinux()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -196,8 +195,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Set additional comment to a key
|
||||
*
|
||||
* @param key key for comment
|
||||
* @param comment the comment
|
||||
* @param key
|
||||
* key for comment
|
||||
* @param comment
|
||||
* the 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
|
||||
* "ISO-8859-1" by default)
|
||||
@@ -337,6 +339,7 @@ public class PropertyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property entry in Property manager.
|
||||
*
|
||||
@@ -363,10 +366,14 @@ public class PropertyManager {
|
||||
/**
|
||||
* Property
|
||||
*
|
||||
* @param key key
|
||||
* @param default_value default value
|
||||
* @param entry_type type
|
||||
* @param entry_comment entry comment
|
||||
* @param key
|
||||
* key
|
||||
* @param default_value
|
||||
* default value
|
||||
* @param entry_type
|
||||
* type
|
||||
* @param entry_comment
|
||||
* entry comment
|
||||
*/
|
||||
public Property(String key, boolean default_value, PropertyType entry_type, String entry_comment) {
|
||||
name = key;
|
||||
@@ -379,10 +386,14 @@ public class PropertyManager {
|
||||
/**
|
||||
* Property entry
|
||||
*
|
||||
* @param key property key
|
||||
* @param default_value default value
|
||||
* @param entry_type property type from enum
|
||||
* @param entry_comment property comment or null
|
||||
* @param key
|
||||
* property key
|
||||
* @param default_value
|
||||
* 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) {
|
||||
name = key;
|
||||
@@ -395,10 +406,14 @@ public class PropertyManager {
|
||||
/**
|
||||
* Property
|
||||
*
|
||||
* @param key key
|
||||
* @param default_value default value
|
||||
* @param entry_type type
|
||||
* @param entry_comment entry comment
|
||||
* @param key
|
||||
* key
|
||||
* @param default_value
|
||||
* default value
|
||||
* @param entry_type
|
||||
* type
|
||||
* @param entry_comment
|
||||
* entry comment
|
||||
*/
|
||||
public Property(String key, String default_value, PropertyType entry_type, String entry_comment) {
|
||||
name = key;
|
||||
@@ -476,7 +491,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Load property value from a file
|
||||
*
|
||||
* @param string the string loaded
|
||||
* @param string
|
||||
* the string loaded
|
||||
* @return was OK
|
||||
*/
|
||||
public boolean parse(String string)
|
||||
@@ -581,11 +597,11 @@ public class PropertyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property types
|
||||
*/
|
||||
private enum PropertyType
|
||||
{
|
||||
private enum PropertyType {
|
||||
BOOLEAN, INT, STRING, DOUBLE;
|
||||
}
|
||||
|
||||
@@ -610,8 +626,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Create property manager from file path and an initial comment.
|
||||
*
|
||||
* @param file file with the props
|
||||
* @param comment the initial comment. Use \n in it if you want.
|
||||
* @param file
|
||||
* file with the props
|
||||
* @param comment
|
||||
* the initial comment. Use \n in it if you want.
|
||||
*/
|
||||
public PropertyManager(File file, String comment) {
|
||||
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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
@@ -729,7 +749,8 @@ public class PropertyManager {
|
||||
|
||||
|
||||
/**
|
||||
* @param forceSave save even if unchanged.
|
||||
* @param forceSave
|
||||
* save even if unchanged.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
@@ -749,7 +771,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get a property entry (rarely used)
|
||||
*
|
||||
* @param n key
|
||||
* @param n
|
||||
* key
|
||||
* @return the entry
|
||||
*/
|
||||
private Property get(String n)
|
||||
@@ -765,7 +788,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get boolean property
|
||||
*
|
||||
* @param n key
|
||||
* @param n
|
||||
* key
|
||||
* @return the boolean found, or false
|
||||
*/
|
||||
public Boolean getBoolean(String n)
|
||||
@@ -781,7 +805,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get numeric property
|
||||
*
|
||||
* @param n key
|
||||
* @param n
|
||||
* key
|
||||
* @return the int found, or null
|
||||
*/
|
||||
public Integer getInteger(String n)
|
||||
@@ -797,7 +822,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get numeric property as double
|
||||
*
|
||||
* @param n key
|
||||
* @param n
|
||||
* key
|
||||
* @return the double found, or null
|
||||
*/
|
||||
public Double getDouble(String n)
|
||||
@@ -813,7 +839,8 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get string property
|
||||
*
|
||||
* @param n key
|
||||
* @param n
|
||||
* key
|
||||
* @return the string found, or null
|
||||
*/
|
||||
public String getString(String n)
|
||||
@@ -829,8 +856,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a boolean property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
*/
|
||||
public void putBoolean(String n, boolean d)
|
||||
{
|
||||
@@ -842,9 +871,12 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a boolean property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param comment the in-file comment
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
* @param comment
|
||||
* the in-file comment
|
||||
*/
|
||||
public void putBoolean(String n, boolean d, String comment)
|
||||
{
|
||||
@@ -856,8 +888,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a numeric property (double)
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
*/
|
||||
public void putDouble(String n, int d)
|
||||
{
|
||||
@@ -869,9 +903,12 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a numeric property (double)
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param comment the in-file comment
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
* @param comment
|
||||
* the in-file comment
|
||||
*/
|
||||
public void putDouble(String n, int d, String comment)
|
||||
{
|
||||
@@ -883,8 +920,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a numeric property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
*/
|
||||
public void putInteger(String n, int d)
|
||||
{
|
||||
@@ -896,9 +935,12 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a numeric property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param comment the in-file comment
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
* @param comment
|
||||
* the in-file comment
|
||||
*/
|
||||
public void putInteger(String n, int d, String comment)
|
||||
{
|
||||
@@ -910,8 +952,10 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a string property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
*/
|
||||
public void putString(String n, String d)
|
||||
{
|
||||
@@ -923,9 +967,12 @@ public class PropertyManager {
|
||||
/**
|
||||
* Add a string property
|
||||
*
|
||||
* @param n key
|
||||
* @param d default value
|
||||
* @param comment the in-file comment
|
||||
* @param n
|
||||
* key
|
||||
* @param d
|
||||
* default value
|
||||
* @param comment
|
||||
* the in-file 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
|
||||
*
|
||||
* @param oldKey old key
|
||||
* @param newKey new key
|
||||
* @param oldKey
|
||||
* old key
|
||||
* @param newKey
|
||||
* new key
|
||||
*/
|
||||
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
|
||||
* values.
|
||||
*
|
||||
* @param key key
|
||||
* @param value the saved value
|
||||
* @param key
|
||||
* key
|
||||
* @param value
|
||||
* the saved value
|
||||
*/
|
||||
public void setValue(String key, Object value)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -26,7 +25,8 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load list from file
|
||||
*
|
||||
* @param file file
|
||||
* @param file
|
||||
* file
|
||||
* @return map of keys and values
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -41,7 +41,8 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load map from file
|
||||
*
|
||||
* @param file file
|
||||
* @param file
|
||||
* file
|
||||
* @return map of keys and values
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -56,7 +57,8 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load list from string
|
||||
*
|
||||
* @param text text of the file
|
||||
* @param text
|
||||
* text of the file
|
||||
* @return map of keys and values
|
||||
*/
|
||||
public static List<String> listFromString(String text)
|
||||
@@ -86,7 +88,8 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load map from string
|
||||
*
|
||||
* @param text text of the file
|
||||
* @param text
|
||||
* text of the file
|
||||
* @return map of keys and values
|
||||
*/
|
||||
public static Map<String, String> mapFromString(String text)
|
||||
@@ -142,7 +145,8 @@ public class SimpleConfig {
|
||||
*
|
||||
* @param target
|
||||
* @param data
|
||||
* @param allowNulls allow nulls.
|
||||
* @param allowNulls
|
||||
* allow nulls.
|
||||
* @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);
|
||||
}
|
||||
|
||||
String text = ""; //# File written by SimpleConfig
|
||||
String text = ""; // # File written by SimpleConfig
|
||||
|
||||
for (String s : lines) {
|
||||
if (text.length() > 0) text += "\n";
|
||||
@@ -186,7 +190,7 @@ public class SimpleConfig {
|
||||
*/
|
||||
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) {
|
||||
if (text.length() > 0) text += "\n";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -21,9 +20,10 @@ public class ZipBuilder {
|
||||
|
||||
|
||||
/**
|
||||
* @param target target zip file
|
||||
* @throws FileNotFoundException if the file is directory or cannot be
|
||||
* created
|
||||
* @param target
|
||||
* target zip file
|
||||
* @throws FileNotFoundException
|
||||
* if the file is directory or cannot be created
|
||||
*/
|
||||
public ZipBuilder(File target) throws FileNotFoundException {
|
||||
target.getParentFile().mkdirs();
|
||||
@@ -36,8 +36,10 @@ public class ZipBuilder {
|
||||
/**
|
||||
* Add stream to a path
|
||||
*
|
||||
* @param path path
|
||||
* @param in stream
|
||||
* @param path
|
||||
* path
|
||||
* @param in
|
||||
* stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addStream(String path, InputStream in) throws IOException
|
||||
@@ -58,8 +60,10 @@ public class ZipBuilder {
|
||||
/**
|
||||
* Add string as a file
|
||||
*
|
||||
* @param path path
|
||||
* @param text text to write
|
||||
* @param path
|
||||
* path
|
||||
* @param text
|
||||
* text to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addString(String path, String text) throws IOException
|
||||
@@ -78,8 +82,10 @@ public class ZipBuilder {
|
||||
/**
|
||||
* Add resource obtained via FileUtils.getResource()
|
||||
*
|
||||
* @param path path
|
||||
* @param resPath resource path
|
||||
* @param path
|
||||
* path
|
||||
* @param resPath
|
||||
* resource path
|
||||
* @throws IOException
|
||||
*/
|
||||
public void addResource(String path, String resPath) throws IOException
|
||||
@@ -98,7 +104,8 @@ public class ZipBuilder {
|
||||
/**
|
||||
* Normalize path
|
||||
*
|
||||
* @param path original path
|
||||
* @param path
|
||||
* original path
|
||||
* @return normalized path
|
||||
*/
|
||||
private String preparePath(String path)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -28,9 +27,12 @@ public class ZipUtils {
|
||||
/**
|
||||
* Extract zip file to target directory
|
||||
*
|
||||
* @param file zip file
|
||||
* @param outputDir target directory
|
||||
* @param filter string filter (will be used to test entry names (paths))
|
||||
* @param file
|
||||
* zip file
|
||||
* @param outputDir
|
||||
* target directory
|
||||
* @param filter
|
||||
* string filter (will be used to test entry names (paths))
|
||||
* @return list of entries extracted (paths)
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -46,7 +48,7 @@ public class ZipUtils {
|
||||
try {
|
||||
if (zip != null) zip.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,9 +57,12 @@ public class ZipUtils {
|
||||
/**
|
||||
* Extract zip file to target directory
|
||||
*
|
||||
* @param zip open zip file
|
||||
* @param outputDir target directory
|
||||
* @param filter string filter (will be used to test entry names (paths))
|
||||
* @param zip
|
||||
* open zip file
|
||||
* @param outputDir
|
||||
* target directory
|
||||
* @param filter
|
||||
* string filter (will be used to test entry names (paths))
|
||||
* @return list of entries extracted (paths)
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -96,9 +101,11 @@ public class ZipUtils {
|
||||
/**
|
||||
* 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
|
||||
* @throws IOException on error
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public static List<String> listZip(File zipFile) throws IOException
|
||||
{
|
||||
@@ -110,7 +117,7 @@ public class ZipUtils {
|
||||
try {
|
||||
if (zip != null) zip.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,9 +126,11 @@ public class ZipUtils {
|
||||
/**
|
||||
* 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
|
||||
* @throws IOException on error
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public static List<String> listZip(ZipFile zip) throws IOException
|
||||
{
|
||||
@@ -145,10 +154,14 @@ public class ZipUtils {
|
||||
/**
|
||||
* Extract one zip entry to target file
|
||||
*
|
||||
* @param zip open zip file
|
||||
* @param entry entry from the zip file
|
||||
* @param destFile destination file ((NOT directory!)
|
||||
* @throws IOException on error
|
||||
* @param zip
|
||||
* open zip file
|
||||
* @param entry
|
||||
* 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
|
||||
{
|
||||
@@ -168,13 +181,13 @@ public class ZipUtils {
|
||||
try {
|
||||
if (is != null) is.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
if (dest != null) dest.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
|
||||
}
|
||||
@@ -184,10 +197,13 @@ public class ZipUtils {
|
||||
/**
|
||||
* Load zip entry to String
|
||||
*
|
||||
* @param zip open zip file
|
||||
* @param entry entry from the zip file
|
||||
* @param zip
|
||||
* open zip file
|
||||
* @param entry
|
||||
* entry from the zip file
|
||||
* @return loaded string
|
||||
* @throws IOException on error
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public static String zipEntryToString(ZipFile zip, ZipEntry entry) throws IOException
|
||||
{
|
||||
@@ -200,7 +216,7 @@ public class ZipUtils {
|
||||
try {
|
||||
if (is != null) is.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +235,7 @@ public class ZipUtils {
|
||||
try {
|
||||
if (zf != null) zf.close();
|
||||
} catch (IOException e) {
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -23,6 +22,7 @@ public abstract class AbstractIonList<T> extends ArrayList<T> implements Ionizab
|
||||
byte b = StreamUtils.readByte(in);
|
||||
|
||||
if (b == IonMarks.ENTRY) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T value = (T) Ion.readObject(in);
|
||||
add(value);
|
||||
} 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
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
*/
|
||||
public void ionReadCustomData(InputStream in)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write custom data of this AbstractIonList implementation
|
||||
*
|
||||
* @param out output stream
|
||||
* @param out
|
||||
* output stream
|
||||
*/
|
||||
public void ionWriteCustomData(OutputStream out)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -37,13 +36,11 @@ public abstract class AbstractIonMap<V> extends LinkedHashMap<String, V> impleme
|
||||
byte b = StreamUtils.readByte(in);
|
||||
if (b == IonMarks.ENTRY) {
|
||||
String key = StreamUtils.readStringBytes(in);
|
||||
V value;
|
||||
try {
|
||||
value = (V) Ion.readObject(in);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
V value = (V) Ion.readObject(in);
|
||||
put(key, value);
|
||||
} catch (IonException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else if (b == IonMarks.END) {
|
||||
break;
|
||||
} else {
|
||||
@@ -77,19 +74,23 @@ public abstract class AbstractIonMap<V> extends LinkedHashMap<String, V> impleme
|
||||
/**
|
||||
* Read custom data of this AbstractIonMap implementation
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
*/
|
||||
public void ionReadCustomData(InputStream in)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write custom data of this AbstractIonMap implementation
|
||||
*
|
||||
* @param out output stream
|
||||
* @param out
|
||||
* output stream
|
||||
*/
|
||||
public void ionWriteCustomData(OutputStream out)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -32,8 +31,10 @@ public class Ion {
|
||||
/**
|
||||
* Register new Ionizable for direct reconstructing.
|
||||
*
|
||||
* @param mark byte mark to be used, see {@link IonMarks} for reference.
|
||||
* @param objClass class of the registered Ionizable
|
||||
* @param mark
|
||||
* byte mark to be used, see {@link IonMarks} for reference.
|
||||
* @param objClass
|
||||
* class of the registered Ionizable
|
||||
* @throws IonException
|
||||
*/
|
||||
public static void registerIonizable(byte mark, Class<?> objClass) throws IonException
|
||||
@@ -48,7 +49,8 @@ public class Ion {
|
||||
/**
|
||||
* Load Ion object from file.
|
||||
*
|
||||
* @param file file path
|
||||
* @param file
|
||||
* file path
|
||||
* @return the loaded object
|
||||
* @throws IonException
|
||||
*/
|
||||
@@ -61,9 +63,11 @@ public class Ion {
|
||||
/**
|
||||
* Load Ion object from file.
|
||||
*
|
||||
* @param file file
|
||||
* @param file
|
||||
* file
|
||||
* @return the loaded object
|
||||
* @throws IonException on failure
|
||||
* @throws IonException
|
||||
* on failure
|
||||
*/
|
||||
public static Object fromFile(File file) throws IonException
|
||||
{
|
||||
@@ -90,7 +94,8 @@ public class Ion {
|
||||
/**
|
||||
* Load Ion object from stream.
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
* @return the loaded object
|
||||
* @throws IonException
|
||||
*/
|
||||
@@ -103,8 +108,10 @@ public class Ion {
|
||||
/**
|
||||
* Store Ion object to file.
|
||||
*
|
||||
* @param path file path
|
||||
* @param obj object to store
|
||||
* @param path
|
||||
* file path
|
||||
* @param obj
|
||||
* object to store
|
||||
* @throws IonException
|
||||
*/
|
||||
public static void toFile(String path, Object obj) throws IonException
|
||||
@@ -116,8 +123,10 @@ public class Ion {
|
||||
/**
|
||||
* Store Ion object to file.
|
||||
*
|
||||
* @param path file path
|
||||
* @param obj object to store
|
||||
* @param path
|
||||
* file path
|
||||
* @param obj
|
||||
* object to store
|
||||
* @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.
|
||||
*
|
||||
* @param out output stream *
|
||||
* @param obj object to store
|
||||
* @param out
|
||||
* output stream *
|
||||
* @param obj
|
||||
* object to store
|
||||
* @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
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
* @return the loaded object
|
||||
* @throws IonException
|
||||
*/
|
||||
@@ -221,8 +233,10 @@ public class Ion {
|
||||
/**
|
||||
* Write single ionizable or primitive object to output stream
|
||||
*
|
||||
* @param out output stream
|
||||
* @param obj stored object
|
||||
* @param out
|
||||
* output stream
|
||||
* @param obj
|
||||
* stored object
|
||||
* @throws IonException
|
||||
*/
|
||||
public static void writeObject(OutputStream out, Object obj) throws IonException
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
public class IonException extends Exception {
|
||||
|
||||
public IonException() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable Arraylist
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable HashMap
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Byte marks used to structure data in Ion files.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -18,7 +17,8 @@ public interface Ionizable {
|
||||
* Load data from the input stream. Mark has already been read, begin
|
||||
* reading right after it.
|
||||
*
|
||||
* @param in input stream
|
||||
* @param in
|
||||
* input stream
|
||||
* @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
|
||||
* after it.
|
||||
*
|
||||
* @param out Output stream
|
||||
* @param out
|
||||
* Output stream
|
||||
* @throws IonException
|
||||
*/
|
||||
public void ionWrite(OutputStream out) throws IonException;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Optional ionizable
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -14,7 +13,8 @@ public class Log {
|
||||
/**
|
||||
* Log FINE message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void f1(String msg)
|
||||
{
|
||||
@@ -25,7 +25,8 @@ public class Log {
|
||||
/**
|
||||
* Log FINER message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void f2(String msg)
|
||||
{
|
||||
@@ -36,7 +37,8 @@ public class Log {
|
||||
/**
|
||||
* Log FINEST message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void f3(String msg)
|
||||
{
|
||||
@@ -47,7 +49,8 @@ public class Log {
|
||||
/**
|
||||
* Log INFO message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void i(String msg)
|
||||
{
|
||||
@@ -58,7 +61,8 @@ public class Log {
|
||||
/**
|
||||
* Log WARNING message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void w(String msg)
|
||||
{
|
||||
@@ -69,7 +73,8 @@ public class Log {
|
||||
/**
|
||||
* Log ERROR message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public static void e(String msg)
|
||||
{
|
||||
@@ -80,8 +85,10 @@ public class Log {
|
||||
/**
|
||||
* Log EXCEPTION and ERROR message in main logger
|
||||
*
|
||||
* @param msg message
|
||||
* @param thrown thrown exception
|
||||
* @param msg
|
||||
* message
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
*/
|
||||
public static void e(String msg, Throwable thrown)
|
||||
{
|
||||
@@ -92,7 +99,8 @@ public class Log {
|
||||
/**
|
||||
* Log EXCEPTION in main logger
|
||||
*
|
||||
* @param thrown thrown exception
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
*/
|
||||
public static void e(Throwable thrown)
|
||||
{
|
||||
@@ -109,7 +117,8 @@ public class Log {
|
||||
/**
|
||||
* Enable / disable static log delegate methods
|
||||
*
|
||||
* @param flag enable
|
||||
* @param flag
|
||||
* enable
|
||||
*/
|
||||
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
|
||||
* available via the static methods.
|
||||
*
|
||||
* @param logName log name (used for filename, must be application-unique)
|
||||
* @param logsDir directory to store logs in
|
||||
* @param oldLogsCount number of old logs to keep, -1 for infinite, 0 for
|
||||
* none.
|
||||
* @param logName
|
||||
* log name (used for filename, must be application-unique)
|
||||
* @param logsDir
|
||||
* directory to store logs in
|
||||
* @param oldLogsCount
|
||||
* number of old logs to keep, -1 for infinite, 0 for none.
|
||||
* @return the created Log instance
|
||||
*/
|
||||
public static synchronized LogInstance create(String logName, File logsDir, int oldLogsCount)
|
||||
@@ -146,8 +157,10 @@ public class Log {
|
||||
* available via the static methods.<br>
|
||||
* Old logs will be kept.
|
||||
*
|
||||
* @param logName log name (used for filename, must be application-unique)
|
||||
* @param logsDir directory to store logs in
|
||||
* @param logName
|
||||
* log name (used for filename, must be application-unique)
|
||||
* @param logsDir
|
||||
* directory to store logs in
|
||||
* @return the created Log instance
|
||||
*/
|
||||
public static synchronized LogInstance create(String logName, File logsDir)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.PrintWriter;
|
||||
@@ -151,7 +150,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Add log monitor
|
||||
*
|
||||
* @param mon monitor
|
||||
* @param mon
|
||||
* monitor
|
||||
* @return assigned ID
|
||||
*/
|
||||
public synchronized int addMonitor(LogMonitor mon)
|
||||
@@ -166,7 +166,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Remove a monitor by ID
|
||||
*
|
||||
* @param id monitor ID
|
||||
* @param id
|
||||
* monitor ID
|
||||
*/
|
||||
public synchronized void removeMonitor(int id)
|
||||
{
|
||||
@@ -177,7 +178,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Enable logging.
|
||||
*
|
||||
* @param flag do enable logging
|
||||
* @param flag
|
||||
* do enable logging
|
||||
*/
|
||||
public void enable(boolean flag)
|
||||
{
|
||||
@@ -188,7 +190,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Enable printing logs to sysout
|
||||
*
|
||||
* @param flag do enable logging
|
||||
* @param flag
|
||||
* do enable logging
|
||||
*/
|
||||
public void enableSysout(boolean flag)
|
||||
{
|
||||
@@ -200,7 +203,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINE message
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void f1(String msg)
|
||||
{
|
||||
@@ -211,7 +215,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINER message
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void f2(String msg)
|
||||
{
|
||||
@@ -222,7 +227,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINEST message
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void f3(String msg)
|
||||
{
|
||||
@@ -233,7 +239,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log INFO message
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void i(String msg)
|
||||
{
|
||||
@@ -244,7 +251,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log WARNING message (less severe than ERROR)
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void w(String msg)
|
||||
{
|
||||
@@ -255,7 +263,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log ERROR message
|
||||
*
|
||||
* @param msg message
|
||||
* @param msg
|
||||
* message
|
||||
*/
|
||||
public void e(String msg)
|
||||
{
|
||||
@@ -266,8 +275,10 @@ public class LogInstance {
|
||||
/**
|
||||
* Log THROWING message
|
||||
*
|
||||
* @param msg message
|
||||
* @param thrown thrown exception
|
||||
* @param msg
|
||||
* message
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
*/
|
||||
public void e(String msg, Throwable thrown)
|
||||
{
|
||||
@@ -278,7 +289,8 @@ public class LogInstance {
|
||||
/**
|
||||
* Log exception thrown
|
||||
*
|
||||
* @param thrown thrown exception
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
*/
|
||||
public void e(Throwable thrown)
|
||||
{
|
||||
@@ -302,6 +314,7 @@ public class LogInstance {
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PowerCraft Log file formatter.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -26,9 +25,12 @@ public class Calc {
|
||||
/**
|
||||
* Get distance from 2D line to 2D point [X,Y]
|
||||
*
|
||||
* @param lineDirVec line directional vector
|
||||
* @param linePoint point of line
|
||||
* @param point point coordinate
|
||||
* @param lineDirVec
|
||||
* line directional vector
|
||||
* @param linePoint
|
||||
* point of line
|
||||
* @param point
|
||||
* point coordinate
|
||||
* @return distance
|
||||
*/
|
||||
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]
|
||||
*
|
||||
* @param lineDirVec line directional vector
|
||||
* @param linePoint point of line
|
||||
* @param point point coordinate
|
||||
* @param lineDirVec
|
||||
* line directional vector
|
||||
* @param linePoint
|
||||
* point of line
|
||||
* @param point
|
||||
* point coordinate
|
||||
* @return distance
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param a side a (opposite)
|
||||
* @param b side b (adjacent)
|
||||
* @param a
|
||||
* side a (opposite)
|
||||
* @param b
|
||||
* side b (adjacent)
|
||||
* @return longest side (hypotenuse)
|
||||
*/
|
||||
public static double pythC(double a, double b)
|
||||
@@ -81,8 +88,10 @@ public class Calc {
|
||||
/**
|
||||
* Get adjacent side of a right-angled triangle
|
||||
*
|
||||
* @param a side a (opposite)
|
||||
* @param c side c (hypotenuse)
|
||||
* @param a
|
||||
* side a (opposite)
|
||||
* @param c
|
||||
* side c (hypotenuse)
|
||||
* @return side b (adjacent)
|
||||
*/
|
||||
public static double pythB(double a, double c)
|
||||
@@ -94,8 +103,10 @@ public class Calc {
|
||||
/**
|
||||
* Get opposite side of a right-angled triangle
|
||||
*
|
||||
* @param b side b (adjacent)
|
||||
* @param c side c (hypotenuse)
|
||||
* @param b
|
||||
* side b (adjacent)
|
||||
* @param c
|
||||
* side c (hypotenuse)
|
||||
* @return side a (opposite)
|
||||
*/
|
||||
public static double pythA(double b, double c)
|
||||
@@ -103,6 +114,7 @@ public class Calc {
|
||||
return Math.sqrt(square(c) - square(b));
|
||||
}
|
||||
|
||||
|
||||
private static class Angles {
|
||||
|
||||
public static double delta(double alpha, double beta, double a360)
|
||||
@@ -126,6 +138,7 @@ public class Calc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calc subclass with buffer utils.
|
||||
*
|
||||
@@ -136,7 +149,8 @@ public class Calc {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static FloatBuffer mkFillBuff(float... obj)
|
||||
@@ -161,7 +175,8 @@ public class Calc {
|
||||
/**
|
||||
* Create new java.nio.FloatBuffer of given length
|
||||
*
|
||||
* @param count elements
|
||||
* @param count
|
||||
* elements
|
||||
* @return the new java.nio.FloatBuffer
|
||||
*/
|
||||
public static FloatBuffer alloc(int count)
|
||||
@@ -171,6 +186,7 @@ public class Calc {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Angle calculations for degrees.
|
||||
*
|
||||
@@ -193,8 +209,10 @@ public class Calc {
|
||||
/**
|
||||
* Subtract two angles alpha - beta
|
||||
*
|
||||
* @param alpha first angle
|
||||
* @param beta second angle
|
||||
* @param alpha
|
||||
* first angle
|
||||
* @param beta
|
||||
* second angle
|
||||
* @return (alpha - beta) in degrees
|
||||
*/
|
||||
public static double delta(double alpha, double beta)
|
||||
@@ -206,8 +224,10 @@ public class Calc {
|
||||
/**
|
||||
* Difference of two angles (absolute value of delta)
|
||||
*
|
||||
* @param alpha first angle
|
||||
* @param beta second angle
|
||||
* @param alpha
|
||||
* first angle
|
||||
* @param beta
|
||||
* second angle
|
||||
* @return difference in radians
|
||||
*/
|
||||
public static double diff(double alpha, double beta)
|
||||
@@ -219,7 +239,8 @@ public class Calc {
|
||||
/**
|
||||
* Cosinus in degrees
|
||||
*
|
||||
* @param deg angle in degrees
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @return cosinus
|
||||
*/
|
||||
public static double cos(double deg)
|
||||
@@ -231,7 +252,8 @@ public class Calc {
|
||||
/**
|
||||
* Sinus in degrees
|
||||
*
|
||||
* @param deg angle in degrees
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @return sinus
|
||||
*/
|
||||
public static double sin(double deg)
|
||||
@@ -243,7 +265,8 @@ public class Calc {
|
||||
/**
|
||||
* Tangents in degrees
|
||||
*
|
||||
* @param deg angle in degrees
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @return tangents
|
||||
*/
|
||||
public static double tan(double deg)
|
||||
@@ -255,7 +278,8 @@ public class Calc {
|
||||
/**
|
||||
* Angle normalized to 0-360 range
|
||||
*
|
||||
* @param angle angle to normalize
|
||||
* @param angle
|
||||
* angle to normalize
|
||||
* @return normalized angle
|
||||
*/
|
||||
public static double norm(double angle)
|
||||
@@ -267,7 +291,8 @@ public class Calc {
|
||||
/**
|
||||
* Convert to radians
|
||||
*
|
||||
* @param deg degrees
|
||||
* @param deg
|
||||
* degrees
|
||||
* @return radians
|
||||
*/
|
||||
public static double toRad(double deg)
|
||||
@@ -279,8 +304,10 @@ public class Calc {
|
||||
/**
|
||||
* Round angle to 0,45,90,135...
|
||||
*
|
||||
* @param deg angle in deg. to round
|
||||
* @param x rounding increment (45 - round to 0,45,90...)
|
||||
* @param deg
|
||||
* angle in deg. to round
|
||||
* @param x
|
||||
* rounding increment (45 - round to 0,45,90...)
|
||||
* @return rounded
|
||||
*/
|
||||
public static int roundX(double deg, double x)
|
||||
@@ -298,7 +325,8 @@ public class Calc {
|
||||
/**
|
||||
* Round angle to 0,45,90,135...
|
||||
*
|
||||
* @param deg angle in deg. to round
|
||||
* @param deg
|
||||
* angle in deg. to round
|
||||
* @return rounded
|
||||
*/
|
||||
public static int round45(double deg)
|
||||
@@ -310,7 +338,8 @@ public class Calc {
|
||||
/**
|
||||
* Round angle to 0,90,180,270
|
||||
*
|
||||
* @param deg angle in deg. to round
|
||||
* @param deg
|
||||
* angle in deg. to round
|
||||
* @return rounded
|
||||
*/
|
||||
public static int round90(double deg)
|
||||
@@ -322,7 +351,8 @@ public class Calc {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static int round15(double deg)
|
||||
@@ -331,6 +361,7 @@ public class Calc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Angle calculations for radians.
|
||||
*
|
||||
@@ -353,8 +384,10 @@ public class Calc {
|
||||
/**
|
||||
* Subtract two angles alpha - beta
|
||||
*
|
||||
* @param alpha first angle
|
||||
* @param beta second angle
|
||||
* @param alpha
|
||||
* first angle
|
||||
* @param beta
|
||||
* second angle
|
||||
* @return (alpha - beta) in radians
|
||||
*/
|
||||
public static double delta(double alpha, double beta)
|
||||
@@ -366,8 +399,10 @@ public class Calc {
|
||||
/**
|
||||
* Difference of two angles (absolute value of delta)
|
||||
*
|
||||
* @param alpha first angle
|
||||
* @param beta second angle
|
||||
* @param alpha
|
||||
* first angle
|
||||
* @param beta
|
||||
* second angle
|
||||
* @return difference in radians
|
||||
*/
|
||||
public static double diff(double alpha, double beta)
|
||||
@@ -379,7 +414,8 @@ public class Calc {
|
||||
/**
|
||||
* Cos
|
||||
*
|
||||
* @param rad angle in rads
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @return cos
|
||||
*/
|
||||
public static double cos(double rad)
|
||||
@@ -391,7 +427,8 @@ public class Calc {
|
||||
/**
|
||||
* Sin
|
||||
*
|
||||
* @param rad angle in rads
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @return sin
|
||||
*/
|
||||
public static double sin(double rad)
|
||||
@@ -403,7 +440,8 @@ public class Calc {
|
||||
/**
|
||||
* Tan
|
||||
*
|
||||
* @param rad angle in rads
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @return tan
|
||||
*/
|
||||
public static double tan(double rad)
|
||||
@@ -415,7 +453,8 @@ public class Calc {
|
||||
/**
|
||||
* Angle normalized to 0-2*PI range
|
||||
*
|
||||
* @param angle angle to normalize
|
||||
* @param angle
|
||||
* angle to normalize
|
||||
* @return normalized angle
|
||||
*/
|
||||
public static double norm(double angle)
|
||||
@@ -427,7 +466,8 @@ public class Calc {
|
||||
/**
|
||||
* Convert to degrees
|
||||
*
|
||||
* @param rad radians
|
||||
* @param rad
|
||||
* radians
|
||||
* @return degrees
|
||||
*/
|
||||
public static double toDeg(double rad)
|
||||
@@ -442,7 +482,8 @@ public class Calc {
|
||||
/**
|
||||
* Get volume of a sphere
|
||||
*
|
||||
* @param radius sphere radius
|
||||
* @param radius
|
||||
* sphere radius
|
||||
* @return volume in cubic units
|
||||
*/
|
||||
public static double sphereGetVolume(double radius)
|
||||
@@ -454,7 +495,8 @@ public class Calc {
|
||||
/**
|
||||
* Get radius of a sphere
|
||||
*
|
||||
* @param volume sphere volume
|
||||
* @param volume
|
||||
* sphere volume
|
||||
* @return radius in units
|
||||
*/
|
||||
public static double sphereGetRadius(double volume)
|
||||
@@ -466,7 +508,8 @@ public class Calc {
|
||||
/**
|
||||
* Get surface of a circle
|
||||
*
|
||||
* @param radius circle radius
|
||||
* @param radius
|
||||
* circle radius
|
||||
* @return volume in square units
|
||||
*/
|
||||
public static double circleGetSurface(double radius)
|
||||
@@ -478,7 +521,8 @@ public class Calc {
|
||||
/**
|
||||
* Get radius of a circle
|
||||
*
|
||||
* @param surface circle volume
|
||||
* @param surface
|
||||
* circle volume
|
||||
* @return radius in units
|
||||
*/
|
||||
public static double circleGetRadius(double surface)
|
||||
@@ -503,9 +547,12 @@ public class Calc {
|
||||
/**
|
||||
* Private clamping helper.
|
||||
*
|
||||
* @param number number to be clamped
|
||||
* @param min min value
|
||||
* @param max max value
|
||||
* @param number
|
||||
* number to be clamped
|
||||
* @param min
|
||||
* min value
|
||||
* @param max
|
||||
* max value
|
||||
* @return clamped double
|
||||
*/
|
||||
private static double clamp_double(Number number, Number min, Number max)
|
||||
@@ -523,8 +570,10 @@ public class Calc {
|
||||
/**
|
||||
* Private clamping helper.
|
||||
*
|
||||
* @param number number to be clamped
|
||||
* @param min min value
|
||||
* @param number
|
||||
* number to be clamped
|
||||
* @param min
|
||||
* min value
|
||||
* @return clamped double
|
||||
*/
|
||||
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>
|
||||
* DOUBLE version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param max maximal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @param max
|
||||
* maximal allowed value
|
||||
* @return result
|
||||
*/
|
||||
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>
|
||||
* FLOAT version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param max maximal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @param max
|
||||
* maximal allowed value
|
||||
* @return result
|
||||
*/
|
||||
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>
|
||||
* INTEGER version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param max maximal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @param max
|
||||
* maximal allowed value
|
||||
* @return result
|
||||
*/
|
||||
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>
|
||||
* INTEGER version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param range range
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param range
|
||||
* range
|
||||
* @return result
|
||||
*/
|
||||
public static int clampi(Number number, Range range)
|
||||
@@ -599,8 +659,10 @@ public class Calc {
|
||||
* Clamp number to min and max bounds, inclusive.<br>
|
||||
* DOUBLE version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param range range
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param range
|
||||
* range
|
||||
* @return result
|
||||
*/
|
||||
public static double clampd(Number number, Range range)
|
||||
@@ -613,8 +675,10 @@ public class Calc {
|
||||
* Clamp number to min and max bounds, inclusive.<br>
|
||||
* FLOAT version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param range range
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param range
|
||||
* range
|
||||
* @return result
|
||||
*/
|
||||
public static float clampf(Number number, Range range)
|
||||
@@ -627,8 +691,10 @@ public class Calc {
|
||||
* Clamp number to min and infinite bounds, inclusive.<br>
|
||||
* DOUBLE version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @return result
|
||||
*/
|
||||
public static double clampd(Number number, Number min)
|
||||
@@ -641,8 +707,10 @@ public class Calc {
|
||||
* Clamp number to min and infinite bounds, inclusive.<br>
|
||||
* FLOAT version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @return result
|
||||
*/
|
||||
public static float clampf(Number number, Number min)
|
||||
@@ -655,8 +723,10 @@ public class Calc {
|
||||
* Clamp number to min and infinite bounds, inclusive.<br>
|
||||
* INTEGER version
|
||||
*
|
||||
* @param number clamped number
|
||||
* @param min minimal allowed value
|
||||
* @param number
|
||||
* clamped number
|
||||
* @param min
|
||||
* minimal allowed value
|
||||
* @return result
|
||||
*/
|
||||
public static int clampi(Number number, Number min)
|
||||
@@ -668,7 +738,8 @@ public class Calc {
|
||||
/**
|
||||
* Get class simple name
|
||||
*
|
||||
* @param obj object
|
||||
* @param obj
|
||||
* object
|
||||
* @return simple name
|
||||
*/
|
||||
public static String cname(Object obj)
|
||||
@@ -681,7 +752,8 @@ public class Calc {
|
||||
/**
|
||||
* Cube a double
|
||||
*
|
||||
* @param a squared double
|
||||
* @param a
|
||||
* squared double
|
||||
* @return square
|
||||
*/
|
||||
public static double cube(double a)
|
||||
@@ -693,7 +765,8 @@ public class Calc {
|
||||
/**
|
||||
* Convert double to string, remove the mess at the end.
|
||||
*
|
||||
* @param d double
|
||||
* @param d
|
||||
* double
|
||||
* @return string
|
||||
*/
|
||||
public static String doubleToString(double d)
|
||||
@@ -709,7 +782,8 @@ public class Calc {
|
||||
/**
|
||||
* Convert float to string, remove the mess at the end.
|
||||
*
|
||||
* @param f float
|
||||
* @param f
|
||||
* float
|
||||
* @return string
|
||||
*/
|
||||
public static String floatToString(float f)
|
||||
@@ -725,9 +799,12 @@ public class Calc {
|
||||
/**
|
||||
* Check if number is in range
|
||||
*
|
||||
* @param number checked
|
||||
* @param left lower end
|
||||
* @param right upper end
|
||||
* @param number
|
||||
* checked
|
||||
* @param left
|
||||
* lower end
|
||||
* @param right
|
||||
* upper end
|
||||
* @return is in range
|
||||
*/
|
||||
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)
|
||||
*
|
||||
* @param from last number
|
||||
* @param to new number
|
||||
* @param time time 0..1
|
||||
* @param easing easing function
|
||||
* @param from
|
||||
* last number
|
||||
* @param to
|
||||
* new number
|
||||
* @param time
|
||||
* time 0..1
|
||||
* @param easing
|
||||
* easing function
|
||||
* @return current number to render
|
||||
*/
|
||||
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)
|
||||
*
|
||||
* @param from last angle
|
||||
* @param to new angle
|
||||
* @param time time 0..1
|
||||
* @param easing easing function
|
||||
* @param from
|
||||
* last angle
|
||||
* @param to
|
||||
* new angle
|
||||
* @param time
|
||||
* time 0..1
|
||||
* @param easing
|
||||
* easing function
|
||||
* @return current angle to render
|
||||
*/
|
||||
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)
|
||||
*
|
||||
* @param from last angle
|
||||
* @param to new angle
|
||||
* @param time time 0..1
|
||||
* @param easing easing function
|
||||
* @param from
|
||||
* last angle
|
||||
* @param to
|
||||
* new angle
|
||||
* @param time
|
||||
* time 0..1
|
||||
* @param easing
|
||||
* easing function
|
||||
* @return current angle to render
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static double max(double... numbers)
|
||||
@@ -800,7 +890,8 @@ public class Calc {
|
||||
/**
|
||||
* Get highest number of a list
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static float max(float... numbers)
|
||||
@@ -816,7 +907,8 @@ public class Calc {
|
||||
/**
|
||||
* Get highest number of a list
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static int max(int... numbers)
|
||||
@@ -832,7 +924,8 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static double min(double... numbers)
|
||||
@@ -848,7 +941,8 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static float min(float... numbers)
|
||||
@@ -864,7 +958,8 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers numbers
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static int min(int... numbers)
|
||||
@@ -880,7 +975,8 @@ public class Calc {
|
||||
/**
|
||||
* Split comma separated list of integers.
|
||||
*
|
||||
* @param list String containing the list.
|
||||
* @param list
|
||||
* String containing the list.
|
||||
* @return array of integers or null.
|
||||
*/
|
||||
public static List<Integer> parseIntList(String list)
|
||||
@@ -895,7 +991,8 @@ public class Calc {
|
||||
for (String part : parts) {
|
||||
try {
|
||||
intList.add(Integer.parseInt(part));
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
return intList;
|
||||
@@ -906,7 +1003,8 @@ public class Calc {
|
||||
/**
|
||||
* Pick random element from a given list.
|
||||
*
|
||||
* @param list list of choices
|
||||
* @param list
|
||||
* list of choices
|
||||
* @return picked element
|
||||
*/
|
||||
public static Object pick(List<?> list)
|
||||
@@ -919,7 +1017,8 @@ public class Calc {
|
||||
/**
|
||||
* Square a double
|
||||
*
|
||||
* @param a squared double
|
||||
* @param a
|
||||
* squared double
|
||||
* @return square
|
||||
*/
|
||||
public static double square(double a)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc.Deg;
|
||||
import mightypork.utils.math.Calc.Rad;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -23,8 +22,10 @@ public class Polar {
|
||||
/**
|
||||
* Create a polar
|
||||
*
|
||||
* @param angle angle in RAD
|
||||
* @param distance distance from origin
|
||||
* @param angle
|
||||
* angle in RAD
|
||||
* @param distance
|
||||
* distance from origin
|
||||
*/
|
||||
public Polar(double angle, double distance) {
|
||||
this(angle, false, distance);
|
||||
@@ -34,9 +35,12 @@ public class Polar {
|
||||
/**
|
||||
* Create a polar
|
||||
*
|
||||
* @param angle angle
|
||||
* @param deg angle is in DEG
|
||||
* @param distance radius
|
||||
* @param angle
|
||||
* angle
|
||||
* @param deg
|
||||
* angle is in DEG
|
||||
* @param distance
|
||||
* radius
|
||||
*/
|
||||
public Polar(double angle, boolean deg, double 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)
|
||||
{
|
||||
@@ -72,7 +77,8 @@ public class Polar {
|
||||
|
||||
|
||||
/**
|
||||
* @param angle angle in DEG
|
||||
* @param angle
|
||||
* angle in DEG
|
||||
*/
|
||||
public void setAngleDeg(double angle)
|
||||
{
|
||||
@@ -90,7 +96,8 @@ public class Polar {
|
||||
|
||||
|
||||
/**
|
||||
* @param r radius
|
||||
* @param r
|
||||
* radius
|
||||
*/
|
||||
public void setRadius(double r)
|
||||
{
|
||||
@@ -101,7 +108,8 @@ public class Polar {
|
||||
/**
|
||||
* Make polar from coord
|
||||
*
|
||||
* @param coord coord
|
||||
* @param coord
|
||||
* coord
|
||||
* @return polar
|
||||
*/
|
||||
public static Polar fromCoord(Coord coord)
|
||||
@@ -113,8 +121,10 @@ public class Polar {
|
||||
/**
|
||||
* Make polar from coords
|
||||
*
|
||||
* @param x x coord
|
||||
* @param y y coord
|
||||
* @param x
|
||||
* x coord
|
||||
* @param y
|
||||
* y coord
|
||||
* @return polar
|
||||
*/
|
||||
public static Polar fromCoord(double x, double y)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
@@ -20,14 +19,17 @@ public class Range {
|
||||
/**
|
||||
* Implicit range constructor 0-1
|
||||
*/
|
||||
public Range() {}
|
||||
public Range() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create new range
|
||||
*
|
||||
* @param min min number
|
||||
* @param max max number
|
||||
* @param min
|
||||
* min number
|
||||
* @param max
|
||||
* max number
|
||||
*/
|
||||
public Range(double min, double max) {
|
||||
if (min > max) {
|
||||
@@ -43,7 +45,8 @@ public class Range {
|
||||
/**
|
||||
* Create new range
|
||||
*
|
||||
* @param minmax min = max number
|
||||
* @param minmax
|
||||
* min = max number
|
||||
*/
|
||||
public Range(double minmax) {
|
||||
this.min = minmax;
|
||||
@@ -120,7 +123,8 @@ public class Range {
|
||||
/**
|
||||
* Set min
|
||||
*
|
||||
* @param min min value
|
||||
* @param min
|
||||
* min value
|
||||
*/
|
||||
public void setMin(double min)
|
||||
{
|
||||
@@ -131,7 +135,8 @@ public class Range {
|
||||
/**
|
||||
* Set max
|
||||
*
|
||||
* @param max max value
|
||||
* @param max
|
||||
* max value
|
||||
*/
|
||||
public void setMax(double max)
|
||||
{
|
||||
@@ -160,7 +165,8 @@ public class Range {
|
||||
/**
|
||||
* Set to value of other range
|
||||
*
|
||||
* @param other copied range
|
||||
* @param other
|
||||
* copied range
|
||||
*/
|
||||
public void setTo(Range other)
|
||||
{
|
||||
@@ -179,8 +185,10 @@ public class Range {
|
||||
/**
|
||||
* Set to min-max values
|
||||
*
|
||||
* @param min min value
|
||||
* @param max max value
|
||||
* @param min
|
||||
* min value
|
||||
* @param max
|
||||
* max value
|
||||
*/
|
||||
public void setTo(double min, double max)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.color;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -24,7 +23,8 @@ public class HSV {
|
||||
/**
|
||||
* Create black color 0,0,0
|
||||
*/
|
||||
public HSV() {}
|
||||
public HSV() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,8 @@ public class HSV {
|
||||
/**
|
||||
* Set color to other color
|
||||
*
|
||||
* @param copied copied color
|
||||
* @param copied
|
||||
* copied color
|
||||
* @return this
|
||||
*/
|
||||
public HSV setTo(HSV copied)
|
||||
@@ -89,9 +90,12 @@ public class HSV {
|
||||
/**
|
||||
* Set to H,S,V 0-1
|
||||
*
|
||||
* @param h hue
|
||||
* @param s saturation
|
||||
* @param v value
|
||||
* @param h
|
||||
* hue
|
||||
* @param s
|
||||
* saturation
|
||||
* @param v
|
||||
* value
|
||||
* @return this
|
||||
*/
|
||||
public HSV setTo(Number h, Number s, Number v)
|
||||
@@ -133,7 +137,8 @@ public class HSV {
|
||||
/**
|
||||
* Make from RGB
|
||||
*
|
||||
* @param color RGB
|
||||
* @param color
|
||||
* RGB
|
||||
* @return HSV
|
||||
*/
|
||||
public static HSV fromRGB(RGB color)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.color;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -47,13 +46,15 @@ public class RGB {
|
||||
/**
|
||||
* Create black color 0,0,0
|
||||
*/
|
||||
public RGB() {}
|
||||
public RGB() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get copy with custom alpha
|
||||
*
|
||||
* @param alpha alpha to set
|
||||
* @param alpha
|
||||
* alpha to set
|
||||
* @return copy w/ alpha
|
||||
*/
|
||||
public RGB setAlpha(double alpha)
|
||||
@@ -65,7 +66,8 @@ public class RGB {
|
||||
/**
|
||||
* set alpha IP
|
||||
*
|
||||
* @param alpha alpha to set
|
||||
* @param alpha
|
||||
* alpha to set
|
||||
* @return this
|
||||
*/
|
||||
public RGB setAlpha_ip(double alpha)
|
||||
@@ -90,7 +92,8 @@ public class RGB {
|
||||
/**
|
||||
* Get copy with alpha multiplied by custom value
|
||||
*
|
||||
* @param alpha alpha to set
|
||||
* @param alpha
|
||||
* alpha to set
|
||||
* @return copy w/ alpha
|
||||
*/
|
||||
public RGB mulAlpha(double alpha)
|
||||
@@ -102,7 +105,8 @@ public class RGB {
|
||||
/**
|
||||
* Multiply alpha by given number
|
||||
*
|
||||
* @param alpha alpha multiplier
|
||||
* @param alpha
|
||||
* alpha multiplier
|
||||
* @return this
|
||||
*/
|
||||
public RGB mulAlpha_ip(double alpha)
|
||||
@@ -116,9 +120,12 @@ public class RGB {
|
||||
/**
|
||||
* Color from RGB 0-1
|
||||
*
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @param r
|
||||
* red
|
||||
* @param g
|
||||
* green
|
||||
* @param b
|
||||
* blue
|
||||
*/
|
||||
public RGB(Number r, Number g, Number b) {
|
||||
this.r = r.doubleValue();
|
||||
@@ -131,10 +138,14 @@ public class RGB {
|
||||
/**
|
||||
* Color from RGB 0-1
|
||||
*
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @param a alpha
|
||||
* @param r
|
||||
* red
|
||||
* @param g
|
||||
* green
|
||||
* @param b
|
||||
* blue
|
||||
* @param a
|
||||
* alpha
|
||||
*/
|
||||
public RGB(Number r, Number g, Number b, Number a) {
|
||||
this.r = r.doubleValue();
|
||||
@@ -148,7 +159,8 @@ public class RGB {
|
||||
/**
|
||||
* Color from hex 0xRRGGBB
|
||||
*
|
||||
* @param hex hex integer
|
||||
* @param hex
|
||||
* hex integer
|
||||
*/
|
||||
public RGB(int hex) {
|
||||
setTo(RGB.fromHex(hex));
|
||||
@@ -159,8 +171,10 @@ public class RGB {
|
||||
/**
|
||||
* Color from hex 0xRRGGBB
|
||||
*
|
||||
* @param hex hex integer
|
||||
* @param alpha alpha color
|
||||
* @param hex
|
||||
* hex integer
|
||||
* @param alpha
|
||||
* alpha color
|
||||
*/
|
||||
public RGB(int hex, double alpha) {
|
||||
setTo(RGB.fromHex(hex));
|
||||
@@ -172,8 +186,10 @@ public class RGB {
|
||||
/**
|
||||
* Color from other RGB and alpha channel
|
||||
*
|
||||
* @param color other RGB color
|
||||
* @param alpha new alpha channel
|
||||
* @param color
|
||||
* other RGB color
|
||||
* @param alpha
|
||||
* new alpha channel
|
||||
*/
|
||||
public RGB(RGB color, double alpha) {
|
||||
setTo(color);
|
||||
@@ -220,7 +236,8 @@ public class RGB {
|
||||
/**
|
||||
* Set color to other color
|
||||
*
|
||||
* @param copied copied color
|
||||
* @param copied
|
||||
* copied color
|
||||
* @return this
|
||||
*/
|
||||
public RGB setTo(RGB copied)
|
||||
@@ -238,7 +255,8 @@ public class RGB {
|
||||
/**
|
||||
* Set to represent hex color
|
||||
*
|
||||
* @param hex hex integer RRGGBB
|
||||
* @param hex
|
||||
* hex integer RRGGBB
|
||||
* @return this
|
||||
*/
|
||||
public RGB setTo(int hex)
|
||||
@@ -252,10 +270,14 @@ public class RGB {
|
||||
/**
|
||||
* Set to R,G,B 0-1
|
||||
*
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @param a alpha
|
||||
* @param r
|
||||
* red
|
||||
* @param g
|
||||
* green
|
||||
* @param b
|
||||
* blue
|
||||
* @param a
|
||||
* alpha
|
||||
* @return this
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @param r
|
||||
* red
|
||||
* @param g
|
||||
* green
|
||||
* @param b
|
||||
* blue
|
||||
* @return this
|
||||
*/
|
||||
public RGB setTo(Number r, Number g, Number b)
|
||||
@@ -333,7 +358,8 @@ public class RGB {
|
||||
/**
|
||||
* Create color from hex 0xRRGGBB
|
||||
*
|
||||
* @param hex hex RRGGBB
|
||||
* @param hex
|
||||
* hex RRGGBB
|
||||
* @return the new color
|
||||
*/
|
||||
public static RGB fromHex(int hex)
|
||||
@@ -348,7 +374,8 @@ public class RGB {
|
||||
/**
|
||||
* Make from HSV
|
||||
*
|
||||
* @param color HSV color
|
||||
* @param color
|
||||
* HSV color
|
||||
* @return RGB
|
||||
*/
|
||||
public static RGB fromHSV(HSV color)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -19,8 +18,10 @@ public class Coord {
|
||||
/**
|
||||
* Get distance to other point
|
||||
*
|
||||
* @param a point a
|
||||
* @param b point b
|
||||
* @param a
|
||||
* point a
|
||||
* @param b
|
||||
* point b
|
||||
* @return distance in units
|
||||
*/
|
||||
public static double dist(Coord a, Coord b)
|
||||
@@ -41,13 +42,15 @@ public class Coord {
|
||||
/**
|
||||
* Create zero coord
|
||||
*/
|
||||
public Coord() {}
|
||||
public Coord() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create coord as a copy of another
|
||||
*
|
||||
* @param copied copied coord
|
||||
* @param copied
|
||||
* copied coord
|
||||
*/
|
||||
public Coord(Coord copied) {
|
||||
setTo(copied);
|
||||
@@ -57,8 +60,10 @@ public class Coord {
|
||||
/**
|
||||
* Create 2D coord
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
*/
|
||||
public Coord(Number x, Number y) {
|
||||
setTo(x, y);
|
||||
@@ -68,9 +73,12 @@ public class Coord {
|
||||
/**
|
||||
* Create 3D coord
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param z z coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @param z
|
||||
* z coordinate
|
||||
*/
|
||||
public Coord(Number x, Number y, Number z) {
|
||||
setTo(x, y, z);
|
||||
@@ -80,7 +88,8 @@ public class Coord {
|
||||
/**
|
||||
* Add a vector, in a copy
|
||||
*
|
||||
* @param vec offset
|
||||
* @param vec
|
||||
* offset
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord add(Coord vec)
|
||||
@@ -92,7 +101,8 @@ public class Coord {
|
||||
/**
|
||||
* Add a vector, in place
|
||||
*
|
||||
* @param vec offset
|
||||
* @param vec
|
||||
* offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord add_ip(Coord vec)
|
||||
@@ -105,8 +115,10 @@ public class Coord {
|
||||
* Add to each component, in a copy.<br>
|
||||
* Z is unchanged.
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord add(Number x, Number y)
|
||||
@@ -119,8 +131,10 @@ public class Coord {
|
||||
* Add to each component, in place.<br>
|
||||
* Z is unchanged.
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord add_ip(Number x, Number y)
|
||||
@@ -132,9 +146,12 @@ public class Coord {
|
||||
/**
|
||||
* Add to each component, in a copy.
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param z z offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @param z
|
||||
* z offset
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord add(Number x, Number y, Number z)
|
||||
@@ -146,9 +163,12 @@ public class Coord {
|
||||
/**
|
||||
* Add to each component, in place.
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param z z offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @param z
|
||||
* z offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord add_ip(Number x, Number y, Number z)
|
||||
@@ -174,7 +194,8 @@ public class Coord {
|
||||
/**
|
||||
* Get distance to other point
|
||||
*
|
||||
* @param point other point
|
||||
* @param point
|
||||
* other point
|
||||
* @return distance in units
|
||||
*/
|
||||
public double distTo(Coord point)
|
||||
@@ -186,7 +207,8 @@ public class Coord {
|
||||
/**
|
||||
* Check if this rectangle in inside a rectangular zone
|
||||
*
|
||||
* @param rect checked rect.
|
||||
* @param rect
|
||||
* checked rect.
|
||||
* @return is inside
|
||||
*/
|
||||
public boolean isInRect(Rect rect)
|
||||
@@ -198,8 +220,10 @@ public class Coord {
|
||||
/**
|
||||
* Check if this rectangle in inside a rectangular zone
|
||||
*
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param min
|
||||
* min coord
|
||||
* @param max
|
||||
* max coord
|
||||
* @return is inside
|
||||
*/
|
||||
public boolean isInRect(Coord min, Coord max)
|
||||
@@ -211,7 +235,8 @@ public class Coord {
|
||||
/**
|
||||
* Get middle of line to other point
|
||||
*
|
||||
* @param other other point
|
||||
* @param other
|
||||
* other point
|
||||
* @return middle
|
||||
*/
|
||||
public Coord midTo(Coord other)
|
||||
@@ -246,7 +271,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in a copy.
|
||||
*
|
||||
* @param d multiplier
|
||||
* @param d
|
||||
* multiplier
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord mul(double d)
|
||||
@@ -258,7 +284,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in place.
|
||||
*
|
||||
* @param d multiplier
|
||||
* @param d
|
||||
* multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Coord mul_ip(double d)
|
||||
@@ -270,7 +297,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in a copy.
|
||||
*
|
||||
* @param vec vector of multipliers
|
||||
* @param vec
|
||||
* vector of multipliers
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord mul(Coord vec)
|
||||
@@ -283,8 +311,10 @@ public class Coord {
|
||||
* Multiply each component, in a copy.<br>
|
||||
* Z is unchanged.
|
||||
*
|
||||
* @param x x multiplier
|
||||
* @param y y multiplier
|
||||
* @param x
|
||||
* x multiplier
|
||||
* @param y
|
||||
* y multiplier
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord mul(double x, int y)
|
||||
@@ -297,8 +327,10 @@ public class Coord {
|
||||
* Multiply each component, in place.<br>
|
||||
* Z is unchanged.
|
||||
*
|
||||
* @param x x multiplier
|
||||
* @param y y multiplier
|
||||
* @param x
|
||||
* x multiplier
|
||||
* @param y
|
||||
* y multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Coord mul_ip(double x, double y)
|
||||
@@ -310,9 +342,12 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in a copy.
|
||||
*
|
||||
* @param x x multiplier
|
||||
* @param y y multiplier
|
||||
* @param z z multiplier
|
||||
* @param x
|
||||
* x multiplier
|
||||
* @param y
|
||||
* y multiplier
|
||||
* @param z
|
||||
* z multiplier
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord mul(double x, double y, double z)
|
||||
@@ -324,7 +359,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in place.
|
||||
*
|
||||
* @param vec vector of multipliers
|
||||
* @param vec
|
||||
* vector of multipliers
|
||||
* @return this
|
||||
*/
|
||||
public Coord mul_ip(Coord vec)
|
||||
@@ -336,9 +372,12 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in place.
|
||||
*
|
||||
* @param x x multiplier
|
||||
* @param y y multiplier
|
||||
* @param z z multiplier
|
||||
* @param x
|
||||
* x multiplier
|
||||
* @param y
|
||||
* y multiplier
|
||||
* @param z
|
||||
* z multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Coord mul_ip(double x, double y, double z)
|
||||
@@ -359,7 +398,8 @@ public class Coord {
|
||||
/**
|
||||
* offset randomly in place
|
||||
*
|
||||
* @param max max +- offset
|
||||
* @param max
|
||||
* max +- offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord random_offset_ip(double max)
|
||||
@@ -371,8 +411,10 @@ public class Coord {
|
||||
/**
|
||||
* offset randomly
|
||||
*
|
||||
* @param min min offset
|
||||
* @param max max offset
|
||||
* @param min
|
||||
* min offset
|
||||
* @param max
|
||||
* max offset
|
||||
* @return offset coord
|
||||
*/
|
||||
public Coord random_offset(double min, double max)
|
||||
@@ -384,8 +426,10 @@ public class Coord {
|
||||
/**
|
||||
* offset randomly in place
|
||||
*
|
||||
* @param min min offset
|
||||
* @param max max offset
|
||||
* @param min
|
||||
* min offset
|
||||
* @param max
|
||||
* max offset
|
||||
* @return this
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param other other coord
|
||||
* @param other
|
||||
* other coord
|
||||
*/
|
||||
public void setToMax(Coord other)
|
||||
{
|
||||
@@ -436,7 +481,8 @@ public class Coord {
|
||||
/**
|
||||
* Set to min values of this and other coord
|
||||
*
|
||||
* @param other other coord
|
||||
* @param other
|
||||
* other coord
|
||||
*/
|
||||
public void setToMin(Coord other)
|
||||
{
|
||||
@@ -449,7 +495,8 @@ public class Coord {
|
||||
/**
|
||||
* Set coordinates to match other coord
|
||||
*
|
||||
* @param copied coord whose coordinates are used
|
||||
* @param copied
|
||||
* coord whose coordinates are used
|
||||
* @return this
|
||||
*/
|
||||
public Coord setTo(Coord copied)
|
||||
@@ -461,8 +508,10 @@ public class Coord {
|
||||
/**
|
||||
* Set 2D coordinates to
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setTo(Number x, Number y)
|
||||
@@ -474,9 +523,12 @@ public class Coord {
|
||||
/**
|
||||
* Set 3D coordinates to
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param z z coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @param z
|
||||
* z coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setTo(Number x, Number y, Number z)
|
||||
@@ -491,7 +543,8 @@ public class Coord {
|
||||
/**
|
||||
* Set X coordinate in a copy
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @return copy with set coordinate
|
||||
*/
|
||||
public Coord setX(Number x)
|
||||
@@ -503,7 +556,8 @@ public class Coord {
|
||||
/**
|
||||
* Set X coordinate in place
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setX_ip(Number x)
|
||||
@@ -516,7 +570,8 @@ public class Coord {
|
||||
/**
|
||||
* Set Y coordinate in a copy
|
||||
*
|
||||
* @param y y coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @return copy with set coordinate
|
||||
*/
|
||||
public Coord setY(Number y)
|
||||
@@ -528,7 +583,8 @@ public class Coord {
|
||||
/**
|
||||
* Set Y coordinate in place
|
||||
*
|
||||
* @param y y coordinate
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setY_ip(Number y)
|
||||
@@ -541,7 +597,8 @@ public class Coord {
|
||||
/**
|
||||
* Set Z coordinate in a copy
|
||||
*
|
||||
* @param z z coordinate
|
||||
* @param z
|
||||
* z coordinate
|
||||
* @return copy with set coordinate
|
||||
*/
|
||||
public Coord setZ(Number z)
|
||||
@@ -553,7 +610,8 @@ public class Coord {
|
||||
/**
|
||||
* Set Z coordinate in place
|
||||
*
|
||||
* @param z z coordinate
|
||||
* @param z
|
||||
* z coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setZ_ip(Number z)
|
||||
@@ -566,7 +624,8 @@ public class Coord {
|
||||
/**
|
||||
* Get a copy subtracted by vector
|
||||
*
|
||||
* @param vec offset
|
||||
* @param vec
|
||||
* offset
|
||||
* @return the offset copy
|
||||
*/
|
||||
public Coord sub(Coord vec)
|
||||
@@ -578,8 +637,10 @@ public class Coord {
|
||||
/**
|
||||
* Get a copy subtracted by 2D coordinate
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @return the offset copy
|
||||
*/
|
||||
public Coord sub(Number x, Number y)
|
||||
@@ -591,9 +652,12 @@ public class Coord {
|
||||
/**
|
||||
* Get a copy subtracted by 3D coordinate
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param z z offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @param z
|
||||
* z offset
|
||||
* @return the offset copy
|
||||
*/
|
||||
public Coord sub(Number x, Number y, Number z)
|
||||
@@ -605,7 +669,8 @@ public class Coord {
|
||||
/**
|
||||
* Offset by vector in place
|
||||
*
|
||||
* @param vec offset
|
||||
* @param vec
|
||||
* offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord sub_ip(Coord vec)
|
||||
@@ -617,8 +682,10 @@ public class Coord {
|
||||
/**
|
||||
* Offset by 2D coordinate in place
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord sub_ip(Number x, Number y)
|
||||
@@ -630,9 +697,12 @@ public class Coord {
|
||||
/**
|
||||
* Offset by 3D coordinate in place
|
||||
*
|
||||
* @param x x offset
|
||||
* @param y y offset
|
||||
* @param z z offset
|
||||
* @param x
|
||||
* x offset
|
||||
* @param y
|
||||
* y offset
|
||||
* @param z
|
||||
* z offset
|
||||
* @return this
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param point second point
|
||||
* @param point
|
||||
* second point
|
||||
* @return vector
|
||||
*/
|
||||
public Coord vecTo(Coord point)
|
||||
@@ -713,8 +784,10 @@ public class Coord {
|
||||
/**
|
||||
* Get cross product of two vectors
|
||||
*
|
||||
* @param a 1st vector
|
||||
* @param b 2nd vector
|
||||
* @param a
|
||||
* 1st vector
|
||||
* @param b
|
||||
* 2nd vector
|
||||
* @return cross product
|
||||
*/
|
||||
public static Coord cross(Coord a, Coord b)
|
||||
@@ -726,8 +799,10 @@ public class Coord {
|
||||
/**
|
||||
* Get dot product of two vectors
|
||||
*
|
||||
* @param a 1st vector
|
||||
* @param b 2nd vector
|
||||
* @param a
|
||||
* 1st vector
|
||||
* @param b
|
||||
* 2nd vector
|
||||
* @return dot product
|
||||
*/
|
||||
public static double dot(Coord a, Coord b)
|
||||
@@ -739,7 +814,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply by other vector, vector multiplication
|
||||
*
|
||||
* @param vec other vector
|
||||
* @param vec
|
||||
* other vector
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord cross(Coord vec)
|
||||
@@ -751,7 +827,8 @@ public class Coord {
|
||||
/**
|
||||
* Multiply by other vector, vector multiplication; in place
|
||||
*
|
||||
* @param vec other vector
|
||||
* @param vec
|
||||
* other vector
|
||||
* @return this
|
||||
*/
|
||||
public Coord cross_ip(Coord vec)
|
||||
@@ -770,7 +847,8 @@ public class Coord {
|
||||
/**
|
||||
* Get dot product
|
||||
*
|
||||
* @param vec other vector
|
||||
* @param vec
|
||||
* other vector
|
||||
* @return dot product
|
||||
*/
|
||||
public double dot(Coord vec)
|
||||
@@ -805,7 +883,8 @@ public class Coord {
|
||||
/**
|
||||
* Scale vector to given size
|
||||
*
|
||||
* @param size size we need
|
||||
* @param size
|
||||
* size we need
|
||||
* @return scaled vector
|
||||
*/
|
||||
public Coord norm(double size)
|
||||
@@ -818,7 +897,8 @@ public class Coord {
|
||||
* Scale vector to given size, in place.<br>
|
||||
* Zero vector remains zero.
|
||||
*
|
||||
* @param size size we need
|
||||
* @param size
|
||||
* size we need
|
||||
* @return scaled vector
|
||||
*/
|
||||
public Coord norm_ip(double size)
|
||||
@@ -914,7 +994,8 @@ public class Coord {
|
||||
/**
|
||||
* Generate random coord (gaussian)
|
||||
*
|
||||
* @param max max distance from 0
|
||||
* @param max
|
||||
* max distance from 0
|
||||
* @return new coord
|
||||
*/
|
||||
public static Coord random(double max)
|
||||
@@ -932,8 +1013,10 @@ public class Coord {
|
||||
/**
|
||||
* Generate random coord (min-max)
|
||||
*
|
||||
* @param min min offset
|
||||
* @param max max offset
|
||||
* @param min
|
||||
* min offset
|
||||
* @param max
|
||||
* max offset
|
||||
* @return new coord
|
||||
*/
|
||||
public static Coord random(double min, double max)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -21,7 +20,8 @@ public class CoordAnimated extends Coord implements Updateable {
|
||||
/**
|
||||
* Update delta timing
|
||||
*
|
||||
* @param delta delta time to add
|
||||
* @param delta
|
||||
* delta time to add
|
||||
*/
|
||||
@Override
|
||||
public void update(double delta)
|
||||
@@ -52,7 +52,8 @@ public class CoordAnimated extends Coord implements Updateable {
|
||||
/**
|
||||
* Start animation
|
||||
*
|
||||
* @param time anim length
|
||||
* @param time
|
||||
* anim length
|
||||
*/
|
||||
public void animStart(double time)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -20,8 +19,10 @@ public class Rect {
|
||||
/**
|
||||
* Rectangle from size
|
||||
*
|
||||
* @param min min coord
|
||||
* @param size rect size
|
||||
* @param min
|
||||
* min coord
|
||||
* @param size
|
||||
* rect size
|
||||
* @return the rect
|
||||
*/
|
||||
public static Rect fromSize(Coord min, Coord size)
|
||||
@@ -33,9 +34,12 @@ public class Rect {
|
||||
/**
|
||||
* Make rect from min coord and size
|
||||
*
|
||||
* @param min min coord
|
||||
* @param width size x
|
||||
* @param height size y
|
||||
* @param min
|
||||
* min coord
|
||||
* @param width
|
||||
* size x
|
||||
* @param height
|
||||
* size y
|
||||
* @return the new rect
|
||||
*/
|
||||
public static Rect fromSize(Coord min, double width, double height)
|
||||
@@ -47,9 +51,12 @@ public class Rect {
|
||||
/**
|
||||
* Rectangle from size
|
||||
*
|
||||
* @param x min X
|
||||
* @param y min Y
|
||||
* @param size rect size
|
||||
* @param x
|
||||
* min X
|
||||
* @param y
|
||||
* min Y
|
||||
* @param size
|
||||
* rect size
|
||||
* @return the rect
|
||||
*/
|
||||
public static Rect fromSize(int x, int y, Coord size)
|
||||
@@ -61,10 +68,14 @@ public class Rect {
|
||||
/**
|
||||
* Make rect from min coord and size
|
||||
*
|
||||
* @param xMin min x
|
||||
* @param yMin min y
|
||||
* @param width size x
|
||||
* @param height size y
|
||||
* @param xMin
|
||||
* min x
|
||||
* @param yMin
|
||||
* min y
|
||||
* @param width
|
||||
* size x
|
||||
* @param height
|
||||
* size y
|
||||
* @return the new rect
|
||||
*/
|
||||
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]
|
||||
*
|
||||
* @param size size coord
|
||||
* @param size
|
||||
* size coord
|
||||
*/
|
||||
public Rect(Coord size) {
|
||||
this(0, 0, size.x, size.y);
|
||||
@@ -100,8 +112,10 @@ public class Rect {
|
||||
/**
|
||||
* New rect of two coords
|
||||
*
|
||||
* @param c1 coord 1
|
||||
* @param c2 coord 2
|
||||
* @param c1
|
||||
* coord 1
|
||||
* @param c2
|
||||
* coord 2
|
||||
*/
|
||||
public Rect(Coord c1, Coord c2) {
|
||||
this(c1.x, c1.y, c2.x, c2.y);
|
||||
@@ -111,10 +125,14 @@ public class Rect {
|
||||
/**
|
||||
* New Rect
|
||||
*
|
||||
* @param x1 lower x
|
||||
* @param y1 lower y
|
||||
* @param x2 upper x
|
||||
* @param y2 upper y
|
||||
* @param x1
|
||||
* lower x
|
||||
* @param y1
|
||||
* lower y
|
||||
* @param x2
|
||||
* upper x
|
||||
* @param y2
|
||||
* upper y
|
||||
*/
|
||||
public Rect(double x1, double y1, double x2, double y2) {
|
||||
setTo(x1, y1, x2, y2);
|
||||
@@ -124,8 +142,10 @@ public class Rect {
|
||||
/**
|
||||
* Rect [0, 0, x, y]
|
||||
*
|
||||
* @param x width
|
||||
* @param y height
|
||||
* @param x
|
||||
* width
|
||||
* @param y
|
||||
* height
|
||||
*/
|
||||
public Rect(double x, double y) {
|
||||
this(0, 0, x, y);
|
||||
@@ -135,7 +155,8 @@ public class Rect {
|
||||
/**
|
||||
* New rect as a copy of other rect
|
||||
*
|
||||
* @param r other rect
|
||||
* @param r
|
||||
* other rect
|
||||
*/
|
||||
public Rect(Rect r) {
|
||||
this(r.min.x, r.min.y, r.max.x, r.max.y);
|
||||
@@ -145,7 +166,8 @@ public class Rect {
|
||||
/**
|
||||
* Get offset copy (add)
|
||||
*
|
||||
* @param move offset vector
|
||||
* @param move
|
||||
* offset vector
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect add(Coord move)
|
||||
@@ -157,8 +179,10 @@ public class Rect {
|
||||
/**
|
||||
* Add X and Y to all coordinates in a copy
|
||||
*
|
||||
* @param x x to add
|
||||
* @param y y to add
|
||||
* @param x
|
||||
* x to add
|
||||
* @param y
|
||||
* y to add
|
||||
* @return copy changed
|
||||
*/
|
||||
public Rect add(double x, double y)
|
||||
@@ -170,7 +194,8 @@ public class Rect {
|
||||
/**
|
||||
* Offset in place (add)
|
||||
*
|
||||
* @param move offset vector
|
||||
* @param move
|
||||
* offset vector
|
||||
* @return this
|
||||
*/
|
||||
public Rect add_ip(Coord move)
|
||||
@@ -184,8 +209,10 @@ public class Rect {
|
||||
/**
|
||||
* Add X and Y to all coordinates in place
|
||||
*
|
||||
* @param x x to add
|
||||
* @param y y to add
|
||||
* @param x
|
||||
* x to add
|
||||
* @param y
|
||||
* y to add
|
||||
* @return this
|
||||
*/
|
||||
public Rect add_ip(double x, double y)
|
||||
@@ -402,7 +429,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to sides in copy
|
||||
*
|
||||
* @param grow grow size (added to each side)
|
||||
* @param grow
|
||||
* grow size (added to each side)
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect grow(Coord grow)
|
||||
@@ -414,8 +442,10 @@ public class Rect {
|
||||
/**
|
||||
* Grow to sides in copy
|
||||
*
|
||||
* @param x x to add
|
||||
* @param y y to add
|
||||
* @param x
|
||||
* x to add
|
||||
* @param y
|
||||
* y to add
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect grow(double x, double y)
|
||||
@@ -427,7 +457,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to sides in place
|
||||
*
|
||||
* @param grow grow size (added to each side)
|
||||
* @param grow
|
||||
* grow size (added to each side)
|
||||
* @return this
|
||||
*/
|
||||
public Rect grow_ip(Coord grow)
|
||||
@@ -441,8 +472,10 @@ public class Rect {
|
||||
/**
|
||||
* Grow to sides in place
|
||||
*
|
||||
* @param x x to add
|
||||
* @param y y to add
|
||||
* @param x
|
||||
* x to add
|
||||
* @param y
|
||||
* y to add
|
||||
* @return this
|
||||
*/
|
||||
public Rect grow_ip(double x, double y)
|
||||
@@ -456,7 +489,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow down in copy
|
||||
*
|
||||
* @param down added pixels
|
||||
* @param down
|
||||
* added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growDown(double down)
|
||||
@@ -468,7 +502,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow down in place
|
||||
*
|
||||
* @param down added pixels
|
||||
* @param down
|
||||
* added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growDown_ip(double down)
|
||||
@@ -481,7 +516,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to left in copy
|
||||
*
|
||||
* @param left added pixels
|
||||
* @param left
|
||||
* added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growLeft(double left)
|
||||
@@ -493,7 +529,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to left in place
|
||||
*
|
||||
* @param left added pixels
|
||||
* @param left
|
||||
* added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growLeft_ip(double left)
|
||||
@@ -506,7 +543,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to right in copy
|
||||
*
|
||||
* @param right added pixels
|
||||
* @param right
|
||||
* added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growRight(double right)
|
||||
@@ -518,7 +556,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow to right in place
|
||||
*
|
||||
* @param right added pixels
|
||||
* @param right
|
||||
* added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growRight_ip(double right)
|
||||
@@ -531,7 +570,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow up in copy
|
||||
*
|
||||
* @param add added pixels
|
||||
* @param add
|
||||
* added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growUp(double add)
|
||||
@@ -543,7 +583,8 @@ public class Rect {
|
||||
/**
|
||||
* Grow up in place
|
||||
*
|
||||
* @param add added pixels
|
||||
* @param add
|
||||
* added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growUp_ip(double add)
|
||||
@@ -556,7 +597,8 @@ public class Rect {
|
||||
/**
|
||||
* Check if point is inside this rectangle
|
||||
*
|
||||
* @param point point to test
|
||||
* @param point
|
||||
* point to test
|
||||
* @return is inside
|
||||
*/
|
||||
public boolean isInside(Coord point)
|
||||
@@ -568,7 +610,8 @@ public class Rect {
|
||||
/**
|
||||
* Multiply in copy
|
||||
*
|
||||
* @param factor multiplier
|
||||
* @param factor
|
||||
* multiplier
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect mul(double factor)
|
||||
@@ -580,8 +623,10 @@ public class Rect {
|
||||
/**
|
||||
* Multiply by number (useful for centered rects)
|
||||
*
|
||||
* @param x x multiplier
|
||||
* @param y y multiplier
|
||||
* @param x
|
||||
* x multiplier
|
||||
* @param y
|
||||
* y multiplier
|
||||
* @return copy multiplied
|
||||
*/
|
||||
public Rect mul(double x, double y)
|
||||
@@ -593,7 +638,8 @@ public class Rect {
|
||||
/**
|
||||
* Multiply coord in place
|
||||
*
|
||||
* @param factor multiplier
|
||||
* @param factor
|
||||
* multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Rect mul_ip(double factor)
|
||||
@@ -607,8 +653,10 @@ public class Rect {
|
||||
/**
|
||||
* Multiply coord in place
|
||||
*
|
||||
* @param x multiplier x
|
||||
* @param y multiplier y
|
||||
* @param x
|
||||
* multiplier x
|
||||
* @param y
|
||||
* multiplier y
|
||||
* @return this
|
||||
*/
|
||||
public Rect mul_ip(double x, double y)
|
||||
@@ -646,7 +694,8 @@ public class Rect {
|
||||
/**
|
||||
* Set to [0,0,coord.x,coord.y]
|
||||
*
|
||||
* @param coord size coord
|
||||
* @param coord
|
||||
* size coord
|
||||
*/
|
||||
public void setTo(Coord coord)
|
||||
{
|
||||
@@ -657,10 +706,14 @@ public class Rect {
|
||||
/**
|
||||
* Set to coordinates
|
||||
*
|
||||
* @param x1 lower x
|
||||
* @param y1 lower y
|
||||
* @param x2 upper x
|
||||
* @param y2 upper y
|
||||
* @param x1
|
||||
* lower x
|
||||
* @param y1
|
||||
* lower y
|
||||
* @param x2
|
||||
* upper x
|
||||
* @param y2
|
||||
* upper y
|
||||
*/
|
||||
public void setTo(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
@@ -674,7 +727,8 @@ public class Rect {
|
||||
/**
|
||||
* Set to other rect's coordinates
|
||||
*
|
||||
* @param r other rect
|
||||
* @param r
|
||||
* other rect
|
||||
*/
|
||||
public void setTo(Rect r)
|
||||
{
|
||||
@@ -686,8 +740,10 @@ public class Rect {
|
||||
/**
|
||||
* Subtract X and Y from all coordinates in a copy
|
||||
*
|
||||
* @param x x to subtract
|
||||
* @param y y to subtract
|
||||
* @param x
|
||||
* x to subtract
|
||||
* @param y
|
||||
* y to subtract
|
||||
* @return copy changed
|
||||
*/
|
||||
public Rect sub(double x, double y)
|
||||
@@ -699,7 +755,8 @@ public class Rect {
|
||||
/**
|
||||
* Get offset copy (subtract)
|
||||
*
|
||||
* @param move offset vector
|
||||
* @param move
|
||||
* offset vector
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect sub(Coord move)
|
||||
@@ -711,8 +768,10 @@ public class Rect {
|
||||
/**
|
||||
* Subtract X and Y from all coordinates in place
|
||||
*
|
||||
* @param x x to subtract
|
||||
* @param y y to subtract
|
||||
* @param x
|
||||
* x to subtract
|
||||
* @param y
|
||||
* y to subtract
|
||||
* @return this
|
||||
*/
|
||||
public Rect sub_ip(double x, double y)
|
||||
@@ -724,7 +783,8 @@ public class Rect {
|
||||
/**
|
||||
* Offset in place (subtract)
|
||||
*
|
||||
* @param move offset vector
|
||||
* @param move
|
||||
* offset vector
|
||||
* @return this
|
||||
*/
|
||||
public Rect sub_ip(Coord move)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.math.easing;
|
||||
|
||||
|
||||
/**
|
||||
* EasingFunction function.
|
||||
*
|
||||
@@ -11,7 +10,8 @@ public abstract class Easing {
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public abstract double get(double t);
|
||||
@@ -20,7 +20,8 @@ public abstract class Easing {
|
||||
/**
|
||||
* Reverse an easing
|
||||
*
|
||||
* @param original original easing
|
||||
* @param original
|
||||
* original easing
|
||||
* @return reversed easing
|
||||
*/
|
||||
public static Easing reverse(Easing original)
|
||||
@@ -32,8 +33,10 @@ public abstract class Easing {
|
||||
/**
|
||||
* Combine two easings
|
||||
*
|
||||
* @param in initial easing
|
||||
* @param out terminal easing
|
||||
* @param in
|
||||
* initial easing
|
||||
* @param out
|
||||
* terminal easing
|
||||
* @return product
|
||||
*/
|
||||
public static Easing combine(Easing in, Easing out)
|
||||
@@ -45,7 +48,8 @@ public abstract class Easing {
|
||||
/**
|
||||
* Create "bilinear" easing - compose of straight and reverse.
|
||||
*
|
||||
* @param in initial easing
|
||||
* @param in
|
||||
* initial easing
|
||||
* @return product
|
||||
*/
|
||||
public static Easing inOut(Easing in)
|
||||
@@ -53,6 +57,7 @@ public abstract class Easing {
|
||||
return combine(in, reverse(in));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse EasingFunction
|
||||
*
|
||||
@@ -64,7 +69,8 @@ public abstract class Easing {
|
||||
|
||||
|
||||
/**
|
||||
* @param in Easing to reverse
|
||||
* @param in
|
||||
* Easing to reverse
|
||||
*/
|
||||
public Reverse(Easing in) {
|
||||
this.ea = in;
|
||||
@@ -78,6 +84,7 @@ public abstract class Easing {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Composite EasingFunction (0-0.5 EasingFunction A, 0.5-1 EasingFunction B)
|
||||
*
|
||||
@@ -92,8 +99,10 @@ public abstract class Easing {
|
||||
/**
|
||||
* Create a composite EasingFunction
|
||||
*
|
||||
* @param in initial EasingFunction
|
||||
* @param out terminal EasingFunction
|
||||
* @param in
|
||||
* initial EasingFunction
|
||||
* @param out
|
||||
* terminal EasingFunction
|
||||
*/
|
||||
public Composite(Easing in, Easing out) {
|
||||
this.in = in;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.Range;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -17,8 +16,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get INTEGER
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return integer
|
||||
*/
|
||||
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 Range) return ((Range) o).randInt();
|
||||
if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0;
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
Log.w("Cannot convert " + o + " to Integer.");
|
||||
return def;
|
||||
}
|
||||
@@ -38,8 +40,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get DOUBLE
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return double
|
||||
*/
|
||||
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 Range) return ((Range) o).randDouble();
|
||||
if (o instanceof Boolean) return ((Boolean) o) ? 1 : 0;
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
Log.w("Cannot convert " + o + " to Double.");
|
||||
return def;
|
||||
}
|
||||
@@ -59,8 +64,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get FLOAT
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return float
|
||||
*/
|
||||
public static double getFloat(Object o, Float def)
|
||||
@@ -68,7 +75,8 @@ public class Convertor {
|
||||
try {
|
||||
if (o == null) return def;
|
||||
if (o instanceof Number) return ((Number) o).floatValue();
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
Log.w("Cannot convert " + o + " to Float.");
|
||||
return def;
|
||||
}
|
||||
@@ -77,8 +85,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get BOOLEAN
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean getBoolean(Object o, Boolean def)
|
||||
@@ -92,7 +102,8 @@ public class Convertor {
|
||||
try {
|
||||
double n = Double.parseDouble(s);
|
||||
return n != 0;
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
if (s.equals("true")) return true;
|
||||
if (s.equals("yes")) return true;
|
||||
@@ -115,8 +126,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get STRING
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return String
|
||||
*/
|
||||
public static String getString(Object o, String def)
|
||||
@@ -132,8 +145,10 @@ public class Convertor {
|
||||
* Get AI_COORD<br>
|
||||
* Converts special constants to magic coordinate instances.
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return AiCoord
|
||||
*/
|
||||
public static Coord getCoord(Object o, Coord def)
|
||||
@@ -164,8 +179,10 @@ public class Convertor {
|
||||
/**
|
||||
* Get RANGE
|
||||
*
|
||||
* @param o object
|
||||
* @param def default value
|
||||
* @param o
|
||||
* object
|
||||
* @param def
|
||||
* default value
|
||||
* @return AiCoord
|
||||
*/
|
||||
public static Range getRange(Object o, Range def)
|
||||
@@ -190,7 +207,8 @@ public class Convertor {
|
||||
|
||||
}
|
||||
if (o instanceof Range) return (Range) o;
|
||||
} catch (NumberFormatException e) {}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
Log.w("Cannot convert " + o + " to Range.");
|
||||
return def;
|
||||
}
|
||||
@@ -199,7 +217,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get INTEGER
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return integer
|
||||
*/
|
||||
public static int getInteger(Object o)
|
||||
@@ -211,7 +230,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get DOUBLE
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return double
|
||||
*/
|
||||
public static double getDouble(Object o)
|
||||
@@ -223,7 +243,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get FLOAT
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return float
|
||||
*/
|
||||
public static double getFloat(Object o)
|
||||
@@ -235,7 +256,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get BOOLEAN
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean getBoolean(Object o)
|
||||
@@ -247,7 +269,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get STRING
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return String
|
||||
*/
|
||||
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
|
||||
* of it)
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return AiCoord
|
||||
*/
|
||||
public static Coord getCoord(Object o)
|
||||
@@ -272,7 +296,8 @@ public class Convertor {
|
||||
/**
|
||||
* Get RANGE
|
||||
*
|
||||
* @param o object
|
||||
* @param o
|
||||
* object
|
||||
* @return AiCoord
|
||||
*/
|
||||
public static Range getRange(Object o)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
/**
|
||||
* Mutable object
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <T> type
|
||||
* @param <T>
|
||||
* type
|
||||
*/
|
||||
public class Mutable<T> {
|
||||
|
||||
@@ -16,7 +16,8 @@ public class Mutable<T> {
|
||||
/**
|
||||
* New mutable object
|
||||
*
|
||||
* @param o value
|
||||
* @param o
|
||||
* value
|
||||
*/
|
||||
public Mutable(T o) {
|
||||
this.o = o;
|
||||
@@ -37,7 +38,8 @@ public class Mutable<T> {
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param o new value to set
|
||||
* @param o
|
||||
* new value to set
|
||||
*/
|
||||
public void set(T o)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -24,8 +23,10 @@ public class ObjectUtils {
|
||||
/**
|
||||
* Sort a map by keys, maintaining key-value pairs.
|
||||
*
|
||||
* @param map map to be sorted
|
||||
* @param comparator a comparator, or null for natural ordering
|
||||
* @param map
|
||||
* map to be sorted
|
||||
* @param comparator
|
||||
* a comparator, or null for natural ordering
|
||||
* @return linked hash map with sorted entries
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@@ -53,8 +54,10 @@ public class ObjectUtils {
|
||||
/**
|
||||
* Sort a map by values, maintaining key-value pairs.
|
||||
*
|
||||
* @param map map to be sorted
|
||||
* @param comparator a comparator, or null for natural ordering
|
||||
* @param map
|
||||
* map to be sorted
|
||||
* @param comparator
|
||||
* a comparator, or null for natural ordering
|
||||
* @return linked hash map with sorted entries
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -64,6 +67,7 @@ public class ObjectUtils {
|
||||
|
||||
Collections.sort(entries, new Comparator<Map.Entry<K, V>>() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public int compare(Entry<K, V> o1, Entry<K, V> o2)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -9,8 +8,10 @@ import mightypork.utils.math.Calc;
|
||||
*
|
||||
* @author MightyPork
|
||||
* @copy (c) 2012
|
||||
* @param <T1> 1st object class
|
||||
* @param <T2> 2nd object class
|
||||
* @param <T1>
|
||||
* 1st object class
|
||||
* @param <T2>
|
||||
* 2nd object class
|
||||
*/
|
||||
public class Pair<T1, T2> {
|
||||
|
||||
@@ -28,8 +29,10 @@ public class Pair<T1, T2> {
|
||||
/**
|
||||
* Make structure of 2 objects
|
||||
*
|
||||
* @param first 1st object
|
||||
* @param second 2nd object
|
||||
* @param first
|
||||
* 1st object
|
||||
* @param second
|
||||
* 2nd object
|
||||
*/
|
||||
public Pair(T1 first, T2 second) {
|
||||
this.first = first;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -9,9 +8,12 @@ import mightypork.utils.math.Calc;
|
||||
*
|
||||
* @author MightyPork
|
||||
* @copy (c) 2012
|
||||
* @param <T1> 1st object class
|
||||
* @param <T2> 2nd object class
|
||||
* @param <T3> 3rd object class
|
||||
* @param <T1>
|
||||
* 1st object class
|
||||
* @param <T2>
|
||||
* 2nd object class
|
||||
* @param <T3>
|
||||
* 3rd object class
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param objA 1st object
|
||||
* @param objB 2nd object
|
||||
* @param objC 3rd object
|
||||
* @param objA
|
||||
* 1st object
|
||||
* @param objB
|
||||
* 2nd object
|
||||
* @param objC
|
||||
* 3rd object
|
||||
*/
|
||||
public Triad(T1 objA, T2 objB, T3 objC) {
|
||||
super(objA, objB);
|
||||
@@ -46,7 +51,8 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
|
||||
/**
|
||||
* Set 1st object
|
||||
*
|
||||
* @param obj 1st object
|
||||
* @param obj
|
||||
* 1st object
|
||||
*/
|
||||
public void setThird(T3 obj)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,18 +25,23 @@ import java.util.Map;
|
||||
* </pre>
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <K> Type for Map keys
|
||||
* @param <V> Type for Map values
|
||||
* @param <K>
|
||||
* Type for Map keys
|
||||
* @param <V>
|
||||
* Type for Map values
|
||||
*/
|
||||
public class VarargsParser<K, V> {
|
||||
|
||||
/**
|
||||
* Parse array of vararg key, value pairs to a LinkedHashMap.
|
||||
*
|
||||
* @param args varargs
|
||||
* @param args
|
||||
* varargs
|
||||
* @return LinkedHashMap
|
||||
* @throws ClassCastException in case of incompatible type in the array
|
||||
* @throws IllegalArgumentException in case of invalid array length (odd)
|
||||
* @throws ClassCastException
|
||||
* in case of incompatible type in the array
|
||||
* @throws IllegalArgumentException
|
||||
* in case of invalid array length (odd)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<K, V> parse(Object... args) throws ClassCastException, IllegalArgumentException
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.patterns;
|
||||
|
||||
|
||||
/**
|
||||
* Object that can be destroyed (free resources etc)
|
||||
*
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package mightypork.utils.patterns.subscription;
|
||||
|
||||
|
||||
/**
|
||||
* Something that can be handled by HANDLER.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <HANDLER> handler type
|
||||
* @param <HANDLER>
|
||||
* handler type
|
||||
*/
|
||||
public interface Handleable<HANDLER> {
|
||||
|
||||
/**
|
||||
* Ask handler to handle this message.
|
||||
*
|
||||
* @param handler handler instance
|
||||
* @param handler
|
||||
* handler instance
|
||||
*/
|
||||
public void handleBy(HANDLER handler);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.patterns.subscription;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
@@ -25,7 +24,8 @@ final public class MessageBus {
|
||||
* Add a {@link MessageChannel} to this bus.<br>
|
||||
* 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
|
||||
*/
|
||||
public MessageChannel<?, ?> addChannel(MessageChannel<?, ?> channel)
|
||||
@@ -47,7 +47,8 @@ final public class MessageBus {
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
@@ -58,7 +59,8 @@ final public class MessageBus {
|
||||
/**
|
||||
* Broadcast a message
|
||||
*
|
||||
* @param message message
|
||||
* @param message
|
||||
* message
|
||||
* @return true if message was accepted by at least one channel
|
||||
*/
|
||||
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
|
||||
* and future channels, until removed from the bus.
|
||||
*
|
||||
* @param client the client
|
||||
* @param client
|
||||
* the client
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean subscribe(Object client)
|
||||
@@ -95,7 +98,8 @@ final public class MessageBus {
|
||||
/**
|
||||
* Disconnect a client from the bus.
|
||||
*
|
||||
* @param client the client
|
||||
* @param client
|
||||
* the client
|
||||
*/
|
||||
public void unsubscribe(Object client)
|
||||
{
|
||||
@@ -117,8 +121,10 @@ final public class MessageBus {
|
||||
/**
|
||||
* Add a channel for given message and client type.
|
||||
*
|
||||
* @param messageClass message type
|
||||
* @param clientClass client type
|
||||
* @param messageClass
|
||||
* message type
|
||||
* @param clientClass
|
||||
* client type
|
||||
* @return the created channel instance
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -13,8 +12,10 @@ import mightypork.utils.patterns.subscription.clients.ToggleableClient;
|
||||
* Message channel, module of {@link MessageBus}
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <MESSAGE> message type
|
||||
* @param <CLIENT> client (subscriber) type
|
||||
* @param <MESSAGE>
|
||||
* message type
|
||||
* @param <CLIENT>
|
||||
* client (subscriber) type
|
||||
*/
|
||||
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>
|
||||
* If message is of wrong type, <code>false</code> is returned.
|
||||
*
|
||||
* @param message a message to be sent
|
||||
* @param clients collection of clients
|
||||
* @param message
|
||||
* a message to be sent
|
||||
* @param clients
|
||||
* collection of clients
|
||||
* @return true if message was accepted by this channel
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param client target client
|
||||
* @param message message to send
|
||||
* @param client
|
||||
* target client
|
||||
* @param message
|
||||
* message to send
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
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
|
||||
* {@link MessageChannel}
|
||||
*
|
||||
* @param message event object
|
||||
* @param message
|
||||
* event object
|
||||
* @return can be broadcasted
|
||||
*/
|
||||
public boolean canBroadcast(Object message)
|
||||
@@ -146,8 +152,10 @@ final public class MessageChannel<MESSAGE extends Handleable<CLIENT>, CLIENT> {
|
||||
/**
|
||||
* Create an instance for given types
|
||||
*
|
||||
* @param messageClass event class
|
||||
* @param clientClass client class
|
||||
* @param messageClass
|
||||
* event class
|
||||
* @param clientClass
|
||||
* client class
|
||||
* @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)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.patterns.subscription.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.patterns.subscription.clients;
|
||||
|
||||
|
||||
/**
|
||||
* Client that can toggle receiving messages.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string;
|
||||
|
||||
|
||||
/**
|
||||
* General purpose string utilities
|
||||
*
|
||||
@@ -11,9 +10,12 @@ public class StringUtils {
|
||||
/**
|
||||
* Get if string is in array
|
||||
*
|
||||
* @param needle checked string
|
||||
* @param case_sensitive case sensitive comparision
|
||||
* @param haystack array of possible values
|
||||
* @param needle
|
||||
* checked string
|
||||
* @param case_sensitive
|
||||
* case sensitive comparision
|
||||
* @param haystack
|
||||
* array of possible values
|
||||
* @return is in array
|
||||
*/
|
||||
public static boolean isInArray(String needle, boolean case_sensitive, String... haystack)
|
||||
@@ -61,7 +63,8 @@ public class StringUtils {
|
||||
/**
|
||||
* Repeat a string
|
||||
*
|
||||
* @param repeated string
|
||||
* @param repeated
|
||||
* string
|
||||
* @param count
|
||||
* @return output
|
||||
*/
|
||||
@@ -77,7 +80,8 @@ public class StringUtils {
|
||||
/**
|
||||
* convert string to a same-length sequence of # marks
|
||||
*
|
||||
* @param password password
|
||||
* @param password
|
||||
* password
|
||||
* @return encoded
|
||||
*/
|
||||
public static String passwordify(String password)
|
||||
@@ -89,8 +93,10 @@ public class StringUtils {
|
||||
/**
|
||||
* convert string to a same-length sequence of chars
|
||||
*
|
||||
* @param password password
|
||||
* @param replacing character used in output
|
||||
* @param password
|
||||
* password
|
||||
* @param replacing
|
||||
* character used in output
|
||||
* @return encoded
|
||||
*/
|
||||
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.)
|
||||
*
|
||||
* @param number number
|
||||
* @param number
|
||||
* number
|
||||
* @return ordinal, string
|
||||
*/
|
||||
public static String numberToOrdinal(int number)
|
||||
@@ -119,7 +126,8 @@ public class StringUtils {
|
||||
/**
|
||||
* Format number with thousands separated by a dot.
|
||||
*
|
||||
* @param number number
|
||||
* @param number
|
||||
* number
|
||||
* @return string 12.004.225
|
||||
*/
|
||||
public static String formatInt(long number)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public interface CharValidator {
|
||||
|
||||
public boolean isValid(char c);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class CharValidatorRegex implements CharValidator {
|
||||
|
||||
private String formula;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class CharValidatorWhitelist implements CharValidator {
|
||||
|
||||
private String whitelist;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
@@ -19,7 +18,8 @@ public class FileSuffixFilter implements FileFilter {
|
||||
/**
|
||||
* Suffix filter
|
||||
*
|
||||
* @param suffixes var-args allowed suffixes, case insensitive
|
||||
* @param suffixes
|
||||
* var-args allowed suffixes, case insensitive
|
||||
*/
|
||||
public FileSuffixFilter(String... suffixes) {
|
||||
this.suffixes = suffixes;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class FilenameCharValidator extends CharValidatorRegex {
|
||||
|
||||
public FilenameCharValidator() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
/**
|
||||
* Utility interface for string filters (accepting filepaths and similar)
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
/**
|
||||
* Class for counting FPS in games.<br>
|
||||
* 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
|
||||
*
|
||||
* @param dropped dropped frames
|
||||
* @param dropped
|
||||
* dropped frames
|
||||
*/
|
||||
public void drop(int dropped)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
public interface Pauseable {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
/**
|
||||
* Timer for delta timing
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user