Revision 571 org.gvsig.chart/trunk/org.gvsig.chart/org.gvsig.chart.app/org.gvsig.chart.app.legendplugin/src/main/java/org/gvsig/project/documents/view/legend/gui/ChartLegendPanelBars.java
ChartLegendPanelBars.java | ||
---|---|---|
70 | 70 |
private JPanel centerPanel = null; // @jve:decl-index=0:visual-constraint="10,10" |
71 | 71 |
private JScrollPane jScrollPane = null; |
72 | 72 |
private JList jFieldList = null; |
73 |
private Random rand = new Random(System.currentTimeMillis()); |
|
73 |
private final Random rand = new Random(System.currentTimeMillis());
|
|
74 | 74 |
private JPanel buttons = null; |
75 | 75 |
private JButton addButton = null; |
76 | 76 |
private JButton removeButton = null; |
... | ... | |
300 | 300 |
bSize.setText(PluginServices.getText(this, "size")); |
301 | 301 |
bSize.setPreferredSize(new Dimension(100, 30)); |
302 | 302 |
bSize.setMaximumSize(new Dimension(100, 30)); |
303 |
bSize.addActionListener(new ActionListener() { |
|
304 |
public void actionPerformed(ActionEvent e) { |
|
305 |
PluginServices.getMDIManager().addCentredWindow( |
|
306 |
new SizePanel(layer, (IChartLegend) getLegend())); |
|
307 |
} |
|
308 |
|
|
303 |
bSize.addActionListener((ActionEvent e) -> { |
|
304 |
PluginServices.getMDIManager().addCentredWindow( |
|
305 |
new SizePanel(layer, (IChartLegend) getLegend())); |
|
309 | 306 |
}); |
310 | 307 |
} |
311 | 308 |
return bSize; |
... | ... | |
346 | 343 |
addButton = new JButton(); |
347 | 344 |
addButton.setText(">"); |
348 | 345 |
addButton.setPreferredSize(new Dimension(50, 40)); |
349 |
addButton.addActionListener(new java.awt.event.ActionListener() { |
|
350 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
351 |
Object[] fields = getJFieldList().getSelectedValues(); |
|
352 |
Color[] colorScheme = colorCombo.getSelectedColors(); |
|
353 |
|
|
354 |
Color[] colors = new Color[colorScheme.length]; |
|
355 |
for (int i = 0; i < colorScheme.length; i++) { |
|
356 |
colors[i] = colorScheme[i]; |
|
357 |
} |
|
358 |
for (int i = 0; i < fields.length; i++) { |
|
359 |
getFieldsTable().addTableRecord( |
|
360 |
colorScheme[rand.nextInt(colorScheme.length)], |
|
361 |
(String) fields[i], (String) fields[i]); |
|
362 |
((DefaultListModel) getJFieldList().getModel()) |
|
363 |
.removeElement(fields[i]); |
|
364 |
} |
|
365 |
actualizePreviewSymbol(); |
|
346 |
addButton.addActionListener((java.awt.event.ActionEvent e) -> { |
|
347 |
Object[] fields = getJFieldList().getSelectedValues(); |
|
348 |
Color[] colorScheme = colorCombo.getSelectedColors(); |
|
349 |
|
|
350 |
Color[] colors = new Color[colorScheme.length]; |
|
351 |
System.arraycopy(colorScheme, 0, colors, 0, colorScheme.length); |
|
352 |
for (Object field : fields) { |
|
353 |
getFieldsTable().addTableRecord(colorScheme[rand.nextInt(colorScheme.length)], (String) field, (String) field); |
|
354 |
((DefaultListModel) getJFieldList().getModel()).removeElement(field); |
|
366 | 355 |
} |
367 | 356 |
}); |
368 | 357 |
} |
... | ... | |
403 | 392 |
removeButton = new JButton(); |
404 | 393 |
removeButton.setPreferredSize(new Dimension(50, 40)); |
405 | 394 |
removeButton.setText("<"); |
406 |
removeButton.addActionListener(new java.awt.event.ActionListener() { |
|
407 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
408 |
int[] index = getFieldsTable().getSelectedRows(); |
|
409 |
String[] fields = new String[index.length]; |
|
410 |
for (int i = 0; i < index.length; i++) { |
|
411 |
fields[i] = (String) getFieldsTable().getFieldValue( |
|
412 |
index[i], 1); |
|
413 |
} |
|
414 |
for (int i = 0; i < fields.length; i++) { |
|
415 |
((DefaultListModel) getJFieldList().getModel()) |
|
416 |
.addElement(fields[i]); |
|
417 |
} |
|
418 |
getFieldsTable().removeSelectedRows(); |
|
419 |
actualizePreviewSymbol(); |
|
395 |
removeButton.addActionListener((java.awt.event.ActionEvent e) -> { |
|
396 |
int[] index = getFieldsTable().getSelectedRows(); |
|
397 |
String[] fields = new String[index.length]; |
|
398 |
for (int i = 0; i < index.length; i++) { |
|
399 |
fields[i] = (String) getFieldsTable().getFieldValue( |
|
400 |
index[i], 1); |
|
420 | 401 |
} |
402 |
for (String field : fields) { |
|
403 |
((DefaultListModel) getJFieldList().getModel()).addElement(field); |
|
404 |
} |
|
405 |
getFieldsTable().removeSelectedRows(); |
|
421 | 406 |
}); |
422 | 407 |
} |
423 | 408 |
return removeButton; |
... | ... | |
433 | 418 |
addAllButton = new JButton(); |
434 | 419 |
addAllButton.setPreferredSize(new Dimension(50, 40)); |
435 | 420 |
addAllButton.setText(">>"); |
436 |
addAllButton.addActionListener(new java.awt.event.ActionListener() { |
|
437 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
438 |
Object[] fields = ((DefaultListModel) getJFieldList() |
|
439 |
.getModel()).toArray(); |
|
440 |
|
|
441 |
Color[] colorScheme = colorCombo.getSelectedColors(); |
|
442 |
|
|
443 |
Color[] colors = new Color[colorScheme.length]; |
|
444 |
for (int i = 0; i < colorScheme.length; i++) { |
|
445 |
colors[i] = colorScheme[i]; |
|
446 |
} |
|
447 |
for (int i = 0; i < fields.length; i++) { |
|
448 |
getFieldsTable().addTableRecord( |
|
449 |
colorScheme[rand.nextInt(colorScheme.length)], |
|
450 |
(String) fields[i], (String) fields[i]); |
|
451 |
((DefaultListModel) getJFieldList().getModel()) |
|
452 |
.removeElement(fields[i]); |
|
453 |
} |
|
454 |
actualizePreviewSymbol(); |
|
421 |
addAllButton.addActionListener((java.awt.event.ActionEvent e) -> { |
|
422 |
Object[] fields = ((DefaultListModel) getJFieldList() |
|
423 |
.getModel()).toArray(); |
|
424 |
|
|
425 |
Color[] colorScheme = colorCombo.getSelectedColors(); |
|
426 |
|
|
427 |
Color[] colors = new Color[colorScheme.length]; |
|
428 |
System.arraycopy(colorScheme, 0, colors, 0, colorScheme.length); |
|
429 |
for (Object field : fields) { |
|
430 |
getFieldsTable().addTableRecord(colorScheme[rand.nextInt(colorScheme.length)], (String) field, (String) field); |
|
431 |
((DefaultListModel) getJFieldList().getModel()).removeElement(field); |
|
455 | 432 |
} |
456 | 433 |
}); |
457 | 434 |
} |
458 | 435 |
return addAllButton; |
459 | 436 |
} |
460 | 437 |
|
461 |
private void actualizePreviewSymbol() { |
|
462 |
int count = getFieldsTable().getRowCount(); |
|
463 |
String[] fieldsTable = new String[count]; |
|
464 |
for (int i = 0; i < count; i++) { |
|
465 |
fieldsTable[i] = (String) getFieldsTable().getFieldValue(i, 1); |
|
466 |
} |
|
467 |
String[] labelsTable = new String[count]; |
|
468 |
for (int i = 0; i < count; i++) { |
|
469 |
labelsTable[i] = (String) getFieldsTable().getFieldValue(i, 2); |
|
470 |
} |
|
471 |
Color[] colorsTable = new Color[count]; |
|
472 |
for (int i = 0; i < count; i++) { |
|
473 |
colorsTable[i] = ((JPanel) getFieldsTable().getFieldValue(i, 0)) |
|
474 |
.getBackground(); |
|
475 |
} |
|
476 |
|
|
477 |
} |
|
478 |
|
|
479 | 438 |
/** |
480 | 439 |
* This method initializes removeAllButton |
481 | 440 |
* |
... | ... | |
754 | 713 |
props.setHasPlotOutline(auxLegend.isOutlineShow()); |
755 | 714 |
props.setIsLegendVisible(false); |
756 | 715 |
props.setPlotBackgroundColor(auxLegend.getOutlineColor()); |
757 |
props.setPlotBackgroundAlpha(colorButton.getAlpha() / 100); |
|
716 |
if (getJCheckBox().isSelected()) { |
|
717 |
float alpha = colorButton.getAlpha() / 100; |
|
718 |
if (alpha > 1) { |
|
719 |
props.setPlotBackgroundAlpha(1.0f); |
|
720 |
} else { |
|
721 |
props.setPlotBackgroundAlpha(alpha); |
|
722 |
} |
|
723 |
} else { |
|
724 |
props.setPlotBackgroundAlpha(0.0f); |
|
725 |
} |
|
758 | 726 |
props.setIsMandatoryChart(jShowAxis.isSelected()); |
759 | 727 |
props.setIsXYPlotChart(false); |
760 | 728 |
props.setChartDimension(auxLegend.is3D()); |
Also available in: Unified diff