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