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 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.DebugIdImplEnabledNested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingAction -
Field Summary
FieldsModifier and TypeFieldDescription(package private) AbstractViewCurrently visible view(package private) HashMap<String, AbstractView> Look-up table for active views.final CLOptionCommand line option to set the size of the GUI or enter fullscreen.final CLOptionCommand line option to set the data view displayed in the GUI.private StringDefault set of parameters as specified for the initial invocation.private intThreshold level for overriding status message.(package private) HandlerRegistrationReference to registration of drag'n'drop handlers (if one was installed).(package private) HandlerRegistrationReference to registration of drag'n'drop handlers (if one was installed).(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.(package private) HandlerRegistrationThe reference to the fullscreen event handler.(package private) WidgetThe reference to the fullscreen widget.(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 StringBy default the first data view is shown.private booleanThe helper variable to indicate whether the Alt key is pressed.private booleanThe helper variable to indicate whether the Shift key is pressed.private final booleanIndicator whether display system supports WebGL to display population structures in 3D.private static EvoLudoWebPopup EvoLudo models (seeEvoLudoTrigger) should attract all keyboard events.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.static EvoLudoWebReference to running engine in ePubs (to conserve resources only one lab can be running at a time)protected TimerOn touch devices, theInitbutton changes toResetfor extended touches.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 intThe index of the currently active view in theactiveViewslist (and theevoludoDeckwidget).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 TypeMethodDescriptionAdds aFullscreenChangeEventhandler.private final voidaddKeyListeners(EvoLudoWeb evoludo) JSNI method: add global key event listeners for 'keydown', 'keyup', and 'keypress' events.private voidaddView(AbstractView view, HashMap<String, AbstractView> oldViews) Convenience method to addviewto list of active viewsactiveViews.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.protected voidchangeViewTo(AbstractView newView) Change view of EvoLudo model data.protected voidchangeViewTo(AbstractView newView, boolean force) Change view of EvoLudo model data.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.protected 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 EvoLudo model is visible on screen.booleankeyDownHandler(String key) Processkeydownevents to allow for repeating keyboard shortcuts.booleankeyUpHandler(String key) Processkeyupevents to allow for non-repeating keyboard shortcuts.private voidHelper method to update the views after the command line options have been applied.(package private) voidLog GWT features and GUI specifics.voidCalled whenever the state of the EvoLudo model changed.voidCalled after the EvoLudo model got re-initialized.voidCalled after the EvoLudo model was reset.voidCalled when the EvoLudo model starts running.voidCalled after a running EvoLudo model stopped because the model converged (or reached an absorbing state).voidCalled when EvoLudo model is unloading.voidCalled when EvoLudo module finished loading.voidCalled when the state of the EvoLudo module has been restored.voidCalled when EvoLudo module is unloading.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.voidCalled when aFullscreenChangeEventis fired.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.protected voidHelper method to deal with ePub specifics.private final voidremoveKeyListeners(EvoLudoWeb evoludo) JSNI method: remove all key event listeners that were registered forevoludo.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).voidshowHelp()Show help in the console,viewConsole.voidPrepare GUI to create a snapshot.(package private) voidHelper method to toggle the visibility ofevoludoCLOPanelto view or modify the parameter settings.private voidHelper method to update counter of GUI.private voidUpdate GUI for running/stopped model.private voidThe Alt-key toggles the button labels for controlling the EvoLudo lab.private voidHelper method to update status of GUI.protected voidEach 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, 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
adjustCLOMethods inherited from interface HasHandlers
fireEventMethods 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,evoludoStepand status lineevoludoStatusplus 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, theInitbutton changes toResetfor extended touches. This timer controls the delay beforeResetis 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,TextAreacauses 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. -
viewIdx
private int viewIdxThe index of the currently active view in theactiveViewslist (and theevoludoDeckwidget). -
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 settingkeyListenerto 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==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
-
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. -
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:MilestoneListenerCalled when EvoLudo module finished loading.- Specified by:
moduleLoadedin interfaceMilestoneListener
-
moduleUnloaded
public void moduleUnloaded()Description copied from interface:MilestoneListenerCalled when EvoLudo module is unloading.- Specified by:
moduleUnloadedin interfaceMilestoneListener
-
moduleRestored
public void moduleRestored()Description copied from interface:MilestoneListenerCalled when the state of the EvoLudo module has been restored.- Specified by:
moduleRestoredin interfaceMilestoneListener
-
modelUnloaded
public void modelUnloaded()Description copied from interface:MilestoneListenerCalled when EvoLudo model is unloading.- Specified by:
modelUnloadedin interfaceMilestoneListener
-
modelRunning
public void modelRunning()Description copied from interface:MilestoneListenerCalled when the EvoLudo model starts running.- Specified by:
modelRunningin interfaceMilestoneListener
-
modelChanged
Description copied from interface:ChangeListenerCalled 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 asRESETandINITthat in turn triggermodelReset()andmodelInit(), respectively.- Specified by:
modelChangedin interfaceChangeListener- Parameters:
action- pending action that needs to be processed.- See Also:
-
modelStopped
public void modelStopped()Description copied from interface:MilestoneListenerCalled after a running EvoLudo model stopped because the model converged (or reached an absorbing state).- Specified by:
modelStoppedin interfaceMilestoneListener
-
modelDidInit
public void modelDidInit()Description copied from interface:MilestoneListenerCalled after the EvoLudo model got re-initialized.- Specified by:
modelDidInitin interfaceMilestoneListener
-
modelDidReset
public void modelDidReset()Description copied from interface:MilestoneListenerCalled after the EvoLudo model was reset.- Specified by:
modelDidResetin 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- 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 (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 listevoludoViewsor when a particular view is requested through command line options (seecloView). 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
-
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
void toggleSettings()Helper method to toggle the visibility ofevoludoCLOPanelto view or modify the parameter settings. -
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- See Also:
-
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
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,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. -
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
Processkeyupevents 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 bykeyUpHandlerandkeyDownHandlershould be disjoint.Implementation Notes:
keyupevents are ignored if:- this EvoLudo model is not visible.
- the command line options field
evoludoCLOhas the focus. With the exception ofShift-Enterto apply the new settings to the model. - in an ePub, except when on a standalone page.
keyupevents do not propagate further (stopPropagation()is always called).- returning
truealso prevents default behaviour (callspreventDefault()).
keyupevents are ignored if:- this EvoLudo model is not visible.
- the command line options field
evoludoCLOhas 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.
keydownevent does not propagate further.- returning
truealso prevents default behaviour.
Global shortcuts provided for the following keys:
Alt- Toggles the mode for some buttons. For example to switch between
InitandReset. Shift- Toggles the mode for some keys, see
Enterbelow 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.
1is the first view etc. Enter, Space- Starts (or stops) the current model. Note,
Shift-Enterapplies 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
EvoLudoTriggerpopup panel. - Stops any running model.
- Initializes a model that is not running. Note, resets the model if
Altis pressed.
Backspace, Delete- Stops running models and initializes (resets if
Altis 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:
trueif key has been handled- See Also:
-
keyDownHandler
Processkeydownevents 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 bykeyUpHandlerandkeyDownHandlershould be disjoint.Implementation Notes:
keydownevents are ignored if:- this EvoLudo model is not visible.
- in an ePub, except when on a standalone page.
keydownevents do not propagate further (stopPropagation()is always called).- returning
truealso prevents default behaviour (callspreventDefault()).
Global shortcuts provided for the following keys:
Alt- Toggles the mode for some buttons. For example to switch between
InitandReset. Shift- Toggles the mode for some keys, see
Enterbelow 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:
trueif 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-readyto 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 addviewto list of active viewsactiveViews. If a view with the same name already exists inoldViewsit is reused.- Parameters:
view- to add to active listoldViews- list of current views
-
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:
-
addFullscreenChangeHandler
Description copied from interface:HasFullscreenChangeHandlersAdds aFullscreenChangeEventhandler.- Specified by:
addFullscreenChangeHandlerin interfaceHasFullscreenChangeHandlers- Parameters:
handler- the fullscreenchange handler- Returns:
HandlerRegistrationused to remove this handler
-
onFullscreenChange
Description copied from interface:FullscreenChangeHandlerCalled when aFullscreenChangeEventis fired.- Specified by:
onFullscreenChangein interfaceFullscreenChangeHandler- Parameters:
event- theFullscreenChangeEventthat 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 theplaceholderelement.- 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:
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). -
logFeatures
void logFeatures()Log GWT features and GUI specifics.
-