allowed more robust jit capabilities by adding setProperty methods
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit.demo/src/org/eclipse/rap/rwt/visualization/jit/demo/Application.java b/bundles/org.eclipse.rap.rwt.visualization.jit.demo/src/org/eclipse/rap/rwt/visualization/jit/demo/Application.java
index bf3aaf1..f6079fd 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit.demo/src/org/eclipse/rap/rwt/visualization/jit/demo/Application.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit.demo/src/org/eclipse/rap/rwt/visualization/jit/demo/Application.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright © 2010-2011 Texas Center for Applied Technology
+ * Copyright � 2010-2011 Texas Center for Applied Technology
* Texas Engineering Experiment Station
* The Texas A&M University System
* All Rights Reserved.
@@ -238,6 +238,8 @@
viz = new SpaceTree(parent, SWT.BORDER);
String sampleData = loadSampleData("samples/spacetree.json");
viz.setJSONData(sampleData);
+ viz.setProperty("orientation", "top");
+ viz.setEdgeProperty("type", "bezier");
viz.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
viz.addListener(SWT.Selection, createSelectionListener());
}
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/HyperTree.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/HyperTree.java
index 6f8b814..6745ae5 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/HyperTree.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/HyperTree.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright © 2010-2011 Austin Riddle
+ * Copyright � 2010-2011 Austin Riddle
* All Rights Reserved.
*
* This program and the accompanying materials
@@ -23,8 +23,8 @@
public HyperTree( final Composite parent, final int style )
{
super( parent, style );
- nodeColor = new RGB(240,0,0);
- edgeColor = new RGB(8,143,255);
+ setNodeColor(new RGB(240,0,0));
+ setEdgeColor(new RGB(8,143,255));
}
public void previousState() {
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/JITGraphWidget.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/JITGraphWidget.java
index 7ebff25..e4a515b 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/JITGraphWidget.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/JITGraphWidget.java
@@ -19,6 +19,7 @@
*/
public void setNodeColor(RGB nodeColor) {
this.nodeColor = nodeColor;
+ setNodeProperty("color",convertRGBToCSSString(getNodeColor()));
}
/**
@@ -28,6 +29,7 @@
*/
public void setEdgeColor(RGB edgeColor) {
this.edgeColor = edgeColor;
+ setEdgeProperty("color",convertRGBToCSSString(getEdgeColor()));
}
/**
@@ -46,5 +48,45 @@
return edgeColor;
}
+ /**
+ * Sets a custom property of the graph implementation.
+ * @see <A href="http://thejit.org">JIT API documentation </A>
+ * @param propName - the name of the property
+ * @param propValue - the value of the property
+ */
+ public void setProperty (String propName, String propValue) {
+ addCommand("setProperty", new Object[] {propName, propValue});
+ }
+
+ /**
+ * Sets a custom property of the graph node implementation.
+ * @see <A href="http://thejit.org">JIT API documentation </A>
+ *
+ * @param propName - the name of the property
+ * @param propValue - the value of the property
+ */
+ public void setNodeProperty(String propName, String propValue)
+ {
+ addCommand("setNodeProperty", new Object[] {propName, propValue});
+ }
+ /**
+ * Sets a custom property of the graph edge implementation.
+ * @see <A href="http://thejit.org">JIT API documentation </A>
+ * @param propName - the name of the property
+ * @param propValue - the value of the property
+ */
+ public void setEdgeProperty(String propName, String propValue)
+ {
+ addCommand("setEdgeProperty", new Object[] {propName, propValue});
+ }
+
+ protected String convertRGBToCSSString(RGB color) {
+ if (color == null) return "";
+ StringBuffer sb = new StringBuffer("rgb(");
+ sb.append(color.red).append(",").
+ append(color.green).append(",").
+ append(color.blue).append(")").toString();
+ return sb.toString();
+ }
}
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/RGraph.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/RGraph.java
index b3b81ab..c5659df 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/RGraph.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/RGraph.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright © 2010-2011 Austin Riddle
+ * Copyright � 2010-2011 Austin Riddle
* All Rights Reserved.
*
* This program and the accompanying materials
@@ -22,8 +22,8 @@
public RGraph( final Composite parent, final int style )
{
super( parent, style );
- nodeColor = new RGB(204,221,238);
- edgeColor = new RGB(119,34,119);
+ setNodeColor(new RGB(204,221,238));
+ setEdgeColor(new RGB(119,34,119));
}
}
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/SpaceTree.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/SpaceTree.java
index 498760e..ac63e5a 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/SpaceTree.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/SpaceTree.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright © 2010-2011 Austin Riddle
+ * Copyright � 2010-2011 Austin Riddle
* All Rights Reserved.
*
* This program and the accompanying materials
@@ -22,8 +22,8 @@
public SpaceTree( final Composite parent, final int style )
{
super( parent, style );
- nodeColor = new RGB(255,221,136);
- edgeColor = new RGB(0,0,200);
+ setNodeColor(new RGB(255,221,136));
+ setEdgeColor(new RGB(0,0,200));
}
-
+
}
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/JITGraphLCA.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/JITGraphLCA.java
index 64f81d6..8394826 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/JITGraphLCA.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/JITGraphLCA.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright © 2010-2011 Austin Riddle
+ * Copyright � 2010-2011 Austin Riddle
* All Rights Reserved.
*
* This program and the accompanying materials
@@ -13,44 +13,7 @@
*****************************************************************************/
package org.eclipse.rap.rwt.visualization.jit.internal;
-import java.io.IOException;
-
-import org.eclipse.rap.rwt.visualization.jit.JITGraphWidget;
-import org.eclipse.rwt.lifecycle.IWidgetAdapter;
-import org.eclipse.rwt.lifecycle.JSWriter;
-import org.eclipse.rwt.lifecycle.WidgetUtil;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Widget;
public abstract class JITGraphLCA extends JITWidgetLCA {
-
- private static final String PROP_EDGE_COLOR = "edgeColor";
- private static final String PROP_NODE_COLOR = "nodeColor";
-
-
- public void preserveValues( final Widget widget ) {
- super.preserveValues(widget);
- JITGraphWidget vWidget = (JITGraphWidget)widget;
- IWidgetAdapter adapter = WidgetUtil.getAdapter( vWidget );
- adapter.preserve( PROP_NODE_COLOR, convertRGBToCSSString(vWidget.getNodeColor()));
- adapter.preserve( PROP_EDGE_COLOR, convertRGBToCSSString(vWidget.getEdgeColor()));
- }
-
- public void renderChanges( final Widget widget ) throws IOException {
- super.renderChanges(widget);
- JITGraphWidget vWidget = ( JITGraphWidget )widget;
- JSWriter writer = JSWriter.getWriterFor( vWidget );
- writer.set( PROP_NODE_COLOR, PROP_NODE_COLOR, convertRGBToCSSString(vWidget.getNodeColor()));
- writer.set( PROP_EDGE_COLOR, PROP_EDGE_COLOR, convertRGBToCSSString(vWidget.getEdgeColor()));
- }
-
- protected String convertRGBToCSSString(RGB color) {
- if (color == null) return "";
- StringBuffer sb = new StringBuffer("rgb(");
- sb.append(color.red).append(",").
- append(color.green).append(",").
- append(color.blue).append(")").toString();
- return sb.toString();
- }
-
+ //empty implementation now
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/hypertreekit/HyperTree.js b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/hypertreekit/HyperTree.js
index c33814d..49204a0 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/hypertreekit/HyperTree.js
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/hypertreekit/HyperTree.js
@@ -25,19 +25,11 @@
visible : {
init :"",
apply :"load"
- },
- widgetData : {
- init :"",
+ },
+ widgetData : {
+ init :"",
apply :"refreshData"
- },
- nodeColor : {
- init :"",
- apply :"applyNodeColor"
- },
- edgeColor : {
- init :"",
- apply :"applyEdgeColor"
- }
+ }
},
destruct : function() {
@@ -214,32 +206,44 @@
}
},
- applyNodeColor : function (color) {
- try {
- this.info("Setting node color: "+color);
- var ht = this._viz;
- if (ht != null) {
- ht.controller.Node.color = color;
- ht.refresh(true);
- }
- }
- catch (e) {
- this.info(e);
- }
- },
-
- applyEdgeColor : function (color) {
- try {
- this.info("Setting edge color: "+color);
- var ht = this._viz;
- if (ht != null) {
- ht.controller.Edge.color = color;
- }
- }
- catch (e) {
- this.info(e);
- }
- },
+ setProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setNodeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Node[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setEdgeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Edge[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
selectNode : function (id) {
try {
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/rgraphkit/RGraph.js b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/rgraphkit/RGraph.js
index ea86764..3dc9e04 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/rgraphkit/RGraph.js
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/rgraphkit/RGraph.js
@@ -28,19 +28,11 @@
visible : {
init :"",
apply :"load"
- },
- widgetData : {
- init :"",
+ },
+ widgetData : {
+ init :"",
apply :"refreshData"
- },
- nodeColor : {
- init :"",
- apply :"applyNodeColor"
- },
- edgeColor : {
- init :"",
- apply :"applyEdgeColor"
- }
+ }
},
destruct : function() {
@@ -248,31 +240,44 @@
}
},
- applyNodeColor : function (color) {
- try {
- var rg = this._viz;
- if (rg != null) {
- rg.controller.Node.color = color;
- rg.refresh();
- }
- }
- catch (e) {
- this.info(e);
- }
- },
-
- applyEdgeColor : function (color) {
- try {
- var rg = this._viz;
- if (rg != null) {
- rg.controller.Edge.color = color;
- rg.refresh();
- }
- }
- catch (e) {
- this.info(e);
- }
- },
+ setProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setNodeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Node[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setEdgeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Edge[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
selectNode : function (id) {
try {
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTree.js b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTree.js
index 1a85508..d82584d 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTree.js
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTree.js
@@ -28,19 +28,11 @@
visible : {
init :"",
apply :"load"
- },
- widgetData : {
- init :"",
- apply :"refreshData"
- },
- nodeColor : {
- init :"",
- apply :"applyNodeColor"
- },
- edgeColor : {
- init :"",
- apply :"applyEdgeColor"
- }
+ },
+ widgetData : {
+ init :"",
+ apply :"refreshData"
+ }
},
destruct : function() {
@@ -94,7 +86,7 @@
vizParent.width = this.getWidth();
vizParent.height = this.getHeight();
var st = new ST(canvas, {
- orientation: "left",
+ orientation: "left",
levelsToShow: 2,
subtreeOffset: 8,
siblingOffset: 5,
@@ -104,7 +96,7 @@
multitree: false,
indent: 10,
//set distance between node and its children
- levelDistance: 50,
+ levelDistance: 50,
Node: {
overridable: true,
type: 'rectangle',
@@ -256,31 +248,44 @@
}
},
- applyNodeColor : function (color) {
- try {
- var st = this._viz;
- if (st != null) {
- st.controller.Node.color = color;
- st.refresh();
- }
- }
- catch (e) {
- this.info(e);
- }
- },
-
- applyEdgeColor : function (color) {
- try {
- var st = this._viz;
- if (st != null) {
- st.controller.Edge.color = color;
- st.refresh();
- }
- }
- catch (e) {
- this.info(e);
- }
- },
+ setProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setNodeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Node[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
+
+ setEdgeProperty : function (propName, propValue) {
+ try {
+ var st = this._viz;
+ if (st != null) {
+ st.controller.Edge[propName] = propValue;
+ st.refresh();
+ }
+ }
+ catch (e) {
+ this.info(e);
+ }
+ },
selectNode : function (id) {
try {
diff --git a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTreeLCA.java b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTreeLCA.java
index 4bbe94e..ef4cc06 100644
--- a/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTreeLCA.java
+++ b/bundles/org.eclipse.rap.rwt.visualization.jit/src/org/eclipse/rap/rwt/visualization/jit/internal/spacetreekit/SpaceTreeLCA.java
@@ -12,8 +12,13 @@
******************************************************************************/
package org.eclipse.rap.rwt.visualization.jit.internal.spacetreekit;
+import java.io.IOException;
+
+import org.eclipse.rap.rwt.visualization.jit.JITGraphWidget;
import org.eclipse.rap.rwt.visualization.jit.SpaceTree;
import org.eclipse.rap.rwt.visualization.jit.internal.JITGraphLCA;
+import org.eclipse.rwt.lifecycle.JSWriter;
+import org.eclipse.swt.widgets.Widget;
public class SpaceTreeLCA extends JITGraphLCA {