2
* Copyright (C) 2007-2008 Camptocamp
4
* This file is part of MapFish Client
6
* MapFish Client is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* MapFish Client 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
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with MapFish Client. If not, see <http://www.gnu.org/licenses/>.
21
* @requires core/GeoStat/ProportionalSymbol.js
24
Ext.namespace('mapfish.widgets', 'mapfish.widgets.geostat');
27
* Class: mapfish.widgets.geostat.ProportionalSymbol
28
* Use this class to create a widget allowing to display proportional
34
mapfish.widgets.geostat.ProportionalSymbol = Ext.extend(Ext.FormPanel, {
38
* {<OpenLayers.Layer.Vector>} The vector layer containing the features that
39
* are styled based on statistical values. If none is provided, one will
46
* {<OpenLayers.Format>} The OpenLayers format used to get features from
47
* the HTTP request response. GeoJSON is used if none is provided.
53
* {String} The URL to the web service. If none is provided, the features
54
* found in the provided vector layer will be used.
59
* APIProperty: featureSelection
60
* {Boolean} A boolean value specifying whether feature selection must
61
* be put in place. If true a popup will be displayed when the
62
* mouse goes over a feature.
64
featureSelection: true,
67
* APIProperty: nameAttribute
68
* {String} The feature attribute that will be used as the popup title.
69
* Only applies if featureSelection is true.
74
* APIProperty: indicator
75
* {String} (read-only) The feature attribute currently chosen
76
* Useful if callbacks are registered on 'featureselected'
77
* and 'featureunselected' events
82
* APIProperty: indicatorText
83
* {String} (read-only) The raw value of the currently chosen indicator
84
* (ie. human readable)
85
* Useful if callbacks are registered on 'featureselected'
86
* and 'featureunselected' events
92
* {<mapfish.GeoStat.ProportionalSymbol>} The core component object.
97
* Property: classificationApplied
98
* {Boolean} true if the classify was applied
100
classificationApplied: false,
104
* {Boolean} true if the widget is ready to accept user commands.
115
* APIProperty: loadMask
116
* An Ext.LoadMask config or true to mask the widget while loading (defaults to false).
121
* Constructor: mapfish.widgets.geostat.ProportionalSymbol
124
* config - {Object} Config object.
128
* Method: initComponent
129
* Inits the component
131
initComponent : function() {
134
fieldLabel: 'Indicator',
139
displayField: 'text',
141
emptyText: 'Select indicator',
143
// triggerAction: 'all',
144
store: new Ext.data.SimpleStore({
145
fields: ['value', 'text'],
146
data : this.indicators
151
// this.classify(false);
157
xtype: 'numberfield',
158
fieldLabel:'Min Size',
164
xtype: 'numberfield',
165
fieldLabel:'Max Size',
173
handler: function() {
182
// handler: this.classify,
185
mapfish.widgets.geostat.ProportionalSymbol.superclass.initComponent.apply(this);
189
* Method: requestSuccess
190
* Calls onReady callback function and mark the widget as ready.
191
* Called on Ajax request success.
193
requestSuccess: function(request) {
196
// if widget is rendered, hide the optional mask
197
if (this.loadMask && this.rendered) {
198
this.loadMask.hide();
203
* Method: requestFailure
204
* Displays an error message on the console.
205
* Called on Ajax request failure.
207
requestFailure: function(request) {
208
OpenLayers.Console.error('Ajax request failed');
213
* Reads the features to get the different value for
214
* the field given for indicator
215
* Creates a new Distribution and related Classification
216
* Then creates an new ProportionalSymbols and applies classification
218
classify: function() {
221
Ext.MessageBox.alert('Error', 'Component init not complete');
225
this.indicator = this.form.findField('indicator').getValue();
226
this.indicatorText = this.form.findField('indicator').getRawValue();
227
if (!this.indicator) {
228
Ext.MessageBox.alert('Error', 'You must choose an indicator');
231
var minSize = this.form.findField('minSize').getValue();
232
var maxSize = this.form.findField('maxSize').getValue();
233
this.coreComp.updateOptions({
234
'indicator': this.indicator,
241
this.coreComp.applyClassification();
242
this.classificationApplied = true;
247
* Called by EXT when the component is rendered.
249
onRender: function(ct, position) {
250
mapfish.widgets.geostat.Choropleth.superclass.onRender.apply(
254
this.loadMask = new Ext.LoadMask(this.bwrap,
256
this.loadMask.show();
259
this.coreComp = new mapfish.GeoStat.ProportionalSymbol(this.map, {
261
'format': this.format,
263
'requestSuccess': this.requestSuccess.createDelegate(this),
264
'requestFailure': this.requestFailure.createDelegate(this),
265
'featureSelection': this.featureSelection,
266
'nameAttribute': this.nameAttribute
270
Ext.reg('proportionalsymbol', mapfish.widgets.geostat.ProportionalSymbol);