2
* Copyright (C) 2009 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',
138
displayField: 'text',
140
emptyText: 'select an indicator',
141
triggerAction: 'all',
142
store: new Ext.data.SimpleStore({
143
fields: ['value', 'text'],
144
data : this.indicators
147
xtype: 'numberfield',
148
fieldLabel:'Min Size',
154
xtype: 'numberfield',
155
fieldLabel:'Max Size',
165
handler: this.classify,
168
mapfish.widgets.geostat.ProportionalSymbol.superclass.initComponent.apply(this);
172
* Method: requestSuccess
173
* Calls onReady callback function and mark the widget as ready.
174
* Called on Ajax request success.
176
requestSuccess: function(request) {
179
// if widget is rendered, hide the optional mask
180
if (this.loadMask && this.rendered) {
181
this.loadMask.hide();
186
* Method: requestFailure
187
* Displays an error message on the console.
188
* Called on Ajax request failure.
190
requestFailure: function(request) {
191
OpenLayers.Console.error('Ajax request failed');
196
* Reads the features to get the different value for
197
* the field given for indicator
198
* Creates a new Distribution and related Classification
199
* Then creates an new ProportionalSymbols and applies classification
201
classify: function() {
204
Ext.MessageBox.alert('Error', 'Component init not complete');
208
this.indicator = this.form.findField('indicator').getValue();
209
this.indicatorText = this.form.findField('indicator').getRawValue();
210
if (!this.indicator) {
211
Ext.MessageBox.alert('Error', 'You must choose an indicator');
214
var minSize = this.form.findField('minSize').getValue();
215
var maxSize = this.form.findField('maxSize').getValue();
216
this.coreComp.updateOptions({
217
'indicator': this.indicator,
221
this.coreComp.applyClassification();
222
this.classificationApplied = true;
227
* Called by EXT when the component is rendered.
229
onRender: function(ct, position) {
230
mapfish.widgets.geostat.Choropleth.superclass.onRender.apply(
234
this.loadMask = new Ext.LoadMask(this.bwrap,
236
this.loadMask.show();
239
this.coreComp = new mapfish.GeoStat.ProportionalSymbol(this.map, {
241
'format': this.format,
243
'requestSuccess': this.requestSuccess.createDelegate(this),
244
'requestFailure': this.requestFailure.createDelegate(this),
245
'featureSelection': this.featureSelection,
246
'nameAttribute': this.nameAttribute
250
Ext.reg('proportionalsymbol', mapfish.widgets.geostat.ProportionalSymbol);