Revision 3531 org.gvsig.legend.dotdensity.app.mainplugin/trunk/org.gvsig.legend.dotdensity.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/DotDensityPanel.java
DotDensityPanel.java | ||
---|---|---|
39 | 39 |
* dac@iver.es |
40 | 40 |
*/ |
41 | 41 |
|
42 |
/* CVS MESSAGES: |
|
42 |
/* CVS MESSAGES:
|
|
43 | 43 |
* |
44 | 44 |
* $Id: DotDensity.java 15647 2007-10-30 12:03:52Z jmvivo $ |
45 | 45 |
* $Log$ |
... | ... | |
157 | 157 |
import org.gvsig.tools.dispose.DisposableIterator; |
158 | 158 |
|
159 | 159 |
/** |
160 |
* This panel lets the user choose the dot density legend settings |
|
161 |
* (numeric field, density of points, etc)
|
|
160 |
* This panel lets the user choose the dot density legend settings (numeric
|
|
161 |
* field, density of points, etc) |
|
162 | 162 |
* |
163 | 163 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
164 | 164 |
* @param <JNumberSpinner> |
... | ... | |
168 | 168 |
|
169 | 169 |
private static Logger logger = LoggerFactory.getLogger(DotDensityPanel.class); |
170 | 170 |
|
171 |
private static final int MAX_VALUE_COUNT = 300;
|
|
172 |
private FLyrVect layer;
|
|
173 |
private JPanel northPanel = null;
|
|
174 |
private GridBagLayoutPanel densityButtonsPanel = null;
|
|
175 |
private JPanel pnlDensities = null;
|
|
176 |
private JComboBox cmbLegendField = null;
|
|
177 |
private JRadioButton rdBtnHigh = null;
|
|
178 |
private JRadioButton rdBtnMedium = null;
|
|
179 |
private JRadioButton rdBtnLow = null;
|
|
180 |
private JNumberSpinner numDotSize = null;
|
|
171 |
private static final int MAX_VALUE_COUNT = 300;
|
|
172 |
private FLyrVect layer;
|
|
173 |
private JPanel northPanel = null;
|
|
174 |
private GridBagLayoutPanel densityButtonsPanel = null;
|
|
175 |
private JPanel pnlDensities = null;
|
|
176 |
private JComboBox cmbLegendField = null;
|
|
177 |
private JRadioButton rdBtnHigh = null;
|
|
178 |
private JRadioButton rdBtnMedium = null;
|
|
179 |
private JRadioButton rdBtnLow = null;
|
|
180 |
private JNumberSpinner numDotSize = null;
|
|
181 | 181 |
|
182 |
private JNumberSpinner nmbrDotValue = null;
|
|
183 |
private JLabel lblLabellingField = null;
|
|
184 |
private DotDensityLegend legend;
|
|
182 |
private JNumberSpinner nmbrDotValue = null;
|
|
183 |
private JLabel lblLabellingField = null;
|
|
184 |
private DotDensityLegend legend;
|
|
185 | 185 |
|
186 |
private String theFieldName;
|
|
187 |
private int theFieldType;
|
|
186 |
private String theFieldName;
|
|
187 |
private int theFieldType;
|
|
188 | 188 |
|
189 |
private boolean initializing;
|
|
190 |
private double max;
|
|
191 |
private double maxDotSize = 0;
|
|
192 |
private double b, a; // line function params where: y = bx + a
|
|
193 |
private int theValueCount;
|
|
189 |
private boolean initializing;
|
|
190 |
private double max;
|
|
191 |
private double maxDotSize = 0;
|
|
192 |
private double b, a; // line function params where: y = bx + a
|
|
193 |
private int theValueCount;
|
|
194 | 194 |
|
195 |
private NumberFormat nf = NumberFormat.getInstance(); |
|
195 | 196 |
|
196 |
private NumberFormat nf = NumberFormat.getInstance(); |
|
197 |
{ |
|
198 |
nf.setMaximumFractionDigits(3); |
|
199 |
} |
|
200 |
private MyListener cmbAction = new MyListener(); |
|
197 |
{ |
|
198 |
nf.setMaximumFractionDigits(3); |
|
199 |
} |
|
200 |
private MyListener cmbAction = new MyListener(); |
|
201 | 201 |
|
202 |
private class MyListener implements ItemListener, ActionListener { |
|
203 |
public void itemStateChanged(ItemEvent e) { |
|
204 |
if (!initializing) |
|
205 |
doIt(); |
|
206 |
} |
|
202 |
private class MyListener implements ItemListener, ActionListener { |
|
207 | 203 |
|
208 |
public void actionPerformed(ActionEvent e) { |
|
209 |
if (!initializing) |
|
210 |
doIt(); |
|
211 |
} |
|
204 |
public void itemStateChanged(ItemEvent e) { |
|
205 |
if (!initializing) { |
|
206 |
doIt(); |
|
207 |
} |
|
208 |
} |
|
212 | 209 |
|
213 |
private void doIt() { |
|
214 |
int index = cmbLegendField.getSelectedIndex(); |
|
215 |
try { |
|
216 |
FeatureStore fsto = (FeatureStore) layer.getDataStore(); |
|
217 |
FeatureSet fset = fsto.getFeatureSet(); |
|
218 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
210 |
public void actionPerformed(ActionEvent e) { |
|
211 |
if (!initializing) { |
|
212 |
doIt(); |
|
213 |
} |
|
214 |
} |
|
219 | 215 |
|
220 |
if (index != -1) { |
|
221 |
theFieldName = (String) cmbLegendField.getSelectedItem(); |
|
222 |
} else { |
|
223 |
theFieldName = (String) cmbLegendField.getItemAt(0); |
|
224 |
} |
|
216 |
private void doIt() { |
|
217 |
int index = cmbLegendField.getSelectedIndex(); |
|
218 |
try { |
|
219 |
FeatureStore fsto = (FeatureStore) layer.getDataStore(); |
|
220 |
FeatureSet fset = fsto.getFeatureSet(); |
|
221 |
FeatureType fty = fsto.getDefaultFeatureType(); |
|
225 | 222 |
|
226 |
FeatureAttributeDescriptor att = |
|
227 |
fty.getAttributeDescriptor(theFieldName); |
|
223 |
if (index != -1) { |
|
224 |
theFieldName = (String) cmbLegendField.getSelectedItem(); |
|
225 |
} else { |
|
226 |
theFieldName = (String) cmbLegendField.getItemAt(0); |
|
227 |
} |
|
228 |
|
|
229 |
FeatureAttributeDescriptor att |
|
230 |
= fty.getAttributeDescriptor(theFieldName); |
|
228 | 231 |
theFieldType = att.getDataType().getType(); |
229 | 232 |
|
230 |
long vc = 0; |
|
231 |
// (rowCount > MAX_VALUE_COUNT) ? MAX_VALUE_COUNT : (int) rowCount; |
|
233 |
long vc = 0; |
|
232 | 234 |
|
233 |
double maxValue = -Double.MAX_VALUE;
|
|
234 |
double minValue = Double.MAX_VALUE;
|
|
235 |
double maxValue = -Double.MAX_VALUE;
|
|
236 |
double minValue = Double.MAX_VALUE;
|
|
235 | 237 |
|
236 |
DisposableIterator disp = fset.fastIterator();
|
|
237 |
Feature fitem = null;
|
|
238 |
double value = 0;
|
|
238 |
DisposableIterator disp = fset.fastIterator();
|
|
239 |
Feature fitem = null;
|
|
240 |
double value = 0;
|
|
239 | 241 |
|
240 |
int i = 0;
|
|
241 |
while (i < MAX_VALUE_COUNT && disp.hasNext()) {
|
|
242 |
int i = 0;
|
|
243 |
while (i < MAX_VALUE_COUNT && disp.hasNext()) {
|
|
242 | 244 |
|
243 |
fitem = (Feature) disp.next();
|
|
244 |
value = fitem.getDouble(theFieldName);
|
|
245 |
if (value < minValue){ |
|
245 |
fitem = (Feature) disp.next();
|
|
246 |
value = fitem.getDouble(theFieldName);
|
|
247 |
if (value < minValue) {
|
|
246 | 248 |
minValue = value; |
247 | 249 |
} |
248 |
if (value > maxValue){ |
|
250 |
if (value > maxValue) {
|
|
249 | 251 |
maxValue = value; |
250 | 252 |
} |
251 |
// ==========
|
|
252 |
i++;
|
|
253 |
}
|
|
254 |
disp.dispose();
|
|
255 |
theValueCount = i;
|
|
256 |
if (theValueCount == 0) {
|
|
257 |
b = 0;
|
|
258 |
a = minValue;
|
|
259 |
} else {
|
|
260 |
b = (maxValue - minValue)/(theValueCount);
|
|
261 |
a = minValue;
|
|
262 |
}
|
|
263 |
buttonsListener.actionPerformed(null);
|
|
253 |
// ==========
|
|
254 |
i++;
|
|
255 |
}
|
|
256 |
disp.dispose();
|
|
257 |
theValueCount = i;
|
|
258 |
if (theValueCount == 0) {
|
|
259 |
b = 0;
|
|
260 |
a = minValue;
|
|
261 |
} else {
|
|
262 |
b = (maxValue - minValue) / (theValueCount);
|
|
263 |
a = minValue;
|
|
264 |
}
|
|
265 |
buttonsListener.actionPerformed(null);
|
|
264 | 266 |
|
265 |
} catch (Exception ex) {
|
|
266 |
logger.info("Error while computing a,b.", ex);
|
|
267 |
} catch (Exception ex) {
|
|
268 |
logger.info("Error while computing a,b.", ex);
|
|
267 | 269 |
|
268 |
ApplicationLocator.getManager().message(
|
|
269 |
Messages.getText("error") +
|
|
270 |
" (" + Messages.getText("dot_density") + ")\n\n"
|
|
271 |
+ ex.getMessage(),
|
|
272 |
JOptionPane.ERROR_MESSAGE);
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
270 |
ApplicationLocator.getManager().message(
|
|
271 |
Messages.getText("error")
|
|
272 |
+ " (" + Messages.getText("dot_density") + ")\n\n"
|
|
273 |
+ ex.getMessage(),
|
|
274 |
JOptionPane.ERROR_MESSAGE);
|
|
275 |
}
|
|
276 |
}
|
|
277 |
}
|
|
276 | 278 |
|
279 |
private ActionListener buttonsListener = new ActionListener() { |
|
280 |
public void actionPerformed(ActionEvent e) { |
|
281 |
int oldValue = getSldDensity().getValue(); |
|
282 |
int newValue = 0; |
|
283 |
if (getRdBtnHigh().isSelected()) { |
|
284 |
newValue = 33; |
|
285 |
} else if (getRdBtnLow().isSelected()) { |
|
286 |
newValue = 66; |
|
287 |
} else if (getRdBtnMedium().isSelected()) { |
|
288 |
newValue = 50; |
|
289 |
} |
|
290 |
if (oldValue == newValue) { |
|
291 |
sldListener.stateChanged(null); |
|
292 |
} else { |
|
293 |
getSldDensity().setValue(newValue); |
|
294 |
} |
|
295 |
} |
|
296 |
}; |
|
297 |
private JPanel centerPanel = null; |
|
298 |
private JSlider sldDensity = null; |
|
277 | 299 |
|
278 |
private ActionListener buttonsListener = new ActionListener() { |
|
279 |
public void actionPerformed(ActionEvent e) { |
|
280 |
int oldValue = getSldDensity().getValue(); |
|
281 |
int newValue = 0; |
|
282 |
if (getRdBtnHigh().isSelected()) { |
|
283 |
newValue = 33; |
|
284 |
} else if (getRdBtnLow().isSelected()) { |
|
285 |
newValue = 66; |
|
286 |
} else if (getRdBtnMedium().isSelected()) { |
|
287 |
newValue = 50; |
|
288 |
} |
|
289 |
if (oldValue == newValue){ |
|
290 |
sldListener.stateChanged(null); |
|
291 |
} else{ |
|
292 |
getSldDensity().setValue(newValue); |
|
293 |
} |
|
294 |
} |
|
295 |
}; |
|
296 |
private JPanel centerPanel = null; |
|
297 |
private JSlider sldDensity = null; |
|
300 |
private boolean dotValueChanging = false; |
|
298 | 301 |
|
299 |
private boolean dotValueChanging= false; |
|
302 |
private ChangeListener sldListener = new ChangeListener() { |
|
303 |
public void stateChanged(ChangeEvent e) { |
|
304 |
if (dotValueChanging) { |
|
305 |
return; |
|
306 |
} |
|
300 | 307 |
|
301 |
private ChangeListener sldListener = new ChangeListener() { |
|
302 |
public void stateChanged(ChangeEvent e) { |
|
303 |
if (dotValueChanging){ |
|
304 |
return; |
|
305 |
} |
|
306 |
|
|
307 |
dotValueChanging = true; |
|
308 |
double d = sldValueToDotValue(getSldDensity().getValue()); |
|
308 |
dotValueChanging = true; |
|
309 |
double d = sldValueToDotValue(getSldDensity().getValue()); |
|
309 | 310 |
nmbrDotValue.setDouble(d); |
310 |
dotValueChanging = false;
|
|
311 |
}
|
|
311 |
dotValueChanging = false;
|
|
312 |
}
|
|
312 | 313 |
|
313 |
};
|
|
314 |
};
|
|
314 | 315 |
|
316 |
private ActionListener nmbrDotValueListener = new ActionListener() { |
|
317 |
public void actionPerformed(ActionEvent e) { |
|
318 |
if (dotValueChanging) { |
|
319 |
return; |
|
320 |
} |
|
315 | 321 |
|
316 |
private ActionListener nmbrDotValueListener = new ActionListener(){ |
|
317 |
public void actionPerformed(ActionEvent e) { |
|
318 |
if (dotValueChanging){ |
|
319 |
return; |
|
320 |
} |
|
322 |
dotValueChanging = true; |
|
323 |
double dotValue = getNmbrDotValue().getDouble(); |
|
324 |
if (dotValue < 0) { |
|
325 |
dotValue = 0; |
|
326 |
} |
|
327 |
int result = dotValueToSldValue(dotValue); |
|
328 |
getSldDensity().setValue(result); |
|
329 |
dotValueChanging = false; |
|
330 |
} |
|
331 |
}; |
|
321 | 332 |
|
322 |
dotValueChanging = true; |
|
323 |
double dotValue = getNmbrDotValue().getDouble(); |
|
324 |
if (dotValue < 0) dotValue = 0; |
|
325 |
int result = dotValueToSldValue(dotValue); |
|
326 |
getSldDensity().setValue(result); |
|
327 |
dotValueChanging = false; |
|
328 |
} |
|
329 |
}; |
|
333 |
private ColorChooserPanel jcc; |
|
334 |
private ILegend oldLegend; |
|
335 |
private JSymbolPreviewButton btnOutline; |
|
336 |
private ColorChooserPanel jccBackground; |
|
330 | 337 |
|
331 |
private ColorChooserPanel jcc;
|
|
332 |
private ILegend oldLegend;
|
|
333 |
private JSymbolPreviewButton btnOutline;
|
|
334 |
private ColorChooserPanel jccBackground;
|
|
338 |
public DotDensityPanel() {
|
|
339 |
super();
|
|
340 |
initialize();
|
|
341 |
}
|
|
335 | 342 |
|
336 |
public DotDensityPanel() { |
|
337 |
super(); |
|
338 |
initialize(); |
|
339 |
} |
|
343 |
/** |
|
344 |
* This method initializes this |
|
345 |
* |
|
346 |
*/ |
|
347 |
private void initialize() { |
|
348 |
this.setLayout(new BorderLayout()); |
|
349 |
this.setSize(new java.awt.Dimension(492, 278)); |
|
350 |
this.add(getNorthPanel(), java.awt.BorderLayout.NORTH); |
|
351 |
this.add(getCenterPanel(), java.awt.BorderLayout.CENTER); |
|
352 |
} |
|
340 | 353 |
|
341 |
/** |
|
342 |
* This method initializes this |
|
343 |
* |
|
344 |
*/ |
|
345 |
private void initialize() { |
|
346 |
this.setLayout(new BorderLayout()); |
|
347 |
this.setSize(new java.awt.Dimension(492,278)); |
|
348 |
this.add(getNorthPanel(), java.awt.BorderLayout.NORTH); |
|
349 |
this.add(getCenterPanel(), java.awt.BorderLayout.CENTER); |
|
350 |
} |
|
354 |
private double sldValueToDotValue(int value) { |
|
355 |
int quantileIndex = (theValueCount * value) / 100; |
|
356 |
double d = (b * quantileIndex + a); // /50; // ?por qu? el 50? |
|
357 |
return d; |
|
358 |
} |
|
351 | 359 |
|
352 |
private double sldValueToDotValue(int value){
|
|
353 |
int quantileIndex = (theValueCount*value)/100;
|
|
354 |
double d = (b*quantileIndex+a); // /50; // ?por qu? el 50?
|
|
355 |
return d;
|
|
356 |
}
|
|
360 |
private int dotValueToSldValue(double value) {
|
|
361 |
int quantileIndex = (int) Math.round((value - a) / b);
|
|
362 |
int result = 100 * quantileIndex / theValueCount;
|
|
363 |
return result;
|
|
364 |
}
|
|
357 | 365 |
|
358 |
private int dotValueToSldValue(double value){ |
|
359 |
int quantileIndex = (int)Math.round((value-a)/b); |
|
360 |
int result = 100*quantileIndex/theValueCount; |
|
361 |
return result; |
|
362 |
} |
|
363 |
|
|
364 |
public void setData(FLayer lyr, ILegend legend) { |
|
365 |
this.layer = (FLyrVect) lyr; |
|
366 |
public void setData(FLayer lyr, ILegend legend) { |
|
367 |
this.layer = (FLyrVect) lyr; |
|
366 | 368 |
this.oldLegend = legend.cloneLegend(); |
367 | 369 |
|
368 |
try {
|
|
369 |
// Para evitar los campos no pertenecientes a la fuente original de la capa.
|
|
370 |
// SelectableDataSource sds = layer.getSource().getRecordset();
|
|
371 |
// FJP: Otra vez con soporte del join
|
|
372 |
// SelectableDataSource sds = layer.getRecordset();
|
|
370 |
try {
|
|
371 |
// Para evitar los campos no pertenecientes a la fuente original de la capa.
|
|
372 |
// SelectableDataSource sds = layer.getSource().getRecordset();
|
|
373 |
// FJP: Otra vez con soporte del join
|
|
374 |
// SelectableDataSource sds = layer.getRecordset();
|
|
373 | 375 |
FeatureStore fsto = (FeatureStore) layer.getDataStore(); |
374 | 376 |
FeatureType fty = fsto.getDefaultFeatureType(); |
375 | 377 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors(); |
376 | 378 |
|
377 |
initializing = true; // silents events to the combo box
|
|
378 |
cmbLegendField.removeAllItems();
|
|
379 |
for (int i = 0; i < atts.length; i++) {
|
|
380 |
if (atts[i].getDataType().isNumeric()) {
|
|
381 |
cmbLegendField.addItem(atts[i].getName());
|
|
382 |
}
|
|
383 |
}
|
|
379 |
initializing = true; // silents events to the combo box
|
|
380 |
cmbLegendField.removeAllItems();
|
|
381 |
for (int i = 0; i < atts.length; i++) {
|
|
382 |
if (atts[i].getDataType().isNumeric()) {
|
|
383 |
cmbLegendField.addItem(atts[i].getName());
|
|
384 |
}
|
|
385 |
}
|
|
384 | 386 |
|
385 |
if (!(legend instanceof DotDensityLegend)) {
|
|
386 |
legend = new DotDensityLegend();
|
|
387 |
((DotDensityLegend) legend).setClassifyingFieldNames(
|
|
388 |
new String[] {(String) cmbLegendField.getItemAt(0)});
|
|
389 |
((DotDensityLegend) legend).setShapeType(layer.getShapeType());
|
|
390 |
}
|
|
387 |
if (!(legend instanceof DotDensityLegend)) {
|
|
388 |
legend = new DotDensityLegend();
|
|
389 |
((DotDensityLegend) legend).setClassifyingFieldNames(
|
|
390 |
new String[]{(String) cmbLegendField.getItemAt(0)});
|
|
391 |
((DotDensityLegend) legend).setShapeType(layer.getShapeType());
|
|
392 |
}
|
|
391 | 393 |
|
392 |
DotDensityLegend theLegend = (DotDensityLegend) legend;
|
|
394 |
DotDensityLegend theLegend = (DotDensityLegend) legend;
|
|
393 | 395 |
|
394 |
initializing = false; // enables events to the combo box
|
|
396 |
initializing = false; // enables events to the combo box
|
|
395 | 397 |
|
396 |
cmbLegendField.setSelectedItem(theLegend.getClassifyingFieldNames()[0]);
|
|
397 |
try {
|
|
398 |
getDotColorChooserPanel().setColor(theLegend.getDotColor());
|
|
399 |
} catch (NullPointerException npEx) {
|
|
400 |
getDotColorChooserPanel().setColor(Color.RED);
|
|
401 |
}
|
|
402 |
try {
|
|
403 |
getBackgroundColorChooserPanel().setColor(theLegend.getBGColor());
|
|
404 |
} catch (NullPointerException npEx) {
|
|
405 |
getDotColorChooserPanel().setColor(Color.WHITE);
|
|
406 |
}
|
|
398 |
cmbLegendField.setSelectedItem(theLegend.getClassifyingFieldNames()[0]);
|
|
399 |
try {
|
|
400 |
getDotColorChooserPanel().setColor(theLegend.getDotColor());
|
|
401 |
} catch (NullPointerException npEx) {
|
|
402 |
getDotColorChooserPanel().setColor(Color.RED);
|
|
403 |
}
|
|
404 |
try {
|
|
405 |
getBackgroundColorChooserPanel().setColor(theLegend.getBGColor());
|
|
406 |
} catch (NullPointerException npEx) {
|
|
407 |
getDotColorChooserPanel().setColor(Color.WHITE);
|
|
408 |
}
|
|
407 | 409 |
|
408 |
getBtnOutline().setSymbol(theLegend.getOutline()); |
|
409 |
try { |
|
410 |
double dotValue = theLegend.getDotValue(); |
|
411 |
if (dotValue <= 0) |
|
412 |
dotValue = sldValueToDotValue(50);//100; |
|
413 |
getNmbrDotValue().setDouble(dotValue); |
|
414 |
dotValueChanging = true; |
|
415 |
getSldDensity().setValue(dotValueToSldValue(dotValue)); |
|
416 |
dotValueChanging = false; |
|
410 |
getBtnOutline().setSymbol(theLegend.getOutline()); |
|
411 |
try { |
|
412 |
double dotValue = theLegend.getDotValue(); |
|
413 |
if (dotValue <= 0) { |
|
414 |
dotValue = sldValueToDotValue(50);//100; |
|
415 |
} |
|
416 |
getNmbrDotValue().setDouble(dotValue); |
|
417 |
dotValueChanging = true; |
|
418 |
getSldDensity().setValue(dotValueToSldValue(dotValue)); |
|
419 |
dotValueChanging = false; |
|
417 | 420 |
|
418 |
} catch (NullPointerException npEx) { |
|
419 |
getSldDensity().setValue(50); |
|
420 |
} |
|
421 |
try { |
|
422 |
double dotSize = theLegend.getDotSize(); |
|
423 |
if (dotSize <= 0) |
|
424 |
dotSize = 2; |
|
425 |
getNumDotSize().setDouble(dotSize); |
|
426 |
} catch (NullPointerException npEx) { |
|
427 |
getNumDotSize().setDouble(3); |
|
428 |
} |
|
421 |
} catch (NullPointerException npEx) { |
|
422 |
getSldDensity().setValue(50); |
|
423 |
} |
|
424 |
try { |
|
425 |
double dotSize = theLegend.getDotSize(); |
|
426 |
if (dotSize <= 0) { |
|
427 |
dotSize = 2; |
|
428 |
} |
|
429 |
getNumDotSize().setDouble(dotSize); |
|
430 |
} catch (NullPointerException npEx) { |
|
431 |
getNumDotSize().setDouble(3); |
|
432 |
} |
|
429 | 433 |
|
430 |
} catch (Exception e) {
|
|
431 |
e.printStackTrace();
|
|
432 |
}
|
|
433 |
}
|
|
434 |
} catch (Exception e) {
|
|
435 |
e.printStackTrace();
|
|
436 |
}
|
|
437 |
}
|
|
434 | 438 |
|
435 |
public ILegend getLegend() {
|
|
436 |
try {
|
|
437 |
int shapeType = layer.getShapeType();
|
|
439 |
public ILegend getLegend() {
|
|
440 |
try {
|
|
441 |
int shapeType = layer.getShapeType();
|
|
438 | 442 |
|
439 |
// shapeType should be always polygon
|
|
440 |
if (!DotDensityLegend.isPolygonal(shapeType)) {
|
|
443 |
// shapeType should be always polygon
|
|
444 |
if (!DotDensityLegend.isPolygonal(shapeType)) {
|
|
441 | 445 |
|
442 | 446 |
ApplicationLocator.getManager().message( |
443 |
Messages.getText("cannot_apply_to_a_non_polygon_layer"), |
|
444 |
JOptionPane.ERROR_MESSAGE); |
|
447 |
Messages.getText("cannot_apply_to_a_non_polygon_layer"),
|
|
448 |
JOptionPane.ERROR_MESSAGE);
|
|
445 | 449 |
return null; |
446 |
}
|
|
450 |
}
|
|
447 | 451 |
|
448 |
// gather values |
|
449 |
double dotValue; |
|
450 |
double dotSize; |
|
451 |
try { |
|
452 |
// dotValue = Double.parseDouble(nmbrDotValue.getText()); |
|
453 |
dotValue = nmbrDotValue.getDouble(); |
|
454 |
} catch (Exception e) { |
|
455 |
// dotValue = nf.parse(nmbrDotValue.getText()).doubleValue(); |
|
456 |
dotValue = nmbrDotValue.getDouble(); |
|
457 |
} |
|
458 |
if (dotValue == 0) |
|
459 |
dotValue = 1; |
|
460 |
try { |
|
461 |
// dotSize = Double.parseDouble(numDotSize.getText()); |
|
462 |
dotSize = numDotSize.getDouble(); |
|
463 |
} catch (Exception e) { |
|
464 |
// dotSize = nf.parse(numDotSize.getText()).doubleValue(); |
|
465 |
dotSize = numDotSize.getDouble(); |
|
466 |
} |
|
452 |
// gather values |
|
453 |
double dotValue; |
|
454 |
double dotSize; |
|
455 |
try { |
|
456 |
dotValue = nmbrDotValue.getDouble(); |
|
457 |
} catch (Exception e) { |
|
458 |
dotValue = nmbrDotValue.getDouble(); |
|
459 |
} |
|
460 |
if (dotValue == 0) { |
|
461 |
dotValue = 1; |
|
462 |
} |
|
463 |
try { |
|
464 |
dotSize = numDotSize.getDouble(); |
|
465 |
} catch (Exception e) { |
|
466 |
dotSize = numDotSize.getDouble(); |
|
467 |
} |
|
467 | 468 |
|
468 |
if (max/dotValue > 50000) { |
|
469 |
int option = JOptionPane.showConfirmDialog(this, |
|
470 |
Messages.getText("looks_like_too_low_value_for_this_field_may_cause_system_to_run_slow"), |
|
471 |
Messages.getText("warning"), |
|
472 |
JOptionPane.OK_CANCEL_OPTION); |
|
473 |
if (option == JOptionPane.CANCEL_OPTION) |
|
474 |
return oldLegend; |
|
475 |
} |
|
469 |
if (max / dotValue > 50000) { |
|
470 |
int option = JOptionPane.showConfirmDialog(this, |
|
471 |
Messages.getText("looks_like_too_low_value_for_this_field_may_cause_system_to_run_slow"), |
|
472 |
Messages.getText("warning"), |
|
473 |
JOptionPane.OK_CANCEL_OPTION); |
|
474 |
if (option == JOptionPane.CANCEL_OPTION) { |
|
475 |
return oldLegend; |
|
476 |
} |
|
477 |
} |
|
476 | 478 |
|
477 |
// create the density symbol with the values set above
|
|
478 |
DotDensityFillSymbol densitySymbol = new DotDensityFillSymbol();
|
|
479 |
densitySymbol.setDotSize(dotSize);
|
|
480 |
densitySymbol.setDotColor(getDotColorChooserPanel().getColor());
|
|
479 |
// create the density symbol with the values set above
|
|
480 |
DotDensityFillSymbol densitySymbol = new DotDensityFillSymbol();
|
|
481 |
densitySymbol.setDotSize(dotSize);
|
|
482 |
densitySymbol.setDotColor(getDotColorChooserPanel().getColor());
|
|
481 | 483 |
|
482 |
// create a simple-fill symbol over which the dot density will be drawn
|
|
483 |
SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
|
|
484 |
fillSymbol.setFillColor(getBackgroundColorChooserPanel().getColor());
|
|
485 |
fillSymbol.setOutline((ILineSymbol) getBtnOutline().getSymbol());
|
|
484 |
// create a simple-fill symbol over which the dot density will be drawn
|
|
485 |
SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
|
|
486 |
fillSymbol.setFillColor(getBackgroundColorChooserPanel().getColor());
|
|
487 |
fillSymbol.setOutline((ILineSymbol) getBtnOutline().getSymbol());
|
|
486 | 488 |
|
487 |
// combine both the DotDensitySymbol and the SimpleFillSymbol in
|
|
488 |
// MultiLayerSymbol so they will be paint as a unique ISymbol
|
|
489 |
MultiLayerFillSymbol symbol = new MultiLayerFillSymbol();
|
|
490 |
symbol.setDescription(
|
|
491 |
"DotDensitySymbol" + Messages.getText("in_layer") +
|
|
492 |
": '"+layer.getName()+"'");
|
|
493 |
symbol.addLayer(fillSymbol);
|
|
494 |
symbol.addLayer(densitySymbol);
|
|
489 |
// combine both the DotDensitySymbol and the SimpleFillSymbol in
|
|
490 |
// MultiLayerSymbol so they will be paint as a unique ISymbol
|
|
491 |
MultiLayerFillSymbol symbol = new MultiLayerFillSymbol();
|
|
492 |
symbol.setDescription(
|
|
493 |
"DotDensitySymbol" + Messages.getText("in_layer")
|
|
494 |
+ ": '" + layer.getName() + "'");
|
|
495 |
symbol.addLayer(fillSymbol);
|
|
496 |
symbol.addLayer(densitySymbol);
|
|
495 | 497 |
|
496 |
legend = new DotDensityLegend(); |
|
497 |
legend.addSymbol(Messages.getText("theSymbol"), symbol); |
|
498 |
legend.setDefaultSymbol(symbol); |
|
499 |
legend.setDotValue(dotValue); |
|
498 |
legend = new DotDensityLegend(); |
|
499 |
legend.setClassifyingFieldNames(new String[]{theFieldName}); |
|
500 |
legend.setClassifyingFieldTypes(new int[]{theFieldType}); |
|
500 | 501 |
|
501 |
legend.setClassifyingFieldNames(new String[] { theFieldName }); |
|
502 |
legend.setClassifyingFieldTypes(new int[] { theFieldType }); |
|
502 |
legend.addSymbol(0, symbol); |
|
503 |
legend.setDefaultSymbol(symbol); |
|
504 |
legend.setDotValue(dotValue); |
|
503 | 505 |
|
504 |
legend.setBGColor(getBackgroundColorChooserPanel().getColor());
|
|
505 |
legend.setDotColor(getDotColorChooserPanel().getColor());
|
|
506 |
legend.setBGColor(getBackgroundColorChooserPanel().getColor());
|
|
507 |
legend.setDotColor(getDotColorChooserPanel().getColor());
|
|
506 | 508 |
|
507 |
} catch (Exception e) { |
|
509 |
} catch (Exception e) { |
|
510 |
logger.warn(Messages.getText("could_not_setup_legend"), e); |
|
511 |
} |
|
512 |
return legend; |
|
508 | 513 |
|
509 |
ApplicationLocator.getManager().message( |
|
510 |
Messages.getText("could_not_setup_legend"), |
|
511 |
JOptionPane.ERROR_MESSAGE); |
|
512 |
} |
|
513 |
return legend; |
|
514 |
} |
|
514 | 515 |
|
515 |
} |
|
516 |
/** |
|
517 |
* This method initializes centerPanel |
|
518 |
* |
|
519 |
* @return javax.swing.JPanel |
|
520 |
*/ |
|
521 |
private JPanel getNorthPanel() { |
|
522 |
if (northPanel == null) { |
|
523 |
lblLabellingField = new JLabel(); |
|
524 |
lblLabellingField.setText(Messages.getText("labeling_field") + "."); |
|
525 |
northPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 0)); |
|
526 |
northPanel.add(lblLabellingField, null); |
|
527 |
northPanel.add(getCmbLegendField(), null); |
|
516 | 528 |
|
517 |
/** |
|
518 |
* This method initializes centerPanel |
|
519 |
* |
|
520 |
* @return javax.swing.JPanel |
|
521 |
*/ |
|
522 |
private JPanel getNorthPanel() { |
|
523 |
if (northPanel == null) { |
|
524 |
lblLabellingField = new JLabel(); |
|
525 |
lblLabellingField.setText(Messages.getText("labeling_field")+"."); |
|
526 |
northPanel = new JPanel(new FlowLayout(FlowLayout.LEADING,15,0)); |
|
527 |
northPanel.add(lblLabellingField, null); |
|
528 |
northPanel.add(getCmbLegendField(), null); |
|
529 |
} |
|
530 |
return northPanel; |
|
531 |
} |
|
529 | 532 |
|
530 |
} |
|
531 |
return northPanel; |
|
532 |
} |
|
533 |
private ColorChooserPanel getDotColorChooserPanel() { |
|
534 |
if (jcc == null) { |
|
535 |
jcc = new ColorChooserPanel(); |
|
536 |
jcc.setAlpha(255); |
|
537 |
} |
|
538 |
return jcc; |
|
539 |
} |
|
533 | 540 |
|
534 |
private ColorChooserPanel getDotColorChooserPanel() { |
|
535 |
if (jcc == null) { |
|
536 |
jcc = new ColorChooserPanel() ; |
|
537 |
jcc.setAlpha(255); |
|
538 |
} |
|
539 |
return jcc; |
|
540 |
} |
|
541 |
/** |
|
542 |
* This method initializes southPanel |
|
543 |
* |
|
544 |
* @return javax.swing.JPanel |
|
545 |
*/ |
|
546 |
private JPanel getDensityButtonsPanel() { |
|
547 |
if (densityButtonsPanel == null) { |
|
548 |
densityButtonsPanel = new GridBagLayoutPanel(); |
|
549 |
LayoutManager layout = new FlowLayout(FlowLayout.LEADING, 0, 0); |
|
550 |
JPanel aux = new JPanel(layout); |
|
551 |
aux.add(getNumDotSize()); |
|
552 |
densityButtonsPanel.addComponent( |
|
553 |
Messages.getText("dot_size"), aux); |
|
554 |
aux = new JPanel(layout); |
|
555 |
aux.add(getNmbrDotValue()); |
|
556 |
densityButtonsPanel.addComponent( |
|
557 |
Messages.getText("dot_value"), aux); |
|
558 |
aux = new JPanel(layout); |
|
559 |
aux.add(getDotColorChooserPanel()); |
|
560 |
densityButtonsPanel.addComponent( |
|
561 |
Messages.getText("color"), aux); |
|
562 |
aux = new JPanel(layout); |
|
563 |
aux.add(getBackgroundColorChooserPanel()); |
|
564 |
densityButtonsPanel.addComponent( |
|
565 |
Messages.getText("background_color"), aux); |
|
566 |
aux = new JPanel(layout); |
|
567 |
aux.add(getBtnOutline()); |
|
568 |
densityButtonsPanel.addComponent( |
|
569 |
Messages.getText("outline"), aux); |
|
570 |
} |
|
571 |
return densityButtonsPanel; |
|
572 |
} |
|
541 | 573 |
|
542 |
/** |
|
543 |
* This method initializes southPanel |
|
544 |
* |
|
545 |
* @return javax.swing.JPanel |
|
546 |
*/ |
|
547 |
private JPanel getDensityButtonsPanel() { |
|
548 |
if (densityButtonsPanel == null) { |
|
549 |
densityButtonsPanel = new GridBagLayoutPanel(); |
|
550 |
LayoutManager layout = new FlowLayout(FlowLayout.LEADING, 0,0); |
|
551 |
JPanel aux = new JPanel(layout); |
|
552 |
aux.add(getNumDotSize()); |
|
553 |
densityButtonsPanel.addComponent( |
|
554 |
Messages.getText("dot_size"), aux); |
|
555 |
aux = new JPanel(layout); |
|
556 |
aux.add(getNmbrDotValue()); |
|
557 |
densityButtonsPanel.addComponent( |
|
558 |
Messages.getText("dot_value"), aux); |
|
559 |
aux = new JPanel(layout); |
|
560 |
aux.add(getDotColorChooserPanel()); |
|
561 |
densityButtonsPanel.addComponent( |
|
562 |
Messages.getText("color"), aux); |
|
563 |
aux = new JPanel(layout); |
|
564 |
aux.add(getBackgroundColorChooserPanel()); |
|
565 |
densityButtonsPanel.addComponent( |
|
566 |
Messages.getText("background_color"), aux); |
|
567 |
aux = new JPanel(layout); |
|
568 |
aux.add(getBtnOutline()); |
|
569 |
densityButtonsPanel.addComponent( |
|
570 |
Messages.getText("outline"), aux); |
|
571 |
} |
|
572 |
return densityButtonsPanel; |
|
573 |
} |
|
574 |
private ColorChooserPanel getBackgroundColorChooserPanel() { |
|
575 |
if (jccBackground == null) { |
|
576 |
jccBackground = new ColorChooserPanel(); |
|
577 |
jccBackground.setColor(Color.WHITE); |
|
578 |
jccBackground.setAlpha(255); |
|
579 |
} |
|
580 |
return jccBackground; |
|
581 |
} |
|
574 | 582 |
|
575 |
private ColorChooserPanel getBackgroundColorChooserPanel() { |
|
576 |
if (jccBackground == null) { |
|
577 |
jccBackground = new ColorChooserPanel() ; |
|
578 |
jccBackground.setColor(Color.WHITE); |
|
579 |
jccBackground.setAlpha(255); |
|
580 |
} |
|
581 |
return jccBackground; |
|
582 |
} |
|
583 |
private JSymbolPreviewButton getBtnOutline() { |
|
584 |
if (btnOutline == null) { |
|
585 |
btnOutline = new JSymbolPreviewButton(Geometry.TYPES.CURVE); |
|
586 |
btnOutline.setPreferredSize(new Dimension(100, 35)); |
|
587 |
} |
|
588 |
return btnOutline; |
|
589 |
} |
|
583 | 590 |
|
584 |
private JSymbolPreviewButton getBtnOutline() { |
|
585 |
if (btnOutline == null) { |
|
586 |
btnOutline = new JSymbolPreviewButton(Geometry.TYPES.CURVE); |
|
587 |
btnOutline.setPreferredSize(new Dimension(100, 35)); |
|
588 |
} |
|
589 |
return btnOutline; |
|
590 |
} |
|
591 |
/** |
|
592 |
* This method initializes pnlDensities |
|
593 |
* |
|
594 |
* @return javax.swing.JPanel |
|
595 |
*/ |
|
596 |
private JPanel getPnlDensities() { |
|
597 |
if (pnlDensities == null) { |
|
598 |
pnlDensities = new JPanel(new BorderLayout(5, 0)); |
|
599 |
pnlDensities.setBorder(BorderFactory.createTitledBorder(null, |
|
600 |
Messages.getText("densities"))); |
|
601 |
JPanel aux2 = new JPanel(); |
|
602 |
JPanel aux; |
|
603 |
aux = new JPanel(new GridLayout(1, 3)); |
|
604 |
aux.add(new JLabel(Messages.getText("low"))); |
|
605 |
aux.add(new JLabel(Messages.getText("medium"))); |
|
606 |
aux.add(new JLabel(Messages.getText("high"))); |
|
591 | 607 |
|
592 |
/** |
|
593 |
* This method initializes pnlDensities |
|
594 |
* |
|
595 |
* @return javax.swing.JPanel |
|
596 |
*/ |
|
597 |
private JPanel getPnlDensities() { |
|
598 |
if (pnlDensities == null) { |
|
599 |
pnlDensities = new JPanel(new BorderLayout(5,0)); |
|
600 |
pnlDensities.setBorder(BorderFactory.createTitledBorder(null, |
|
601 |
Messages.getText("densities"))); |
|
602 |
JPanel aux2 = new JPanel(); |
|
603 |
JPanel aux; |
|
604 |
aux = new JPanel(new GridLayout(1,3)); |
|
605 |
aux.add(new JLabel(Messages.getText("low"))); |
|
606 |
aux.add(new JLabel(Messages.getText("medium"))); |
|
607 |
aux.add(new JLabel(Messages.getText("high"))); |
|
608 |
aux2.add(aux); |
|
608 | 609 |
|
609 |
aux2.add(aux); |
|
610 |
aux = new JPanel(new GridLayout(1, 3)); |
|
611 |
aux.add(getRdBtnLow()); |
|
612 |
aux.add(getRdBtnMedium()); |
|
613 |
aux.add(getRdBtnHigh()); |
|
610 | 614 |
|
611 |
aux = new JPanel(new GridLayout(1,3)); |
|
612 |
aux.add(getRdBtnLow()); |
|
613 |
aux.add(getRdBtnMedium()); |
|
614 |
aux.add(getRdBtnHigh()); |
|
615 |
aux2.add(aux); |
|
616 |
aux2.setLayout(new BoxLayout(aux2, BoxLayout.Y_AXIS)); |
|
615 | 617 |
|
616 |
aux2.add(aux); |
|
617 |
aux2.setLayout(new BoxLayout(aux2, BoxLayout.Y_AXIS)); |
|
618 |
pnlDensities.add(aux2, BorderLayout.NORTH); |
|
619 |
pnlDensities.add(getSldDensity(), BorderLayout.CENTER); |
|
620 |
pnlDensities.add(getDensityButtonsPanel(), BorderLayout.SOUTH); |
|
618 | 621 |
|
619 |
pnlDensities.add(aux2, BorderLayout.NORTH); |
|
620 |
pnlDensities.add(getSldDensity(), BorderLayout.CENTER); |
|
621 |
pnlDensities.add(getDensityButtonsPanel(), BorderLayout.SOUTH); |
|
622 |
ButtonGroup group = new ButtonGroup(); |
|
623 |
group.add(getRdBtnHigh()); |
|
624 |
group.add(getRdBtnLow()); |
|
625 |
group.add(getRdBtnMedium()); |
|
626 |
getRdBtnMedium().setSelected(true); |
|
627 |
} |
|
628 |
return pnlDensities; |
|
629 |
} |
|
622 | 630 |
|
623 |
ButtonGroup group = new ButtonGroup(); |
|
624 |
group.add(getRdBtnHigh()); |
|
625 |
group.add(getRdBtnLow()); |
|
626 |
group.add(getRdBtnMedium()); |
|
627 |
getRdBtnMedium().setSelected(true); |
|
628 |
} |
|
629 |
return pnlDensities; |
|
630 |
} |
|
631 |
/** |
|
632 |
* This method initializes cmbLegendField |
|
633 |
* |
|
634 |
* @return javax.swing.JComboBox |
|
635 |
*/ |
|
636 |
private JComboBox getCmbLegendField() { |
|
637 |
if (cmbLegendField == null) { |
|
638 |
cmbLegendField = new JComboBox(); |
|
639 |
cmbLegendField.addActionListener(cmbAction); |
|
640 |
} |
|
641 |
return cmbLegendField; |
|
642 |
} |
|
631 | 643 |
|
644 |
/** |
|
645 |
* This method initializes rdBtnHigh |
|
646 |
* |
|
647 |
* @return javax.swing.JRadioButton |
|
648 |
*/ |
|
649 |
private JRadioButton getRdBtnHigh() { |
|
650 |
if (rdBtnHigh == null) { |
|
651 |
Icon ic = IconThemeHelper.getImageIcon( |
|
652 |
"legend-dot-density-high-density-sample"); |
|
653 |
rdBtnHigh = new JRadioButton(ic); |
|
654 |
rdBtnHigh.addActionListener(buttonsListener); |
|
655 |
} |
|
656 |
return rdBtnHigh; |
|
657 |
} |
|
632 | 658 |
|
633 |
/** |
|
634 |
* This method initializes cmbLegendField |
|
635 |
* |
|
636 |
* @return javax.swing.JComboBox |
|
637 |
*/ |
|
638 |
private JComboBox getCmbLegendField() { |
|
639 |
if (cmbLegendField == null) { |
|
640 |
cmbLegendField = new JComboBox(); |
|
641 |
cmbLegendField.addActionListener(cmbAction); |
|
642 |
} |
|
643 |
return cmbLegendField; |
|
644 |
} |
|
645 |
|
|
646 |
/** |
|
647 |
* This method initializes rdBtnHigh |
|
648 |
* |
|
649 |
* @return javax.swing.JRadioButton |
|
650 |
*/ |
|
651 |
private JRadioButton getRdBtnHigh() { |
|
652 |
if (rdBtnHigh == null) { |
|
653 |
Icon ic = IconThemeHelper.getImageIcon( |
|
654 |
"legend-dot-density-high-density-sample"); |
|
655 |
rdBtnHigh = new JRadioButton(ic); |
|
656 |
rdBtnHigh.addActionListener(buttonsListener); |
|
657 |
} |
|
658 |
return rdBtnHigh; |
|
659 |
} |
|
660 |
|
|
661 |
/** |
|
662 |
* This method initializes rdBtnMedium |
|
663 |
* |
|
664 |
* @return javax.swing.JRadioButton |
|
665 |
*/ |
|
666 |
private JRadioButton getRdBtnMedium() { |
|
667 |
if (rdBtnMedium == null) { |
|
659 |
/** |
|
660 |
* This method initializes rdBtnMedium |
|
661 |
* |
|
662 |
* @return javax.swing.JRadioButton |
|
663 |
*/ |
|
664 |
private JRadioButton getRdBtnMedium() { |
|
665 |
if (rdBtnMedium == null) { |
|
668 | 666 |
Icon ic = IconThemeHelper.getImageIcon( |
669 |
"legend-dot-density-medium-density-sample"); |
|
670 |
rdBtnMedium = new JRadioButton(ic);
|
|
671 |
rdBtnMedium.addActionListener(buttonsListener);
|
|
672 |
}
|
|
673 |
return rdBtnMedium;
|
|
674 |
}
|
|
667 |
"legend-dot-density-medium-density-sample");
|
|
668 |
rdBtnMedium = new JRadioButton(ic);
|
|
669 |
rdBtnMedium.addActionListener(buttonsListener);
|
|
670 |
}
|
|
671 |
return rdBtnMedium;
|
|
672 |
}
|
|
675 | 673 |
|
676 |
/**
|
|
677 |
* This method initializes rdBtnMax
|
|
678 |
*
|
|
679 |
* @return javax.swing.JRadioButton
|
|
680 |
*/
|
|
681 |
private JRadioButton getRdBtnLow() {
|
|
682 |
if (rdBtnLow == null) {
|
|
674 |
/**
|
|
675 |
* This method initializes rdBtnMax
|
|
676 |
*
|
|
677 |
* @return javax.swing.JRadioButton
|
|
678 |
*/
|
|
679 |
private JRadioButton getRdBtnLow() {
|
|
680 |
if (rdBtnLow == null) {
|
|
683 | 681 |
Icon ic = IconThemeHelper.getImageIcon( |
684 |
"legend-dot-density-low-density-sample"); |
|
685 |
rdBtnLow = new JRadioButton(ic);
|
|
686 |
rdBtnLow.addActionListener(buttonsListener);
|
|
687 |
}
|
|
688 |
return rdBtnLow;
|
|
689 |
}
|
|
682 |
"legend-dot-density-low-density-sample");
|
|
683 |
rdBtnLow = new JRadioButton(ic);
|
|
684 |
rdBtnLow.addActionListener(buttonsListener);
|
|
685 |
}
|
|
686 |
return rdBtnLow;
|
|
687 |
}
|
|
690 | 688 |
|
691 |
/**
|
|
692 |
* This method initializes numDotSize
|
|
693 |
*
|
|
694 |
* @return de.ios.framework.swing.JNumberField
|
|
695 |
*/
|
|
696 |
private JNumberSpinner getNumDotSize() {
|
|
697 |
if (numDotSize == null) {
|
|
698 |
numDotSize = new JNumberSpinner(1.0, 4, 0.0, Double.MAX_VALUE, 1.0, 2);
|
|
699 |
}
|
|
700 |
return numDotSize;
|
|
701 |
}
|
|
689 |
/**
|
|
690 |
* This method initializes numDotSize
|
|
691 |
*
|
|
692 |
* @return de.ios.framework.swing.JNumberField
|
|
693 |
*/
|
|
694 |
private JNumberSpinner getNumDotSize() {
|
|
695 |
if (numDotSize == null) {
|
|
696 |
numDotSize = new JNumberSpinner(1.0, 4, 0.0, Double.MAX_VALUE, 1.0, 2);
|
|
697 |
}
|
|
698 |
return numDotSize;
|
|
699 |
}
|
|
702 | 700 |
|
703 |
/**
|
|
704 |
* This method initializes nmbrDotValue
|
|
705 |
*
|
|
706 |
* @return de.ios.framework.swing.JNumberField
|
|
707 |
*/
|
|
708 |
private JNumberSpinner getNmbrDotValue() {
|
|
709 |
if (nmbrDotValue == null) {
|
|
710 |
nmbrDotValue = new JNumberSpinner(1.0, 15, 0.01, Double.MAX_VALUE, 1.0, 2);
|
|
711 |
nmbrDotValue.addActionListener(nmbrDotValueListener);
|
|
701 |
/**
|
|
702 |
* This method initializes nmbrDotValue
|
|
703 |
*
|
|
704 |
* @return de.ios.framework.swing.JNumberField
|
|
705 |
*/
|
|
706 |
private JNumberSpinner getNmbrDotValue() {
|
|
707 |
if (nmbrDotValue == null) {
|
|
708 |
nmbrDotValue = new JNumberSpinner(1.0, 15, 0.01, Double.MAX_VALUE, 1.0, 2);
|
|
709 |
nmbrDotValue.addActionListener(nmbrDotValueListener);
|
|
712 | 710 |
|
713 |
}
|
|
714 |
return nmbrDotValue;
|
|
715 |
}
|
|
711 |
}
|
|
712 |
return nmbrDotValue;
|
|
713 |
}
|
|
716 | 714 |
|
717 |
/**
|
|
718 |
* This method initializes centerPanel
|
|
719 |
*
|
|
720 |
* @return javax.swing.JPanel
|
|
721 |
*/
|
|
722 |
private JPanel getCenterPanel() {
|
|
723 |
if (centerPanel == null) {
|
|
724 |
centerPanel = new JPanel();
|
|
725 |
centerPanel.setLayout(new BorderLayout(5, 5));
|
|
726 |
centerPanel.add(getPnlDensities(), java.awt.BorderLayout.WEST);
|
|
727 |
}
|
|
728 |
return centerPanel;
|
|
729 |
}
|
|
715 |
/**
|
|
716 |
* This method initializes centerPanel
|
|
717 |
*
|
|
718 |
* @return javax.swing.JPanel
|
|
719 |
*/
|
|
720 |
private JPanel getCenterPanel() {
|
|
721 |
if (centerPanel == null) {
|
|
722 |
centerPanel = new JPanel();
|
|
723 |
centerPanel.setLayout(new BorderLayout(5, 5));
|
|
724 |
centerPanel.add(getPnlDensities(), java.awt.BorderLayout.WEST);
|
|
725 |
}
|
|
726 |
return centerPanel;
|
|
727 |
}
|
|
730 | 728 |
|
731 |
/**
|
|
732 |
* This method initializes sldDensity
|
|
733 |
*
|
|
734 |
* @return javax.swing.JSlider
|
|
735 |
*/
|
|
736 |
private JSlider getSldDensity() {
|
|
737 |
if (sldDensity == null) {
|
|
738 |
sldDensity = new JSlider();
|
|
739 |
sldDensity.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
|
|
740 |
sldDensity.addChangeListener(sldListener);
|
|
741 |
}
|
|
742 |
return sldDensity;
|
|
743 |
}
|
|
729 |
/**
|
|
730 |
* This method initializes sldDensity
|
|
731 |
*
|
|
732 |
* @return javax.swing.JSlider
|
|
733 |
*/
|
|
734 |
private JSlider getSldDensity() {
|
|
735 |
if (sldDensity == null) {
|
|
736 |
sldDensity = new JSlider();
|
|
737 |
sldDensity.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
|
|
738 |
sldDensity.addChangeListener(sldListener);
|
|
739 |
}
|
|
740 |
return sldDensity;
|
|
741 |
}
|
|
744 | 742 |
|
745 |
public String getDescription() {
|
|
746 |
return Messages.getText("Defines_a_dot_density_symbol_based_on_a_field_value") + ".";
|
|
747 |
}
|
|
743 |
public String getDescription() {
|
|
744 |
return Messages.getText("Defines_a_dot_density_symbol_based_on_a_field_value") + ".";
|
|
745 |
}
|
|
748 | 746 |
|
749 |
public ImageIcon getIcon() {
|
|
750 |
ImageIcon ic = IconThemeHelper.getImageIcon(
|
|
751 |
"legend-overview-dot-density"); |
|
752 |
return ic;
|
|
753 |
}
|
|
747 |
public ImageIcon getIcon() {
|
|
748 |
ImageIcon ic = IconThemeHelper.getImageIcon(
|
|
749 |
"legend-overview-dot-density");
|
|
750 |
return ic;
|
|
751 |
}
|
|
754 | 752 |
|
755 |
public Class getParentClass() {
|
|
756 |
return Quantities.class;
|
|
757 |
}
|
|
753 |
public Class getParentClass() {
|
|
754 |
return Quantities.class;
|
|
755 |
}
|
|
758 | 756 |
|
759 |
public String getTitle() {
|
|
760 |
return Messages.getText("dot_density");
|
|
761 |
}
|
|
757 |
public String getTitle() {
|
|
758 |
return Messages.getText("dot_density");
|
|
759 |
}
|
|
762 | 760 |
|
763 |
public JPanel getPanel() {
|
|
764 |
return this;
|
|
765 |
}
|
|
761 |
public JPanel getPanel() {
|
|
762 |
return this;
|
|
763 |
}
|
|
766 | 764 |
|
767 |
public Class getLegendClass() {
|
|
768 |
return DotDensityLegend.class;
|
|
769 |
}
|
|
765 |
public Class getLegendClass() {
|
|
766 |
return DotDensityLegend.class;
|
|
767 |
}
|
|
770 | 768 |
|
771 |
public boolean isSuitableFor(FLayer layer) {
|
|
772 |
if (layer instanceof FLyrVect) {
|
|
773 |
try {
|
|
774 |
FLyrVect lyr = (FLyrVect) layer;
|
|
775 |
if (!DotDensityLegend.isPolygonal(lyr.getShapeType())) {
|
|
776 |
return false;
|
|
777 |
}
|
|
769 |
public boolean isSuitableFor(FLayer layer) {
|
|
770 |
if (layer instanceof FLyrVect) {
|
|
771 |
try {
|
|
772 |
FLyrVect lyr = (FLyrVect) layer;
|
|
773 |
if (!DotDensityLegend.isPolygonal(lyr.getShapeType())) {
|
|
774 |
return false;
|
|
775 |
}
|
|
778 | 776 |
|
779 |
FeatureStore fsto = (FeatureStore) lyr.getDataStore();
|
|
780 |
FeatureType fty = fsto.getDefaultFeatureType();
|
|
781 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors();
|
|
777 |
FeatureStore fsto = (FeatureStore) lyr.getDataStore();
|
|
778 |
FeatureType fty = fsto.getDefaultFeatureType();
|
|
779 |
FeatureAttributeDescriptor[] atts = fty.getAttributeDescriptors();
|
|
782 | 780 |
|
783 |
for (int i=0; i<atts.length; i++) {
|
|
784 |
if (atts[i].getDataType().isNumeric()) {
|
|
785 |
return true;
|
|
786 |
}
|
|
787 |
}
|
|
788 |
} catch (Exception e) {
|
|
781 |
for (int i = 0; i < atts.length; i++) {
|
|
782 |
if (atts[i].getDataType().isNumeric()) {
|
|
783 |
return true;
|
|
784 |
}
|
|
785 |
}
|
|
786 |
} catch (Exception e) {
|
|
789 | 787 |
|
790 |
ApplicationLocator.getManager().messageDialog(
|
|
791 |
Messages.getText("error_trying_to_access_to_the_layer"),
|
|
792 |
Messages.getText("error"), |
|
793 |
JOptionPane.ERROR_MESSAGE);
|
|
794 |
return false;
|
|
795 |
}
|
|
796 |
}
|
|
797 |
return false;
|
|
798 |
}
|
|
788 |
ApplicationLocator.getManager().messageDialog(
|
|
789 |
Messages.getText("error_trying_to_access_to_the_layer"),
|
|
790 |
Messages.getText("error"),
|
|
791 |
JOptionPane.ERROR_MESSAGE);
|
|
792 |
return false;
|
|
793 |
}
|
|
794 |
}
|
|
795 |
return false;
|
|
796 |
}
|
|
799 | 797 |
|
800 | 798 |
} |
Also available in: Unified diff