|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.presentation.Presentation
public final class Presentation
This class creates AnyLogic GUI and controls the model execution in GUI
applications and applets. The presentation has a panel, a toolbar and a
status bar. The presentation can be created in three modes: application,
applet and component. In application mode the Presentation creates JFrame
and puts its components there. In applet mode Presentation embeds its
components into a given JApplet. In component mode the Presentation assumes
that an externally created container takes care of embedding and laying
out the presentation components.
After creating an instance of Presentation you need to call its start()
method.
The GUI is highly customizable: you can control what sections of the
toolbar and the status bar are visible.
| Field Summary | |
|---|---|
static int |
MODE_APPLET
|
static int |
MODE_APPLICATION
|
static int |
MODE_COMPONENT
|
| Constructor Summary | |
|---|---|
Presentation(Experiment<?> ex,
int mode,
java.awt.Container container)
Creates a Presentation (AnyLogic model GUI components) for a given experiment in a given mode: MODE_APPLICATION, MODE_APPLET, or MODE_COMPONENT. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
A method of ActionListener interface. |
void |
addSnapshotEventListener(SnapshotEventListener listener)
Registers listener for snapshot events, this listener is notified about changes performed by saveSnapshot(String) and
loadSnapshot(String) methodsDoes nothing if the given listener has already been added |
void |
close()
This method returns immediately and performs the following actions in a separate thread: stops experiment if it is not stopped, destroys the model and closes experiment window (only if model is started in the application mode) |
javax.swing.JApplet |
getApplet()
In applet mode returns the applet, otherwise returns null. |
java.awt.Container |
getContainer()
Returns frame, applet, or other container of the presentation GUI. |
Experiment<?> |
getExperiment()
Returns the experiment associated with this presentation. |
javax.swing.JFrame |
getFrame()
In application mode returns the frame, otherwise returns null. |
int |
getMode()
Returns the mode of the presentation: MODE_APPLICATION, MODE_APPLET, or MODE_COMPONENT. |
Panel |
getPanel()
Returns the panel - the area where the model active objects draw themselves. |
StatusBar |
getStatusBar()
Returns the status bar of AnyLogic GUI application or applet. |
ToolBar |
getToolBar()
Returns the tool bar of AnyLogic GUI application or applet. |
boolean |
isFullScreen()
Returns true if the frame mode is full screen, false if it is normal. |
boolean |
isMaximized()
Returns true if the model window is maximized,
false otherwise |
boolean |
isPanningEnabled()
Tests if mouse panning is enabled. |
boolean |
isZoomEnabled()
Tests if zoom from the GUI is enabled. |
void |
loadSnapshot(java.lang.String fileName)
Stops experiment and loads snapshot (in its 'not running' state), doesn't resume simulation of loaded snapshot. |
void |
onActiveObjectDestroyed(ActiveObject ao)
A callback called by the engine when an active object is being destroyed. |
void |
openWebSite(java.lang.String url)
Opens web page with the given URL in the browser |
void |
refresh()
Refreshes all presentation components (tool bar, status bar and the panel). |
void |
removeSnapshotEventListener(SnapshotEventListener listener)
Unregisters listener for snapshot events (which was previously registered using addSnapshotEventListener(SnapshotEventListener)
method)Does nothing if the given listener has already been removed |
void |
saveSnapshot(java.lang.String fileName)
Pauses experiment if it is currently running, saves snapshot and then resumes experiment if it was running On any error throws nothing. |
void |
setConfirmWindowClose(boolean confirm)
Configures the presentation window to show confirmation dialog when user tries to close the model window. |
void |
setFullScreen(boolean full)
In application mode, sets the full screen or normal. |
void |
setMaximized(boolean maximized)
In application mode, sets the window state to maximized or normal. |
void |
setPanelSize(int width,
int height)
In application mode, sets the size of the frame so that the frame's inner panel dimensions are exactly width by height pixels. |
void |
setPanningEnabled(boolean yes)
Enables or disables panning with mouse right+drag, but does not affect programmatic changes of offsets that are always possible. |
void |
setPresentable(Presentable p)
Sets the presentable object to be displayed by the presentation panel. |
void |
setZoomEnabled(boolean yes)
Enables or disables zoom initiated from the GUI (button. mouse, or keyboard), but does not affect programmatic changes of zoom that are always possible. |
void |
showErrorDialog(java.lang.String text,
java.lang.String title)
Shows a standard error dialog box with the given text. |
void |
showMessageDialog(java.lang.String text)
Shows a standard message dialog box with the given text. |
void |
start()
Starts the GUI, subject to mode: in application mode initializes and shows frame; in application and applet mode lays out the toolbar, panel and the status bar. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MODE_APPLICATION
public static final int MODE_APPLET
public static final int MODE_COMPONENT
| Constructor Detail |
|---|
public Presentation(Experiment<?> ex,
int mode,
java.awt.Container container)
ex - the experimentmode - the modecontainer - the applet in applet mode, the external container in component mode, or null| Method Detail |
|---|
public void start()
public void close()
public int getMode()
public Panel getPanel()
public StatusBar getStatusBar()
public ToolBar getToolBar()
public java.awt.Container getContainer()
public javax.swing.JFrame getFrame()
public javax.swing.JApplet getApplet()
public void setPresentable(Presentable p)
public void onActiveObjectDestroyed(ActiveObject ao)
ao - the active object being destroyedpublic Experiment<?> getExperiment()
public boolean isFullScreen()
public void setPanelSize(int width,
int height)
width - the width of the panel in pixelsheight - the height of the panel in pixelspublic void showMessageDialog(java.lang.String text)
text - the text to display
public void showErrorDialog(java.lang.String text,
java.lang.String title)
text - the text to displaypublic void setZoomEnabled(boolean yes)
yes - if true, zoom is enabled, if false - disabledpublic boolean isZoomEnabled()
public void setPanningEnabled(boolean yes)
yes - if true, panning is enabled, if false - disabledpublic boolean isPanningEnabled()
public void refresh()
public void addSnapshotEventListener(SnapshotEventListener listener)
saveSnapshot(String) and
loadSnapshot(String) methods
listener - the listener of snapshot eventspublic void removeSnapshotEventListener(SnapshotEventListener listener)
addSnapshotEventListener(SnapshotEventListener)
method)
listener - the listener of snapshot eventspublic void saveSnapshot(java.lang.String fileName)
addSnapshotEventListener(SnapshotEventListener)
fileName - the name of snapshot filepublic void loadSnapshot(java.lang.String fileName)
addSnapshotEventListener(SnapshotEventListener)
fileName - the name of snapshot filepublic void setFullScreen(boolean full)
full - if true - go full screen, otherwise restore normal modepublic void setMaximized(boolean maximized)
maximized - if true - the window will
be maximized, otherwise - restored to the normal sizepublic void setConfirmWindowClose(boolean confirm)
confirm - true enables close confirmation,
false disablespublic boolean isMaximized()
true if the model window is maximized,
false otherwise
true if the model window is maximizedpublic void openWebSite(java.lang.String url)
url - the url to openpublic void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed in interface java.awt.event.ActionListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||