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 SummaryFieldsModifier and TypeFieldDescriptionstatic final intIf the distance between the mouse and segment is under this number in pixels, then, the mouse is considered over the segmentstatic final intTimer refresh duration, in milliseconds.
- 
Constructor SummaryConstructorsConstructorDescriptionDiagramController(int canvasWidth, int canvasHeight) Initialize the controller diagram.
- 
Method SummaryModifier and TypeMethodDescriptioncom.google.gwt.event.shared.HandlerRegistrationaddChangeOnDiagramHandler(com.orange.links.client.event.ChangeOnDiagramHandler handler) voidaddDecoration(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.HandlerRegistrationaddNewFunctionHandler(com.orange.links.client.event.NewFunctionHandler handler) voidaddPointOnConnection(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.HandlerRegistrationaddTieLinkHandler(com.orange.links.client.event.TieLinkHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddUntieLinkHandler(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) voidClear the diagram (connections and widgets)voiddeleteConnection(com.orange.links.client.connection.Connection c) voiddeleteWidget(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.ConnectiondrawStraightArrowConnection(com.google.gwt.user.client.ui.Widget startWidget, com.google.gwt.user.client.ui.Widget endWidget, GUITransition transition) com.orange.links.client.connection.ConnectiondrawStraightArrowConnection(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.ConnectiondrawStraightConnection(com.google.gwt.user.client.ui.Widget startWidget, com.google.gwt.user.client.ui.Widget endWidget) Draw a straight connection between two GWT widgets.voidfireEvent(com.google.gwt.event.shared.GwtEvent<?> event) intintcom.orange.links.client.menu.ContextMenucom.orange.links.client.canvas.DiagramCanvasGet the diagram canvascom.orange.links.client.save.DiagramModellonggetFps()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.Pointcom.orange.links.client.shapes.DrawableSet<FunctionShape> com.orange.links.client.shapes.DrawableSet<com.orange.links.client.connection.Connection> com.google.gwt.user.client.ui.AbsolutePanelgetView()com.google.gwt.user.client.ui.ScrollPanelvoidimportDiagram(String diagramXmlExport, com.orange.links.client.save.DiagramWidgetFactory saveFactory) booleanvoidmakeDraggable(com.smartgwt.client.widgets.Canvas widget) OUR personalization to allow dragging into SmartGWTvoidvoidregisterDragController(com.allen_sauer.gwt.dnd.client.DragController dragController) Register a drag controller to control the refresh ratevoidremoveDecoration(com.orange.links.client.connection.Connection decoratedConnection) Remove a decoration from the diagramvoidvoidsetFrameSize(int width, int height) voidshowGrid(boolean showGrid) Change the background of the canvas by displaying or not a gray grid.voidvoidvoidupdate()
- 
Field Details- 
MIN_DISTANCE_TO_SEGMENTpublic 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_RATEpublic 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- 
DiagramControllerpublic 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 Details- 
getContextMenupublic com.orange.links.client.menu.ContextMenu getContextMenu()- Specified by:
- getContextMenuin interface- com.orange.links.client.menu.HasContextMenu
 
- 
pauseRefreshpublic void pauseRefresh()
- 
runRefreshpublic void runRefresh()
- 
clearDiagrampublic void clearDiagram()Clear the diagram (connections and widgets)
- 
drawStraightArrowConnectionpublic 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
 
- 
drawStraightArrowConnectionpublic 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) 
- 
drawConnectionpublic <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) 
- 
drawStraightConnectionpublic 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
 
- 
addWidgetAdd 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
- 
addDecorationpublic 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
 
- 
removeDecorationpublic void removeDecoration(com.orange.links.client.connection.Connection decoratedConnection) Remove a decoration from the diagram- Parameters:
- decoratedConnection- connection where the decoration will be deleted
 
- 
addPointOnConnectionpublic 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
 
- 
showGridpublic 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
 
- 
getDiagramCanvaspublic com.orange.links.client.canvas.DiagramCanvas getDiagramCanvas()Get the diagram canvas- Returns:
- the diagram canvas
 
- 
getViewpublic com.google.gwt.user.client.ui.AbsolutePanel getView()- Returns:
- the view where the widgets are displayed
 
- 
setFrameSizepublic void setFrameSize(int width, int height) 
- 
getViewAsScrollPanelpublic com.google.gwt.user.client.ui.ScrollPanel getViewAsScrollPanel()
- 
makeDraggablepublic void makeDraggable(com.smartgwt.client.widgets.Canvas widget) OUR personalization to allow dragging into SmartGWT- Parameters:
- widget- widget to alter
 
- 
registerDragControllerpublic 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
 
- 
unsynchronizedShapespublic void unsynchronizedShapes()
- 
synchronizedShapespublic void synchronizedShapes()
- 
addUntieLinkHandlerpublic com.google.gwt.event.shared.HandlerRegistration addUntieLinkHandler(com.orange.links.client.event.UntieLinkHandler handler) - Specified by:
- addUntieLinkHandlerin interface- com.orange.links.client.event.UntieLinkEvent.HasUntieLinkHandlers
 
- 
addTieLinkHandlerpublic com.google.gwt.event.shared.HandlerRegistration addTieLinkHandler(com.orange.links.client.event.TieLinkHandler handler) - Specified by:
- addTieLinkHandlerin interface- com.orange.links.client.event.TieLinkEvent.HasTieLinkHandlers
 
- 
addChangeOnDiagramHandlerpublic com.google.gwt.event.shared.HandlerRegistration addChangeOnDiagramHandler(com.orange.links.client.event.ChangeOnDiagramHandler handler) - Specified by:
- addChangeOnDiagramHandlerin interface- com.orange.links.client.event.ChangeOnDiagramEvent.HasChangeOnDiagramHandlers
 
- 
addNewFunctionHandlerpublic com.google.gwt.event.shared.HandlerRegistration addNewFunctionHandler(com.orange.links.client.event.NewFunctionHandler handler) - Specified by:
- addNewFunctionHandlerin interface- com.orange.links.client.event.NewFunctionEvent.HasNewFunctionHandlers
 
- 
isShowGridpublic boolean isShowGrid()- Returns:
- true if a grid is displayed in background
 
- 
updatepublic void update()
- 
deleteConnectionpublic void deleteConnection(com.orange.links.client.connection.Connection c) 
- 
deleteWidgetpublic void deleteWidget(com.google.gwt.user.client.ui.Widget widget) 
- 
getMousePointpublic com.orange.links.client.shapes.Point getMousePoint()
- 
getCanvasWidthpublic int getCanvasWidth()
- 
getCanvasHeightpublic int getCanvasHeight()
- 
getFpspublic long getFps()- Returns:
- the fps which are really displayed (frame per second)
 
- 
getUnsynchronizedConnectionspublic com.orange.links.client.shapes.DrawableSet<com.orange.links.client.connection.Connection> getUnsynchronizedConnections()- Returns:
- unsynchronized connection
 
- 
getDiagramModelpublic com.orange.links.client.save.DiagramModel getDiagramModel()
- 
exportDiagram
- 
importDiagrampublic void importDiagram(String diagramXmlExport, com.orange.links.client.save.DiagramWidgetFactory saveFactory) 
- 
getShapes
- 
getFunctionsMap
 
-