diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2010-06-16 17:55:39 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2010-06-19 11:20:11 +0200 |
commit | 80a1ea6e6e524f2f49f0fc2d0884b08261bae73b (patch) | |
tree | afb8efcd8225a047c7ad803be60d1bab8f68ae38 /web-gui/plot/source/class | |
parent | 21c3f2360967138d9dfc13a3985fb92ca1c44027 (diff) | |
download | json-dbus-bridge-examples-80a1ea6e6e524f2f49f0fc2d0884b08261bae73b.tar.gz json-dbus-bridge-examples-80a1ea6e6e524f2f49f0fc2d0884b08261bae73b.tar.xz |
[plot] add plot web demo
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'web-gui/plot/source/class')
-rw-r--r-- | web-gui/plot/source/class/plot/Application.js | 138 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/test/DemoTest.js | 55 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/theme/Appearance.js | 18 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/theme/Color.js | 18 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/theme/Decoration.js | 18 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/theme/Font.js | 18 | ||||
-rw-r--r-- | web-gui/plot/source/class/plot/theme/Theme.js | 21 |
7 files changed, 286 insertions, 0 deletions
diff --git a/web-gui/plot/source/class/plot/Application.js b/web-gui/plot/source/class/plot/Application.js new file mode 100644 index 0000000..23dc842 --- /dev/null +++ b/web-gui/plot/source/class/plot/Application.js @@ -0,0 +1,138 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +/* ************************************************************************ + +#asset(plot/*) + +************************************************************************ */ + +/** + * This is the main application class of your custom application "plot" + */ +qx.Class.define("plot.Application", +{ +extend : qx.application.Standalone, + + + +/* +***************************************************************************** + MEMBERS +***************************************************************************** +*/ + +members : +{ + __rpc: null, + __call: null, + __plot: null, + __data: null, + __flot: null, + __loadLabel: null, + /** + * This method contains the initial application code and gets called + * during startup of the application + * + * @lint ignoreDeprecated(alert) + */ + main : function() + { + // Call super class + this.base(arguments); + + // Enable logging in debug variant + if (qx.core.Variant.isSet("qx.debug", "on")) + { + // support native logging capabilities, e.g. Firebug for Firefox + qx.log.appender.Native; + // support additional cross-browser console. Press F7 to toggle visibility + qx.log.appender.Console; + } + + /* + ------------------------------------------------------------------------- + Below is your actual application code... + ------------------------------------------------------------------------- + */ + + // Document is the application root + var doc = this.getRoot(); + doc.setBackgroundColor("#ffffff"); + + var back = new qx.ui.basic.Image("hello_world/back.png"); + back.setScale(true); + doc.add(back, {left:0, top: 0}); + + this.__rpc = new qx.io.remote.Rpc("http://localhost:8080/rpc", "com.pengutronix.jdb.systeminfo|/"); + + this.__data = []; + this.__plot = new qx.ui.core.Widget(); + this.__plot.addListener("appear", this.__showPlot, this); + doc.add(this.__plot, {left: 100, top: 100}); + this.__plot.setHeight(200); + this.__plot.setWidth(400); + + this.__loadLabel = new qx.ui.basic.Label("-"); + doc.add(this.__loadLabel, {left: 100, top: 80 }); + + var timer = new qx.event.Timer(500); + timer.addListener("interval", this.__tick, this); + timer.start(); + + }, + __showPlot: function() { + var e = this.__plot.getContainerElement().getDomElement(); + qx.bom.element.Attribute.set(e, 'id', 'infoPlot'); + + this.__flot = jQuery.plot(jQuery("#infoPlot"), + [], + { + xaxis: {ticks: 0, min: 0, max: 100}, + yaxis: {ticks: 10, min: 0, max: 100}, + grid: {borderWidth: 1} + }); + this.__updatePlot(); + }, + __updatePlot: function() { + this.__flot.setData( + [{ + data: this.__data + }]); + this.__flot.setupGrid(); + this.__flot.draw(); + }, + __tick: function() { + if (this.__call != null) { + this.__rpc.abort(this.__call); + } + this.__call = this.__rpc.callAsync( + qx.lang.Function.bind(this.__callback, this), + "com.pengutronix.jdb.SystemInfo.CpuLoad"); + }, + __callback: function(ret, err, id) { + this.__call = null; + if (err != null) { + return; + } + var data = []; + var start = this.__data.length - 99; + if (start < 0) + start = 0; + var i; + for (i = start; i < this.__data.length; ++i) + data.push([i-start, this.__data[i][1]]); + data.push([i-start, ret]) + this.__data = data; + this.__loadLabel.setValue(this.tr("CPU Load: %1%", ret)); + this.__updatePlot(); + } +} +}); diff --git a/web-gui/plot/source/class/plot/test/DemoTest.js b/web-gui/plot/source/class/plot/test/DemoTest.js new file mode 100644 index 0000000..e7b2e80 --- /dev/null +++ b/web-gui/plot/source/class/plot/test/DemoTest.js @@ -0,0 +1,55 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +/** + * This class demonstrates how to define unit tests for your application. + * + * Execute <code>generate.py test</code> to generate a testrunner application + * and open it from <tt>test/index.html</tt> + * + * The methods that contain the tests are instance methods with a + * <code>test</code> prefix. You can create an arbitrary number of test + * classes like this one. They can be organized in a regular class hierarchy, + * i.e. using deeper namespaces and a corresponding file structure within the + * <tt>test</tt> folder. + */ +qx.Class.define("plot.test.DemoTest", +{ + extend : qx.dev.unit.TestCase, + + members : + { + /* + --------------------------------------------------------------------------- + TESTS + --------------------------------------------------------------------------- + */ + + /** + * Here are some simple tests + */ + testSimple : function() + { + this.assertEquals(4, 3+1, "This should never fail!"); + this.assertFalse(false, "Can false be true?!"); + }, + + /** + * Here are some more advanced tests + */ + testAdvanced: function () + { + var a = 3; + var b = a; + this.assertIdentical(a, b, "A rose by any other name is still a rose"); + this.assertInRange(3, 1, 10, "You must be kidding, 3 can never be outside [1,10]!"); + } + } +}); diff --git a/web-gui/plot/source/class/plot/theme/Appearance.js b/web-gui/plot/source/class/plot/theme/Appearance.js new file mode 100644 index 0000000..e64bd3b --- /dev/null +++ b/web-gui/plot/source/class/plot/theme/Appearance.js @@ -0,0 +1,18 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +qx.Theme.define("plot.theme.Appearance", +{ + extend : qx.theme.modern.Appearance, + + appearances : + { + } +});
\ No newline at end of file diff --git a/web-gui/plot/source/class/plot/theme/Color.js b/web-gui/plot/source/class/plot/theme/Color.js new file mode 100644 index 0000000..58fa266 --- /dev/null +++ b/web-gui/plot/source/class/plot/theme/Color.js @@ -0,0 +1,18 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +qx.Theme.define("plot.theme.Color", +{ + extend : qx.theme.modern.Color, + + colors : + { + } +});
\ No newline at end of file diff --git a/web-gui/plot/source/class/plot/theme/Decoration.js b/web-gui/plot/source/class/plot/theme/Decoration.js new file mode 100644 index 0000000..553554a --- /dev/null +++ b/web-gui/plot/source/class/plot/theme/Decoration.js @@ -0,0 +1,18 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +qx.Theme.define("plot.theme.Decoration", +{ + extend : qx.theme.modern.Decoration, + + decorations : + { + } +});
\ No newline at end of file diff --git a/web-gui/plot/source/class/plot/theme/Font.js b/web-gui/plot/source/class/plot/theme/Font.js new file mode 100644 index 0000000..e990ed6 --- /dev/null +++ b/web-gui/plot/source/class/plot/theme/Font.js @@ -0,0 +1,18 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +qx.Theme.define("plot.theme.Font", +{ + extend : qx.theme.modern.Font, + + fonts : + { + } +});
\ No newline at end of file diff --git a/web-gui/plot/source/class/plot/theme/Theme.js b/web-gui/plot/source/class/plot/theme/Theme.js new file mode 100644 index 0000000..f6d370b --- /dev/null +++ b/web-gui/plot/source/class/plot/theme/Theme.js @@ -0,0 +1,21 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +qx.Theme.define("plot.theme.Theme", +{ + meta : + { + color : plot.theme.Color, + decoration : plot.theme.Decoration, + font : plot.theme.Font, + icon : qx.theme.icon.Tango, + appearance : plot.theme.Appearance + } +});
\ No newline at end of file |