summaryrefslogtreecommitdiffstats
path: root/web-gui/plot/source/class
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2010-06-16 17:55:39 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2010-06-19 11:20:11 +0200
commit80a1ea6e6e524f2f49f0fc2d0884b08261bae73b (patch)
treeafb8efcd8225a047c7ad803be60d1bab8f68ae38 /web-gui/plot/source/class
parent21c3f2360967138d9dfc13a3985fb92ca1c44027 (diff)
downloadjson-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.js138
-rw-r--r--web-gui/plot/source/class/plot/test/DemoTest.js55
-rw-r--r--web-gui/plot/source/class/plot/theme/Appearance.js18
-rw-r--r--web-gui/plot/source/class/plot/theme/Color.js18
-rw-r--r--web-gui/plot/source/class/plot/theme/Decoration.js18
-rw-r--r--web-gui/plot/source/class/plot/theme/Font.js18
-rw-r--r--web-gui/plot/source/class/plot/theme/Theme.js21
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