Package org.evoludo

Class EvoLudoWeb

All Implemented Interfaces:
EntryPoint, HasAttachHandlers, EventHandler, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget, ChangeListener, MilestoneListener, FullscreenChangeHandler, HasFullscreenChangeHandlers, CLOProvider

Entry point classes define onModuleLoad().
  • Field Details

    • uiBinder

      private static EvoLudoWeb.EvoLudoWebBinder uiBinder
      GWT magic to create GUI elements (see EvoLudoWeb.ui.xml).
    • updatetime

      protected double updatetime
      Time of last GUI update
    • runningEPub

      public static EvoLudoWeb runningEPub
      Reference to running engine in ePubs (to conserve resources only one lab can be running at a time)
    • engine

      EvoLudoGWT engine
      Controller. Manages the interface with the outside world.
    • logger

      protected Logger logger
      Logger for keeping track of and reporting events and issues.
    • logEvoHandler

      protected EvoLudoWeb.EvoLogHandler logEvoHandler
      Handler for the log framework to report notifications etc. in EvoLudo's console
    • dragEnterHandler

      HandlerRegistration dragEnterHandler
      Reference to registration of drag'n'drop handlers (if one was installed).
    • dragLeaveHandler

      HandlerRegistration dragLeaveHandler
      Reference to registration of drag'n'drop handlers (if one was installed).
    • fullscreenHandler

      HandlerRegistration fullscreenHandler
      The reference to the fullscreen event handler.
    • fullscreenWidget

      Widget fullscreenWidget
      The reference to the fullscreen widget.
    • elementID

      String elementID
      ID of element in DOM that contains the EvoLudo lab.
    • defaultCLO

      private String defaultCLO
      Default set of parameters as specified for the initial invocation.
    • activeViews

      Look-up table for active views. This is the selection shown in evoludoViews.
    • initialView

      private String initialView
      By default the first data view is shown. In general this shows the strategies in the (structured) population in 2D.
    • activeView

      AbstractView activeView
      Currently visible view
    • viewConsole

      Console viewConsole
      Console view requires slightly special treatment to ensure results of early feature detection get reported.
    • evoludoPanel

      @UiField HTMLPanel 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

      @UiField HeaderPanel evoludoLayout
      Basic layout of EvoLudo model GUI with header (for time display, evoludoTime, and view selector evoludoViews), footer (for delay slider evoludoSlider, control buttons evoludoSettings, evoludoInitReset, evoludoStartStop, evoludoStep and status line evoludoStatus plus possibly parameters evoludoCLOPanel) as well as the main content area (for different canvases, evoludoDeck).
    • evoludoTime

      @UiField Label evoludoTime
      Label to display elapsed generations (time).
    • evoludoViews

      @UiField ListBox 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 by evoludoViews.
    • evoludoSlider

      @UiField Slider evoludoSlider
      Slider adjusting the delay between updates.
    • evoludoSettings

      @UiField Button evoludoSettings
      'Settings' button
    • evoludoInitReset

      @UiField Button evoludoInitReset
      The 'Init'/'Reset' button
    • showAltTouchTimer

      protected Timer showAltTouchTimer
      On touch devices, the Init button changes to Reset for extended touches. This timer controls the delay before Reset is shown. Any other touch event during this period cancels the timer.
    • evoludoStartStop

      @UiField Button evoludoStartStop
      The 'Start'/'Stop' button
    • evoludoStep

      @UiField Button evoludoStep
      The 'Step' button
    • evoludoCLOPanel

      @UiField FlowPanel evoludoCLOPanel
      Panel containing all elements to change/view parameters. Visibility toggled with the 'Settings' button, evoludoSettings. Initially invisible.
    • evoludoCLO

      @UiField Label evoludoCLO
      The text field containing the command line options for the EvoLudo model. Note, TextArea causes grief with ePubs in Apple Books.
    • evoludoApply

      @UiField Button evoludoApply
      The 'Apply' button ('Standalone' in ePubs)
    • guiState

      Field to store the current state of the GUI while applying a new set of parameters.
    • evoludoDefault

      @UiField Button evoludoDefault
      The 'Default' button
    • evoludoHelp

      @UiField Button evoludoHelp
      The 'Help' button
    • evoludoStatus

      @UiField HTML evoludoStatus
      Status line of EvoLudo model GUI.
    • displayStatusThresholdLevel

      private int displayStatusThresholdLevel
      Threshold level for overriding status message.
    • evoludoOverlay

      @UiField HTML evoludoOverlay
      Overlay for drag'n'drop operations
    • hasZipJs

      private static boolean hasZipJs
      The helper variable to indicate JavaScript for dealing with zip archives has already been loaded.
    • isShiftDown

      private boolean isShiftDown
      The helper variable to indicate whether the Shift key is pressed.
    • isAltDown

      private boolean isAltDown
      The helper variable to indicate whether the Alt key is pressed.
    • cloView

      public final CLOption cloView
      Command line option to set the data view displayed in the GUI.
    • cloSize

      public final CLOption cloSize
      Command line option to set the size of the GUI or enter fullscreen.
    • keyListener

      private static EvoLudoWeb keyListener
      Popup EvoLudo models (see EvoLudoTrigger) should attract all keyboard events. This is achieved by setting keyListener to the popup model.
    • isWebGLSupported

      private final boolean isWebGLSupported
      Indicator 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

      public EvoLudoWeb(String id, EvoLudoTrigger.LightboxPanel popup)
      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

      public EvoLudoWeb(String id, String clo)
      Main constructor for EvoLudo labs.

      Note:

      • If id==null the default ID elementID is used
      • Attempts to fail gracefully if no element with id exists in DOM or if the HTML5 canvas element is not supported.
      Parameters:
      id - the DOM id of the element containing the lab
      clo - the string with the command line options
  • Method Details

    • onModuleLoad

      public void onModuleLoad()
      Entry point method. Process DOM and add/allocate an EvoLudo lab whenever a <div> element with class="evoludo-simulation" is found. Parameters may be passed to the EvoLudo lab either through the data-clo attribute or as part of the URL as a parameter clo. Similarly, <div> elements with class="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 interface EntryPoint
    • onLoad

      public void onLoad()

      Called when loading GWT application. The contents of evoludoCLO serve as the command line options. If evoludoCLO is empty, the data-clo attribute of the lab element is checked for command line options.

      Overrides:
      onLoad in class Widget
    • 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.

      Overrides:
      onUnload in class Widget
    • moduleLoaded

      public void moduleLoaded()
      Description copied from interface: MilestoneListener
      Called when EvoLudo module finished loading.
      Specified by:
      moduleLoaded in interface MilestoneListener
    • moduleUnloaded

      public void moduleUnloaded()
      Description copied from interface: MilestoneListener
      Called when EvoLudo module is unloading.
      Specified by:
      moduleUnloaded in interface MilestoneListener
    • moduleRestored

      public void moduleRestored()
      Description copied from interface: MilestoneListener
      Called when the state of the EvoLudo module has been restored.
      Specified by:
      moduleRestored in interface MilestoneListener
    • modelUnloaded

      public void modelUnloaded()
      Description copied from interface: MilestoneListener
      Called when EvoLudo model is unloading.
      Specified by:
      modelUnloaded in interface MilestoneListener
    • modelRunning

      public void modelRunning()
      Description copied from interface: MilestoneListener
      Called when the EvoLudo model starts running.
      Specified by:
      modelRunning in interface MilestoneListener
    • modelChanged

      public void modelChanged(ChangeListener.PendingAction action)
      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 as RESET and INIT that in turn trigger modelReset() and modelInit(), respectively.

      Specified by:
      modelChanged in interface ChangeListener
      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 interface MilestoneListener
    • modelDidInit

      public void modelDidInit()
      Description copied from interface: MilestoneListener
      Called after the EvoLudo model got re-initialized.
      Specified by:
      modelDidInit in interface MilestoneListener
    • modelDidReset

      public void modelDidReset()
      Description copied from interface: MilestoneListener
      Called after the EvoLudo model was reset.
      Specified by:
      modelDidReset in interface MilestoneListener
    • 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

      @UiHandler("evoludoViews") public void onViewChange(ChangeEvent event)
      Handler for changes of the view selector (evoludoViews).
      Parameters:
      event - the ChangeEvent that was fired
    • changeViewTo

      protected void changeViewTo(AbstractView newView)
      Change view of EvoLudo model data. This helper method is called when the user selects a new view with the popup list evoludoViews or when a particular view is requested through command line options (see cloView).
      Parameters:
      newView - new view of model data to display
    • changeViewTo

      protected void changeViewTo(AbstractView newView, boolean force)
      Change view of EvoLudo model data. This helper method is called when the user selects a new view with the popup list evoludoViews or when a particular view is requested through command line options (see cloView). The view is re-activated if force is true and activation is skipped if the view didn't change and force is false.
      Parameters:
      newView - new view of model data to display
      force - if true the view is re-activated even if it didn't change
    • onSliderClick

      @UiHandler("evoludoSlider") public void onSliderClick(ClickEvent event)
      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 - the ClickEvent that was fired
    • onSliderInput

      @UiHandler("evoludoSlider") public void onSliderInput(InputEvent event)
      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 - the InputEvent that was fired
    • onSettingsClick

      @UiHandler("evoludoSettings") public void onSettingsClick(ClickEvent event)
      Toggle visibility of the text field evoludoCLOPanel to view or modify the parameter settings.
      Parameters:
      event - the ClickEvent that was fired
      See Also:
    • onSettingsTouchStart

      @UiHandler("evoludoSettings") public void onSettingsTouchStart(TouchStartEvent event)
      Touch of parameter button started. Suppress default behaviour (prevents magnifying glass and text selection).
      Parameters:
      event - the TouchStartEvent that was fired
    • onSettingsTouchEnd

      @UiHandler("evoludoSettings") public void onSettingsTouchEnd(TouchEndEvent event)
      Toggle visibility of evoludoCLOPanel to view or modify the parameter settings. Touch of Settings-button ended.
      Parameters:
      event - the TouchEndEvent that was fired
      See Also:
    • toggleSettings

      void toggleSettings()
      Helper method to toggle the visibility of evoludoCLOPanel to view or modify the parameter settings.
    • onInitResetClick

      @UiHandler("evoludoInitReset") public void onInitResetClick(ClickEvent event)
      Initialize or reset EvoLudo model (action depends on title of button). Button changes to Reset if Alt key is pressed and reverts to Init after it is released.
      Parameters:
      event - the ClickEvent that was fired
      See Also:
    • onInitResetTouchStart

      @UiHandler("evoludoInitReset") public void onInitResetTouchStart(TouchStartEvent event)
      Touch of Init button started. Set timer for switching to Reset. Suppress default behaviour (prevents magnifying glass and text selection).
      Parameters:
      event - the TouchStartEvent that was fired
    • onInitResetTouchEnd

      @UiHandler("evoludoInitReset") public void onInitResetTouchEnd(TouchEndEvent event)
      Touch of Init (or Reset) 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

      @UiHandler("evoludoStartStop") public void onStartStopClick(ClickEvent event)
      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

      @UiHandler("evoludoStartStop") public void onStartStopTouchStart(TouchStartEvent event)
      Touch of Start, Stop button started. Suppress default behaviour (prevents magnifying glass and text selection).
      Parameters:
      event - the TouchStartEvent that was fired
    • onStartStopTouchEnd

      @UiHandler("evoludoStartStop") public void onStartStopTouchEnd(TouchEndEvent event)
      Touch of Start, 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

      @UiHandler("evoludoStep") public void onStepClick(ClickEvent event)
      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

      @UiHandler("evoludoStep") public void onStepTouchStart(TouchStartEvent event)
      Touch of Next button started. Suppress default behaviour (prevents magnifying glass and text selection).
      Parameters:
      event - the TouchStartEvent that was fired
    • onStepTouchEnd

      @UiHandler("evoludoStep") public void onStepTouchEnd(TouchEndEvent event)
      Touch of Next 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

      @UiHandler("evoludoApply") public void onApplyClick(ClickEvent event)
      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 in evoludoCLO 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

      @UiHandler("evoludoDefault") public void onDefaultClick(ClickEvent event)
      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

      @UiHandler("evoludoHelp") public void onHelpClick(ClickEvent event)
      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

      public void displayStatus(String msg)
      Displays a message in the status line of the EvoLudo GUI with the default level Level.INFO.
      Parameters:
      msg - the message to display
    • displayStatus

      public void displayStatus(String msg, int level)
      Displays a message in the status line of the EvoLudo GUI with the severity level. 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 display
      level - the severity of the message
    • onDragOver

      @UiHandler("evoludoOverlay") public void onDragOver(DragOverEvent doe)
      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

      @UiHandler("evoludoOverlay") public void onDragLeave(DragLeaveEvent dle)
      Handler for drag'n'drop operation exiting lab.
      Parameters:
      dle - the DragLeaveEvent that was fired
    • onDrop

      @UiHandler("evoludoOverlay") public void onDrop(DropEvent drop)
      Handler for dropping and restoring saved state.
      Parameters:
      drop - the DropEvent that was fired
    • restoreFromString

      public void restoreFromString(String filename, String content)
      Restore state of EvoLudo model from String content.
      Parameters:
      filename - (only for reference and reporting of success or failure)
      content - encoded state of EvoLudo model
    • keyUpHandler

      public boolean keyUpHandler(String key)
      Process keyup 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, see keyDownHandler(String). The set of keys handled by keyUpHandler and keyDownHandler should be disjoint.

      Implementation Notes:

      • keyup events are ignored if:
        1. this EvoLudo model is not visible.
        2. the command line options field evoludoCLO has the focus. With the exception of Shift-Enter to apply the new settings to the model.
        3. 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 (calls preventDefault()).
      keyup events are ignored if:
      • this EvoLudo model is not visible.
      • the command line options field evoludoCLO has the focus. With the exception of Shift-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 and Reset.
      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 the Apply-button.
      Escape
      Implements several functions depending on context:
      1. Ignored in ePub.
      2. Closes current EvoLudo simulation if running in a EvoLudoTrigger popup panel.
      3. Stops any running model.
      4. 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

      public boolean keyDownHandler(String key)
      Process keydown 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, see keyUpHandler(String). The set of keys handled by keyUpHandler and keyDownHandler should be disjoint.

      Implementation Notes:

      • keydown events are ignored if:
        1. this EvoLudo model is not visible.
        2. 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 (calls preventDefault()).

      Global shortcuts provided for the following keys:

      Alt
      Toggles the mode for some buttons. For example to switch between Init and Reset.
      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 ID snapshot-ready to DOM. This is used to control automated snapshots using capture-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

      private void addView(AbstractView view, HashMap<String,AbstractView> oldViews)
      Convenience method to add view to list of active views activeViews. If a view with the same name already exists in oldViews it is reused.
      Parameters:
      view - to add to active list
      oldViews - list of current views
    • collectCLO

      public void collectCLO(CLOParser parser)
      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, the parser issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and call super.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 interface CLOProvider
      Parameters:
      parser - the reference to parser that manages command line options
      See Also:
    • addFullscreenChangeHandler

      public HandlerRegistration addFullscreenChangeHandler(FullscreenChangeHandler handler)
      Description copied from interface: HasFullscreenChangeHandlers
      Adds a FullscreenChangeEvent handler.
      Specified by:
      addFullscreenChangeHandler in interface HasFullscreenChangeHandlers
      Parameters:
      handler - the fullscreenchange handler
      Returns:
      HandlerRegistration used to remove this handler
    • onFullscreenChange

      public void onFullscreenChange(FullscreenChangeEvent event)
      Description copied from interface: FullscreenChangeHandler
      Called when a FullscreenChangeEvent is fired.
      Specified by:
      onFullscreenChange in interface FullscreenChangeHandler
      Parameters:
      event - the FullscreenChangeEvent that was fired
    • addKeyListeners

      private final void addKeyListeners(EvoLudoWeb evoludo)
      JSNI method: add global key event listeners for 'keydown', 'keyup', and 'keypress' events. All listeners are stored in the map window.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

      private final void removeKeyListeners(EvoLudoWeb evoludo)
      JSNI method: remove all key event listeners that were registered for evoludo.
      Parameters:
      evoludo - GUI controller that handles the key events
    • createEvoLudoLab

      public static void createEvoLudoLab(String id, String clo)
      Expose method for creating EvoLudo labs (EvoLudoWeb objects) to javascript
      Parameters:
      id - the ID of element for EvoLudo lab
      clo - command line arguments of model
    • insertEvoLudoLab

      public static void insertEvoLudoLab(Element placeholder, String clo)
      Insert EvoLudo model in DOM by replacing the placeholder element.
      Parameters:
      placeholder - the placeholder element for the EvoLudo lab
      clo - 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:

      1. 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.
      2. If two EvoLudo models are simultaneously visible it is undefined which lab receives the 'keypress'
      3. 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

      public static void insertEPubEvoLudoLab(Element placeholder, String url)
      Fighting Apple Books constraints: Insert EvoLudo model in DOM by replacing the placeholder 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 lab
      url - 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

      public static void createEvoLudoTrigger(String id)
      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.