public abstract class AbstractApplication
extends javafx.application.Application
Application that adds a bunch of functionality such as scaling and cursor visibility.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractApplication.Setting
A
Setting represents a setting that can be enabled or disabled. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractApplication()
Constructs a new
AbstractApplication with no title. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
configureMenuBar(javafx.scene.control.MenuBar menuBar)
Called when the
MenuBar can be configured. |
protected abstract void |
configurePixels(byte[] pixels)
Called when pixels can be configured at start.
|
protected abstract void |
configureStage(javafx.stage.Stage stage)
Called when the primary
Stage can be configured. |
protected abstract void |
configureStatusBar(javafx.scene.layout.HBox hBox)
Called when the status bar can be configured.
|
protected abstract void |
configureTabPane(javafx.scene.control.TabPane tabPane)
Called when the
TabPane can be configured. |
protected void |
enter()
Enters the FPS-game mode.
|
protected void |
exit()
Call this method when it's time to exit.
|
protected int |
getCanvasHeight()
Returns the canvas height.
|
protected int |
getCanvasWidth()
Returns the canvas width.
|
protected FPSCounter |
getFPSCounter()
Returns the
FPSCounter associated with this AbstractApplication. |
protected int |
getKernelHeight()
Returns the kernel height.
|
protected int |
getKernelWidth()
Returns the kernel width.
|
protected int |
getMouseX()
Returns the X-coordinate of the mouse.
|
protected int |
getMouseY()
Returns the Y-coordinate of the mouse.
|
protected boolean |
hasEntered()
Returns
true if, and only if, this AbstractApplication has been entered like an FPS-game, false otherwise. |
protected boolean |
hasRequestedToExit()
Returns
true if, and only if, exit has been requested, false otherwise. |
protected boolean |
isCursorHidden()
Returns
true if, and only if, the cursor is hidden, false otherwise. |
protected boolean |
isKeyPressed()
Returns
true if, and only if, at least one key is being pressed, false otherwise. |
protected boolean |
isKeyPressed(javafx.scene.input.KeyCode keyCode)
Returns
true if, and only if, the key denoted by keyCode is being pressed, false otherwise. |
protected boolean |
isKeyPressed(javafx.scene.input.KeyCode keyCode,
boolean isKeyPressedOnce)
Returns
true if, and only if, the key denoted by keyCode is being pressed, false otherwise. |
protected boolean |
isMouseDragging()
Returns
true if, and only if, the mouse is being dragged, false otherwise. |
protected boolean |
isMouseMoving()
Returns
true if, and only if, the mouse is being moved, false otherwise. |
protected boolean |
isMouseRecentering()
Returns
true if, and only if, mouse re-centering is being performed, false otherwise. |
protected void |
leave()
Leaves the FPS-game mode.
|
protected abstract void |
onExit()
Called before this
AbstractApplication is finally exiting. |
protected abstract void |
onMouseDragged(float x,
float y)
Called when the mouse is dragged.
|
protected abstract void |
onMouseMoved(float x,
float y)
Called when the mouse is moved.
|
protected abstract void |
render()
Called when rendering.
|
protected void |
setCanvasHeight(int canvasHeight)
Sets a new canvas height.
|
protected void |
setCanvasWidth(int canvasWidth)
Sets a new canvas width.
|
protected void |
setCursorHidden(boolean isCursorHidden)
Sets whether the cursor should be hidden or shown.
|
protected void |
setKernelHeight(int kernelHeight)
Sets a new kernel height.
|
protected void |
setKernelWidth(int kernelWidth)
Sets a new kernel width.
|
protected void |
setMouseRecentering(boolean isMouseRecentering)
Sets the mouse re-centering.
|
void |
start(javafx.stage.Stage stage)
Starts this
AbstractApplication instance. |
protected abstract void |
update()
Called when updating.
|
protected AbstractApplication()
AbstractApplication with no title.public final void start(javafx.stage.Stage stage)
AbstractApplication instance.start in class javafx.application.Applicationstage - a Stageprotected final FPSCounter getFPSCounter()
FPSCounter associated with this AbstractApplication.FPSCounter associated with this AbstractApplicationprotected final boolean hasEntered()
true if, and only if, this AbstractApplication has been entered like an FPS-game, false otherwise.
To enter this AbstractApplication like an FPS-game, call enter().
If it has been entered like an FPS-game and you want to leave, call leave().
When it's been entered like an FPS-game, the cursor will be hidden and the mouse will be re-centering.
true if, and only if, this AbstractApplication has been entered like an FPS-game, false otherwiseprotected final boolean hasRequestedToExit()
true if, and only if, exit has been requested, false otherwise.
To request this AbstractApplication to exit, call exit().
true if, and only if, exit has been requested, false otherwiseprotected final boolean isCursorHidden()
true if, and only if, the cursor is hidden, false otherwise.true if, and only if, the cursor is hidden, false otherwiseprotected final boolean isKeyPressed()
true if, and only if, at least one key is being pressed, false otherwise.true if, and only if, at least one key is being pressed, false otherwiseprotected final boolean isKeyPressed(javafx.scene.input.KeyCode keyCode)
true if, and only if, the key denoted by keyCode is being pressed, false otherwise.
Calling this method is equivalent to calling isKeyPressed(keyCode, false).
If keyCode is null, a NullPointerException will be thrown.
keyCode - a KeyCodetrue if, and only if, the key denoted by keyCode is being pressed, false otherwisejava.lang.NullPointerException - thrown if, and only if, keyCode is nullprotected final boolean isKeyPressed(javafx.scene.input.KeyCode keyCode,
boolean isKeyPressedOnce)
true if, and only if, the key denoted by keyCode is being pressed, false otherwise.
If isKeyPressedOnce is true, only the first call to this method will return true per press-release cycle given a specific key.
If keyCode is null, a NullPointerException will be thrown.
keyCode - a KeyCodeisKeyPressedOnce - true if, and only if, a key press should occur at most one time per press-release cycle, false otherwisetrue if, and only if, the key denoted by keyCode is being pressed, false otherwisejava.lang.NullPointerException - thrown if, and only if, keyCode is nullprotected final boolean isMouseDragging()
true if, and only if, the mouse is being dragged, false otherwise.true if, and only if, the mouse is being dragged, false otherwiseprotected final boolean isMouseMoving()
true if, and only if, the mouse is being moved, false otherwise.true if, and only if, the mouse is being moved, false otherwiseprotected final boolean isMouseRecentering()
true if, and only if, mouse re-centering is being performed, false otherwise.true if, and only if, mouse re-centering is being performed, false otherwiseprotected final int getCanvasHeight()
protected final int getCanvasWidth()
protected final int getKernelHeight()
protected final int getKernelWidth()
protected final int getMouseX()
protected final int getMouseY()
protected abstract void configureMenuBar(javafx.scene.control.MenuBar menuBar)
MenuBar can be configured.menuBar - the MenuBar to configureprotected abstract void configurePixels(byte[] pixels)
pixels - a byte array with pixel dataprotected abstract void configureStage(javafx.stage.Stage stage)
Stage can be configured.stage - the primary Stage to configureprotected abstract void configureStatusBar(javafx.scene.layout.HBox hBox)
hBox - a HBox that acts as a status barprotected abstract void configureTabPane(javafx.scene.control.TabPane tabPane)
TabPane can be configured.tabPane - the TabPane to configureprotected final void exit()
When this AbstractApplication is exiting, it will call onExit() before finally exiting.
If this AbstractApplication has been entered like an FPS-game, it will leave this state instead of exiting. In this case you'll have to call this method twice in order to exit.
protected final void enter()
If you want to leave this FPS-game mode, call leave().
protected final void leave()
If you want to enter this FPS-game mode, call enter().
protected abstract void onExit()
AbstractApplication is finally exiting.protected abstract void onMouseDragged(float x,
float y)
x - the new X-coordinatey - the new Y-coordinateprotected abstract void onMouseMoved(float x,
float y)
x - the new X-coordinatey - the new Y-coordinateprotected abstract void render()
protected final void setCanvasHeight(int canvasHeight)
canvasHeight - a new canvas heightprotected final void setCanvasWidth(int canvasWidth)
canvasWidth - a new canvas widthprotected final void setCursorHidden(boolean isCursorHidden)
isCursorHidden - true if, and only if, the cursor should be hidden, false otherwiseprotected final void setKernelHeight(int kernelHeight)
kernelHeight - a new kernel heightprotected final void setKernelWidth(int kernelWidth)
kernelWidth - a new kernel widthprotected final void setMouseRecentering(boolean isMouseRecentering)
isMouseRecentering - true if, and only if, mouse re-centering should be performed, false otherwiseprotected abstract void update()