summaryrefslogtreecommitdiffstats
path: root/qooxdoo/source/class/Smokeping
diff options
context:
space:
mode:
Diffstat (limited to 'qooxdoo/source/class/Smokeping')
-rw-r--r--qooxdoo/source/class/Smokeping/Application.js92
-rw-r--r--qooxdoo/source/class/Smokeping/GraphShadow.js94
-rw-r--r--qooxdoo/source/class/Smokeping/Server.js76
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Graph.js107
-rw-r--r--qooxdoo/source/class/Smokeping/ui/GraphList.js56
-rw-r--r--qooxdoo/source/class/Smokeping/ui/LoadingAnimation.js52
-rw-r--r--qooxdoo/source/class/Smokeping/ui/MPosition.js53
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Mover.js112
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Navigator.js110
-rw-r--r--qooxdoo/source/class/Smokeping/ui/TargetTree.js85
-rw-r--r--qooxdoo/source/class/Smokeping/ui/Zoomer.js194
11 files changed, 0 insertions, 1031 deletions
diff --git a/qooxdoo/source/class/Smokeping/Application.js b/qooxdoo/source/class/Smokeping/Application.js
deleted file mode 100644
index 917b608..0000000
--- a/qooxdoo/source/class/Smokeping/Application.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ************************************************************************
-
-#module(Smokeping)
-#resource(Smokeping.image:image)
-#embed(Smokeping.image/*)
-
-************************************************************************ */
-
-qx.Class.define('Smokeping.Application',
-{
- extend: qx.application.Gui,
-
- members:
- {
- main: function()
- {
- var self=this;
- this.base(arguments);
-
- qx.io.Alias.getInstance().add(
- 'SP', qx.core.Setting.get('Smokeping.resourceUri')
- );
-
- // if we run with a file:// url make sure
- // the app finds the smokeping service (smokeping.cgi)
- Smokeping.Server.getInstance().setLocalUrl(
- 'http://localhost/~oetiker/smq/'
- );
-
- var base_layout = new qx.ui.layout.VerticalBoxLayout();
- with(base_layout){
- setPadding(8);
- setLocation(0,0);
- setWidth('100%');
- setHeight('100%');
- setSpacing(10);
- };
- base_layout.addToDocument();
- var title = new qx.ui.basic.Atom(this.tr('Smokeping Viewer'));
- with(title){
- setTextColor('#b0b0b0');
- setFont(qx.ui.core.Font.fromString('16px bold sans-serif'));
- }
- base_layout.add(title);
-
- var splitpane = new qx.ui.splitpane.HorizontalSplitPane(200, '1*');
- splitpane.setEdge(0);
- splitpane.setHeight('1*');
- splitpane.setShowKnob(true);
- base_layout.add(splitpane);
-
- var tree = new Smokeping.ui.TargetTree();
- splitpane.addLeft(tree);
-
- var graphlist = new Smokeping.ui.GraphList();
- splitpane.addRight(graphlist);
-
-
- },
-
- close : function(e)
- {
- this.base(arguments);
- // return "Smokeping Web UI: "
- // + "Do you really want to close the application?";
- },
-
-
- terminate : function(e) {
- this.base(arguments);
- }
-
- /********************************************************************
- * Functional Block Methods
- ********************************************************************/
-
- },
-
-
-
-
- /*
- *****************************************************************************
- SETTINGS
- *****************************************************************************
- */
-
- settings : {
- 'Smokeping.resourceUri' : './resource'
- }
-});
-
diff --git a/qooxdoo/source/class/Smokeping/GraphShadow.js b/qooxdoo/source/class/Smokeping/GraphShadow.js
deleted file mode 100644
index 6460f48..0000000
--- a/qooxdoo/source/class/Smokeping/GraphShadow.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * The data representation of a Smokeping Graph
- */
-
-qx.Class.define('Smokeping.GraphShadow',
-{
- extend: qx.core.Object,
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
- construct : function() {
- this.base(arguments);
- },
-
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
- properties: {
- /** Width of the graph canvas in pixels */
- width :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
- /** height of the graph canvas in pixels */
- height :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
- /** start of the graph in seconds since 1970 */
- start :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
- /** end of the graph in seconds since 1970 */
- end :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
- /** upper border of the graph */
- top :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
- /** bottom border of the graph */
- bottom :
- {
- check : "Number",
- nullable : true,
- themeable : false
- },
-
- /** url to the cgi which produces the graphs */
- cgi :
- {
- check : "String",
- nullable : true,
- themeable : false
- },
-
- /** which data source should we use for the graph */
- data :
- {
- check : "String",
- nullable : true,
- themeable : false
- }
- },
- members: {
- getSrc: function(){
- with(this){
- return getCgi()+'?g='+getData()+';w='+getWidth()+';h='+getHeight()+';s='+getStart()+';e='+getEnd()+';t='+getTop()+';b='+getBottom();
- }
- }
- }
-});
-
diff --git a/qooxdoo/source/class/Smokeping/Server.js b/qooxdoo/source/class/Smokeping/Server.js
deleted file mode 100644
index ebc938d..0000000
--- a/qooxdoo/source/class/Smokeping/Server.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * A smokeping specific rpc call which works
- */
-
-qx.Class.define('Smokeping.Server',
-{
- extend: qx.io.remote.Rpc,
- type: "singleton",
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param local_url {String} When running the application in file:// mode.
- * where will we find our RPC server.
- */
- construct: function (local_url) {
-
- with(this){
- base(arguments);
- setTimeout(7000000);
- setUrl('smokeping.cgi');
- setServiceName('Smokeping');
- }
-
- return this;
- },
-
- /*
- *****************************************************************************
- MEMBERS
- *****************************************************************************
- */
-
- members :
- {
-
- /*
- ---------------------------------------------------------------------------
- CORE METHODS
- ---------------------------------------------------------------------------
- */
-
- /**
- * Tell about the BaseUrl we found.
- *
- * @type member
- *
- * @param {void}
- *
- * @return BaseUrl {Strings}
- */
-
- getBaseUrl: function(){
- return this.__base_url;
- },
-
- setLocalUrl: function(local_url){
- if ( document.location.host === '' ) {
- with(this){
- setUrl(local_url+'smokeping.cgi');
- setCrossDomain(true);
- }
- }
- }
-
- }
-});
-
diff --git a/qooxdoo/source/class/Smokeping/ui/Graph.js b/qooxdoo/source/class/Smokeping/ui/Graph.js
deleted file mode 100644
index 506f158..0000000
--- a/qooxdoo/source/class/Smokeping/ui/Graph.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * a widget showing the smokeping graph overview
- */
-
-var Smokeping_ui_Graph_default_width = null;
-var Smokeping_ui_Graph_default_height = null;
-
-qx.Class.define('Smokeping.ui.Graph',
-{
- extend: qx.ui.layout.BoxLayout,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param object {file} What happens when the SNCF conductors tamazing.
- *
- */
-
- construct: function (graph) {
- this.base(arguments);
- this._graph=graph;
- if ( Smokeping_ui_Graph_default_width){
- this.setWidth( Smokeping_ui_Graph_default_width)
- this.setHeight( Smokeping_ui_Graph_default_height);
- }
- else {
- this.setWidth('auto');
- this.setHeight('auto');
- };
- this.set({
- border : new qx.ui.core.Border(1,'dotted','#ffffff'),
- horizontalChildrenAlign: 'center',
- verticalChildrenAlign: 'middle'
- });
- this._highlight();
- var loader = new Smokeping.ui.LoadingAnimation();
- this.add(loader);
- this._preloader = qx.io.image.PreloaderManager.getInstance().create(Smokeping.Server.getInstance().getUrl()
- + '?g='+graph+';s=now-1d;e=now;t=100000;b=0;w=200;h=100');
- if (this._preloader.isLoaded()){
- qx.client.Timer.once(this._image_loader,this,0);
- } else {
- this._preloader.addEventListener('load', this._image_loader, this);
- }
- this.addEventListener('mouseover',this._highlight,this);
- this.addEventListener('mouseout',this._unhighlight,this);
- },
-
- members: {
- _image_loader: function(e) {
- Smokeping_ui_Graph_default_width = this._preloader.getWidth();
- Smokeping_ui_Graph_default_height = this._preloader.getHeight();
- var image = new qx.ui.basic.Image();
- image.setPreloader(this._preloader);
- qx.io.image.PreloaderManager.getInstance().remove(this._preloader);
- with(this){
- removeAll();
- add(image);
- addEventListener('click',this._open_navigator,this);
- _unhighlight();
- }
- },
- _open_navigator: function(e){
- with(this){
- setEnabled(false);
- _unhighlight();
- this._window = new Smokeping.ui.Navigator(this._graph);
- _window.addToDocument();
- _window.positionRelativeTo(getElement(),2,-4);
- addEventListener('beforeDisappear',_kill_window,this);
- _window.open();
- _window.addEventListener('beforeDisappear',_close_window,this);
- }
- },
- _close_window: function(e){
- this.setEnabled(true);
- },
- _kill_window: function(e){
- this._window.close();
- this._window.dispose();
- },
- _highlight: function(e){
- this.setBackgroundColor('#f8f8f8');
- this.getBorder().set({
- color: '#808080'
- });
- },
- _unhighlight: function(e){
- this.setBackgroundColor('transparent');
- this.getBorder().set({
- color: '#ffffff'
- });
- }
- }
-
-
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/GraphList.js b/qooxdoo/source/class/Smokeping/ui/GraphList.js
deleted file mode 100644
index c49b601..0000000
--- a/qooxdoo/source/class/Smokeping/ui/GraphList.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * a widget showing the smokeping graph overview
- */
-
-qx.Class.define('Smokeping.ui.GraphList',
-{
- extend: qx.ui.layout.FlowLayout,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param base_url {String} Path to the location of the image generator
- *
- */
-
- construct: function () {
-
- with(this){
- base(arguments);
- set({
- overflow: 'auto',
- backgroundColor: 'white',
- border: new qx.ui.core.Border(1,'solid','#a0a0a0'),
- width: '100%',
- height: '100%',
- verticalSpacing: 10,
- horizontalSpacing: 10,
- padding: 10
- })
- };
- qx.event.message.Bus.subscribe('sp.menu.folder',this._load_graphs,this);
- },
-
- members: {
- _load_graphs: function(m){
- var files = m.getData()
- this.removeAll();
- for(var i=0;i<files.length;i++){
- var image = new Smokeping.ui.Graph(files[i]);
- this.add(image);
- }
- }
- }
-
-
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/LoadingAnimation.js b/qooxdoo/source/class/Smokeping/ui/LoadingAnimation.js
deleted file mode 100644
index c06ccc4..0000000
--- a/qooxdoo/source/class/Smokeping/ui/LoadingAnimation.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * The widget showing a detail graph
- */
-
-qx.Class.define('Smokeping.ui.LoadingAnimation',
-{
- extend: qx.ui.layout.CanvasLayout,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param graph_url {String} Url to the explorable graph
- *
- */
-
- construct: function () {
- this.base(arguments);
- this.set({
- width: '100%',
- height: '100%'
- });
- var plane = new qx.ui.basic.Terminator();
- plane.set({
- width: '100%',
- height: '100%',
- backgroundColor: '#f0f0f0',
- opacity: 1
- });
- this.add(plane);
-
- var centerbox = new qx.ui.layout.BoxLayout();
- centerbox.set({
- width: '100%',
- height: '100%',
- horizontalChildrenAlign: 'center',
- verticalChildrenAlign: 'middle'
- });
- var animation = new qx.ui.basic.Image(qx.io.Alias.getInstance().resolve('SP/image/ajax-loader.gif'));
- centerbox.add(animation);
- this.add(centerbox);
- }
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/MPosition.js b/qooxdoo/source/class/Smokeping/ui/MPosition.js
deleted file mode 100644
index 74b709d..0000000
--- a/qooxdoo/source/class/Smokeping/ui/MPosition.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * some mouse handling routines for thegraph mover and zoomer.
- */
-
-qx.Mixin.define('Smokeping.ui.MPosition',
-{
-
- members: {
- _init_cache: function(){
- var el = this._target.getElement();
- this._page_left = qx.html.Location.getPageAreaLeft(el);
- this._page_top = qx.html.Location.getPageAreaTop(el);
- this._image_width = qx.html.Location.getPageAreaRight(el) - this._page_left;
- this._image_height = qx.html.Location.getPageAreaBottom(el) - this._page_top ;
- this._canvas_top = this._top;
- this._canvas_left = this._image_width-this._width-this._right;
- this._canvas_right = this._right;
- this._canvas_bottom = this._image_height-this._height-this._top;
- },
-
- _get_mouse_y: function(e){
- var mouse_y = e.getPageY()-this._page_top;
-
- if (mouse_y < this._canvas_top) {
- mouse_y = this._canvas_top;
- }
- if (mouse_y > this._canvas_top + this._height) {
- mouse_y = this._canvas_top + this._height;
- }
- return mouse_y;
- },
-
- _get_mouse_x: function(e){
- var mouse_x = e.getPageX()-this._page_left;
-
- if (mouse_x < this._canvas_left) {
- mouse_x = this._canvas_left;
- }
- if (mouse_x > this._canvas_left + this._width) {
- mouse_x = this._canvas_left + this._width;
- }
- return mouse_x;
- }
- }
-
-
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/Mover.js b/qooxdoo/source/class/Smokeping/ui/Mover.js
deleted file mode 100644
index 2d1d5f0..0000000
--- a/qooxdoo/source/class/Smokeping/ui/Mover.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * Lets you do google map like draging of the graph canvas along time axis
- *
- */
-
-qx.Class.define('Smokeping.ui.Mover',
-{
- extend: qx.ui.layout.CanvasLayout,
- include: Smokeping.ui.MPosition,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param target {Widget} What surface should we base our selection on
- *
- * @param width {Integer} Width of the 'interesting' area of the target
- *
- * @param height {Integer} Height ot the 'interesting' area of the target
- *
- * @param right {Integer} Distance from the right edge
- *
- * @param top {Integer} Distance from the top
- *
- * The zoomer will not activate if the ctrl key is pressed. This allows
- * for the Mover to act on these events
- *
- */
-
- construct: function (target,src,width,height,top,right,start,end) {
- this._target = target;
- this._src = src;
- this._width = width;
- this._height = height;
- this._top = top;
- this._right = right;
- this._start = start;
- this._end = end;
- with(this){
- base(arguments);
- set({
- width: width,
- height: height+17,
- top: top-2,
- right: right,
- visibility: false,
- overflow: 'hidden',
- backgroundColor: 'white'
- });
- }
- // make the canvas large
-
- this._moveing = false;
- this._target.addEventListener("mousedown", this._move_start,this);
- this._target.addEventListener("mousemove", this._move_move,this);
- this._target.addEventListener("mouseup", this._move_end,this);
- },
-
- members: {
- _move_start: function(e){
- if (!e.isCtrlPressed()) return;
- this._init_cache();
- this._moveing = true;
- this._start_x = e.getPageX();
- this._target.setCapture(true);
- this.removeAll();
- for (var i=0;i<4;i++){
- var duration = (this._end-this._start);
- var tile = new qx.ui.basic.Image();
- tile.set({
- top: -(this._top-2),
- left: -this._canvas_left,
- clipTop: this._top-2,
- clipLeft: this._canvas_left,
- clipWidth: this._width,
- width: this._width,
- height: this._height+17,
- left: this._width * i,
- source: this._src+';w='+this._width+';h='+this._height+';s='+(this._start+(duration*(i-2)))+';e='+(this._end+(duration*(i-2)))
- });
- this.add(tile);
- }
- this.setScrollLeft(2*this._width);
- this.setVisibility(true);
- this._move_move(e);
- },
-
- _move_move: function(e){
- if (this._target.getCapture() && this._moveing ){
- var drag_x = e.getPageX() - this._start_x;
- this.setScrollLeft(-drag_x+this._width*2);
- }
- },
- _move_end: function(e){
- if (!this._moveing) return;
- this._moveing = false;
- this._target.setCapture(false);
- this.setVisibility(false);
- }
- }
-
-
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/Navigator.js b/qooxdoo/source/class/Smokeping/ui/Navigator.js
deleted file mode 100644
index eb799e7..0000000
--- a/qooxdoo/source/class/Smokeping/ui/Navigator.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * The widget showing a detail graph
- */
-
-qx.Class.define('Smokeping.ui.Navigator',
-{
- extend: qx.ui.window.Window,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param graph_url {String} Url to the explorable graph
- *
- */
-
- construct: function (graph) {
- this._graph = graph;
- with(this){
- base(arguments,tr("Smokeping Graph Navigator"));
- set({
- showMaximize: false,
- showMinimize: false,
- width: 300,
- height: 200,
- minWidth: 300,
- minHeight: 200,
- backgroundColor: '#f0f0f0'
- });
- }
- this._graph_width = 300;
- this._graph_height = 200;
- this._lastrun = 0;
- this._loader = new Smokeping.ui.LoadingAnimation();
- this._url = Smokeping.Server.getInstance().getUrl();
- this._update_image();
- },
-
- members: {
- // resizable objects have a changeWidth method
- // which we can override to take part in the fun
- // why I have to access this._graph_width without the this.
- // in this case
- _changeWidth: function(newWidth) {
- var diff = newWidth - this.getBoxWidth();
- this.base(arguments, newWidth);
- this.add(this._loader);
- this._graph_width = this._graph_width + diff;
- qx.client.Timer.once(this._update_image,this,250);
- },
-
- _changeHeight: function(newHeight) {
- var diff = newHeight - this.getBoxHeight();
- this.base(arguments, newHeight);
- this.add(this._loader);
- this._graph_height = this._graph_height + diff;
- qx.client.Timer.once(this._update_image,this,250);
-
- },
-
- _get_url: function(){
- return this._url+ '?g='+this._graph+';s=now-1d;e=now;t=100000;b=0;w='+this._graph_width+';h='+this._graph_height;
- },
-
- _update_image: function(){
- var now = (new Date()).getTime();
- if (this._lastrun + 1000 < now) {
- this._preloader = qx.io.image.PreloaderManager.getInstance().create(this._get_url())
- if (this._preloader.isLoaded()){
- qx.client.Timer.once(this._show_image,this,0);
- } else {
- this._preloader.addEventListener('load', this._show_image, this);
- }
- this._lastrun = now;
- }
- else {
- this.debug('Skipping update since previous update less tahn 1 second')
- }
- },
-
- _show_image: function(e){
- with(this){
- set({
- width: 'auto',
- height: 'auto'
- });
- var image = new qx.ui.basic.Image();
- image.setPreloader(this._preloader);
- qx.io.image.PreloaderManager.getInstance().remove(this._preloader);
- removeAll();
- add(image);
- var zoomer = new Smokeping.ui.Zoomer(image,this._graph_width,this._graph_height,33,30);
- add(zoomer);
- var mover = new Smokeping.ui.Mover(image,this._url+ '?g='+this._graph,this._graph_width,this._graph_height,33,30,1201680005,1201686005);
- add(mover);
- }
- }
- }
-
-
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/TargetTree.js b/qooxdoo/source/class/Smokeping/ui/TargetTree.js
deleted file mode 100644
index 0e97a08..0000000
--- a/qooxdoo/source/class/Smokeping/ui/TargetTree.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * a widget showing the smokeping target tree
- */
-
-qx.Class.define('Smokeping.ui.TargetTree',
-{
- extend: qx.ui.tree.Tree,
-
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
-
- construct: function () {
- with(this){
- base(arguments,'root node');
- set({
- backgroundColor: 'white',
- border: new qx.ui.core.Border(1,'solid','#a0a0a0'),
- overflow: 'auto',
- width: '100%',
- height: '100%',
- padding: 5,
- hideNode: true
- });
- getManager().addEventListener('changeSelection', this._send_event,this)
- };
- var self = this;
- var fill_tree = function(data,exc,id){
- if (exc == null){
- var nodes = data.length;
- for(var i=0;i<nodes;i++){
- self._fill_folder(self,data[i]);
- }
- }
- else {
- alert(exc);
- }
- };
- Smokeping.Server.getInstance().callAsync(fill_tree,'get_tree');
- },
-
- /*
- *****************************************************************************
- Statics
- *****************************************************************************
- */
- members: {
-
- _fill_folder: function(node,data){
- // in data[0] we have the id of the folder
- var folder = new qx.ui.tree.TreeFolder(data[1]);
- node.add(folder);
- var files = new Array();
- var length = data.length;
- for (var i=2;i<length;i++){
- if(qx.util.Validation.isValidArray(data[i])){
- this._fill_folder(folder,data[i]);
- } else {
- i++; // skip the node id for now
- var file = new qx.ui.tree.TreeFile(data[i]);
- files.push(data[i-1]);
- folder.add(file);
- }
- }
- folder.setUserData('ids',files);
- },
-
- _send_event: function(e) {
- if (e.getData().length > 0) {
- if ( e.getData()[0].basename == 'TreeFolder' ){
- qx.event.message.Bus.dispatch('sp.menu.folder',e.getData()[0].getUserData('ids'));
- }
- }
- }
- }
-});
-
-
diff --git a/qooxdoo/source/class/Smokeping/ui/Zoomer.js b/qooxdoo/source/class/Smokeping/ui/Zoomer.js
deleted file mode 100644
index 8d20d88..0000000
--- a/qooxdoo/source/class/Smokeping/ui/Zoomer.js
+++ /dev/null
@@ -1,194 +0,0 @@
-/* ************************************************************************
-#module(Smokeping)
-************************************************************************ */
-
-/**
- * Lets you selcet an Area. Depending on the angel of your selection you get
- * a time, a range or both.
- *
- */
-
-qx.Class.define('Smokeping.ui.Zoomer',
-{
- extend: qx.ui.layout.CanvasLayout,
-
- include: Smokeping.ui.MPosition,
- /*
- *****************************************************************************
- CONSTRUCTOR
- *****************************************************************************
- */
-
- /**
- * @param target {Widget} What surface should we base our selection on
- *
- * @param width {Integer} Width of the 'interesting' area of the target
- *
- * @param height {Integer} Height ot the 'interesting' area of the target
- *
- * @param right {Integer} Distance from the right edge
- *
- * @param top {Integer} Distance from the top
- *
- * The zoomer will not activate if the ctrl key is pressed. This allows
- * for the Mover to act on these events
- *
- */
-
- construct: function (target,width,height,top,right) {
- this._target = target;
- this._width = width;
- this._height = height+1; // some where the calc is 1 off. this fixes it
- this._top = top;
- this._right = right;
- with(this){
- base(arguments);
- set({
- width: '100%',
- height: '100%',
- visibility: false
- });
- }
- var zoomer_defaults = {
- backgroundColor: 'black',
- opacity: 0.1,
- overflow: 'hidden' // important to make box go to 'zero height' on ie6
- };
- var dir = ['left','right','top','bottom' ];
- var z = [];
- this._zoomer = z;
- for(var i=0;i<dir.length;i++){
- z[dir[i]] = new qx.ui.basic.Terminator();
- z[dir[i]].set(zoomer_defaults);
- this.add(z[dir[i]]);
- }
-
- z['frame'] = new qx.ui.basic.Terminator();
- z['frame'].set(zoomer_defaults);
- z['frame'].set({
- opacity: 1,
- backgroundColor: 'transparent',
- border: new qx.ui.core.Border(1,'dotted','#808080')
- });
-
- this.add(z['frame']);
- this._zooming = false; // we are not curently in zoom mode
- this._target.addEventListener("mousedown", this._zoom_start,this);
- this._target.addEventListener("mousemove", this._zoom_move,this);
- this._target.addEventListener("mouseup", this._zoom_end,this);
- },
-
- members: {
- _zoom_start: function(e){
- if (e.isCtrlPressed()) return;
- this._zooming = true;
- var z = this._zoomer;
- this._init_cache();
-
- this._selector_start_x = this._get_mouse_x(e);
- this._selector_start_y = this._get_mouse_y(e);
-
- this._target.setCapture(true);
- this._zoom_move(e);
- this.setVisibility(true);
- },
-
- _zoom_move: function(e){
- var z = this._zoomer;
- if (this._target.getCapture() && this._zooming ){
-
- var mouse_x = this._get_mouse_x(e);
-
- var mouse_left_x;
- var mouse_right_x;
- if (mouse_x > this._selector_start_x){
- mouse_left_x = this._selector_start_x;
- mouse_right_x = mouse_x;
- }
- else {
- mouse_right_x = this._selector_start_x;
- mouse_left_x = mouse_x;
- }
-
- var mouse_y = this._get_mouse_y(e);
- var mouse_top_y;
- var mouse_bottom_y;
- if (mouse_y > this._selector_start_y){
- mouse_top_y = this._selector_start_y;
- mouse_bottom_y = mouse_y;
- }
- else {
- mouse_bottom_y = this._selector_start_y;
- mouse_top_y = mouse_y;
- }
-
- var time_sel = 1;
- var range_sel = 1;
- var pi = 3.14159265;
- var angle = Math.atan ((mouse_right_x - mouse_left_x) / (mouse_bottom_y - mouse_top_y));
- if ( angle > Math.PI/2 * 0.85){
- range_sel = 0;
- }
- if ( angle < Math.PI/2 * 0.15){
- time_sel = 0;
- }
-
- z['top'].set({
- left: time_sel ? mouse_left_x : this._canvas_left,
- width: time_sel ? mouse_right_x - mouse_left_x : this._width,
- top: 0,
- height: range_sel ? mouse_top_y : this._canvas_top
- });
-
- z['bottom'].set({
- left: time_sel ? mouse_left_x : this._canvas_left,
- width: time_sel ? mouse_right_x - mouse_left_x : this._width,
- top: range_sel ? mouse_bottom_y : this._canvas_top + this._height,
- height: range_sel ? this._image_height - mouse_bottom_y : this._canvas_bottom
- });
-
- z['left'].set({
- width: time_sel ? mouse_left_x: this._canvas_left,
- height: this._image_height
- });
-
- z['right'].set({
- left: time_sel ? mouse_right_x : this._image_width - this._canvas_right,
- width: time_sel ? this._image_width - mouse_right_x : this._canvas_right,
- height: this._image_height
- });
- z['frame'].set({
- left: time_sel ? mouse_left_x : this._canvas_left,
- width: time_sel ? mouse_right_x - mouse_left_x : this._width,
- top: range_sel ? mouse_top_y : this._canvas_top,
- height: range_sel ? mouse_bottom_y - mouse_top_y : this._height
- });
- }
- },
- _zoom_end: function(e){
- if (!this._zooming) return;
- var z = this._zoomer;
- this._target.setCapture(false);
- this.setVisibility(false);
- this._zooming = false;
-
- if (z['bottom'].getTop() == z['top'].getTop()+z['top'].getHeight()){
- this._zoom_factor_top = 0;
- this._zoom_factor_bottom = 0;
- }
- else {
- var prev_factor = 1 - this._zoom_factor_top - this._zoom_factor_bottom;
- this._zoom_factor_top =
- (z['top'].getHeight()-this._canvas_top)/this._height * prev_factor
- + this._zoom_factor_top;
- this.zoom_factor_bottom =
- (z['bottom'].getHeight()-this._canvas_bottom)/this._height * prev_factor
- + this._zoom_factor_bottom;
- }
- }
- }
-
-
-});
-
-