Class EvoLudoWeb
- All Implemented Interfaces:
EntryPoint, HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, CLOProvider
EvoLudoWeb
Top-level GUI controller for an EvoLudo laboratory instance running in a GWT environment (browser or ePub). This class implements the primary user interface and coordinates between the GWT widgets, the EvoLudo engine (EvoLudoGWT), and a collection of AbstractView implementations that render model data. It provides lifecycle integration with GWT (EntryPoint, onModuleLoad/onLoad/onUnload), runtime control of the engine (start/stop, init/reset, step/debug), management of command-line options (CLO), keyboard and drag-and-drop handlers, export/import of state, as well as ePub-specific accommodations.
Responsibilities
- Create and bind the GUI widgets declared in the accompanying UiBinder template.
- Instantiate and configure the EvoLudoGWT engine and its logger and Console view.
- Parse and apply command-line options (CLO) to load modules and models, configure views, and restore saved state.
- Maintain and update a dynamic list of active data views for the running model, showing only the appropriate views for module/model features (2D/3D populations, histograms, statistics, console).
- Provide keyboard shortcuts and a JS-friendly key listener mechanism (via JSNI) that reliably receives global key events even if GWT's default handlers lose focus.
- Support drag-and-drop of saved state files, including integrating optional JavaScript zip handling when needed.
- Handle fullscreen events and resizing, and provide a snapshot-ready signal for automated site capture.
- Adjust behavior for ePub contexts (inline flow vs standalone page), disabling editing, console, and drag-and-drop where necessary.
- Expose helper JS entry points to create/insert labs or triggers from external JavaScript (createEvoLudoLab, insertEvoLudoLab, insertEPubEvoLudoLab, createEvoLudoTrigger).
Lifecycle
- onModuleLoad(): scans the DOM for marker elements (evoludo-simulation and
evoludo-trigger-html) and replaces them with interactive labs or trigger
buttons.
- onLoad(): called when the widget is attached; sets up the engine, logger,
console, fullscreen element, and applies any CLO present.
- onUnload(): attempts to gracefully shut down the engine, clear the console
and remove global listeners. Care is taken to avoid throwing exceptions
during unload to keep GWT module reloads stable.
Command-Line Options (CLO)
The class supplies and consumes CLO options that control initial view and GUI size/fullscreen. It provides an editable CLO field in the UI (unless disabled for ePubs), an Apply button (or Standalone link in ePubs), and a Default button to revert to initial settings. The applyCLO() flow: parse CLO, update engine/module/model, load and size views, restore state if present, and activate/resume execution according to parsed flags (e.g. --run, --snap, --samples).
Views and Display
EvoLudoWeb keeps a DeckLayoutPanel (evoludoDeck) that displays exactly one
view at a time, while ViewController manages the available views and
selection state. Views are created or reused based on module capabilities and
model type. Views are responsible for rendering, while EvoLudoWeb
orchestrates loading, sizing, activation, deactivation, and disposal. The
Console view is treated specially and may be omitted in restricted ePub
modes.
Input Handling and Shortcuts
Global keyboard handling is implemented through KeyHandler to
provide reliable shortcuts that control the engine and UI. The controller
distinguishes between repeating actions (handled on key down) and
non-repeating actions (handled on key up) while JSNI routines install
window-level listeners that delegate to the controller. Touch interaction
variants are supported for critical controls (Start/Stop, Init/Reset,
Settings).
Drag-and-Drop and State Restore
The widget supports drag-and-drop of saved state files. It verifies data transfer validity and, when necessary, injects a JavaScript ZIP handler to decompress archives. Restored state is parsed into a Plist, applied to the engine, and the GUI reconfigured to reflect the restored model and settings.
Logging
Logging is routed through the engine's Logger. EvoLudoWeb installs a custom EvoLogHandler that mirrors important messages to the on-screen Console and to the status line (for warnings/errors). Help text and preformatted blocks are handled carefully to preserve formatting and safe encoding for XML/XHTML contexts and ePubs.
Concurrency and Threading
GWT executes UI work on the browser main thread. EvoLudoWeb schedules deferred actions via the Scheduler where appropriate and ensures that model state changes (start/stop/reset) are requested via the engine's request APIs. No internal multithreading beyond browser event callbacks is used.
Extension Points
- Views: Implement AbstractView to add new visualizations. EvoLudoWeb will discover and include them based on module interfaces and model type.
- CLO Providers: EvoLudoWeb implements CLOProvider to contribute GUI related options and to react when the engine parses command-line arguments.
- FullscreenChangeHandler: the class listens for fullscreen changes to apply styling and sizing changes.
ePub Behaviour
EvoLudoWeb adapts to ePub readers: inline labs in an ePub may have editing, drag-and-drop, and console functionality disabled to accommodate reader restrictions. If the lab is on a standalone ePub page, full interactivity is allowed. Special workarounds are applied for known platform quirks (e.g. Apple Books/touch event handler injection).
Generic reader notes:- button elements do not work in ePub's and hence trigger-'buttons' must be provided as anchor elements.
Apple Books:
- challenges for passing information to non-linear page (clo parameters)
- parameters and hash cleared from url before opening non-linear page
- non-linear page has no opener, referrer, parent to link to calling document
- no need to read data-clo of triggers because parameters cannot be reliably transmitted to popup lab; besides, it would be much easier to simply append the data to the URL.
- localStorage does not reliably work (>=2sec delay is required between setting the local variable and opening EvoLudoLab.xhtml...)
- changes to localStorage do not fire storage events
- need to do something about touch events on desktop...
- attaching touch handlers to triggers does nothing
- Apple's TouchEvents.js patch does not play nicely with GWT
- patch seems to prevent marking/highlighting of text passages. worth verifying and filing bug report with Apple if this is indeed the case?
- events in ePubs:
- iBooks does not fire 'wheel' or 'scroll' events (i.e. zooming does not work) for labs in the flow of the text; no point in adding them to the canvas(es). however, ok in non-linear labs!
- key events are sent (at least) to all labs in current chapter (isShowing does not work because it's impossible (?) to determine current page visible...); do not process key events for labs in the flow of the text (except maybe 'Alt'?). however, ok in non-linear labs!
- check for full screen capabilities causes flicker in iBooks (ugly...); seems to be related to key event handing (never observed for context menu); should be resolved by disabling key handler;
- use different GUI elements in ePub
- parameters in
evoludoCLOtext area are not read-only but essentially impossible to enter or edit anything; parameters should be read-only (mark with grey text color or similar); disable 'Apply' button, change 'Default' button to 'Standalone/External' lab opening a non-linear page or redirecting to evoludo.org, respectively (use 'Alt' key).
evoludoCLOis read only for labs in text flow. 'Apply' and 'Help' buttons disabled (no console to display help text because of scrolling issues). 'Default' button is repurposed to open standalone lab. - parameters in
- Clicks on button text do work for starting simulations but not for stopping them... clicking on the button next to its text works as expected.
Adobe Digital Editions
- non-linear pages are appended to the end, which makes returning to the corresponding text location impossible (somehow a marker should be set to allow using the back button).
Usage
- Place a <div class="evoludo-simulation"> in the HTML with an optional data-clo attribute or supply "clo" in the URL. The module will instantiate EvoLudoWeb for each such element during onModuleLoad().
- Alternatively, call the exported JavaScript helpers to create or insert labs dynamically.
- Interact with the lab through the provided GUI or keyboard shortcuts. Use Apply/Default to manage parameters and use Export/drag-and-drop to save/restore state.
Implementation notes: this class is designed to be a single, self-contained controller per DOM container element. It expects to run within the GWT environment and to co-operate with EvoLudoGWT, the Model/Module abstraction, and various AbstractView subclasses. It uses JSNI for some browser integration and therefore relies on the presence of the window object and typical browser DOM APIs.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassCustom handler for logging system.(package private) static interfaceGWT magic to define GUI elements (see EvoLudoWeb.ui.xml).(package private) classHelper structure to store the current state of the GUI.Nested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringLabel of button to advance model by single microscopic step.(package private) static final StringLabel of button to show help.(package private) static final StringLabel of button to initialize model.(package private) static final StringLabel of button to reverse on step.(package private) static final StringLabel of button to reset model.(package private) static final StringLabel of button to collect one statistics sample.(package private) static final StringLabel of button to show/hide parameter settings.(package private) static final StringLabel of button to start model.(package private) static final StringLabel of button to advance model by one step.(package private) static final StringLabel of button to stop model.private booleanDefer resetting the status threshold until after the loading sequence completes.private intThreshold level for overriding status message.(package private) static final StringAttribute name for command line options in DOM elements.(package private) HandlerRegistrationReference to registration of drag'n'drop handlers.(package private) HandlerRegistrationReference to registration of drag'n'drop handlers.(package private) StringID of element in DOM that contains the EvoLudo lab.(package private) EvoLudoGWTController.(package private) ButtonThe 'Apply' button ('Standalone' in ePubs)(package private) LabelThe text field containing the command line options for the EvoLudo model.(package private) FlowPanelPanel containing all elements to change/view parameters.(package private) DeckLayoutPanelPanel containing all the canvas elements to display the EvoLudo model's data.(package private) ButtonThe 'Default' button(package private) ButtonThe 'Help' button(package private) ButtonThe 'Init'/'Reset' button(package private) HeaderPanelBasic layout of EvoLudo model GUI with header (for time display,evoludoTime, and view selectorevoludoViews), footer (for delay sliderevoludoSlider, control buttonsevoludoSettings,evoludoInitReset,evoludoStartStop,evoludoStepand status lineevoludoStatusplus possibly parametersevoludoCLOPanel) as well as the main content area (for different canvases,evoludoDeck).(package private) HTMLOverlay for drag'n'drop operations(package private) HTMLPanelOutermost panel containing the EvoLudo GUI.(package private) ResizeLayoutPanelPanel 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) SliderSlider adjusting the delay between updates.(package private) ButtonThe 'Start'/'Stop' button(package private) HTMLStatus line of EvoLudo model GUI.(package private) ButtonThe 'Step' button(package private) LabelLabel to display elapsed generations (time).(package private) ListBoxSelector for all graphical representations to visualize the state of the EvoLudo model.private FSControllerController handling fullscreen and --size option.(package private) EvoLudoWeb.GUIStateField to store the current state of the GUI while applying a new set of parameters.private static booleanThe helper variable to indicate JavaScript for dealing with zip archives has already been loaded.private final KeyHandlerHelper that centralizes keyboard handling.protected EvoLudoWeb.EvoLogHandlerHandler for the log framework to report notifications etc.protected LoggerLogger for keeping track of and reporting events and issues.protected EvoLudoTrigger.LightboxPanelThe transparent backdrop of popup EvoLudo labs is stored here to reuse.private SettingsControllerController for ePub specific behaviour and emulation.protected TimerOn touch devices, theInitbutton changes toResetfor extended touches.private DivElementMarker element to indicate that a snapshot is ready.(package private) static final StringClosing tag of pre-formatted text.(package private) static final StringOpening tag of pre-formatted text.private static EvoLudoWeb.EvoLudoWebBinderGWT magic to create GUI elements (see EvoLudoWeb.ui.xml).protected doubleTime of last GUI update(package private) ConsoleConsole view requires slightly special treatment to ensure results of early feature detection get reported.private ViewControllerController managing all data views and theevoludoDeck.(package private) WebListenerController managing Lifecycle, Run, Sample, and Change events.Fields inherited from class UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNote: 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 TypeMethodDescriptionprivate voidaddEvoLudoToDOM(Element labElement, String clo) Add an EvoLudo lab to the DOM element with the given ID.voidapplyCLO()Process and apply the command line arguments stored inevoludoCLOLoads new model (and unloads old one), if necessary, and loads/adjusts the data views as appropriate.voidApplies the text currently in the CLO field to the engine.voidchangeView(AbstractView<?> view) Switches to the provided view.protected voidchangeViewTo(AbstractView<?> newView) Change view of EvoLudo model data.protected voidchangeViewTo(AbstractView<?> newView, boolean force) Change view of EvoLudo model data.voidClear the command line option field in the GUI.voidRemove the temporary DOM marker indicating that a snapshot is ready.booleanCloses the overlay containing this EvoLudo lab, if any.voidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.private voidHelper method to update the views after the command line options have been applied.static voidcreateEvoLudoLab(String id, String clo) Expose method for creating EvoLudo labs (EvoLudoWeb objects) to javascriptstatic voidExpose method for creating EvoLudoTriggers to javascript.voiddisplayStatus(String msg) Displays a message in the status line of the EvoLudo GUI with the default levelLevel.INFO.voiddisplayStatus(String msg, int level) Displays a message in the status line of the EvoLudo GUI with the severitylevel.static voidJSNI method: create EvoLudo labs directly from javascript.static voidJSNI method: create EvoLudo lab trigger buttons directly from javascript.static voidJSNI method: expose method for inserting EvoLudo models into ePub to javascript.static voidJSNI method: expose method for inserting EvoLudo models into HTML to javascript.AbstractView<?> Return the currently active view.intReturn the index of the currently active view in the list of active views.List<AbstractView<?>> Return the list of all active views.Obtain the DOM element that backs the CLO label for direct manipulation.private StringExtract command line options from URL parameterclo.Return the engine that controls the EvoLudo modules.voidHandle model reset event.booleanhasPopup()Check if this lab owns a popup overlay.voidInitialize or reset EvoLudo model.static voidinsertEPubEvoLudoLab(Element placeholder, String url) Fighting Apple Books constraints: Insert EvoLudo model in DOM by replacing theplaceholderelement with an iframe.static voidinsertEvoLudoLab(Element placeholder, String clo) Insert EvoLudo model in DOM by replacing theplaceholderelement.booleanCheck if the CLO settings panel is visible in the GUI.booleanisEPub()Check if this lab is running inside an ePub reader.booleanCheck if this lab is displayed as standalone page in ePub.booleanCheck if EvoLudo model is visible on screen.private voidloadViews(boolean resetViews) Helper method to update the views after the command line options have been applied.private static voidEnsures ZIP JavaScript is loaded exactly once across all instances.(package private) voidLog GWT features and GUI specifics.voidonApplyClick(ClickEvent event) Apply command line parameters to EvoLudo model.voidonDefaultClick(ClickEvent event) Discard current parameter settings and revert to default settings on initial launch of current model.voidHandler for drag'n'drop operation exiting lab.voidonDragOver(DragOverEvent doe) Handler for drag'n'drop operation entering lab.voidHandler for dropping and restoring saved state.voidonHelpClick(ClickEvent event) Displays a list and brief description of all parameters in the console,viewConsole, including the default and current settings.voidonInitResetClick(ClickEvent event) Initialize or reset EvoLudo model (action depends on title of button).voidonInitResetTouchEnd(TouchEndEvent event) Touch ofInit(orReset) button ended.voidTouch ofInitbutton started.voidonLoad()voidEntry point method.voidonSettingsClick(ClickEvent event) Toggle visibility of the text fieldevoludoCLOPanelto view or modify the parameter settings.voidonSettingsTouchEnd(TouchEndEvent event) Toggle visibility ofevoludoCLOPanelto view or modify the parameter settings.voidTouch of parameter button started.voidonSliderClick(ClickEvent event) Slider changed, adjust delay between updates.voidonSliderInput(InputEvent event) Slider changed, adjust delay between updates.voidonStartStopClick(ClickEvent event) Start,Stopbutton clicked.voidonStartStopTouchEnd(TouchEndEvent event) Touch ofStart,Stopbutton ended.voidTouch ofStart,Stopbutton started.voidonStepClick(ClickEvent event) Nextbutton clicked.voidonStepTouchEnd(TouchEndEvent event) Touch ofNextbutton ended.voidonStepTouchStart(TouchStartEvent event) Touch ofNextbutton started.voidonUnload()voidonViewChange(ChangeEvent event) Handler for changes of the view selector (evoludoViews).private voidHelper method to advance the EvoLudo model by a single step.private voidProcess the command line options for snap execution,EvoLudoGWT.cloSnap, and start the model accordingly.protected voidHelper method to deal with ePub specifics.private voidProcess DOM and add/allocate an EvoLudo lab whenever a<div>element withclass="evoludo-simulation"is found.private voidProcess DOM and replace all<div>elements withclass="evoludo-trigger-html"by a button that triggers a popup EvoLudo lab.voidRestore the default log threshold (display all severities).voidReset the current view selection to the default entry.voidrestoreFromString(String filename, String content) Restore state of EvoLudo model from Stringcontent.protected voidCLOParser issues warnings for unknown options but do not throw them away (can be annoying when switching between models).private voidSchedule showing alternate/context buttons after a long touch and prevent default handling.private voidsetupConsole(Logger logger) Setup the EvoLudo console to display log messages.private voidCreate EvoLudo engine and load modules.private voidsetupLogger(EvoLudoGWT engine) Retrieve the logger and setup the log handler.voidshowHelp()Show help in the console,viewConsole.private voidsnapDynamics(Model activeModel) Helper method to process snap for dynamics mode.private voidsnapSamples(Model activeModel) Helper method to process snap for statistics sample mode.voidPrepare GUI to create a snapshot.voidSyncs the delay slider with the engine's current delay.voidHelper method to toggle the visibility ofevoludoCLOPanelto view or modify the parameter settings.voidHelper method to update counter of GUI.private voidUpdate drag-and-drop handlers after UI toggles changed the layout.voidUpdate GUI for running/stopped model.voidThe Alt-key toggles the button labels for controlling the EvoLudo lab.voidHelper method to update status of GUI.Methods inherited from class Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetMethods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CLOProvider
adjustCLO
-
Field Details
-
uiBinder
GWT magic to create GUI elements (see EvoLudoWeb.ui.xml). -
updatetime
protected double updatetimeTime of last GUI update -
settingsController
Controller for ePub specific behaviour and emulation. -
engine
EvoLudoGWT engineController. Manages the interface with the outside world. -
keyController
Helper that centralizes keyboard handling. -
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. -
dragLeaveHandler
HandlerRegistration dragLeaveHandlerReference to registration of drag'n'drop handlers. -
elementID
String elementIDID of element in DOM that contains the EvoLudo lab. -
viewController
Controller managing all data views and theevoludoDeck. -
webListener
WebListener webListenerController managing Lifecycle, Run, Sample, and Change events. -
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. -
fsController
Controller handling fullscreen and --size option. -
DOM_DATA_CLO
-
evoludoPanel
-
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,evoludoStepand status lineevoludoStatusplus possibly parametersevoludoCLOPanel) as well as the main content area (for different canvases,evoludoDeck). -
evoludoTime
-
evoludoViews
-
evoludoDeck
Panel containing all the canvas elements to display the EvoLudo model's data. Only one is shown at any time, selected byevoludoViews. -
evoludoSlider
-
BUTTON_SETTINGS
-
BUTTON_START
-
BUTTON_STOP
-
BUTTON_INIT
-
BUTTON_RESET
-
BUTTON_STEP
-
BUTTON_DEBUG
Label of button to advance model by single microscopic step.- See Also:
-
BUTTON_SAMPLE
-
BUTTON_PREV
-
BUTTON_HELP
-
evoludoSettings
-
evoludoInitReset
-
showAltTouchTimer
On touch devices, theInitbutton changes toResetfor extended touches. This timer controls the delay beforeResetis shown. Any other touch event during this period cancels the timer. -
evoludoStartStop
-
evoludoStep
-
evoludoCLOPanel
Panel containing all elements to change/view parameters. Visibility toggled with the 'Settings' button,evoludoSettings. Initially invisible. -
evoludoCLO
-
evoludoApply
-
guiState
EvoLudoWeb.GUIState guiStateField to store the current state of the GUI while applying a new set of parameters. -
evoludoDefault
-
evoludoHelp
-
TAG_PRE_OPEN
-
TAG_PRE_CLOSE
-
evoludoStatus
-
displayStatusThresholdLevel
private int displayStatusThresholdLevelThreshold level for overriding status message. -
deferStatusThresholdReset
private boolean deferStatusThresholdResetDefer resetting the status threshold until after the loading sequence completes. -
evoludoOverlay
-
hasZipJs
private static boolean hasZipJsThe helper variable to indicate JavaScript for dealing with zip archives has already been loaded. -
snapmarker
-
-
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==nullthe default IDelementIDis used - Attempts to fail gracefully if no element with
idexists in DOM or if the HTML5canvaselement 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-cloattribute 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:
onModuleLoadin interfaceEntryPoint
-
processEvoLudoLabs
private void processEvoLudoLabs()Process DOM and add/allocate an EvoLudo lab whenever a<div>element withclass="evoludo-simulation"is found.The first lab found is passed any command line options specified in the URL (parameter
clo). Any subsequent labs need to specify command line options through thedata-cloattribute. -
addEvoLudoToDOM
Add an EvoLudo lab to the DOM element with the given ID. If the ID isnullor empty, a unique ID is generated. Ifcloisnullor empty, thedata-cloattribute is read and used to set the command line options for the lab.- Parameters:
labElement- the DOM element representing the labclo- the command line options for the lab
-
getCLOFromURL
Extract command line options from URL parameterclo.- Returns:
- the command line options
-
processEvoLudoTriggers
private void processEvoLudoTriggers()Process DOM and replace all<div>elements withclass="evoludo-trigger-html"by a button that triggers a popup EvoLudo lab.Note: buttons do not work in ePub's and hence trigger-'buttons' must be provided as anchor elements.
-
onLoad
public void onLoad()Called when loading GWT application. The contents of
evoludoCLOserve as the command line options. IfevoludoCLOis empty, thedata-cloattribute of the lab element is checked for command line options. -
setupEngine
private void setupEngine()Create EvoLudo engine and load modules. -
resetViewSelection
public void resetViewSelection()Reset the current view selection to the default entry. -
clearCommandLineOptions
public void clearCommandLineOptions()Clear the command line option field in the GUI. -
resetStatusThreshold
public void resetStatusThreshold()Restore the default log threshold (display all severities). -
handleModelDidReset
public void handleModelDidReset()Handle model reset event. -
setupLogger
Retrieve the logger and setup the log handler.- Parameters:
engine- the EvoLudo engine
-
setupConsole
Setup the EvoLudo console to display log messages.- Parameters:
logger- the logger instance
-
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.
-
updateGUI
public void updateGUI()Update GUI for running/stopped model. -
updateStatus
public void updateStatus()Helper method to update status of GUI. -
updateCounter
public void updateCounter()Helper method to update counter of GUI. -
onViewChange
Handler for changes of the view selector (evoludoViews).- Parameters:
event- theChangeEventthat was fired
-
changeViewTo
Change view of EvoLudo model data. This helper method is called when the user selects a new view with the popup listevoludoViewsor when a particular view is requested through command line options (seeViewController.getCloView()).- 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 listevoludoViewsor when a particular view is requested through command line options (seeViewController.getCloView()). The view is re-activated ifforceistrueand activation is skipped if the view didn't change andforceisfalse.- Parameters:
newView- new view of model data to displayforce- iftruethe view is re-activated even if it didn't change
-
getActiveViews
Return the list of all active views.- Returns:
- the list of all active views (console included)
-
getActiveView
-
getActiveViewIndex
public int getActiveViewIndex()Return the index of the currently active view in the list of active views.- Returns:
- the index of the active view inside the deck or
-1.
-
changeView
Switches to the provided view.- Parameters:
view- the new view to display
-
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- theClickEventthat 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- theInputEventthat was fired
-
onSettingsClick
Toggle visibility of the text fieldevoludoCLOPanelto view or modify the parameter settings.- Parameters:
event- theClickEventthat was fired- See Also:
-
onSettingsTouchStart
Touch of parameter button started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event- theTouchStartEventthat was fired
-
onSettingsTouchEnd
Toggle visibility ofevoludoCLOPanelto view or modify the parameter settings. Touch of Settings-button ended.- Parameters:
event- theTouchEndEventthat was fired- See Also:
-
toggleSettings
public void toggleSettings()Helper method to toggle the visibility ofevoludoCLOPanelto view or modify the parameter settings. -
getCLOElement
Obtain the DOM element that backs the CLO label for direct manipulation.- Returns:
- the DOM element that backs the CLO label
-
applyCLOFromField
public void applyCLOFromField()Applies the text currently in the CLO field to the engine. -
isEPubStandalone
public boolean isEPubStandalone()Check if this lab is displayed as standalone page in ePub.- Returns:
trueif a standalone
-
isEPub
public boolean isEPub()Check if this lab is running inside an ePub reader.- Returns:
truewhen running inside an ePub reader.
-
isCLOPanelVisible
public boolean isCLOPanelVisible()Check if the CLO settings panel is visible in the GUI.- Returns:
trueif settings panel visible
-
closePopup
public boolean closePopup()Closes the overlay containing this EvoLudo lab, if any.- Returns:
trueif lab was closed
-
hasPopup
public boolean hasPopup()Check if this lab owns a popup overlay.- Returns:
trueif lab shown on overlay
-
getEngine
Return the engine that controls the EvoLudo modules.- Returns:
- the engine
-
syncDelaySlider
public void syncDelaySlider()Syncs the delay slider with the engine's current delay. -
onInitResetClick
Initialize or reset EvoLudo model (action depends on title of button). Button changes toResetifAltkey is pressed and reverts toInitafter it is released.- Parameters:
event- the ClickEvent that was fired
-
scheduleAltButtons
Schedule showing alternate/context buttons after a long touch and prevent default handling.- Parameters:
event- the touch event (must not benull)
-
onInitResetTouchStart
Touch ofInitbutton 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
public void initReset()Initialize or reset EvoLudo model. If model is running wait until next update is completed to prevent unexpected side effects. -
onStartStopClick
Start,Stopbutton 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,Stopbutton started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event- the TouchStartEvent that was fired
-
onStartStopTouchEnd
Touch ofStart,Stopbutton ended. Start EvoLudo model if not running and stop model if running. Button changes title accordingly.- Parameters:
event- the TouchEndEvent that was fired
-
onStepClick
Nextbutton 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 ofNextbutton started. Suppress default behaviour (prevents magnifying glass and text selection).- Parameters:
event- the TouchStartEvent that was fired
-
onStepTouchEnd
Touch ofNextbutton 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 inevoludoCLOLoads 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. -
processCLOSnap
private void processCLOSnap()Process the command line options for snap execution,EvoLudoGWT.cloSnap, and start the model accordingly. -
snapDynamics
Helper method to process snap for dynamics mode.- Parameters:
activeModel- the active model
-
snapSamples
Helper method to process snap for statistics sample mode.- Parameters:
activeModel- the active model
-
loadViews
private void loadViews(boolean resetViews) 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.Note: many views need to know their size to adjust, for exmple, buffer sizes or data storage for statistics. However, only views that have been added to the DOM have valid sizes. For this reason the dimensions of the active view are passed to all other views.
- Parameters:
resetViews- whether to reset view state after loading
-
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
-
loadZipJs
private static void loadZipJs()Ensures ZIP JavaScript is loaded exactly once across all instances. Thread-safe and idempotent. -
updateKeys
public 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-readyto DOM. This is used to control automated snapshots usingcapture-website.- See Also:
-
clearSnapshotMarker
public void clearSnapshotMarker()Remove the temporary DOM marker indicating that a snapshot is ready. -
collectCLO
Description copied from interface:CLOProviderAll 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, theparserissues 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:
collectCLOin interfaceCLOProvider- Parameters:
parser- the reference to parser that manages command line options- See Also:
-
createEvoLudoLab
-
insertEvoLudoLab
-
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 by activating their
KeyHandler.
- Returns:
trueif lab is visible on screen
-
insertEPubEvoLudoLab
Fighting Apple Books constraints: Insert EvoLudo model in DOM by replacing theplaceholderelement 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). -
updateDropHandlers
private void updateDropHandlers()Update drag-and-drop handlers after UI toggles changed the layout. -
logFeatures
void logFeatures()Log GWT features and GUI specifics.
-