Formatting, added eclipse prefs file
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileLock;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.rogue.display.DisplaySystem;
|
||||
import mightypork.rogue.input.InputSystem;
|
||||
import mightypork.rogue.sounds.SoundSystem;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.rogue.display.DisplaySystem;
|
||||
import mightypork.rogue.input.InputSystem;
|
||||
import mightypork.rogue.sounds.SoundSystem;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.utils.files.PropertyManager;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
/**
|
||||
* Application constants
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import mightypork.utils.files.OsUtils;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -60,8 +61,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.AppAdapter;
|
||||
|
||||
@@ -12,8 +13,7 @@ import mightypork.rogue.AppAdapter;
|
||||
public class SimpleBusClient extends AppAdapter {
|
||||
|
||||
/**
|
||||
* @param app
|
||||
* app access
|
||||
* @param app app access
|
||||
*/
|
||||
public SimpleBusClient(AppAccess app) {
|
||||
super(app);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.bus;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.events.UpdateEvent;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -66,14 +67,12 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -24,14 +25,10 @@ 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;
|
||||
@@ -110,14 +107,12 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -40,14 +41,12 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
@@ -42,7 +43,6 @@ public class ScreenChangeEvent implements Handleable<ScreenChangeEvent.Listener>
|
||||
handler.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(ScreenChangeEvent event);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.bus.events;
|
||||
|
||||
|
||||
import mightypork.utils.patterns.subscription.Handleable;
|
||||
|
||||
|
||||
@@ -25,7 +26,6 @@ public class UpdateEvent implements Handleable<UpdateEvent.Listener> {
|
||||
handler.receive(this);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(UpdateEvent event);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
@@ -51,8 +52,7 @@ 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,8 +161,7 @@ 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)
|
||||
{
|
||||
@@ -179,8 +178,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.display;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display.constraints;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display.constraints;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display.rendering;
|
||||
|
||||
|
||||
public interface Renderable {
|
||||
|
||||
public void render();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.display.rendering;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
@@ -20,7 +21,6 @@ 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,7 +112,6 @@ public class FontManager {
|
||||
OUTLINE;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Preloaded font identifier [name, size, style]
|
||||
// *
|
||||
@@ -224,12 +223,9 @@ 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)
|
||||
{
|
||||
@@ -254,14 +250,10 @@ 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)
|
||||
@@ -274,24 +266,16 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
import static mightypork.rogue.fonts.FontManager.Style.*;
|
||||
import mightypork.rogue.fonts.FontManager.Glyphs;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.fonts;
|
||||
|
||||
|
||||
import static mightypork.rogue.fonts.Align.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@@ -74,7 +75,6 @@ public class LoadedFont {
|
||||
private double clipVerticalT = 0;
|
||||
private double clipVerticalB = 0;
|
||||
|
||||
|
||||
private class CharStorageEntry {
|
||||
|
||||
/** Character's width */
|
||||
@@ -572,16 +572,11 @@ 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)
|
||||
{
|
||||
@@ -592,14 +587,10 @@ 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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import mightypork.rogue.AppAccess;
|
||||
import mightypork.rogue.bus.DelegatingBusClient;
|
||||
import mightypork.rogue.bus.events.KeyboardEvent;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
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);
|
||||
|
||||
@@ -16,8 +15,7 @@ public interface KeyBinder {
|
||||
/**
|
||||
* Remove handler from a keystroke (id any)
|
||||
*
|
||||
* @param stroke
|
||||
* stroke
|
||||
* @param stroke stroke
|
||||
*/
|
||||
abstract void unbindKeyStroke(KeyStroke stroke);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import mightypork.rogue.bus.events.KeyboardEvent;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -21,10 +22,8 @@ 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)
|
||||
@@ -44,8 +43,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.input;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@@ -16,10 +17,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -16,7 +17,8 @@ import org.newdawn.slick.openal.SoundStore;
|
||||
*/
|
||||
public class AudioX implements Destroyable {
|
||||
|
||||
private enum PlayMode {
|
||||
private enum PlayMode
|
||||
{
|
||||
EFFECT, MUSIC;
|
||||
};
|
||||
|
||||
@@ -35,8 +37,7 @@ 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;
|
||||
@@ -160,12 +161,9 @@ 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)
|
||||
@@ -177,12 +175,9 @@ 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
|
||||
@@ -196,12 +191,9 @@ 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
|
||||
@@ -222,14 +214,10 @@ 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)
|
||||
@@ -244,12 +232,9 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
@@ -17,8 +18,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import mightypork.utils.objects.Mutable;
|
||||
import mightypork.utils.time.Pauseable;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
public class NullAudio extends AudioX {
|
||||
|
||||
public NullAudio() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.sounds;
|
||||
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -118,14 +119,10 @@ 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)
|
||||
{
|
||||
@@ -137,18 +134,12 @@ 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)
|
||||
{
|
||||
@@ -161,11 +152,9 @@ 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)
|
||||
{
|
||||
@@ -179,8 +168,7 @@ 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)
|
||||
@@ -197,8 +185,7 @@ 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)
|
||||
@@ -226,8 +213,7 @@ 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)
|
||||
{
|
||||
@@ -238,10 +224,8 @@ 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)
|
||||
{
|
||||
@@ -252,8 +236,7 @@ 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)
|
||||
{
|
||||
@@ -264,10 +247,8 @@ 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)
|
||||
{
|
||||
@@ -278,8 +259,7 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Pause a loop
|
||||
*
|
||||
* @param key
|
||||
* sound key
|
||||
* @param key sound key
|
||||
*/
|
||||
public void pauseLoop(String key)
|
||||
{
|
||||
@@ -301,8 +281,7 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Resume a loop
|
||||
*
|
||||
* @param key
|
||||
* sound key
|
||||
* @param key sound key
|
||||
*/
|
||||
public void resumeLoop(String key)
|
||||
{
|
||||
@@ -313,8 +292,7 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of master volume
|
||||
*
|
||||
* @param d
|
||||
* level
|
||||
* @param d level
|
||||
*/
|
||||
public void setMasterVolume(double d)
|
||||
{
|
||||
@@ -325,8 +303,7 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of effects volume
|
||||
*
|
||||
* @param d
|
||||
* level
|
||||
* @param d level
|
||||
*/
|
||||
public void setEffectsVolume(double d)
|
||||
{
|
||||
@@ -337,8 +314,7 @@ public class SoundSystem extends DelegatingBusClient {
|
||||
/**
|
||||
* Set level of music volume
|
||||
*
|
||||
* @param d
|
||||
* level
|
||||
* @param d level
|
||||
*/
|
||||
public void setMusicVolume(double d)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.tasks;
|
||||
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.testing;
|
||||
|
||||
|
||||
import mightypork.rogue.display.constraints.Bounding;
|
||||
import mightypork.rogue.display.constraints.Constraint;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.testing;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -181,7 +182,6 @@ class StringMessage implements Handleable<StringMessage.Listener> {
|
||||
this.s = str;
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(StringMessage message);
|
||||
@@ -205,7 +205,6 @@ class IntMessage implements Handleable<IntMessage.Listener> {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
|
||||
public interface Listener {
|
||||
|
||||
public void receive(IntMessage message);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -51,10 +52,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
// TODO rewrite
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.textures;
|
||||
|
||||
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
@@ -24,16 +25,11 @@ 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)
|
||||
@@ -43,10 +39,8 @@ 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;
|
||||
@@ -58,16 +52,11 @@ 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,5 +1,6 @@
|
||||
package mightypork.rogue.util;
|
||||
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import mightypork.rogue.textures.TextureManager;
|
||||
import mightypork.rogue.textures.TxQuad;
|
||||
@@ -26,10 +27,8 @@ 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)
|
||||
{
|
||||
@@ -40,14 +39,10 @@ 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)
|
||||
{
|
||||
@@ -63,16 +58,11 @@ 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)
|
||||
{
|
||||
@@ -83,20 +73,13 @@ 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)
|
||||
{
|
||||
@@ -121,14 +104,10 @@ 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)
|
||||
{
|
||||
@@ -139,18 +118,12 @@ 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)
|
||||
{
|
||||
@@ -171,14 +144,10 @@ 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)
|
||||
{
|
||||
@@ -189,18 +158,12 @@ 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)
|
||||
{
|
||||
@@ -231,14 +194,10 @@ 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)
|
||||
{
|
||||
@@ -249,18 +208,12 @@ 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)
|
||||
{
|
||||
@@ -280,14 +233,10 @@ 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)
|
||||
{
|
||||
@@ -298,18 +247,12 @@ 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)
|
||||
{
|
||||
@@ -338,16 +281,11 @@ 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)
|
||||
{
|
||||
@@ -358,20 +296,13 @@ 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)
|
||||
{
|
||||
@@ -436,8 +367,7 @@ public class RenderUtils {
|
||||
/**
|
||||
* Render quad 2D
|
||||
*
|
||||
* @param rect
|
||||
* rectangle
|
||||
* @param rect rectangle
|
||||
*/
|
||||
public static void quadRect(Rect rect)
|
||||
{
|
||||
@@ -448,10 +378,8 @@ 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)
|
||||
{
|
||||
@@ -463,14 +391,10 @@ 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)
|
||||
{
|
||||
@@ -481,12 +405,9 @@ 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)
|
||||
{
|
||||
@@ -497,12 +418,9 @@ 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)
|
||||
{
|
||||
@@ -513,12 +431,9 @@ 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)
|
||||
{
|
||||
@@ -529,12 +444,9 @@ 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)
|
||||
{
|
||||
@@ -545,14 +457,10 @@ 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)
|
||||
{
|
||||
@@ -563,10 +471,8 @@ 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)
|
||||
{
|
||||
@@ -596,12 +502,9 @@ 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)
|
||||
{
|
||||
@@ -612,14 +515,10 @@ 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)
|
||||
{
|
||||
@@ -637,10 +536,8 @@ 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)
|
||||
{
|
||||
@@ -651,12 +548,9 @@ 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)
|
||||
{
|
||||
@@ -667,14 +561,10 @@ 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)
|
||||
{
|
||||
@@ -685,16 +575,11 @@ 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)
|
||||
{
|
||||
@@ -755,12 +640,9 @@ 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)
|
||||
{
|
||||
@@ -771,10 +653,8 @@ 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)
|
||||
{
|
||||
@@ -785,12 +665,9 @@ 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)
|
||||
{
|
||||
@@ -801,14 +678,10 @@ 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)
|
||||
{
|
||||
@@ -820,14 +693,10 @@ 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)
|
||||
{
|
||||
@@ -839,16 +708,11 @@ 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)
|
||||
{
|
||||
@@ -889,12 +753,9 @@ 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)
|
||||
{
|
||||
@@ -906,14 +767,10 @@ 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)
|
||||
{
|
||||
@@ -925,14 +782,10 @@ 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)
|
||||
{
|
||||
@@ -944,16 +797,11 @@ 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)
|
||||
{
|
||||
@@ -996,12 +844,9 @@ 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)
|
||||
{
|
||||
@@ -1013,14 +858,10 @@ 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)
|
||||
{
|
||||
@@ -1032,14 +873,10 @@ 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)
|
||||
{
|
||||
@@ -1055,8 +892,7 @@ public class RenderUtils {
|
||||
/**
|
||||
* Bind GL color
|
||||
*
|
||||
* @param color
|
||||
* RGB color
|
||||
* @param color RGB color
|
||||
*/
|
||||
public static void setColor(RGB color)
|
||||
{
|
||||
@@ -1067,10 +903,8 @@ 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)
|
||||
{
|
||||
@@ -1081,8 +915,7 @@ public class RenderUtils {
|
||||
/**
|
||||
* Translate with coord
|
||||
*
|
||||
* @param coord
|
||||
* coord
|
||||
* @param coord coord
|
||||
*/
|
||||
public static void translate(Coord coord)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.rogue.util;
|
||||
|
||||
|
||||
/**
|
||||
* Utils class
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -91,8 +92,7 @@ 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,7 +140,6 @@ public class FileTreeDiff {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class NotEqualException extends Exception {
|
||||
|
||||
public NotEqualException(String msg) {
|
||||
@@ -149,7 +148,6 @@ public class FileTreeDiff {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class Tuple<T> {
|
||||
|
||||
public T a;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -14,12 +15,9 @@ 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
|
||||
{
|
||||
@@ -30,16 +28,11 @@ 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
|
||||
{
|
||||
@@ -69,14 +62,10 @@ 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
|
||||
{
|
||||
@@ -99,12 +88,9 @@ 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
|
||||
{
|
||||
@@ -134,12 +120,9 @@ 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
|
||||
{
|
||||
@@ -162,10 +145,8 @@ 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)
|
||||
@@ -188,8 +169,7 @@ public class FileUtils {
|
||||
/**
|
||||
* Read entire file to a string.
|
||||
*
|
||||
* @param file
|
||||
* file
|
||||
* @param file file
|
||||
* @return file contents
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -204,8 +184,7 @@ 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)
|
||||
@@ -217,10 +196,8 @@ 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)
|
||||
@@ -248,8 +225,7 @@ public class FileUtils {
|
||||
/**
|
||||
* Remove extension.
|
||||
*
|
||||
* @param file
|
||||
* file
|
||||
* @param file file
|
||||
* @return filename without extension
|
||||
*/
|
||||
public static String[] getFilenameParts(File file)
|
||||
@@ -300,8 +276,7 @@ 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)
|
||||
@@ -313,10 +288,8 @@ 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)
|
||||
@@ -384,12 +357,9 @@ 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
|
||||
{
|
||||
@@ -427,8 +397,7 @@ 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)
|
||||
@@ -458,8 +427,7 @@ 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)
|
||||
@@ -474,8 +442,7 @@ public class FileUtils {
|
||||
/**
|
||||
* Escape filename, keeping the same extension
|
||||
*
|
||||
* @param filename
|
||||
* filename
|
||||
* @param filename filename
|
||||
* @return escaped
|
||||
*/
|
||||
public static String escapeFilename(String filename)
|
||||
@@ -489,8 +456,7 @@ 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)
|
||||
@@ -516,10 +482,8 @@ 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
|
||||
@@ -552,8 +516,7 @@ 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,11 +1,13 @@
|
||||
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,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -195,10 +196,8 @@ 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)
|
||||
{
|
||||
@@ -264,7 +263,6 @@ public class PropertyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper class which loads Properties from UTF-8 file (Properties use
|
||||
* "ISO-8859-1" by default)
|
||||
@@ -339,7 +337,6 @@ public class PropertyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property entry in Property manager.
|
||||
*
|
||||
@@ -366,14 +363,10 @@ 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;
|
||||
@@ -386,14 +379,10 @@ 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;
|
||||
@@ -406,14 +395,10 @@ 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;
|
||||
@@ -491,8 +476,7 @@ 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)
|
||||
@@ -597,11 +581,11 @@ public class PropertyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property types
|
||||
*/
|
||||
private enum PropertyType {
|
||||
private enum PropertyType
|
||||
{
|
||||
BOOLEAN, INT, STRING, DOUBLE;
|
||||
}
|
||||
|
||||
@@ -626,10 +610,8 @@ 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;
|
||||
@@ -729,8 +711,7 @@ public class PropertyManager {
|
||||
|
||||
|
||||
/**
|
||||
* @param newlineBeforeComments
|
||||
* put newline before comments
|
||||
* @param newlineBeforeComments put newline before comments
|
||||
*/
|
||||
public void cfgNewlineBeforeComments(boolean newlineBeforeComments)
|
||||
{
|
||||
@@ -739,8 +720,7 @@ public class PropertyManager {
|
||||
|
||||
|
||||
/**
|
||||
* @param separateSections
|
||||
* do separate sections by newline
|
||||
* @param separateSections do separate sections by newline
|
||||
*/
|
||||
public void cfgSeparateSections(boolean separateSections)
|
||||
{
|
||||
@@ -749,8 +729,7 @@ public class PropertyManager {
|
||||
|
||||
|
||||
/**
|
||||
* @param forceSave
|
||||
* save even if unchanged.
|
||||
* @param forceSave save even if unchanged.
|
||||
*/
|
||||
public void cfgForceSave(boolean forceSave)
|
||||
{
|
||||
@@ -759,8 +738,7 @@ public class PropertyManager {
|
||||
|
||||
|
||||
/**
|
||||
* @param validate
|
||||
* enable validation
|
||||
* @param validate enable validation
|
||||
*/
|
||||
public void enableValidation(boolean validate)
|
||||
{
|
||||
@@ -771,8 +749,7 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get a property entry (rarely used)
|
||||
*
|
||||
* @param n
|
||||
* key
|
||||
* @param n key
|
||||
* @return the entry
|
||||
*/
|
||||
private Property get(String n)
|
||||
@@ -788,8 +765,7 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get boolean property
|
||||
*
|
||||
* @param n
|
||||
* key
|
||||
* @param n key
|
||||
* @return the boolean found, or false
|
||||
*/
|
||||
public Boolean getBoolean(String n)
|
||||
@@ -805,8 +781,7 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get numeric property
|
||||
*
|
||||
* @param n
|
||||
* key
|
||||
* @param n key
|
||||
* @return the int found, or null
|
||||
*/
|
||||
public Integer getInteger(String n)
|
||||
@@ -822,8 +797,7 @@ 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)
|
||||
@@ -839,8 +813,7 @@ public class PropertyManager {
|
||||
/**
|
||||
* Get string property
|
||||
*
|
||||
* @param n
|
||||
* key
|
||||
* @param n key
|
||||
* @return the string found, or null
|
||||
*/
|
||||
public String getString(String n)
|
||||
@@ -856,10 +829,8 @@ 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)
|
||||
{
|
||||
@@ -871,12 +842,9 @@ 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)
|
||||
{
|
||||
@@ -888,10 +856,8 @@ 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)
|
||||
{
|
||||
@@ -903,12 +869,9 @@ 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)
|
||||
{
|
||||
@@ -920,10 +883,8 @@ 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)
|
||||
{
|
||||
@@ -935,12 +896,9 @@ 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)
|
||||
{
|
||||
@@ -952,10 +910,8 @@ 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)
|
||||
{
|
||||
@@ -967,12 +923,9 @@ 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)
|
||||
{
|
||||
@@ -984,10 +937,8 @@ 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)
|
||||
{
|
||||
@@ -1000,10 +951,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -25,8 +26,7 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load list from file
|
||||
*
|
||||
* @param file
|
||||
* file
|
||||
* @param file file
|
||||
* @return map of keys and values
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -41,8 +41,7 @@ public class SimpleConfig {
|
||||
/**
|
||||
* Load map from file
|
||||
*
|
||||
* @param file
|
||||
* file
|
||||
* @param file file
|
||||
* @return map of keys and values
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -57,8 +56,7 @@ 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)
|
||||
@@ -88,8 +86,7 @@ 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)
|
||||
@@ -145,8 +142,7 @@ 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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -20,10 +21,9 @@ 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,10 +36,8 @@ 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
|
||||
@@ -60,10 +58,8 @@ 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
|
||||
@@ -82,10 +78,8 @@ 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
|
||||
@@ -104,8 +98,7 @@ public class ZipBuilder {
|
||||
/**
|
||||
* Normalize path
|
||||
*
|
||||
* @param path
|
||||
* original path
|
||||
* @param path original path
|
||||
* @return normalized path
|
||||
*/
|
||||
private String preparePath(String path)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files;
|
||||
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -27,12 +28,9 @@ 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
|
||||
*/
|
||||
@@ -57,12 +55,9 @@ 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
|
||||
*/
|
||||
@@ -101,11 +96,9 @@ 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
|
||||
{
|
||||
@@ -126,11 +119,9 @@ 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
|
||||
{
|
||||
@@ -154,14 +145,10 @@ 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
|
||||
{
|
||||
@@ -197,13 +184,10 @@ 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
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -58,8 +59,7 @@ 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)
|
||||
{
|
||||
@@ -69,8 +69,7 @@ public abstract class AbstractIonList<T> extends ArrayList<T> implements Ionizab
|
||||
/**
|
||||
* Write custom data of this AbstractIonList implementation
|
||||
*
|
||||
* @param out
|
||||
* output stream
|
||||
* @param out output stream
|
||||
*/
|
||||
public void ionWriteCustomData(OutputStream out)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -74,8 +75,7 @@ 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)
|
||||
{
|
||||
@@ -85,8 +85,7 @@ public abstract class AbstractIonMap<V> extends LinkedHashMap<String, V> impleme
|
||||
/**
|
||||
* Write custom data of this AbstractIonMap implementation
|
||||
*
|
||||
* @param out
|
||||
* output stream
|
||||
* @param out output stream
|
||||
*/
|
||||
public void ionWriteCustomData(OutputStream out)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,10 +32,8 @@ 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
|
||||
@@ -49,8 +48,7 @@ public class Ion {
|
||||
/**
|
||||
* Load Ion object from file.
|
||||
*
|
||||
* @param file
|
||||
* file path
|
||||
* @param file file path
|
||||
* @return the loaded object
|
||||
* @throws IonException
|
||||
*/
|
||||
@@ -63,11 +61,9 @@ 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
|
||||
{
|
||||
@@ -94,8 +90,7 @@ public class Ion {
|
||||
/**
|
||||
* Load Ion object from stream.
|
||||
*
|
||||
* @param in
|
||||
* input stream
|
||||
* @param in input stream
|
||||
* @return the loaded object
|
||||
* @throws IonException
|
||||
*/
|
||||
@@ -108,10 +103,8 @@ 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
|
||||
@@ -123,10 +116,8 @@ 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
|
||||
@@ -162,10 +153,8 @@ 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
|
||||
@@ -177,8 +166,7 @@ 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
|
||||
*/
|
||||
@@ -233,10 +221,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
public class IonException extends Exception {
|
||||
|
||||
public IonException() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable Arraylist
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Ionizable HashMap
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Byte marks used to structure data in Ion files.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -17,8 +18,7 @@ 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,8 +28,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
/**
|
||||
* Optional ionizable
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.files.ion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -13,8 +14,7 @@ public class Log {
|
||||
/**
|
||||
* Log FINE message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void f1(String msg)
|
||||
{
|
||||
@@ -25,8 +25,7 @@ public class Log {
|
||||
/**
|
||||
* Log FINER message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void f2(String msg)
|
||||
{
|
||||
@@ -37,8 +36,7 @@ public class Log {
|
||||
/**
|
||||
* Log FINEST message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void f3(String msg)
|
||||
{
|
||||
@@ -49,8 +47,7 @@ public class Log {
|
||||
/**
|
||||
* Log INFO message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void i(String msg)
|
||||
{
|
||||
@@ -61,8 +58,7 @@ public class Log {
|
||||
/**
|
||||
* Log WARNING message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void w(String msg)
|
||||
{
|
||||
@@ -73,8 +69,7 @@ public class Log {
|
||||
/**
|
||||
* Log ERROR message in main logger
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public static void e(String msg)
|
||||
{
|
||||
@@ -85,10 +80,8 @@ 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)
|
||||
{
|
||||
@@ -99,8 +92,7 @@ public class Log {
|
||||
/**
|
||||
* Log EXCEPTION in main logger
|
||||
*
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
* @param thrown thrown exception
|
||||
*/
|
||||
public static void e(Throwable thrown)
|
||||
{
|
||||
@@ -117,8 +109,7 @@ public class Log {
|
||||
/**
|
||||
* Enable / disable static log delegate methods
|
||||
*
|
||||
* @param flag
|
||||
* enable
|
||||
* @param flag enable
|
||||
*/
|
||||
public static void enableStaticLogging(boolean flag)
|
||||
{
|
||||
@@ -133,12 +124,10 @@ 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)
|
||||
@@ -157,10 +146,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.PrintWriter;
|
||||
@@ -150,8 +151,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Add log monitor
|
||||
*
|
||||
* @param mon
|
||||
* monitor
|
||||
* @param mon monitor
|
||||
* @return assigned ID
|
||||
*/
|
||||
public synchronized int addMonitor(LogMonitor mon)
|
||||
@@ -166,8 +166,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Remove a monitor by ID
|
||||
*
|
||||
* @param id
|
||||
* monitor ID
|
||||
* @param id monitor ID
|
||||
*/
|
||||
public synchronized void removeMonitor(int id)
|
||||
{
|
||||
@@ -178,8 +177,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Enable logging.
|
||||
*
|
||||
* @param flag
|
||||
* do enable logging
|
||||
* @param flag do enable logging
|
||||
*/
|
||||
public void enable(boolean flag)
|
||||
{
|
||||
@@ -190,8 +188,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Enable printing logs to sysout
|
||||
*
|
||||
* @param flag
|
||||
* do enable logging
|
||||
* @param flag do enable logging
|
||||
*/
|
||||
public void enableSysout(boolean flag)
|
||||
{
|
||||
@@ -203,8 +200,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINE message
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void f1(String msg)
|
||||
{
|
||||
@@ -215,8 +211,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINER message
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void f2(String msg)
|
||||
{
|
||||
@@ -227,8 +222,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log FINEST message
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void f3(String msg)
|
||||
{
|
||||
@@ -239,8 +233,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log INFO message
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void i(String msg)
|
||||
{
|
||||
@@ -251,8 +244,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log WARNING message (less severe than ERROR)
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void w(String msg)
|
||||
{
|
||||
@@ -263,8 +255,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log ERROR message
|
||||
*
|
||||
* @param msg
|
||||
* message
|
||||
* @param msg message
|
||||
*/
|
||||
public void e(String msg)
|
||||
{
|
||||
@@ -275,10 +266,8 @@ 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)
|
||||
{
|
||||
@@ -289,8 +278,7 @@ public class LogInstance {
|
||||
/**
|
||||
* Log exception thrown
|
||||
*
|
||||
* @param thrown
|
||||
* thrown exception
|
||||
* @param thrown thrown exception
|
||||
*/
|
||||
public void e(Throwable thrown)
|
||||
{
|
||||
@@ -314,7 +302,6 @@ public class LogInstance {
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PowerCraft Log file formatter.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.logging;
|
||||
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,12 +26,9 @@ 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)
|
||||
@@ -56,12 +54,9 @@ 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)
|
||||
@@ -73,10 +68,8 @@ 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)
|
||||
@@ -88,10 +81,8 @@ 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)
|
||||
@@ -103,10 +94,8 @@ 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)
|
||||
@@ -114,7 +103,6 @@ public class Calc {
|
||||
return Math.sqrt(square(c) - square(b));
|
||||
}
|
||||
|
||||
|
||||
private static class Angles {
|
||||
|
||||
public static double delta(double alpha, double beta, double a360)
|
||||
@@ -138,7 +126,6 @@ public class Calc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calc subclass with buffer utils.
|
||||
*
|
||||
@@ -149,8 +136,7 @@ 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)
|
||||
@@ -175,8 +161,7 @@ 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)
|
||||
@@ -186,7 +171,6 @@ public class Calc {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Angle calculations for degrees.
|
||||
*
|
||||
@@ -209,10 +193,8 @@ 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)
|
||||
@@ -224,10 +206,8 @@ 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)
|
||||
@@ -239,8 +219,7 @@ public class Calc {
|
||||
/**
|
||||
* Cosinus in degrees
|
||||
*
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @param deg angle in degrees
|
||||
* @return cosinus
|
||||
*/
|
||||
public static double cos(double deg)
|
||||
@@ -252,8 +231,7 @@ public class Calc {
|
||||
/**
|
||||
* Sinus in degrees
|
||||
*
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @param deg angle in degrees
|
||||
* @return sinus
|
||||
*/
|
||||
public static double sin(double deg)
|
||||
@@ -265,8 +243,7 @@ public class Calc {
|
||||
/**
|
||||
* Tangents in degrees
|
||||
*
|
||||
* @param deg
|
||||
* angle in degrees
|
||||
* @param deg angle in degrees
|
||||
* @return tangents
|
||||
*/
|
||||
public static double tan(double deg)
|
||||
@@ -278,8 +255,7 @@ 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)
|
||||
@@ -291,8 +267,7 @@ public class Calc {
|
||||
/**
|
||||
* Convert to radians
|
||||
*
|
||||
* @param deg
|
||||
* degrees
|
||||
* @param deg degrees
|
||||
* @return radians
|
||||
*/
|
||||
public static double toRad(double deg)
|
||||
@@ -304,10 +279,8 @@ 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)
|
||||
@@ -325,8 +298,7 @@ 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)
|
||||
@@ -338,8 +310,7 @@ 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)
|
||||
@@ -351,8 +322,7 @@ 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)
|
||||
@@ -361,7 +331,6 @@ public class Calc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Angle calculations for radians.
|
||||
*
|
||||
@@ -384,10 +353,8 @@ 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)
|
||||
@@ -399,10 +366,8 @@ 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)
|
||||
@@ -414,8 +379,7 @@ public class Calc {
|
||||
/**
|
||||
* Cos
|
||||
*
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @param rad angle in rads
|
||||
* @return cos
|
||||
*/
|
||||
public static double cos(double rad)
|
||||
@@ -427,8 +391,7 @@ public class Calc {
|
||||
/**
|
||||
* Sin
|
||||
*
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @param rad angle in rads
|
||||
* @return sin
|
||||
*/
|
||||
public static double sin(double rad)
|
||||
@@ -440,8 +403,7 @@ public class Calc {
|
||||
/**
|
||||
* Tan
|
||||
*
|
||||
* @param rad
|
||||
* angle in rads
|
||||
* @param rad angle in rads
|
||||
* @return tan
|
||||
*/
|
||||
public static double tan(double rad)
|
||||
@@ -453,8 +415,7 @@ 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)
|
||||
@@ -466,8 +427,7 @@ public class Calc {
|
||||
/**
|
||||
* Convert to degrees
|
||||
*
|
||||
* @param rad
|
||||
* radians
|
||||
* @param rad radians
|
||||
* @return degrees
|
||||
*/
|
||||
public static double toDeg(double rad)
|
||||
@@ -482,8 +442,7 @@ 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)
|
||||
@@ -495,8 +454,7 @@ 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)
|
||||
@@ -508,8 +466,7 @@ 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)
|
||||
@@ -521,8 +478,7 @@ 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)
|
||||
@@ -547,12 +503,9 @@ 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)
|
||||
@@ -570,10 +523,8 @@ 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)
|
||||
@@ -589,12 +540,9 @@ 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)
|
||||
@@ -607,12 +555,9 @@ 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)
|
||||
@@ -625,12 +570,9 @@ 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)
|
||||
@@ -643,10 +585,8 @@ 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)
|
||||
@@ -659,10 +599,8 @@ 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)
|
||||
@@ -675,10 +613,8 @@ 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)
|
||||
@@ -691,10 +627,8 @@ 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)
|
||||
@@ -707,10 +641,8 @@ 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)
|
||||
@@ -723,10 +655,8 @@ 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)
|
||||
@@ -738,8 +668,7 @@ public class Calc {
|
||||
/**
|
||||
* Get class simple name
|
||||
*
|
||||
* @param obj
|
||||
* object
|
||||
* @param obj object
|
||||
* @return simple name
|
||||
*/
|
||||
public static String cname(Object obj)
|
||||
@@ -752,8 +681,7 @@ public class Calc {
|
||||
/**
|
||||
* Cube a double
|
||||
*
|
||||
* @param a
|
||||
* squared double
|
||||
* @param a squared double
|
||||
* @return square
|
||||
*/
|
||||
public static double cube(double a)
|
||||
@@ -765,8 +693,7 @@ 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)
|
||||
@@ -782,8 +709,7 @@ 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)
|
||||
@@ -799,12 +725,9 @@ 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)
|
||||
@@ -816,14 +739,10 @@ 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)
|
||||
@@ -835,14 +754,10 @@ 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)
|
||||
@@ -854,14 +769,10 @@ 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)
|
||||
@@ -873,8 +784,7 @@ public class Calc {
|
||||
/**
|
||||
* Get highest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static double max(double... numbers)
|
||||
@@ -890,8 +800,7 @@ public class Calc {
|
||||
/**
|
||||
* Get highest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static float max(float... numbers)
|
||||
@@ -907,8 +816,7 @@ public class Calc {
|
||||
/**
|
||||
* Get highest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static int max(int... numbers)
|
||||
@@ -924,8 +832,7 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static double min(double... numbers)
|
||||
@@ -941,8 +848,7 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static float min(float... numbers)
|
||||
@@ -958,8 +864,7 @@ public class Calc {
|
||||
/**
|
||||
* Get lowest number of a list
|
||||
*
|
||||
* @param numbers
|
||||
* numbers
|
||||
* @param numbers numbers
|
||||
* @return lowest
|
||||
*/
|
||||
public static int min(int... numbers)
|
||||
@@ -975,8 +880,7 @@ 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)
|
||||
@@ -991,8 +895,7 @@ public class Calc {
|
||||
for (String part : parts) {
|
||||
try {
|
||||
intList.add(Integer.parseInt(part));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} catch (NumberFormatException e) {}
|
||||
}
|
||||
|
||||
return intList;
|
||||
@@ -1003,8 +906,7 @@ 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)
|
||||
@@ -1017,8 +919,7 @@ public class Calc {
|
||||
/**
|
||||
* Square a double
|
||||
*
|
||||
* @param a
|
||||
* squared double
|
||||
* @param a squared double
|
||||
* @return square
|
||||
*/
|
||||
public static double square(double a)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc.Deg;
|
||||
import mightypork.utils.math.Calc.Rad;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -22,10 +23,8 @@ 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);
|
||||
@@ -35,12 +34,9 @@ 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;
|
||||
@@ -67,8 +63,7 @@ public class Polar {
|
||||
|
||||
|
||||
/**
|
||||
* @param angle
|
||||
* angle in RAD
|
||||
* @param angle angle in RAD
|
||||
*/
|
||||
public void setAngle(double angle)
|
||||
{
|
||||
@@ -77,8 +72,7 @@ public class Polar {
|
||||
|
||||
|
||||
/**
|
||||
* @param angle
|
||||
* angle in DEG
|
||||
* @param angle angle in DEG
|
||||
*/
|
||||
public void setAngleDeg(double angle)
|
||||
{
|
||||
@@ -96,8 +90,7 @@ public class Polar {
|
||||
|
||||
|
||||
/**
|
||||
* @param r
|
||||
* radius
|
||||
* @param r radius
|
||||
*/
|
||||
public void setRadius(double r)
|
||||
{
|
||||
@@ -108,8 +101,7 @@ public class Polar {
|
||||
/**
|
||||
* Make polar from coord
|
||||
*
|
||||
* @param coord
|
||||
* coord
|
||||
* @param coord coord
|
||||
* @return polar
|
||||
*/
|
||||
public static Polar fromCoord(Coord coord)
|
||||
@@ -121,10 +113,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.math;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
@@ -26,10 +27,8 @@ public class 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) {
|
||||
@@ -45,8 +44,7 @@ public class Range {
|
||||
/**
|
||||
* Create new range
|
||||
*
|
||||
* @param minmax
|
||||
* min = max number
|
||||
* @param minmax min = max number
|
||||
*/
|
||||
public Range(double minmax) {
|
||||
this.min = minmax;
|
||||
@@ -123,8 +121,7 @@ public class Range {
|
||||
/**
|
||||
* Set min
|
||||
*
|
||||
* @param min
|
||||
* min value
|
||||
* @param min min value
|
||||
*/
|
||||
public void setMin(double min)
|
||||
{
|
||||
@@ -135,8 +132,7 @@ public class Range {
|
||||
/**
|
||||
* Set max
|
||||
*
|
||||
* @param max
|
||||
* max value
|
||||
* @param max max value
|
||||
*/
|
||||
public void setMax(double max)
|
||||
{
|
||||
@@ -165,8 +161,7 @@ public class Range {
|
||||
/**
|
||||
* Set to value of other range
|
||||
*
|
||||
* @param other
|
||||
* copied range
|
||||
* @param other copied range
|
||||
*/
|
||||
public void setTo(Range other)
|
||||
{
|
||||
@@ -185,10 +180,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.math.color;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -72,8 +73,7 @@ public class HSV {
|
||||
/**
|
||||
* Set color to other color
|
||||
*
|
||||
* @param copied
|
||||
* copied color
|
||||
* @param copied copied color
|
||||
* @return this
|
||||
*/
|
||||
public HSV setTo(HSV copied)
|
||||
@@ -90,12 +90,9 @@ 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)
|
||||
@@ -137,8 +134,7 @@ public class HSV {
|
||||
/**
|
||||
* Make from RGB
|
||||
*
|
||||
* @param color
|
||||
* RGB
|
||||
* @param color RGB
|
||||
* @return HSV
|
||||
*/
|
||||
public static HSV fromRGB(RGB color)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math.color;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -53,8 +54,7 @@ public class 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)
|
||||
@@ -66,8 +66,7 @@ public class RGB {
|
||||
/**
|
||||
* set alpha IP
|
||||
*
|
||||
* @param alpha
|
||||
* alpha to set
|
||||
* @param alpha alpha to set
|
||||
* @return this
|
||||
*/
|
||||
public RGB setAlpha_ip(double alpha)
|
||||
@@ -92,8 +91,7 @@ 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)
|
||||
@@ -105,8 +103,7 @@ public class RGB {
|
||||
/**
|
||||
* Multiply alpha by given number
|
||||
*
|
||||
* @param alpha
|
||||
* alpha multiplier
|
||||
* @param alpha alpha multiplier
|
||||
* @return this
|
||||
*/
|
||||
public RGB mulAlpha_ip(double alpha)
|
||||
@@ -120,12 +117,9 @@ 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();
|
||||
@@ -138,14 +132,10 @@ 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();
|
||||
@@ -159,8 +149,7 @@ public class RGB {
|
||||
/**
|
||||
* Color from hex 0xRRGGBB
|
||||
*
|
||||
* @param hex
|
||||
* hex integer
|
||||
* @param hex hex integer
|
||||
*/
|
||||
public RGB(int hex) {
|
||||
setTo(RGB.fromHex(hex));
|
||||
@@ -171,10 +160,8 @@ 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));
|
||||
@@ -186,10 +173,8 @@ 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);
|
||||
@@ -236,8 +221,7 @@ public class RGB {
|
||||
/**
|
||||
* Set color to other color
|
||||
*
|
||||
* @param copied
|
||||
* copied color
|
||||
* @param copied copied color
|
||||
* @return this
|
||||
*/
|
||||
public RGB setTo(RGB copied)
|
||||
@@ -255,8 +239,7 @@ 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)
|
||||
@@ -270,14 +253,10 @@ 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)
|
||||
@@ -294,12 +273,9 @@ 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)
|
||||
@@ -358,8 +334,7 @@ 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)
|
||||
@@ -374,8 +349,7 @@ public class RGB {
|
||||
/**
|
||||
* Make from HSV
|
||||
*
|
||||
* @param color
|
||||
* HSV color
|
||||
* @param color HSV color
|
||||
* @return RGB
|
||||
*/
|
||||
public static RGB fromHSV(HSV color)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
@@ -18,10 +19,8 @@ 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)
|
||||
@@ -49,8 +48,7 @@ public class Coord {
|
||||
/**
|
||||
* Create coord as a copy of another
|
||||
*
|
||||
* @param copied
|
||||
* copied coord
|
||||
* @param copied copied coord
|
||||
*/
|
||||
public Coord(Coord copied) {
|
||||
setTo(copied);
|
||||
@@ -60,10 +58,8 @@ 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);
|
||||
@@ -73,12 +69,9 @@ 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);
|
||||
@@ -88,8 +81,7 @@ public class Coord {
|
||||
/**
|
||||
* Add a vector, in a copy
|
||||
*
|
||||
* @param vec
|
||||
* offset
|
||||
* @param vec offset
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord add(Coord vec)
|
||||
@@ -101,8 +93,7 @@ public class Coord {
|
||||
/**
|
||||
* Add a vector, in place
|
||||
*
|
||||
* @param vec
|
||||
* offset
|
||||
* @param vec offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord add_ip(Coord vec)
|
||||
@@ -115,10 +106,8 @@ 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)
|
||||
@@ -131,10 +120,8 @@ 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)
|
||||
@@ -146,12 +133,9 @@ 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)
|
||||
@@ -163,12 +147,9 @@ 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)
|
||||
@@ -194,8 +175,7 @@ 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)
|
||||
@@ -207,8 +187,7 @@ 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)
|
||||
@@ -220,10 +199,8 @@ 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)
|
||||
@@ -235,8 +212,7 @@ 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)
|
||||
@@ -271,8 +247,7 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in a copy.
|
||||
*
|
||||
* @param d
|
||||
* multiplier
|
||||
* @param d multiplier
|
||||
* @return changed copy
|
||||
*/
|
||||
public Coord mul(double d)
|
||||
@@ -284,8 +259,7 @@ public class Coord {
|
||||
/**
|
||||
* Multiply each component, in place.
|
||||
*
|
||||
* @param d
|
||||
* multiplier
|
||||
* @param d multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Coord mul_ip(double d)
|
||||
@@ -297,8 +271,7 @@ 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)
|
||||
@@ -311,10 +284,8 @@ 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)
|
||||
@@ -327,10 +298,8 @@ 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)
|
||||
@@ -342,12 +311,9 @@ 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)
|
||||
@@ -359,8 +325,7 @@ 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)
|
||||
@@ -372,12 +337,9 @@ 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)
|
||||
@@ -398,8 +360,7 @@ public class Coord {
|
||||
/**
|
||||
* offset randomly in place
|
||||
*
|
||||
* @param max
|
||||
* max +- offset
|
||||
* @param max max +- offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord random_offset_ip(double max)
|
||||
@@ -411,10 +372,8 @@ 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)
|
||||
@@ -426,10 +385,8 @@ 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)
|
||||
@@ -467,8 +424,7 @@ 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)
|
||||
{
|
||||
@@ -481,8 +437,7 @@ 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)
|
||||
{
|
||||
@@ -495,8 +450,7 @@ 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)
|
||||
@@ -508,10 +462,8 @@ 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)
|
||||
@@ -523,12 +475,9 @@ 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)
|
||||
@@ -543,8 +492,7 @@ 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)
|
||||
@@ -556,8 +504,7 @@ public class Coord {
|
||||
/**
|
||||
* Set X coordinate in place
|
||||
*
|
||||
* @param x
|
||||
* x coordinate
|
||||
* @param x x coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setX_ip(Number x)
|
||||
@@ -570,8 +517,7 @@ 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)
|
||||
@@ -583,8 +529,7 @@ public class Coord {
|
||||
/**
|
||||
* Set Y coordinate in place
|
||||
*
|
||||
* @param y
|
||||
* y coordinate
|
||||
* @param y y coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setY_ip(Number y)
|
||||
@@ -597,8 +542,7 @@ 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)
|
||||
@@ -610,8 +554,7 @@ public class Coord {
|
||||
/**
|
||||
* Set Z coordinate in place
|
||||
*
|
||||
* @param z
|
||||
* z coordinate
|
||||
* @param z z coordinate
|
||||
* @return this
|
||||
*/
|
||||
public Coord setZ_ip(Number z)
|
||||
@@ -624,8 +567,7 @@ public class Coord {
|
||||
/**
|
||||
* Get a copy subtracted by vector
|
||||
*
|
||||
* @param vec
|
||||
* offset
|
||||
* @param vec offset
|
||||
* @return the offset copy
|
||||
*/
|
||||
public Coord sub(Coord vec)
|
||||
@@ -637,10 +579,8 @@ 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)
|
||||
@@ -652,12 +592,9 @@ 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)
|
||||
@@ -669,8 +606,7 @@ public class Coord {
|
||||
/**
|
||||
* Offset by vector in place
|
||||
*
|
||||
* @param vec
|
||||
* offset
|
||||
* @param vec offset
|
||||
* @return this
|
||||
*/
|
||||
public Coord sub_ip(Coord vec)
|
||||
@@ -682,10 +618,8 @@ 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)
|
||||
@@ -697,12 +631,9 @@ 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)
|
||||
@@ -717,8 +648,7 @@ 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)
|
||||
@@ -784,10 +714,8 @@ 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)
|
||||
@@ -799,10 +727,8 @@ 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)
|
||||
@@ -814,8 +740,7 @@ 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)
|
||||
@@ -827,8 +752,7 @@ 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)
|
||||
@@ -847,8 +771,7 @@ public class Coord {
|
||||
/**
|
||||
* Get dot product
|
||||
*
|
||||
* @param vec
|
||||
* other vector
|
||||
* @param vec other vector
|
||||
* @return dot product
|
||||
*/
|
||||
public double dot(Coord vec)
|
||||
@@ -883,8 +806,7 @@ 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)
|
||||
@@ -897,8 +819,7 @@ 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)
|
||||
@@ -994,8 +915,7 @@ 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)
|
||||
@@ -1013,10 +933,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
import mightypork.utils.time.Updateable;
|
||||
|
||||
@@ -20,8 +21,7 @@ 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,8 +52,7 @@ public class CoordAnimated extends Coord implements Updateable {
|
||||
/**
|
||||
* Start animation
|
||||
*
|
||||
* @param time
|
||||
* anim length
|
||||
* @param time anim length
|
||||
*/
|
||||
public void animStart(double time)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math.coord;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -19,10 +20,8 @@ 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)
|
||||
@@ -34,12 +33,9 @@ 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)
|
||||
@@ -51,12 +47,9 @@ 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)
|
||||
@@ -68,14 +61,10 @@ 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)
|
||||
@@ -101,8 +90,7 @@ 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);
|
||||
@@ -112,10 +100,8 @@ 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);
|
||||
@@ -125,14 +111,10 @@ 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);
|
||||
@@ -142,10 +124,8 @@ 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);
|
||||
@@ -155,8 +135,7 @@ 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);
|
||||
@@ -166,8 +145,7 @@ public class Rect {
|
||||
/**
|
||||
* Get offset copy (add)
|
||||
*
|
||||
* @param move
|
||||
* offset vector
|
||||
* @param move offset vector
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect add(Coord move)
|
||||
@@ -179,10 +157,8 @@ 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)
|
||||
@@ -194,8 +170,7 @@ public class Rect {
|
||||
/**
|
||||
* Offset in place (add)
|
||||
*
|
||||
* @param move
|
||||
* offset vector
|
||||
* @param move offset vector
|
||||
* @return this
|
||||
*/
|
||||
public Rect add_ip(Coord move)
|
||||
@@ -209,10 +184,8 @@ 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)
|
||||
@@ -429,8 +402,7 @@ 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)
|
||||
@@ -442,10 +414,8 @@ 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)
|
||||
@@ -457,8 +427,7 @@ 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)
|
||||
@@ -472,10 +441,8 @@ 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)
|
||||
@@ -489,8 +456,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow down in copy
|
||||
*
|
||||
* @param down
|
||||
* added pixels
|
||||
* @param down added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growDown(double down)
|
||||
@@ -502,8 +468,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow down in place
|
||||
*
|
||||
* @param down
|
||||
* added pixels
|
||||
* @param down added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growDown_ip(double down)
|
||||
@@ -516,8 +481,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow to left in copy
|
||||
*
|
||||
* @param left
|
||||
* added pixels
|
||||
* @param left added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growLeft(double left)
|
||||
@@ -529,8 +493,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow to left in place
|
||||
*
|
||||
* @param left
|
||||
* added pixels
|
||||
* @param left added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growLeft_ip(double left)
|
||||
@@ -543,8 +506,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow to right in copy
|
||||
*
|
||||
* @param right
|
||||
* added pixels
|
||||
* @param right added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growRight(double right)
|
||||
@@ -556,8 +518,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow to right in place
|
||||
*
|
||||
* @param right
|
||||
* added pixels
|
||||
* @param right added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growRight_ip(double right)
|
||||
@@ -570,8 +531,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow up in copy
|
||||
*
|
||||
* @param add
|
||||
* added pixels
|
||||
* @param add added pixels
|
||||
* @return grown copy
|
||||
*/
|
||||
public Rect growUp(double add)
|
||||
@@ -583,8 +543,7 @@ public class Rect {
|
||||
/**
|
||||
* Grow up in place
|
||||
*
|
||||
* @param add
|
||||
* added pixels
|
||||
* @param add added pixels
|
||||
* @return this
|
||||
*/
|
||||
public Rect growUp_ip(double add)
|
||||
@@ -597,8 +556,7 @@ 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)
|
||||
@@ -610,8 +568,7 @@ public class Rect {
|
||||
/**
|
||||
* Multiply in copy
|
||||
*
|
||||
* @param factor
|
||||
* multiplier
|
||||
* @param factor multiplier
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect mul(double factor)
|
||||
@@ -623,10 +580,8 @@ 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)
|
||||
@@ -638,8 +593,7 @@ public class Rect {
|
||||
/**
|
||||
* Multiply coord in place
|
||||
*
|
||||
* @param factor
|
||||
* multiplier
|
||||
* @param factor multiplier
|
||||
* @return this
|
||||
*/
|
||||
public Rect mul_ip(double factor)
|
||||
@@ -653,10 +607,8 @@ 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)
|
||||
@@ -694,8 +646,7 @@ public class Rect {
|
||||
/**
|
||||
* Set to [0,0,coord.x,coord.y]
|
||||
*
|
||||
* @param coord
|
||||
* size coord
|
||||
* @param coord size coord
|
||||
*/
|
||||
public void setTo(Coord coord)
|
||||
{
|
||||
@@ -706,14 +657,10 @@ 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)
|
||||
{
|
||||
@@ -727,8 +674,7 @@ public class Rect {
|
||||
/**
|
||||
* Set to other rect's coordinates
|
||||
*
|
||||
* @param r
|
||||
* other rect
|
||||
* @param r other rect
|
||||
*/
|
||||
public void setTo(Rect r)
|
||||
{
|
||||
@@ -740,10 +686,8 @@ 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)
|
||||
@@ -755,8 +699,7 @@ public class Rect {
|
||||
/**
|
||||
* Get offset copy (subtract)
|
||||
*
|
||||
* @param move
|
||||
* offset vector
|
||||
* @param move offset vector
|
||||
* @return offset copy
|
||||
*/
|
||||
public Rect sub(Coord move)
|
||||
@@ -768,10 +711,8 @@ 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)
|
||||
@@ -783,8 +724,7 @@ public class Rect {
|
||||
/**
|
||||
* Offset in place (subtract)
|
||||
*
|
||||
* @param move
|
||||
* offset vector
|
||||
* @param move offset vector
|
||||
* @return this
|
||||
*/
|
||||
public Rect sub_ip(Coord move)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.math.easing;
|
||||
|
||||
|
||||
/**
|
||||
* EasingFunction function.
|
||||
*
|
||||
@@ -10,8 +11,7 @@ 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,8 +20,7 @@ public abstract class Easing {
|
||||
/**
|
||||
* Reverse an easing
|
||||
*
|
||||
* @param original
|
||||
* original easing
|
||||
* @param original original easing
|
||||
* @return reversed easing
|
||||
*/
|
||||
public static Easing reverse(Easing original)
|
||||
@@ -33,10 +32,8 @@ 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)
|
||||
@@ -48,8 +45,7 @@ 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)
|
||||
@@ -57,7 +53,6 @@ public abstract class Easing {
|
||||
return combine(in, reverse(in));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse EasingFunction
|
||||
*
|
||||
@@ -69,8 +64,7 @@ public abstract class Easing {
|
||||
|
||||
|
||||
/**
|
||||
* @param in
|
||||
* Easing to reverse
|
||||
* @param in Easing to reverse
|
||||
*/
|
||||
public Reverse(Easing in) {
|
||||
this.ea = in;
|
||||
@@ -84,7 +78,6 @@ public abstract class Easing {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Composite EasingFunction (0-0.5 EasingFunction A, 0.5-1 EasingFunction B)
|
||||
*
|
||||
@@ -99,10 +92,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.Range;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
@@ -16,10 +17,8 @@ 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)
|
||||
@@ -30,8 +29,7 @@ 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;
|
||||
}
|
||||
@@ -40,10 +38,8 @@ 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)
|
||||
@@ -54,8 +50,7 @@ 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;
|
||||
}
|
||||
@@ -64,10 +59,8 @@ 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)
|
||||
@@ -75,8 +68,7 @@ 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;
|
||||
}
|
||||
@@ -85,10 +77,8 @@ 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)
|
||||
@@ -102,8 +92,7 @@ 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;
|
||||
@@ -126,10 +115,8 @@ 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)
|
||||
@@ -145,10 +132,8 @@ 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)
|
||||
@@ -179,10 +164,8 @@ 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)
|
||||
@@ -207,8 +190,7 @@ 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;
|
||||
}
|
||||
@@ -217,8 +199,7 @@ public class Convertor {
|
||||
/**
|
||||
* Get INTEGER
|
||||
*
|
||||
* @param o
|
||||
* object
|
||||
* @param o object
|
||||
* @return integer
|
||||
*/
|
||||
public static int getInteger(Object o)
|
||||
@@ -230,8 +211,7 @@ public class Convertor {
|
||||
/**
|
||||
* Get DOUBLE
|
||||
*
|
||||
* @param o
|
||||
* object
|
||||
* @param o object
|
||||
* @return double
|
||||
*/
|
||||
public static double getDouble(Object o)
|
||||
@@ -243,8 +223,7 @@ public class Convertor {
|
||||
/**
|
||||
* Get FLOAT
|
||||
*
|
||||
* @param o
|
||||
* object
|
||||
* @param o object
|
||||
* @return float
|
||||
*/
|
||||
public static double getFloat(Object o)
|
||||
@@ -256,8 +235,7 @@ public class Convertor {
|
||||
/**
|
||||
* Get BOOLEAN
|
||||
*
|
||||
* @param o
|
||||
* object
|
||||
* @param o object
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean getBoolean(Object o)
|
||||
@@ -269,8 +247,7 @@ public class Convertor {
|
||||
/**
|
||||
* Get STRING
|
||||
*
|
||||
* @param o
|
||||
* object
|
||||
* @param o object
|
||||
* @return String
|
||||
*/
|
||||
public static String getString(Object o)
|
||||
@@ -283,8 +260,7 @@ 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)
|
||||
@@ -296,8 +272,7 @@ 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,8 +16,7 @@ public class Mutable<T> {
|
||||
/**
|
||||
* New mutable object
|
||||
*
|
||||
* @param o
|
||||
* value
|
||||
* @param o value
|
||||
*/
|
||||
public Mutable(T o) {
|
||||
this.o = o;
|
||||
@@ -38,8 +37,7 @@ public class Mutable<T> {
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param o
|
||||
* new value to set
|
||||
* @param o new value to set
|
||||
*/
|
||||
public void set(T o)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -23,10 +24,8 @@ 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" })
|
||||
@@ -54,10 +53,8 @@ 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")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -8,10 +9,8 @@ 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> {
|
||||
|
||||
@@ -29,10 +28,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
|
||||
|
||||
@@ -8,12 +9,9 @@ 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> {
|
||||
|
||||
@@ -26,12 +24,9 @@ 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);
|
||||
@@ -51,8 +46,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.objects;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,28 +21,24 @@ import java.util.Map;
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Object[] array = { "one", 1, "two", 4, "three", 9, "four", 16 };
|
||||
* Map<String, Integer> args = new VarargsParser<String, Integer>().parse(array);
|
||||
* </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,5 +1,6 @@
|
||||
package mightypork.utils.patterns;
|
||||
|
||||
|
||||
/**
|
||||
* Object that can be destroyed (free resources etc)
|
||||
*
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
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,5 +1,6 @@
|
||||
package mightypork.utils.patterns.subscription;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
@@ -24,8 +25,7 @@ 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,8 +47,7 @@ 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)
|
||||
{
|
||||
@@ -59,8 +58,7 @@ 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)
|
||||
@@ -81,8 +79,7 @@ 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)
|
||||
@@ -98,8 +95,7 @@ final public class MessageBus {
|
||||
/**
|
||||
* Disconnect a client from the bus.
|
||||
*
|
||||
* @param client
|
||||
* the client
|
||||
* @param client the client
|
||||
*/
|
||||
public void unsubscribe(Object client)
|
||||
{
|
||||
@@ -121,10 +117,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.patterns.subscription;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -12,10 +13,8 @@ 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> {
|
||||
|
||||
@@ -36,10 +35,8 @@ 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)
|
||||
@@ -86,10 +83,8 @@ 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)
|
||||
@@ -104,8 +99,7 @@ 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)
|
||||
@@ -152,10 +146,8 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.patterns.subscription.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.patterns.subscription.clients;
|
||||
|
||||
|
||||
/**
|
||||
* Client that can toggle receiving messages.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.string;
|
||||
|
||||
|
||||
/**
|
||||
* General purpose string utilities
|
||||
*
|
||||
@@ -10,12 +11,9 @@ 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)
|
||||
@@ -63,8 +61,7 @@ public class StringUtils {
|
||||
/**
|
||||
* Repeat a string
|
||||
*
|
||||
* @param repeated
|
||||
* string
|
||||
* @param repeated string
|
||||
* @param count
|
||||
* @return output
|
||||
*/
|
||||
@@ -80,8 +77,7 @@ 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)
|
||||
@@ -93,10 +89,8 @@ 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)
|
||||
@@ -108,8 +102,7 @@ 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)
|
||||
@@ -126,8 +119,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public interface CharValidator {
|
||||
|
||||
public boolean isValid(char c);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class CharValidatorRegex implements CharValidator {
|
||||
|
||||
private String formula;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class CharValidatorWhitelist implements CharValidator {
|
||||
|
||||
private String whitelist;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
@@ -18,8 +19,7 @@ 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,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
public class FilenameCharValidator extends CharValidatorRegex {
|
||||
|
||||
public FilenameCharValidator() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.string.validation;
|
||||
|
||||
|
||||
/**
|
||||
* Utility interface for string filters (accepting filepaths and similar)
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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.
|
||||
@@ -43,8 +44,7 @@ public class FpsMeter {
|
||||
/**
|
||||
* Notification that some frames have been dropped
|
||||
*
|
||||
* @param dropped
|
||||
* dropped frames
|
||||
* @param dropped dropped frames
|
||||
*/
|
||||
public void drop(int dropped)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
public interface Pauseable {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
/**
|
||||
* Timer for delta timing
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.utils.time;
|
||||
|
||||
|
||||
/**
|
||||
* Timer for interpolated timing
|
||||
*
|
||||
@@ -19,8 +20,7 @@ public class TimerInterpolating {
|
||||
/**
|
||||
* New interpolated timer
|
||||
*
|
||||
* @param fps
|
||||
* target FPS
|
||||
* @param fps target FPS
|
||||
*/
|
||||
public TimerInterpolating(long fps) {
|
||||
FRAME = Math.round(SECOND / fps);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user