001 /*
002 * $Id: McvSideLegend.java,v 1.7 2012/02/19 17:35:51 davep Exp $
003 *
004 * This file is part of McIDAS-V
005 *
006 * Copyright 2007-2012
007 * Space Science and Engineering Center (SSEC)
008 * University of Wisconsin - Madison
009 * 1225 W. Dayton Street, Madison, WI 53706, USA
010 * https://www.ssec.wisc.edu/mcidas
011 *
012 * All Rights Reserved
013 *
014 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
015 * some McIDAS-V source code is based on IDV and VisAD source code.
016 *
017 * McIDAS-V is free software; you can redistribute it and/or modify
018 * it under the terms of the GNU Lesser Public License as published by
019 * the Free Software Foundation; either version 3 of the License, or
020 * (at your option) any later version.
021 *
022 * McIDAS-V is distributed in the hope that it will be useful,
023 * but WITHOUT ANY WARRANTY; without even the implied warranty of
024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
025 * GNU Lesser Public License for more details.
026 *
027 * You should have received a copy of the GNU Lesser Public License
028 * along with this program. If not, see http://www.gnu.org/licenses.
029 */
030
031 package edu.wisc.ssec.mcidasv.ui;
032
033 import java.awt.BorderLayout;
034 import java.awt.Insets;
035 import java.awt.event.ItemEvent;
036 import java.awt.event.ItemListener;
037 import java.util.ArrayList;
038 import java.util.Hashtable;
039 import java.util.List;
040
041 import javax.swing.BorderFactory;
042 import javax.swing.JCheckBox;
043 import javax.swing.JComponent;
044 import javax.swing.JPanel;
045
046 import ucar.unidata.idv.DisplayControl;
047 import ucar.unidata.idv.ui.SideLegend;
048 import ucar.unidata.idv.ui.SideLegend.CategoryPanel;
049 //import ucar.unidata.idv.ui.SideLegend.DisplayControlLegendPanel;
050 import ucar.unidata.util.GuiUtils;
051
052 public class McvSideLegend extends SideLegend {
053
054 // since you're gonna have to redo a significant portion of this, you might
055 // as well add in something to convey the ViewManager's active layer...
056 // may as well make it a tree, too.
057 // parent nodes don't get checks unless *all* kids are checked
058 // i like the UI from this link:
059 // http://rabbit-hole.blogspot.com/2006/11/tree-and-tree-table-with-checkboxes.html
060 // @Override protected void fillLegendSafely() {
061 // List controls = viewManager.getControlsForLegend();
062 // for (int i = 0; i < categoryPanels.size(); i++) {
063 // CategoryPanel categoryPanel =
064 // (CategoryPanel) categoryPanels.get(i);
065 // // categoryPanel.clear();
066 // categoryPanel.reInitialize();
067 // categoryPanel.getContents().setVisible(true);
068 // }
069 //
070 // Hashtable seen = new Hashtable();
071 // for (int i = controls.size() - 1; i >= 0; i--) {
072 // final DisplayControl control = (DisplayControl) controls.get(i);
073 // String category = control.getDisplayCategory();
074 // System.err.println("debug: category=" + category);
075 // if ((category == null) || (category.length() == 0)) {
076 // category = "Displays";
077 // }
078 // CategoryPanel categoryPanel =
079 // (CategoryPanel) categoryToPanel.get(category);
080 // if (categoryPanel == null) {
081 // categoryPanel = new CategoryPanel(this, category);
082 // categoryPanels.add(categoryPanel);
083 // categoryToPanel.put(category, categoryPanel);
084 // Boolean b = (Boolean) categoryToPanelOpen.get(category);
085 // if (b != null) {
086 // categoryPanel.setInnerVisible(b.booleanValue());
087 // }
088 // }
089 // seen.put(categoryPanel, categoryPanel);
090 // DisplayControlLegendPanel legendPanel =
091 // (DisplayControlLegendPanel) control.getTransientProperty(
092 // "SIDELEGEND");
093 // if (legendPanel == null) {
094 // JCheckBox visCbx = control.doMakeVisibilityControl("");
095 // ItemListener itemListener = new ItemListener() {
096 // public void itemStateChanged(ItemEvent event) {
097 // displayControlVisibilityChanged(control,
098 // event.getStateChange() == ItemEvent.SELECTED);
099 // }
100 // };
101 // visCbx.addItemListener(itemListener);
102 // visCbx.setBorder(BorderFactory.createEmptyBorder());
103 // JComponent sideLegendLabel =
104 // control.getLegendLabel(control.SIDE_LEGEND);
105 // sideLegendLabel.setBorder(BorderFactory.createEmptyBorder(0,
106 // 5, 0, 3));
107 // legendPanel = new DisplayControlLegendPanel(control,
108 // sideLegendLabel, false,
109 // GuiUtils.inset(visCbx, new Insets(0, 0, 0, 2)),
110 // control.getLegendButtons(control.SIDE_LEGEND));
111 //
112 // JComponent controlLegend =
113 // control.getLegendComponent(control.SIDE_LEGEND);
114 // legendPanel.add(controlLegend, false);
115 // control.putTransientProperty("SIDELEGEND", legendPanel);
116 // }
117 // categoryPanel.add(control, legendPanel.getContents());
118 // }
119 //
120 // List orderedCategoryPanels = new ArrayList();
121 // for (int i = 0; i < categoryPanels.size(); i++) {
122 // CategoryPanel categoryPanel =
123 // (CategoryPanel) categoryPanels.get(i);
124 // if (seen.get(categoryPanel) != null) {
125 // orderedCategoryPanels.add(categoryPanel.getContents());
126 // } else {
127 // categoryPanel.clear();
128 // }
129 // }
130 //
131 //
132 // JPanel panels = GuiUtils.vbox(orderedCategoryPanels);
133 // // synchronized (legendsPanel.getTreeLock()) {
134 // legendsPanel.removeAll();
135 // legendsPanel.add(panels, BorderLayout.NORTH);
136 // legendsPanel.invalidate();
137 // // }
138 // }
139
140
141 }