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
FieldsModifier and TypeFieldDescriptionbooleanbooleanbooleanbooleanbooleanstatic intIf the distance between the mouse and segment is under this number in pixels, then, the mouse is considered over the segmentstatic intTimer refresh duration, in milliseconds. -
Constructor Summary
ConstructorsConstructorDescriptionDiagramController(int canvasWidth, int canvasHeight) Initialize the controller diagram. -
Method Summary
Modifier 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
-
minDistanceToSegment
public static int minDistanceToSegmentIf 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 refreshRateTimer 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 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:
getContextMenuin 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:
addUntieLinkHandlerin 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:
addTieLinkHandlerin 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:
addChangeOnDiagramHandlerin 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:
addNewFunctionHandlerin 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
-