Class SurfaceMapper


  • public class SurfaceMapper
    extends Object
    • Field Detail

      • MODE

        public int MODE
      • snap

        protected boolean snap
      • prevMouse

        protected processing.core.PVector prevMouse
      • ctrlDown

        protected boolean ctrlDown
      • altDown

        protected boolean altDown
      • grouping

        protected boolean grouping
      • selectionTool

        protected Rectangle selectionTool
      • startPos

        protected processing.core.PVector startPos
      • isDragging

        protected boolean isDragging
      • disableSelectionTool

        protected boolean disableSelectionTool
    • Constructor Detail

      • SurfaceMapper

        public SurfaceMapper​(processing.core.PApplet parent,
                             int width,
                             int height)
        Create instance of IxKeystone
        Parameters:
        parent -
        width -
        height -
    • Method Detail

      • removeDuplicates

        public static <T> void removeDuplicates​(ArrayList<T> list)
      • addEventHandler

        public void addEventHandler​(Object object,
                                    String methodName)
      • addSelectedSurface

        public void addSelectedSurface​(SuperSurface cps)
        Add a surface to selected surfaces
        Parameters:
        cps -
      • addSurface

        public SuperSurface addSurface​(SuperSurface superSurface)
        Add a surface to surfaceMapper
        Parameters:
        superSurface -
        Returns:
      • bringSurfaceToFront

        public void bringSurfaceToFront​(int index)
        Places the surface last in the surfaces array, i.e. on top.
        Parameters:
        index -
      • clearSelectedSurfaces

        public void clearSelectedSurfaces()
        Clears the arraylist of selected surfaces.
      • clearSurfaces

        public void clearSurfaces()
        Remove all surfaces
      • bringFrontSurface

        public void bringFrontSurface()
      • bringBackSurface

        public void bringBackSurface()
      • createBezierSurface

        public SuperSurface createBezierSurface​(int res)
        Creates a Bezier surface with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.
        Parameters:
        res -
        Returns:
      • createBezierSurface

        public SuperSurface createBezierSurface​(int res,
                                                int x,
                                                int y)
        Creates a Bezier surface at X/Y with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.
        Parameters:
        res -
        x -
        y -
        Returns:
      • createQuadSurface

        public SuperSurface createQuadSurface​(int res)
        Creates a Quad surface with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.
        Parameters:
        res -
        Returns:
      • createQuadSurface

        public SuperSurface createQuadSurface​(int res,
                                              int x,
                                              int y)
        Creates a Quad surface at X/Y with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.
        Parameters:
        res -
        x -
        y -
        Returns:
      • disableMouseEvents

        public void disableMouseEvents()
        Unregisters Mouse Event listener for the SurfaceMapper
      • enableMouseEvents

        public void enableMouseEvents()
        Registers Mouse Event listener for the SurfaceMapper
      • findActiveBezierSurface

        public boolean findActiveBezierSurface​(float mX,
                                               float mY)
        Check if coordinates is inside any of the bezier surfaces.
        Parameters:
        mX -
        mY -
        Returns:
      • findActiveQuadSurface

        public boolean findActiveQuadSurface​(float mX,
                                             float mY)
        Check if coordinates is inside any of the quad surfaces.
        Parameters:
        mX -
        mY -
        Returns:
      • findActiveSurface

        public boolean findActiveSurface​(float mX,
                                         float mY)
        Check if coordinates is inside any of the surfaces.
        Parameters:
        mX -
        mY -
        Returns:
      • fireEvent

        public void fireEvent​(int id)
        Fire event to object
      • getColor

        public int[] getColor()
        Returns the array of colors used in calibration mode for coloring the surfaces.
        Returns:
      • getDebug

        public boolean getDebug()
        See if debug mode is on.
        Returns:
      • getDisableSelectionTool

        public boolean getDisableSelectionTool()
        Is the selection tool disabled?
        Returns:
      • getIdFont

        public processing.core.PFont getIdFont()
        Get font for drawing text
        Returns:
      • getMode

        public int getMode()
        Check which mode is enabled (render or calibrate)
        Returns:
      • getNumAddedSurfaces

        public int getNumAddedSurfaces()
      • getPrevMouse

        public processing.core.PVector getPrevMouse()
        Get previous mouse position
        Returns:
      • getSelectedSurfaces

        public ArrayList<SuperSurface> getSelectedSurfaces()
        Get the selected surfaces
        Returns:
      • getSelectionDistance

        public int getSelectionDistance()
        Get current max distance for an object to be selected
        Returns:
      • getSelectionMouseColor

        public int getSelectionMouseColor()
      • getSelectionTool

        public Rectangle getSelectionTool()
        Returns the rectangle used for selecting surfaces
        Returns:
      • getSketchList

        public List<Sketch> getSketchList()
      • getSnap

        public boolean getSnap()
        See if snap mode is used
        Returns:
      • getSnapDistance

        public int getSnapDistance()
        See the snap distance
        Returns:
      • getSurfaceById

        public SuperSurface getSurfaceById​(int id)
        Get surface by Id.
        Parameters:
        id -
        Returns:
      • isAllowUserInput

        public boolean isAllowUserInput()
        Check if any user event is allowed
        Returns:
      • isAltDown

        public boolean isAltDown()
        Is ALT pressed?
        Returns:
      • isCtrlDown

        public boolean isCtrlDown()
        Is CTRL pressed?
        Returns:
      • isDragging

        public boolean isDragging()
        Returns:
      • isEnableSelectionMouse

        public boolean isEnableSelectionMouse()
      • isGrouping

        public boolean isGrouping()
        Check if multiple surfaces are being manipulated
        Returns:
      • isUsingBackground

        public boolean isUsingBackground()
        Boolean used to know if the background image should be rendered in calibration mode.
        Returns:
      • keyEvent

        public void keyEvent​(processing.event.KeyEvent k)
        KeyEvent method
        Parameters:
        k -
      • ksMouseEvent

        public void ksMouseEvent​(processing.event.MouseEvent e)
        MouseEvent method.
        Parameters:
        e -
      • load

        public void load​(File file)
        Load projection map from file
        Parameters:
        file -
      • mouseEvent

        public void mouseEvent​(processing.event.MouseEvent e)
        MouseEvent method. Forwards the MouseEvent to ksMouseEvent if user input is allowed
        Parameters:
        e -
      • movePoint

        public void movePoint​(SuperSurface ss,
                              int x,
                              int y)
        Move a point of a surface
        Parameters:
        ss -
        x -
        y -
      • removeSelectedSurfaces

        public void removeSelectedSurfaces()
        Delete the selected surfaces
      • render

        public void render​(processing.core.PGraphics glos)
        Render method used when calibrating. Shouldn't be used for final rendering.
        Parameters:
        glos -
      • save

        public void save​(processing.data.XML root)
        Puts all projection mapping data in the XMLElement
        Parameters:
        root -
      • save

        public void save​(File file)
        Save all projection mapping data to file
        Parameters:
        file -
      • selectSurfaces

        public void selectSurfaces​(int mX,
                                   int mY)
      • setAllowUserInput

        public void setAllowUserInput​(boolean allowUserInput)
        Set if any user event is allowed
        Parameters:
        allowUserInput -
      • setBackground

        public void setBackground​(processing.core.PImage tex)
        Optionally set a background image in calibration mode.
        Parameters:
        tex -
      • setColor

        public void setColor​(int[] ccolor)
        Set the array of colors used in calibration mode for coloring the surfaces.
        Parameters:
        ccolor -
      • setCtrlDown

        public void setCtrlDown​(boolean pressed)
        Set CTRL pressed
        Parameters:
        pressed -
      • setDebug

        public void setDebug​(boolean debug)
        Manually set debug mode. (debug mode will print more to console)
        Parameters:
        debug -
      • setDisableSelectionTool

        public void setDisableSelectionTool​(boolean disableSelectionTool)
        Enable/disable selection tool
        Parameters:
        disableSelectionTool -
      • setEnableSelectionMouse

        public void setEnableSelectionMouse​(boolean enableSelectionMouse)
      • setGrouping

        public void setGrouping​(boolean grouping)
        Set if multiple surfaces are being manipulated
        Parameters:
        grouping -
      • setIsDragging

        public void setIsDragging​(boolean isDragging)
        Parameters:
        isDragging -
      • setModeCalibrate

        public void setModeCalibrate()
        Set mode to calibrate
      • setModeRender

        public void setModeRender()
        Set mode to render
      • setNumAddedSurfaces

        public void setNumAddedSurfaces​(int numAddedSurfaces)
      • setPrevMouse

        public void setPrevMouse​(float x,
                                 float y)
        Set previous mouse position
        Parameters:
        x -
        y -
      • setSelectedSurface

        public void setSelectedSurface​(SuperSurface cps)
        Select the surface. Deselects all previously selected surfaces.
        Parameters:
        cps -
      • setSelectionDistance

        public void setSelectionDistance​(int selectionDistance)
        Set the max distance for an object to be selected
        Parameters:
        selectionDistance -
      • setSelectionMouseColor

        public void setSelectionMouseColor​(int selectionMouseColor)
      • setSelectionTool

        public void setSelectionTool​(Rectangle r)
        Set the selection tool
        Parameters:
        r -
      • setSelectionTool

        public void setSelectionTool​(int x,
                                     int y,
                                     int width,
                                     int height)
        Set the selection tool
        Parameters:
        x -
        y -
        width -
        height -
      • setShakeAll

        public void setShakeAll​(int strength,
                                int speed,
                                int fallOfSpeed)
        Shake all surfaces with max Z-displacement strength, vibration-speed speed, and shake decline fallOfSpeed. (min 0, max 1000 (1000 = un-ending shaking))
        Parameters:
        strength -
        speed -
        fallOfSpeed -
      • setSketchList

        public void setSketchList​(List<Sketch> sketchList)
      • setSnap

        public void setSnap​(boolean snap)
        Manually set corner snap mode
        Parameters:
        snap -
      • setSnapDistance

        public void setSnapDistance​(int snapDistance)
        Set corner snap distance
        Parameters:
        snapDistance -
      • setUsingBackground

        public void setUsingBackground​(boolean val)
        Set if background image should rendered in calibration mode
        Parameters:
        val -
      • shake

        public void shake()
        Update shaking for all surfaces
      • toggleCalibration

        public void toggleCalibration()
        Toggle the mode
      • toggleSnap

        public void toggleSnap()
        Toggle if corner snapping is used
      • version

        public String version()