From 39949dae437b3447f488bb812ff5e9871379f808 Mon Sep 17 00:00:00 2001 From: quentinflahaut Date: Wed, 12 Mar 2014 09:49:58 +0100 Subject: [PATCH] Update README.md --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a632075..5fce52e 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ graph.addEdge("europe", "germany", "euro", "#FFA500", true); graph.addEdge("europe", "italy", "euro", "#FFA500", true); graph.addEdge("europe", "spain", "euro", "#FFA500", true); graph.addEdge("europe", "etce", 4.0, "euro", "#0000FF", true); -graph.addEdge("europe", "uk", "�", "#FFA500", true); +graph.addEdge("europe", "uk", "£", "#FFA500", true); graph.addEdge("asia", "china"); graph.addEdge("asia", "japan"); @@ -295,6 +295,49 @@ With VivaGraph +#### Handle an event a change node color +```java +//Handle when the mouse goes over a node: +graph.addNodeMouseHoverHandler(new NodeMouseHoverHandler() { + + @Override + public void onMouseHover(String nodeName, GraphGWT o, JSONObject currentNodeData) { + //changing node color: + currentNodeData.put("color", new JSONString("yellow")); + } + +}); +//handle a click on a node +graph.addNodeClickHandler(new NodeClickHandler() { +//when click is pressed + @Override + public void onClick(String nodeName, GraphGWT o, JSONObject currentNodeData) { + currentNodeData.put("color", new JSONString("red")); + } +//when click is released + @Override + public void onClickRelease(String nodeName, GraphGWT o, JSONObject currentNodeData) { + currentNodeData.put("color", new JSONString("blue")); + } +}); +``` +Event are currently handled only on a node. Hre is the different event we can handle : +- NodeMouseHoverHandler (when the mouse enter over a node area + * onMouseHover +- NodeMouseOutHandler (when the mouse leave a node area) + * onMouseOut +- NodeClickHandler + * onClick + * onClickRelease +- NodeRightClickHandler + * onRightClick + * onRightClickRelease +- NodeMiddleClickHandler + * onMiddleClickRelease + * onMiddleClickRelease + + + #### Using graphGWT in a GWT project Create a folder named "public" next to the gwt.xml file. Add the file [arbor.js](https://raw.github.com/Temis/Graph/master/GraphGwt/src/main/java/com/temis/shared/arbor.js) in the gwt.xml file, add these lines :