From 80a1ea6e6e524f2f49f0fc2d0884b08261bae73b Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 16 Jun 2010 17:55:39 +0200 Subject: [plot] add plot web demo Signed-off-by: Michael Olbrich --- web-gui/plot/source/class/plot/Application.js | 138 +++++++++++++++++++++ web-gui/plot/source/class/plot/test/DemoTest.js | 55 ++++++++ web-gui/plot/source/class/plot/theme/Appearance.js | 18 +++ web-gui/plot/source/class/plot/theme/Color.js | 18 +++ web-gui/plot/source/class/plot/theme/Decoration.js | 18 +++ web-gui/plot/source/class/plot/theme/Font.js | 18 +++ web-gui/plot/source/class/plot/theme/Theme.js | 21 ++++ web-gui/plot/source/index.html | 12 ++ web-gui/plot/source/resource/plot/back.png | Bin 0 -> 98107 bytes web-gui/plot/source/translation/readme.txt | 3 + 10 files changed, 301 insertions(+) create mode 100644 web-gui/plot/source/class/plot/Application.js create mode 100644 web-gui/plot/source/class/plot/test/DemoTest.js create mode 100644 web-gui/plot/source/class/plot/theme/Appearance.js create mode 100644 web-gui/plot/source/class/plot/theme/Color.js create mode 100644 web-gui/plot/source/class/plot/theme/Decoration.js create mode 100644 web-gui/plot/source/class/plot/theme/Font.js create mode 100644 web-gui/plot/source/class/plot/theme/Theme.js create mode 100644 web-gui/plot/source/index.html create mode 100644 web-gui/plot/source/resource/plot/back.png create mode 100644 web-gui/plot/source/translation/readme.txt (limited to 'web-gui/plot/source') 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 generate.py test to generate a testrunner application + * and open it from test/index.html + * + * The methods that contain the tests are instance methods with a + * test 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 + * test 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 diff --git a/web-gui/plot/source/index.html b/web-gui/plot/source/index.html new file mode 100644 index 0000000..78b9e21 --- /dev/null +++ b/web-gui/plot/source/index.html @@ -0,0 +1,12 @@ + + + + + plot + + + + + + + diff --git a/web-gui/plot/source/resource/plot/back.png b/web-gui/plot/source/resource/plot/back.png new file mode 100644 index 0000000..fd06541 Binary files /dev/null and b/web-gui/plot/source/resource/plot/back.png differ diff --git a/web-gui/plot/source/translation/readme.txt b/web-gui/plot/source/translation/readme.txt new file mode 100644 index 0000000..66975e6 --- /dev/null +++ b/web-gui/plot/source/translation/readme.txt @@ -0,0 +1,3 @@ +This directory will contain translation (.po) files once you run the +'translation' job in your project. + -- cgit v1.2.3