Class EvoLudoWeb
- All Implemented Interfaces:
EntryPoint
,HasAttachHandlers
,EventHandler
,HasHandlers
,EventListener
,HasVisibility
,IsRenderable
,IsWidget
,ChangeListener
,MilestoneListener
,FullscreenChangeHandler
,HasFullscreenChangeHandlers
,CLOProvider
onModuleLoad()
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Custom handler for logging system.(package private) static interface
GWT magic to define GUI elements (see EvoLudoWeb.ui.xml).(package private) class
Helper structure to store the current state of the GUI.Nested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
Nested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingAction
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AbstractView
Currently visible view(package private) HashMap
<String, AbstractView> Look-up table for active views.final CLOption
Command line option to set the size of the GUI or enter fullscreen.final CLOption
Command line option to set the data view displayed in the GUI.private String
Default set of parameters as specified for the initial invocation.private int
Threshold level for overriding status message.(package private) HandlerRegistration
Reference to registration of drag'n'drop handlers (if one was installed).(package private) HandlerRegistration
Reference to registration of drag'n'drop handlers (if one was installed).(package private) String
ID of element in DOM that contains the EvoLudo lab.(package private) EvoLudoGWT
Controller.(package private) Button
The 'Apply' button ('Standalone' in ePubs)(package private) Label
The text field containing the command line options for the EvoLudo model.(package private) FlowPanel
Panel containing all elements to change/view parameters.(package private) DeckLayoutPanel
Panel containing all the canvas elements to display the EvoLudo model's data.(package private) Button
The 'Default' button(package private) Button
The 'Help' button(package private) Button
The 'Init'/'Reset' button(package private) HeaderPanel
Basic layout of EvoLudo model GUI with header (for time display,evoludoTime
, and view selectorevoludoViews
), footer (for delay sliderevoludoSlider
, control buttonsevoludoSettings
,evoludoInitReset
,evoludoStartStop
,evoludoStep
and status lineevoludoStatus
plus possibly parametersevoludoCLOPanel
) as well as the main content area (for different canvases,evoludoDeck
).(package private) HTML
Overlay for drag'n'drop operations(package private) HTMLPanel
Outermost panel containing the EvoLudo GUI.(package private) ResizeLayoutPanel
Panel implementing the ability to resize the GUI of EvoLudo models (only possible in browser or standalone mode in ePubs).(package private) Button
'Settings' button(package private) Slider
Slider adjusting the delay between updates.(package private) Button
The 'Start'/'Stop' button(package private) HTML
Status line of EvoLudo model GUI.(package private) Button
The 'Step' button(package private) Label
Label to display elapsed generations (time).(package private) ListBox
Selector for all graphical representations to visualize the state of the EvoLudo model.(package private) HandlerRegistration
The reference to the fullscreen event handler.(package private) Widget
The reference to the fullscreen widget.(package private) EvoLudoWeb.GUIState
Field to store the current state of the GUI while applying a new set of parameters.private static boolean
The helper variable to indicate JavaScript for dealing with zip archives has already been loaded.private String
By default the first data view is shown.private boolean
The helper variable to indicate whether the Alt key is pressed.private boolean
The helper variable to indicate whether the Shift key is pressed.private final boolean
Indicator whether display system supports WebGL to display population structures in 3D.private static EvoLudoWeb
Popup EvoLudo models (seeEvoLudoTrigger
) should attract all keyboard events.protected EvoLudoWeb.EvoLogHandler
Handler for the log framework to report notifications etc.protected Logger
Logger for keeping track of and reporting events and issues.protected EvoLudoTrigger.LightboxPanel
The transparent backdrop of popup EvoLudo labs is stored here to reuse.static EvoLudoWeb
Reference to running engine in ePubs (to conserve resources only one lab can be running at a time)protected Timer
On touch devices, theInit
button changes toReset
for extended touches.private static EvoLudoWeb.EvoLudoWebBinder
GWT magic to create GUI elements (see EvoLudoWeb.ui.xml).protected double
Time of last GUI update(package private) Console
Console view requires slightly special treatment to ensure results of early feature detection get reported.Fields inherited from class UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Note: empty default constructor seems to be required by GWT.EvoLudoWeb
(String id, String clo) Main constructor for EvoLudo labs.EvoLudoWeb
(String id, EvoLudoTrigger.LightboxPanel popup) Constructor restricted to trigger buttons that create an overlay displaying an EvoLudo lab. -
Method Summary
Modifier and TypeMethodDescriptionAdds aFullscreenChangeEvent
handler.private final void
addKeyListeners
(EvoLudoWeb evoludo) JSNI method: add global key event listeners for 'keydown', 'keyup', and 'keypress' events.private void
addView
(AbstractView view, HashMap<String, AbstractView> oldViews) Convenience method to addview
to list of active viewsactiveViews
.void
applyCLO()
Process and apply the command line arguments stored inevoludoCLO
Loads new model (and unloads old one), if necessary, and loads/adjusts the data views as appropriate.protected void
changeViewTo
(AbstractView newView) Change view of EvoLudo model data.protected void
changeViewTo
(AbstractView newView, boolean force) Change view of EvoLudo model data.void
collectCLO
(CLOParser parser) All providers of command line options must implement this method to collect their options.private void
Helper method to update the views after the command line options have been applied.static void
createEvoLudoLab
(String id, String clo) Expose method for creating EvoLudo labs (EvoLudoWeb objects) to javascriptstatic void
Expose method for creating EvoLudoTriggers to javascript.void
displayStatus
(String msg) Displays a message in the status line of the EvoLudo GUI with the default levelLevel.INFO
.void
displayStatus
(String msg, int level) Displays a message in the status line of the EvoLudo GUI with the severitylevel
.static void
JSNI method: create EvoLudo labs directly from javascript.static void
JSNI method: create EvoLudo lab trigger buttons directly from javascript.static void
JSNI method: expose method for inserting EvoLudo models into ePub to javascript.static void
JSNI method: expose method for inserting EvoLudo models into HTML to javascript.protected void
Initialize or reset EvoLudo model.static void
insertEPubEvoLudoLab
(Element placeholder, String url) Fighting Apple Books constraints: Insert EvoLudo model in DOM by replacing theplaceholder
element with an iframe.static void
insertEvoLudoLab
(Element placeholder, String clo) Insert EvoLudo model in DOM by replacing theplaceholder
element.boolean
Check if EvoLudo model is visible on screen.boolean
keyDownHandler
(String key) Processkeydown
events to allow for repeating keyboard shortcuts.boolean
keyUpHandler
(String key) Processkeyup
events to allow for non-repeating keyboard shortcuts.private void
Helper method to update the views after the command line options have been applied.(package private) void
Log GWT features and GUI specifics.void
Called whenever the state of the EvoLudo model changed.void
Called after the EvoLudo model got re-initialized.void
Called after the EvoLudo model was reset.void
Called when the EvoLudo model starts running.void
Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).void
Called when EvoLudo model is unloading.void
Called when EvoLudo module finished loading.void
Called when the state of the EvoLudo module has been restored.void
Called when EvoLudo module is unloading.void
onApplyClick
(ClickEvent event) Apply command line parameters to EvoLudo model.void
onDefaultClick
(ClickEvent event) Discard current parameter settings and revert to default settings on initial launch of current model.void
Handler for drag'n'drop operation exiting lab.void
onDragOver
(DragOverEvent doe) Handler for drag'n'drop operation entering lab.void
Handler for dropping and restoring saved state.void
Called when aFullscreenChangeEvent
is fired.void
onHelpClick
(ClickEvent event) Displays a list and brief description of all parameters in the console,viewConsole
, including the default and current settings.void
onInitResetClick
(ClickEvent event) Initialize or reset EvoLudo model (action depends on title of button).void
onInitResetTouchEnd
(TouchEndEvent event) Touch ofInit
(orReset
) button ended.void
Touch ofInit
button started.void
onLoad()
void
Entry point method.void
onSettingsClick
(ClickEvent event) Toggle visibility of the text fieldevoludoCLOPanel
to view or modify the parameter settings.void
onSettingsTouchEnd
(TouchEndEvent event) Toggle visibility ofevoludoCLOPanel
to view or modify the parameter settings.void
Touch of parameter button started.void
onSliderClick
(ClickEvent event) Slider changed, adjust delay between updates.void
onSliderInput
(InputEvent event) Slider changed, adjust delay between updates.void
onStartStopClick
(ClickEvent event) Start
,Stop
button clicked.void
onStartStopTouchEnd
(TouchEndEvent event) Touch ofStart
,Stop
button ended.void
Touch ofStart
,Stop
button started.void
onStepClick
(ClickEvent event) Next
button clicked.void
onStepTouchEnd
(TouchEndEvent event) Touch ofNext
button ended.void
onStepTouchStart
(TouchStartEvent event) Touch ofNext
button started.void
onUnload()
void
onViewChange
(ChangeEvent event) Handler for changes of the view selector (evoludoViews
).private void
Helper method to advance the EvoLudo model by a single step.protected void
Helper method to deal with ePub specifics.private final void
removeKeyListeners
(EvoLudoWeb evoludo) JSNI method: remove all key event listeners that were registered forevoludo
.void
restoreFromString
(String filename, String content) Restore state of EvoLudo model from Stringcontent
.protected void
CLOParser issues warnings for unknown options but do not throw them away (can be annoying when switching between models).void
showHelp()
Show help in the console,viewConsole
.void
Prepare GUI to create a snapshot.(package private) void
Helper method to toggle the visibility ofevoludoCLOPanel
to view or modify the parameter settings.private void
Helper method to update counter of GUI.private void
Update GUI for running/stopped model.private void
The Alt-key toggles the button labels for controlling the EvoLudo lab.private void
Helper method to update status of GUI.protected void
Each EvoLudo model may entertain its own selection of views to visualize its data.Methods inherited from class Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
Methods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods inherited from class UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface CLOProvider
adjustCLO
Methods inherited from interface HasHandlers
fireEvent
Methods inherited from interface MilestoneListener
modelLoaded, modelRelaxed, modelSettings
-
Field Details
-
uiBinder
GWT magic to create GUI elements (see EvoLudoWeb.ui.xml). -
updatetime
protected double updatetimeTime of last GUI update -
runningEPub
Reference to running engine in ePubs (to conserve resources only one lab can be running at a time) -
engine
EvoLudoGWT engineController. Manages the interface with the outside world. -
logger
Logger for keeping track of and reporting events and issues. -
logEvoHandler
Handler for the log framework to report notifications etc. in EvoLudo's console -
dragEnterHandler
HandlerRegistration dragEnterHandlerReference to registration of drag'n'drop handlers (if one was installed). -
dragLeaveHandler
HandlerRegistration dragLeaveHandlerReference to registration of drag'n'drop handlers (if one was installed). -
fullscreenHandler
HandlerRegistration fullscreenHandlerThe reference to the fullscreen event handler. -
fullscreenWidget
Widget fullscreenWidgetThe reference to the fullscreen widget. -
elementID
String elementIDID of element in DOM that contains the EvoLudo lab. -
defaultCLO
Default set of parameters as specified for the initial invocation. -
activeViews
HashMap<String,AbstractView> activeViewsLook-up table for active views. This is the selection shown inevoludoViews
. -
initialView
By default the first data view is shown. In general this shows the strategies in the (structured) population in 2D. -
activeView
AbstractView activeViewCurrently visible view -
popup
The transparent backdrop of popup EvoLudo labs is stored here to reuse. -
viewConsole
Console viewConsoleConsole view requires slightly special treatment to ensure results of early feature detection get reported. -
evoludoPanel
Outermost panel containing the EvoLudo GUI. -
evoludoResize
Panel implementing the ability to resize the GUI of EvoLudo models (only possible in browser or standalone mode in ePubs). -
evoludoLayout
Basic layout of EvoLudo model GUI with header (for time display,evoludoTime
, and view selectorevoludoViews
), footer (for delay sliderevoludoSlider
, control buttonsevoludoSettings
,evoludoInitReset
,evoludoStartStop
,evoludoStep
and status lineevoludoStatus
plus possibly parametersevoludoCLOPanel
) as well as the main content area (for different canvases,evoludoDeck
). -
evoludoTime
Label to display elapsed generations (time). -
evoludoViews
Selector for all graphical representations to visualize the state of the EvoLudo model. -
evoludoDeck
Panel containing all the canvas elements to display the EvoLudo model's data. Only one is shown at any time, selected byevoludoViews
. -
evoludoSlider
Slider adjusting the delay between updates. -
evoludoSettings
'Settings' button -
evoludoInitReset
The 'Init'/'Reset' button -
showAltTouchTimer
On touch devices, theInit
button changes toReset
for extended touches. This timer controls the delay beforeReset
is shown. Any other touch event during this period cancels the timer. -
evoludoStartStop
The 'Start'/'Stop' button -
evoludoStep
The 'Step' button -
evoludoCLOPanel
Panel containing all elements to change/view parameters. Visibility toggled with the 'Settings' button,evoludoSettings
. Initially invisible. -
evoludoCLO
The text field containing the command line options for the EvoLudo model. Note,TextArea
causes grief with ePubs in Apple Books. -
evoludoApply
The 'Apply' button ('Standalone' in ePubs) -
guiState
EvoLudoWeb.GUIState guiStateField to store the current state of the GUI while applying a new set of parameters. -
evoludoDefault
The 'Default' button -
evoludoHelp
The 'Help' button -
evoludoStatus
Status line of EvoLudo model GUI. -
displayStatusThresholdLevel
private int displayStatusThresholdLevelThreshold level for overriding status message. -
evoludoOverlay
Overlay for drag'n'drop operations -
hasZipJs
private static boolean hasZipJsThe helper variable to indicate JavaScript for dealing with zip archives has already been loaded. -
isShiftDown
private boolean isShiftDownThe helper variable to indicate whether the Shift key is pressed. -
isAltDown
private boolean isAltDownThe helper variable to indicate whether the Alt key is pressed. -
cloView
Command line option to set the data view displayed in the GUI. -
cloSize
Command line option to set the size of the GUI or enter fullscreen. -
keyListener
Popup EvoLudo models (seeEvoLudoTrigger
) should attract all keyboard events. This is achieved by settingkeyListener
to the popup model. -
isWebGLSupported
private final boolean isWebGLSupportedIndicator whether display system supports WebGL to display population structures in 3D.
-
-
Constructor Details
-
EvoLudoWeb
private EvoLudoWeb()Note: empty default constructor seems to be required by GWT. Why? At least it does not need to be publicly exposed. -
EvoLudoWeb
Constructor restricted to trigger buttons that create an overlay displaying an EvoLudo lab.- Parameters:
id
- of trigger element in DOM (unique and automatically generated,onModuleLoad()
.popup
- semi-transparent overlay
-
EvoLudoWeb
Main constructor for EvoLudo labs.Note:
- If
id==null
the default IDelementID
is used - Attempts to fail gracefully if no element with
id
exists in DOM or if the HTML5canvas
element is not supported.
- Parameters:
id
- the DOM id of the element containing the labclo
- the string with the command line options
- If
-
-
Method Details
-
onModuleLoad
public void onModuleLoad()Entry point method. Process DOM and add/allocate an EvoLudo lab whenever a<div>
element withclass="evoludo-simulation"
is found. Parameters may be passed to the EvoLudo lab either through thedata-clo
attribute or as part of the URL as a parameterclo
. Similarly,<div>
elements withclass="evoludo-trigger-html"
are converted to buttons that trigger a popup EvoLudo lab. Buttons do not work in ePub's and hence trigger-'buttons' must be provided as anchor elements.- Specified by:
onModuleLoad
in interfaceEntryPoint
-
onLoad
public void onLoad()Called when loading GWT application. The contents of
evoludoCLO
serve as the command line options. IfevoludoCLO
is empty, thedata-clo
attribute of the lab element is checked for command line options. -
onUnload
public void onUnload()Called when unloading GWT application. Housekeeping routine to clean up and free as many resources as possible. For example, ensures that EvoLudo model stops running, removes lab from key listeners, removes drag'n'drop handler, unloads model.
Important: ensure that no errors/exceptions are thrown here! All errors/exceptions are caught and ignored, which results in incomplete unloading and most likely subsequent re-loading of module will fail. A good indicator is if the info message "Module XYZ unloaded" appears in log.
-
moduleLoaded
public void moduleLoaded()Description copied from interface:MilestoneListener
Called when EvoLudo module finished loading.- Specified by:
moduleLoaded
in interfaceMilestoneListener
-
moduleUnloaded
public void moduleUnloaded()Description copied from interface:MilestoneListener
Called when EvoLudo module is unloading.- Specified by:
moduleUnloaded
in interfaceMilestoneListener
-
moduleRestored
public void moduleRestored()Description copied from interface:MilestoneListener
Called when the state of the EvoLudo module has been restored.- Specified by:
moduleRestored
in interfaceMilestoneListener
-
modelUnloaded
public void modelUnloaded()Description copied from interface:MilestoneListener
Called when EvoLudo model is unloading.- Specified by:
modelUnloaded
in interfaceMilestoneListener
-
modelRunning
public void modelRunning()Description copied from interface:MilestoneListener
Called when the EvoLudo model starts running.- Specified by:
modelRunning
in interfaceMilestoneListener
-
modelChanged
Description copied from interface:ChangeListener
Called whenever the state of the EvoLudo model changed. Process potentially pending requests.Note: the model may process some pending actions directly and without notifying the listeners through
modelChanged(PendingAction)
first. In particular, this applies to pending actions that fire their own notifications, such asRESET
andINIT
that in turn triggermodelReset()
andmodelInit()
, respectively.- Specified by:
modelChanged
in interfaceChangeListener
- Parameters:
action
- pending action that needs to be processed.- See Also:
-
modelStopped
public void modelStopped()Description copied from interface:MilestoneListener
Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).- Specified by:
modelStopped
in interfaceMilestoneListener
-
modelDidInit
public void modelDidInit()Description copied from interface:MilestoneListener
Called after the EvoLudo model got re-initialized.- Specified by:
modelDidInit
in interfaceMilestoneListener
-
modelDidReset
public void modelDidReset()Description copied from interface:MilestoneListener
Called after the EvoLudo model was reset.- Specified by:
modelDidReset
in interfaceMilestoneListener
-
updateGUI
private void updateGUI()Update GUI for running/stopped model. -
updateStatus
private void updateStatus()Helper method to update status of GUI. -
updateCounter
private void updateCounter()Helper method to update counter of GUI. -
onViewChange
Handler for changes of the view selector (evoludoViews
).- Parameters:
event
- theChangeEvent
that was fired
-
changeViewTo
Change view of EvoLudo model data. This helper method is called when the user selects a new view with the popup listevoludoViews
or when a particular view is requested through command line options (seecloView
).- Parameters:
newView
- new view of model data to display
-
changeViewTo
Change view of EvoLudo model data. This helper method is called when the user selects a new view with the popup listevoludoViews
or when a particular view is requested through command line options (seecloView
). The view is re-activated ifforce
istrue
and activation is skipped if the view didn't change andforce
isfalse
.- Parameters:
newView
- new view of model data to displayforce
- iftrue
the view is re-activated even if it didn't change
-
onSliderClick
Slider changed, adjust delay between updates. This event is triggered when clicking or taping on the slider (surprisingly, this does not trigger an InputEvent).- Parameters:
event
- theClickEvent
that was fired
-
onSliderInput
Slider changed, adjust delay between updates. This event is triggered when programmatically changing the slider settings, e.g. after processing key events to increase/decrease delay or when sliding the slider with touches or the mouse.- Parameters:
event
- theInputEvent
that was fired
-
onSettingsClick
Toggle visibility of the text fieldevoludoCLOPanel
to view or modify the parameter settings.- Parameters:
event
- theClickEvent
that was fired- See Also:
-
onSettingsTouchStart
Touch of parameter button started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event
- theTouchStartEvent
that was fired
-
onSettingsTouchEnd
Toggle visibility ofevoludoCLOPanel
to view or modify the parameter settings. Touch of Settings-button ended.- Parameters:
event
- theTouchEndEvent
that was fired- See Also:
-
toggleSettings
void toggleSettings()Helper method to toggle the visibility ofevoludoCLOPanel
to view or modify the parameter settings. -
onInitResetClick
Initialize or reset EvoLudo model (action depends on title of button). Button changes toReset
ifAlt
key is pressed and reverts toInit
after it is released.- Parameters:
event
- the ClickEvent that was fired- See Also:
-
onInitResetTouchStart
Touch ofInit
button started. Set timer for switching toReset
. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event
- the TouchStartEvent that was fired
-
onInitResetTouchEnd
Touch ofInit
(orReset
) button ended. Take the appropriate action.- Parameters:
event
- the TouchEndEvent that was fired
-
initReset
protected void initReset()Initialize or reset EvoLudo model. If model is running wait until next update is completed to prevent unexpected side effects. -
onStartStopClick
Start
,Stop
button clicked. Start EvoLudo model if not running and stop model if running. Button changes title accordingly.- Parameters:
event
- the ClickEvent that was fired
-
onStartStopTouchStart
Touch ofStart
,Stop
button started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event
- the TouchStartEvent that was fired
-
onStartStopTouchEnd
Touch ofStart
,Stop
button ended. Start EvoLudo model if not running and stop model if running. Button changes title accordingly.- Parameters:
event
- the TouchEndEvent that was fired
-
onStepClick
Next
button clicked. Advances the EvoLudo model by a single step. If the model is running, this is ignored.- Parameters:
event
- the ClickEvent that was fired
-
onStepTouchStart
Touch ofNext
button started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event
- the TouchStartEvent that was fired
-
onStepTouchEnd
Touch ofNext
button ended. Advances the EvoLudo model by a single step. If the model is running, this is ignored.- Parameters:
event
- the TouchEndEvent that was fired
-
prevNextDebug
private void prevNextDebug()Helper method to advance the EvoLudo model by a single step. The label on the button determines the action:- Step
- advances the model by a single step,
- Prev
- goes back by a single step and
- Debug
- advances the model by a single update.
-
onApplyClick
Apply command line parameters to EvoLudo model. For EvoLudo labs in the text flow of ePub's parameters cannot be changed and the title of the 'Apply' button is changed to 'Standalone' and opens a separate standalone EvoLudo lab, which permits parameter manipulations.- Parameters:
event
- the ClickEvent that was fired
-
applyCLO
public void applyCLO()Process and apply the command line arguments stored inevoludoCLO
Loads new model (and unloads old one), if necessary, and loads/adjusts the data views as appropriate. -
configGUI
private void configGUI()Helper method to update the views after the command line options have been applied. Ensures that all views are loaded and the GUI updated. -
loadViews
private void loadViews()Helper method to update the views after the command line options have been applied. Ensures that all views are loaded, the correct sizes applied and the content reset. -
revertCLO
protected void revertCLO()CLOParser issues warnings for unknown options but do not throw them away (can be annoying when switching between models). -
onDefaultClick
Discard current parameter settings and revert to default settings on initial launch of current model. For EvoLudo labs in the text flow of an ePub this button is disabled.- Parameters:
event
- the ClickEvent that was fired
-
onHelpClick
Displays a list and brief description of all parameters in the console,viewConsole
, including the default and current settings. For EvoLudo labs in the text flow of an ePub this button is disabled because the console is suppressed because scrolling is prevented by ePub reader.- Parameters:
event
- the ClickEvent that was fired
-
showHelp
public void showHelp()Show help in the console,viewConsole
. -
displayStatus
Displays a message in the status line of the EvoLudo GUI with the default levelLevel.INFO
.- Parameters:
msg
- the message to display
-
displayStatus
Displays a message in the status line of the EvoLudo GUI with the severitylevel
. Status messages are only overridden by subsequent messages with the same or higher levels. The threshold level for displaying messages is reset the next time the model is initialized or reset.- Parameters:
msg
- the message to displaylevel
- the severity of the message
-
onDragOver
Handler for drag'n'drop operation entering lab.Note: apparently DragOverHandler is required for the DropHandler to work (no actions necessary, though).
- Parameters:
doe
- the DragOverEvent that was fired
-
onDragLeave
Handler for drag'n'drop operation exiting lab.- Parameters:
dle
- the DragLeaveEvent that was fired
-
onDrop
Handler for dropping and restoring saved state.- Parameters:
drop
- the DropEvent that was fired
-
restoreFromString
Restore state of EvoLudo model from Stringcontent
.- Parameters:
filename
- (only for reference and reporting of success or failure)content
- encoded state of EvoLudo model
-
keyUpHandler
Processkeyup
events to allow for non-repeating keyboard shortcuts. Use for events where repeating does not make sense, such as stopping a model or changing views. For repeating events, such as advancing the model by a single step, seekeyDownHandler(String)
. The set of keys handled bykeyUpHandler
andkeyDownHandler
should be disjoint.Implementation Notes:
keyup
events are ignored if:- this EvoLudo model is not visible.
- the command line options field
evoludoCLO
has the focus. With the exception ofShift-Enter
to apply the new settings to the model. - in an ePub, except when on a standalone page.
keyup
events do not propagate further (stopPropagation()
is always called).- returning
true
also prevents default behaviour (callspreventDefault()
).
keyup
events are ignored if:- this EvoLudo model is not visible.
- the command line options field
evoludoCLO
has the focus. With the exception ofShift-Enter
, which applies the new settings to the model. - when shown in an ePub, except when on a standalone page.
keydown
event does not propagate further.- returning
true
also prevents default behaviour.
Global shortcuts provided for the following keys:
Alt
- Toggles the mode for some buttons. For example to switch between
Init
andReset
. Shift
- Toggles the mode for some keys, see
Enter
below for an example. 0
- Toggles the visibility of the field to view and modify parameter settings.
1-9
- Quick view selector. Switches to data view with the selected index if it
exists.
1
is the first view etc. Enter, Space
- Starts (or stops) the current model. Note,
Shift-Enter
applies the new parameter settings if the field is visible and has the keyboard focus. Same as pressing theApply
-button. Escape
- Implements several functions depending on context:
- Ignored in ePub.
- Closes current EvoLudo simulation if running in a
EvoLudoTrigger
popup panel. - Stops any running model.
- Initializes a model that is not running. Note, resets the model if
Alt
is pressed.
Backspace, Delete
- Stops running models and initializes (resets if
Alt
is pressed) stopped models. E
- Export the current state of the model (as a modified
plist
). Ignored if model is running and in ePubs. H
- Show the help screen with brief descriptions of all parameters in the console view.
- Parameters:
key
- the string value of the released key- Returns:
true
if key has been handled- See Also:
-
keyDownHandler
Processkeydown
events to allow for repeating keyboard shortcuts. Use for events where repeating does make sense, such as advancing a model by a single step or changing the speed of the model execution by adjusting the delay between subsequent updates. For non-repeating events, such starting or stopping the model or changing the view, seekeyUpHandler(String)
. The set of keys handled bykeyUpHandler
andkeyDownHandler
should be disjoint.Implementation Notes:
keydown
events are ignored if:- this EvoLudo model is not visible.
- in an ePub, except when on a standalone page.
keydown
events do not propagate further (stopPropagation()
is always called).- returning
true
also prevents default behaviour (callspreventDefault()
).
Global shortcuts provided for the following keys:
Alt
- Toggles the mode for some buttons. For example to switch between
Init
andReset
. Shift
- Toggles the mode for some keys, see
Enter
below for an example. ArrowRight, n
- Advance the model by a single step. Same as pressing the
Step
-button. +, =
- Increase the speed of the model execution. Decrease the delay between updates. Moves the speed-slider to the right.
-
- Decrease the speed of the model execution. Increase the delay between updates. Moves the speed-slider to the right.
- Parameters:
key
- the string value of the pressed key- Returns:
true
if key has been handled- See Also:
-
updateKeys
private void updateKeys()The Alt-key toggles the button labels for controlling the EvoLudo lab. -
snapshotReady
public void snapshotReady()Prepare GUI to create a snapshot. Stops running model, updates GUI (buttons and view) and adds a marker element with IDsnapshot-ready
to DOM. This is used to control automated snapshots usingcapture-website
.- See Also:
-
updateViews
protected void updateViews()Each EvoLudo model may entertain its own selection of views to visualize its data. Re-use currently active views if possible otherwise instantiate suitable views based on the features of the current model. Update the view selector accordingly.Note: the console view is dealt with elsewhere (see
processEPubSettings()
). -
addView
Convenience method to addview
to list of active viewsactiveViews
. If a view with the same name already exists inoldViews
it is reused.- Parameters:
view
- to add to active listoldViews
- list of current views
-
collectCLO
Description copied from interface:CLOProvider
All providers of command line options must implement this method to collect their options.Each command line option is (uniquely) identified by it's name (see
CLOption.getName()
), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, theparser
issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and callsuper.collectCLO(CLOParser)
at the end such that subclasses are able to override command line options specified in a parental class.Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.
- Specified by:
collectCLO
in interfaceCLOProvider
- Parameters:
parser
- the reference to parser that manages command line options- See Also:
-
addFullscreenChangeHandler
Description copied from interface:HasFullscreenChangeHandlers
Adds aFullscreenChangeEvent
handler.- Specified by:
addFullscreenChangeHandler
in interfaceHasFullscreenChangeHandlers
- Parameters:
handler
- the fullscreenchange handler- Returns:
HandlerRegistration
used to remove this handler
-
onFullscreenChange
Description copied from interface:FullscreenChangeHandler
Called when aFullscreenChangeEvent
is fired.- Specified by:
onFullscreenChange
in interfaceFullscreenChangeHandler
- Parameters:
event
- theFullscreenChangeEvent
that was fired
-
addKeyListeners
JSNI method: add global key event listeners for 'keydown', 'keyup', and 'keypress' events. All listeners are stored in the mapwindow.EvoLudoUtils.keyListeners
, which links listener functions to their respective controllers. The key handlers exposed through GWT appear to be more restricted and often lose focus. This somewhat brute force approach result in a much better GUI experience.- Parameters:
evoludo
- GUI controller that handles the key events
-
removeKeyListeners
JSNI method: remove all key event listeners that were registered forevoludo
.- Parameters:
evoludo
- GUI controller that handles the key events
-
createEvoLudoLab
Expose method for creating EvoLudo labs (EvoLudoWeb objects) to javascript- Parameters:
id
- the ID of element for EvoLudo labclo
- command line arguments of model
-
insertEvoLudoLab
Insert EvoLudo model in DOM by replacing theplaceholder
element.- Parameters:
placeholder
- the placeholder element for the EvoLudo labclo
- command line arguments of model
-
isShowing
public boolean isShowing()Check if EvoLudo model is visible on screen. This is used to determine which model should receive and process key events.Notes:
- Does not work in ePub (always returns true; apparently impossible to determine currently visible page through javascript. thus, all labs (at least within chapter) would get key events. this is not only messy but even crashes iBooks when requesting full screen.
- If two EvoLudo models are simultaneously visible it is undefined which lab receives the 'keypress'
- Popup EvoLudo models acquire all key events (through the static
keyListener
), regardless of whether other models are displayed underneath.
- Returns:
true
if lab is visible on screen
-
insertEPubEvoLudoLab
Fighting Apple Books constraints: Insert EvoLudo model in DOM by replacing theplaceholder
element with an iframe. This allows to load the lab as expected but all interactivity is disabled.- Parameters:
placeholder
- the placeholder element for the EvoLudo laburl
- command line arguments of model
-
exportInsertEPubEvoLudoLab
public static void exportInsertEPubEvoLudoLab()JSNI method: expose method for inserting EvoLudo models into ePub to javascript. -
exportInsertEvoLudoLab
public static void exportInsertEvoLudoLab()JSNI method: expose method for inserting EvoLudo models into HTML to javascript. -
exportCreateEvoLudoLab
public static void exportCreateEvoLudoLab()JSNI method: create EvoLudo labs directly from javascript. -
createEvoLudoTrigger
Expose method for creating EvoLudoTriggers to javascript.- Parameters:
id
- the ID of element for EvoLudo trigger button
-
exportCreateEvoLudoTrigger
public static void exportCreateEvoLudoTrigger()JSNI method: create EvoLudo lab trigger buttons directly from javascript. -
processEPubSettings
protected void processEPubSettings()Helper method to deal with ePub specifics. If EvoLudo lab is in flow of text then the console is removed (or added if EvoLudo model is on standalone ePub page or in browser), drag'n'drop to restore states and setting of parameters are disabled (or enabled otherwise). -
logFeatures
void logFeatures()Log GWT features and GUI specifics.
-