Class ServerMethods

  • All Implemented Interfaces:
    IServerMethods

    @Controller
    public class ServerMethods
    extends java.lang.Object
    implements IServerMethods
    Rest Controller, receives Client-requests and responds
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerMethods()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String createLayer​(java.lang.String clientId, java.lang.String layerid)
      creates Layer with layerid as name in html
      java.lang.String createShape​(java.lang.String clientId, java.lang.String type, java.lang.String canvasId, java.lang.String cx, java.lang.String cy, java.lang.String rx, java.lang.String ry, java.lang.String fill, java.lang.String stroke, java.lang.String stroke_width, java.lang.String info_text)
      creates a shape of type-template with all given parameters
      java.lang.String deleteClientData​(java.lang.String clientId)
      closes Client Data,closes and deletes saved files of Client. should be used to free resources
      java.lang.String deleteShape​(java.lang.String clientId, java.lang.String shapeId)
      deletes shape with shapeid in layerID, returns exception if nothing found
      java.lang.String editShape​(java.lang.String clientId, java.lang.String canvasId, java.lang.String shapeID, java.lang.String cx, java.lang.String cy, java.lang.String rx, java.lang.String ry, java.lang.String fill, java.lang.String stroke, java.lang.String stroke_width, java.lang.String info_text)
      gets shape-type and changes all parameters which are not null, example: if only cx and cy are given for a circle, it knows that circle should only be moved.
      java.util.List<java.lang.String> getColours()
      List with all possible Colours
      java.util.List<java.lang.String> getEditOptions()
      List with all Edit options possible in menue, like changeColour, addStroke, move, delete, create,
      java.lang.String getHtmlCanvas​(java.lang.String clientId)  
      java.util.List<java.lang.String> getLayers​(java.lang.String clientId)
      list with names of all created layers
      java.util.List<java.lang.String> getShapes()
      List with all possible Shapes
      java.util.List<java.lang.String> getShapesOfLayer​(java.lang.String clientId, java.lang.String layerId)
      List with all Shapenames of Layer
      java.lang.String getSVG​(java.lang.String clientId)
      saves active Layers as one svg
      java.lang.String LayerActivition​(java.lang.String clientId, java.lang.Boolean activated, java.lang.String layerId)
      sets Layer active(True) or gets deactivated(false)
      java.lang.String registerClient()
      registers Client, opens new Thread and returns id
      org.springframework.http.ResponseEntity<java.lang.String> test()
      testmethod, can be used to test communication
      • Methods inherited from class java.lang.Object

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

      • ServerMethods

        public ServerMethods()
    • Method Detail

      • test

        @RequestMapping(value="/test",
                        method=GET)
        @ResponseBody
        public org.springframework.http.ResponseEntity<java.lang.String> test()
        Description copied from interface: IServerMethods
        testmethod, can be used to test communication
        Specified by:
        test in interface IServerMethods
        Returns:
        ResponseEntity mit String Data
      • createShape

        @RequestMapping(value="/createshape",
                        method=GET)
        public java.lang.String createShape​(@RequestParam("clientid")
                                            java.lang.String clientId,
                                            @RequestParam(value="type",defaultValue="")
                                            java.lang.String type,
                                            @RequestParam(value="canvasId",defaultValue="")
                                            java.lang.String canvasId,
                                            @RequestParam(value="cx",defaultValue="")
                                            java.lang.String cx,
                                            @RequestParam(value="cy",defaultValue="")
                                            java.lang.String cy,
                                            @RequestParam(value="rx",defaultValue="",required=false)
                                            java.lang.String rx,
                                            @RequestParam(value="ry",defaultValue="",required=false)
                                            java.lang.String ry,
                                            @RequestParam(value="fill",defaultValue="BLUE")
                                            java.lang.String fill,
                                            @RequestParam(value="stroke",defaultValue="",required=false)
                                            java.lang.String stroke,
                                            @RequestParam(value="stroke_width",defaultValue="",required=false)
                                            java.lang.String stroke_width,
                                            @RequestParam(value="info_text",defaultValue="",required=false)
                                            java.lang.String info_text)
        Description copied from interface: IServerMethods
        creates a shape of type-template with all given parameters
        Specified by:
        createShape in interface IServerMethods
        Parameters:
        clientId - =id of client
        type - =shape
        canvasId - =Layerid
        cx - =x1-point - Default:Null
        cy - =y1-point - Default:Null
        rx - =radius for circle/x2 point for line/width - not required
        ry - =ry paramater/y2 point for line/height - not required
        fill - =colour to fill shape
        stroke - =stroke colour - not required
        stroke_width - = stroke thickness - not required
        info_text - =text, points, path - not required
        Returns:
        html Doc with new reated Shape
      • createLayer

        @RequestMapping(value="/createlayer",
                        method=POST)
        public java.lang.String createLayer​(java.lang.String clientId,
                                            java.lang.String layerid)
        Description copied from interface: IServerMethods
        creates Layer with layerid as name in html
        Specified by:
        createLayer in interface IServerMethods
        Parameters:
        clientId - String
        layerid - string id
        Returns:
        info about success
      • registerClient

        @RequestMapping(value="/registerclient",
                        method=POST)
        public java.lang.String registerClient()
        Description copied from interface: IServerMethods
        registers Client, opens new Thread and returns id
        Specified by:
        registerClient in interface IServerMethods
        Returns:
        Client Id
      • getSVG

        @RequestMapping(value="/getSVG",
                        method=GET)
        public java.lang.String getSVG​(java.lang.String clientId)
        Description copied from interface: IServerMethods
        saves active Layers as one svg
        Specified by:
        getSVG in interface IServerMethods
        Parameters:
        clientId - String
        Returns:
        String in SVG format
      • editShape

        @RequestMapping(value="/editshape",
                        method=GET)
        public java.lang.String editShape​(@RequestParam(value="clientid",defaultValue="")
                                          java.lang.String clientId,
                                          @RequestParam(value="canvasId",defaultValue="")
                                          java.lang.String canvasId,
                                          @RequestParam(value="shapeID",defaultValue="")
                                          java.lang.String shapeID,
                                          @RequestParam(value="cx",required=false)
                                          java.lang.String cx,
                                          @RequestParam(value="cy",required=false)
                                          java.lang.String cy,
                                          @RequestParam(value="rx",required=false)
                                          java.lang.String rx,
                                          @RequestParam(value="ry",required=false)
                                          java.lang.String ry,
                                          @RequestParam(value="fill",required=false)
                                          java.lang.String fill,
                                          @RequestParam(value="stroke",required=false)
                                          java.lang.String stroke,
                                          @RequestParam(value="stroke_width",required=false)
                                          java.lang.String stroke_width,
                                          @RequestParam(value="info_text",required=false)
                                          java.lang.String info_text)
        Description copied from interface: IServerMethods
        gets shape-type and changes all parameters which are not null, example: if only cx and cy are given for a circle, it knows that circle should only be moved.
        Specified by:
        editShape in interface IServerMethods
        Parameters:
        clientId - string clientid
        canvasId - =Layerid
        shapeID - =Name of Layer, given by user
        cx - =x1-point - Default:Null
        cy - =y1-point - Default:Null
        rx - =radius for circle/x2 point for line - Default:Null
        ry - =ry paramater/y2 point for line - Default:Null
        fill - =colour - Default:Null
        stroke - =stroke colour - Default:Null
        stroke_width - =number of stroke thickness
        info_text - =text, points, path
        Returns:
        html Doc of Canvas with edited Shape
      • getLayers

        @RequestMapping(value="/getlayers",
                        method=GET)
        public java.util.List<java.lang.String> getLayers​(java.lang.String clientId)
        Description copied from interface: IServerMethods
        list with names of all created layers
        Specified by:
        getLayers in interface IServerMethods
        Parameters:
        clientId - string clientid
        Returns:
        String List with all LayerIds
      • getShapesOfLayer

        @RequestMapping(value="getshapesoflayer",
                        method=GET)
        public java.util.List<java.lang.String> getShapesOfLayer​(java.lang.String clientId,
                                                                 java.lang.String layerId)
        Description copied from interface: IServerMethods
        List with all Shapenames of Layer
        Specified by:
        getShapesOfLayer in interface IServerMethods
        Parameters:
        clientId - string clientid
        layerId - string clientid
        Returns:
        String List with all Shape ids of a specified Layer
      • getColours

        @RequestMapping(value="/getcolours",
                        method=GET)
        public java.util.List<java.lang.String> getColours()
        Description copied from interface: IServerMethods
        List with all possible Colours
        Specified by:
        getColours in interface IServerMethods
        Returns:
        String List with Colours
      • getShapes

        @RequestMapping(value="/getshapes",
                        method=GET)
        public java.util.List<java.lang.String> getShapes()
        Description copied from interface: IServerMethods
        List with all possible Shapes
        Specified by:
        getShapes in interface IServerMethods
        Returns:
        String List with shapes. eg. rectangular, circle
      • getEditOptions

        @RequestMapping(value="/geteditoptions",
                        method=GET)
        public java.util.List<java.lang.String> getEditOptions()
        Description copied from interface: IServerMethods
        List with all Edit options possible in menue, like changeColour, addStroke, move, delete, create,
        Specified by:
        getEditOptions in interface IServerMethods
        Returns:
        String List with options. e.g. create,delete etc
      • deleteShape

        @RequestMapping(value="/deleteshape",
                        method=DELETE)
        public java.lang.String deleteShape​(java.lang.String clientId,
                                            java.lang.String shapeId)
        Description copied from interface: IServerMethods
        deletes shape with shapeid in layerID, returns exception if nothing found
        Specified by:
        deleteShape in interface IServerMethods
        Parameters:
        clientId - String
        shapeId - String
        Returns:
        String with message about success
      • deleteClientData

        @RequestMapping(value="/deleteclientdata",
                        method=DELETE)
        public java.lang.String deleteClientData​(java.lang.String clientId)
        Description copied from interface: IServerMethods
        closes Client Data,closes and deletes saved files of Client. should be used to free resources
        Specified by:
        deleteClientData in interface IServerMethods
        Parameters:
        clientId - string clientid
        Returns:
        String with message about success
      • LayerActivition

        @RequestMapping(value="/layeractivition",
                        method=POST)
        public java.lang.String LayerActivition​(java.lang.String clientId,
                                                java.lang.Boolean activated,
                                                java.lang.String layerId)
        Description copied from interface: IServerMethods
        sets Layer active(True) or gets deactivated(false)
        Specified by:
        LayerActivition in interface IServerMethods
        Parameters:
        clientId - String
        activated - boolean
        layerId - String
        Returns:
        String with message about success
      • getHtmlCanvas

        public java.lang.String getHtmlCanvas​(java.lang.String clientId)
        Specified by:
        getHtmlCanvas in interface IServerMethods
        Parameters:
        clientId - string clientid
        Returns:
        Html Doc of Layers