diff --git a/src/com/bwyap/engine/Engine.java b/src/com/bwyap/engine/Engine.java index e93f35f..0c05080 100644 --- a/src/com/bwyap/engine/Engine.java +++ b/src/com/bwyap/engine/Engine.java @@ -2,35 +2,29 @@ import com.bwyap.engine.window.WindowInterface; -/** - * An abstract Engine that holds a {@code WindowInterface}. +/** An abstract Engine that holds a {@code WindowInterface}. * This class should be extended to implement the main engine - * loop which calls the {@code update} and {@code render} + * loop which calls the {@code update} and {@code render} * methods. - * @author bwyap - * - */ -public abstract class Engine implements EngineInterface { - + * + * @author bwyap */ +public abstract class Engine implements EngineInterface +{ protected final WindowInterface window; - protected int targetFPS; protected float fps; - - - public Engine(WindowInterface window, int targetFPS) throws Exception { + + public Engine(WindowInterface window, int targetFPS) throws Exception + { this.window = window; this.targetFPS = targetFPS; } - + @Override - public float getFPS() { - return fps; - } - + public float getFPS() + { return fps; } + @Override - public int getTargetFPS() { - return targetFPS; - } - + public int getTargetFPS() + { return targetFPS; } } diff --git a/src/com/bwyap/engine/EngineInterface.java b/src/com/bwyap/engine/EngineInterface.java index 7575426..63adfee 100644 --- a/src/com/bwyap/engine/EngineInterface.java +++ b/src/com/bwyap/engine/EngineInterface.java @@ -1,55 +1,41 @@ package com.bwyap.engine; -/** - * Specifies the methods that an engine requires. - * @author bwyap - * - */ -public interface EngineInterface { - - /** - * Run the game engine loop. - */ +/** Specifies the methods that an engine requires. + * + * @author bwyap */ +public interface EngineInterface +{ + /** Run the game engine loop. */ public void run(); - - /** - * Initialise the engine and prepare resources for rendering - */ + + /** Initialise the engine and prepare resources for rendering */ public void init(); - - /** - * Get the current system time - * @return - */ + + /** Get the current system time + * + * @return */ public float getCurrentTime(); - - /** - * Update the application - * @param timestep - */ + + /** Update the application + * + * @param timestep */ public void update(float timestep); - - /** - * Render the graphics of the application - * @param timestep - */ + + /** Render the graphics of the application + * + * @param timestep */ public void render(float timestep); - - /** - * Frees resources that are no longer needed. - */ + + /** Frees resources that are no longer needed. */ public void cleanup(); - - /** - * Get the last measured FPS of the engine. - * @return - */ + + /** Get the last measured FPS of the engine. + * + * @return */ public float getFPS(); - - /** - * Gets the target FPS of the game. - * @return - */ + + /** Gets the target FPS of the game. + * + * @return */ public int getTargetFPS(); - } diff --git a/src/com/bwyap/engine/FixedTimestepEngine.java b/src/com/bwyap/engine/FixedTimestepEngine.java index 7dc5b77..9bd36e5 100644 --- a/src/com/bwyap/engine/FixedTimestepEngine.java +++ b/src/com/bwyap/engine/FixedTimestepEngine.java @@ -2,64 +2,51 @@ import com.bwyap.engine.window.WindowInterface; -/** - * An Engine implementation which uses a fixed time loop. - * This class should be extended to provide implementations +/** An Engine implementation which uses a fixed time loop. + * This class should be extended to provide implementations * for the {@code update} and {@code render} methods. - * @author bwyap - * - */ -public abstract class FixedTimestepEngine extends Engine { - + * + * @author bwyap */ +public abstract class FixedTimestepEngine extends Engine +{ + public FixedTimestepEngine(WindowInterface window, int targetFPS) throws Exception + { super(window, targetFPS); } - public FixedTimestepEngine(WindowInterface window, int targetFPS) throws Exception { - super(window, targetFPS); - } - - - /** - * Run the engine loop using a fixed timestep. - * This method should not be altered. - */ + /** Run the engine loop using a fixed timestep. + * This method should not be altered. */ @Override - public final void run() { + public final void run() + { float now, delta; - float last = 0f, fpsTimer = 0f, secsPerUpdate = 1f/targetFPS; + float last = 0f, fpsTimer = 0f, secsPerUpdate = 1f / targetFPS; int fps = 0; - init(); - - while (!window.shouldClose()) { + while (!window.shouldClose()) + { now = this.getCurrentTime(); delta = now - last; last = now; - window.processEvents(); update(delta); render(delta); window.swapDisplayBuffers(); - fps++; fpsTimer += delta; - - window.setFpsDisplay(fps/fpsTimer); - - if (fpsTimer >= 1.0f) { + window.setFpsDisplay(fps / fpsTimer); + if (fpsTimer >= 1.0f) + { this.fps = fps; fpsTimer -= 1.0f; fps = 0; } - - while ((float) this.getCurrentTime() < now + secsPerUpdate) { + while ((float) this.getCurrentTime() < now + secsPerUpdate) + { // wait } } - cleanup(); } } - - // Old method /* public final void run() { diff --git a/src/com/bwyap/engine/gui/GUI.java b/src/com/bwyap/engine/gui/GUI.java index e44c4e9..f0a80d1 100644 --- a/src/com/bwyap/engine/gui/GUI.java +++ b/src/com/bwyap/engine/gui/GUI.java @@ -3,25 +3,22 @@ import com.bwyap.engine.gui.element.RectangularPanel; import com.bwyap.engine.input.InputHandler; -/** - * A GUI Panel which is intended to span the whole screen. +/** A GUI Panel which is intended to span the whole screen. * Its origin is always at (0,0). - * @author bwyap - * - */ -public abstract class GUI extends RectangularPanel implements GUIInterface { - - public GUI(float width, float height) { + * + * @author bwyap */ +public abstract class GUI extends RectangularPanel implements GUIInterface +{ + public GUI(float width, float height) + { super(0, 0, width, height); setRenderShape(false); } - - + @Override - public final void handleInput(InputHandler input) { + public final void handleInput(InputHandler input) + { // Handle input with this panel as the bounds super.handleInput(input, this); } - - } diff --git a/src/com/bwyap/engine/gui/GUIController.java b/src/com/bwyap/engine/gui/GUIController.java index 9cb9011..bfe9863 100644 --- a/src/com/bwyap/engine/gui/GUIController.java +++ b/src/com/bwyap/engine/gui/GUIController.java @@ -3,52 +3,36 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.engine.window.WindowInterface; - -/** - * A controller class that can render a GUI. +/** A controller class that can render a GUI. * It uses a {@code GUIRenderer} to render * the current GUI which must be set. If the * currentGUI is {@code null}, nothing will * be rendered by the renderer. - * @author bwyap - * - */ -public abstract class GUIController implements GUIControllerInterface { - - + * + * @author bwyap */ +public abstract class GUIController implements GUIControllerInterface +{ protected GUI currentGUI; protected final GUIRenderer renderer; - - - public GUIController(GUIRenderer renderer) { - this.renderer = renderer; - } - - - /** - * Set the GUI to update and render - * @param gui - */ - public void setGUI(GUI gui) { - this.currentGUI = gui; - } - - + + public GUIController(GUIRenderer renderer) + { this.renderer = renderer; } + + /** Set the GUI to update and render + * + * @param gui */ + public void setGUI(GUI gui) + { this.currentGUI = gui; } + @Override - public final void handleInput(InputHandler input) { - if (currentGUI != null) currentGUI.handleInput(input); - } + public final void handleInput(InputHandler input) + { if (currentGUI != null) currentGUI.handleInput(input); } - @Override - public final void update(float timestep) { - if (currentGUI != null) currentGUI.update(timestep); - } - + public final void update(float timestep) + { if (currentGUI != null) currentGUI.update(timestep); } @Override - public final void render(WindowInterface window) { - if (currentGUI != null) renderer.render(currentGUI, window); - } - + public final void render(WindowInterface window) + { if (currentGUI != null) renderer.render(currentGUI, window); } } diff --git a/src/com/bwyap/engine/gui/GUIControllerInterface.java b/src/com/bwyap/engine/gui/GUIControllerInterface.java index 8d4ce85..e00552d 100644 --- a/src/com/bwyap/engine/gui/GUIControllerInterface.java +++ b/src/com/bwyap/engine/gui/GUIControllerInterface.java @@ -3,31 +3,23 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.engine.window.WindowInterface; -/** - * Provides methods that a GUI controller should implement. - * @author bwyap - * - */ -public interface GUIControllerInterface { - - /** - * Polls input for the current GUI - * @param input - */ +/** Provides methods that a GUI controller should implement. + * + * @author bwyap */ +public interface GUIControllerInterface +{ + /** Polls input for the current GUI + * + * @param input */ public void handleInput(InputHandler input); - - - /** - * Updates the current GUI - * @param timestep - */ + + /** Updates the current GUI + * + * @param timestep */ public void update(float timestep); - - - /** - * Renders the current GUI - * @param window - */ + + /** Renders the current GUI + * + * @param window */ public void render(WindowInterface window); - } diff --git a/src/com/bwyap/engine/gui/GUIInterface.java b/src/com/bwyap/engine/gui/GUIInterface.java index 5cf7643..a2a9eb6 100644 --- a/src/com/bwyap/engine/gui/GUIInterface.java +++ b/src/com/bwyap/engine/gui/GUIInterface.java @@ -3,43 +3,32 @@ import com.bwyap.engine.gui.interfaces.GUIElementInterface; import com.bwyap.engine.input.InputHandler; -/** - * An interface for a GUI that can hold GUI elements. - * @author bwyap - * - */ -public interface GUIInterface { - - - /** - * Update elements in the GUI - * @param timestep - */ +/** An interface for a GUI that can hold GUI elements. + * + * @author bwyap */ +public interface GUIInterface +{ + /** Update elements in the GUI + * + * @param timestep */ public void update(float timestep); - - - /** - * Poll input for the elements in the GUI + + /** Poll input for the elements in the GUI + * * @param input - * @param timetep - */ + * @param timetep */ public void handleInput(InputHandler input); - - - /** - * Add a new element to the GUI - * @param element - */ + + /** Add a new element to the GUI + * + * @param element */ public void addElement(GUIElementInterface e, float x, float y); - - - /** - * Remove an element from the GUI. - * Returns true if the element was + + /** Remove an element from the GUI. + * Returns true if the element was * found and was successfully removed. - * @param element - * @return - */ + * + * @param element + * @return */ public boolean removeElement(GUIElementInterface e); - } diff --git a/src/com/bwyap/engine/gui/GUIRenderer.java b/src/com/bwyap/engine/gui/GUIRenderer.java index a2fd39e..94be53e 100644 --- a/src/com/bwyap/engine/gui/GUIRenderer.java +++ b/src/com/bwyap/engine/gui/GUIRenderer.java @@ -9,8 +9,7 @@ import com.bwyap.engine.gui.interfaces.IColouredVectorShape; import com.bwyap.engine.window.WindowInterface; -/** - *
+/**
* A renderer that can render GUI elements to the screen. * The concrete implementation of how the elements should be * rendered is library specific and must be provided in a @@ -19,113 +18,87 @@ *
* Supported GUI elements: *
Render the GUI elements.
+ + /**Render the GUI elements.
** Calls to draw all GUI elements should be made in this method. * This method is called automatically. *
+ * * @param gui - * @param window - */ + * @param window */ protected abstract void renderGUI(Panel panel, WindowInterface window); - - - /** - * CLean up the resources after rendering the GUI - */ + + /** CLean up the resources after rendering the GUI */ protected abstract void endRenderGUI(); - - /* =================== * AUXILIARY METHODS * =================== */ - - - /** - * Render text onto the screen. If the given font has not yet been loaded, it will be loaded + /** Render text onto the screen. If the given font has not yet been loaded, it will be loaded * via the {@code NVGFont.acquireFont} method. This method should handle cases where the text * is null appropriately. - * @param text the text component - * @param element the bounds the text component is attached to - */ + * + * @param text the text component + * @param element the bounds the text component is attached to */ public abstract void renderText(TextComponent text, GUIBoundsInterface element); - - - /** - * Render a vector drawn button - * @param button - */ + + /** Render a vector drawn button + * + * @param button */ protected abstract void renderVectorButton(VectorButton button); - - - /** - * Render a textured button - * @param button - */ + + /** Render a textured button + * + * @param button */ protected abstract void renderTexturedButton(TexturedButton button); - - - /** - * Render a vector drawn radio button - * @param radio - */ + + /** Render a vector drawn radio button + * + * @param radio */ protected abstract void renderVectorRadioButton(VectorRadioButton radio); - - - /** - * Render a coloured vector shape to the screen + + /** Render a coloured vector shape to the screen + * * @param shape - * @param e - */ + * @param e */ protected abstract void renderColouredVectorShape(IColouredVectorShape shape, GUIBoundsInterface e, float offsetX, float offsetY); - - } diff --git a/src/com/bwyap/engine/gui/GUIRendererInterface.java b/src/com/bwyap/engine/gui/GUIRendererInterface.java index 1dbb656..1af15c0 100644 --- a/src/com/bwyap/engine/gui/GUIRendererInterface.java +++ b/src/com/bwyap/engine/gui/GUIRendererInterface.java @@ -14,24 +14,18 @@ import com.bwyap.engine.gui.element.vector.VectorTextField; import com.bwyap.engine.window.WindowInterface; - -/** - * An interface for methods that a GUI renderer should provide. - * @author bwyap - * - */ -public interface GUIRendererInterface { - - - /** - * Renders the GUI on the window. +/** An interface for methods that a GUI renderer should provide. + * + * @author bwyap */ +public interface GUIRendererInterface +{ + /** Renders the GUI on the window. * This step should be done after other elements are rendered. * All preparation for GUI rendering should be handled by the GUI system. - * @param window - */ + * + * @param window */ public void render(GUI gui, WindowInterface window); - /* * ================= * RENDERING METHODS @@ -39,78 +33,57 @@ public interface GUIRendererInterface { * The following methods must be implemented to be able * to render the provided GUI elements in this library. */ - - - /** - * Render a panel and the elements contained within it - * @param panel the panel to render + /** Render a panel and the elements contained within it + * + * @param panel the panel to render * @param window the bounding window - * @param parent the parent of the panel - */ + * @param parent the parent of the panel */ public void renderPanel(Panel panel, WindowInterface window, Vector2f parent); - - - /** - * Render a scroll area and the elements contained within it + + /** Render a scroll area and the elements contained within it + * * @param scrollArea - * @param window - */ + * @param window */ public void renderVectorScrollArea(VectorScrollArea scrollArea, WindowInterface window); - - - /** - * Render a label - * @param label - */ + + /** Render a label + * + * @param label */ public void renderLabel(Label label); - - - /** - * Render a text field - * @param textfield - */ + + /** Render a text field + * + * @param textfield */ public void renderVectorTextField(VectorTextField textfield); - - /** - * Render a text box - * @param textBox - */ + /** Render a text box + * + * @param textBox */ public void renderVectorTextBox(VectorTextBox textBox); - - - /** - * Render a button - * @param button - */ + + /** Render a button + * + * @param button */ public void renderButton(Button button); - - - /** - * Render a check box - * @param checkbox - */ + + /** Render a check box + * + * @param checkbox */ public void renderVectorCheckBox(VectorCheckBox checkbox); - - - /** - * Render a radio button group + + /** Render a radio button group + * * @param group - * @param parentPanel - */ + * @param parentPanel */ public void renderRadioButtonGroup(RadioButtonGroup group, Panel parentPanel); - - - /** - * Render a progress bar - * @param progressBar - */ + + /** Render a progress bar + * + * @param progressBar */ public void renderVectorProgressBar(VectorProgressBar progressBar); - - - /** - * Render an image - * @param holder - */ + + /** Render an image + * + * @param holder */ public void renderImage(ImageHolder holder); } diff --git a/src/com/bwyap/engine/gui/element/CircularRadioButton.java b/src/com/bwyap/engine/gui/element/CircularRadioButton.java index 04494ea..5cb361b 100644 --- a/src/com/bwyap/engine/gui/element/CircularRadioButton.java +++ b/src/com/bwyap/engine/gui/element/CircularRadioButton.java @@ -4,84 +4,64 @@ import com.bwyap.engine.gui.element.vector.VectorRadioButton; import com.bwyap.engine.gui.interfaces.IVectorEllipse; - -/** - * A circular radio button. +/** A circular radio button. * See {@link RadioButton}. - * @author bwyap - * - */ -public class CircularRadioButton extends VectorRadioButton implements IVectorEllipse{ + * + * @author bwyap */ +public class CircularRadioButton extends VectorRadioButton implements IVectorEllipse +{ + public CircularRadioButton(String name, float x, float y, float radius) + { super(name, x, y, radius, radius); } - - public CircularRadioButton(String name, float x, float y, float radius) { - super(name, x, y, radius, radius); - } - - - public CircularRadioButton(float x, float y, float radius) { - super(x, y, radius, radius); - } - - - /** - * Set the radius and positional offset of the elliptical bounds. - * @param x offset - * @param y offset + public CircularRadioButton(float x, float y, float radius) + { super(x, y, radius, radius); } + + /** Set the radius and positional offset of the elliptical bounds. + * + * @param x offset + * @param y offset * @param rx semi-major radius - * @param ry semi-major radius - */ + * @param ry semi-major radius */ @Override - public void setBounds(float xOffset, float yOffset, float rx, float ry) { - super.setBounds(xOffset, yOffset, rx, ry); - } - - - /** - * Set the radius of the elliptical bounds. + public void setBounds(float xOffset, float yOffset, float rx, float ry) + { super.setBounds(xOffset, yOffset, rx, ry); } + + /** Set the radius of the elliptical bounds. * The offset of the bounding ellipse is set * to (0, 0). + * * @param rx semi-major radius - * @param ry semi-major radius - */ + * @param ry semi-major radius */ @Override - public void setBounds(float rx, float ry) { - super.setBounds(rx, ry); - } - + public void setBounds(float rx, float ry) + { super.setBounds(rx, ry); } - /** - * Set the radius of the circular bounds. + /** Set the radius of the circular bounds. * The offset of the bounding circle is set * to (0, 0). - * @param r radius for semi-major and semi-minor axes - */ - public void setBoundsRadius(float r) { - setBounds(0, 0, r, r); - } - - + * + * @param r radius for semi-major and semi-minor axes */ + public void setBoundsRadius(float r) + { setBounds(0, 0, r, r); } + @Override - public boolean withinBounds(float x, float y) { + public boolean withinBounds(float x, float y) + { /* * Formula: * (x-h)^2/(rx)^2 + (y-k)^2/(ry)^2 <= 1 */ - float xtop = (float)Math.pow(x - (position.x + bounds.x + boundsOffset.x), 2); - float xbot = (float)Math.pow(bounds.x, 2); - float ytop = (float)Math.pow(y - (position.y + bounds.y + boundsOffset.y), 2); - float ybot = (float)Math.pow(bounds.y, 2); - - return (xtop/xbot) + (ytop/ybot) <= 1.0f; + float xtop = (float) Math.pow(x - (position.x + bounds.x + boundsOffset.x), 2); + float xbot = (float) Math.pow(bounds.x, 2); + float ytop = (float) Math.pow(y - (position.y + bounds.y + boundsOffset.y), 2); + float ybot = (float) Math.pow(bounds.y, 2); + return (xtop / xbot) + (ytop / ybot) <= 1.0f; } - - - /** - * {@inheritDoc} + + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void update(float timestep) { } - + * */ + public void update(float timestep) + {} } diff --git a/src/com/bwyap/engine/gui/element/EllipticalButton.java b/src/com/bwyap/engine/gui/element/EllipticalButton.java index b70cfaf..4d4707c 100644 --- a/src/com/bwyap/engine/gui/element/EllipticalButton.java +++ b/src/com/bwyap/engine/gui/element/EllipticalButton.java @@ -3,76 +3,60 @@ import com.bwyap.engine.gui.element.vector.VectorButton; import com.bwyap.engine.gui.interfaces.IVectorEllipse; -/** - * An elliptical button that is drawn by the graphics rendering system. +/** An elliptical button that is drawn by the graphics rendering system. * See {@link Button}. - * @author bwyap - * - */ -public abstract class EllipticalButton extends VectorButton implements IVectorEllipse { - - - public EllipticalButton(float x, float y, float xr, float yr) { - super(x, y, xr, yr); - - } - + * + * @author bwyap */ +public abstract class EllipticalButton extends VectorButton implements IVectorEllipse +{ + public EllipticalButton(float x, float y, float xr, float yr) + { super(x, y, xr, yr); } - /** - * Set the radius and positional offset of the elliptical bounds. - * @param x offset - * @param y offset + /** Set the radius and positional offset of the elliptical bounds. + * + * @param x offset + * @param y offset * @param rx semi-major radius - * @param ry semi-major radius - */ + * @param ry semi-major radius */ @Override - public void setBounds(float xOffset, float yOffset, float rx, float ry) { - super.setBounds(xOffset, yOffset, rx, ry); - } - - - /** - * Set the radius of the elliptical bounds. + public void setBounds(float xOffset, float yOffset, float rx, float ry) + { super.setBounds(xOffset, yOffset, rx, ry); } + + /** Set the radius of the elliptical bounds. * The offset of the bounding ellipse is set * to (0, 0). + * * @param rx semi-major radius - * @param ry semi-major radius - */ + * @param ry semi-major radius */ @Override - public void setBounds(float rx, float ry) { - super.setBounds(0, 0, rx, ry); - } - + public void setBounds(float rx, float ry) + { super.setBounds(0, 0, rx, ry); } - /** - * Set the radius of the circular bounds. + /** Set the radius of the circular bounds. * The offset of the bounding circle is set * to (0, 0). - * @param r radius for semi-major and semi-minor axes - */ - public void setBoundsRadius(float r) { - super.setBounds(0, 0, r, r); - } - - + * + * @param r radius for semi-major and semi-minor axes */ + public void setBoundsRadius(float r) + { super.setBounds(0, 0, r, r); } + @Override - public boolean withinBounds(float x, float y) { + public boolean withinBounds(float x, float y) + { /* * Formula: * (x-h)^2/(rx)^2 + (y-k)^2/(ry)^2 <= 1 */ - float xtop = (float)Math.pow(x - (position.x + bounds.x + boundsOffset.x), 2); - float xbot = (float)Math.pow(bounds.x, 2); - float ytop = (float)Math.pow(y - (position.y + bounds.y + boundsOffset.y), 2); - float ybot = (float)Math.pow(bounds.y, 2); - + float xtop = (float) Math.pow(x - (position.x + bounds.x + boundsOffset.x), 2); + float xbot = (float) Math.pow(bounds.x, 2); + float ytop = (float) Math.pow(y - (position.y + bounds.y + boundsOffset.y), 2); + float ybot = (float) Math.pow(bounds.y, 2); /* // circular bounds float xcenter = position.x + circularBoundsRadius; float ycenter = position.y + circularBoundsRadius; return Math.pow(x - xcenter, 2) + Math.pow(y - ycenter, 2) <= Math.pow(circularBoundsRadius, 2); */ - return (xtop/xbot) + (ytop/ybot) <= 1.0f; + return (xtop / xbot) + (ytop / ybot) <= 1.0f; } - } diff --git a/src/com/bwyap/engine/gui/element/Label.java b/src/com/bwyap/engine/gui/element/Label.java index 83aa23c..4203e80 100644 --- a/src/com/bwyap/engine/gui/element/Label.java +++ b/src/com/bwyap/engine/gui/element/Label.java @@ -9,21 +9,17 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.lwjgl.engine.resource.LWJGLResourceManager; - -/** - * An GUI element that displays text. NOTE: The bounds for this element +/** An GUI element that displays text. NOTE: The bounds for this element * are not used to describe the bounds of the text. If you need to detect * mouse interaction with the element, use a button instead. - * @author bwyap - * - */ -public class Label extends GUIElement implements GUIElementInterface, ITextDisplay { - - + * + * @author bwyap */ +public class Label extends GUIElement implements GUIElementInterface, ITextDisplay +{ private TextComponent text; - - - public Label(String string, float x, float y) { + + public Label(String string, float x, float y) + { super(x, y, 1, 1); text = new TextComponent(string); text.setClipText(false); @@ -32,19 +28,16 @@ public Label(String string, float x, float y) { // Set the font of the label text text.setFontName(LWJGLResourceManager.instance().lib.getFont("default")); } - - - @Override - public TextComponent getTextComponent() { - return text; - } - @Override - public void update(float timestep) { } - + public TextComponent getTextComponent() + { return text; } @Override - public void handleInput(InputHandler input, GUIBoundsInterface bounds) { } + public void update(float timestep) + {} + @Override + public void handleInput(InputHandler input, GUIBoundsInterface bounds) + {} } diff --git a/src/com/bwyap/engine/gui/element/RectangularButton.java b/src/com/bwyap/engine/gui/element/RectangularButton.java index 492dfc1..85a57a8 100644 --- a/src/com/bwyap/engine/gui/element/RectangularButton.java +++ b/src/com/bwyap/engine/gui/element/RectangularButton.java @@ -4,17 +4,12 @@ import com.bwyap.engine.gui.element.vector.VectorButton; import com.bwyap.engine.gui.interfaces.IVectorRect; -/** - * A rectangular button that is drawn by the graphics rendering system. +/** A rectangular button that is drawn by the graphics rendering system. * See {@link Button}. - * @author bwyap - * - */ -public abstract class RectangularButton extends VectorButton implements IVectorRect { - - - public RectangularButton(int x, int y, float width, float height) { - super(x, y, width, height); - } - + * + * @author bwyap */ +public abstract class RectangularButton extends VectorButton implements IVectorRect +{ + public RectangularButton(int x, int y, float width, float height) + { super(x, y, width, height); } } diff --git a/src/com/bwyap/engine/gui/element/RectangularCheckBox.java b/src/com/bwyap/engine/gui/element/RectangularCheckBox.java index 0a7d9e8..60308f3 100644 --- a/src/com/bwyap/engine/gui/element/RectangularCheckBox.java +++ b/src/com/bwyap/engine/gui/element/RectangularCheckBox.java @@ -4,30 +4,22 @@ import com.bwyap.engine.gui.element.vector.VectorCheckBox; import com.bwyap.engine.gui.interfaces.IVectorRect; -/** - * A rectangular check box. +/** A rectangular check box. * See {@link CheckBox}. - * @author bwyap - * - */ -public class RectangularCheckBox extends VectorCheckBox implements IVectorRect { + * + * @author bwyap */ +public class RectangularCheckBox extends VectorCheckBox implements IVectorRect +{ + public RectangularCheckBox(float x, float y, float width, CheckBoxCheckStyle style) + { super(x, y, width, width, style); } - public RectangularCheckBox(float x, float y, float width, CheckBoxCheckStyle style) { - super(x, y, width, width, style); - } - - - public RectangularCheckBox(float x, float y, float width) { - super(x, y, width, width); - } + public RectangularCheckBox(float x, float y, float width) + { super(x, y, width, width); } - - /** - * {@inheritDoc} + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void update(float timestep) { } - + * */ + public void update(float timestep) + {} } diff --git a/src/com/bwyap/engine/gui/element/RectangularPanel.java b/src/com/bwyap/engine/gui/element/RectangularPanel.java index 343f5a7..1d344a6 100644 --- a/src/com/bwyap/engine/gui/element/RectangularPanel.java +++ b/src/com/bwyap/engine/gui/element/RectangularPanel.java @@ -3,30 +3,20 @@ import com.bwyap.engine.gui.element.base.Panel; import com.bwyap.engine.gui.interfaces.IVectorRect; - -/** - * A rectangular panel. +/** A rectangular panel. * See {@link Panel}. - * @author bwyap - * - */ -public class RectangularPanel extends Panel implements IVectorRect { - + * + * @author bwyap */ +public class RectangularPanel extends Panel implements IVectorRect +{ + public RectangularPanel(float x, float y, float width, float height) + { super(x, y, width, height); } - public RectangularPanel(float x, float y, float width, float height) { - super(x, y, width, height); - } - - @Override - public float getWidth() { - return bounds.x; - } - - + public float getWidth() + { return bounds.x; } + @Override - public float getHeight() { - return bounds.y; - } - + public float getHeight() + { return bounds.y; } } diff --git a/src/com/bwyap/engine/gui/element/RectangularPanelWindow.java b/src/com/bwyap/engine/gui/element/RectangularPanelWindow.java index d8c91d8..4e3c5b8 100644 --- a/src/com/bwyap/engine/gui/element/RectangularPanelWindow.java +++ b/src/com/bwyap/engine/gui/element/RectangularPanelWindow.java @@ -3,16 +3,12 @@ import com.bwyap.engine.gui.element.base.PanelWindow; import com.bwyap.engine.gui.interfaces.IVectorRect; -/** - * A rectangular panel window. +/** A rectangular panel window. * See {@link PanelWindow}. - * @author bwyap - * - */ -public abstract class RectangularPanelWindow extends PanelWindow implements IVectorRect { - - public RectangularPanelWindow(String title, float x, float y, float width, float height) { - super(title, x, y, width, height); - } - + * + * @author bwyap */ +public abstract class RectangularPanelWindow extends PanelWindow implements IVectorRect +{ + public RectangularPanelWindow(String title, float x, float y, float width, float height) + { super(title, x, y, width, height); } } diff --git a/src/com/bwyap/engine/gui/element/RectangularScrollArea.java b/src/com/bwyap/engine/gui/element/RectangularScrollArea.java index 6ea9f7f..5246780 100644 --- a/src/com/bwyap/engine/gui/element/RectangularScrollArea.java +++ b/src/com/bwyap/engine/gui/element/RectangularScrollArea.java @@ -4,17 +4,12 @@ import com.bwyap.engine.gui.element.vector.VectorScrollArea; import com.bwyap.engine.gui.interfaces.IVectorRect; - -/** - * A rectangular scroll area. +/** A rectangular scroll area. * See {@link ScrollArea}. - * @author bwyap - * - */ -public class RectangularScrollArea extends VectorScrollArea implements IVectorRect { - - public RectangularScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection) { - super(x, y, width, height, scrollLength, scrollDirection); - } - + * + * @author bwyap */ +public class RectangularScrollArea extends VectorScrollArea implements IVectorRect +{ + public RectangularScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection) + { super(x, y, width, height, scrollLength, scrollDirection); } } diff --git a/src/com/bwyap/engine/gui/element/RectangularSolidProgressBar.java b/src/com/bwyap/engine/gui/element/RectangularSolidProgressBar.java index 3919e2d..e51ec4e 100644 --- a/src/com/bwyap/engine/gui/element/RectangularSolidProgressBar.java +++ b/src/com/bwyap/engine/gui/element/RectangularSolidProgressBar.java @@ -6,31 +6,24 @@ import com.bwyap.engine.gui.interfaces.IVectorRect; import com.bwyap.engine.input.InputHandler; +/** A rectangular progress bar filled with a solid colour. + * See {@link ProgressBar}. + * + * @author bwyap */ +public class RectangularSolidProgressBar extends SolidVectorProgressBar implements IVectorRect +{ + public RectangularSolidProgressBar(float x, float y, float width, float height) + { super(x, y, width, height); } -/** - * A rectangular progress bar filled with a solid colour. - * See {@link ProgressBar}. - * @author bwyap - * - */ -public class RectangularSolidProgressBar extends SolidVectorProgressBar implements IVectorRect { - - public RectangularSolidProgressBar(float x, float y, float width, float height) { - super(x, y, width, height); - } - - - /** - * {@inheritDoc} + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ + * */ @Override - public void update(float timestep) { } + public void update(float timestep) + {} - @Override - public void handleInput(InputHandler input, GUIBoundsInterface bounds) { } - + public void handleInput(InputHandler input, GUIBoundsInterface bounds) + {} } diff --git a/src/com/bwyap/engine/gui/element/RectangularTextBox.java b/src/com/bwyap/engine/gui/element/RectangularTextBox.java index 301ed67..596fe33 100644 --- a/src/com/bwyap/engine/gui/element/RectangularTextBox.java +++ b/src/com/bwyap/engine/gui/element/RectangularTextBox.java @@ -4,17 +4,12 @@ import com.bwyap.engine.gui.element.vector.VectorTextBox; import com.bwyap.engine.gui.interfaces.IVectorRect; - -/** - * A rectangular text box. +/** A rectangular text box. * See {@link TextBox}. - * @author bwyap - * - */ -public abstract class RectangularTextBox extends VectorTextBox implements IVectorRect { - - public RectangularTextBox(float x, float y, float width, float height, float padding) { - super(x, y, width, height, padding); - } - + * + * @author bwyap */ +public abstract class RectangularTextBox extends VectorTextBox implements IVectorRect +{ + public RectangularTextBox(float x, float y, float width, float height, float padding) + { super(x, y, width, height, padding); } } diff --git a/src/com/bwyap/engine/gui/element/RectangularTextfield.java b/src/com/bwyap/engine/gui/element/RectangularTextfield.java index c0b3fad..979f99f 100644 --- a/src/com/bwyap/engine/gui/element/RectangularTextfield.java +++ b/src/com/bwyap/engine/gui/element/RectangularTextfield.java @@ -4,17 +4,12 @@ import com.bwyap.engine.gui.element.vector.VectorTextField; import com.bwyap.engine.gui.interfaces.IVectorRect; -/** - * A vector drawn rectangular text field. +/** A vector drawn rectangular text field. * See {@link TextField}. - * @author bwyap - * - */ -public abstract class RectangularTextfield extends VectorTextField implements IVectorRect { - - public RectangularTextfield(int x, int y, float width, float height) { - super(x, y, width, height); - - } - + * + * @author bwyap */ +public abstract class RectangularTextfield extends VectorTextField implements IVectorRect +{ + public RectangularTextfield(int x, int y, float width, float height) + { super(x, y, width, height); } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularButton.java b/src/com/bwyap/engine/gui/element/RoundedRectangularButton.java index bdd3e13..95b31a4 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularButton.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularButton.java @@ -4,32 +4,27 @@ import com.bwyap.engine.gui.element.vector.VectorButton; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; -/** - * A rounded rectangular button that is drawn by the graphics rendering system. +/** A rounded rectangular button that is drawn by the graphics rendering system. * See {@link Button}. - * @author bwyap - * - */ -public abstract class RoundedRectangularButton extends VectorButton implements IVectorRoundedRect { - + * + * @author bwyap */ +public abstract class RoundedRectangularButton extends VectorButton implements IVectorRoundedRect +{ protected float radius; - - public RoundedRectangularButton(int x, int y, float width, float height, float radius) { + + public RoundedRectangularButton(int x, int y, float width, float height, float radius) + { super(x, y, width, height); this.radius = radius; } - + @Override - public float getRadius() { - return radius; - } - - /** - * Set the radius of the corners - * @param radius - */ - public void setRadius(float radius) { - this.radius = radius; - } - + public float getRadius() + { return radius; } + + /** Set the radius of the corners + * + * @param radius */ + public void setRadius(float radius) + { this.radius = radius; } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularCheckBox.java b/src/com/bwyap/engine/gui/element/RoundedRectangularCheckBox.java index 4469aea..9f43f5e 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularCheckBox.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularCheckBox.java @@ -4,39 +4,34 @@ import com.bwyap.engine.gui.element.vector.VectorCheckBox; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; -/** - * A rounded rectangular check box. +/** A rounded rectangular check box. * See {@link CheckBox}. - * @author bwyap - * - */ -public class RoundedRectangularCheckBox extends VectorCheckBox implements IVectorRoundedRect { - + * + * @author bwyap */ +public class RoundedRectangularCheckBox extends VectorCheckBox implements IVectorRoundedRect +{ private float radius; - - public RoundedRectangularCheckBox(float x, float y, float width, float radius, CheckBoxCheckStyle style) { + + public RoundedRectangularCheckBox(float x, float y, float width, float radius, CheckBoxCheckStyle style) + { super(x, y, width, width, style); this.radius = radius; } - - - public RoundedRectangularCheckBox(float x, float y, float width, float radius) { + + public RoundedRectangularCheckBox(float x, float y, float width, float radius) + { super(x, y, width, width); this.radius = radius; } - - + @Override - public float getRadius() { - return radius; - } - - - /** - * {@inheritDoc} + public float getRadius() + { return radius; } + + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void update(float timestep) { } + * */ + public void update(float timestep) + {} } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularPanel.java b/src/com/bwyap/engine/gui/element/RoundedRectangularPanel.java index 837cdbc..d83b492 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularPanel.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularPanel.java @@ -3,25 +3,21 @@ import com.bwyap.engine.gui.element.base.Panel; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; -/** - * A rounded rectangular panel. +/** A rounded rectangular panel. * See {@link Panel}. - * @author bwyap - * - */ -public class RoundedRectangularPanel extends Panel implements IVectorRoundedRect { - + * + * @author bwyap */ +public class RoundedRectangularPanel extends Panel implements IVectorRoundedRect +{ private float radius; - public RoundedRectangularPanel(float x, float y, float width, float height, float radius) { + public RoundedRectangularPanel(float x, float y, float width, float height, float radius) + { super(x, y, width, height); this.radius = radius; } - - - @Override - public float getRadius() { - return radius; - } + @Override + public float getRadius() + { return radius; } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularPanelWindow.java b/src/com/bwyap/engine/gui/element/RoundedRectangularPanelWindow.java index 99df778..9083f04 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularPanelWindow.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularPanelWindow.java @@ -3,25 +3,21 @@ import com.bwyap.engine.gui.element.base.PanelWindow; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; -/** - * A rounded rectangular panel window. +/** A rounded rectangular panel window. * See {@link PanelWindow}. - * @author bwyap - * - */ -public abstract class RoundedRectangularPanelWindow extends PanelWindow implements IVectorRoundedRect { - + * + * @author bwyap */ +public abstract class RoundedRectangularPanelWindow extends PanelWindow implements IVectorRoundedRect +{ private float radius; - public RoundedRectangularPanelWindow(String title, float x, float y, float width, float height, float radius) { + public RoundedRectangularPanelWindow(String title, float x, float y, float width, float height, float radius) + { super(title, x, y, width, height); this.radius = radius; } - @Override - public float getRadius() { - return radius; - } - + public float getRadius() + { return radius; } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularScrollArea.java b/src/com/bwyap/engine/gui/element/RoundedRectangularScrollArea.java index 83f3071..db4cd93 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularScrollArea.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularScrollArea.java @@ -4,35 +4,27 @@ import com.bwyap.engine.gui.element.vector.VectorScrollArea; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; - -/** - * A rounded rectangular scroll area. +/** A rounded rectangular scroll area. * See {@link ScrollArea}. - * @author bwyap - * - */ -public class RoundedRectangularScrollArea extends VectorScrollArea implements IVectorRoundedRect { - + * + * @author bwyap */ +public class RoundedRectangularScrollArea extends VectorScrollArea implements IVectorRoundedRect +{ private float radius; - - public RoundedRectangularScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection, float radius) { + + public RoundedRectangularScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection, float radius) + { super(x, y, width, height, scrollLength, scrollDirection); this.radius = radius; } - - - /** - * Set the radius of the corners - * @param radius - */ - public void setRadius(float radius) { - this.radius = radius; - } - - - @Override - public float getRadius() { - return radius; - } + /** Set the radius of the corners + * + * @param radius */ + public void setRadius(float radius) + { this.radius = radius; } + + @Override + public float getRadius() + { return radius; } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularSolidProgressBar.java b/src/com/bwyap/engine/gui/element/RoundedRectangularSolidProgressBar.java index 936b378..ca4e3bf 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularSolidProgressBar.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularSolidProgressBar.java @@ -6,42 +6,33 @@ import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; import com.bwyap.engine.input.InputHandler; - -/** - * A rounded rectangular progress bar filled with a solid colour. +/** A rounded rectangular progress bar filled with a solid colour. * See {@link ProgressBar}. - * @author bwyap - * - */ -public class RoundedRectangularSolidProgressBar extends SolidVectorProgressBar implements IVectorRoundedRect { - + * + * @author bwyap */ +public class RoundedRectangularSolidProgressBar extends SolidVectorProgressBar implements IVectorRoundedRect +{ private float radius; - - - public RoundedRectangularSolidProgressBar(float x, float y, float width, float height, float radius) { + + public RoundedRectangularSolidProgressBar(float x, float y, float width, float height, float radius) + { super(x, y, width, height); this.radius = radius; } - - + @Override - public float getRadius() { - return radius; - } - - - /** - * {@inheritDoc} + public float getRadius() + { return radius; } + + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ + * */ @Override - public void update(float timestep) { } + public void update(float timestep) + {} - @Override - public void handleInput(InputHandler input, GUIBoundsInterface bounds) { } - - + public void handleInput(InputHandler input, GUIBoundsInterface bounds) + {} } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularTextBox.java b/src/com/bwyap/engine/gui/element/RoundedRectangularTextBox.java index 7777c60..3c401d2 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularTextBox.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularTextBox.java @@ -4,34 +4,27 @@ import com.bwyap.engine.gui.element.vector.VectorTextBox; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; - -/** - * A rounded rectangular text box. +/** A rounded rectangular text box. * See {@link TextBox}. - * @author bwyap - * - */ -public abstract class RoundedRectangularTextBox extends VectorTextBox implements IVectorRoundedRect{ - + * + * @author bwyap */ +public abstract class RoundedRectangularTextBox extends VectorTextBox implements IVectorRoundedRect +{ private float radius; - - public RoundedRectangularTextBox(float x, float y, float width, float height, float radius, float padding) { + + public RoundedRectangularTextBox(float x, float y, float width, float height, float radius, float padding) + { super(x, y, width, height, padding); this.radius = radius; } - - - /** - * Set the radius of the rounded rectangle - * @param radius - */ - public void setRadius(float radius) { - this.radius = radius; - } - - + + /** Set the radius of the rounded rectangle + * + * @param radius */ + public void setRadius(float radius) + { this.radius = radius; } + @Override - public float getRadius() { - return radius; - } + public float getRadius() + { return radius; } } diff --git a/src/com/bwyap/engine/gui/element/RoundedRectangularTextfield.java b/src/com/bwyap/engine/gui/element/RoundedRectangularTextfield.java index c22e40d..e8af550 100644 --- a/src/com/bwyap/engine/gui/element/RoundedRectangularTextfield.java +++ b/src/com/bwyap/engine/gui/element/RoundedRectangularTextfield.java @@ -4,34 +4,27 @@ import com.bwyap.engine.gui.element.vector.VectorTextField; import com.bwyap.engine.gui.interfaces.IVectorRoundedRect; - -/** - * A vector drawn rounded rectangular text field. +/** A vector drawn rounded rectangular text field. * See {@link TextField}. - * @author bwyap - * - */ -public abstract class RoundedRectangularTextfield extends VectorTextField implements IVectorRoundedRect { - + * + * @author bwyap */ +public abstract class RoundedRectangularTextfield extends VectorTextField implements IVectorRoundedRect +{ protected float radius; - public RoundedRectangularTextfield(int x, int y, float width, float height, float radius) { + public RoundedRectangularTextfield(int x, int y, float width, float height, float radius) + { super(x, y, width, height); this.radius = radius; } - @Override - public float getRadius() { - return radius; - } - - /** - * Set the radius of the corners - * @param radius - */ - public void setRadius(float radius) { - this.radius = radius; - } - + public float getRadius() + { return radius; } + + /** Set the radius of the corners + * + * @param radius */ + public void setRadius(float radius) + { this.radius = radius; } } diff --git a/src/com/bwyap/engine/gui/element/TexturedButton.java b/src/com/bwyap/engine/gui/element/TexturedButton.java index fd7ebb9..938ce59 100644 --- a/src/com/bwyap/engine/gui/element/TexturedButton.java +++ b/src/com/bwyap/engine/gui/element/TexturedButton.java @@ -2,86 +2,69 @@ import com.bwyap.engine.gui.element.base.Button; -/** - * A button that is rendered with a texture. +/** A button that is rendered with a texture. * See {@link Button}. - * @author bwyap - * - */ -public abstract class TexturedButton extends Button { - + * + * @author bwyap */ +public abstract class TexturedButton extends Button +{ protected String texture, mouseoverTexture, pressedTexture; - - - public TexturedButton(int x, int y, int width, int height) { - super(x, y, width, height); - } - - /** - * Set the normal texture and mouseover texture to use by its name - * @param texture - */ - public void setTextures(String texture, String mouseoverTexture) { + + public TexturedButton(int x, int y, int width, int height) + { super(x, y, width, height); } + + /** Set the normal texture and mouseover texture to use by its name + * + * @param texture */ + public void setTextures(String texture, String mouseoverTexture) + { this.texture = texture; this.mouseoverTexture = mouseoverTexture; } - - /** - * Set the normal texture, mouseover and pressed texture to use by its name - * @param texture - */ - public void setTextures(String texture, String mouseoverTexture, String pressedTexture) { + + /** Set the normal texture, mouseover and pressed texture to use by its name + * + * @param texture */ + public void setTextures(String texture, String mouseoverTexture, String pressedTexture) + { this.texture = texture; this.mouseoverTexture = mouseoverTexture; this.pressedTexture = pressedTexture; } - - /** - * Set the button texture to use by its name - * @param texture - */ - public void setTexture(String texture) { - this.texture = texture; - } - - /** - * Get the name of the button texture - * @return - */ - public String getTexture() { - return texture; - } - - /** - * Set the mouseover texture to use by its name - * @param texture - */ - public void setMouseoverTexture(String texture) { - this.mouseoverTexture = texture; - } - - /** - * Get the name of the mouseover texture - * @return - */ - public String getMouseoverTexture() { - return mouseoverTexture; - } - - /** - * Set the button pressed texture to use by its name - * @param texture - */ - public void setPressedTexture(String pressedTexture) { - this.pressedTexture = pressedTexture; - } - - /** - * Get the name of the button pressed texture - * @return - */ - public String getPressedTexture() { - return pressedTexture; - } - + + /** Set the button texture to use by its name + * + * @param texture */ + public void setTexture(String texture) + { this.texture = texture; } + + /** Get the name of the button texture + * + * @return */ + public String getTexture() + { return texture; } + + /** Set the mouseover texture to use by its name + * + * @param texture */ + public void setMouseoverTexture(String texture) + { this.mouseoverTexture = texture; } + + /** Get the name of the mouseover texture + * + * @return */ + public String getMouseoverTexture() + { return mouseoverTexture; } + + /** Set the button pressed texture to use by its name + * + * @param texture */ + public void setPressedTexture(String pressedTexture) + { this.pressedTexture = pressedTexture; } + + /** Get the name of the button pressed texture + * + * @return */ + public String getPressedTexture() + { return pressedTexture; } } diff --git a/src/com/bwyap/engine/gui/element/base/AbstractGUIElement.java b/src/com/bwyap/engine/gui/element/base/AbstractGUIElement.java index 1b29436..5eea0dc 100644 --- a/src/com/bwyap/engine/gui/element/base/AbstractGUIElement.java +++ b/src/com/bwyap/engine/gui/element/base/AbstractGUIElement.java @@ -5,178 +5,145 @@ import com.bwyap.engine.gui.interfaces.GUIElementInterface; import com.bwyap.engine.window.BoundsInterface; - -/** - * A dummy class that can be extended by GUI elements +/** A dummy class that can be extended by GUI elements * that should not be rendered themselves, but need to * be to be processed by the renderer. - * @author bwyap - * - */ -public abstract class AbstractGUIElement implements GUIElementInterface { - + * + * @author bwyap */ +public abstract class AbstractGUIElement implements GUIElementInterface +{ protected boolean enabled; - - + @Override - public final void setEnabled(boolean enabled) { - this.enabled = enabled; - } + public final void setEnabled(boolean enabled) + { this.enabled = enabled; } - @Override - public final boolean isEnabled() { - return enabled; - } - - + public final boolean isEnabled() + { return enabled; } + /* * ============== * UNUSED METHODS * ============== */ - - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getWidth() {return 0;} - - /** - * Unused method in this class. - */ + public float getWidth() + { return 0; } + + /** Unused method in this class. */ @Override - public float getHeight() {return 0;} + public float getHeight() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPaddingTop() {return 0;} + public float getPaddingTop() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPaddingBottom() {return 0;} + public float getPaddingBottom() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPaddingLeft() {return 0;} + public float getPaddingLeft() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPaddingRight() {return 0;} + public float getPaddingRight() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public Vector2f getPosition() {return null;} + public Vector2f getPosition() + { return null; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public Vector2f getAbsolutePosition() {return null;} + public Vector2f getAbsolutePosition() + { return null; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPositionX() {return 0;} + public float getPositionX() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public float getPositionY() {return 0;} + public float getPositionY() + { return 0; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public Vector2f getBounds() {return null;} + public Vector2f getBounds() + { return null; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public Vector2f getAbsoluteBounds() {return null;} + public Vector2f getAbsoluteBounds() + { return null; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public Vector2f getOriginalBounds() {return null;} + public Vector2f getOriginalBounds() + { return null; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void updateBounds(BoundsInterface window, Vector2f parent) {} + public void updateBounds(BoundsInterface window, Vector2f parent) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setPosition(float x, float y) {} + public void setPosition(float x, float y) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setPosition(Vector2f position) {} + public void setPosition(Vector2f position) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setPadding(float top, float bottom, float left, float right) {} + public void setPadding(float top, float bottom, float left, float right) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setBounds(float x, float y, float width, float height) {} + public void setBounds(float x, float y, float width, float height) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setBounds(float width, float height) {} + public void setBounds(float width, float height) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public boolean withinBounds(float x, float y) {return false;} + public boolean withinBounds(float x, float y) + { return false; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setPositionAbsolute(boolean absolute) {} + public void setPositionAbsolute(boolean absolute) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public boolean isPositionAbsolute() {return false;} + public boolean isPositionAbsolute() + { return false; } - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public void setScaleAbsolute(boolean absolute) {} + public void setScaleAbsolute(boolean absolute) + {} - /** - * Unused method in this class. - */ + /** Unused method in this class. */ @Override - public boolean isScaleAbsolute() {return false;} + public boolean isScaleAbsolute() + { return false; } } diff --git a/src/com/bwyap/engine/gui/element/base/Button.java b/src/com/bwyap/engine/gui/element/base/Button.java index 2b84ca6..c868bdb 100644 --- a/src/com/bwyap/engine/gui/element/base/Button.java +++ b/src/com/bwyap/engine/gui/element/base/Button.java @@ -5,48 +5,38 @@ import com.bwyap.engine.gui.interfaces.ITextDisplay; import com.bwyap.engine.input.InputHandler; -/** - * An abstract model of a button that supports a text component. - * @author bwyap - * - */ -public abstract class Button extends ClickableElement implements ITextDisplay{ - +/** An abstract model of a button that supports a text component. + * + * @author bwyap */ +public abstract class Button extends ClickableElement implements ITextDisplay +{ protected final TextComponent text; - - public Button(float x, float y, float width, float height) { + + public Button(float x, float y, float width, float height) + { super(x, y, width, height); text = new TextComponent(1.0f, 1.0f, 1.0f, 1.0f); } - - + @Override - public TextComponent getTextComponent() { - return text; - } - - - /** - * {@inheritDoc} - *Override this method for custom update functionality.
- */ + public TextComponent getTextComponent() + { return text; } + + /** {@inheritDoc} + *Override this method for custom update functionality.
*/ @Override - public void onMouseOver(float x, float y) { } - - - /** - * {@inheritDoc} - *Override this method for custom update functionality.
- */ + public void onMouseOver(float x, float y) + {} + + /** {@inheritDoc} + *Override this method for custom update functionality.
*/ @Override - public void update(float timestep) { } + public void update(float timestep) + {} - - /** - * {@inheritDoc} - *Override this method for custom input handling functionality.
- */ + /** {@inheritDoc} + *Override this method for custom input handling functionality.
*/ @Override - public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) { } - + public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) + {} } diff --git a/src/com/bwyap/engine/gui/element/base/CheckBox.java b/src/com/bwyap/engine/gui/element/base/CheckBox.java index 340746a..6b72749 100644 --- a/src/com/bwyap/engine/gui/element/base/CheckBox.java +++ b/src/com/bwyap/engine/gui/element/base/CheckBox.java @@ -3,64 +3,59 @@ import com.bwyap.engine.gui.interfaces.GUIBoundsInterface; import com.bwyap.engine.input.InputHandler; - -/** - * A check box which can be selected. It holds its selected state until - * it is clicked again. Its state can be checked using the {@code isSelected} +/** A check box which can be selected. It holds its selected state until + * it is clicked again. Its state can be checked using the {@code isSelected} * method. The methods {@code onSelect} and {@code onDeselect} can be overridden * to implement custom functionality. - * @author bwyap - * - */ -public abstract class CheckBox extends SelectableElement { + * + * @author bwyap */ +public abstract class CheckBox extends SelectableElement +{ + public CheckBox(float x, float y, float width, float height) + { super(x, y, width, height); } - - public CheckBox(float x, float y, float width, float height) { - super(x, y, width, height); - } - - @Override - public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) { + public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) + { // Override SelectableElement functionality } - - + @Override - public void onMouseClicked(float x, float y, int mouseButton) { - if (isSelectable()) { - for (int button : acceptedButtons) { - if (button == mouseButton) { - if (!isSelected()) { + public void onMouseClicked(float x, float y, int mouseButton) + { + if (isSelectable()) + { + for (int button : acceptedButtons) + { + if (button == mouseButton) + { + if (!isSelected()) + { setSelected(true); - onSelect(); + onSelect(); } - else { + else + { setSelected(false); onDeselect(); } - break; + break; } } } } - - /** - * {@inheritDoc} + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void onSelect() { } + * */ + public void onSelect() + {} - - /** - * {@inheritDoc} + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void onDeselect() { } - + * */ + public void onDeselect() + {} } diff --git a/src/com/bwyap/engine/gui/element/base/ClickableElement.java b/src/com/bwyap/engine/gui/element/base/ClickableElement.java index 9a920c4..ce4a0ba 100644 --- a/src/com/bwyap/engine/gui/element/base/ClickableElement.java +++ b/src/com/bwyap/engine/gui/element/base/ClickableElement.java @@ -8,122 +8,101 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.lwjgl.engine.resource.LWJGLResourceManager; -/** - * A GUI element that can be clicked by specified mouse buttons. +/** A GUI element that can be clicked by specified mouse buttons. * Valid mouse buttons are in the list {@code acceptedButtons}. * - * @author bwyap - * - */ -public abstract class ClickableElement extends GUIElement implements MouseDownInterface { - + * @author bwyap */ +public abstract class ClickableElement extends GUIElement implements MouseDownInterface +{ protected List+/**
* A template that provides core methods for an arbitrary GUI element * that can be selected, enabled, scaled, and has a position. *
** Uses the {@code JOML} library for Vector operations. *
- * @author bwyap - * - */ -public abstract class GUIElement extends AbstractGUIElement implements GUIElementInterface { - + * + * @author bwyap */ +public abstract class GUIElement extends AbstractGUIElement implements GUIElementInterface +{ protected final Vector2f absolutePosition, position; protected boolean positionAbsolute; protected boolean scaleAbsolute; - protected float scaleX; protected float scaleY; - private float paddingTop = 2.0f; private float paddingBottom = 2.0f; private float paddingLeft = 2.0f; private float paddingRight = 2.0f; - protected final Vector2f boundsOffset, absoluteBoundsOffset; protected final Vector2f bounds, absoluteBounds, originalBounds; - - - /** - * Create a new GUIElement at the specified co-ordinates + + /** Create a new GUIElement at the specified co-ordinates * with bounds given by the width and height. + * * @param x * @param y * @param width - * @param height - */ - public GUIElement(float x, float y, float width, float height) { + * @param height */ + public GUIElement(float x, float y, float width, float height) + { this.absolutePosition = new Vector2f(x, y); this.position = new Vector2f(x, y); this.enabled = true; this.originalBounds = new Vector2f(width, height); this.absoluteBounds = new Vector2f(width, height); this.bounds = new Vector2f(width, height); - // default bounds have an offset of 0 - this.boundsOffset = new Vector2f(0, 0); - this.absoluteBoundsOffset = new Vector2f(0, 0); - + this.boundsOffset = new Vector2f(0, 0); + this.absoluteBoundsOffset = new Vector2f(0, 0); // by default GUI elements are not absolutely positioned // that is, they should be scaled according to the screen AR this.positionAbsolute = false; @@ -63,186 +54,145 @@ public GUIElement(float x, float y, float width, float height) { this.scaleY = 1.0f; } - - /** - * Create a new GUIElement at the specified co-ordinates. + /** Create a new GUIElement at the specified co-ordinates. * Bounds initially set to 0. + * * @param x - * @param y - */ - public GUIElement(float x, float y) { - this(x, y, 0, 0); - } - + * @param y */ + public GUIElement(float x, float y) + { this(x, y, 0, 0); } @Override - public void updateBounds(BoundsInterface window, Vector2f parent) { - if (!scaleAbsolute) { - scaleX = (float)window.getBounds().x/window.getOriginalBounds().x; - scaleY = (float)window.getBounds().y/window.getOriginalBounds().y; + public void updateBounds(BoundsInterface window, Vector2f parent) + { + if (!scaleAbsolute) + { + scaleX = (float) window.getBounds().x / window.getOriginalBounds().x; + scaleY = (float) window.getBounds().y / window.getOriginalBounds().y; boundsOffset.x = absoluteBoundsOffset.x * scaleX; boundsOffset.y = absoluteBoundsOffset.y * scaleY; bounds.x = absoluteBounds.x * scaleX; bounds.y = absoluteBounds.y * scaleY; } - - if (!positionAbsolute) { - position.x = (absolutePosition.x * (float)window.getBounds().x/window.getOriginalBounds().x) + parent.x; - position.y = (absolutePosition.y * (float)window.getBounds().y/window.getOriginalBounds().y) + parent.y; + if (!positionAbsolute) + { + position.x = (absolutePosition.x * (float) window.getBounds().x / window.getOriginalBounds().x) + parent.x; + position.y = (absolutePosition.y * (float) window.getBounds().y / window.getOriginalBounds().y) + parent.y; } - else { + else + { position.x = (absolutePosition.x) + parent.x; position.y = (absolutePosition.y) + parent.y; } } - @Override - public final void setPosition(float x, float y) { + public final void setPosition(float x, float y) + { absolutePosition.x = x; absolutePosition.y = y; } - - - @Override - public final void setPosition(Vector2f position) { - setPosition(position.x, position.y); - } - @Override - public final Vector2f getPosition() { - return position; - } - + public final void setPosition(Vector2f position) + { setPosition(position.x, position.y); } @Override - public final Vector2f getAbsolutePosition() { - return absolutePosition; - } - + public final Vector2f getPosition() + { return position; } @Override - public final float getPositionX() { - return position.x; - } + public final Vector2f getAbsolutePosition() + { return absolutePosition; } + @Override + public final float getPositionX() + { return position.x; } @Override - public final float getPositionY() { - return position.y; - } - - + public final float getPositionY() + { return position.y; } + @Override - public void setBounds(float xOffset, float yOffset, float width, float height) { + public void setBounds(float xOffset, float yOffset, float width, float height) + { absoluteBoundsOffset.x = xOffset; absoluteBoundsOffset.y = yOffset; absoluteBounds.x = width; absoluteBounds.y = height; } - - + @Override - public void setBounds(float width, float height) { - setBounds(0, 0, width, height); - } - - + public void setBounds(float width, float height) + { setBounds(0, 0, width, height); } + @Override - public Vector2f getBounds() { - return bounds; - } - - + public Vector2f getBounds() + { return bounds; } + @Override - public float getWidth() { - return bounds.x; - } - - + public float getWidth() + { return bounds.x; } + @Override - public float getHeight() { - return bounds.y; - } - - + public float getHeight() + { return bounds.y; } + @Override - public Vector2f getAbsoluteBounds() { - return absoluteBounds; - } - - + public Vector2f getAbsoluteBounds() + { return absoluteBounds; } + @Override - public Vector2f getOriginalBounds() { - return originalBounds; - } - + public Vector2f getOriginalBounds() + { return originalBounds; } @Override - public void setPadding(float top, float bottom, float left, float right) { + public void setPadding(float top, float bottom, float left, float right) + { paddingTop = top; paddingBottom = bottom; paddingLeft = left; paddingRight = right; } - - + @Override - public float getPaddingTop() { - return paddingTop; - } - - + public float getPaddingTop() + { return paddingTop; } + @Override - public float getPaddingBottom() { - return paddingBottom; - } - - + public float getPaddingBottom() + { return paddingBottom; } + @Override - public float getPaddingLeft() { - return paddingLeft; - } - - + public float getPaddingLeft() + { return paddingLeft; } + @Override - public float getPaddingRight() { - return paddingRight; - } - - + public float getPaddingRight() + { return paddingRight; } + @Override - public boolean withinBounds(float x, float y) { - if((x >= (position.x + boundsOffset.x) && x < (position.x + boundsOffset.x + bounds.x)) && - (y >= (position.y + boundsOffset.y) && y < (position.y + boundsOffset.y + bounds.y))) { - return true; - } + public boolean withinBounds(float x, float y) + { + if ((x >= (position.x + boundsOffset.x) && x < (position.x + boundsOffset.x + bounds.x)) && + (y >= (position.y + boundsOffset.y) && y < (position.y + boundsOffset.y + bounds.y))) + { return true; } return false; } - - + @Override - public void setPositionAbsolute(boolean absolute) { - this.positionAbsolute = absolute; - } - - + public void setPositionAbsolute(boolean absolute) + { this.positionAbsolute = absolute; } + @Override - public boolean isPositionAbsolute() { - return positionAbsolute; - } - - + public boolean isPositionAbsolute() + { return positionAbsolute; } + @Override - public void setScaleAbsolute(boolean absolute) { - this.scaleAbsolute = absolute; - } - - + public void setScaleAbsolute(boolean absolute) + { this.scaleAbsolute = absolute; } + @Override - public boolean isScaleAbsolute() { - return scaleAbsolute; - } - + public boolean isScaleAbsolute() + { return scaleAbsolute; } } diff --git a/src/com/bwyap/engine/gui/element/base/ImageHolder.java b/src/com/bwyap/engine/gui/element/base/ImageHolder.java index bbe52be..03bf500 100644 --- a/src/com/bwyap/engine/gui/element/base/ImageHolder.java +++ b/src/com/bwyap/engine/gui/element/base/ImageHolder.java @@ -6,26 +6,20 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.engine.window.BoundsInterface; - -/** - * An image holder represents a set of bounds in which to render an image. +/** An image holder represents a set of bounds in which to render an image. * The image to render is specified by name and its ID retrieved from the * {@code NVGTexture} class' static map when rendering. - * @author bwyap - * - */ -public class ImageHolder extends GUIElement { - - + * + * @author bwyap */ +public class ImageHolder extends GUIElement +{ private String textureName; - private float imageX, imageY, absoluteImageX, absoluteImageY; private float imageWidth, imageHeight, absoluteImageWidth, absoluteImageHeight; - - /** - * Create an image holder with the specified image, with custom + /** Create an image holder with the specified image, with custom * parameters for the image's position and dimensions. + * * @param textureName * @param x * @param y @@ -34,136 +28,105 @@ public class ImageHolder extends GUIElement { * @param width * @param height * @param imageWidth - * @param imageHeight - */ - public ImageHolder(String textureName, float x, float y, float imageX, float imageY, float width, float height, float imageWidth, float imageHeight) { + * @param imageHeight */ + public ImageHolder(String textureName, float x, float y, float imageX, float imageY, float width, float height, float imageWidth, float imageHeight) + { super(x, y, width, height); this.imageX = this.absoluteImageX = imageX; this.imageY = this.absoluteImageY = imageY; this.imageWidth = this.absoluteImageWidth = imageWidth; - this.imageHeight = this.absoluteImageHeight = imageHeight; + this.imageHeight = this.absoluteImageHeight = imageHeight; this.textureName = textureName; } - - - /** - * Create an image holder with the specified image, with + + /** Create an image holder with the specified image, with * its position and dimensions the same as the image holder. + * * @param textureName * @param x * @param y * @param width - * @param height - */ - public ImageHolder(String textureName, float x, float y, float width, float height) { - this(textureName, x, y, x, y, width, height, width, height); - } - - - /** - * Set the absolute x-position of the image. + * @param height */ + public ImageHolder(String textureName, float x, float y, float width, float height) + { this(textureName, x, y, x, y, width, height, width, height); } + + /** Set the absolute x-position of the image. * The image is clipped by the bounds of the image holder. - * @param imageX - */ - public void setImageX(float imageX) { - this.absoluteImageX = imageX; - } - - - /** - * Get the x-position of the image. + * + * @param imageX */ + public void setImageX(float imageX) + { this.absoluteImageX = imageX; } + + /** Get the x-position of the image. * The image is clipped by the bounds of the image holder. - * @return - */ - public float getImageX() { - return imageX; - } - - - /** - * Set the absolute y-position of the image. + * + * @return */ + public float getImageX() + { return imageX; } + + /** Set the absolute y-position of the image. * The image is clipped by the bounds of the image holder. - * @param imageY - */ - public void setImageY(float imageY) { - this.absoluteImageY = imageY; - } - - - /** - * Get the y-position of the image. + * + * @param imageY */ + public void setImageY(float imageY) + { this.absoluteImageY = imageY; } + + /** Get the y-position of the image. * The image is clipped by the bounds of the image holder. - * @return - */ - public float getImageY() { - return imageY; - } - - - /** - * Set the absolute width of the image. + * + * @return */ + public float getImageY() + { return imageY; } + + /** Set the absolute width of the image. * The image is clipped by the bounds of the image holder. - * @param imageWidth - */ - public void setImageWidth(float imageWidth) { - this.absoluteImageWidth = imageWidth; - } - - /** - * Get the width of the image. + * + * @param imageWidth */ + public void setImageWidth(float imageWidth) + { this.absoluteImageWidth = imageWidth; } + + /** Get the width of the image. * The image is clipped by the bounds of the image holder. - * @return - */ - public float getImageWidth() { - return imageWidth; - } - - - /** - * Set the absolute height of the image. + * + * @return */ + public float getImageWidth() + { return imageWidth; } + + /** Set the absolute height of the image. * The image is clipped by the bounds of the image holder. - * @param imageHeight - */ - public void setImageHeight(float imageHeight) { - this.absoluteImageHeight = imageHeight; - } - - - /** - * Get the height of the image. + * + * @param imageHeight */ + public void setImageHeight(float imageHeight) + { this.absoluteImageHeight = imageHeight; } + + /** Get the height of the image. * The image is clipped by the bounds of the image holder. - * @return - */ - public float getImageHeight() { - return imageHeight; - } - - - /** - * Get the name of the texture - * @return - */ - public String getTextureName() { - return textureName; - } - - + * + * @return */ + public float getImageHeight() + { return imageHeight; } + + /** Get the name of the texture + * + * @return */ + public String getTextureName() + { return textureName; } + @Override - public void updateBounds(BoundsInterface window, Vector2f parent) { + public void updateBounds(BoundsInterface window, Vector2f parent) + { super.updateBounds(window, parent); - imageX = scaleX * absoluteImageX; imageY = scaleY * absoluteImageY; imageWidth = scaleX * absoluteImageWidth; imageHeight = scaleY * absoluteImageHeight; } - - + @Override - public void update(float timestep) {} + public void update(float timestep) + {} - @Override - public void handleInput(InputHandler input, GUIBoundsInterface bounds) { } - + public void handleInput(InputHandler input, GUIBoundsInterface bounds) + {} } diff --git a/src/com/bwyap/engine/gui/element/base/Panel.java b/src/com/bwyap/engine/gui/element/base/Panel.java index 3254a71..330ca4a 100644 --- a/src/com/bwyap/engine/gui/element/base/Panel.java +++ b/src/com/bwyap/engine/gui/element/base/Panel.java @@ -13,231 +13,189 @@ import com.bwyap.engine.gui.interfaces.IColouredVectorShape; import com.bwyap.engine.input.InputHandler; - -/** - * A panel is a renderable GUI element which can +/** A panel is a renderable GUI element which can * contain other GUI elements. The updating and rendering * of the GUIPanel should also take care of updating * and rendering all child elements. - * @author bwyap - * - */ -public abstract class Panel extends SelectableElement implements IColouredVectorShape, Iterable* Override this method to implement custom functionality. * Ensure you also call {@code super.onSelected()} if overriding. - *
- */ - public void onSelect() { - if (buttonGroup != null) buttonGroup.selectNew(this.getName()); - } + * */ + public void onSelect() + { if (buttonGroup != null) buttonGroup.selectNew(this.getName()); } - - /** - * {@inheritDoc} + /** {@inheritDoc} ** Override this method to implement custom functionality. - *
- */ - public void onDeselect() { } - + * */ + public void onDeselect() + {} } diff --git a/src/com/bwyap/engine/gui/element/base/RadioButtonGroup.java b/src/com/bwyap/engine/gui/element/base/RadioButtonGroup.java index 7e283a2..ca3b075 100644 --- a/src/com/bwyap/engine/gui/element/base/RadioButtonGroup.java +++ b/src/com/bwyap/engine/gui/element/base/RadioButtonGroup.java @@ -6,104 +6,89 @@ import com.bwyap.engine.gui.interfaces.GUIBoundsInterface; import com.bwyap.engine.input.InputHandler; - -/** - * A RadioButtonGroup stores a collection of radio buttons which are - * dependent on each other. When a radio button is selected, the - * previously selected radio button is deselected automatically. Only +/** A RadioButtonGroup stores a collection of radio buttons which are + * dependent on each other. When a radio button is selected, the + * previously selected radio button is deselected automatically. Only * one radio button can be selected at a time in a radio button group. - * @author bwyap - * - */ -public class RadioButtonGroup extends AbstractGUIElement { - + * + * @author bwyap */ +public class RadioButtonGroup extends AbstractGUIElement +{ private final MapOverride this method for custom input handling functionality.
- */ + *Override this method for custom input handling functionality.
*/ @Override - public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) { - if (!mouseOver && input.isMouseDown() && isSelected()) { + public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) + { + if (!mouseOver && input.isMouseDown() && isSelected()) + { setSelected(false); onDeselect(); } } - - - /** - * Action to perform when the element is selected - */ + + /** Action to perform when the element is selected */ public abstract void onSelect(); - - - /** - * Action to perform when the element is deselected - */ - public abstract void onDeselect(); + /** Action to perform when the element is deselected */ + public abstract void onDeselect(); } diff --git a/src/com/bwyap/engine/gui/element/base/TextBox.java b/src/com/bwyap/engine/gui/element/base/TextBox.java index 8a922c2..172e134 100644 --- a/src/com/bwyap/engine/gui/element/base/TextBox.java +++ b/src/com/bwyap/engine/gui/element/base/TextBox.java @@ -5,69 +5,60 @@ import com.bwyap.engine.gui.interfaces.IColouredVectorShape; import com.bwyap.engine.window.BoundsInterface; - -/** - * A text box which wraps text at the specified width. - * @author bwyap - * - */ -public abstract class TextBox extends TextField implements IColouredVectorShape { - - +/** A text box which wraps text at the specified width. + * + * @author bwyap */ +public abstract class TextBox extends TextField implements IColouredVectorShape +{ private float absoluteTextBoxWidth; private float absolutePadding; private boolean submittable; - - - public TextBox(float x, float y, float width, float height, float padding) { + + public TextBox(float x, float y, float width, float height, float padding) + { super(x, y, width, height); this.absolutePadding = padding; this.absoluteTextBoxWidth = width; this.submittable = false; - text.setTextBox(true); text.setAlignment(ETextAlignment.TOP_LEFT); text.setPadding(absolutePadding, absolutePadding, absolutePadding, absolutePadding); text.setTextBoxWidth(absoluteTextBoxWidth - 2 * absolutePadding); } - - - /** - * Check whether the contents of the text box are sent to the {@code onSubmit} method - * @return - */ - public boolean isSubmittable() { - return submittable; - } - - - /** - * Set whether the contents of the text box are sent to the {@code onSubmit} method - * @param submittable - */ - public void setSubmittable(boolean submittable) { - this.submittable = submittable; - } - - + + /** Check whether the contents of the text box are sent to the {@code onSubmit} method + * + * @return */ + public boolean isSubmittable() + { return submittable; } + + /** Set whether the contents of the text box are sent to the {@code onSubmit} method + * + * @param submittable */ + public void setSubmittable(boolean submittable) + { this.submittable = submittable; } + @Override - public void updateBounds(BoundsInterface window, Vector2f parent) { + public void updateBounds(BoundsInterface window, Vector2f parent) + { super.updateBounds(window, parent); - if (!scaleAbsolute) { + if (!scaleAbsolute) + { text.setTextBoxWidth(absoluteTextBoxWidth * scaleX - 2 * absolutePadding * scaleX); text.setPadding(absolutePadding * scaleY, absolutePadding * scaleY, absolutePadding * scaleX, absolutePadding * scaleX); } } - - + @Override - public void enterPressed() { - if (isSubmittable()) { + public void enterPressed() + { + if (isSubmittable()) + { super.enterPressed(); } - else { + else + { putChar('\n'); } } - } diff --git a/src/com/bwyap/engine/gui/element/base/TextField.java b/src/com/bwyap/engine/gui/element/base/TextField.java index 7158fee..86eda64 100644 --- a/src/com/bwyap/engine/gui/element/base/TextField.java +++ b/src/com/bwyap/engine/gui/element/base/TextField.java @@ -5,26 +5,22 @@ import com.bwyap.engine.gui.interfaces.ITextDisplay; import com.bwyap.engine.input.InputHandler; - -/** - * A text field that allows text to be entered within it +/** A text field that allows text to be entered within it * when it is selected. It contains a {@code TextComponent} * to hold text for rendering. - * @author bwyap - * - */ -public abstract class TextField extends SelectableElement implements ITextDisplay { - + * + * @author bwyap */ +public abstract class TextField extends SelectableElement implements ITextDisplay +{ protected final TextComponent text; - private boolean editable; private boolean showCaret; private boolean displayingCaret; private float caretBlinkTime = 0; private float BLINK_TIME = 0.5f; - - - public TextField(float x, float y, float width, float height) { + + public TextField(float x, float y, float width, float height) + { super(x, y, width, height); text = new TextComponent(); text.setText(""); @@ -32,107 +28,83 @@ public TextField(float x, float y, float width, float height) { showCaret = true; editable = true; } - - - /** - * Check if the text field is showing the blinking caret. - */ - public boolean showCaret() { - return showCaret; - } - - - /** - * Set whether the text field should show the caret when it is selected. - * @param showCaret - */ - public void setShowCaret(boolean showCaret) { - this.showCaret = showCaret; - } - - - /** - * Set the blink time of the caret. + + /** Check if the text field is showing the blinking caret. */ + public boolean showCaret() + { return showCaret; } + + /** Set whether the text field should show the caret when it is selected. + * + * @param showCaret */ + public void setShowCaret(boolean showCaret) + { this.showCaret = showCaret; } + + /** Set the blink time of the caret. * Default is 0.5f. - * @param blinkTime - */ - public void setBlinkTime(float blinkTime) { - this.BLINK_TIME = blinkTime; - } - - - /** - * Get the blink time of the caret. - * @return - */ - public float getBlinkTime() { - return BLINK_TIME; - } + * + * @param blinkTime */ + public void setBlinkTime(float blinkTime) + { this.BLINK_TIME = blinkTime; } + /** Get the blink time of the caret. + * + * @return */ + public float getBlinkTime() + { return BLINK_TIME; } - /** - * Check whether the contents of this text field are editable - * @return - */ - public boolean isEditable() { - return editable; - } - - - /** - * Set whether the contents of this text field are editable - * @param editable - */ - public void setEditable(boolean editable) { - this.editable = editable; - } - - - /** - * Action to perform when the text field data is to be submitted - * @param text - */ + /** Check whether the contents of this text field are editable + * + * @return */ + public boolean isEditable() + { return editable; } + + /** Set whether the contents of this text field are editable + * + * @param editable */ + public void setEditable(boolean editable) + { this.editable = editable; } + + /** Action to perform when the text field data is to be submitted + * + * @param text */ public abstract void onSubmit(String text); - - + @Override - public void onSelect() { - if (editable) beginEnterText(); - } - - + public void onSelect() + { if (editable) beginEnterText(); } + @Override - public void onDeselect() { - if (editable) stopEnterText(); - } - - + public void onDeselect() + { if (editable) stopEnterText(); } + @Override - public void onMouseOver(float x, float y) {} + public void onMouseOver(float x, float y) + {} - @Override - public TextComponent getTextComponent() { - return text; - } - - - /** - * {@inheritDoc} - *Override this method for custom update functionality.
- */ + public TextComponent getTextComponent() + { return text; } + + /** {@inheritDoc} + *Override this method for custom update functionality.
*/ @Override - public void update(float timestep) { - if (showCaret) { - if (isSelected() && editable) { + public void update(float timestep) + { + if (showCaret) + { + if (isSelected() && editable) + { caretBlinkTime += timestep; - if (caretBlinkTime >= BLINK_TIME) { + if (caretBlinkTime >= BLINK_TIME) + { caretBlinkTime = 0; - if (displayingCaret) { + if (displayingCaret) + { text.setText(text.getText().substring(0, text.getText().length() - 1) + " "); displayingCaret = false; } - else { + else + { text.setText(text.getText().substring(0, text.getText().length() - 1) + "|"); displayingCaret = true; } @@ -141,94 +113,86 @@ public void update(float timestep) { } } - - /** - * {@inheritDoc} - *Override this method for custom input handling functionality.
- */ + /** {@inheritDoc} + *Override this method for custom input handling functionality.
*/ @Override - public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) { + public void onHandleInput(InputHandler input, GUIBoundsInterface bounds) + { super.onHandleInput(input, bounds); - if (isSelected() && editable) enterText(input); } - - + private boolean clearCharBuffer; - - /** - * Set up the text component to begin editing the text - */ - protected void beginEnterText() { + + /** Set up the text component to begin editing the text */ + protected void beginEnterText() + { displayingCaret = true; text.appendText("|"); caretBlinkTime = 0; clearCharBuffer = true; } - - - /** - * Clean up after text in the text component has been edited - */ - protected void stopEnterText() { - if (text.getText().length() > 0) text.setText(text.getText().substring(0, text.getText().length() - 1)); - } - - - /** - * Poll the input handler to edit the text in the text component - */ - protected void enterText(InputHandler input) { - if (clearCharBuffer) { + + /** Clean up after text in the text component has been edited */ + protected void stopEnterText() + { if (text.getText().length() > 0) text.setText(text.getText().substring(0, text.getText().length() - 1)); } + + /** Poll the input handler to edit the text in the text component */ + protected void enterText(InputHandler input) + { + if (clearCharBuffer) + { input.consumeLastTypedChar(); clearCharBuffer = false; } char c = input.consumeLastTypedChar(); - if (c == '\b') { + if (c == '\b') + { // Remove a character if the key was backspace - removeChar(); + removeChar(); } - else if (c == '\n') { + else if (c == '\n') + { // Call the enter method if the enter key was pressed enterPressed(); } - else if (c != 0) { + else if (c != 0) + { // Add a character to the text field putChar(c); } } - - - /** - * Add a character to the text field - * @param c - */ - protected final void putChar(char c) { - if (showCaret) { - if (displayingCaret) text.setText(text.getText().substring(0, text.getText().length() - 1) + c + "|"); + + /** Add a character to the text field + * + * @param c */ + protected final void putChar(char c) + { + if (showCaret) + { + if (displayingCaret) + text.setText(text.getText().substring(0, text.getText().length() - 1) + c + "|"); else text.setText(text.getText().substring(0, text.getText().length() - 1) + c + " "); } else text.setText(text.getText() + c); } - - - /** - * Remove a character from the text field - */ - protected final void removeChar() { - if (showCaret && displayingCaret) { + + /** Remove a character from the text field */ + protected final void removeChar() + { + if (showCaret && displayingCaret) + { if (text.getText().length() > 1) text.setText(text.getText().substring(0, text.getText().length() - 2) + "|"); } else if (text.getText().length() > 1) text.setText(text.getText().substring(0, text.getText().length() - 2) + " "); } - - - /** - * Action to perform when the enter key is pressed - */ - protected void enterPressed() { + + /** Action to perform when the enter key is pressed */ + protected void enterPressed() + { // Call the enter method if the enter key was pressed - if (showCaret) onSubmit(text.getText().substring(0, text.getText().length() - 1)); + if (showCaret) + onSubmit(text.getText().substring(0, text.getText().length() - 1)); else onSubmit(text.getText()); } } diff --git a/src/com/bwyap/engine/gui/element/properties/Fade.java b/src/com/bwyap/engine/gui/element/properties/Fade.java index 67c1f95..5d5712a 100644 --- a/src/com/bwyap/engine/gui/element/properties/Fade.java +++ b/src/com/bwyap/engine/gui/element/properties/Fade.java @@ -1,73 +1,58 @@ package com.bwyap.engine.gui.element.properties; -/** - * A class to hold the fade amount of a rendered element. - * @author bwyap - * - */ -public class Fade implements GUIProperty { - +/** A class to hold the fade amount of a rendered element. + * + * @author bwyap */ +public class Fade implements GUIProperty +{ private float alpha; private boolean fading; - - /** - * Set whether the vector shape is fading - * @return - */ - public boolean isFading() { - return fading; - } - - - /** - * Set whether the vector shape is fading - * @param fading - */ - public void setFading(boolean fading) { - this.fading = fading; - } - - - /** - * Get the fade value - * @return - */ - public float getFade() { - return alpha; - } - - - /** - * Set the fade value. + /** Set whether the vector shape is fading + * + * @return */ + public boolean isFading() + { return fading; } + + /** Set whether the vector shape is fading + * + * @param fading */ + public void setFading(boolean fading) + { this.fading = fading; } + + /** Get the fade value + * + * @return */ + public float getFade() + { return alpha; } + + /** Set the fade value. * Clamped between 0 and 1. - * @param fade - */ - public void setFade(float fade) { + * + * @param fade */ + public void setFade(float fade) + { this.alpha = fade; // Clamp between 0 and 1 decreaseFade(0); increaseFade(0); } - - - /** - * Decrease the fade by the specified amount - * @param amount - */ - public void decreaseFade(float amount) { + + /** Decrease the fade by the specified amount + * + * @param amount */ + public void decreaseFade(float amount) + { alpha -= amount; if (alpha < 0) alpha = 0; } - - - /** - * Increase the fade by the specified amount - * @param amount - */ - public void increaseFade(float amount) { + + /** Increase the fade by the specified amount + * + * @param amount */ + public void increaseFade(float amount) + { alpha += amount; if (alpha > 1) alpha = 1; } - } diff --git a/src/com/bwyap/engine/gui/element/properties/GUIProperty.java b/src/com/bwyap/engine/gui/element/properties/GUIProperty.java index 9c9e0cd..51b2087 100644 --- a/src/com/bwyap/engine/gui/element/properties/GUIProperty.java +++ b/src/com/bwyap/engine/gui/element/properties/GUIProperty.java @@ -1,10 +1,8 @@ package com.bwyap.engine.gui.element.properties; -/** - * Indicates that the class is a property of a GUI element - * @author bwyap - * - */ -public interface GUIProperty { - +/** Indicates that the class is a property of a GUI element + * + * @author bwyap */ +public interface GUIProperty +{ } diff --git a/src/com/bwyap/engine/gui/element/properties/TextComponent.java b/src/com/bwyap/engine/gui/element/properties/TextComponent.java index 7bb06eb..fad98df 100644 --- a/src/com/bwyap/engine/gui/element/properties/TextComponent.java +++ b/src/com/bwyap/engine/gui/element/properties/TextComponent.java @@ -5,14 +5,12 @@ import com.bwyap.engine.gui.element.base.ETextAlignment; -/** - * A class to hold information for a text component +/** A class to hold information for a text component * to be rendered using the graphics rendering system. - * @author bwyap - * - */ -public class TextComponent implements GUIProperty { - + * + * @author bwyap */ +public class TextComponent implements GUIProperty +{ private String text = ""; private float absoluteTextSize, textSize; private final Vector2f positionOffset; @@ -23,52 +21,42 @@ public class TextComponent implements GUIProperty { private boolean scale; private boolean textBox; private float textBoxWidth; - private float paddingTop, paddingBottom, paddingLeft, paddingRight; - - - /** - * Create a text component with an empty string - * and default settings (Font size 20, white colour). - */ - public TextComponent() { - this(1.0f, 1.0f, 1.0f, 1.0f); - } - - - /** - * Create a text component with the given string + + /** Create a text component with an empty string + * and default settings (Font size 20, white colour). */ + public TextComponent() + { this(1.0f, 1.0f, 1.0f, 1.0f); } + + /** Create a text component with the given string * and default settings (Font size 20, white colour). - * @param text - */ - public TextComponent(String text) { + * + * @param text */ + public TextComponent(String text) + { this(); setText(text); } - - /** - * Create a text component with an empty + /** Create a text component with an empty * string and assign it the given colour. + * * @param r * @param g * @param b - * @param a - */ - public TextComponent(float r, float g, float b, float a) { - this("", r, g, b, a); - } + * @param a */ + public TextComponent(float r, float g, float b, float a) + { this("", r, g, b, a); } - - /** - * Create a text component with the given + /** Create a text component with the given * string and assign it the given colour. + * * @param r * @param g * @param b - * @param a - */ - public TextComponent(String text, float r, float g, float b, float a) { + * @param a */ + public TextComponent(String text, float r, float g, float b, float a) + { positionOffset = new Vector2f(); textColour = new Vector4f(r, b, g, a); textSize = absoluteTextSize = 20.0f; @@ -76,218 +64,176 @@ public TextComponent(String text, float r, float g, float b, float a) { scale = true; alignment = ETextAlignment.CENTER; } - - - /** - * Set the text component's width for rendering as a text box. + + /** Set the text component's width for rendering as a text box. * Use the {@code setTextBox} to enable rendering as a text box. - * @param textBoxWidth - */ - public void setTextBoxWidth(float textBoxWidth) { - this.textBoxWidth = textBoxWidth; - } - - - /** - * Set whether this text component should be rendered as a text box - * @param textBox - */ - public void setTextBox(boolean textBox) { - this.textBox = textBox; - } - - - /** - * Check if this text component should be rendered as a text box - * @return - */ - public boolean isTextBox() { - return textBox; - } - - - /** - * Get the width of the textbox in which the text should be rendered - * @return - */ - public float getTextBoxWidth() { - return textBoxWidth; - } - - - /** - * Get the position offset of the text component. + * + * @param textBoxWidth */ + public void setTextBoxWidth(float textBoxWidth) + { this.textBoxWidth = textBoxWidth; } + + /** Set whether this text component should be rendered as a text box + * + * @param textBox */ + public void setTextBox(boolean textBox) + { this.textBox = textBox; } + + /** Check if this text component should be rendered as a text box + * + * @return */ + public boolean isTextBox() + { return textBox; } + + /** Get the width of the textbox in which the text should be rendered + * + * @return */ + public float getTextBoxWidth() + { return textBoxWidth; } + + /** Get the position offset of the text component. * This is relative to its alignment position. - * @return - */ - public Vector2f getOffset() { - return positionOffset; - } - - - /** - * Set the position offset of the text component. + * + * @return */ + public Vector2f getOffset() + { return positionOffset; } + + /** Set the position offset of the text component. * This is relative to its alignment position. + * * @param x - * @param y - */ - public void setOffset(float x, float y) { + * @param y */ + public void setOffset(float x, float y) + { positionOffset.x = x; positionOffset.y = y; } - - /** - * Set the padding for the text component + /** Set the padding for the text component + * * @param top * @param bottom * @param left - * @param right - */ - public void setPadding(float top, float bottom, float left, float right) { + * @param right */ + public void setPadding(float top, float bottom, float left, float right) + { paddingTop = top; paddingBottom = bottom; paddingLeft = left; paddingRight = right; } - - - public float getPaddingTop() { return paddingTop; } - public float getPaddingBottom() { return paddingBottom; } - public float getPaddingLeft() { return paddingLeft; } - public float getPaddingRight() { return paddingRight; } - - - /** - * Check if the text will be clipped to the bounds of the component. + + public float getPaddingTop() + { return paddingTop; } + + public float getPaddingBottom() + { return paddingBottom; } + + public float getPaddingLeft() + { return paddingLeft; } + + public float getPaddingRight() + { return paddingRight; } + + /** Check if the text will be clipped to the bounds of the component. * By default this is set to true. - * @return - */ - public boolean isClipText() { - return clipText; - } - - - /** - * Set whether the text will be clipped to the bounds of the component. - * @param clipText - */ - public void setClipText(boolean clipText) { - this.clipText = clipText; - } - - - /** - * Set the alignment of the text to render. - * The alignment tag can be used by the + * + * @return */ + public boolean isClipText() + { return clipText; } + + /** Set whether the text will be clipped to the bounds of the component. + * + * @param clipText */ + public void setClipText(boolean clipText) + { this.clipText = clipText; } + + /** Set the alignment of the text to render. + * The alignment tag can be used by the * renderer to specify the text alignment, * but it can be ignored. - * @param alignment - */ - public void setAlignment(ETextAlignment alignment) { - this.alignment = alignment; - } - - /** - * Get the alignment of the text. - * @return - */ - public ETextAlignment getAlignment() { - return alignment; - } - - /** - * Get the button text - * @return - */ - public String getText() { - return text; - } - - /** - * Set the button text - * @param text - */ - public void setText(String text) { - this.text = text; - } - - /** - * Append some text to the current text - * @param text - */ - public void appendText(String text) { - this.text += text; - } - - /** - * Get the name of the font used to render the text - * @return - */ - public String getFontName() { - return fontName; - } - - /** - * Set the name of the font used to render the text - * @param font - */ - public void setFontName(String font) { - this.fontName = font; - } - - /** - * Get the colour of the text - * @return - */ - public Vector4f getTextColour() { - return textColour; - } - - /** - * Set the colour of the text + * + * @param alignment */ + public void setAlignment(ETextAlignment alignment) + { this.alignment = alignment; } + + /** Get the alignment of the text. + * + * @return */ + public ETextAlignment getAlignment() + { return alignment; } + + /** Get the button text + * + * @return */ + public String getText() + { return text; } + + /** Set the button text + * + * @param text */ + public void setText(String text) + { this.text = text; } + + /** Append some text to the current text + * + * @param text */ + public void appendText(String text) + { this.text += text; } + + /** Get the name of the font used to render the text + * + * @return */ + public String getFontName() + { return fontName; } + + /** Set the name of the font used to render the text + * + * @param font */ + public void setFontName(String font) + { this.fontName = font; } + + /** Get the colour of the text + * + * @return */ + public Vector4f getTextColour() + { return textColour; } + + /** Set the colour of the text + * * @param r * @param g * @param b - * @param a - */ - public void setTextColour(float r, float g, float b, float a) { + * @param a */ + public void setTextColour(float r, float g, float b, float a) + { this.textColour.x = r; this.textColour.y = g; this.textColour.z = b; this.textColour.w = a; } - - /** - * Get the text size - * @return - */ - public float getTextSize() { - return textSize; - } - - /** - * Get the absolute text size (unmodified by screen scaling) - * @return - */ - public float getAbsoluteTextSize() { - return absoluteTextSize; - } - - /** - * Set the absolute text size - * @param size - */ - public void setTextSize(float size) { - this.absoluteTextSize = size; - } - - /** - * Check if the text component should be scaled according to its parent. + + /** Get the text size + * + * @return */ + public float getTextSize() + { return textSize; } + + /** Get the absolute text size (unmodified by screen scaling) + * + * @return */ + public float getAbsoluteTextSize() + { return absoluteTextSize; } + + /** Set the absolute text size + * + * @param size */ + public void setTextSize(float size) + { this.absoluteTextSize = size; } + + /** Check if the text component should be scaled according to its parent. * Default is true. - * @return - */ - public boolean scale() { - return scale; - } + * + * @return */ + public boolean scale() + { return scale; } } diff --git a/src/com/bwyap/engine/gui/element/properties/VectorShapeColourProperties.java b/src/com/bwyap/engine/gui/element/properties/VectorShapeColourProperties.java index 7d4ffae..b9e061b 100644 --- a/src/com/bwyap/engine/gui/element/properties/VectorShapeColourProperties.java +++ b/src/com/bwyap/engine/gui/element/properties/VectorShapeColourProperties.java @@ -2,22 +2,19 @@ import org.joml.Vector4f; - -/** - * A class that holds the colours that - * should be used to render a GUI element. - * @author bwyap - * - */ -public class VectorShapeColourProperties implements GUIProperty { - +/** A class that holds the colours that + * should be used to render a GUI element. + * + * @author bwyap */ +public class VectorShapeColourProperties implements GUIProperty +{ public final Vector4f colour, mouseoverColour, mouseDownColour, selectedColour; public final Vector4f borderColour, borderMouseoverColour; public boolean hasBorder; public float borderWidth; - - public VectorShapeColourProperties() { + public VectorShapeColourProperties() + { colour = new Vector4f(0.4f, 0.4f, 0.4f, 1.0f); mouseoverColour = new Vector4f(0.5f, 0.5f, 0.5f, 1.0f); mouseDownColour = new Vector4f(0.6f, 0.6f, 0.6f, 0.95f); @@ -26,218 +23,184 @@ public VectorShapeColourProperties() { borderMouseoverColour = new Vector4f(0.9f, 0.9f, 0.9f, 1.0f); borderWidth = 3.0f; } - - - /** - * Set the colour of the shape + + /** Set the colour of the shape + * * @param r * @param g * @param b - * @param a - */ - public void setColour(float r, float g, float b, float a) { + * @param a */ + public void setColour(float r, float g, float b, float a) + { this.colour.x = r; this.colour.y = g; this.colour.z = b; this.colour.w = a; } - - /** - * Set the colour of the shape - * @param colour - */ - public void setColour(Vector4f colour) { - setColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the shape - * @return - */ - public Vector4f getColour() { - return colour; - } - - /** - * Set the colour of the shape when it is selected + + /** Set the colour of the shape + * + * @param colour */ + public void setColour(Vector4f colour) + { setColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the shape + * + * @return */ + public Vector4f getColour() + { return colour; } + + /** Set the colour of the shape when it is selected + * * @param r * @param g * @param b - * @param a - */ - public void setSelectedColour(float r, float g, float b, float a) { + * @param a */ + public void setSelectedColour(float r, float g, float b, float a) + { this.selectedColour.x = r; this.selectedColour.y = g; this.selectedColour.z = b; this.selectedColour.w = a; } - - /** - * Set the colour of the shape when it is selected - * @param colour - */ - public void setSelectedColour(Vector4f colour) { - setSelectedColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the shape - * @return - */ - public Vector4f getSelectedColour() { - return selectedColour; - } - - /** - * Set the colour of the shape when the mouse is over it + + /** Set the colour of the shape when it is selected + * + * @param colour */ + public void setSelectedColour(Vector4f colour) + { setSelectedColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the shape + * + * @return */ + public Vector4f getSelectedColour() + { return selectedColour; } + + /** Set the colour of the shape when the mouse is over it + * * @param r * @param g * @param b - * @param a - */ - public void setMouseoverColour(float r, float g, float b, float a) { + * @param a */ + public void setMouseoverColour(float r, float g, float b, float a) + { this.mouseoverColour.x = r; this.mouseoverColour.y = g; this.mouseoverColour.z = b; this.mouseoverColour.w = a; - } - - /** - * Set the colour of the shape when the mouse is over it - * @param colour - */ - public void setMouseoverColour(Vector4f colour) { - setMouseoverColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the shape when the mouse is over it - * @return - */ - public Vector4f getMouseoverColour() { - return mouseoverColour; } - - /** - * Set the colour of the shape when the mouse is pressing it + + /** Set the colour of the shape when the mouse is over it + * + * @param colour */ + public void setMouseoverColour(Vector4f colour) + { setMouseoverColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the shape when the mouse is over it + * + * @return */ + public Vector4f getMouseoverColour() + { return mouseoverColour; } + + /** Set the colour of the shape when the mouse is pressing it + * * @param r * @param g * @param b - * @param a - */ - public void setMouseDownColour(float r, float g, float b, float a) { + * @param a */ + public void setMouseDownColour(float r, float g, float b, float a) + { this.mouseDownColour.x = r; this.mouseDownColour.y = g; this.mouseDownColour.z = b; this.mouseDownColour.w = a; } - - /** - * Set the colour of the shape when the mouse is pressing it - * @param colour - */ - public void setMouseDownColour(Vector4f colour) { - setMouseDownColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the shape when the mouse is pressing it - * @return - */ - public Vector4f getMouseDownColour() { - return mouseDownColour; - } - - /** - * Set the colour of the border + + /** Set the colour of the shape when the mouse is pressing it + * + * @param colour */ + public void setMouseDownColour(Vector4f colour) + { setMouseDownColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the shape when the mouse is pressing it + * + * @return */ + public Vector4f getMouseDownColour() + { return mouseDownColour; } + + /** Set the colour of the border + * * @param r * @param g * @param b - * @param a - */ - public void setBorderColour(float r, float g, float b, float a) { + * @param a */ + public void setBorderColour(float r, float g, float b, float a) + { this.borderColour.x = r; this.borderColour.y = g; this.borderColour.z = b; this.borderColour.w = a; } - - /** - * Set the colour of the border - * @param colour - */ - public void setBorderColour(Vector4f colour) { - setBorderColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the border - * @return - */ - public Vector4f getBorderColour() { - return borderColour; - } - - /** - * Set the colour of the border when the mouse is over the shape + + /** Set the colour of the border + * + * @param colour */ + public void setBorderColour(Vector4f colour) + { setBorderColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the border + * + * @return */ + public Vector4f getBorderColour() + { return borderColour; } + + /** Set the colour of the border when the mouse is over the shape + * * @param r * @param g * @param b - * @param a - */ - public void setBorderMouseoverColour(float r, float g, float b, float a) { + * @param a */ + public void setBorderMouseoverColour(float r, float g, float b, float a) + { this.borderMouseoverColour.x = r; this.borderMouseoverColour.y = g; this.borderMouseoverColour.z = b; this.borderMouseoverColour.w = a; } - - /** - * Set the colour of the border when the mouse is over the shape - * @param colour - */ - public void setBorderMouseoverColour(Vector4f colour) { - setBorderMouseoverColour(colour.x, colour.y, colour.z, colour.w); - } - - /** - * Get the colour of the border when the mouse is over the shape - * @return - */ - public Vector4f getBorderMouseoverColour() { - return borderMouseoverColour; - } - - /** - * Set whether the shape should be rendered with a border - * @param hasBorder - */ - public void setHasBorder(boolean hasBorder) { - this.hasBorder = hasBorder; - } - - /** - * Check if the shape should be rendered with a border - * @return - */ - public boolean hasBorder() { - return hasBorder; - } - - /** - * Set the width of the border - * @param width - */ - public void setBorderWidth(float width) { - this.borderWidth = width; - } - - /** - * Get the width of the border - * @return - */ - public float getBorderWidth() { - return borderWidth; - } - + + /** Set the colour of the border when the mouse is over the shape + * + * @param colour */ + public void setBorderMouseoverColour(Vector4f colour) + { setBorderMouseoverColour(colour.x, colour.y, colour.z, colour.w); } + + /** Get the colour of the border when the mouse is over the shape + * + * @return */ + public Vector4f getBorderMouseoverColour() + { return borderMouseoverColour; } + + /** Set whether the shape should be rendered with a border + * + * @param hasBorder */ + public void setHasBorder(boolean hasBorder) + { this.hasBorder = hasBorder; } + + /** Check if the shape should be rendered with a border + * + * @return */ + public boolean hasBorder() + { return hasBorder; } + + /** Set the width of the border + * + * @param width */ + public void setBorderWidth(float width) + { this.borderWidth = width; } + + /** Get the width of the border + * + * @return */ + public float getBorderWidth() + { return borderWidth; } } diff --git a/src/com/bwyap/engine/gui/element/vector/EVectorShape.java b/src/com/bwyap/engine/gui/element/vector/EVectorShape.java index f772366..c21eaf9 100644 --- a/src/com/bwyap/engine/gui/element/vector/EVectorShape.java +++ b/src/com/bwyap/engine/gui/element/vector/EVectorShape.java @@ -1,10 +1,9 @@ package com.bwyap.engine.gui.element.vector; -/** - * A vector shape which can be drawn by the graphics rendering system. - * @author bwyap - * - */ -public enum EVectorShape { +/** A vector shape which can be drawn by the graphics rendering system. + * + * @author bwyap */ +public enum EVectorShape +{ RECTANGLE, ROUNDED_RECT, ELLIPSE; } diff --git a/src/com/bwyap/engine/gui/element/vector/SolidVectorProgressBar.java b/src/com/bwyap/engine/gui/element/vector/SolidVectorProgressBar.java index 3277ba8..f4410e5 100644 --- a/src/com/bwyap/engine/gui/element/vector/SolidVectorProgressBar.java +++ b/src/com/bwyap/engine/gui/element/vector/SolidVectorProgressBar.java @@ -4,41 +4,34 @@ import com.bwyap.engine.gui.element.base.ProgressBar; - -/** - * A vector drawn progress bar that is filled with a solid colour. +/** A vector drawn progress bar that is filled with a solid colour. * See {@link ProgressBar}. - * @author bwyap - * - */ -public abstract class SolidVectorProgressBar extends VectorProgressBar { - + * + * @author bwyap */ +public abstract class SolidVectorProgressBar extends VectorProgressBar +{ private final Vector4f fillColour; - - public SolidVectorProgressBar(float x, float y, float width, float height) { + public SolidVectorProgressBar(float x, float y, float width, float height) + { super(x, y, width, height); fillColour = new Vector4f(0.0f, 0.8f, 0.1f, 1.0f); } - - - /** - * Set the fill colour of the progress bar - * @param fillColour - */ - public void setFillColour(Vector4f fillColour) { - this.fillColour.x = fillColour.x; - this.fillColour.y = fillColour.y; - this.fillColour.z = fillColour.z; - this.fillColour.w = fillColour.w; - } - - - /** - * Get the fill colour of the progress bar - * @return - */ - public Vector4f getFillColour() { - return fillColour; + + /** Set the fill colour of the progress bar + * + * @param fillColour */ + public void setFillColour(Vector4f fillColour) + { + this.fillColour.x = fillColour.x; + this.fillColour.y = fillColour.y; + this.fillColour.z = fillColour.z; + this.fillColour.w = fillColour.w; } + + /** Get the fill colour of the progress bar + * + * @return */ + public Vector4f getFillColour() + { return fillColour; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorButton.java b/src/com/bwyap/engine/gui/element/vector/VectorButton.java index 0e02812..9d8895d 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorButton.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorButton.java @@ -4,35 +4,30 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; -/** - * A button that is rendered using the graphics rendering system. +/** A button that is rendered using the graphics rendering system. * It can be one of the shapes as enumerated by {@code ButtonShape}. * See {@link Button}. - * @author bwyap - * - */ -public abstract class VectorButton extends Button implements IColouredVectorShape { - - protected final VectorShapeColourProperties colours; - - /** - * A button is given default mouseOver, mouseDown, border and borderMouseover colours. + * + * @author bwyap */ +public abstract class VectorButton extends Button implements IColouredVectorShape +{ + protected final VectorShapeColourProperties colours; + + /** A button is given default mouseOver, mouseDown, border and borderMouseover colours. * Initially the value of {@code hasBorder} is false. + * * @param x * @param y * @param width * @param height - * @param shape - */ - public VectorButton(float x, float y, float width, float height) { + * @param shape */ + public VectorButton(float x, float y, float width, float height) + { super(x, y, width, height); this.colours = new VectorShapeColourProperties(); } - - + @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } - + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorCheckBox.java b/src/com/bwyap/engine/gui/element/vector/VectorCheckBox.java index 5bb3f91..9a6622c 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorCheckBox.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorCheckBox.java @@ -6,32 +6,28 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; - -/** - * A vector drawn check box. +/** A vector drawn check box. * See {@link CheckBox}. - * @author bwyap - * - */ -public abstract class VectorCheckBox extends CheckBox implements IColouredVectorShape { - - /** - * Style to use to indicate a checked check box. - * @author bwyap - */ - public enum CheckBoxCheckStyle { + * + * @author bwyap */ +public abstract class VectorCheckBox extends CheckBox implements IColouredVectorShape +{ + /** Style to use to indicate a checked check box. + * + * @author bwyap */ + public enum CheckBoxCheckStyle + { TICK, CROSS, DOT, NONE; } - + protected final VectorShapeColourProperties colours; - private CheckBoxCheckStyle checkStyle; private float checkStrokeWidth; private float checkPadding; private final Vector4f checkColour; - - - public VectorCheckBox(float x, float y, float width, float height, CheckBoxCheckStyle style) { + + public VectorCheckBox(float x, float y, float width, float height, CheckBoxCheckStyle style) + { super(x, y, width, height); this.colours = new VectorShapeColourProperties(); this.checkColour = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f); @@ -39,106 +35,76 @@ public VectorCheckBox(float x, float y, float width, float height, CheckBoxCheck this.checkStrokeWidth = 2f; this.checkPadding = 3f; } - - - public VectorCheckBox(float x, float y, float width, float height) { - this(x, y, width, height, CheckBoxCheckStyle.TICK); - } - - - /** - * Get the check style of the check box - * @return - */ - public CheckBoxCheckStyle getCheckStyle() { - return checkStyle; - } - - - /** - * Set the check style of the check box - * @return - */ - public void setCheckStyle(CheckBoxCheckStyle style) { - this.checkStyle = style; - } - - - /** - * Get the stroke width of the check mark - * @return - */ - public float getCheckStrokeWidth() { - return checkStrokeWidth; - } - - - /** - * Set the stroke width of the check mark - * @param checkStrokeWidth - */ - public void setCheckStrokeWidth(float checkStrokeWidth) { - this.checkStrokeWidth = checkStrokeWidth; - } - - - /** - * Get the amount of padding the check mark has from the edge of the check box - * @return - */ - public float getCheckPadding() { - return checkPadding; - } - - - /** - * Set the amount of padding the check mark has from the edge of the check box - * @param style - */ - public void setCheckPadding(float checkPadding) { - this.checkPadding = checkPadding; - } - - - /** - * Get the colour of the check mark - * @return - */ - public Vector4f getCheckColour() { - return checkColour; - } - - - /** - * Set the colour of the check mark + + public VectorCheckBox(float x, float y, float width, float height) + { this(x, y, width, height, CheckBoxCheckStyle.TICK); } + + /** Get the check style of the check box + * + * @return */ + public CheckBoxCheckStyle getCheckStyle() + { return checkStyle; } + + /** Set the check style of the check box + * + * @return */ + public void setCheckStyle(CheckBoxCheckStyle style) + { this.checkStyle = style; } + + /** Get the stroke width of the check mark + * + * @return */ + public float getCheckStrokeWidth() + { return checkStrokeWidth; } + + /** Set the stroke width of the check mark + * + * @param checkStrokeWidth */ + public void setCheckStrokeWidth(float checkStrokeWidth) + { this.checkStrokeWidth = checkStrokeWidth; } + + /** Get the amount of padding the check mark has from the edge of the check box + * + * @return */ + public float getCheckPadding() + { return checkPadding; } + + /** Set the amount of padding the check mark has from the edge of the check box + * + * @param style */ + public void setCheckPadding(float checkPadding) + { this.checkPadding = checkPadding; } + + /** Get the colour of the check mark + * + * @return */ + public Vector4f getCheckColour() + { return checkColour; } + + /** Set the colour of the check mark + * * @param r * @param g * @param b - * @param a - */ - public void setCheckColour(float r, float g, float b, float a) { + * @param a */ + public void setCheckColour(float r, float g, float b, float a) + { checkColour.x = r; checkColour.y = g; checkColour.z = b; checkColour.w = a; } - - - /** - * Set the colour of the check mark + + /** Set the colour of the check mark + * * @param r * @param g * @param b - * @param a - */ - public void setCheckColour(Vector4f colour) { - setCheckColour(colour.x, colour.y, colour.z, colour.w); - } - - - @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } + * @param a */ + public void setCheckColour(Vector4f colour) + { setCheckColour(colour.x, colour.y, colour.z, colour.w); } + @Override + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorProgressBar.java b/src/com/bwyap/engine/gui/element/vector/VectorProgressBar.java index 421eb8a..0a2f752 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorProgressBar.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorProgressBar.java @@ -6,28 +6,22 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; - -/** - * A Vector drawn progress bar. +/** A Vector drawn progress bar. * See {@link ProgressBar}. - * @author bwyap - * - */ -public abstract class VectorProgressBar extends ProgressBar implements IColouredVectorShape { - + * + * @author bwyap */ +public abstract class VectorProgressBar extends ProgressBar implements IColouredVectorShape +{ private final VectorShapeColourProperties colours; - - - public VectorProgressBar(float x, float y, float width, float height) { + + public VectorProgressBar(float x, float y, float width, float height) + { super(x, y, width, height); colours = new VectorShapeColourProperties(); colours.setColour(new Vector4f(0.0f, 0.0f, 0.0f, 1.0f)); } - - + @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } - + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorRadioButton.java b/src/com/bwyap/engine/gui/element/vector/VectorRadioButton.java index eba2df5..03c2719 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorRadioButton.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorRadioButton.java @@ -6,93 +6,74 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; - -/** - * A vector drawn radio button. +/** A vector drawn radio button. * See {@link RadioButton}. - * @author bwyap - * - */ -public abstract class VectorRadioButton extends RadioButton implements IColouredVectorShape { - + * + * @author bwyap */ +public abstract class VectorRadioButton extends RadioButton implements IColouredVectorShape +{ protected final VectorShapeColourProperties colours; - private final Vector4f checkColour; private float checkPadding; - public VectorRadioButton(String name, float x, float y, float width, float height) { + public VectorRadioButton(String name, float x, float y, float width, float height) + { super(name, x, y, width, height); this.colours = new VectorShapeColourProperties(); this.checkColour = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f); this.checkPadding = 4f; } - - - public VectorRadioButton(float x, float y, float width, float height) { + + public VectorRadioButton(float x, float y, float width, float height) + { super(x, y, width, height); this.colours = new VectorShapeColourProperties(); this.checkColour = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f); this.checkPadding = 4f; } - - /** - * Get the amount of padding between the check mark and the edge of the button - * @return - */ - public float getCheckPadding() { - return checkPadding; - } - - - /** - * Set the amount of padding between the check mark and the edge of the button - * @return - */ - public void setCheckPadding(float checkPadding) { - this.checkPadding = checkPadding; - } - - - /** - * Get the colour of the check mark - * @return - */ - public Vector4f getCheckColour() { - return checkColour; - } - - - /** - * Set the colour of the check mark + /** Get the amount of padding between the check mark and the edge of the button + * + * @return */ + public float getCheckPadding() + { return checkPadding; } + + /** Set the amount of padding between the check mark and the edge of the button + * + * @return */ + public void setCheckPadding(float checkPadding) + { this.checkPadding = checkPadding; } + + /** Get the colour of the check mark + * + * @return */ + public Vector4f getCheckColour() + { return checkColour; } + + /** Set the colour of the check mark + * * @param r * @param g * @param b - * @param a - */ - public void setCheckColour(float r, float g, float b, float a) { + * @param a */ + public void setCheckColour(float r, float g, float b, float a) + { checkColour.x = r; checkColour.y = g; checkColour.z = b; checkColour.w = a; } - - - /** - * Set the colour of the check mark + + /** Set the colour of the check mark + * * @param r * @param g * @param b - * @param a - */ - public void setCheckColour(Vector4f colour) { - setCheckColour(colour.x, colour.y, colour.z, colour.w); - } - - + * @param a */ + public void setCheckColour(Vector4f colour) + { setCheckColour(colour.x, colour.y, colour.z, colour.w); } + @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } - + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorScrollArea.java b/src/com/bwyap/engine/gui/element/vector/VectorScrollArea.java index 1a56d98..cf7a45f 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorScrollArea.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorScrollArea.java @@ -4,26 +4,21 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; -/** - * A scroll area with a vector drawn background. +/** A scroll area with a vector drawn background. * See {@link ScrollArea}. - * @author bwyap - * - */ -public abstract class VectorScrollArea extends ScrollArea implements IColouredVectorShape { - - protected final VectorShapeColourProperties colours; - - - public VectorScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection) { + * + * @author bwyap */ +public abstract class VectorScrollArea extends ScrollArea implements IColouredVectorShape +{ + protected final VectorShapeColourProperties colours; + + public VectorScrollArea(float x, float y, float width, float height, float scrollLength, ScrollDirection scrollDirection) + { super(x, y, width, height, scrollLength, scrollDirection); this.colours = new VectorShapeColourProperties(); } - - - @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } + @Override + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorTextBox.java b/src/com/bwyap/engine/gui/element/vector/VectorTextBox.java index 5b06b20..85d3e5e 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorTextBox.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorTextBox.java @@ -4,26 +4,21 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; - -/** - * A text box with a vector drawn background. +/** A text box with a vector drawn background. * See {@link TextBox}. - * @author bwyap - * - */ -public abstract class VectorTextBox extends TextBox implements IColouredVectorShape { - + * + * @author bwyap */ +public abstract class VectorTextBox extends TextBox implements IColouredVectorShape +{ protected final VectorShapeColourProperties colours; - - public VectorTextBox(float x, float y, float width, float height, float padding) { + + public VectorTextBox(float x, float y, float width, float height, float padding) + { super(x, y, width, height, padding); this.colours = new VectorShapeColourProperties(); } - @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } - + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/element/vector/VectorTextField.java b/src/com/bwyap/engine/gui/element/vector/VectorTextField.java index 05debe5..775e8bb 100644 --- a/src/com/bwyap/engine/gui/element/vector/VectorTextField.java +++ b/src/com/bwyap/engine/gui/element/vector/VectorTextField.java @@ -4,25 +4,21 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; import com.bwyap.engine.gui.interfaces.IColouredVectorShape; -/** - * A text field with a vector drawn background. +/** A text field with a vector drawn background. * See {@link TextField}. - * @author bwyap - * - */ -public abstract class VectorTextField extends TextField implements IColouredVectorShape { + * + * @author bwyap */ +public abstract class VectorTextField extends TextField implements IColouredVectorShape +{ + protected final VectorShapeColourProperties colours; - protected final VectorShapeColourProperties colours; - - public VectorTextField(int x, int y, float width, float height) { + public VectorTextField(int x, int y, float width, float height) + { super(x, y, width, height); this.colours = new VectorShapeColourProperties(); } - - + @Override - public VectorShapeColourProperties colourProperties() { - return colours; - } - + public VectorShapeColourProperties colourProperties() + { return colours; } } diff --git a/src/com/bwyap/engine/gui/interfaces/GUIBoundsInterface.java b/src/com/bwyap/engine/gui/interfaces/GUIBoundsInterface.java index 81c430f..5b49608 100644 --- a/src/com/bwyap/engine/gui/interfaces/GUIBoundsInterface.java +++ b/src/com/bwyap/engine/gui/interfaces/GUIBoundsInterface.java @@ -2,63 +2,45 @@ import com.bwyap.engine.window.BoundsInterface; -/** - * Provides methods that a GUI element with bounds should implement. - * @author bwyap - * - */ -public interface GUIBoundsInterface extends BoundsInterface { - - - /** - * Check if a specified co-ordinate is within the bounds of this element - * @param x - * @param y - * @return - */ +/** Provides methods that a GUI element with bounds should implement. + * + * @author bwyap */ +public interface GUIBoundsInterface extends BoundsInterface +{ + /** Check if a specified co-ordinate is within the bounds of this element + * + * @param x + * @param y + * @return */ public boolean withinBounds(float x, float y); - - - /** - * Get the width of the element - * @return - */ + + /** Get the width of the element + * + * @return */ public float getWidth(); - - - /** - * Get the height of this element - * @return - */ + + /** Get the height of this element + * + * @return */ public float getHeight(); - - /** - * Get the padding amount for the top of the element - * @return - */ + /** Get the padding amount for the top of the element + * + * @return */ public float getPaddingTop(); - - - /** - * Get the padding amount for the bottom of the element - * @return - */ + + /** Get the padding amount for the bottom of the element + * + * @return */ public float getPaddingBottom(); - - - /** - * Get the padding amount for the left of the element - * @return - */ + + /** Get the padding amount for the left of the element + * + * @return */ public float getPaddingLeft(); - - - /** - * Get the padding amount for the right of the element - * @return - */ + + /** Get the padding amount for the right of the element + * + * @return */ public float getPaddingRight(); - - } diff --git a/src/com/bwyap/engine/gui/interfaces/GUIElementInterface.java b/src/com/bwyap/engine/gui/interfaces/GUIElementInterface.java index 5c14b43..893365d 100644 --- a/src/com/bwyap/engine/gui/interfaces/GUIElementInterface.java +++ b/src/com/bwyap/engine/gui/interfaces/GUIElementInterface.java @@ -5,149 +5,114 @@ import com.bwyap.engine.input.InputHandler; import com.bwyap.engine.window.BoundsInterface; - -/** - *+/**
* Methods that all GUI elements should implement. *
** Uses the {@code JOML} library for Vector operations. *
- * @author bwyap - * - */ -public interface GUIElementInterface extends GUIBoundsInterface { - - - /** - * Update the GUI element - * @param timestep - */ + * + * @author bwyap */ +public interface GUIElementInterface extends GUIBoundsInterface +{ + /** Update the GUI element + * + * @param timestep */ public void update(float timestep); - - - /** - * Handle how the GUI element should respond to input. - * @param window - */ + + /** Handle how the GUI element should respond to input. + * + * @param window */ public void handleInput(InputHandler input, GUIBoundsInterface bounds); - - - /** - * Update the GUI element's position and bounds according to the bounding window. - * This method should be called before the element is rendered. - */ + + /** Update the GUI element's position and bounds according to the bounding window. + * This method should be called before the element is rendered. */ public void updateBounds(BoundsInterface window, Vector2f parent); - - - /** - * Set the absolute position of the GUI element. + + /** Set the absolute position of the GUI element. * Co-ordinates are in screen co-ordinates. + * * @param x - * @param y - */ + * @param y */ public void setPosition(float x, float y); - - - /** - * Set the absolute position of the GUI element. + + /** Set the absolute position of the GUI element. * Co-ordinates are in screen co-ordinates. + * * @param x - * @param y - */ + * @param y */ public void setPosition(Vector2f position); - - /** - * Set the padding for the panel + /** Set the padding for the panel + * * @param top * @param bottom * @param left - * @param right - */ + * @param right */ public void setPadding(float top, float bottom, float left, float right); - - - /** - * Set the bounds of this GUI element using a rectangle. + + /** Set the bounds of this GUI element using a rectangle. * By default a GUI element will use rectangular bounds * unless otherwise specified with the {@code useCircularBounds} * method. - * @param x offset from the element's x position - * @param y offset from the element's y position - * @param width width of the bounds - * @param height height of the bounds - */ + * + * @param x offset from the element's x position + * @param y offset from the element's y position + * @param width width of the bounds + * @param height height of the bounds */ public void setBounds(float x, float y, float width, float height); - - - /** - * Set the bounds of this GUI element using a rectangle. + + /** Set the bounds of this GUI element using a rectangle. * The offset of the bounds is set to (0, 0). - * @param width width of the bounds - * @param height height of the bounds - */ + * + * @param width width of the bounds + * @param height height of the bounds */ public void setBounds(float width, float height); - - - /** - * Checks if the given screen co-ordinates are within + + /** Checks if the given screen co-ordinates are within * the set bounds of this GUI element. The element could * be using rectangular bounds or circular bounds - which - * can be set using the {@code setRectangularBounds} or + * can be set using the {@code setRectangularBounds} or * {@code setCircularBounds} method. - * @param x - * @param y - * @return true if the given co-ordinates are within bounds of the GUI element - */ + * + * @param x + * @param y + * @return true if the given co-ordinates are within bounds of the GUI element */ public boolean withinBounds(float x, float y); - - - /** - * Set the GUI element to be enabled or disabled. - * @param enabled - */ + + /** Set the GUI element to be enabled or disabled. + * + * @param enabled */ public void setEnabled(boolean enabled); - - - /** - *Check if the GUI element is currently enabled.
+ + /**Check if the GUI element is currently enabled.
** A disabled GUI element cannot be activated * (It should have a different texture to indicate its state to the user). *
- * @return - */ + * + * @return */ public boolean isEnabled(); - - - /** - * Set whether the GUI element's position should be absolute. - * @param absolute - */ + + /** Set whether the GUI element's position should be absolute. + * + * @param absolute */ public void setPositionAbsolute(boolean absolute); - - - /** - * Check if the GUI element's position is absolute. + + /** Check if the GUI element's position is absolute. * Default is false. - * @return - */ + * + * @return */ public boolean isPositionAbsolute(); - - - /** - * Set whether the GUI element's scale should be absolute. - * @param absolute - */ + + /** Set whether the GUI element's scale should be absolute. + * + * @param absolute */ public void setScaleAbsolute(boolean absolute); - - - /** - * Check if the GUI element's scale is absolute. + + /** Check if the GUI element's scale is absolute. * Default is false. - * @return - */ + * + * @return */ public boolean isScaleAbsolute(); - } diff --git a/src/com/bwyap/engine/gui/interfaces/IColouredVectorShape.java b/src/com/bwyap/engine/gui/interfaces/IColouredVectorShape.java index 21def0b..998e0b3 100644 --- a/src/com/bwyap/engine/gui/interfaces/IColouredVectorShape.java +++ b/src/com/bwyap/engine/gui/interfaces/IColouredVectorShape.java @@ -2,12 +2,10 @@ import com.bwyap.engine.gui.element.properties.VectorShapeColourProperties; -public interface IColouredVectorShape extends IVectorShape { - - /** - * Gets the VectorShapeColour object for this GUI element - * @return - */ +public interface IColouredVectorShape extends IVectorShape +{ + /** Gets the VectorShapeColour object for this GUI element + * + * @return */ public VectorShapeColourProperties colourProperties(); - } diff --git a/src/com/bwyap/engine/gui/interfaces/IFade.java b/src/com/bwyap/engine/gui/interfaces/IFade.java index 7cc8f0f..33ad5e7 100644 --- a/src/com/bwyap/engine/gui/interfaces/IFade.java +++ b/src/com/bwyap/engine/gui/interfaces/IFade.java @@ -2,13 +2,10 @@ import com.bwyap.engine.gui.element.properties.Fade; -public interface IFade { - - - /** - * Get the fade property of the GUI element - * @return - */ +public interface IFade +{ + /** Get the fade property of the GUI element + * + * @return */ public Fade getFade(); - } diff --git a/src/com/bwyap/engine/gui/interfaces/ISelectable.java b/src/com/bwyap/engine/gui/interfaces/ISelectable.java index 6e418ad..09b5871 100644 --- a/src/com/bwyap/engine/gui/interfaces/ISelectable.java +++ b/src/com/bwyap/engine/gui/interfaces/ISelectable.java @@ -1,24 +1,19 @@ package com.bwyap.engine.gui.interfaces; -public interface ISelectable { - - /** - * Check whether the GUI element has been selected - * @return - */ +public interface ISelectable +{ + /** Check whether the GUI element has been selected + * + * @return */ public boolean isSelected(); - - - /** - * Set whether the GUI element is currently selectable - * @param selectable - */ + + /** Set whether the GUI element is currently selectable + * + * @param selectable */ public void setSelectable(boolean selectable); - - - /** - * Check whether he GUI element is currently selectable - * @return - */ + + /** Check whether he GUI element is currently selectable + * + * @return */ public boolean isSelectable(); } diff --git a/src/com/bwyap/engine/gui/interfaces/ITextDisplay.java b/src/com/bwyap/engine/gui/interfaces/ITextDisplay.java index 5e98f4d..946cf68 100644 --- a/src/com/bwyap/engine/gui/interfaces/ITextDisplay.java +++ b/src/com/bwyap/engine/gui/interfaces/ITextDisplay.java @@ -2,17 +2,13 @@ import com.bwyap.engine.gui.element.properties.TextComponent; -/** - * Indicates that a GUI element has text which can be displayed - * @author bwyap - * - */ -public interface ITextDisplay { - - /** - * Get the text component - * @return - */ +/** Indicates that a GUI element has text which can be displayed + * + * @author bwyap */ +public interface ITextDisplay +{ + /** Get the text component + * + * @return */ public TextComponent getTextComponent(); - } diff --git a/src/com/bwyap/engine/gui/interfaces/IVectorEllipse.java b/src/com/bwyap/engine/gui/interfaces/IVectorEllipse.java index 5ed0203..59ad91f 100644 --- a/src/com/bwyap/engine/gui/interfaces/IVectorEllipse.java +++ b/src/com/bwyap/engine/gui/interfaces/IVectorEllipse.java @@ -2,10 +2,9 @@ import com.bwyap.engine.gui.element.vector.EVectorShape; -public interface IVectorEllipse extends IVectorShape { - +public interface IVectorEllipse extends IVectorShape +{ @Override - default public EVectorShape getShape() { - return EVectorShape.ELLIPSE; - } + default public EVectorShape getShape() + { return EVectorShape.ELLIPSE; } } diff --git a/src/com/bwyap/engine/gui/interfaces/IVectorRect.java b/src/com/bwyap/engine/gui/interfaces/IVectorRect.java index fc6cb4a..88ea2b5 100644 --- a/src/com/bwyap/engine/gui/interfaces/IVectorRect.java +++ b/src/com/bwyap/engine/gui/interfaces/IVectorRect.java @@ -2,10 +2,9 @@ import com.bwyap.engine.gui.element.vector.EVectorShape; -public interface IVectorRect extends IVectorShape { - +public interface IVectorRect extends IVectorShape +{ @Override - default public EVectorShape getShape() { - return EVectorShape.RECTANGLE; - } + default public EVectorShape getShape() + { return EVectorShape.RECTANGLE; } } diff --git a/src/com/bwyap/engine/gui/interfaces/IVectorRoundedRect.java b/src/com/bwyap/engine/gui/interfaces/IVectorRoundedRect.java index 10b4707..c628ee3 100644 --- a/src/com/bwyap/engine/gui/interfaces/IVectorRoundedRect.java +++ b/src/com/bwyap/engine/gui/interfaces/IVectorRoundedRect.java @@ -2,18 +2,14 @@ import com.bwyap.engine.gui.element.vector.EVectorShape; -public interface IVectorRoundedRect extends IVectorRect { - - /** - * Get the radius of the rounded corners - * @return - */ +public interface IVectorRoundedRect extends IVectorRect +{ + /** Get the radius of the rounded corners + * + * @return */ public float getRadius(); - @Override - default public EVectorShape getShape() { - return EVectorShape.ROUNDED_RECT; - } - + default public EVectorShape getShape() + { return EVectorShape.ROUNDED_RECT; } } diff --git a/src/com/bwyap/engine/gui/interfaces/IVectorShape.java b/src/com/bwyap/engine/gui/interfaces/IVectorShape.java index 80c8c68..fcc0f81 100644 --- a/src/com/bwyap/engine/gui/interfaces/IVectorShape.java +++ b/src/com/bwyap/engine/gui/interfaces/IVectorShape.java @@ -2,19 +2,14 @@ import com.bwyap.engine.gui.element.vector.EVectorShape; -public interface IVectorShape { - - /** - * Get the shape of this Vector shaped GUI element - */ +public interface IVectorShape +{ + /** Get the shape of this Vector shaped GUI element */ public EVectorShape getShape(); - - - /** - * Check if the shape should be rendered - * @return - */ - default public boolean renderShape() { - return true; - } + + /** Check if the shape should be rendered + * + * @return */ + default public boolean renderShape() + { return true; } } diff --git a/src/com/bwyap/engine/gui/interfaces/MouseDownInterface.java b/src/com/bwyap/engine/gui/interfaces/MouseDownInterface.java index c2455da..fc81a33 100644 --- a/src/com/bwyap/engine/gui/interfaces/MouseDownInterface.java +++ b/src/com/bwyap/engine/gui/interfaces/MouseDownInterface.java @@ -1,36 +1,27 @@ package com.bwyap.engine.gui.interfaces; -public interface MouseDownInterface extends MouseOverInterface { - - - /** - * An action to perform when a specific mouse button is down over the GUI element +public interface MouseDownInterface extends MouseOverInterface +{ + /** An action to perform when a specific mouse button is down over the GUI element + * * @param x * @param y - * @param mouseButton - */ + * @param mouseButton */ public void onMouseDown(float x, float y, int mouseButton); - - - /** - * An action to perform when the GUI element is clicked by a specific mouse button + + /** An action to perform when the GUI element is clicked by a specific mouse button * (mouse down then released) + * * @param x * @param y - * @param mouseButton - */ + * @param mouseButton */ public void onMouseClicked(float x, float y, int mouseButton); - - - /** - * Checks if ANY accepted mouse button is down on the GUI element - */ + + /** Checks if ANY accepted mouse button is down on the GUI element */ public boolean isMouseDown(); - - - /** - * Checks if a specified mouse button is down on the GUI element - * @param mouseButton - */ + + /** Checks if a specified mouse button is down on the GUI element + * + * @param mouseButton */ public boolean isMouseDown(int mouseButton); } diff --git a/src/com/bwyap/engine/gui/interfaces/MouseOverInterface.java b/src/com/bwyap/engine/gui/interfaces/MouseOverInterface.java index 6f72d19..1da0e47 100644 --- a/src/com/bwyap/engine/gui/interfaces/MouseOverInterface.java +++ b/src/com/bwyap/engine/gui/interfaces/MouseOverInterface.java @@ -1,28 +1,21 @@ package com.bwyap.engine.gui.interfaces; -public interface MouseOverInterface { - - - /** - * An action to perform when the mouse is over the GUI element +public interface MouseOverInterface +{ + /** An action to perform when the mouse is over the GUI element + * * @param x - * @param y - */ + * @param y */ public void onMouseOver(float x, float y); - - - /** - * Checks if the mouse is over the GUI element - * @return - */ + + /** Checks if the mouse is over the GUI element + * + * @return */ public boolean isMouseOver(); - - - /** - * Check whether this element reacts to having the mouse over the element. + + /** Check whether this element reacts to having the mouse over the element. * The {@code onMouseClicked} method should still work when {@code mouseOverReact} is {@code false}. - * @return - */ + * + * @return */ public boolean mouseOverReact(); - } diff --git a/src/com/bwyap/engine/input/InputHandler.java b/src/com/bwyap/engine/input/InputHandler.java index cc7d598..e6c3b5f 100644 --- a/src/com/bwyap/engine/input/InputHandler.java +++ b/src/com/bwyap/engine/input/InputHandler.java @@ -1,92 +1,75 @@ package com.bwyap.engine.input; -/** - * Provides methods to poll for input through the +/** Provides methods to poll for input through the * keyboard and mouse. The actual keyboard and mouse * handlers must be updated manually and it is not * a responsibility of this class. - * @author bwyap - * - */ -public class InputHandler implements KeyboardHandlerInterface, MouseHandlerInterface{ - + * + * @author bwyap */ +public class InputHandler implements KeyboardHandlerInterface, MouseHandlerInterface +{ private KeyboardHandlerInterface keyboardHandler; private MouseHandlerInterface mouseHandler; - - - public InputHandler(KeyboardHandlerInterface keyboardHandler, MouseHandlerInterface mouseHandler) { + + public InputHandler(KeyboardHandlerInterface keyboardHandler, MouseHandlerInterface mouseHandler) + { this.keyboardHandler = keyboardHandler; this.mouseHandler = mouseHandler; } - - @Override - public boolean isKeyDown(int keycode) { - return keyboardHandler.isKeyDown(keycode); - } - + @Override - public char consumeLastTypedChar() { - return keyboardHandler.consumeLastTypedChar(); - } - + public boolean isKeyDown(int keycode) + { return keyboardHandler.isKeyDown(keycode); } + @Override - public boolean isMouseDown(int mouseButton) { - return mouseHandler.isMouseDown(mouseButton); - } + public char consumeLastTypedChar() + { return keyboardHandler.consumeLastTypedChar(); } @Override - public boolean isMouseDown() { - return mouseHandler.isMouseDown(); - } + public boolean isMouseDown(int mouseButton) + { return mouseHandler.isMouseDown(mouseButton); } @Override - public double getMouseX() { - return mouseHandler.getMouseX(); - } + public boolean isMouseDown() + { return mouseHandler.isMouseDown(); } @Override - public double getMouseY() { - return mouseHandler.getMouseY(); - } + public double getMouseX() + { return mouseHandler.getMouseX(); } @Override - public boolean isMouseEntered() { - return mouseHandler.isMouseEntered(); - } + public double getMouseY() + { return mouseHandler.getMouseY(); } @Override - public double getMouseScrollX() { - return mouseHandler.getMouseScrollX(); - } + public boolean isMouseEntered() + { return mouseHandler.isMouseEntered(); } @Override - public double consumeMouseScrollX() { - return mouseHandler.consumeMouseScrollX(); - } - + public double getMouseScrollX() + { return mouseHandler.getMouseScrollX(); } + @Override - public double getMouseScrollY() { - return mouseHandler.getMouseScrollY(); - } + public double consumeMouseScrollX() + { return mouseHandler.consumeMouseScrollX(); } @Override - public double consumeMouseScrollY() { - return mouseHandler.consumeMouseScrollY(); - } + public double getMouseScrollY() + { return mouseHandler.getMouseScrollY(); } @Override - public double getLastMouseScrollTime() { - return mouseHandler.getLastMouseScrollTime(); - } + public double consumeMouseScrollY() + { return mouseHandler.consumeMouseScrollY(); } @Override - public int getKeyMods() { - return keyboardHandler.getKeyMods(); - } + public double getLastMouseScrollTime() + { return mouseHandler.getLastMouseScrollTime(); } @Override - public int getKeysDown() { - return keyboardHandler.getKeysDown(); - } + public int getKeyMods() + { return keyboardHandler.getKeyMods(); } + @Override + public int getKeysDown() + { return keyboardHandler.getKeysDown(); } } diff --git a/src/com/bwyap/engine/input/InputMapping.java b/src/com/bwyap/engine/input/InputMapping.java index 9472f06..3691827 100644 --- a/src/com/bwyap/engine/input/InputMapping.java +++ b/src/com/bwyap/engine/input/InputMapping.java @@ -7,75 +7,62 @@ import com.bwyap.utility.resource.JSONWrapper; - -/** - * Provides a configurable mapping of user inputs loaded from an external JSON file - * @author bwyap - * - */ -public final class InputMapping extends JSONWrapper{ - - +/** Provides a configurable mapping of user inputs loaded from an external JSON file + * + * @author bwyap */ +public final class InputMapping extends JSONWrapper +{ private final Map- * If a velocity variance has been set (a value > 0.0f) a + * If a velocity variance has been set (a value > 0.0f) a * slightly varied baseVelocity vector will be returned. - * The direction of the returned vector will depend on + * The direction of the returned vector will depend on * the magnitude of the velocityDirectionVariance. *
*@@ -167,193 +151,165 @@ else if (emitRadius > 0.0f) { * {@code speedVariance}. The value by default is 0 which * will result in no speed variation. A value less than 1.0f * will generate a speed slower than the base velocity, - * while values higher than 1.0f will generate a speed + * while values higher than 1.0f will generate a speed * that is between {@code speedVariance/2} to {@code speedVariance} * times faster than the base velocity speed. - *
- * @return - */ - protected Vector3f generateStartVelocity() { - if (velocityDirectionVariance > 0.0f && baseVelocity.length() > 0) { + * + * + * @return */ + protected Vector3f generateStartVelocity() + { + if (velocityDirectionVariance > 0.0f && baseVelocity.length() > 0) + { float xAngle, yAngle, zAngle; - xAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance/2); - yAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance/2); - zAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance/2); - + xAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance / 2); + yAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance / 2); + zAngle = (rand.nextFloat() * velocityDirectionVariance) - (velocityDirectionVariance / 2); Vector3f velocity = new Vector3f(baseVelocity); Quaternionf rotation = new Quaternionf(); rotation.rotateXYZ(xAngle, yAngle, zAngle); velocity.rotate(rotation); - float speed = baseVelocity.length() * (speedVariance > 0 ? ((speedVariance/2) * rand.nextFloat()) + (speedVariance/2) : 1) ; + float speed = baseVelocity.length() * (speedVariance > 0 ? ((speedVariance / 2) * rand.nextFloat()) + (speedVariance / 2) : 1); return velocity.normalize().mul(speed); } else return baseVelocity; } - - - /** - * Generate a colour for a new particle. + + /** Generate a colour for a new particle. * If no colours have been added, a default colour will be returned. - * @return - */ - protected Vector3f generateColour() { - if (colours.size() == 0) + * + * @return */ + protected Vector3f generateColour() + { + if (colours.size() == 0) return new Vector3f(0.8f, 0.8f, 0.8f); - else + else return colours.get(rand.nextInt(colours.size())); } - - - /** - * Generates a radius for a new particle. - * @return - */ - protected float generateRadius() { - return (rand.nextFloat() * (particleRadiusMax - particleRadiusMin)) + particleRadiusMin; - } - - - /** - * Specify a bounding box within which to emit new particles. + + /** Generates a radius for a new particle. + * + * @return */ + protected float generateRadius() + { return (rand.nextFloat() * (particleRadiusMax - particleRadiusMin)) + particleRadiusMin; } + + /** Specify a bounding box within which to emit new particles. * Centered at the particle system's position. * (EmitBoxBounds take precedence) - * @param boxBounds - */ - public void setEmitBoxBounds(float width, float height) { + * + * @param boxBounds */ + public void setEmitBoxBounds(float width, float height) + { //TODO // } - - - /** - * Set the radius of the sphere within which to emit new particles. + + /** Set the radius of the sphere within which to emit new particles. * Centered at the particle system's position. * (EmitBoxBounds take precedence) - * @param radius - */ - public void setEmitRadius(float radius) { - this.emitRadius = radius; - } - - /** - * Check if the particle system is active and releasing particles - * @return - */ - public boolean isActive() { - return active; - } - - /** - * Set whether the particle system is active - * @param active - */ - public void setActive(boolean active) { + * + * @param radius */ + public void setEmitRadius(float radius) + { this.emitRadius = radius; } + + /** Check if the particle system is active and releasing particles + * + * @return */ + public boolean isActive() + { return active; } + + /** Set whether the particle system is active + * + * @param active */ + public void setActive(boolean active) + { this.active = active; if (!active) currentTime = 0; } - - /** - * Set the position of the particle system - * @param position - */ - public void setPosition(Vector3f position) { - this.position = position; - } - - /** - * Move the position of the particle system + + /** Set the position of the particle system + * + * @param position */ + public void setPosition(Vector3f position) + { this.position = position; } + + /** Move the position of the particle system + * * @param xOffset * @param yOffset - * @param zOffset - */ - public void movePosition(float xOffset, float yOffset, float zOffset) { + * @param zOffset */ + public void movePosition(float xOffset, float yOffset, float zOffset) + { this.position.x += xOffset; this.position.y += yOffset; this.position.z += zOffset; } - - /** - * Get the position of the particle system - * @return - */ - public Vector3f getPosition() { - return position; - } - - /** - * Set the base velocity of particles emitted from this system. - * @param velocity - */ - public void setBaseVelocity(Vector3f velocity) { - this.baseVelocity = velocity; - } - - /** - * Set the particle radius bounds. + + /** Get the position of the particle system + * + * @return */ + public Vector3f getPosition() + { return position; } + + /** Set the base velocity of particles emitted from this system. + * + * @param velocity */ + public void setBaseVelocity(Vector3f velocity) + { this.baseVelocity = velocity; } + + /** Set the particle radius bounds. + * * @param radius - * @param variance - */ - public void setParticleRadius(float radius, float variance) { - particleRadiusMin = radius - variance/2; - particleRadiusMax = radius + variance/2; - } - - /** - * Set the minimum particle radius. - * @param min - */ - public void setParticleRadiusMin(float min) { - particleRadiusMin = min; + * @param variance */ + public void setParticleRadius(float radius, float variance) + { + particleRadiusMin = radius - variance / 2; + particleRadiusMax = radius + variance / 2; } - - /** - * Set the maximum particle radius. - * @param max - */ - public void setParticleRadiusMax(float max) { - particleRadiusMax = max; - } - - /** - * Set the particle lifetime bounds. + + /** Set the minimum particle radius. + * + * @param min */ + public void setParticleRadiusMin(float min) + { particleRadiusMin = min; } + + /** Set the maximum particle radius. + * + * @param max */ + public void setParticleRadiusMax(float max) + { particleRadiusMax = max; } + + /** Set the particle lifetime bounds. + * * @param lifetime - * @param variance - */ - public void setParticleLifetime(float lifetime, float variance) { - particleLifetimeMin = lifetime - variance/2; - particleLifetimeMax = lifetime + variance/2; - } - - /** - * Set the minimum particle lifetime. - * @param min - */ - public void setParticleLifetimeMin(float min) { - particleLifetimeMin = min; - } - - /** - * Set the maximum particle lifetime. - * @param max - */ - public void setParticleLifetimeMax(float max) { - particleLifetimeMax = max; - } - - /** - * Set the velocity direction variance when generating a new particle. - * @param variance - */ - public void setVelocityDirectionVariance(float variance) { - this.velocityDirectionVariance = variance; - } - - /** - * Set the speed variance when generating a new particle. - * @param speed - */ - public void setSpeedVariance(float speed) { - this.speedVariance = speed; + * @param variance */ + public void setParticleLifetime(float lifetime, float variance) + { + particleLifetimeMin = lifetime - variance / 2; + particleLifetimeMax = lifetime + variance / 2; } + /** Set the minimum particle lifetime. + * + * @param min */ + public void setParticleLifetimeMin(float min) + { particleLifetimeMin = min; } + + /** Set the maximum particle lifetime. + * + * @param max */ + public void setParticleLifetimeMax(float max) + { particleLifetimeMax = max; } + + /** Set the velocity direction variance when generating a new particle. + * + * @param variance */ + public void setVelocityDirectionVariance(float variance) + { this.velocityDirectionVariance = variance; } + + /** Set the speed variance when generating a new particle. + * + * @param speed */ + public void setSpeedVariance(float speed) + { this.speedVariance = speed; } } diff --git a/src/com/bwyap/engine/render/Texture.java b/src/com/bwyap/engine/render/Texture.java index e5ca9d0..2bae277 100644 --- a/src/com/bwyap/engine/render/Texture.java +++ b/src/com/bwyap/engine/render/Texture.java @@ -1,62 +1,48 @@ package com.bwyap.engine.render; -/** - *- * An abstract Texture object that holds the ID a loaded texture. - * A texture can also be used as a texture atlas if its rows and - * columns are set in the constructor (by default it has a row - * and col count of 1, which means the texture is not animated). +/**
+ * An abstract Texture object that holds the ID a loaded texture. + * A texture can also be used as a texture atlas if its rows and + * columns are set in the constructor (by default it has a row + * and col count of 1, which means the texture is not animated). *
- * @author bwyap - * - */ -public abstract class Texture { - + * + * @author bwyap */ +public abstract class Texture +{ protected final int textureID; - - protected int rows; protected int cols; - - public Texture(int textureID) { + public Texture(int textureID) + { this.textureID = textureID; this.rows = 1; this.cols = 1; } - - - public Texture(int textureID, int rows, int cols) { + + public Texture(int textureID, int rows, int cols) + { this.textureID = textureID; this.rows = rows; this.cols = cols; } - - - /** - * Get the ID of the texture - * @return - */ - public int getID() { - return textureID; - } - - - /** - * Get the number of rows this texture has if it is a texture atlas. - * @return - */ - public int getRows() { - return rows; - } - - - /** - * Get the number of columns this texture has if it is a texture atlas. - * @return - */ - public int getCols() { - return cols; - } - + + /** Get the ID of the texture + * + * @return */ + public int getID() + { return textureID; } + + /** Get the number of rows this texture has if it is a texture atlas. + * + * @return */ + public int getRows() + { return rows; } + + /** Get the number of columns this texture has if it is a texture atlas. + * + * @return */ + public int getCols() + { return cols; } } diff --git a/src/com/bwyap/engine/render3d/Camera.java b/src/com/bwyap/engine/render3d/Camera.java index e57584c..fe2ad85 100644 --- a/src/com/bwyap/engine/render3d/Camera.java +++ b/src/com/bwyap/engine/render3d/Camera.java @@ -2,9 +2,7 @@ import org.joml.Vector3f; - -/** - *+/**
* The camera is responsible for holding information which determines the point of view * from which the user will see the world and the objects within it. *
@@ -13,24 +11,20 @@ * which will be used to create the appropriate matrices to transform the objects * in the world. * - * @author bwyap - * - */ -public class Camera { - + * + * @author bwyap */ +public class Camera +{ public static final float DEFAULT_FOV = (float) Math.toRadians(60.0f); public static final float DEFAULT_Z_NEAR = 0.01f; public static final float DEFAULT_Z_FAR = 1000.f; - - private boolean dirty; - private final Vector3f position; private final Vector3f rotation; private float zNear, zFar, FOV, aspectRatio; - - - public Camera(float zNear, float zFar, float FOV, float aspectRatio) { + + public Camera(float zNear, float zFar, float FOV, float aspectRatio) + { position = new Vector3f(0, 0, 0); rotation = new Vector3f(0, 0, 0); this.zNear = zNear; @@ -39,9 +33,9 @@ public Camera(float zNear, float zFar, float FOV, float aspectRatio) { this.aspectRatio = aspectRatio; this.dirty = true; } - - - public Camera(Vector3f position, Vector3f rotation, float zNear, float zFar, float FOV, float aspectRatio) { + + public Camera(Vector3f position, Vector3f rotation, float zNear, float zFar, float FOV, float aspectRatio) + { this.position = position; this.rotation = rotation; this.zNear = zNear; @@ -50,128 +44,103 @@ public Camera(Vector3f position, Vector3f rotation, float zNear, float zFar, flo this.aspectRatio = aspectRatio; this.dirty = true; } - - - public void update(float timestep) { - - } - - - /** - * Check if the camera's view has changed since its last update. - * @return - */ - public boolean isDirty() { - return dirty; - } - - - /** - * Set the camera's dirty setting. This should be set to true if the camera's view has changed. - * @param dirty - */ - public void setDirty(boolean dirty) { - this.dirty = dirty; - } - - - /** - * Get the position of the camera - * @return - */ - public Vector3f getPosition() { - return position; - } - - - /** - * Set the camera's position + + public void update(float timestep) + {} + + /** Check if the camera's view has changed since its last update. + * + * @return */ + public boolean isDirty() + { return dirty; } + + /** Set the camera's dirty setting. This should be set to true if the camera's view has changed. + * + * @param dirty */ + public void setDirty(boolean dirty) + { this.dirty = dirty; } + + /** Get the position of the camera + * + * @return */ + public Vector3f getPosition() + { return position; } + + /** Set the camera's position + * * @param x * @param y - * @param z - */ - public void setPosition(float x, float y, float z) { + * @param z */ + public void setPosition(float x, float y, float z) + { position.x = x; position.y = y; position.z = z; dirty = true; } - - - /** - * Move the camera's position in the direction it is pointed + + /** Move the camera's position in the direction it is pointed + * * @param xOffset * @param yOffset - * @param zOffset - */ - public void movePosition(float xOffset, float yOffset, float zOffset) { - if (zOffset != 0) { + * @param zOffset */ + public void movePosition(float xOffset, float yOffset, float zOffset) + { + if (zOffset != 0) + { position.x += (float) Math.sin(Math.toRadians(rotation.y)) * -1.0f * zOffset; position.z += (float) Math.cos(Math.toRadians(rotation.y)) * zOffset; } - - if (xOffset != 0) { + if (xOffset != 0) + { position.x += (float) Math.sin(Math.toRadians(rotation.y - 90)) * -1.0f * xOffset; position.z += (float) Math.cos(Math.toRadians(rotation.y - 90)) * xOffset; } - position.y += yOffset; - dirty = true; } - - - /** - * Get the rotation of the camera - * @return - */ - public Vector3f getRotation() { - return rotation; - } - - - /** - * Set the rotation of the camera + + /** Get the rotation of the camera + * + * @return */ + public Vector3f getRotation() + { return rotation; } + + /** Set the rotation of the camera + * * @param x * @param y - * @param z - */ - public void setRotation(float x, float y, float z) { + * @param z */ + public void setRotation(float x, float y, float z) + { rotation.x = x; rotation.y = y; rotation.z = z; dirty = true; } - - - /** - * Move the rotation of the camera + + /** Move the rotation of the camera + * * @param xOffset * @param yOffset - * @param zOffset - */ - public void moveRotation(float xOffset, float yOffset, float zOffset) { + * @param zOffset */ + public void moveRotation(float xOffset, float yOffset, float zOffset) + { rotation.x += xOffset; rotation.y += yOffset; rotation.z += zOffset; dirty = true; } - - - public float getFOV() { - return FOV; - } - - public float getZNear() { - return zNear; - } - - public float getZFar() { - return zFar; - } - - public float getAspectRatio() { - return aspectRatio; - } - + + public float getFOV() + { return FOV; } + + public float getZNear() + { return zNear; } + + public float getZFar() + { return zFar; } + + public float getAspectRatio() + { return aspectRatio; } } diff --git a/src/com/bwyap/engine/render3d/Renderer3D.java b/src/com/bwyap/engine/render3d/Renderer3D.java index f4e3768..381ba7d 100644 --- a/src/com/bwyap/engine/render3d/Renderer3D.java +++ b/src/com/bwyap/engine/render3d/Renderer3D.java @@ -2,81 +2,59 @@ import com.bwyap.engine.window.WindowInterface; - -/** - * An abstract 3D renderer class which sets up the view and projection - * matrices for rendering a 3D scene. The actual methods required to +/** An abstract 3D renderer class which sets up the view and projection + * matrices for rendering a 3D scene. The actual methods required to * render the scene using a rendering library must be implemented by * extending this class. - * @author bwyap - * - */ -public abstract class Renderer3D { - + * + * @author bwyap */ +public abstract class Renderer3D +{ public final Transformation transform; - - - public Renderer3D() { - this.transform = new Transformation(); - } - - - /** - * Set up the view and projection matrices required to render a scene + + public Renderer3D() + { this.transform = new Transformation(); } + + /** Set up the view and projection matrices required to render a scene + * * @param window - * @param camera - */ - public void startRender3D(WindowInterface window, Camera camera) { - if (window.isResized()) { + * @param camera */ + public void startRender3D(WindowInterface window, Camera camera) + { + if (window.isResized()) + { window.setResized(false); camera.setDirty(true); } - // Camera's view has changed. Update the view and projection matrices - if (camera.isDirty()) { + if (camera.isDirty()) + { camera.setDirty(false); - // Update the projection matrix transform.updateProjectionMatrix(camera.getFOV(), window.getWidth(), window.getHeight(), camera.getZNear(), camera.getZFar()); - // Update view Matrix transform.updateViewMatrix(camera); } - startRender3D(); } - - - /** - * Prepare implementation specific resources to render a 3D scene. - * The view and projection matrices are automatically updated. - */ + + /** Prepare implementation specific resources to render a 3D scene. + * The view and projection matrices are automatically updated. */ public abstract void startRender3D(); - - - /** - * Render a scene to the screen. - * @param scene - */ - public final void renderScene(Scene scene) { - scene.renderLayers(this, transform.getProjectionMatrix(), transform.getViewMatrix()); - } - - - /** - * Set the rendering system to 2D ortho projection to render a GUI. - */ + + /** Render a scene to the screen. + * + * @param scene */ + public final void renderScene(Scene scene) + { scene.renderLayers(this, transform.getProjectionMatrix(), transform.getViewMatrix()); } + + /** Set the rendering system to 2D ortho projection to render a GUI. */ public abstract void startRenderGUI(); - - /** - * Clean up resources after rendering to the screen. - */ + + /** Clean up resources after rendering to the screen. */ public abstract void stopRender(); - - - /** - * Clean up resources used by the renderer. - * Override this method to - */ + + /** Clean up resources used by the renderer. + * Override this method to */ public abstract void cleanup(); } diff --git a/src/com/bwyap/engine/render3d/Scene.java b/src/com/bwyap/engine/render3d/Scene.java index 76f4e96..07f72b1 100644 --- a/src/com/bwyap/engine/render3d/Scene.java +++ b/src/com/bwyap/engine/render3d/Scene.java @@ -7,96 +7,77 @@ import com.bwyap.engine.input.InputHandler; - -/** - *+/**
* A scene holds scene layers which can be rendered. - * Each layer has its own shader which is used to - * shade the objects in that layer. + * Each layer has its own shader which is used to + * shade the objects in that layer. * A scene also has a camera which is used to view the layer. *
*- * Each layer and the camera are automatically updated in the - * scene's {@code update} method. Use the {@code handleInput} + * Each layer and the camera are automatically updated in the + * scene's {@code update} method. Use the {@code handleInput} * and {@code renderLayers} methods to poll input and render * the layers respectively. *
- * @author bwyap * - */ -public abstract class Scene { - + * @author bwyap */ +public abstract class Scene +{ private List+/**
* A layer within the scene containing renderable entities. * Entities within this scene layer should use the same shader. *
*- * The type of entities to be contained in this layer should + * The type of entities to be contained in this layer should * be specified in the type parameter. *
- * @author bwyap - * - */ -public interface SceneLayer- * Implements the following interfaces: + * Implements the following interfaces: *
+/**
* A fixed timestep engine that uses LWJGL to render a 3D scene. * If no scene is set, the scene rendering call will be skipped. - * This engine also supports a GUI which will be updated and + * This engine also supports a GUI which will be updated and * rendered if set using the {@code initGUI()} method. *
** This rendering engine makes use of {@code Scene} objects. * Each tick, the current scene will be updated and rendered. - * The {@code currentScene} is initially null and must be set - * using the {@code setScene} method. + * The {@code currentScene} is initially null and must be set + * using the {@code setScene} method. *
- * @author bwyap - * - */ -public abstract class LWJGL3DEngine extends FixedTimestepEngine { - + * + * @author bwyap */ +public abstract class LWJGL3DEngine extends FixedTimestepEngine +{ private final LWJGLRenderer renderer; private final GUIControllerInterface guiController; - private float fpsPrintTimer = 0; private Scene currentScene; - - - public LWJGL3DEngine(WindowInterface window, int targetFPS) throws Exception { + + public LWJGL3DEngine(WindowInterface window, int targetFPS) throws Exception + { super(window, targetFPS); this.renderer = new LWJGLRenderer(); this.guiController = initGUI(); } - - /** - * Initialise the GUI system used by this engine. + /** Initialise the GUI system used by this engine. * (Return {@code null} if the engine does not require a GUI) - * @throws Exception - */ + * + * @throws Exception */ public abstract GUIControllerInterface initGUI() throws Exception; - @Override - public float getCurrentTime() { - return (float) glfwGetTime(); - } - - - /** - * Set the scene to be rendered. - * @param scene - */ - public void setScene(Scene scene) { - currentScene = scene; - } - - + public float getCurrentTime() + { return (float) glfwGetTime(); } + + /** Set the scene to be rendered. + * + * @param scene */ + public void setScene(Scene scene) + { currentScene = scene; } + @Override - public final void update(float timestep) { - if (currentScene != null) { + public final void update(float timestep) + { + if (currentScene != null) + { currentScene.handleInput(window.getInputHandler(), timestep); currentScene.update(timestep); } - - if (guiController != null) { + if (guiController != null) + { guiController.handleInput(window.getInputHandler()); guiController.update(timestep); } - //Print the FPS to the console. //TODO: remove this later. fpsPrintTimer += timestep; - if (fpsPrintTimer >= 1) { + if (fpsPrintTimer >= 1) + { fpsPrintTimer -= 1; //System.out.println((int)getFPS() + " fps"); } } - - + @Override - public final void render(float timestep) { - if (currentScene != null) { + public final void render(float timestep) + { + if (currentScene != null) + { renderer.startRender3D(window, currentScene.getCamera()); renderer.renderScene(currentScene); } if (guiController != null) guiController.render(window); - renderer.stopRender(); - } - - - @Override - public void cleanup() { - renderer.cleanup(); + renderer.stopRender(); } + @Override + public void cleanup() + { renderer.cleanup(); } } diff --git a/src/com/bwyap/lwjgl/engine/entity/AnimatedRenderableObject.java b/src/com/bwyap/lwjgl/engine/entity/AnimatedRenderableObject.java index 5ea6110..8d11b96 100644 --- a/src/com/bwyap/lwjgl/engine/entity/AnimatedRenderableObject.java +++ b/src/com/bwyap/lwjgl/engine/entity/AnimatedRenderableObject.java @@ -1,58 +1,50 @@ package com.bwyap.lwjgl.engine.entity; - -/** - * A renderable object which supports an animated texture. - * @author bwyap - * - */ -public class AnimatedRenderableObject extends RenderableEntity implements AnimatedTexture { - +/** A renderable object which supports an animated texture. + * + * @author bwyap */ +public class AnimatedRenderableObject extends RenderableEntity implements AnimatedTexture +{ private int texturePosition; private float textureChangeSpeed; private float currentFrameTime; - - public AnimatedRenderableObject(String meshName) { + public AnimatedRenderableObject(String meshName) + { super(meshName); this.texturePosition = 0; this.textureChangeSpeed = 0; this.currentFrameTime = 0; } - - /** - * {@inheritDoc} + /** {@inheritDoc} ** IMPORTANT: * When overriding this method to implement particle physics * ensure you call {@code super.update(timestep)} to animate the particle. *
- * @param timestep - */ + * + * @param timestep */ @Override - public void update(float timestep) { + public void update(float timestep) + { currentFrameTime += timestep; - if (currentFrameTime >= textureChangeSpeed) { + if (currentFrameTime >= textureChangeSpeed) + { currentFrameTime = 0; texturePosition++; } } - - - @Override - public int getTexturePosition() { - return texturePosition; - } - + @Override - public void setTextureChangeSpeed(float speed) { - this.textureChangeSpeed = speed; - } - + public int getTexturePosition() + { return texturePosition; } + @Override - public float getTextureChangeSpeed() { - return textureChangeSpeed; - } + public void setTextureChangeSpeed(float speed) + { this.textureChangeSpeed = speed; } + @Override + public float getTextureChangeSpeed() + { return textureChangeSpeed; } } diff --git a/src/com/bwyap/lwjgl/engine/entity/AnimatedTexture.java b/src/com/bwyap/lwjgl/engine/entity/AnimatedTexture.java index 4d5a1b2..e17d5a9 100644 --- a/src/com/bwyap/lwjgl/engine/entity/AnimatedTexture.java +++ b/src/com/bwyap/lwjgl/engine/entity/AnimatedTexture.java @@ -1,25 +1,19 @@ package com.bwyap.lwjgl.engine.entity; -public interface AnimatedTexture { - - - /** - * Set the speed at which the texture changes. - * @param speed - */ +public interface AnimatedTexture +{ + /** Set the speed at which the texture changes. + * + * @param speed */ public void setTextureChangeSpeed(float speed); - - - /** - * Get the speed at which the texture changes. - * @return - */ + + /** Get the speed at which the texture changes. + * + * @return */ public float getTextureChangeSpeed(); - - - /** - * Get the texture position at which the entity should be using - * @return - */ + + /** Get the texture position at which the entity should be using + * + * @return */ public int getTexturePosition(); } diff --git a/src/com/bwyap/lwjgl/engine/entity/RenderableEntity.java b/src/com/bwyap/lwjgl/engine/entity/RenderableEntity.java index dd9e11d..c97aef9 100644 --- a/src/com/bwyap/lwjgl/engine/entity/RenderableEntity.java +++ b/src/com/bwyap/lwjgl/engine/entity/RenderableEntity.java @@ -4,98 +4,71 @@ import com.bwyap.lwjgl.engine.render3d.Material; import com.bwyap.lwjgl.engine.render3d.LWJGLTexture; -/** - *+/**
* A 3D entity that can be rendered to the screen. - * Stores a mesh name, as well as a texture and - * material with which to render the mesh. + * Stores a mesh name, as well as a texture and + * material with which to render the mesh. * Extends {@code RotatableEntity} which provide * methods to move, scale and rotate the entity. *
- *+ *
* Implements the following interfaces: - * {@code EntityInterface}, + * {@code EntityInterface}, * {@code ScalableInterface}, * {@code MovableInterface} and * {@code RotatableInterface}. *
- * @author bwyap - * - */ -public class RenderableEntity extends RotatableEntity { - + * + * @author bwyap */ +public class RenderableEntity extends RotatableEntity +{ private final String meshName; - private LWJGLTexture texture; private Material material; - - - public RenderableEntity(String meshName) { - this.meshName = meshName; - } - - - /** - * Update the object's state. + + public RenderableEntity(String meshName) + { this.meshName = meshName; } + + /** Update the object's state. * TODO make this method abstract - * @param timestep - */ - public void update(float timestep) { - - } - - - /** - * Get the name of the mesh used by this object - * @return - */ - public String getMeshName() { - return meshName; - } - - - /** - * Get the texture used by this object - * @return - */ - public LWJGLTexture getTexture() { - return texture; - } - - - /** - * Check if the object has a texture to use - * @return - */ - public boolean isTextured() { - return texture != null; - } - - - /** - * Set the texture used by this object - * @param texture - */ - public void setTexture(LWJGLTexture texture) { - this.texture = texture; - } - - - /** - * Get the material used by this object - * @return - */ - public Material getMaterial() { - return material; - } - - - /** - * Set the material used by this object - * @param material - */ - public void setMaterial(Material material) { - this.material = material; - } - + * + * @param timestep */ + public void update(float timestep) + {} + + /** Get the name of the mesh used by this object + * + * @return */ + public String getMeshName() + { return meshName; } + + /** Get the texture used by this object + * + * @return */ + public LWJGLTexture getTexture() + { return texture; } + + /** Check if the object has a texture to use + * + * @return */ + public boolean isTextured() + { return texture != null; } + + /** Set the texture used by this object + * + * @param texture */ + public void setTexture(LWJGLTexture texture) + { this.texture = texture; } + + /** Get the material used by this object + * + * @return */ + public Material getMaterial() + { return material; } + + /** Set the material used by this object + * + * @param material */ + public void setMaterial(Material material) + { this.material = material; } } diff --git a/src/com/bwyap/lwjgl/engine/gui/nanovg/NVGFont.java b/src/com/bwyap/lwjgl/engine/gui/nanovg/NVGFont.java index a71face..4ea624f 100644 --- a/src/com/bwyap/lwjgl/engine/gui/nanovg/NVGFont.java +++ b/src/com/bwyap/lwjgl/engine/gui/nanovg/NVGFont.java @@ -8,103 +8,80 @@ import java.util.HashMap; import java.util.Map; - -/** - * Holds the name and path to a font that can be - * used by NanoVG to render text using a .tff font +/** Holds the name and path to a font that can be + * used by NanoVG to render text using a .tff font * file. The font must be loaded into a byte buffer - * using the {@code load()} command before it can - * be used. - */ -public class NVGFont { - + * using the {@code load()} command before it can + * be used. */ +public class NVGFont +{ private static Map- * Holds a textureID of a texture loaded for NanoVG. A texture - * can also be used as a texture atlas if its rows and columns - * are set in the constructor (by default it has a row and col - * count of 1, which means the texture is not animated). +/**
+ * Holds a textureID of a texture loaded for NanoVG. A texture + * can also be used as a texture atlas if its rows and columns + * are set in the constructor (by default it has a row and col + * count of 1, which means the texture is not animated). *
*- * Also provides a static method to load textures into memory - * for rendering by NanoVG. The rendering context must be + * Also provides a static method to load textures into memory + * for rendering by NanoVG. The rendering context must be * provided for the loading process. *
- * @author bwyap - * - */ -public class NVGTexture extends Texture { - + * + * @author bwyap */ +public class NVGTexture extends Texture +{ private static Map* IMPORTANT: * When overriding this method to implement particle physics * ensure you call {@code super.update(timestep)} to animate the particle. *
- * @param timestep - */ + * + * @param timestep */ @Override - public void update(float timestep) { + public void update(float timestep) + { currentFrameTime += timestep; - if (currentFrameTime >= textureChangeSpeed) { + if (currentFrameTime >= textureChangeSpeed) + { currentFrameTime = 0; texturePosition++; - } - } - - - @Override - public int getTexturePosition() { - return texturePosition; + } } - + @Override - public void setTextureChangeSpeed(float speed) { - this.textureChangeSpeed = speed; - } - + public int getTexturePosition() + { return texturePosition; } + @Override - public float getTextureChangeSpeed() { - return textureChangeSpeed; - } + public void setTextureChangeSpeed(float speed) + { this.textureChangeSpeed = speed; } + @Override + public float getTextureChangeSpeed() + { return textureChangeSpeed; } } diff --git a/src/com/bwyap/lwjgl/engine/particle/ParticleSystem.java b/src/com/bwyap/lwjgl/engine/particle/ParticleSystem.java index bc8764a..c291e67 100644 --- a/src/com/bwyap/lwjgl/engine/particle/ParticleSystem.java +++ b/src/com/bwyap/lwjgl/engine/particle/ParticleSystem.java @@ -14,82 +14,72 @@ import com.bwyap.lwjgl.mesh.InstancedMesh; import com.bwyap.lwjgl.mesh.Mesh; -/** - * An abstract particle system that renders its particles +/** An abstract particle system that renders its particles * using the {@code LWJGLRenderer}. Particles can be assigned - * a mesh and texture. (The mesh should be a quad or it may + * a mesh and texture. (The mesh should be a quad or it may * cause undesirable results) - * system uses a - * @author bwyap - * - * @param- * Holds a textureID of a texture loaded for LWJGL, and a flag - * to indicate whether the texture has alpha support. A texture - * can also be used as a texture atlas if its rows and columns - * are set in the constructor (by default it has a row and col - * count of 1, which means the texture is not animated). +/**
+ * Holds a textureID of a texture loaded for LWJGL, and a flag + * to indicate whether the texture has alpha support. A texture + * can also be used as a texture atlas if its rows and columns + * are set in the constructor (by default it has a row and col + * count of 1, which means the texture is not animated). *
*- * The class also provides a static method to load a texture + * The class also provides a static method to load a texture * to the graphics card using {@code PNGDecoder}. *
- * @author bwyap - * - */ -public class LWJGLTexture extends Texture { - + * + * @author bwyap */ +public class LWJGLTexture extends Texture +{ private static Map+/**
* A scene layer that holds {@code RenderableEntity} objects. - * All objects in the layer are updated and rendered through + * All objects in the layer are updated and rendered through * the {@code update} and {@code render} methods. *
** The {@code RenderableEntity} objects are stored in two {@code Maps}, - * one which holds objects with non-instanced meshes one which + * one which holds objects with non-instanced meshes one which * holds instanced meshes. *
- * @author bwyap - * - */ -public abstract class EntityLayer implements SceneLayer* Requires {@code LWJGLRenderer}. - *
- */ + * */ @Override - public final void render(Renderer3D renderer, Matrix4f projectionMatrix, Matrix4f viewMatrix) { + public final void render(Renderer3D renderer, Matrix4f projectionMatrix, Matrix4f viewMatrix) + { beginRender(projectionMatrix, viewMatrix); renderObjects((LWJGLRenderer) renderer, viewMatrix); endRender(); } - - - /** - * Prepare the shader for rendering the entities + + /** Prepare the shader for rendering the entities + * * @param projectionMatrix - * @param viewMatrix - */ + * @param viewMatrix */ protected abstract void beginRender(Matrix4f projectionMatrix, Matrix4f viewMatrix); - - - /** - * Render the entities in scene layer + + /** Render the entities in scene layer + * * @param renderer - * @param viewMatrix - */ + * @param viewMatrix */ protected abstract void renderObjects(LWJGLRenderer renderer, Matrix4f viewMatrix); - - - /** - * Clean up the shader resources after rendering the entities - */ + + /** Clean up the shader resources after rendering the entities */ protected abstract void endRender(); - } diff --git a/src/com/bwyap/lwjgl/engine/render3d/scene/LightedObjectLayer.java b/src/com/bwyap/lwjgl/engine/render3d/scene/LightedObjectLayer.java index d788b01..223d74c 100644 --- a/src/com/bwyap/lwjgl/engine/render3d/scene/LightedObjectLayer.java +++ b/src/com/bwyap/lwjgl/engine/render3d/scene/LightedObjectLayer.java @@ -22,77 +22,70 @@ import com.bwyap.lwjgl.mesh.InstancedMesh; import com.bwyap.lwjgl.mesh.Mesh; - -/** - *+/**
* A scene layer that can hold renderable entities * that are lit by a Phong lighting shader. - * All objects in the layer are updated and rendered + * All objects in the layer are updated and rendered * through the {@code update} and {@code render} methods. *
*- * All non-instanced meshes are rendered first, and + * All non-instanced meshes are rendered first, and * all objects with the same mesh are rendered in the * same cycle. *
- * @author bwyap - * - */ -public abstract class LightedObjectLayer extends EntityLayer { - + * + * @author bwyap */ +public abstract class LightedObjectLayer extends EntityLayer +{ protected SceneLighting lighting; - - - public LightedObjectLayer() throws Exception { + + public LightedObjectLayer() throws Exception + { super(); lighting = new SceneLighting(); shader = new PhongLightingShader(); shader.init(); } - - - /** - * Get the {@code SceneLighting} object used to light + + /** Get the {@code SceneLighting} object used to light * the objects in this scene layer - * @return - */ - public SceneLighting getLighting() { - return lighting; - } - - + * + * @return */ + public SceneLighting getLighting() + { return lighting; } + @Override - protected void beginRender(Matrix4f projectionMatrix, Matrix4f viewMatrix) { + protected void beginRender(Matrix4f projectionMatrix, Matrix4f viewMatrix) + { shader.bind(); shader.setUniform("projectionMatrix", projectionMatrix); - shader.setUniform("textureSampler", 0); - calculateLighting(lighting, viewMatrix); + shader.setUniform("textureSampler", 0); + calculateLighting(lighting, viewMatrix); } - - - /** - * {@inheritDoc} + + /** {@inheritDoc} ** It is assumed that all entities that share the same instanced mesh * also share the same material type and texture. * To have entities with the same instanced mesh but different textures, * use a mesh with a different name (or use non-instanced meshes). - *
- */ + * */ @Override - protected void renderObjects(LWJGLRenderer renderer, Matrix4f viewMatrix) { + protected void renderObjects(LWJGLRenderer renderer, Matrix4f viewMatrix) + { // Render non instanced objects shader.setUniform("isInstanced", 0); - // Iterate through each mesh and render each object that has that mesh - for (String meshName : meshMap.keySet()) { + for (String meshName : meshMap.keySet()) + { Mesh mesh = Mesh.getMesh(meshName); - - renderer.renderMeshList(mesh, meshMap.get(meshName), (RenderableEntity o) -> { + renderer.renderMeshList(mesh, meshMap.get(meshName), (RenderableEntity o) -> + { // Set the material information ((PhongLightingShader) shader).setUniform("material", o.getMaterial()); shader.setUniform("useTexture", o.isTextured() ? 1 : 0); - if (o.isTextured()) { + if (o.isTextured()) + { // Set the texture information in the shader shader.setUniform("textureSampler", 0); shader.setUniform("numCols", o.getTexture().getCols()); @@ -101,8 +94,8 @@ protected void renderObjects(LWJGLRenderer renderer, Matrix4f viewMatrix) { renderer.setTexture(o.getTexture()); renderer.setTransparent(o.getTexture().hasAlpha()); } - - if (o instanceof AnimatedTexture) { + if (o instanceof AnimatedTexture) + { // If the texture is animated, set the texture co-ordinates AnimatedTexture a = (AnimatedTexture) o; int col = a.getTexturePosition() % o.getTexture().getCols(); @@ -111,56 +104,53 @@ protected void renderObjects(LWJGLRenderer renderer, Matrix4f viewMatrix) { float texYOffset = (float) row / o.getTexture().getRows(); shader.setUniform("nonInstancedTexOffset", new Vector2f(texXOffset, texYOffset)); } - // Set the model view matrix uniform Matrix4f modelViewMatrix; if (o instanceof RotatableEntity) modelViewMatrix = renderer.transform.buildModelViewMatrix(o, viewMatrix); else modelViewMatrix = renderer.transform.buildModelBillboardMatrix(o); - shader.setUniform("modelViewNonInstancedMatrix", modelViewMatrix); + shader.setUniform("modelViewNonInstancedMatrix", modelViewMatrix); }); } - // Render instanced objects shader.setUniform("isInstanced", 1); - // Iterate through each mesh and render each object that has that mesh - for (String meshName : instancedMeshMap.keySet()) { + for (String meshName : instancedMeshMap.keySet()) + { InstancedMesh mesh = (InstancedMesh) Mesh.getMesh(meshName); - // Set up the instance data in the buffer List* Requires {@code LWJGLRenderer}. - *
- */ + * */ @Override - public void render(Renderer3D renderer, Matrix4f projectionMatrix, Matrix4f viewMatrix) { + public void render(Renderer3D renderer, Matrix4f projectionMatrix, Matrix4f viewMatrix) + { shader.bind(); shader.setUniform("textureSampler", 0); shader.setUniform("projectionMatrix", projectionMatrix); - - for(ParticleSystem> system : particleSystems) { - system.render((LWJGLRenderer)renderer, shader, viewMatrix); - } - + for (ParticleSystem> system : particleSystems) + { system.render((LWJGLRenderer) renderer, shader, viewMatrix); } shader.unbind(); } - } diff --git a/src/com/bwyap/lwjgl/engine/render3d/shader/ParticleShader.java b/src/com/bwyap/lwjgl/engine/render3d/shader/ParticleShader.java index fe5ea57..6759218 100644 --- a/src/com/bwyap/lwjgl/engine/render3d/shader/ParticleShader.java +++ b/src/com/bwyap/lwjgl/engine/render3d/shader/ParticleShader.java @@ -1,27 +1,21 @@ package com.bwyap.lwjgl.engine.render3d.shader; +public class ParticleShader extends Shader +{ + public ParticleShader() throws Exception + { super(); } -public class ParticleShader extends Shader { - - - public ParticleShader() throws Exception { - super(); - } - - @Override - public void init() throws Exception { - createVertexShader(Shader.getSource("particle_vertex")); - createFragmentShader(Shader.getSource("particle_fragment")); - link(); - + public void init() throws Exception + { + createVertexShader(Shader.getSource("particle_vertex")); + createFragmentShader(Shader.getSource("particle_fragment")); + link(); // Create uniforms for modelView and projection matrices and texture - createUniform("projectionMatrix"); - createUniform("textureSampler"); - - // Create uniforms for animated particle support - createUniform("numRows"); - createUniform("numCols"); + createUniform("projectionMatrix"); + createUniform("textureSampler"); + // Create uniforms for animated particle support + createUniform("numRows"); + createUniform("numCols"); } - } diff --git a/src/com/bwyap/lwjgl/engine/render3d/shader/PhongLightingShader.java b/src/com/bwyap/lwjgl/engine/render3d/shader/PhongLightingShader.java index 1ad0a4d..03627a2 100644 --- a/src/com/bwyap/lwjgl/engine/render3d/shader/PhongLightingShader.java +++ b/src/com/bwyap/lwjgl/engine/render3d/shader/PhongLightingShader.java @@ -6,56 +6,47 @@ import com.bwyap.lwjgl.engine.render3d.light.SceneLighting; import com.bwyap.lwjgl.engine.render3d.light.SpotLight; -/** - * Phong lighting model shader. - * Provides methods to create uniforms for directional lights, point lights and spot lights. - * @author bwyap - * - */ -public class PhongLightingShader extends Shader { - - - public PhongLightingShader() throws Exception { - super(); - } - +/** Phong lighting model shader. + * Provides methods to create uniforms for directional lights, point lights and spot lights. + * + * @author bwyap */ +public class PhongLightingShader extends Shader +{ + public PhongLightingShader() throws Exception + { super(); } - /** - * Initialise the uniforms required for Phong lighting - * @throws Exception - */ + /** Initialise the uniforms required for Phong lighting + * + * @throws Exception */ @Override - public void init() throws Exception { + public void init() throws Exception + { createVertexShader(Shader.getSource("vertex")); createFragmentShader(Shader.getSource("fragment")); link(); - // Create uniforms for modelView and projection matrices and texture createUniform("projectionMatrix"); createUniform("modelViewNonInstancedMatrix"); createUniform("textureSampler"); - createUniform("isInstanced"); createUniform("numCols"); createUniform("numRows"); createUniform("nonInstancedTexOffset"); - createMaterialUniform("material"); createUniform("useTexture"); createUniform("specularPower"); createUniform("ambientLight"); createDirectionalLightListUniform("directionalLights", SceneLighting.MAX_DIR_LIGHTS); createPointLightListUniform("pointLights", SceneLighting.MAX_POINT_LIGHTS); - createSpotLightListUniform("spotLights", SceneLighting.MAX_SPOT_LIGHTS); + createSpotLightListUniform("spotLights", SceneLighting.MAX_SPOT_LIGHTS); } - - - /** - * Create the uniform for a point light - * @param uniformName - * @throws Exception - */ - public void createPointLightUniform(String uniformName) throws Exception { + + /** Create the uniform for a point light + * + * @param uniformName + * @throws Exception */ + public void createPointLightUniform(String uniformName) throws Exception + { createUniform(uniformName + ".colour"); createUniform(uniformName + ".position"); createUniform(uniformName + ".intensity"); @@ -63,203 +54,176 @@ public void createPointLightUniform(String uniformName) throws Exception { createUniform(uniformName + ".att.linear"); createUniform(uniformName + ".att.exponent"); } - - - /** - * Create the uniform for a directional light - * @param uniformName - * @throws Exception - */ - public void createDirectionalLightUniform(String uniformName) throws Exception { + + /** Create the uniform for a directional light + * + * @param uniformName + * @throws Exception */ + public void createDirectionalLightUniform(String uniformName) throws Exception + { createUniform(uniformName + ".colour"); createUniform(uniformName + ".direction"); createUniform(uniformName + ".intensity"); } - - - /** - * Create the uniform for a spot light - * @param uniformName - * @throws Exception - */ - public void createSpotLightUniform(String uniformName) throws Exception { - createPointLightUniform(uniformName + ".pl"); + + /** Create the uniform for a spot light + * + * @param uniformName + * @throws Exception */ + public void createSpotLightUniform(String uniformName) throws Exception + { + createPointLightUniform(uniformName + ".pl"); createUniform(uniformName + ".coneDir"); createUniform(uniformName + ".cutoff"); } - - - /** - * Create the uniform for a material - * @param uniformName - * @throws Exception - */ - public void createMaterialUniform(String uniformName) throws Exception { + + /** Create the uniform for a material + * + * @param uniformName + * @throws Exception */ + public void createMaterialUniform(String uniformName) throws Exception + { createUniform(uniformName + ".colour"); createUniform(uniformName + ".reflectance"); } - - - /** - * Create the uniform for a list of directional lights - * @param uniformName - * @param size - * @throws Exception - */ - public void createDirectionalLightListUniform(String uniformName, int size) throws Exception { - for (int i = 0; i < size; i++) { - createDirectionalLightUniform(uniformName + "[" + i + "]"); - } - } - - - /** - * Create the uniform for a list of point lights - * @param uniformName - * @param size - * @throws Exception - */ - public void createPointLightListUniform(String uniformName, int size) throws Exception { - for (int i = 0; i < size; i++) { - createPointLightUniform(uniformName + "[" + i + "]"); - } + + /** Create the uniform for a list of directional lights + * + * @param uniformName + * @param size + * @throws Exception */ + public void createDirectionalLightListUniform(String uniformName, int size) throws Exception + { + for (int i = 0; i < size; i++) + { createDirectionalLightUniform(uniformName + "[" + i + "]"); } } - - /** - * Create the uniform for a list of spot lights - * @param uniformName - * @param size - * @throws Exception - */ - public void createSpotLightListUniform(String uniformName, int size) throws Exception { - for (int i = 0; i < size; i++) { - createSpotLightUniform(uniformName + "[" + i + "]"); - } - } - - - /** - * Sets the uniforms for a point light. - * @param uniformName - * @param pointLight - */ - public void setUniform(String uniformName, PointLight pointLight) { - setUniform(uniformName + ".colour", pointLight.getColour()); - setUniform(uniformName + ".position", pointLight.getPosition()); - setUniform(uniformName + ".intensity", pointLight.getIntensity()); - PointLight.Attenuation att = pointLight.getAttenuation(); - setUniform(uniformName + ".att.constant", att.getConstant()); - setUniform(uniformName + ".att.linear", att.getLinear()); + /** Create the uniform for a list of point lights + * + * @param uniformName + * @param size + * @throws Exception */ + public void createPointLightListUniform(String uniformName, int size) throws Exception + { + for (int i = 0; i < size; i++) + { createPointLightUniform(uniformName + "[" + i + "]"); } + } + + /** Create the uniform for a list of spot lights + * + * @param uniformName + * @param size + * @throws Exception */ + public void createSpotLightListUniform(String uniformName, int size) throws Exception + { + for (int i = 0; i < size; i++) + { createSpotLightUniform(uniformName + "[" + i + "]"); } + } + + /** Sets the uniforms for a point light. + * + * @param uniformName + * @param pointLight */ + public void setUniform(String uniformName, PointLight pointLight) + { + setUniform(uniformName + ".colour", pointLight.getColour()); + setUniform(uniformName + ".position", pointLight.getPosition()); + setUniform(uniformName + ".intensity", pointLight.getIntensity()); + PointLight.Attenuation att = pointLight.getAttenuation(); + setUniform(uniformName + ".att.constant", att.getConstant()); + setUniform(uniformName + ".att.linear", att.getLinear()); setUniform(uniformName + ".att.exponent", att.getExponent()); } - - - /** - * Sets the uniforms for a directional light. - * @param uniformName - * @param dirLight - * @throws Exception - */ - public void setUniform(String uniformName, DirectionalLight dirLight) { - setUniform(uniformName + ".colour", dirLight.getColour()); - setUniform(uniformName + ".direction", dirLight.getDirection()); + + /** Sets the uniforms for a directional light. + * + * @param uniformName + * @param dirLight + * @throws Exception */ + public void setUniform(String uniformName, DirectionalLight dirLight) + { + setUniform(uniformName + ".colour", dirLight.getColour()); + setUniform(uniformName + ".direction", dirLight.getDirection()); setUniform(uniformName + ".intensity", dirLight.getIntensity()); } - - - /** - * Sets the uniforms for a spot light. - * @param uniformName - * @param spotLight - * @throws Exception - */ - public void setUniform(String uniformName, SpotLight spotLight) { + + /** Sets the uniforms for a spot light. + * + * @param uniformName + * @param spotLight + * @throws Exception */ + public void setUniform(String uniformName, SpotLight spotLight) + { setUniform(uniformName + ".pl", spotLight.getPointLight()); setUniform(uniformName + ".coneDir", spotLight.getConeDirection()); setUniform(uniformName + ".cutoff", spotLight.getCutOff()); } - - /** - * Sets the uniforms for a material. - * @param uniformName - * @param material - * @throws Exception - */ - public void setUniform(String uniformName, Material material) { - setUniform(uniformName + ".colour", material.getColour()); + + /** Sets the uniforms for a material. + * + * @param uniformName + * @param material + * @throws Exception */ + public void setUniform(String uniformName, Material material) + { + setUniform(uniformName + ".colour", material.getColour()); setUniform(uniformName + ".reflectance", material.getReflectance()); } - - /** - * Sets the uniforms for a list of directional lights + /** Sets the uniforms for a list of directional lights + * * @param uniformName - * @param directionalLights - */ - public void setUniform(String uniformName, DirectionalLight[] directionalLights) { - int numLights = directionalLights != null ? directionalLights.length : 0; - for (int i = 0; i < numLights; i++) { - setUniform(uniformName, directionalLights[i], i); - } + * @param directionalLights */ + public void setUniform(String uniformName, DirectionalLight[] directionalLights) + { + int numLights = directionalLights != null ? directionalLights.length : 0; + for (int i = 0; i < numLights; i++) + { setUniform(uniformName, directionalLights[i], i); } } - - - /** - * Sets the uniforms for a directional light in an array at the specified position. + + /** Sets the uniforms for a directional light in an array at the specified position. + * * @param uniformName * @param directionalLight - * @param pos - */ - public void setUniform(String uniformName, DirectionalLight directionalLight, int pos) { - setUniform(uniformName + "[" + pos + "]", directionalLight); - } - - - /** - * Sets the uniforms for a list of point lights + * @param pos */ + public void setUniform(String uniformName, DirectionalLight directionalLight, int pos) + { setUniform(uniformName + "[" + pos + "]", directionalLight); } + + /** Sets the uniforms for a list of point lights + * * @param uniformName - * @param pointLights - */ - public void setUniform(String uniformName, PointLight[] pointLights) { - int numLights = pointLights != null ? pointLights.length : 0; - for (int i = 0; i < numLights; i++) { - setUniform(uniformName, pointLights[i], i); - } + * @param pointLights */ + public void setUniform(String uniformName, PointLight[] pointLights) + { + int numLights = pointLights != null ? pointLights.length : 0; + for (int i = 0; i < numLights; i++) + { setUniform(uniformName, pointLights[i], i); } } - - /** - * Sets the uniforms for a point light in an array at the specified position. + + /** Sets the uniforms for a point light in an array at the specified position. + * * @param uniformName * @param pointLight - * @param pos - */ - public void setUniform(String uniformName, PointLight pointLight, int pos) { - setUniform(uniformName + "[" + pos + "]", pointLight); - } - - - /** - * Sets the uniforms for a list of spot lights + * @param pos */ + public void setUniform(String uniformName, PointLight pointLight, int pos) + { setUniform(uniformName + "[" + pos + "]", pointLight); } + + /** Sets the uniforms for a list of spot lights + * * @param uniformName - * @param spotLights - */ - public void setUniform(String uniformName, SpotLight[] spotLights) { + * @param spotLights */ + public void setUniform(String uniformName, SpotLight[] spotLights) + { int numLights = spotLights != null ? spotLights.length : 0; - for (int i = 0; i < numLights; i++) { - setUniform(uniformName, spotLights[i], i); - } + for (int i = 0; i < numLights; i++) + { setUniform(uniformName, spotLights[i], i); } } - - - /** - * Sets the uniforms for a spot light in an array at the specified position. + + /** Sets the uniforms for a spot light in an array at the specified position. + * * @param uniformName * @param spotLight - * @param pos - */ - public void setUniform(String uniformName, SpotLight spotLight, int pos) { - setUniform(uniformName + "[" + pos + "]", spotLight); - } - + * @param pos */ + public void setUniform(String uniformName, SpotLight spotLight, int pos) + { setUniform(uniformName + "[" + pos + "]", spotLight); } } diff --git a/src/com/bwyap/lwjgl/engine/render3d/shader/Shader.java b/src/com/bwyap/lwjgl/engine/render3d/shader/Shader.java index 645c624..5b0a804 100644 --- a/src/com/bwyap/lwjgl/engine/render3d/shader/Shader.java +++ b/src/com/bwyap/lwjgl/engine/render3d/shader/Shader.java @@ -35,236 +35,175 @@ import org.joml.Vector3f; import org.lwjgl.BufferUtils; -/** - * Responsible for initialising a vertex and fragment shader in the rendering pipeline. +/** Responsible for initialising a vertex and fragment shader in the rendering pipeline. * Contains methods to pass uniform data to the shaders when rendering a scene. - * @author bwyap - * - */ -public abstract class Shader { - - + * + * @author bwyap */ +public abstract class Shader +{ private static final Map* This method requires that LWJGL's {@code GL.createCapabilities()} method be called. - *
- */ + * */ @Override - public void loadDependentResources() throws Exception { + public void loadDependentResources() throws Exception + { loadMeshes(); loadLWJGLTextures(); } - - - /** - * Load resources for the GUI renderer (through NanoVG) - * @param ctx - * @throws IOException - */ - public void loadNVGResources(long ctx) throws IOException { + + /** Load resources for the GUI renderer (through NanoVG) + * + * @param ctx + * @throws IOException */ + public void loadNVGResources(long ctx) throws IOException + { loadNVGFonts(); loadNVGTextures(ctx); } - - - /** - * Get the settings object - * @return - */ - public Settings settings() { - return settings; - } - - - /** - * Get the input mapping object - * @return - */ - public InputMapping inputMapping() { - return inputMapping; - } - - - + + /** Get the settings object + * + * @return */ + public Settings settings() + { return settings; } + + /** Get the input mapping object + * + * @return */ + public InputMapping inputMapping() + { return inputMapping; } /* * =============== * PRIVATE METHODS * =============== */ - - + // EXTERNAL - - /** - * Load folders for local data - */ - private void loadFolders() { + /** Load folders for local data */ + private void loadFolders() + { ResourceLoader.loadFolder(new File(lib.getFolders().get("data_folder"))); ResourceLoader.loadFolder(new File(lib.getFolders().get("config_folder"))); } - - - /** - * Load configuration files - */ - private void loadConfig() { + + /** Load configuration files */ + private void loadConfig() + { File configFile = new File(lib.getConfig().get("config_file")); settings = new Settings(ResourceLoader.loadJSON(configFile)); - if (!settings.isValid()) { + if (!settings.isValid()) + { ResourceLoader.copyFileFromJar(configFile, null); settings = new Settings(ResourceLoader.loadJSON(configFile)); } - File inputMappingFile = new File(lib.getConfig().get("input_file")); inputMapping = new InputMapping(ResourceLoader.loadJSON(inputMappingFile)); - if (!inputMapping.isValid()) { + if (!inputMapping.isValid()) + { ResourceLoader.copyFileFromJar(inputMappingFile, null); inputMapping = new InputMapping(ResourceLoader.loadJSON(inputMappingFile)); } } - - - + // INTERNAL - - /** - * Load shader code into memory. The shader code can be retrieved - * from the {@code Shader} class to create and link the shader. - */ - private void loadShaders() { + /** Load shader code into memory. The shader code can be retrieved + * from the {@code Shader} class to create and link the shader. */ + private void loadShaders() + { Shader.addSource("vertex", ResourceLoader.loadShaderFile(lib.getShaders().get("vertex"))); Shader.addSource("fragment", ResourceLoader.loadShaderFile(lib.getShaders().get("fragment"))); Shader.addSource("particle_vertex", ResourceLoader.loadShaderFile(lib.getShaders().get("particle_vertex"))); Shader.addSource("particle_fragment", ResourceLoader.loadShaderFile(lib.getShaders().get("particle_fragment"))); } - - - /** - * Load meshes from their OBJ files into memory - * @throws Exception - */ - private void loadMeshes() throws Exception { + + /** Load meshes from their OBJ files into memory + * + * @throws Exception */ + private void loadMeshes() throws Exception + { OBJLoader.loadInstancedMesh("particle", lib.getMeshes().get("particle"), 2000); OBJLoader.loadInstancedMesh("icube", lib.getMeshes().get("cube"), 64); OBJLoader.loadMesh("bunny", lib.getMeshes().get("bunny")); OBJLoader.loadMesh("cube", lib.getMeshes().get("cube")); } - - - /** - * Load mesh textures - * @throws IOException - */ - private void loadLWJGLTextures() throws IOException { + + /** Load mesh textures + * + * @throws IOException */ + private void loadLWJGLTextures() throws IOException + { LWJGLTexture.loadTexture("test", lib.getTextures().get("test")); LWJGLTexture.loadTexture("test_particle", lib.getTextures().get("test_particle")); LWJGLTexture.loadTexture("test_animated_particle", lib.getTextures().get("test_animated_particle"), 4, 4); } - - - /** - * Load fonts for GUI rendering - * @throws IOException - */ - private void loadNVGFonts() throws IOException { - NVGFont.createFont("aeromatics_reg", lib.getFonts().get("aeromatics_reg")); - } - - - /** - * Load textures for GUI rendering - * @param ctx - * @throws IOException - */ - private void loadNVGTextures(long ctx) throws IOException{ + + /** Load fonts for GUI rendering + * + * @throws IOException */ + private void loadNVGFonts() throws IOException + { NVGFont.createFont("aeromatics_reg", lib.getFonts().get("aeromatics_reg")); } + + /** Load textures for GUI rendering + * + * @param ctx + * @throws IOException */ + private void loadNVGTextures(long ctx) throws IOException + { NVGTexture.loadTexture("test_button", lib.getTextures().get("test_button"), ctx); NVGTexture.loadTexture("test_button_mouseover", lib.getTextures().get("test_button_mouseover"), ctx); NVGTexture.loadTexture("test_button_pressed", lib.getTextures().get("test_button_pressed"), ctx); NVGTexture.loadTexture("test_image", lib.getTextures().get("test_image"), ctx); } - } diff --git a/src/com/bwyap/lwjgl/mesh/InstancedMesh.java b/src/com/bwyap/lwjgl/mesh/InstancedMesh.java index e6587a2..e387505 100644 --- a/src/com/bwyap/lwjgl/mesh/InstancedMesh.java +++ b/src/com/bwyap/lwjgl/mesh/InstancedMesh.java @@ -12,77 +12,60 @@ import org.lwjgl.BufferUtils; - -public class InstancedMesh extends Mesh { - +public class InstancedMesh extends Mesh +{ public static final int FLOAT_SIZE_BYTES = 4; public static final int VECTOR4F_SIZE_BYTES = 4 * FLOAT_SIZE_BYTES; public static final int MATRIX_SIZE_FLOATS = 4 * 4; public static final int MATRIX_SIZE_BYTES = MATRIX_SIZE_FLOATS * FLOAT_SIZE_BYTES; public static final int INSTANCE_SIZE_BYTES = MATRIX_SIZE_BYTES * 1 + FLOAT_SIZE_BYTES * 2; public static final int INSTANCE_SIZE_FLOATS = MATRIX_SIZE_FLOATS * 1 + 2; - private final int instances; private final int instanceDataVbo; - private final FloatBuffer instanceDataBuffer; - - protected InstancedMesh(String name, float[] positions, float[] texCoords, float[] normals, int[] indices, int instances) { + protected InstancedMesh(String name, float[] positions, float[] texCoords, float[] normals, int[] indices, int instances) + { super(name, positions, texCoords, normals, indices); this.instances = instances; this.instanceDataBuffer = BufferUtils.createFloatBuffer(instances * INSTANCE_SIZE_FLOATS); - glBindVertexArray(getVaoID()); - //Model view matrix instanceDataVbo = glGenBuffers(); vboIDs.add(instanceDataVbo); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVbo); int start = 3; int strideStart = 0; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) + { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } - // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); - glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } - - - /** - * Get the maximum number of instances which can be rendered - * @return - */ - public int getInstances() { - return instances; - } - - - - /** - * Get the ID of the VBO for the instance data - * @return - */ - public int getInstanceDataVboID() { - return instanceDataVbo; - } - - - /** - * Get the float buffer with the instance data for this mesh. + + /** Get the maximum number of instances which can be rendered + * + * @return */ + public int getInstances() + { return instances; } + + /** Get the ID of the VBO for the instance data + * + * @return */ + public int getInstanceDataVboID() + { return instanceDataVbo; } + + /** Get the float buffer with the instance data for this mesh. * Created with the appropriate size when this mesh was instantiated. - * @return - */ - public FloatBuffer getInstanceDataBuffer() { - return instanceDataBuffer; - } - + * + * @return */ + public FloatBuffer getInstanceDataBuffer() + { return instanceDataBuffer; } } diff --git a/src/com/bwyap/lwjgl/mesh/Mesh.java b/src/com/bwyap/lwjgl/mesh/Mesh.java index 27563f4..5bcee95 100644 --- a/src/com/bwyap/lwjgl/mesh/Mesh.java +++ b/src/com/bwyap/lwjgl/mesh/Mesh.java @@ -23,80 +23,65 @@ import org.joml.Vector3f; import org.lwjgl.BufferUtils; -/** - *- * A mesh holds the vertices, indices, normals and texture co-ordinates +/**
+ * A mesh holds the vertices, indices, normals and texture co-ordinates * necessary to render a 3D model using LWJGL. Meshes should be loaded * from OBJ files using the {@code OBJLoader} class. *
- * ** A mesh must be given a texture using the {@code setTexture} method, * and the texture must have been previously loaded. By default a mesh - * without a texture will be rendered using a default colour. A mesh - * also be rendered with a colour which can be assigned using the + * without a texture will be rendered using a default colour. A mesh + * also be rendered with a colour which can be assigned using the * {@code setColour} method if no texture has been previously assigned. *
* - * @author bwyap - * - */ -public class Mesh { - + * @author bwyap */ +public class Mesh +{ private static final Map
* The method {@code createGame()} method should be overridden to
* load a more specific and concrete implementation of GLFWGame.
*
- * @author bwyap
- *
- */
-public abstract class GLFWWindow extends Window {
-
+ * @author bwyap */
+public abstract class GLFWWindow extends Window
+{
private long window;
private boolean vSync;
private boolean polygonMode;
-
private GLFWKeyboardHandler keyboardHandler;
private GLFWMouseHandler mouseHandler;
-
// Callbacks
- GLFWErrorCallback errorCallback;
- GLFWWindowSizeCallback windowSizeCallback;
- GLFWKeyCallback keyCallback;
+ GLFWErrorCallback errorCallback;
+ GLFWWindowSizeCallback windowSizeCallback;
+ GLFWKeyCallback keyCallback;
GLFWMouseButtonCallback mouseButtonCallback;
- GLFWCursorPosCallback cursorPosCallback;
- GLFWScrollCallback scrollCallback;
- GLFWCursorEnterCallback cursorEnterCallback;
-
-
- /**
- * A GLFW window.
+ GLFWCursorPosCallback cursorPosCallback;
+ GLFWScrollCallback scrollCallback;
+ GLFWCursorEnterCallback cursorEnterCallback;
+
+ /** A GLFW window.
+ *
* @param width
- * @param height
- */
- public GLFWWindow(int width, int height, String title, boolean vSync, boolean polygonMode, boolean showFps) {
+ * @param height */
+ public GLFWWindow(int width, int height, String title, boolean vSync, boolean polygonMode, boolean showFps)
+ {
super(width, height, title, showFps);
this.vSync = vSync;
this.polygonMode = polygonMode;
}
-
-
+
@Override
- public void init() {
+ public void init()
+ {
// Initialize GLFW. Most GLFW functions will not work before doing this.
- if (!glfwInit())
+ if (!glfwInit())
throw new IllegalStateException("Unable to initialize GLFW");
-
//Configure the window
glfwDefaultWindowHints(); // optional, the current window hints are already the default
glfwWindowHint(GLFW_SAMPLES, 4);
@@ -117,196 +110,156 @@ public void init() {
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
-
//Create the window
window = glfwCreateWindow(width, height, title, NULL, NULL);
- if (window == NULL)
+ if (window == NULL)
throw new RuntimeException("Failed to create the GLFW window");
-
// Initialise the callbacks for the window
initCallbacks();
-
// Get the resolution of the primary monitor
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
-
// Center our window
glfwSetWindowPos(window,
(vidmode.width() - width) / 2,
- (vidmode.height() - height) / 2
- );
-
- glfwMakeContextCurrent(window); // Make the OpenGL context current
-
- if (vSync) {
- glfwSwapInterval(1); // Enable v-sync
+ (vidmode.height() - height) / 2);
+ glfwMakeContextCurrent(window); // Make the OpenGL context current
+ if (vSync)
+ {
+ glfwSwapInterval(1); // Enable v-sync
}
-
- glfwShowWindow(window); // Make the window visible
+ glfwShowWindow(window); // Make the window visible
GL.createCapabilities();
loadGLRequiredResources();
-
//Create a new engine to run
- try {
+ try
+ {
engine = createEngine();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
}
-
setClearColour(0, 0, 0, 0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
-
if (polygonMode) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
-
-
+
@Override
- public boolean shouldClose() {
- return glfwWindowShouldClose(this.getID());
- }
-
-
+ public boolean shouldClose()
+ { return glfwWindowShouldClose(this.getID()); }
+
@Override
- public void processEvents() {
- glfwPollEvents();
- }
-
-
+ public void processEvents()
+ { glfwPollEvents(); }
+
@Override
- public void swapDisplayBuffers() {
- glfwSwapBuffers(this.getID());
- }
-
-
- /**
- * Load resources which require GL capabilities to be initialised first.
- * This method is automatically called.
- */
+ public void swapDisplayBuffers()
+ { glfwSwapBuffers(this.getID()); }
+
+ /** Load resources which require GL capabilities to be initialised first.
+ * This method is automatically called. */
public abstract void loadGLRequiredResources();
-
-
- /**
- * Initialise the callbacks used by this window.
- */
- protected void initCallbacks() {
+
+ /** Initialise the callbacks used by this window. */
+ protected void initCallbacks()
+ {
// Setup an error callback.
// The default implementation will print the error message in System.err.
errorCallback = GLFWErrorCallback.createPrint(System.err).set();
-
// Setup window callback
- glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() {
+ glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback()
+ {
@Override
- public void invoke(long window, int width, int height) {
+ public void invoke(long window, int width, int height)
+ {
GLFWWindow.this.width = width;
GLFWWindow.this.height = height;
GLFWWindow.this.setResized(true);
glfwSetWindowAspectRatio(window, LWJGLResourceManager.instance().settings().getWidth(), LWJGLResourceManager.instance().settings().getHeight());
}
});
-
// Create input handlers
keyboardHandler = new GLFWKeyboardHandler();
mouseHandler = new GLFWMouseHandler();
input = new InputHandler(keyboardHandler, mouseHandler);
-
// Setup key callback
- glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
+ glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback()
+ {
@Override
- public void invoke(long window, int key, int scancode, int action, int mods) {
- keyboardHandler.invoke(window, key, scancode, action, mods);
- }
+ public void invoke(long window, int key, int scancode, int action, int mods)
+ { keyboardHandler.invoke(window, key, scancode, action, mods); }
});
-
// Setup mouse callbacks
- glfwSetMouseButtonCallback(window, mouseButtonCallback = new GLFWMouseButtonCallback() {
+ glfwSetMouseButtonCallback(window, mouseButtonCallback = new GLFWMouseButtonCallback()
+ {
@Override
- public void invoke(long window, int button, int action, int mods) {
- mouseHandler.invokeMouseButtonCallback(window, button, action, mods);
- }
+ public void invoke(long window, int button, int action, int mods)
+ { mouseHandler.invokeMouseButtonCallback(window, button, action, mods); }
});
-
- glfwSetScrollCallback(window, scrollCallback = new GLFWScrollCallback() {
+ glfwSetScrollCallback(window, scrollCallback = new GLFWScrollCallback()
+ {
@Override
- public void invoke(long window, double xoffset, double yoffset) {
- mouseHandler.invokeScrollCallback(window, xoffset, yoffset);
- }
+ public void invoke(long window, double xoffset, double yoffset)
+ { mouseHandler.invokeScrollCallback(window, xoffset, yoffset); }
});
-
- glfwSetCursorPosCallback(window, cursorPosCallback = new GLFWCursorPosCallback() {
+ glfwSetCursorPosCallback(window, cursorPosCallback = new GLFWCursorPosCallback()
+ {
@Override
- public void invoke(long window, double xpos, double ypos) {
- mouseHandler.invokeCursorPosCallback(window, xpos, ypos);
- }
+ public void invoke(long window, double xpos, double ypos)
+ { mouseHandler.invokeCursorPosCallback(window, xpos, ypos); }
});
-
- glfwSetCursorEnterCallback(window, cursorEnterCallback = new GLFWCursorEnterCallback() {
+ glfwSetCursorEnterCallback(window, cursorEnterCallback = new GLFWCursorEnterCallback()
+ {
@Override
- public void invoke(long window, boolean entered) {
- mouseHandler.invokeCursorEnterCallback(window, entered);
- }
+ public void invoke(long window, boolean entered)
+ { mouseHandler.invokeCursorEnterCallback(window, entered); }
});
-
}
-
-
+
@Override
- public final void start() {
+ public final void start()
+ {
// Initialise the window
init();
-
// Run the engine
engine.run();
-
// Dispose the window
dispose();
}
-
@Override
- public void dispose() {
+ public void dispose()
+ {
glfwFreeCallbacks(window);
glfwSetErrorCallback(null).free();
-
// Destroy the window
glfwDestroyWindow(window);
-
glfwTerminate();
}
-
-
- /**
- * Sets the clear colour for the window
+
+ /** Sets the clear colour for the window
+ *
* @param r
* @param g
* @param b
- * @param alpha
- */
- public void setClearColour(float r, float g, float b, float alpha) {
- glClearColor(r, g, b, alpha);
- }
-
-
- /**
- * Get the window handle
- * @return
- */
- public long getID() {
- return window;
- }
-
-
+ * @param alpha */
+ public void setClearColour(float r, float g, float b, float alpha)
+ { glClearColor(r, g, b, alpha); }
+
+ /** Get the window handle
+ *
+ * @return */
+ public long getID()
+ { return window; }
+
@Override
- protected void setWindowTitle(String title) {
- glfwSetWindowTitle(window, title);
- }
-
-
- /**
- * Checks if vSync is enabled for this window
- * @return
- */
- public boolean isVSync() {
- return vSync;
- }
-
+ protected void setWindowTitle(String title)
+ { glfwSetWindowTitle(window, title); }
+
+ /** Checks if vSync is enabled for this window
+ *
+ * @return */
+ public boolean isVSync()
+ { return vSync; }
}
diff --git a/src/com/bwyap/lwjgl/window/input/GLFWKeyboardHandler.java b/src/com/bwyap/lwjgl/window/input/GLFWKeyboardHandler.java
index 3c9157d..f3262f5 100644
--- a/src/com/bwyap/lwjgl/window/input/GLFWKeyboardHandler.java
+++ b/src/com/bwyap/lwjgl/window/input/GLFWKeyboardHandler.java
@@ -12,137 +12,117 @@
import com.bwyap.engine.input.KeyboardHandlerInterface;
-/**
- * Handles keyboard input through GLFWKeyCallbacks.
- * @author bwyap
- *
- */
-public class GLFWKeyboardHandler implements KeyboardHandlerInterface {
-
+/** Handles keyboard input through GLFWKeyCallbacks.
+ *
+ * @author bwyap */
+public class GLFWKeyboardHandler implements KeyboardHandlerInterface
+{
private static final boolean DEBUG = false;
-
private boolean[] keys = new boolean[65535];
private int keyMods = 0x0;
private int keysDown = 0;
private char typedChar = 0;
-
private Map
* In the GLFW system, the following bits will be set if
- *
* {@code GLFW_MOD_SHIFT: 0x1}
* {@code GLFW_MOD_CONTROL: 0x2}
* {@code GLFW_MOD_ALT: 0x4}
* {@code GLFW_MOD_SUPER: 0x8} (Command on macOS)
- *
* This method should be overridden so that the loaded object can be checked for validity.
- * @return
- */
- public boolean isValid() {
- return true;
- }
+ *
+ * @return */
+ public boolean isValid()
+ { return true; }
}
diff --git a/src/com/bwyap/utility/resource/ResourceLoader.java b/src/com/bwyap/utility/resource/ResourceLoader.java
index 39a8d28..242cc4a 100644
--- a/src/com/bwyap/utility/resource/ResourceLoader.java
+++ b/src/com/bwyap/utility/resource/ResourceLoader.java
@@ -19,266 +19,252 @@
import com.bwyap.lwjgl.engine.resource.LWJGLResourceManager;
import com.bwyap.utility.StreamLogger;
-public class ResourceLoader {
-
+public class ResourceLoader
+{
private static StreamLogger logger = null;
-
-
- /**
- * Loads a JSON object from a file on disk.
+
+ /** Loads a JSON object from a file on disk.
* If the file is not found on disk, a default version will be copied from the jar.
- * @param file File which describes the location of the physical file
- * @return
- */
- public static JSONObject loadJSON(File file) {
+ *
+ * @param file File which describes the location of the physical file
+ * @return */
+ public static JSONObject loadJSON(File file)
+ {
JSONObject jsonObject = null;
-
- if (!file.exists()) {
+ if (!file.exists())
+ {
log("Config file <" + file.getName() + "> not found. Using default config.");
copyFileFromJar(file, null);
}
-
JSONParser parser = new JSONParser();
- try {
+ try
+ {
Object o = parser.parse(new FileReader(file));
jsonObject = (JSONObject) o;
}
- catch (IOException e) {
+ catch (IOException e)
+ {
printStackTrace(e);
}
- catch (ParseException e) {
+ catch (ParseException e)
+ {
log("An error occurred while trying to parse JSON file <" + file.getName() + ">.");
printStackTrace(e);
}
-
return jsonObject;
}
-
-
- /**
- * Loads a JSON object from an internal file.
- * @param path the internal path of the JSON file
- * @return
- */
- public static JSONObject loadInternalJSON(String path) {
+
+ /** Loads a JSON object from an internal file.
+ *
+ * @param path the internal path of the JSON file
+ * @return */
+ public static JSONObject loadInternalJSON(String path)
+ {
JSONObject jsonObject = null;
-
JSONParser parser = new JSONParser();
- try {
+ try
+ {
String config = loadInternalTextFileAsString(path);
Object o = parser.parse(config);
jsonObject = (JSONObject) o;
}
- catch (ParseException e) {
+ catch (ParseException e)
+ {
log("An error occurred while trying to parse internal JSON file <" + path + ">.");
printStackTrace(e);
}
-
return jsonObject;
}
-
-
- /**
- * Reads an internal CSV file from within the jar and loads the data into a hash map.
- * @param path
- * @return
- */
- public static HashMap
* WARNING: this will overwrite anything that is in {@code file}.
- * @param file the external file to copy the internal file to
- * @param internalPath the path of the internal file. This can be null.
- */
- public static void copyFileFromJar(File file, String internalPath) {
+ *
+ * @param file the external file to copy the internal file to
+ * @param internalPath the path of the internal file. This can be null. */
+ public static void copyFileFromJar(File file, String internalPath)
+ {
InputStream in = null;
-
- try (PrintWriter out = new PrintWriter(file.getPath(), "UTF-8");
- FileOutputStream outStream = new FileOutputStream(file)) {
-
- if (internalPath == null) {
+ try (PrintWriter out = new PrintWriter(file.getPath(), "UTF-8");
+ FileOutputStream outStream = new FileOutputStream(file))
+ {
+ if (internalPath == null)
+ {
in = ResourceLoader.class.getClass().getResourceAsStream(LWJGLResourceManager.DEFAULT_INTERNAL_PATH + file.getPath());
}
- else {
+ else
+ {
in = ResourceLoader.class.getClass().getResourceAsStream(internalPath);
}
-
log("Copying file <" + file.getName() + ">");
- while (in.available() > 0) {
- out.write(in.read());
- }
+ while (in.available() > 0)
+ { out.write(in.read()); }
log("File <" + file.getName() + "> copy complete.");
}
- catch (Exception e) {
+ catch (Exception e)
+ {
log("ERROR occured when writing <" + file.getName() + "> to file.");
printStackTrace(e);
}
}
-
- /**
- * Creates a folder if it is valid
- * @param file the File representing the directory
- */
- public static void loadFolder(File file) {
- if(!file.isDirectory() | !file.exists()) {
+ /** Creates a folder if it is valid
+ *
+ * @param file the File representing the directory */
+ public static void loadFolder(File file)
+ {
+ if (!file.isDirectory() | !file.exists())
+ {
log("Directory <" + file.getPath() + "> not found.");
file.mkdirs();
log("<" + file.getPath() + "> created.");
}
}
-
- /**
- * Sets the logger for the resource loader to use
- * @param logger
- */
- public static void setLogger(StreamLogger logger) {
- ResourceLoader.logger = logger;
- }
-
-
- /**
- * Log a message to the logger if it has been initialised.
+ /** Sets the logger for the resource loader to use
+ *
+ * @param logger */
+ public static void setLogger(StreamLogger logger)
+ { ResourceLoader.logger = logger; }
+
+ /** Log a message to the logger if it has been initialised.
* Otherwise, the message is printed to the {@code System.out} stream
- * @param message
- */
- private static void log(String message) {
- if (logger != null) {
+ *
+ * @param message */
+ private static void log(String message)
+ {
+ if (logger != null)
+ {
logger.pushResource(message);
}
else System.out.println("RES >> " + message);
}
-
-
- /**
- * A private method for printing stack traces to a logger if it exists.
+
+ /** A private method for printing stack traces to a logger if it exists.
* If a custom logger has not been assigned, traces are printed to their default location.
- * @param e
- */
- private static void printStackTrace(Exception e) {
- if (logger != null) e.printStackTrace(logger.getStream());
+ *
+ * @param e */
+ private static void printStackTrace(Exception e)
+ {
+ if (logger != null)
+ e.printStackTrace(logger.getStream());
else e.printStackTrace();
}
-
}