Mercurial > hg > NetworkVis
comparison d3s_examples/python-neo4jrestclient/static/platin/js/Util/WidgetWrapper.js @ 8:18ef6948d689
new d3s examples
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 01 Oct 2015 17:17:27 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:45dad9e38c82 | 8:18ef6948d689 |
---|---|
1 /* | |
2 * WidgetWrapper.js | |
3 * | |
4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 3 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
19 * MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
23 * @class WidgetWrapper | |
24 * Interface-like implementation for widgets interaction to each other; aimed to be modified for dynamic data sources | |
25 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de) | |
26 * @release 1.0 | |
27 * @release date: 2012-07-27 | |
28 * @version date: 2012-07-27 | |
29 * | |
30 * @param {Object} widget either a map, time or table widget | |
31 */ | |
32 WidgetWrapper = function() { | |
33 | |
34 var wrapper = this; | |
35 | |
36 this.setWidget = function(widget) { | |
37 this.widget = widget; | |
38 } | |
39 | |
40 this.display = function(data) { | |
41 if ( data instanceof Array) { | |
42 GeoTemConfig.datasets = data; | |
43 if ( typeof wrapper.widget != 'undefined') { | |
44 this.widget.initWidget(data); | |
45 } | |
46 } | |
47 }; | |
48 | |
49 Publisher.Subscribe('highlight', this, function(data) { | |
50 if (data == undefined) { | |
51 return; | |
52 } | |
53 if ( typeof wrapper.widget != 'undefined') { | |
54 wrapper.widget.highlightChanged(data); | |
55 } | |
56 }); | |
57 | |
58 Publisher.Subscribe('selection', this, function(data) { | |
59 if ( typeof wrapper.widget != 'undefined') { | |
60 wrapper.widget.selectionChanged(data); | |
61 } | |
62 }); | |
63 | |
64 Publisher.Subscribe('filterData', this, function(data) { | |
65 wrapper.display(data); | |
66 }); | |
67 | |
68 Publisher.Subscribe('rise', this, function(id) { | |
69 if ( typeof wrapper.widget != 'undefined' && typeof wrapper.widget.riseLayer != 'undefined') { | |
70 wrapper.widget.riseLayer(id); | |
71 } | |
72 }); | |
73 | |
74 Publisher.Subscribe('resizeWidget', this, function() { | |
75 if ( typeof wrapper.widget != 'undefined' && typeof wrapper.widget.gui != 'undefined' && typeof wrapper.widget.gui.resize != 'undefined' ) { | |
76 wrapper.widget.gui.resize(); | |
77 } | |
78 }); | |
79 | |
80 Publisher.Subscribe('getConfig', this, function(inquiringWidget) { | |
81 if (inquiringWidget == undefined) { | |
82 return; | |
83 } | |
84 if ( typeof wrapper.widget != 'undefined') { | |
85 if ( typeof wrapper.widget.getConfig != 'undefined') { | |
86 wrapper.widget.getConfig(inquiringWidget); | |
87 } | |
88 } | |
89 }); | |
90 | |
91 Publisher.Subscribe('setConfig', this, function(config) { | |
92 if (config == undefined) { | |
93 return; | |
94 } | |
95 if ( typeof wrapper.widget != 'undefined') { | |
96 if ( typeof wrapper.widget.setConfig != 'undefined') { | |
97 wrapper.widget.setConfig(config); | |
98 } | |
99 } | |
100 }); | |
101 | |
102 | |
103 this.triggerRefining = function(datasets) { | |
104 Publisher.Publish('filterData', datasets, null); | |
105 }; | |
106 | |
107 this.triggerSelection = function(selectedObjects) { | |
108 Publisher.Publish('selection', selectedObjects, this); | |
109 }; | |
110 | |
111 this.triggerHighlight = function(highlightedObjects) { | |
112 Publisher.Publish('highlight', highlightedObjects, this); | |
113 }; | |
114 | |
115 this.triggerRise = function(id) { | |
116 Publisher.Publish('rise', id); | |
117 }; | |
118 | |
119 }; |