Class Engine

  • All Implemented Interfaces:
    java.lang.Runnable

    public final class Engine
    extends Threaded
    Author:
    Group 3
    • Constructor Summary

      Constructors 
      Constructor Description
      Engine​(MainController uiController)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateTool​(java.lang.String toolID)
      Activate tool
      void configCard​(PageElement page)
      Configure the card.
      void consoleLineCallback​(java.lang.String line)
      Receive line from the console.
      void deleteElement​(java.lang.String id)
      Delete an element.
      void drawImageEl​(ImageElement img)
      Instruct the UI to draw an image.
      void drawPlayer​(java.lang.String id, java.lang.String mediaLoc, java.lang.Boolean showControls, java.lang.Boolean autoPlay, java.lang.Boolean loop, java.lang.Double offset)
      Show a player.
      void drawShapeStroke​(java.lang.String shapeID, java.lang.String colour, java.lang.String style, java.lang.Double width)
      Set a shape's stroke.
      void drawShapeText​(java.lang.String shapeID, java.lang.String text, java.lang.String hAlign, java.lang.String vAlign, java.lang.String font, java.lang.String colour, java.lang.Double size, java.lang.Boolean underscore, java.lang.Boolean italic, java.lang.Boolean bold)
      Set text on a shape on screen.
      void elementRelocated​(java.lang.String elID, LocObj newLoc)
      The UI has relocated an element.
      void evalPyStr​(java.lang.String code)
      Evaluate a python string.
      void exit()
      Exit Application.
      DocIO getDocIO()
      Returns the current Document IO object.
      java.util.HashMap<java.lang.String,​java.lang.Object> getElementProperties​(java.lang.String elID)
      Provide the Element's properties to the UI.
      java.lang.String getElScript​(java.lang.String id)
      Get the string of an Element's script.
      java.lang.String getElScriptLang​(java.lang.String id)
      Get an element's language.
      java.util.Optional<java.util.HashMap<java.lang.String,​java.lang.Object>> getShapeTextProps​(java.lang.String shapeID)
      Get Shape's text properties.
      java.util.Optional<java.lang.String> getShapeTextString​(java.lang.String shapeID)
      Get shape Text String.
      ToolIO getToolIO()
      Get the current Tool IO.
      void gotoNextPage()
      Go to next sequential page.
      void gotoPage​(PageElement page, java.lang.Boolean storeHistory)
      Go to provided page.
      void gotoPage​(java.lang.Integer pageNum, java.lang.Boolean storeHistory)
      Go to specified page number.
      void gotoPage​(java.lang.String pageID, java.lang.Boolean storeHistory)
      Go to specified page.
      void gotoPrevPage()
      Go to last visited page.
      void loadEmptyDoc()
      Load an empty document.
      void makeNewCard()
      Append a new card.
      void moveCard​(java.lang.String id, java.lang.Integer newIndex)
      Move card to new index.
      void moveElement​(java.lang.String id, java.lang.Double x, java.lang.Double y, java.lang.Double zIndex)
      Move an element.
      void offerEvent​(javafx.event.Event event)
      Send an event to the engine.
      void offerNewDoc​(java.io.File xmlFile)
      Send a doc to the engine.
      void openExternalLink​(java.lang.String link)
      Open an external link.
      void openInternalLink​(java.lang.String link)
      Open an internal link.
      void processEls​(VisualElement el)
      Process elements on a page.
      void putImage​(java.lang.String id, java.lang.Double xSize, java.lang.Double ySize, java.lang.Double rot, java.lang.Double xLoc, java.lang.Double yLoc, java.lang.Double zInd, java.lang.String source)
      Instruct the UI to draw an image using discrete values.
      void putMessage​(java.lang.String message, java.lang.Boolean blocking)
      Instruct the UI to show a message to the User.
      void putShape​(java.lang.String id, java.lang.String type)
      Put a shape to the display.
      java.lang.String readConsoleLine()
      Read a line from the console.
      void redrawEl​(VisualElement el)
      Re/draws a Visual element.
      void removeElementFromScreen​(java.lang.String id)
      Remove an element from the screen.
      void resizeElement​(java.lang.String id, java.lang.Double x, java.lang.Double y, java.lang.Double rot)
      Resize an element on screen.
      void run()
      Run stuff.
      void runFunction​(java.lang.Runnable r)
      Run a function on the engine thread.
      void saveCurrentDoc()
      Attempt to save the current doc.
      void saveCurrentDocAs​(java.lang.String newPath)
      Attempt to save current doc to new location.
      void setCursorType​(java.lang.String cType)
      Set the cursor type.
      void setElementShadow​(java.lang.String id, java.lang.Double radius)
      Set basic shadow on an element.
      void setElementVisibility​(java.lang.String id, java.lang.Boolean vis)
      Set a drawn element's on-screen visibility.
      void setElScript​(java.lang.String id, java.lang.String lang, java.lang.String scr)
      Set an Element's script.
      void setScriptGlobal​(java.lang.String name, java.lang.Object obj)
      Put a global into the scripting engine.
      void setShapeColour​(java.lang.String id, java.lang.String colour)
      Set a Shape's style.
      void setShapeTextProps​(java.lang.String shapeID, java.util.HashMap<java.lang.String,​java.lang.Object> props)
      Set shape element text properties.
      void setShapeTextString​(java.lang.String shapeID, java.lang.String text)
      Set Shape Text String.
      void showDocChooser()
      Request the UI to show a doc chooser.
      void showStartScreen()
      Loads the start screen.
      void toggleEdit​(java.lang.Boolean editable)
      Toggle if the display is editable.
      void togglePlayerPlaying​(java.lang.String id, java.lang.Boolean play)
      Make a player on screen play/pause.
      void updateProperties​(java.util.HashMap<java.lang.String,​java.lang.Object> props, java.lang.String elId)
      Update element properties.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Engine

        public Engine​(MainController uiController)
        Constructor.
        Parameters:
        uiController - Ref to the main UI controller.
    • Method Detail

      • offerEvent

        public void offerEvent​(javafx.event.Event event)
        Send an event to the engine.
        Parameters:
        event - Event to send.
      • offerNewDoc

        public void offerNewDoc​(java.io.File xmlFile)
        Send a doc to the engine.
        Parameters:
        xmlFile - Doc to open.
      • runFunction

        public void runFunction​(java.lang.Runnable r)
        Run a function on the engine thread.
        Parameters:
        r - Runnable function.
      • getDocIO

        public DocIO getDocIO()
        Returns the current Document IO object.
        Returns:
        doc IO.
      • run

        public void run()
        Description copied from class: Threaded
        Run stuff.
        Specified by:
        run in interface java.lang.Runnable
        Specified by:
        run in class Threaded
      • setScriptGlobal

        public void setScriptGlobal​(java.lang.String name,
                                    java.lang.Object obj)
        Put a global into the scripting engine.
        Parameters:
        name - Global Name.
        obj - Global.
      • openExternalLink

        public void openExternalLink​(java.lang.String link)
        Open an external link.
        Parameters:
        link - Link to open.
      • openInternalLink

        public void openInternalLink​(java.lang.String link)
        Open an internal link.
        Parameters:
        link - Link to item.
      • drawImageEl

        public void drawImageEl​(ImageElement img)
        Instruct the UI to draw an image.
        Parameters:
        img - Image to draw.
      • putImage

        public void putImage​(java.lang.String id,
                             java.lang.Double xSize,
                             java.lang.Double ySize,
                             java.lang.Double rot,
                             java.lang.Double xLoc,
                             java.lang.Double yLoc,
                             java.lang.Double zInd,
                             java.lang.String source)
        Instruct the UI to draw an image using discrete values.
        Parameters:
        id - Image ID
        xSize - Image X Size.
        ySize - Image Y Size.
        rot - Rotation.
        xLoc - X Location.
        yLoc - Y Location.
        zInd - Z Index.
        source - Image Source.
      • putShape

        public void putShape​(java.lang.String id,
                             java.lang.String type)
        Put a shape to the display.
        Parameters:
        id - Shape ID.
        type - Shape type.
      • setShapeColour

        public void setShapeColour​(java.lang.String id,
                                   java.lang.String colour)
        Set a Shape's style.
        Parameters:
        id - Target shape ID.
        colour - Fill colour.
      • drawShapeText

        public void drawShapeText​(java.lang.String shapeID,
                                  java.lang.String text,
                                  java.lang.String hAlign,
                                  java.lang.String vAlign,
                                  java.lang.String font,
                                  java.lang.String colour,
                                  java.lang.Double size,
                                  java.lang.Boolean underscore,
                                  java.lang.Boolean italic,
                                  java.lang.Boolean bold)
        Set text on a shape on screen. Sets properties for all text in the shape.
        Parameters:
        shapeID - Target ID.
        text - Text to set.
        hAlign - Horizontal alignment.
        vAlign - Vertical alignment.
        font - Font name.
        colour - Font colour.
        size - Font size.
        underscore - Under-line text.
        italic - Italicise text.
        bold - Bold text.
      • getShapeTextString

        public java.util.Optional<java.lang.String> getShapeTextString​(java.lang.String shapeID)
        Get shape Text String.
        Parameters:
        shapeID - Shape.
        Returns:
        Maybe text string.
      • setShapeTextString

        public void setShapeTextString​(java.lang.String shapeID,
                                       java.lang.String text)
        Set Shape Text String.
        Parameters:
        shapeID - Shape.
        text - Text.
      • getShapeTextProps

        public java.util.Optional<java.util.HashMap<java.lang.String,​java.lang.Object>> getShapeTextProps​(java.lang.String shapeID)
        Get Shape's text properties.
        Parameters:
        shapeID - Shape.
        Returns:
        Maybe Properties.
      • setShapeTextProps

        public void setShapeTextProps​(java.lang.String shapeID,
                                      java.util.HashMap<java.lang.String,​java.lang.Object> props)
        Set shape element text properties.
        Parameters:
        shapeID - Shape.
        props - Text props.
      • drawShapeStroke

        public void drawShapeStroke​(java.lang.String shapeID,
                                    java.lang.String colour,
                                    java.lang.String style,
                                    java.lang.Double width)
        Set a shape's stroke.
        Parameters:
        shapeID - Target Shape ID.
        colour - Colour to set.
        style - Stroke Style.
        width - Stroke Width.
      • resizeElement

        public void resizeElement​(java.lang.String id,
                                  java.lang.Double x,
                                  java.lang.Double y,
                                  java.lang.Double rot)
        Resize an element on screen.
        Parameters:
        id - Element ID.
        x - New X size.
        y - New Y size.
        rot - New rotation (degrees).
      • setElementVisibility

        public void setElementVisibility​(java.lang.String id,
                                         java.lang.Boolean vis)
        Set a drawn element's on-screen visibility. Does not modify data.
        Parameters:
        id - Element ID.
        vis - Visibility.
      • removeElementFromScreen

        public void removeElementFromScreen​(java.lang.String id)
        Remove an element from the screen. Does not modify data.
        Parameters:
        id - Element.
      • moveElement

        public void moveElement​(java.lang.String id,
                                java.lang.Double x,
                                java.lang.Double y,
                                java.lang.Double zIndex)
        Move an element.
        Parameters:
        id - Element ID.
        x - New X location.
        y - New Y location.
        zIndex - New Z Index
      • setElementShadow

        public void setElementShadow​(java.lang.String id,
                                     java.lang.Double radius)
        Set basic shadow on an element.
        Parameters:
        id - Target ID.
        radius - Shadow radius.
      • drawPlayer

        public void drawPlayer​(java.lang.String id,
                               java.lang.String mediaLoc,
                               java.lang.Boolean showControls,
                               java.lang.Boolean autoPlay,
                               java.lang.Boolean loop,
                               java.lang.Double offset)
        Show a player.
        Parameters:
        id - Player ID.
        mediaLoc - Media location.
        showControls - Display controls?
        autoPlay - Auto-play media?
        loop - Loop media?
        offset - Media offset (in seconds).
      • togglePlayerPlaying

        public void togglePlayerPlaying​(java.lang.String id,
                                        java.lang.Boolean play)
        Make a player on screen play/pause.
        Parameters:
        id - Player ID.
        play - Play/Pause.
      • deleteElement

        public void deleteElement​(java.lang.String id)
        Delete an element.
        Parameters:
        id - Element ID.
      • makeNewCard

        public void makeNewCard()
        Append a new card.
      • moveCard

        public void moveCard​(java.lang.String id,
                             java.lang.Integer newIndex)
        Move card to new index.
        Parameters:
        id - Card ID.
        newIndex - Position to move to.
      • setCursorType

        public void setCursorType​(java.lang.String cType)
        Set the cursor type.
        Parameters:
        cType - String of Cursor enum value.
      • gotoNextPage

        public void gotoNextPage()
        Go to next sequential page.
      • gotoPrevPage

        public void gotoPrevPage()
        Go to last visited page.
      • gotoPage

        public void gotoPage​(java.lang.Integer pageNum,
                             java.lang.Boolean storeHistory)
        Go to specified page number.
        Parameters:
        pageNum - Number to go to.
        storeHistory - Should I record it in history?
      • gotoPage

        public void gotoPage​(java.lang.String pageID,
                             java.lang.Boolean storeHistory)
        Go to specified page.
        Parameters:
        pageID - ID to go to.
        storeHistory - Should I record it in history?
      • gotoPage

        public void gotoPage​(PageElement page,
                             java.lang.Boolean storeHistory)
        Go to provided page.
        Parameters:
        page - Page to go to.
        storeHistory - Should I record it in history?
      • configCard

        public void configCard​(PageElement page)
        Configure the card.
        Parameters:
        page - card to configure display for.
      • processEls

        public void processEls​(VisualElement el)
        Process elements on a page.
        Parameters:
        el - Element
      • redrawEl

        public void redrawEl​(VisualElement el)
        Re/draws a Visual element.
        Parameters:
        el - Visual Element.
      • evalPyStr

        public void evalPyStr​(java.lang.String code)
        Evaluate a python string.
        Parameters:
        code - Code string.
      • getElScript

        public java.lang.String getElScript​(java.lang.String id)
        Get the string of an Element's script. Returns an empty string if none available.
        Parameters:
        id - Element ID.
        Returns:
        Script string.
      • getElScriptLang

        public java.lang.String getElScriptLang​(java.lang.String id)
        Get an element's language.
        Parameters:
        id - Element ID.
        Returns:
        Language. python if not present.
      • setElScript

        public void setElScript​(java.lang.String id,
                                java.lang.String lang,
                                java.lang.String scr)
        Set an Element's script.
        Parameters:
        id - Element ID.
        lang - Language.
        scr - Script.
      • getToolIO

        public ToolIO getToolIO()
        Get the current Tool IO.
        Returns:
        toolIO.
      • activateTool

        public void activateTool​(java.lang.String toolID)
        Activate tool
        Parameters:
        toolID - Tool to activate.
      • elementRelocated

        public void elementRelocated​(java.lang.String elID,
                                     LocObj newLoc)
        The UI has relocated an element. It upsets me that I can't just easily use Events, but hey ho.
        Parameters:
        elID - Element ID.
        newLoc - New location.
      • getElementProperties

        public java.util.HashMap<java.lang.String,​java.lang.Object> getElementProperties​(java.lang.String elID)
        Provide the Element's properties to the UI.
        Parameters:
        elID - Element ID.
        Returns:
        Properties Map.
      • updateProperties

        public void updateProperties​(java.util.HashMap<java.lang.String,​java.lang.Object> props,
                                     java.lang.String elId)
        Update element properties.
        Parameters:
        props - Properties map.
        elId - Element ID.
      • putMessage

        public void putMessage​(java.lang.String message,
                               java.lang.Boolean blocking)
        Instruct the UI to show a message to the User.
        Parameters:
        message - Message to show
        blocking - Should I block the User?
      • consoleLineCallback

        public void consoleLineCallback​(java.lang.String line)
        Receive line from the console.
        Parameters:
        line - Entered line.
      • readConsoleLine

        public java.lang.String readConsoleLine()
        Read a line from the console. Will wait until data available.
        Returns:
        Line.
      • toggleEdit

        public void toggleEdit​(java.lang.Boolean editable)
        Toggle if the display is editable.
        Parameters:
        editable - Is it editable?
      • showDocChooser

        public void showDocChooser()
        Request the UI to show a doc chooser.
      • saveCurrentDoc

        public void saveCurrentDoc()
        Attempt to save the current doc.
      • saveCurrentDocAs

        public void saveCurrentDocAs​(java.lang.String newPath)
        Attempt to save current doc to new location.
        Parameters:
        newPath - new location to save to.
      • showStartScreen

        public void showStartScreen()
        Loads the start screen.
      • loadEmptyDoc

        public void loadEmptyDoc()
        Load an empty document.
      • exit

        public void exit()
        Exit Application.