Package com.orange.links.client
Class DiagramController
java.lang.Object
com.orange.links.client.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 Summary
Modifier and TypeFieldDescriptionstatic final int
If the distance between the mouse and segment is under this number in pixels, then, the mouse is considered over the segmentstatic final int
Timer refresh duration, in milliseconds. -
Constructor Summary
ConstructorDescriptionDiagramController
(int canvasWidth, int canvasHeight) Initialize the controller diagram. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gwt.event.shared.HandlerRegistration
addChangeOnDiagramHandler
(com.orange.links.client.event.ChangeOnDiagramHandler handler) 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 connectioncom.google.gwt.event.shared.HandlerRegistration
addNewFunctionHandler
(com.orange.links.client.event.NewFunctionHandler handler) 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 connectioncom.google.gwt.event.shared.HandlerRegistration
addTieLinkHandler
(com.orange.links.client.event.TieLinkHandler handler) com.google.gwt.event.shared.HandlerRegistration
addUntieLinkHandler
(com.orange.links.client.event.UntieLinkHandler handler) addWidget
(com.google.gwt.user.client.ui.Widget w, int left, int top) Add a widget on the diagramaddWidgetAtMousePoint
(com.google.gwt.user.client.ui.Widget w) void
Clear the diagram (connections and widgets)void
deleteConnection
(com.orange.links.client.connection.Connection c) void
deleteWidget
(com.google.gwt.user.client.ui.Widget widget) <C extends com.orange.links.client.connection.Connection>
CdrawConnection
(com.orange.links.client.connection.ConnectionFactory<C> cf, com.orange.links.client.shapes.Shape start, com.orange.links.client.shapes.Shape end) 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) 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.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.void
fireEvent
(com.google.gwt.event.shared.GwtEvent<?> event) int
int
com.orange.links.client.menu.ContextMenu
com.orange.links.client.canvas.DiagramCanvas
Get the diagram canvascom.orange.links.client.save.DiagramModel
long
getFps()
Map<com.google.gwt.user.client.ui.Widget,
Map<com.google.gwt.user.client.ui.Widget, com.orange.links.client.connection.Connection>> com.orange.links.client.shapes.Point
com.orange.links.client.shapes.DrawableSet<FunctionShape>
com.orange.links.client.shapes.DrawableSet<com.orange.links.client.connection.Connection>
com.google.gwt.user.client.ui.AbsolutePanel
getView()
com.google.gwt.user.client.ui.ScrollPanel
void
importDiagram
(String diagramXmlExport, com.orange.links.client.save.DiagramWidgetFactory saveFactory) boolean
void
makeDraggable
(com.smartgwt.client.widgets.Canvas widget) OUR personalization to allow dragging into SmartGWTvoid
void
registerDragController
(com.allen_sauer.gwt.dnd.client.DragController dragController) Register a drag controller to control the refresh ratevoid
removeDecoration
(com.orange.links.client.connection.Connection decoratedConnection) Remove a decoration from the diagramvoid
void
setFrameSize
(int width, int height) void
showGrid
(boolean showGrid) Change the background of the canvas by displaying or not a gray grid.void
void
void
update()
-
Field Details
-
MIN_DISTANCE_TO_SEGMENT
public static final int MIN_DISTANCE_TO_SEGMENTIf the distance between the mouse and segment is under this number in pixels, then, the mouse is considered over the segment- See Also:
-
REFERESH_RATE
public static final int REFERESH_RATETimer refresh duration, in milliseconds. It defers if the application is running in development mode or in the web mode- See Also:
-
-
Constructor Details
-
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 pixelscanvasHeight
- height expressed in pixels
-
-
Method Details
-
getContextMenu
public com.orange.links.client.menu.ContextMenu getContextMenu()- Specified by:
getContextMenu
in interfacecom.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 widgetendWidget
- End Widgetname
- 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 widgetendWidget
- End Widget- Returns:
- the created new connection between the two widgets
-
addWidget
Add a widget on the diagram- Parameters:
w
- the widget to addleft
- left margin with the absolute paneltop
- top margin with the absolute panel- Returns:
- the shape
-
addWidgetAtMousePoint
-
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 connectiondecoratedConnection
- 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 addedleft
- Left margin in pixelstop
- 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() -
addUntieLinkHandler
public com.google.gwt.event.shared.HandlerRegistration addUntieLinkHandler(com.orange.links.client.event.UntieLinkHandler handler) - Specified by:
addUntieLinkHandler
in interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.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
-
importDiagram
public void importDiagram(String diagramXmlExport, com.orange.links.client.save.DiagramWidgetFactory saveFactory) -
getShapes
-
getFunctionsMap
-