public abstract class ViewAppState extends CompositeAppState implements IEmbeddedViewClient
ViewAppState
is a custom SimpleAppState
designed to
plug into a core MasterApplication
. Each ViewAppState
can request multiple EmbeddedView
s from the
MasterApplication
and can embed these views in an SWT
Composite
.
The standard lifecycle of a ViewAppState
is as follows:
MasterApplication
already exists and is initialized.ViewAppState
is initialized.ViewAppState
is started (see
start(MasterApplication)
).Composite
(see
createComposite(Composite)
).Composite
is disposed.ViewAppState
is stopped (see stop()
).ViewAppState
can be simultaneously embedded in multiple
Composite
s, and each ViewAppState
should support
the ability to be stopped and restarted at a later time.
Constructor and Description |
---|
ViewAppState()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanupAppState()
Disconnects the
ViewAppState from the associated
Application . |
org.eclipse.swt.widgets.Composite |
createComposite(org.eclipse.swt.widgets.Composite parent)
Creates a new SWT
Composite with this ViewAppState
embedded within it. |
com.jme3.scene.Node |
createHUD(EmbeddedView view)
Returns the
rootGuiNode , which should be attached to a ViewPort. |
java.lang.Object |
createViewCamera(EmbeddedView view)
Creates a default
FlightCamera for the specified
EmbeddedView . |
void |
disposeHUD(EmbeddedView view)
Detaches all children from the GUI/HUD
Node ,
guiNode . |
void |
disposeViewCamera(EmbeddedView view)
Disposes specified interactive camera associated with the specified
EmbeddedView . |
void |
exportImage()
Exports the view to an image file.
|
com.jme3.math.Ray |
getCrosshairRay()
Gets a Ray from the crosshair's location to the grid.
|
com.jme3.math.Ray |
getCursorRay()
Gets a Ray from the camera to the cursor.
|
com.jme3.math.Ray |
getCursorRayFromClick()
Gets a Ray from the camera to the cursor.
|
boolean |
getDisplayAxes() |
boolean |
getDisplayHUD() |
com.jme3.scene.Node |
getRootNode()
Gets the
ViewAppState 's root Node . |
com.jme3.scene.Node |
getSceneRoot(EmbeddedView view)
Returns the
rootNode . |
void |
setDisplayAxes(boolean display)
Sets whether or not to show the
axes . |
void |
setDisplayHUD(boolean display)
Sets whether or not to show the HUD (
guiNode ). |
void |
start(com.jme3.app.Application app)
Overrides the default behavior to do nothing.
|
void |
start(MasterApplication app)
Starts the
ViewAppState by attaching it to the specified
MasterApplication . |
void |
stop()
This method detaches from the
embeddedView before performing the
default stop operation. |
void |
updateHUD(EmbeddedView view,
int width,
int height)
Notifies the client that a HUD must be updated based on the provided
width and height of the associated
EmbeddedView 's underlying
AwtPanel . |
void |
updateViewCamera(EmbeddedView view,
boolean enabled)
Enables or disables the default
FlightCamera associated with the
EmbeddedView . |
void |
viewActivated(EmbeddedView view)
Notifies the client that the
EmbeddedView (i.e., the
underlying AwtPanel ) has been activated. |
void |
viewDeactivated(EmbeddedView view)
Notifies the client that the
EmbeddedView (i.e., the
underlying AwtPanel ) has been deactivated. |
void |
viewResized(EmbeddedView view,
int width,
int height)
Notifies the client that the
EmbeddedView 's underlying
AwtPanel has been resized. |
disableControls, enableControls, initialize
cleanup, createBasicMaterial, createLitMaterial, enqueue, getApplication, getCollision, getCrosshairRay, getCursorRay, getCursorRayFromClick, getMaterial, isEnabled, isInitialized, postRender, printCollisionResults, removeMaterial, render, setEnabled, setMaterial, stateAttached, stateDetached, update
public org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent)
Composite
with this ViewAppState
embedded within it. This method gets an EmbeddedView
from the
MasterApplication
, connects with that view, and embeds that view
in the Composite
.parent
- The parent Composite
.Composite
that has an embedded jME view managed
by this ViewAppState
. This Composite
's
layout should be set by the caller. This
Composite
should be disposed when it is no longer
required.public void exportImage()
public void start(com.jme3.app.Application app)
start(MasterApplication)
instead.start
in class SimpleAppState
app
- The jME Application
that will be hosting this
SimpleAppState
.public void start(MasterApplication app)
ViewAppState
by attaching it to the specified
MasterApplication
.app
- The jME-based MasterApplication
that will be
hosting this ViewAppState
.public void stop()
embeddedView
before performing the
default stop operation.stop
in class CompositeAppState
public void cleanupAppState()
ViewAppState
from the associated
Application
.
Note: If this method is overridden, then the first call from the
sub-class should be super.cleanupAppState();
in order to
properly clean up the default SimpleAppState
and
ViewAppState
features.
public com.jme3.scene.Node getRootNode()
ViewAppState
's root Node
. Any updates
to this value should be done on the render thread if the
ViewAppState
is initialized.ViewAppState
's root Node
.public boolean getDisplayHUD()
guiNode
) should be displayed.setDisplayHUD(boolean)
public void setDisplayHUD(boolean display)
guiNode
). If the value
changes, this will enable/disable the HUD in the rendering thread.display
- Whether or not to show the HUD.getDisplayHUD()
public boolean getDisplayAxes()
axes
should be displayed.setDisplayAxes(boolean)
public void setDisplayAxes(boolean display)
axes
. If the value changes, this
will enable/disable the axes in the rendering thread.display
- Whether or not to show the axes.getDisplayAxes()
public com.jme3.scene.Node getSceneRoot(EmbeddedView view)
rootNode
.getSceneRoot
in interface IEmbeddedViewClient
view
- The EmbeddedView
that is requesting the root
Node
.Node
for the client's scene.public com.jme3.scene.Node createHUD(EmbeddedView view)
rootGuiNode
, which should be attached to a ViewPort.
Attach custom spatials to the guiNode
, which can be toggled with
setDisplayHUD(boolean)
.createHUD
in interface IEmbeddedViewClient
view
- The EmbeddedView
that is requesting the GUI/HUD
Node
.Node
.public void updateHUD(EmbeddedView view, int width, int height)
IEmbeddedViewClient
EmbeddedView
's underlying
AwtPanel
.
Note: This method is called from the render thread.
updateHUD
in interface IEmbeddedViewClient
view
- The EmbeddedView
whose size has changed.width
- The new width of the EmbeddedView
's
AwtPanel
.height
- The new width of the EmbeddedView
's
AwtPanel
.public void disposeHUD(EmbeddedView view)
Node
,
guiNode
.disposeHUD
in interface IEmbeddedViewClient
view
- The EmbeddedView
that is detaching from the
GUI/HUD Node
.public java.lang.Object createViewCamera(EmbeddedView view)
FlightCamera
for the specified
EmbeddedView
.createViewCamera
in interface IEmbeddedViewClient
view
- The EmbeddedView
that is requesting an
interactive camera.public void updateViewCamera(EmbeddedView view, boolean enabled)
FlightCamera
associated with the
EmbeddedView
.updateViewCamera
in interface IEmbeddedViewClient
view
- The EmbeddedView
that has gained or lost focus.enabled
- Whether or not to enable the interactive camera.public void disposeViewCamera(EmbeddedView view)
IEmbeddedViewClient
EmbeddedView
.
Note: This method is called from the render thread.
disposeViewCamera
in interface IEmbeddedViewClient
view
- The EmbeddedView
that is removing the interactive
camera.public void viewResized(EmbeddedView view, int width, int height)
IEmbeddedViewClient
EmbeddedView
's underlying
AwtPanel
has been resized.
Note: This method is called from the render thread.
viewResized
in interface IEmbeddedViewClient
view
- The EmbeddedView
whose size has changed.width
- The new width of the EmbeddedView
's
AwtPanel
.height
- The new width of the EmbeddedView
's
AwtPanel
.public void viewActivated(EmbeddedView view)
IEmbeddedViewClient
EmbeddedView
(i.e., the
underlying AwtPanel
) has been activated.viewActivated
in interface IEmbeddedViewClient
view
- The activated view.public void viewDeactivated(EmbeddedView view)
IEmbeddedViewClient
EmbeddedView
(i.e., the
underlying AwtPanel
) has been deactivated.viewDeactivated
in interface IEmbeddedViewClient
view
- The deactivated view.public com.jme3.math.Ray getCrosshairRay()
public com.jme3.math.Ray getCursorRay()
Use this method when getting the cursor's location after a mouse-move
event. For mouse-click events, use getCursorRayFromClick()
.
public com.jme3.math.Ray getCursorRayFromClick()
During click events, jME3 calculates the 2D cursor position as
Y-decreasing from top to bottom. Use this method when getting the
cursor's location after a mouse-click event. For mouse-move events, use
getCursorRay()
.