Revision 3573
org.gvsig.legend.proportionalsymbols.app.mainplugin/trunk/org.gvsig.legend.proportionalsymbols.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/ProportionalSymbolsPanel.java | ||
---|---|---|
93 | 93 |
import org.gvsig.tools.dispose.DisposableIterator; |
94 | 94 |
|
95 | 95 |
/** |
96 |
* Implements the panel for the legend of proportional symbols.In the interface will be |
|
97 |
* options to select the value field, the normalization field (if the user wants to use it) and |
|
98 |
* options to select the symbol an its minimum and maximum size. |
|
96 |
* Implements the panel for the legend of proportional symbols.In the interface |
|
97 |
* will be options to select the value field, the normalization field (if the |
|
98 |
* user wants to use it) and options to select the symbol an its minimum and |
|
99 |
* maximum size. |
|
99 | 100 |
* |
100 |
* Also there will be possible to select a background symbol (only when the shapetype of the layer is
|
|
101 |
* polygonal). |
|
101 |
* Also there will be possible to select a background symbol (only when the |
|
102 |
* shapetype of the layer is polygonal).
|
|
102 | 103 |
* |
103 | 104 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
104 | 105 |
* @author jldominguez |
... | ... | |
107 | 108 |
|
108 | 109 |
private static Logger logger = LoggerFactory.getLogger(ProportionalSymbolsPanel.class); |
109 | 110 |
|
110 |
private static final long serialVersionUID = 7394720230276170902L;
|
|
111 |
private JPanel symbolPanel;
|
|
112 |
private JPanel backgroundPanel;
|
|
113 |
private JSymbolPreviewButton tmplateSymbol;
|
|
114 |
private JSymbolPreviewButton backSymbol;
|
|
115 |
private JComboBox cmbValue;
|
|
116 |
private JComboBox cmbNormalization;
|
|
117 |
private JNumberSpinner txtMinSize;
|
|
118 |
private JNumberSpinner txtMaxSize;
|
|
119 |
private ClassifiableVectorial myLayer;
|
|
120 |
private ProportionalSymbolsLegend auxLegend;
|
|
121 |
private String[] fieldNames;
|
|
122 |
private int templateShapeType = 0;
|
|
111 |
private static final long serialVersionUID = 7394720230276170902L;
|
|
112 |
private JPanel symbolPanel;
|
|
113 |
private JPanel backgroundPanel;
|
|
114 |
private JSymbolPreviewButton tmplateSymbol;
|
|
115 |
private JSymbolPreviewButton backSymbol;
|
|
116 |
private JComboBox cmbValue;
|
|
117 |
private JComboBox cmbNormalization;
|
|
118 |
private JNumberSpinner txtMinSize;
|
|
119 |
private JNumberSpinner txtMaxSize;
|
|
120 |
private ClassifiableVectorial myLayer;
|
|
121 |
private ProportionalSymbolsLegend auxLegend;
|
|
122 |
private String[] fieldNames;
|
|
123 |
private int templateShapeType = 0;
|
|
123 | 124 |
|
124 |
private String noNormalization = Messages.getText("none");
|
|
125 |
private String noNormalization = Messages.getText("none");
|
|
125 | 126 |
|
126 |
private boolean useNormalization = true;
|
|
127 |
private boolean useNormalization = true;
|
|
127 | 128 |
|
128 |
/**
|
|
129 |
* Default constructor
|
|
130 |
*/
|
|
131 |
public ProportionalSymbolsPanel() {
|
|
132 |
initialize();
|
|
133 |
}
|
|
129 |
/**
|
|
130 |
* Default constructor
|
|
131 |
*/
|
|
132 |
public ProportionalSymbolsPanel() {
|
|
133 |
initialize();
|
|
134 |
}
|
|
134 | 135 |
|
135 |
/**
|
|
136 |
* This method initializes this
|
|
137 |
*/
|
|
138 |
private void initialize() {
|
|
136 |
/**
|
|
137 |
* This method initializes this
|
|
138 |
*/
|
|
139 |
private void initialize() {
|
|
139 | 140 |
|
140 |
setLayout(new BorderLayout());
|
|
141 |
JPanel aux = new JPanel(new BorderLayout());
|
|
141 |
setLayout(new BorderLayout());
|
|
142 |
JPanel aux = new JPanel(new BorderLayout());
|
|
142 | 143 |
|
143 |
JPanel fieldsPanel = new JPanel(new FlowLayout());
|
|
144 |
fieldsPanel.setBorder(BorderFactory.
|
|
145 |
createTitledBorder(null,
|
|
146 |
Messages.getText("fields")
|
|
147 |
));
|
|
148 |
fieldsPanel.setPreferredSize(new Dimension(300,60));
|
|
144 |
JPanel fieldsPanel = new JPanel(new FlowLayout());
|
|
145 |
fieldsPanel.setBorder(BorderFactory.
|
|
146 |
createTitledBorder(null,
|
|
147 |
Messages.getText("fields")
|
|
148 |
));
|
|
149 |
fieldsPanel.setPreferredSize(new Dimension(300, 60));
|
|
149 | 150 |
|
150 |
cmbValue = new JComboBox();
|
|
151 |
cmbValue.setActionCommand("VALUE_SELECTED");
|
|
151 |
cmbValue = new JComboBox();
|
|
152 |
cmbValue.setActionCommand("VALUE_SELECTED");
|
|
152 | 153 |
|
153 |
cmbNormalization = new JComboBox();
|
|
154 |
cmbNormalization.setActionCommand("NORMALIZATION_SELECTED");
|
|
154 |
cmbNormalization = new JComboBox();
|
|
155 |
cmbNormalization.setActionCommand("NORMALIZATION_SELECTED");
|
|
155 | 156 |
|
156 |
fieldsPanel.add(new JLabel(
|
|
157 |
Messages.getText("value")
|
|
158 |
+":" ));
|
|
159 |
fieldsPanel.add(cmbValue);
|
|
157 |
fieldsPanel.add(new JLabel(
|
|
158 |
Messages.getText("value")
|
|
159 |
+ ":"));
|
|
160 |
fieldsPanel.add(cmbValue);
|
|
160 | 161 |
|
161 |
fieldsPanel.add(new JLabel(
|
|
162 |
Messages.getText("normalization")
|
|
163 |
+":" ));
|
|
164 |
fieldsPanel.add(cmbNormalization);
|
|
162 |
fieldsPanel.add(new JLabel(
|
|
163 |
Messages.getText("normalization")
|
|
164 |
+ ":"));
|
|
165 |
fieldsPanel.add(cmbNormalization);
|
|
165 | 166 |
|
167 |
symbolPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 3, 2)); |
|
168 |
symbolPanel.setBorder(BorderFactory. |
|
169 |
createTitledBorder(null, |
|
170 |
Messages.getText("symbol") |
|
171 |
)); |
|
166 | 172 |
|
167 |
symbolPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 3,2)); |
|
168 |
symbolPanel.setBorder(BorderFactory. |
|
169 |
createTitledBorder(null, |
|
170 |
Messages.getText("symbol") |
|
171 |
)); |
|
173 |
GridBagLayoutPanel aux2 = new GridBagLayoutPanel(); |
|
174 |
aux2.addComponent(new JLabel( |
|
175 |
Messages.getText("size") |
|
176 |
)); |
|
177 |
aux2.addComponent(new JBlank(10, 10)); |
|
178 |
aux2.addComponent( |
|
179 |
Messages.getText("from") |
|
180 |
+ ":", |
|
181 |
getTxtMinSize()); |
|
182 |
aux2.addComponent( |
|
183 |
Messages.getText("to") |
|
184 |
+ ":", |
|
185 |
getTxtMaxSize()); |
|
172 | 186 |
|
173 |
GridBagLayoutPanel aux2 = new GridBagLayoutPanel(); |
|
174 |
aux2.addComponent(new JLabel( |
|
175 |
Messages.getText("size") |
|
176 |
)); |
|
177 |
aux2.addComponent(new JBlank(10,10)); |
|
178 |
aux2.addComponent( |
|
179 |
Messages.getText("from") |
|
180 |
+":", |
|
181 |
getTxtMinSize()); |
|
182 |
aux2.addComponent( |
|
183 |
Messages.getText("to") |
|
184 |
+":", |
|
185 |
getTxtMaxSize()); |
|
187 |
JPanel templatePanel = new JPanel(); |
|
188 |
templatePanel.setBorder(BorderFactory.createTitledBorder(null, |
|
189 |
Messages.getText("template") |
|
190 |
)); |
|
191 |
templatePanel.add(getTemplSymbol()); |
|
192 |
symbolPanel.add(new JBlank(10, 10)); |
|
193 |
symbolPanel.add(aux2); |
|
194 |
symbolPanel.add(new JBlank(10, 10)); |
|
195 |
symbolPanel.add(templatePanel); |
|
186 | 196 |
|
187 |
JPanel templatePanel = new JPanel(); |
|
188 |
templatePanel.setBorder(BorderFactory.createTitledBorder(null, |
|
189 |
Messages.getText("template") |
|
190 |
)); |
|
191 |
templatePanel.add(getTemplSymbol()); |
|
192 |
symbolPanel.add(new JBlank(10,10)); |
|
193 |
symbolPanel.add(aux2); |
|
194 |
symbolPanel.add(new JBlank(10,10)); |
|
195 |
symbolPanel.add(templatePanel); |
|
197 |
aux.add(fieldsPanel, BorderLayout.NORTH); |
|
198 |
aux.add(symbolPanel, BorderLayout.CENTER); |
|
196 | 199 |
|
197 |
aux.add(fieldsPanel, BorderLayout.NORTH); |
|
198 |
aux.add(symbolPanel, BorderLayout.CENTER); |
|
200 |
this.add(aux, BorderLayout.CENTER); |
|
199 | 201 |
|
200 |
this.add(aux, BorderLayout.CENTER); |
|
202 |
cmbValue.addActionListener(action); |
|
203 |
cmbNormalization.addActionListener(action); |
|
204 |
tmplateSymbol.addActionListener(action); |
|
205 |
} |
|
201 | 206 |
|
202 |
cmbValue.addActionListener(action); |
|
203 |
cmbNormalization.addActionListener(action); |
|
204 |
tmplateSymbol.addActionListener(action); |
|
205 |
} |
|
206 |
/** |
|
207 |
* Creates the panel where the button for the background symbol will be placed |
|
208 |
* |
|
209 |
* @return JPanel panel |
|
210 |
*/ |
|
207 |
/** |
|
208 |
* Creates the panel where the button for the background symbol will be |
|
209 |
* placed |
|
210 |
* |
|
211 |
* @return JPanel panel |
|
212 |
*/ |
|
213 |
private JPanel getBackgroundPanel() { |
|
214 |
backgroundPanel = new JPanel(); |
|
215 |
backgroundPanel.setBorder(BorderFactory.createTitledBorder(null, |
|
216 |
Messages.getText("background") |
|
217 |
)); |
|
218 |
backgroundPanel.add(getBtnBackground()); |
|
219 |
return backgroundPanel; |
|
220 |
} |
|
211 | 221 |
|
212 |
private JPanel getBackgroundPanel() { |
|
213 |
backgroundPanel = new JPanel(); |
|
214 |
backgroundPanel.setBorder(BorderFactory.createTitledBorder(null, |
|
215 |
Messages.getText("background") |
|
216 |
)); |
|
217 |
backgroundPanel.add(getBtnBackground()); |
|
218 |
return backgroundPanel; |
|
219 |
} |
|
220 |
/** |
|
221 |
* Creates a JNumberSpinner which is used to select the maximum size for the symbol |
|
222 |
* |
|
223 |
* @return JNumberSpinner |
|
224 |
*/ |
|
225 |
private JNumberSpinner getTxtMaxSize() { |
|
226 |
if (txtMaxSize == null) { |
|
227 |
txtMaxSize = new JNumberSpinner(25.0,7,0.0,100.0,1.0,2); |
|
228 |
txtMaxSize.addActionListener(action); |
|
229 |
} |
|
230 |
return txtMaxSize; |
|
231 |
} |
|
232 |
/** |
|
233 |
* Creates a JNumberSpinner which is used to select the minimum size for the symbol |
|
234 |
* |
|
235 |
* @return JNumberSpinner |
|
236 |
*/ |
|
237 |
private JNumberSpinner getTxtMinSize() { |
|
238 |
if (txtMinSize == null) { |
|
239 |
txtMinSize = new JNumberSpinner(3.0,7,0.0,100.0,1.0,2); |
|
240 |
txtMinSize.addActionListener(action); |
|
241 |
} |
|
242 |
return txtMinSize; |
|
243 |
} |
|
244 |
/** |
|
245 |
* Creates a JSymbolPreviewButton which is used to select the template symbol |
|
246 |
* |
|
247 |
* @return JSymbolPreviewButton |
|
248 |
*/ |
|
249 |
private JSymbolPreviewButton getTemplSymbol() { |
|
222 |
/** |
|
223 |
* Creates a JNumberSpinner which is used to select the maximum size for the |
|
224 |
* symbol |
|
225 |
* |
|
226 |
* @return JNumberSpinner |
|
227 |
*/ |
|
228 |
private JNumberSpinner getTxtMaxSize() { |
|
229 |
if (txtMaxSize == null) { |
|
230 |
txtMaxSize = new JNumberSpinner(25.0, 7, 0.0, 100.0, 1.0, 2); |
|
231 |
txtMaxSize.addActionListener(action); |
|
232 |
} |
|
233 |
return txtMaxSize; |
|
234 |
} |
|
250 | 235 |
|
251 |
if (tmplateSymbol == null) { |
|
252 |
int tst = ProportionalSymbolsLegend.isPolygonal(this.templateShapeType) ? |
|
253 |
Geometry.TYPES.POINT |
|
254 |
: this.templateShapeType; |
|
236 |
/** |
|
237 |
* Creates a JNumberSpinner which is used to select the minimum size for the |
|
238 |
* symbol |
|
239 |
* |
|
240 |
* @return JNumberSpinner |
|
241 |
*/ |
|
242 |
private JNumberSpinner getTxtMinSize() { |
|
243 |
if (txtMinSize == null) { |
|
244 |
txtMinSize = new JNumberSpinner(3.0, 7, 0.0, 100.0, 1.0, 2); |
|
245 |
txtMinSize.addActionListener(action); |
|
246 |
} |
|
247 |
return txtMinSize; |
|
248 |
} |
|
255 | 249 |
|
256 |
tmplateSymbol = new JSymbolPreviewButton(tst); |
|
257 |
} |
|
258 |
tmplateSymbol.setPreferredSize(new Dimension(100, 45)); |
|
259 |
return tmplateSymbol; |
|
260 |
} |
|
261 |
/** |
|
262 |
* Creates a JSymbolPreviewButton which is used to select the background symbol |
|
263 |
* |
|
264 |
* @return JSymbolPreviewButton |
|
265 |
*/ |
|
266 |
private JSymbolPreviewButton getBtnBackground() { |
|
267 |
if (backSymbol == null) { |
|
268 |
backSymbol = new JSymbolPreviewButton(Geometry.TYPES.SURFACE); |
|
269 |
backSymbol.setPreferredSize(new Dimension(100, 45)); |
|
250 |
/** |
|
251 |
* Creates a JSymbolPreviewButton which is used to select the template |
|
252 |
* symbol |
|
253 |
* |
|
254 |
* @return JSymbolPreviewButton |
|
255 |
*/ |
|
256 |
private JSymbolPreviewButton getTemplSymbol() { |
|
270 | 257 |
|
258 |
if (tmplateSymbol == null) { |
|
259 |
int tst = ProportionalSymbolsLegend.isPolygonal(this.templateShapeType) |
|
260 |
? Geometry.TYPES.POINT |
|
261 |
: this.templateShapeType; |
|
262 |
|
|
263 |
tmplateSymbol = new JSymbolPreviewButton(tst); |
|
264 |
} |
|
265 |
tmplateSymbol.setPreferredSize(new Dimension(100, 45)); |
|
266 |
return tmplateSymbol; |
|
267 |
} |
|
268 |
|
|
269 |
/** |
|
270 |
* Creates a JSymbolPreviewButton which is used to select the background |
|
271 |
* symbol |
|
272 |
* |
|
273 |
* @return JSymbolPreviewButton |
|
274 |
*/ |
|
275 |
private JSymbolPreviewButton getBtnBackground() { |
|
276 |
if (backSymbol == null) { |
|
277 |
backSymbol = new JSymbolPreviewButton(Geometry.TYPES.SURFACE); |
|
278 |
backSymbol.setPreferredSize(new Dimension(100, 45)); |
|
279 |
|
|
271 | 280 |
ISymbol fillsym = MapContextLocator.getSymbolManager().createSymbol( |
272 |
Geometry.TYPES.SURFACE, Color.ORANGE); |
|
281 |
Geometry.TYPES.SURFACE, Color.ORANGE);
|
|
273 | 282 |
backSymbol.setSymbol(fillsym); |
274 |
} |
|
275 |
return backSymbol; |
|
276 |
} |
|
277 |
/** |
|
278 |
* Creates a new symbol of an specific shapetype with a concrete size |
|
279 |
* |
|
280 |
* @param shapeType |
|
281 |
* @param size |
|
282 |
* |
|
283 |
* @return ISymbol symbol created |
|
284 |
*/ |
|
285 |
private ISymbol newSymbol(int shapeType, double size) { |
|
286 |
if (getTemplSymbol().getSymbol() == null) { |
|
287 |
ISymbol templateSymbol; |
|
283 |
} |
|
284 |
return backSymbol; |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* Creates a new symbol of an specific shapetype with a concrete size |
|
289 |
* |
|
290 |
* @param shapeType |
|
291 |
* @param size |
|
292 |
* |
|
293 |
* @return ISymbol symbol created |
|
294 |
*/ |
|
295 |
private ISymbol newSymbol(int shapeType, double size) { |
|
296 |
if (getTemplSymbol().getSymbol() == null) { |
|
297 |
ISymbol templateSymbol; |
|
288 | 298 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
289 |
if( geomManager.isSubtype(Geometry.TYPES.POINT, shapeType) ||
|
|
290 |
geomManager.isSubtype(Geometry.TYPES.MULTIPOINT, shapeType) ||
|
|
291 |
geomManager.isSubtype(Geometry.TYPES.SURFACE, shapeType) ||
|
|
292 |
geomManager.isSubtype(Geometry.TYPES.MULTISURFACE, shapeType) ) {
|
|
293 |
templateSymbol = new SimpleMarkerSymbol();
|
|
294 |
((SimpleMarkerSymbol) templateSymbol).setSize(size);
|
|
295 |
((SimpleMarkerSymbol) templateSymbol).setColor(Color.DARK_GRAY);
|
|
299 |
if (geomManager.isSubtype(Geometry.TYPES.POINT, shapeType)
|
|
300 |
|| geomManager.isSubtype(Geometry.TYPES.MULTIPOINT, shapeType)
|
|
301 |
|| geomManager.isSubtype(Geometry.TYPES.SURFACE, shapeType)
|
|
302 |
|| geomManager.isSubtype(Geometry.TYPES.MULTISURFACE, shapeType)) {
|
|
303 |
templateSymbol = new SimpleMarkerSymbol();
|
|
304 |
((SimpleMarkerSymbol) templateSymbol).setSize(size);
|
|
305 |
((SimpleMarkerSymbol) templateSymbol).setColor(Color.DARK_GRAY);
|
|
296 | 306 |
|
297 |
} else if( geomManager.isSubtype(Geometry.TYPES.CURVE, shapeType) ||
|
|
298 |
geomManager.isSubtype(Geometry.TYPES.MULTICURVE, shapeType) ) {
|
|
299 |
templateSymbol = new SimpleLineSymbol();
|
|
300 |
((SimpleLineSymbol) templateSymbol).setLineWidth(size);
|
|
301 |
((SimpleLineSymbol) templateSymbol).setLineColor(Color.DARK_GRAY);
|
|
307 |
} else if (geomManager.isSubtype(Geometry.TYPES.CURVE, shapeType)
|
|
308 |
|| geomManager.isSubtype(Geometry.TYPES.MULTICURVE, shapeType)) {
|
|
309 |
templateSymbol = new SimpleLineSymbol();
|
|
310 |
((SimpleLineSymbol) templateSymbol).setLineWidth(size);
|
|
311 |
((SimpleLineSymbol) templateSymbol).setLineColor(Color.DARK_GRAY);
|
|
302 | 312 |
|
303 | 313 |
} else { |
304 |
throw new RuntimeException("Unknown symbol type");
|
|
314 |
throw new RuntimeException("Unknown symbol type");
|
|
305 | 315 |
|
306 | 316 |
} |
307 | 317 |
|
308 |
getTemplSymbol().setSymbol(templateSymbol);
|
|
309 |
return newSymbol(shapeType, size);
|
|
310 |
} else {
|
|
311 |
// clone symbol
|
|
312 |
ISymbol mySymbol = getTemplSymbol().getSymbol();
|
|
318 |
getTemplSymbol().setSymbol(templateSymbol);
|
|
319 |
return newSymbol(shapeType, size);
|
|
320 |
} else {
|
|
321 |
// clone symbol
|
|
322 |
ISymbol mySymbol = getTemplSymbol().getSymbol();
|
|
313 | 323 |
|
314 |
try {
|
|
324 |
try {
|
|
315 | 325 |
mySymbol = (ISymbol) mySymbol.clone(); |
316 | 326 |
} catch (CloneNotSupportedException e) { |
317 | 327 |
logger.info("Error while cloning symbol", e); |
318 | 328 |
ApplicationLocator.getManager().messageDialog( |
319 |
Messages.getText("_Unable_to_clone_symbol"), |
|
320 |
Messages.getText("error"), |
|
321 |
JOptionPane.ERROR_MESSAGE); |
|
329 |
Messages.getText("_Unable_to_clone_symbol"),
|
|
330 |
Messages.getText("error"),
|
|
331 |
JOptionPane.ERROR_MESSAGE);
|
|
322 | 332 |
} |
323 | 333 |
|
324 |
if (mySymbol instanceof ILineSymbol) {
|
|
325 |
ILineSymbol lSym = (ILineSymbol) mySymbol;
|
|
326 |
lSym.setLineWidth(size);
|
|
334 |
if (mySymbol instanceof ILineSymbol) {
|
|
335 |
ILineSymbol lSym = (ILineSymbol) mySymbol;
|
|
336 |
lSym.setLineWidth(size);
|
|
327 | 337 |
|
328 |
}
|
|
329 |
if (mySymbol instanceof IMarkerSymbol) {
|
|
330 |
IMarkerSymbol mSym = (IMarkerSymbol) mySymbol;
|
|
331 |
mSym.setSize(size);
|
|
338 |
}
|
|
339 |
if (mySymbol instanceof IMarkerSymbol) {
|
|
340 |
IMarkerSymbol mSym = (IMarkerSymbol) mySymbol;
|
|
341 |
mSym.setSize(size);
|
|
332 | 342 |
|
333 |
if (ProportionalSymbolsLegend.isPolygonal(shapeType)) {
|
|
334 |
// this is to allow using in Polygon layers
|
|
335 |
MarkerFillSymbol fillSymbol = new MarkerFillSymbol();
|
|
336 |
fillSymbol.setOutline(null);
|
|
337 |
fillSymbol.setFillColor(null);
|
|
338 |
fillSymbol.getMarkerFillProperties().
|
|
339 |
setFillStyle(IMarkerFillPropertiesStyle.SINGLE_CENTERED_SYMBOL);
|
|
340 |
fillSymbol.setMarker(mSym);
|
|
341 |
}
|
|
342 |
}
|
|
343 |
return mySymbol;
|
|
344 |
}
|
|
345 |
}
|
|
343 |
if (ProportionalSymbolsLegend.isPolygonal(shapeType)) {
|
|
344 |
// this is to allow using in Polygon layers
|
|
345 |
MarkerFillSymbol fillSymbol = new MarkerFillSymbol();
|
|
346 |
fillSymbol.setOutline(null);
|
|
347 |
fillSymbol.setFillColor(null);
|
|
348 |
fillSymbol.getMarkerFillProperties().
|
|
349 |
setFillStyle(IMarkerFillPropertiesStyle.SINGLE_CENTERED_SYMBOL);
|
|
350 |
fillSymbol.setMarker(mSym);
|
|
351 |
}
|
|
352 |
}
|
|
353 |
return mySymbol;
|
|
354 |
}
|
|
355 |
}
|
|
346 | 356 |
|
347 |
/**
|
|
348 |
* Fills the comboboxes that are placed in the panel with the classifying field names of the layer
|
|
349 |
* which contain numerical information
|
|
350 |
*
|
|
351 |
*/
|
|
352 |
private void fillFieldNames() {
|
|
357 |
/**
|
|
358 |
* Fills the comboboxes that are placed in the panel with the classifying
|
|
359 |
* field names of the layer which contain numerical information
|
|
360 |
*
|
|
361 |
*/
|
|
362 |
private void fillFieldNames() {
|
|
353 | 363 |
|
354 |
// SelectableDataSource rs; |
|
364 |
// SelectableDataSource rs; |
|
365 |
try { |
|
366 |
FeatureStore fsto = (FeatureStore) ((FLyrVect) myLayer).getDataStore(); |
|
367 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
355 | 368 |
|
356 |
try { |
|
357 |
FeatureStore fsto = (FeatureStore) ((FLyrVect) myLayer).getDataStore(); |
|
358 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
359 |
|
|
360 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors(); |
|
361 |
int cont = 0; |
|
362 |
for (int i = 0; i < atts.length; i++) { |
|
363 |
if (atts[i].getDataType().isNumeric()) { |
|
369 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors(); |
|
370 |
int cont = 0; |
|
371 |
for (int i = 0; i < atts.length; i++) { |
|
372 |
if (atts[i].getDataType().isNumeric()) { |
|
364 | 373 |
cont++; |
365 |
}
|
|
366 |
}
|
|
367 |
String[] nomFields = new String[cont];
|
|
374 |
}
|
|
375 |
}
|
|
376 |
String[] nomFields = new String[cont];
|
|
368 | 377 |
|
369 |
cont = 0;
|
|
378 |
cont = 0;
|
|
370 | 379 |
for (int i = 0; i < atts.length; i++) { |
371 | 380 |
if (atts[i].getDataType().isNumeric()) { |
372 | 381 |
nomFields[cont] = atts[i].getName(); |
373 | 382 |
cont++; |
374 | 383 |
} |
375 | 384 |
} |
376 |
this.fieldNames = nomFields;
|
|
385 |
this.fieldNames = nomFields;
|
|
377 | 386 |
|
387 |
DefaultComboBoxModel cMValue = new DefaultComboBoxModel(this.fieldNames); |
|
388 |
DefaultComboBoxModel cMNormalization = new DefaultComboBoxModel(this.fieldNames); |
|
389 |
cmbValue.setModel(cMValue); |
|
390 |
cmbNormalization.setModel(cMNormalization); |
|
391 |
cmbNormalization.addItem(noNormalization); |
|
378 | 392 |
|
379 |
DefaultComboBoxModel cMValue = new DefaultComboBoxModel(this.fieldNames); |
|
380 |
DefaultComboBoxModel cMNormalization = new DefaultComboBoxModel(this.fieldNames); |
|
381 |
cmbValue.setModel(cMValue); |
|
382 |
cmbNormalization.setModel(cMNormalization); |
|
383 |
cmbNormalization.addItem(noNormalization); |
|
393 |
} catch (DataException e) { |
|
384 | 394 |
|
385 |
} catch (DataException e) { |
|
395 |
logger.info("Error while getting fields", e); |
|
396 |
ApplicationLocator.getManager().messageDialog( |
|
397 |
Messages.getText("_Error_while_getting_fields"), |
|
398 |
Messages.getText("error"), |
|
399 |
JOptionPane.ERROR_MESSAGE); |
|
386 | 400 |
|
387 |
logger.info("Error while getting fields", e); |
|
388 |
ApplicationLocator.getManager().messageDialog( |
|
389 |
Messages.getText("_Error_while_getting_fields"), |
|
390 |
Messages.getText("error"), |
|
391 |
JOptionPane.ERROR_MESSAGE); |
|
401 |
// NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
|
402 |
} |
|
403 |
} |
|
392 | 404 |
|
393 |
// NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e); |
|
394 |
} |
|
395 |
} |
|
405 |
public void setData(FLayer lyr, ILegend legend) { |
|
396 | 406 |
|
407 |
this.myLayer = (ClassifiableVectorial) lyr; |
|
397 | 408 |
|
398 |
public void setData(FLayer lyr, ILegend legend) {
|
|
409 |
fillFieldNames();
|
|
399 | 410 |
|
400 |
this.myLayer = (ClassifiableVectorial) lyr;
|
|
411 |
int myt = Geometry.TYPES.GEOMETRY;
|
|
401 | 412 |
|
402 |
fillFieldNames(); |
|
413 |
try { |
|
414 |
myt = this.myLayer.getGeometryType().getType(); |
|
415 |
} catch (ReadException re) { |
|
416 |
logger.info("Error while getting geometry type", re); |
|
417 |
ApplicationLocator.getManager().message( |
|
418 |
"Error getting geometry type", |
|
419 |
JOptionPane.ERROR_MESSAGE); |
|
420 |
} |
|
403 | 421 |
|
404 |
int myt = Geometry.TYPES.GEOMETRY; |
|
422 |
templateShapeType |
|
423 |
= ProportionalSymbolsLegend.isPolygonal(myt) |
|
424 |
? Geometry.TYPES.POINT : myt; |
|
405 | 425 |
|
406 |
try { |
|
407 |
myt = this.myLayer.getGeometryType().getType(); |
|
408 |
} catch (ReadException re) { |
|
409 |
logger.info("Error while getting geometry type", re); |
|
410 |
ApplicationLocator.getManager().message( |
|
411 |
"Error getting geometry type", |
|
412 |
JOptionPane.ERROR_MESSAGE); |
|
413 |
} |
|
426 |
getTemplSymbol().setShapeType(templateShapeType); |
|
414 | 427 |
|
415 |
templateShapeType =
|
|
416 |
ProportionalSymbolsLegend.isPolygonal(myt) ?
|
|
417 |
Geometry.TYPES.POINT : myt;
|
|
428 |
if (ProportionalSymbolsLegend.isPolygonal(myt) && backgroundPanel == null) {
|
|
429 |
symbolPanel.add(getBackgroundPanel());
|
|
430 |
}
|
|
418 | 431 |
|
419 |
getTemplSymbol().setShapeType(templateShapeType);
|
|
432 |
if (ProportionalSymbolsLegend.class.equals(legend.getClass())) {
|
|
420 | 433 |
|
421 |
if (ProportionalSymbolsLegend.isPolygonal(myt) && backgroundPanel == null) { |
|
422 |
symbolPanel.add(getBackgroundPanel()); |
|
423 |
} |
|
424 |
|
|
425 |
|
|
426 |
if (ProportionalSymbolsLegend.class.equals(legend.getClass())) { |
|
427 |
|
|
428 | 434 |
auxLegend = (ProportionalSymbolsLegend) legend.cloneLegend(); |
429 |
cmbValue.setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
|
|
430 |
ISymbol defSymbol = auxLegend.getDefaultSymbol();
|
|
435 |
cmbValue.setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
|
|
436 |
ISymbol defSymbol = auxLegend.getDefaultSymbol();
|
|
431 | 437 |
|
432 |
if(((ProportionalSymbolsLegend) auxLegend).getUseNormalization()) |
|
433 |
cmbNormalization.setSelectedItem(auxLegend.getClassifyingFieldNames()[1]); |
|
434 |
else cmbNormalization.setSelectedItem(noNormalization); |
|
438 |
if (((ProportionalSymbolsLegend) auxLegend).getUseNormalization()) { |
|
439 |
cmbNormalization.setSelectedItem(auxLegend.getClassifyingFieldNames()[1]); |
|
440 |
} else { |
|
441 |
cmbNormalization.setSelectedItem(noNormalization); |
|
442 |
} |
|
435 | 443 |
|
436 |
txtMaxSize.setDouble(auxLegend.getMaxSize());
|
|
437 |
txtMinSize.setDouble(auxLegend.getMinSize());
|
|
444 |
txtMaxSize.setDouble(auxLegend.getMaxSize());
|
|
445 |
txtMinSize.setDouble(auxLegend.getMinSize());
|
|
438 | 446 |
|
439 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
440 |
((ILineSymbol)defSymbol).setLineWidth(2);
|
|
441 |
} else {
|
|
442 |
((IMarkerSymbol)defSymbol).setSize(15); |
|
443 |
}
|
|
447 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
448 |
((ILineSymbol) defSymbol).setLineWidth(2);
|
|
449 |
} else {
|
|
450 |
((IMarkerSymbol) defSymbol).setSize(15);
|
|
451 |
}
|
|
444 | 452 |
|
445 |
getTemplSymbol().setSymbol(defSymbol);
|
|
453 |
getTemplSymbol().setSymbol(defSymbol);
|
|
446 | 454 |
|
447 |
if(((ProportionalSymbolsLegend) auxLegend).getBackgroundSymbol() != null) |
|
448 |
getBtnBackground().setSymbol(((ProportionalSymbolsLegend) auxLegend).getBackgroundSymbol()); |
|
455 |
if (((ProportionalSymbolsLegend) auxLegend).getBackgroundSymbol() != null) { |
|
456 |
getBtnBackground().setSymbol(((ProportionalSymbolsLegend) auxLegend).getBackgroundSymbol()); |
|
457 |
} |
|
449 | 458 |
|
450 |
} else {
|
|
459 |
} else {
|
|
451 | 460 |
|
452 |
auxLegend = new ProportionalSymbolsLegend();
|
|
453 |
auxLegend.setTemplateShapeType(templateShapeType);
|
|
461 |
auxLegend = new ProportionalSymbolsLegend();
|
|
462 |
auxLegend.setTemplateShapeType(templateShapeType);
|
|
454 | 463 |
|
455 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
456 |
auxLegend.setDefaultSymbol(newSymbol(templateShapeType, 2));
|
|
457 |
} else {
|
|
458 |
auxLegend.setDefaultSymbol(newSymbol(templateShapeType, 15));
|
|
459 |
}
|
|
464 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
465 |
auxLegend.setDefaultSymbol(newSymbol(templateShapeType, 2));
|
|
466 |
} else {
|
|
467 |
auxLegend.setDefaultSymbol(newSymbol(templateShapeType, 15));
|
|
468 |
}
|
|
460 | 469 |
|
461 |
getTemplSymbol().setSymbol(auxLegend.getDefaultSymbol());
|
|
462 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
470 |
getTemplSymbol().setSymbol(auxLegend.getDefaultSymbol());
|
|
471 |
if (ProportionalSymbolsLegend.isLinear(templateShapeType)) {
|
|
463 | 472 |
txtMinSize.setDouble(3); |
464 | 473 |
txtMaxSize.setDouble(3); |
465 |
} else {
|
|
474 |
} else {
|
|
466 | 475 |
txtMinSize.setDouble(10); |
467 | 476 |
txtMaxSize.setDouble(10); |
468 |
}
|
|
469 |
}
|
|
477 |
}
|
|
478 |
}
|
|
470 | 479 |
|
471 |
}
|
|
480 |
}
|
|
472 | 481 |
|
482 |
public ILegend getLegend() { |
|
483 |
ProportionalSymbolsLegend theLegend = new ProportionalSymbolsLegend(); |
|
473 | 484 |
|
474 |
public ILegend getLegend() {
|
|
475 |
ProportionalSymbolsLegend theLegend = new ProportionalSymbolsLegend();
|
|
485 |
String[] fieldNames = new String[2];
|
|
486 |
fieldNames[0] = cmbValue.getSelectedItem().toString();
|
|
476 | 487 |
|
477 |
String[] fieldNames = new String[2]; |
|
478 |
fieldNames[0]= cmbValue.getSelectedItem().toString(); |
|
488 |
if (!useNormalization) { |
|
489 |
fieldNames[1] = fieldNames[0]; |
|
490 |
} else { |
|
491 |
fieldNames[1] = cmbNormalization.getSelectedItem().toString(); |
|
492 |
} |
|
479 | 493 |
|
480 |
if(!useNormalization) |
|
481 |
fieldNames[1]= fieldNames[0]; |
|
482 |
else fieldNames[1]= cmbNormalization.getSelectedItem().toString(); |
|
494 |
auxLegend.setTemplateShapeType(templateShapeType); |
|
495 |
auxLegend.setValueField(cmbValue.getSelectedItem().toString()); |
|
496 |
auxLegend.setNormalizationField(cmbNormalization.getSelectedItem().toString()); |
|
497 |
auxLegend.setUseNormalization(useNormalization); |
|
483 | 498 |
|
484 |
auxLegend.setTemplateShapeType(templateShapeType); |
|
485 |
auxLegend.setValueField(cmbValue.getSelectedItem().toString()); |
|
486 |
auxLegend.setNormalizationField(cmbNormalization.getSelectedItem().toString()); |
|
487 |
auxLegend.setUseNormalization(useNormalization); |
|
499 |
auxLegend.setMinSize(txtMinSize.getDouble()); |
|
500 |
auxLegend.setMaxSize(txtMaxSize.getDouble()); |
|
488 | 501 |
|
489 |
auxLegend.setMinSize(txtMinSize.getDouble()); |
|
490 |
auxLegend.setMaxSize(txtMaxSize.getDouble()); |
|
491 |
|
|
492 |
ISymbol symbol = getTemplSymbol().getSymbol(); |
|
493 |
symbol.setDescription(getSymbolDescription()); |
|
494 |
auxLegend.setDefaultSymbol(symbol); |
|
495 |
|
|
496 | 502 |
auxLegend.clear(); |
497 |
auxLegend.addSymbol("defaultSymbol", symbol); |
|
503 |
|
|
504 |
ISymbol symbol = getTemplSymbol().getSymbol(); |
|
505 |
symbol.setDescription(getSymbolDescription()); |
|
506 |
auxLegend.setDefaultSymbol(symbol); |
|
498 | 507 |
|
499 |
if(auxLegend.isPolygonal(this.templateShapeType)){ |
|
500 |
auxLegend.setBackgroundSymbol(getBtnBackground().getSymbol()); |
|
501 |
} |
|
502 |
auxLegend.setClassifyingFieldNames(fieldNames); |
|
508 |
auxLegend.setClassifyingFieldNames(fieldNames); |
|
503 | 509 |
|
504 |
// ================================== |
|
510 |
// ================================== |
|
511 |
FLyrVect vect = (FLyrVect) myLayer; |
|
512 |
FeatureStore fsto = null; |
|
513 |
FeatureType fty = null; |
|
514 |
FeatureAttributeDescriptor[] atts = null; |
|
505 | 515 |
|
506 |
FLyrVect vect = (FLyrVect) myLayer; |
|
507 |
FeatureStore fsto = null; |
|
508 |
FeatureType fty = null; |
|
509 |
FeatureAttributeDescriptor[] atts = null; |
|
516 |
try { |
|
517 |
fsto = (FeatureStore) vect.getDataStore(); |
|
518 |
fty = fsto.getDefaultFeatureType(); |
|
510 | 519 |
|
511 |
try { |
|
512 |
fsto = (FeatureStore) vect.getDataStore(); |
|
513 |
fty = fsto.getDefaultFeatureType(); |
|
514 |
|
|
515 |
int[] fieldTyp = new int[2]; |
|
516 |
fieldTyp[0] = fty.getAttributeDescriptor(fieldNames[0]).getType(); |
|
520 |
int[] fieldTyp = new int[2]; |
|
521 |
fieldTyp[0] = fty.getAttributeDescriptor(fieldNames[0]).getType(); |
|
517 | 522 |
fieldTyp[1] = fty.getAttributeDescriptor(fieldNames[1]).getType(); |
518 | 523 |
auxLegend.setClassifyingFieldTypes(fieldTyp); |
519 | 524 |
|
520 |
FeatureSet fset = fsto.getFeatureSet();
|
|
521 |
DisposableIterator diter = fset.fastIterator();
|
|
522 |
Feature fitem = null;
|
|
523 |
double[] maxs = new double[fieldNames.length];
|
|
525 |
FeatureSet fset = fsto.getFeatureSet();
|
|
526 |
DisposableIterator diter = fset.fastIterator();
|
|
527 |
Feature fitem = null;
|
|
528 |
double[] maxs = new double[fieldNames.length];
|
|
524 | 529 |
double[] mins = new double[fieldNames.length]; |
525 |
for (int i=0; i<fieldNames.length; i++) {
|
|
530 |
for (int i = 0; i < fieldNames.length; i++) {
|
|
526 | 531 |
// init to worst values |
527 | 532 |
maxs[i] = -Double.MAX_VALUE; |
528 | 533 |
mins[i] = Double.MAX_VALUE; |
529 | 534 |
} |
530 | 535 |
double aux_dob = 0; |
531 | 536 |
|
532 |
while (diter.hasNext()) {
|
|
533 |
fitem = (Feature) diter.next();
|
|
534 |
for (int i=0; i<fieldNames.length; i++) {
|
|
535 |
aux_dob = fitem.getDouble(fieldNames[i]);
|
|
536 |
if (aux_dob > maxs[i]) {
|
|
537 |
maxs[i] = aux_dob;
|
|
538 |
}
|
|
537 |
while (diter.hasNext()) {
|
|
538 |
fitem = (Feature) diter.next();
|
|
539 |
for (int i = 0; i < fieldNames.length; i++) {
|
|
540 |
aux_dob = fitem.getDouble(fieldNames[i]);
|
|
541 |
if (aux_dob > maxs[i]) {
|
|
542 |
maxs[i] = aux_dob;
|
|
543 |
}
|
|
539 | 544 |
if (aux_dob < mins[i]) { |
540 | 545 |
mins[i] = aux_dob; |
541 | 546 |
} |
542 |
}
|
|
543 |
}
|
|
547 |
}
|
|
548 |
}
|
|
544 | 549 |
auxLegend.setMinFeature(mins[0]); |
545 | 550 |
auxLegend.setMaxFeature(maxs[0]); |
546 | 551 |
|
547 |
} catch (DataException e) {
|
|
548 |
logger.info("Error while creating ProportionalSymbols legend", e);
|
|
549 |
ApplicationLocator.getManager().message(
|
|
550 |
Messages.getText("_Error_while_creating_legend"),
|
|
551 |
JOptionPane.ERROR_MESSAGE);
|
|
552 |
}
|
|
552 |
} catch (DataException e) {
|
|
553 |
logger.info("Error while creating ProportionalSymbols legend", e);
|
|
554 |
ApplicationLocator.getManager().message(
|
|
555 |
Messages.getText("_Error_while_creating_legend"),
|
|
556 |
JOptionPane.ERROR_MESSAGE);
|
|
557 |
}
|
|
553 | 558 |
|
554 |
theLegend = (ProportionalSymbolsLegend) auxLegend.cloneLegend();
|
|
555 |
// theLegend.addSymbol("defaultSymbol", symbol);
|
|
559 |
//Just to avoid empty legend
|
|
560 |
auxLegend.addSymbol(-Double.MAX_VALUE, symbol);
|
|
556 | 561 |
|
557 |
return theLegend; |
|
558 |
} |
|
559 |
/** |
|
560 |
* Creates the String which will be the description of the symbol. If the selected normalization field |
|
561 |
* is not "None", then the String created will have this structure ValueField/NormalizationField. Else, |
|
562 |
* if the user select "None" for the normalization field,the string will show the ValueField only. |
|
563 |
* |
|
564 |
* @return String description for the symbol |
|
565 |
*/ |
|
562 |
if (auxLegend.isPolygonal(this.templateShapeType)) { |
|
563 |
auxLegend.setBackgroundSymbol(getBtnBackground().getSymbol()); |
|
564 |
} |
|
566 | 565 |
|
567 |
private String getSymbolDescription() { |
|
568 |
String description = ""; |
|
566 |
theLegend = (ProportionalSymbolsLegend) auxLegend.cloneLegend(); |
|
569 | 567 |
|
570 |
if (cmbValue.getSelectedItem() != null) |
|
571 |
description += cmbValue.getSelectedItem().toString(); |
|
572 |
if (cmbNormalization.getSelectedItem().toString().compareTo(noNormalization) != 0 ) |
|
573 |
description += " / "+cmbNormalization.getSelectedItem().toString(); |
|
568 |
return theLegend; |
|
569 |
} |
|
574 | 570 |
|
575 |
return description; |
|
576 |
} |
|
571 |
/** |
|
572 |
* Creates the String which will be the description of the symbol. If the |
|
573 |
* selected normalization field is not "None", then the String created will |
|
574 |
* have this structure ValueField/NormalizationField. Else, if the user |
|
575 |
* select "None" for the normalization field,the string will show the |
|
576 |
* ValueField only. |
|
577 |
* |
|
578 |
* @return String description for the symbol |
|
579 |
*/ |
|
580 |
private String getSymbolDescription() { |
|
581 |
String description = ""; |
|
577 | 582 |
|
578 |
public String getDescription() { |
|
579 |
return Messages.getText( |
|
580 |
"draw_quantities_using_symbol_size_to_show_exact_values"); |
|
581 |
} |
|
583 |
if (cmbValue.getSelectedItem() != null) { |
|
584 |
description += cmbValue.getSelectedItem().toString(); |
|
585 |
} |
|
586 |
if (cmbNormalization.getSelectedItem().toString().compareTo(noNormalization) != 0) { |
|
587 |
description += " / " + cmbNormalization.getSelectedItem().toString(); |
|
588 |
} |
|
582 | 589 |
|
583 |
public ImageIcon getIcon() { |
|
584 |
return IconThemeHelper.getImageIcon( |
|
585 |
"legend-overview-proportional-symbols"); |
|
586 |
} |
|
590 |
return description; |
|
591 |
} |
|
587 | 592 |
|
588 |
public Class getParentClass() { |
|
589 |
return Quantities.class; |
|
590 |
} |
|
593 |
public String getDescription() { |
|
594 |
return Messages.getText( |
|
595 |
"draw_quantities_using_symbol_size_to_show_exact_values"); |
|
596 |
} |
|
591 | 597 |
|
592 |
public String getTitle() { |
|
593 |
return Messages.getText("proportional_symbols"); |
|
594 |
} |
|
598 |
public ImageIcon getIcon() { |
|
599 |
return IconThemeHelper.getImageIcon( |
|
600 |
"legend-overview-proportional-symbols"); |
|
601 |
} |
|
595 | 602 |
|
596 |
public Class getLegendClass() {
|
|
597 |
return ProportionalSymbolsLegend.class;
|
|
598 |
}
|
|
603 |
public Class getParentClass() {
|
|
604 |
return Quantities.class;
|
|
605 |
}
|
|
599 | 606 |
|
607 |
public String getTitle() { |
|
608 |
return Messages.getText("proportional_symbols"); |
|
609 |
} |
|
600 | 610 |
|
601 |
public boolean isSuitableFor(FLayer layer) { |
|
602 |
if (layer instanceof FLyrVect) { |
|
611 |
public Class getLegendClass() { |
|
612 |
return ProportionalSymbolsLegend.class; |
|
613 |
} |
|
603 | 614 |
|
604 |
FLyrVect lyr = (FLyrVect) layer; |
|
605 |
try { |
|
606 |
if (lyr.getShapeType() == Geometry.TYPES.GEOMETRY) |
|
607 |
return false; |
|
615 |
public boolean isSuitableFor(FLayer layer) { |
|
616 |
if (layer instanceof FLyrVect) { |
|
608 | 617 |
|
609 |
FeatureStore fsto = (FeatureStore) lyr.getDataStore(); |
|
610 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
611 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors(); |
|
618 |
FLyrVect lyr = (FLyrVect) layer; |
|
619 |
try { |
|
620 |
if (lyr.getShapeType() == Geometry.TYPES.GEOMETRY) { |
|
621 |
return false; |
|
622 |
} |
|
612 | 623 |
|
613 |
for (int i = 0; i < atts.length; i++) { |
|
614 |
if (atts[i].getDataType().isNumeric()) { |
|
615 |
return true; |
|
616 |
} |
|
617 |
} |
|
618 |
} catch (DataException e) { |
|
619 |
logger.info("Error in isSuitableFor", e); |
|
620 |
ApplicationLocator.getManager().message( |
|
621 |
Messages.getText("_Error_while_checking_suitability"), |
|
622 |
JOptionPane.ERROR_MESSAGE); |
|
623 |
return false; |
|
624 |
} |
|
625 |
} |
|
626 |
return false; |
|
627 |
} |
|
624 |
FeatureStore fsto = (FeatureStore) lyr.getDataStore(); |
|
625 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
626 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors(); |
|
628 | 627 |
|
628 |
for (int i = 0; i < atts.length; i++) { |
|
629 |
if (atts[i].getDataType().isNumeric()) { |
|
630 |
return true; |
|
631 |
} |
|
632 |
} |
|
633 |
} catch (DataException e) { |
|
634 |
logger.info("Error in isSuitableFor", e); |
|
635 |
ApplicationLocator.getManager().message( |
|
636 |
Messages.getText("_Error_while_checking_suitability"), |
|
637 |
JOptionPane.ERROR_MESSAGE); |
|
638 |
return false; |
|
639 |
} |
|
640 |
} |
|
641 |
return false; |
|
642 |
} |
|
629 | 643 |
|
630 |
public JPanel getPanel() {
|
|
631 |
return this;
|
|
632 |
}
|
|
644 |
public JPanel getPanel() {
|
|
645 |
return this;
|
|
646 |
}
|
|
633 | 647 |
|
648 |
private ActionListener action = new ActionListener() { |
|
634 | 649 |
|
635 |
private ActionListener action = new ActionListener() {
|
|
650 |
public void actionPerformed(ActionEvent e) {
|
|
636 | 651 |
|
637 |
public void actionPerformed(ActionEvent e) { |
|
652 |
if (e.getSource().equals(cmbValue)) { |
|
653 |
JComboBox cb = (JComboBox) e.getSource(); |
|
654 |
auxLegend.setValueField(cb.getSelectedItem().toString()); |
|
655 |
} |
|
656 |
if (e.getSource().equals(cmbNormalization)) { |
|
657 |
JComboBox cb = (JComboBox) e.getSource(); |
|
658 |
if (cb.getSelectedItem().toString().compareTo(noNormalization) == 0) { |
|
659 |
useNormalization = false; |
|
660 |
auxLegend.setNormalizationField(cmbValue.getSelectedItem().toString()); |
|
661 |
} else { |
|
662 |
useNormalization = true; |
|
663 |
auxLegend.setNormalizationField(cb.getSelectedItem().toString()); |
|
664 |
} |
|
665 |
auxLegend.setUseNormalization(useNormalization); |
|
666 |
} |
|
667 |
if (e.getSource().equals(txtMinSize)) { |
|
668 |
if (txtMaxSize.getDouble() < txtMinSize.getDouble()) { |
|
669 |
txtMaxSize.setDouble(txtMinSize.getDouble()); |
|
670 |
} |
|
671 |
} |
|
672 |
if (e.getSource().equals(txtMaxSize)) { |
|
673 |
if (txtMaxSize.getDouble() < txtMinSize.getDouble()) { |
|
674 |
txtMinSize.setDouble(txtMaxSize.getDouble()); |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
}; |
|
638 | 679 |
|
639 |
if (e.getSource().equals(cmbValue)) { |
|
640 |
JComboBox cb = (JComboBox) e.getSource(); |
|
641 |
auxLegend.setValueField(cb.getSelectedItem().toString()); |
|
642 |
} |
|
643 |
if (e.getSource().equals(cmbNormalization)) { |
|
644 |
JComboBox cb = (JComboBox) e.getSource(); |
|
645 |
if(cb.getSelectedItem().toString().compareTo(noNormalization) == 0) { |
|
646 |
useNormalization = false; |
|
647 |
auxLegend.setNormalizationField(cmbValue.getSelectedItem().toString()); |
|
648 |
} |
|
649 |
else { |
|
650 |
useNormalization = true; |
|
651 |
auxLegend.setNormalizationField(cb.getSelectedItem().toString()); |
|
652 |
} |
|
653 |
auxLegend.setUseNormalization(useNormalization); |
|
654 |
} |
|
655 |
if (e.getSource().equals(txtMinSize)) { |
|
656 |
// ISymbol sym = tmplateSymbol.getSymbol(); |
|
657 |
// if(sym != null) { |
|
658 |
// if(sym instanceof ILineSymbol) { |
|
659 |
// ILineSymbol line = (ILineSymbol)sym; |
|
660 |
// line.setLineWidth(txtMinSize.getDouble()); |
|
661 |
// tmplateSymbol.setSymbol(line); |
|
662 |
// } |
|
663 |
// |
|
664 |
// if(sym instanceof IMarkerSymbol) { |
|
665 |
// IMarkerSymbol point = (IMarkerSymbol)sym; |
|
666 |
// point.setSize(txtMinSize.getDouble()); |
|
667 |
// tmplateSymbol.setSymbol(point); |
|
668 |
// } |
|
669 |
// tmplateSymbol.repaint(); |
|
670 |
// } |
|
671 |
|
|
672 |
if(txtMaxSize.getDouble() < txtMinSize.getDouble()) |
|
673 |
txtMaxSize.setDouble(txtMinSize.getDouble()); |
|
674 |
} |
|
675 |
if(e.getSource().equals(txtMaxSize)) { |
|
676 |
if(txtMaxSize.getDouble() < txtMinSize.getDouble()) |
|
677 |
txtMinSize.setDouble(txtMaxSize.getDouble()); |
|
678 |
} |
|
679 |
// if(e.getSource().equals(tmplateSymbol)) { |
|
680 |
// ISymbol sym = tmplateSymbol.getSymbol(); |
|
681 |
// if(sym != null) { |
|
682 |
// if(sym instanceof ILineSymbol) { |
|
683 |
// ILineSymbol line = (ILineSymbol)sym; |
|
684 |
// txtMinSize.setDouble(((int)line.getLineWidth())); |
|
685 |
// txtMaxSize.setDouble(((int)line.getLineWidth())); |
|
686 |
// } |
|
687 |
// |
|
688 |
// if(sym instanceof IMarkerSymbol) { |
|
689 |
// IMarkerSymbol point = (IMarkerSymbol)sym; |
|
690 |
// txtMinSize.setDouble(((int)point.getSize())); |
|
691 |
// txtMaxSize.setDouble(((int)point.getSize())); |
|
692 |
// |
|
693 |
// } |
|
694 |
// } |
|
695 |
// } |
|
696 |
} |
|
697 |
}; |
|
698 |
|
|
699 | 680 |
} |
Also available in: Unified diff