Class DiagramController

  • All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers, com.orange.links.client.event.ChangeOnDiagramEvent.HasChangeOnDiagramHandlers, com.orange.links.client.event.NewFunctionEvent.HasNewFunctionHandlers, com.orange.links.client.event.TieLinkEvent.HasTieLinkHandlers, com.orange.links.client.event.UntieLinkEvent.HasUntieLinkHandlers, com.orange.links.client.menu.HasContextMenu

    public class DiagramController
    extends Object
    implements com.orange.links.client.event.NewFunctionEvent.HasNewFunctionHandlers, com.orange.links.client.event.TieLinkEvent.HasTieLinkHandlers, com.orange.links.client.event.UntieLinkEvent.HasUntieLinkHandlers, com.orange.links.client.event.ChangeOnDiagramEvent.HasChangeOnDiagramHandlers, com.orange.links.client.menu.HasContextMenu
    Controller which manage all the diagram logic
    Author:
    Pierre Renaudin (pierre.renaudin.fr@gmail.com), David Durham (david.durham.jr@gmail.com)
    • Field Detail

      • minDistanceToSegment

        public static int minDistanceToSegment
        If the distance between the mouse and segment is under this number in pixels, then, the mouse is considered over the segment
      • refreshRate

        public static int refreshRate
        Timer refresh duration, in milliseconds. It defers if the application is running in development mode or in the web mode
      • inEditionDragMovablePoint

        public boolean inEditionDragMovablePoint
      • inEditionSelectableShapeToDrawConnection

        public boolean inEditionSelectableShapeToDrawConnection
      • inDragBuildArrow

        public boolean inDragBuildArrow
      • inDragMovablePoint

        public boolean inDragMovablePoint
      • inDragWidget

        public boolean inDragWidget
    • Constructor Detail

      • DiagramController

        public DiagramController​(int canvasWidth,
                                 int canvasHeight)
        Initialize the controller diagram. Use this constructor to start your diagram. A code sample is :

        DiagramController controller = new DiagramController(400,400);
        RootPanel.get().add(controller.getView());
        Parameters:
        canvasWidth - width expressed in pixels
        canvasHeight - height expressed in pixels
    • Method Detail

      • getContextMenu

        public com.orange.links.client.menu.ContextMenu getContextMenu()
        Specified by:
        getContextMenu in interface com.orange.links.client.menu.HasContextMenu
      • pauseRefresh

        public void pauseRefresh()
      • runRefresh

        public void runRefresh()
      • clearDiagram

        public void clearDiagram()
        Clear the diagram (connections and widgets)
      • drawStraightArrowConnection

        public com.orange.links.client.connection.Connection drawStraightArrowConnection​(com.google.gwt.user.client.ui.Widget startWidget,
                                                                                         com.google.gwt.user.client.ui.Widget endWidget,
                                                                                         String name)
        Draw a straight connection with an arrow between two GWT widgets. The arrow is pointing to the second widget
        Parameters:
        startWidget - Start widget
        endWidget - End Widget
        name - name of the arrow
        Returns:
        the created new connection between the two widgets
      • drawStraightArrowConnection

        public com.orange.links.client.connection.Connection drawStraightArrowConnection​(com.google.gwt.user.client.ui.Widget startWidget,
                                                                                         com.google.gwt.user.client.ui.Widget endWidget,
                                                                                         GUITransition transition)
      • drawConnection

        public <C extends com.orange.links.client.connection.Connection> C drawConnection​(com.orange.links.client.connection.ConnectionFactory<C> cf,
                                                                                          com.orange.links.client.shapes.Shape start,
                                                                                          com.orange.links.client.shapes.Shape end)
      • drawStraightConnection

        public com.orange.links.client.connection.Connection drawStraightConnection​(com.google.gwt.user.client.ui.Widget startWidget,
                                                                                    com.google.gwt.user.client.ui.Widget endWidget)
        Draw a straight connection between two GWT widgets. The arrow is pointing to the second widget
        Parameters:
        startWidget - Start widget
        endWidget - End Widget
        Returns:
        the created new connection between the two widgets
      • addWidget

        public FunctionShape addWidget​(com.google.gwt.user.client.ui.Widget w,
                                       int left,
                                       int top)
        Add a widget on the diagram
        Parameters:
        w - the widget to add
        left - left margin with the absolute panel
        top - top margin with the absolute panel
        Returns:
        the shape
      • addWidgetAtMousePoint

        public FunctionShape addWidgetAtMousePoint​(com.google.gwt.user.client.ui.Widget w)
      • addDecoration

        public void addDecoration​(com.google.gwt.user.client.ui.Widget decoration,
                                  com.orange.links.client.connection.Connection decoratedConnection)
        Add a widget as a decoration on a connection
        Parameters:
        decoration - widget that will be in the middle of the connection
        decoratedConnection - the connection where the decoration will be put
      • removeDecoration

        public void removeDecoration​(com.orange.links.client.connection.Connection decoratedConnection)
        Remove a decoration from the diagram
        Parameters:
        decoratedConnection - connection where the decoration will be deleted
      • addPointOnConnection

        public void addPointOnConnection​(com.orange.links.client.connection.Connection c,
                                         int left,
                                         int top)
        Add an segment on a path by adding a point on the connection
        Parameters:
        c - the connection where the point will be added
        left - Left margin in pixels
        top - Top margin in pixels
      • showGrid

        public void showGrid​(boolean showGrid)
        Change the background of the canvas by displaying or not a gray grid.
        Parameters:
        showGrid - if true, show a grid, else don't
      • getDiagramCanvas

        public com.orange.links.client.canvas.DiagramCanvas getDiagramCanvas()
        Get the diagram canvas
        Returns:
        the diagram canvas
      • getView

        public com.google.gwt.user.client.ui.AbsolutePanel getView()
        Returns:
        the view where the widgets are displayed
      • setFrameSize

        public void setFrameSize​(int width,
                                 int height)
      • getViewAsScrollPanel

        public com.google.gwt.user.client.ui.ScrollPanel getViewAsScrollPanel()
      • makeDraggable

        public void makeDraggable​(com.smartgwt.client.widgets.Canvas widget)
        OUR personalization to allow dragging into SmartGWT
        Parameters:
        widget - widget to alter
      • registerDragController

        public void registerDragController​(com.allen_sauer.gwt.dnd.client.DragController dragController)
        Register a drag controller to control the refresh rate
        Parameters:
        dragController - The DragController used to handle the drags on widgets
      • unsynchronizedShapes

        public void unsynchronizedShapes()
      • synchronizedShapes

        public void synchronizedShapes()
      • fireEvent

        public void fireEvent​(com.google.gwt.event.shared.GwtEvent<?> event)
        Specified by:
        fireEvent in interface com.google.gwt.event.shared.HasHandlers
      • addUntieLinkHandler

        public com.google.gwt.event.shared.HandlerRegistration addUntieLinkHandler​(com.orange.links.client.event.UntieLinkHandler handler)
        Specified by:
        addUntieLinkHandler in interface com.orange.links.client.event.UntieLinkEvent.HasUntieLinkHandlers
      • addTieLinkHandler

        public com.google.gwt.event.shared.HandlerRegistration addTieLinkHandler​(com.orange.links.client.event.TieLinkHandler handler)
        Specified by:
        addTieLinkHandler in interface com.orange.links.client.event.TieLinkEvent.HasTieLinkHandlers
      • addChangeOnDiagramHandler

        public com.google.gwt.event.shared.HandlerRegistration addChangeOnDiagramHandler​(com.orange.links.client.event.ChangeOnDiagramHandler handler)
        Specified by:
        addChangeOnDiagramHandler in interface com.orange.links.client.event.ChangeOnDiagramEvent.HasChangeOnDiagramHandlers
      • addNewFunctionHandler

        public com.google.gwt.event.shared.HandlerRegistration addNewFunctionHandler​(com.orange.links.client.event.NewFunctionHandler handler)
        Specified by:
        addNewFunctionHandler in interface com.orange.links.client.event.NewFunctionEvent.HasNewFunctionHandlers
      • isShowGrid

        public boolean isShowGrid()
        Returns:
        true if a grid is displayed in background
      • update

        public void update()
      • deleteConnection

        public void deleteConnection​(com.orange.links.client.connection.Connection c)
      • deleteWidget

        public void deleteWidget​(com.google.gwt.user.client.ui.Widget widget)
      • getMousePoint

        public com.orange.links.client.shapes.Point getMousePoint()
      • getCanvasWidth

        public int getCanvasWidth()
      • getCanvasHeight

        public int getCanvasHeight()
      • getFps

        public long getFps()
        Returns:
        the fps which are really displayed (frame per second)
      • getUnsynchronizedConnections

        public com.orange.links.client.shapes.DrawableSet<com.orange.links.client.connection.Connection> getUnsynchronizedConnections()
        Returns:
        unsynchronized connection
      • getDiagramModel

        public com.orange.links.client.save.DiagramModel getDiagramModel()
      • exportDiagram

        public String exportDiagram()
      • importDiagram

        public void importDiagram​(String diagramXmlExport,
                                  com.orange.links.client.save.DiagramWidgetFactory saveFactory)
      • getShapes

        public com.orange.links.client.shapes.DrawableSet<FunctionShape> getShapes()
      • getFunctionsMap

        public Map<com.google.gwt.user.client.ui.Widget,​Map<com.google.gwt.user.client.ui.Widget,​com.orange.links.client.connection.Connection>> getFunctionsMap()