Revision 18883 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/LegendManager.java
LegendManager.java | ||
---|---|---|
48 | 48 |
import java.awt.Component; |
49 | 49 |
import java.awt.Dimension; |
50 | 50 |
import java.awt.FlowLayout; |
51 |
import java.awt.Graphics; |
|
52 | 51 |
import java.awt.event.ActionListener; |
53 | 52 |
import java.io.File; |
54 | 53 |
import java.util.ArrayList; |
... | ... | |
90 | 89 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
91 | 90 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
92 | 91 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
93 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
|
94 |
import com.iver.cit.gvsig.gui.styling.SymbolPreviewer; |
|
95 | 92 |
/** |
96 | 93 |
* Implements the panel which allows the user to control all the information about the |
97 | 94 |
* legends of a layer in order to improve the information that it offers to the user. |
... | ... | |
129 | 126 |
private JButton btnSaveLegend; |
130 | 127 |
private JButton btnLoadLegend; |
131 | 128 |
private Hashtable<FLayer, ILegend> table = null; |
132 |
|
|
129 |
private boolean empty = true; |
|
133 | 130 |
public static String defaultLegendFolderPath; |
134 | 131 |
{ |
135 | 132 |
|
... | ... | |
436 | 433 |
* were added through the static method addLegendPage(ILegendPanel page) |
437 | 434 |
*/ |
438 | 435 |
private void fillDialog() { |
439 |
for (int i = 0; i < legendPool.size(); i++) { |
|
440 |
Class pageClass = (Class) legendPool.get(i); |
|
441 |
ILegendPanel page; |
|
442 |
try { |
|
443 |
page = (ILegendPanel) pageClass.newInstance(); |
|
444 |
if (page.isSuitableFor(layer)) { |
|
445 |
// this legend can be applied to this layer |
|
446 |
pages.put(page.getClass(), page); |
|
436 |
if (empty) { |
|
437 |
for (int i = 0; i < legendPool.size(); i++) { |
|
438 |
Class pageClass = (Class) legendPool.get(i); |
|
439 |
ILegendPanel page; |
|
440 |
try { |
|
441 |
page = (ILegendPanel) pageClass.newInstance(); |
|
442 |
if (page.isSuitableFor(layer)) { |
|
443 |
// this legend can be applied to this layer |
|
444 |
pages.put(page.getClass(), page); |
|
447 | 445 |
|
448 |
if (dirtyTree) { |
|
449 |
// rebuild page tree |
|
450 |
dirtyTree = false; |
|
446 |
if (dirtyTree) {
|
|
447 |
// rebuild page tree
|
|
448 |
dirtyTree = false;
|
|
451 | 449 |
|
452 |
ArrayList legList = new ArrayList(pages.values()); |
|
453 |
ArrayList alreadyAdded = new ArrayList(); |
|
454 |
DefaultTreeModel model = new DefaultTreeModel(root); |
|
455 |
while (legList.size()>0) { |
|
456 |
ILegendPanel legend = (ILegendPanel) legList.get(0); |
|
457 |
Class parent = legend.getParentClass(); |
|
458 |
while (parent != null && |
|
459 |
!alreadyAdded.contains(pages.get(parent))) { |
|
460 |
legend = (ILegendPanel) pages.get(parent); |
|
450 |
ArrayList legList = new ArrayList(pages.values()); |
|
451 |
ArrayList alreadyAdded = new ArrayList(); |
|
452 |
DefaultTreeModel model = new DefaultTreeModel(root); |
|
453 |
while (legList.size()>0) { |
|
454 |
ILegendPanel legend = (ILegendPanel) legList.get(0); |
|
455 |
Class parent = legend.getParentClass(); |
|
456 |
while (parent != null && |
|
457 |
!alreadyAdded.contains(pages.get(parent))) { |
|
458 |
legend = (ILegendPanel) pages.get(parent); |
|
459 |
} |
|
460 |
doInsertNode(model, legend); |
|
461 |
legList.remove(legend); |
|
462 |
alreadyAdded.add(legend); |
|
461 | 463 |
} |
462 |
doInsertNode(model, legend); |
|
463 |
legList.remove(legend); |
|
464 |
alreadyAdded.add(legend); |
|
464 |
treeModel = model; |
|
465 |
jTreeLegends.setModel(model); |
|
465 | 466 |
} |
466 |
treeModel = model;
|
|
467 |
jTreeLegends.setModel(model); |
|
467 |
doInsertNode(treeModel, page);
|
|
468 |
|
|
468 | 469 |
} |
469 |
doInsertNode(treeModel, page);
|
|
470 |
getJTreeLegends().setModel(treeModel);
|
|
470 | 471 |
|
472 |
} catch (InstantiationException e) { |
|
473 |
NotificationManager.addError("Trying to instantiate an interface" + |
|
474 |
" or abstract class + "+pageClass.getName(), e); |
|
475 |
} catch (IllegalAccessException e) { |
|
476 |
NotificationManager.addError("IllegalAccessException: does " + |
|
477 |
pageClass.getName() + " class have an anonymous" + |
|
478 |
" constructor?", e); |
|
471 | 479 |
} |
472 |
getJTreeLegends().setModel(treeModel); |
|
473 | 480 |
|
474 |
} catch (InstantiationException e) { |
|
475 |
NotificationManager.addError("Trying to instantiate an interface" + |
|
476 |
" or abstract class + "+pageClass.getName(), e); |
|
477 |
} catch (IllegalAccessException e) { |
|
478 |
NotificationManager.addError("IllegalAccessException: does " + |
|
479 |
pageClass.getName() + " class have an anonymous" + |
|
480 |
" constructor?", e); |
|
481 | 481 |
} |
482 |
|
|
482 |
getJTreeLegends().repaint(); |
|
483 |
empty = false; |
|
483 | 484 |
} |
484 |
getJTreeLegends().repaint(); |
|
485 |
|
|
486 | 485 |
} |
487 | 486 |
|
488 | 487 |
private DefaultMutableTreeNode findNode(Class searchID) { |
Also available in: Unified diff