public abstract class GwtApplication extends java.lang.Object implements Application
Application
based on GWT. Clients have to override getConfig()
and
createApplicationListener()
. Clients can override the default loading screen via
getPreloaderCallback()
and implement any loading screen drawing via GWT widgets.Modifier and Type | Class and Description |
---|---|
static class |
GwtApplication.AgentInfo
Returned by
agentInfo . |
static interface |
GwtApplication.LoadingListener
LoadingListener interface main purpose is to do some things before or after
setupLoop() |
Application.ApplicationType
Modifier and Type | Field and Description |
---|---|
protected TextArea |
log |
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_NONE
Constructor and Description |
---|
GwtApplication() |
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Adds a new
LifecycleListener to the application. |
protected void |
adjustMeterPanel(Panel meterPanel,
Style meterStyle)
called by
createPreloaderPanel(String) for overriding purpose. |
static GwtApplication.AgentInfo |
agentInfo()
Contains precomputed information on the user-agent.
|
static void |
consoleLog(java.lang.String message) |
abstract ApplicationListener |
createApplicationListener() |
protected GwtAudio |
createAudio() |
protected Files |
createFiles() |
protected GwtInput |
createInput(CanvasElement canvas,
GwtApplicationConfiguration config) |
Preloader |
createPreloader() |
protected PreloaderCallback |
createPreloaderPanel(java.lang.String logoUrl) |
void |
debug(java.lang.String tag,
java.lang.String message)
Logs a debug message to the console or logcat
|
void |
debug(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs a debug message to the console or logcat
|
void |
error(java.lang.String tag,
java.lang.String message)
Logs an error message to the console or logcat
|
void |
error(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs an error message to the console or logcat
|
void |
exit()
Schedule an exit from the application.
|
ApplicationListener |
getApplicationListener() |
ApplicationLogger |
getApplicationLogger() |
Audio |
getAudio() |
java.lang.String |
getBaseUrl() |
CanvasElement |
getCanvasElement() |
Clipboard |
getClipboard() |
abstract GwtApplicationConfiguration |
getConfig() |
Files |
getFiles() |
Graphics |
getGraphics() |
Input |
getInput() |
long |
getJavaHeap() |
GwtApplication.LoadingListener |
getLoadingListener() |
int |
getLogLevel()
Gets the log level.
|
long |
getNativeHeap() |
Net |
getNet() |
Widget |
getNoWebGLSupportWidget()
Override this method to return a custom widget informing the that their browser lacks support of WebGL.
|
Preferences |
getPreferences(java.lang.String name)
Returns the
Preferences instance of this Application. |
Preloader |
getPreloader() |
java.lang.String |
getPreloaderBaseURL() |
PreloaderCallback |
getPreloaderCallback()
This procedure creates the preloader panel and returns a preloader callback to update it.
|
Panel |
getRootPanel() |
Application.ApplicationType |
getType() |
int |
getVersion() |
static boolean |
isMobileDevice() |
void |
log(java.lang.String tag,
java.lang.String message)
Logs a message to the console or logcat
|
void |
log(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs a message to the console or logcat
|
void |
onModuleLoad() |
void |
postRunnable(java.lang.Runnable runnable)
Posts a
Runnable on the main loop thread. |
void |
removeLifecycleListener(LifecycleListener listener)
Removes the
LifecycleListener . |
void |
setApplicationLogger(ApplicationLogger applicationLogger)
Sets the current Application logger.
|
void |
setLoadingListener(GwtApplication.LoadingListener loadingListener) |
void |
setLogLevel(int logLevel)
Sets the log level.
|
public abstract GwtApplicationConfiguration getConfig()
GwtApplication
.public java.lang.String getPreloaderBaseURL()
public ApplicationListener getApplicationListener()
getApplicationListener
in interface Application
ApplicationListener
instancepublic abstract ApplicationListener createApplicationListener()
public void onModuleLoad()
public Widget getNoWebGLSupportWidget()
public Panel getRootPanel()
public Preloader createPreloader()
public PreloaderCallback getPreloaderCallback()
adjustMeterPanel(Panel, Style)
.
public PreloaderCallback getPreloaderCallback () { return createPreloaderPanel(GWT.getHostPageBaseURL() + "logo_preload.png"); }
protected PreloaderCallback createPreloaderPanel(java.lang.String logoUrl)
protected void adjustMeterPanel(Panel meterPanel, Style meterStyle)
createPreloaderPanel(String)
for overriding purpose.
override this method to adjust the styles of the loading progress bar. Example for changing
the bars padding and color:
meterPanel.setStyleName("gdx-meter"); meterPanel.addStyleName("nostripes"); Style meterPanelStyle = meterPanel.getElement().getStyle(); meterPanelStyle.setProperty("backgroundColor", "#ff0000"); meterPanelStyle.setProperty("padding", "0px"); meterStyle.setProperty("backgroundColor", "#ffffff"); meterStyle.setProperty("backgroundImage", "none");
public Graphics getGraphics()
getGraphics
in interface Application
Graphics
instancepublic Audio getAudio()
getAudio
in interface Application
Audio
instancepublic Input getInput()
getInput
in interface Application
Input
instancepublic Files getFiles()
getFiles
in interface Application
Files
instancepublic Net getNet()
getNet
in interface Application
Net
instancepublic void log(java.lang.String tag, java.lang.String message)
Application
log
in interface Application
public void log(java.lang.String tag, java.lang.String message, java.lang.Throwable exception)
Application
log
in interface Application
public void error(java.lang.String tag, java.lang.String message)
Application
error
in interface Application
public void error(java.lang.String tag, java.lang.String message, java.lang.Throwable exception)
Application
error
in interface Application
public void debug(java.lang.String tag, java.lang.String message)
Application
debug
in interface Application
public void debug(java.lang.String tag, java.lang.String message, java.lang.Throwable exception)
Application
debug
in interface Application
public void setLogLevel(int logLevel)
Application
Application.LOG_NONE
will mute all log output. Application.LOG_ERROR
will only let error messages through.
Application.LOG_INFO
will let all non-debug messages through, and Application.LOG_DEBUG
will let all messages through.setLogLevel
in interface Application
logLevel
- Application.LOG_NONE
, Application.LOG_ERROR
, Application.LOG_INFO
, Application.LOG_DEBUG
.public int getLogLevel()
Application
getLogLevel
in interface Application
public void setApplicationLogger(ApplicationLogger applicationLogger)
Application
Application.log(String, String)
are delegated to this ApplicationLogger
setApplicationLogger
in interface Application
public ApplicationLogger getApplicationLogger()
getApplicationLogger
in interface Application
ApplicationLogger
public Application.ApplicationType getType()
getType
in interface Application
Application.ApplicationType
this application has, e.g. Android or Desktoppublic int getVersion()
getVersion
in interface Application
public long getJavaHeap()
getJavaHeap
in interface Application
public long getNativeHeap()
getNativeHeap
in interface Application
public Preferences getPreferences(java.lang.String name)
Application
Preferences
instance of this Application. It can be used to store application settings across runs.getPreferences
in interface Application
name
- the name of the preferences, must be useable as a file name.public Clipboard getClipboard()
getClipboard
in interface Application
public void postRunnable(java.lang.Runnable runnable)
Application
Runnable
on the main loop thread.
In a multi-window application, the Gdx.graphics and Gdx.input values may be
unpredictable at the time the Runnable is executed. If graphics or input are needed, they can be copied
to a variable to be used in the Runnable. For example:
final Graphics graphics = Gdx.graphics;
postRunnable
in interface Application
runnable
- the runnable.public void exit()
Application
exit
in interface Application
protected GwtAudio createAudio()
protected Files createFiles()
protected GwtInput createInput(CanvasElement canvas, GwtApplicationConfiguration config)
public static boolean isMobileDevice()
true
if application runs on a mobile devicepublic static GwtApplication.AgentInfo agentInfo()
public java.lang.String getBaseUrl()
public Preloader getPreloader()
public CanvasElement getCanvasElement()
public GwtApplication.LoadingListener getLoadingListener()
public void setLoadingListener(GwtApplication.LoadingListener loadingListener)
public void addLifecycleListener(LifecycleListener listener)
Application
LifecycleListener
to the application. This can be used by extensions to hook into the lifecycle more
easily. The ApplicationListener
methods are sufficient for application level development.addLifecycleListener
in interface Application
public void removeLifecycleListener(LifecycleListener listener)
Application
LifecycleListener
.removeLifecycleListener
in interface Application
public static void consoleLog(java.lang.String message)