Revision 11704 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/QuantityByCategory.java
QuantityByCategory.java | ||
---|---|---|
23 | 23 |
import com.iver.andami.messages.NotificationManager; |
24 | 24 |
import com.iver.andami.ui.mdiManager.IWindow; |
25 | 25 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
26 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
26 | 27 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
27 | 28 |
import com.iver.cit.gvsig.fmap.core.symbols.PictureMarkerSymbol; |
28 | 29 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
29 | 30 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
31 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
30 | 32 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
31 | 33 |
import com.iver.cit.gvsig.fmap.rendering.GraduatedSymbolLegend; |
32 | 34 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
... | ... | |
135 | 137 |
if (legend instanceof QuantityByCategoryLegend) { |
136 | 138 |
this.legend = (QuantityByCategoryLegend) legend; |
137 | 139 |
getCmbColorField().setSelectedItem( |
138 |
this.legend.getColorRampLegend().getFieldName()); |
|
140 |
this.legend.getColorRampLegend().getFieldNames());
|
|
139 | 141 |
|
140 | 142 |
getCmbGraduatedField().setSelectedItem( |
141 |
this.legend.getGraduatedSymbolLegend().getFieldName()); |
|
143 |
this.legend.getGraduatedSymbolLegend().getFieldNames());
|
|
142 | 144 |
} else { |
143 | 145 |
this.legend = new QuantityByCategoryLegend(); |
144 |
this.legend.getColorRampLegend().setFieldName( |
|
145 |
(String) getCmbColorField().getSelectedItem()); |
|
146 |
this.legend.getGraduatedSymbolLegend().setFieldName( |
|
147 |
(String) getCmbGraduatedField().getSelectedItem()); |
|
146 |
this.legend.setFieldNames( |
|
147 |
new String[] { |
|
148 |
(String) getCmbColorField().getSelectedItem(), |
|
149 |
(String) getCmbGraduatedField().getSelectedItem() |
|
150 |
}); |
|
148 | 151 |
try { |
149 | 152 |
this.legend.setShapeType(((FLyrVect)lyr).getShapeType()); |
150 | 153 |
} catch (ReadDriverException e) { |
... | ... | |
195 | 198 |
if (c.equals(getBtnColor())) { |
196 | 199 |
VectorialIntervalLegend colorRamp = legend.getColorRampLegend(); |
197 | 200 |
String fieldName = (String) getCmbColorField().getSelectedItem(); |
198 |
if (!fieldName.equals(colorRamp.getFieldName())) { |
|
201 |
if (!fieldName.equals(colorRamp.getFieldNames())) {
|
|
199 | 202 |
// if classification field has changed, clear the legend |
200 |
colorRamp.setFieldName(fieldName);
|
|
203 |
colorRamp.setFieldNames(new String[] {fieldName});
|
|
201 | 204 |
colorRamp.clear(); |
202 | 205 |
} |
203 | 206 |
|
... | ... | |
211 | 214 |
} else if (c.equals(getBtnSymbol())) { |
212 | 215 |
GraduatedSymbolLegend graduatedSymbol = legend.getGraduatedSymbolLegend(); |
213 | 216 |
String fieldName = (String) getCmbColorField().getSelectedItem(); |
214 |
if (!fieldName.equals(graduatedSymbol.getFieldName())) { |
|
217 |
if (!fieldName.equals(graduatedSymbol.getFieldNames())) {
|
|
215 | 218 |
// if classification field has changed, clear the legend |
216 |
graduatedSymbol.setFieldName(fieldName);
|
|
219 |
graduatedSymbol.setFieldNames(new String[] {fieldName});
|
|
217 | 220 |
graduatedSymbol.clear(); |
218 | 221 |
} |
219 | 222 |
// create a new modal window to edit the graduated symbol legend |
... | ... | |
263 | 266 |
return wi; |
264 | 267 |
} |
265 | 268 |
} |
266 |
/** |
|
267 |
* DOCUMENT ME! |
|
268 |
*/ |
|
269 |
|
|
269 | 270 |
protected void fillFieldNames() { |
270 | 271 |
DataSource rs = null; |
271 | 272 |
ArrayList nomFields = null; |
... | ... | |
297 | 298 |
NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
298 | 299 |
} |
299 | 300 |
|
300 |
/* ArrayList nomFields = new ArrayList(); |
|
301 |
for (int i = 0; i < rs.getFieldsCount(); i++) { |
|
302 |
if ((rs.getFieldType(i) == FRecordset.INTEGER) || |
|
303 |
(rs.getFieldType(i) == FRecordset.DECIMAL) || |
|
304 |
(rs.getFieldType(i) == FRecordset.DATE)) |
|
305 |
{ |
|
306 |
nomFields.add(rs.getFieldName(i).trim()); |
|
307 |
} |
|
308 |
|
|
309 |
} |
|
310 |
*/ |
|
311 | 301 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields.toArray()); |
312 | 302 |
cmbColorField.setModel(cM); |
313 | 303 |
cM = new DefaultComboBoxModel(nomFields.toArray()); |
314 | 304 |
cmbGraduatedSymbolField.setModel(cM); |
315 | 305 |
|
316 |
// fieldsListValor.setSelectedIndex(0);
|
|
306 |
}
|
|
317 | 307 |
|
318 |
} |
|
308 |
private boolean isNumericField(int fieldType) { |
|
309 |
switch (fieldType) { |
|
310 |
case Types.BIGINT: |
|
311 |
case Types.DECIMAL: |
|
312 |
case Types.DOUBLE: |
|
313 |
case Types.FLOAT: |
|
314 |
case Types.INTEGER: |
|
315 |
case Types.NUMERIC: |
|
316 |
case Types.REAL: |
|
317 |
case Types.SMALLINT: |
|
318 |
case Types.TINYINT: |
|
319 |
return true; |
|
320 |
default: |
|
321 |
return false; |
|
322 |
} |
|
323 |
|
|
324 |
} |
|
325 |
|
|
326 |
public boolean isSuitableFor(FLayer layer) { |
|
327 |
if (layer instanceof FLyrVect) { |
|
328 |
try { |
|
329 |
FLyrVect lyr = (FLyrVect) layer; |
|
330 |
|
|
331 |
if (lyr.getShapeType() != FShape.POLYGON) |
|
332 |
return false; |
|
333 |
|
|
334 |
SelectableDataSource sds; |
|
335 |
sds = ((FLyrVect) layer).getRecordset(); |
|
336 |
String[] fNames = sds.getFieldNames(); |
|
337 |
for (int i = 0; i < fNames.length; i++) { |
|
338 |
if (isNumericField(sds.getFieldType(i))) { |
|
339 |
return true; |
|
340 |
} |
|
341 |
} |
|
342 |
} catch (ReadDriverException e) { |
|
343 |
return false; |
|
344 |
} |
|
345 |
} |
|
346 |
return false; |
|
347 |
} |
|
319 | 348 |
} |
Also available in: Unified diff