@Override public TiePointGrid[] getSelectedTiePointGrids() { checkSelectedBandsAndGrids(); return selectedTiePointGrids; }
@Override public void selectAll() { select(true); }
@Override public void setCheckBoxes(JCheckBox selectAllCheckBox, JCheckBox selectNoneCheckBox) { this.selectAllCheckBox = selectAllCheckBox; this.selectNoneCheckBox = selectNoneCheckBox; updateCheckBoxStates(); }
@Override public JPanel createCheckersPane() { int length = 0; if (allBands != null) { length += allBands.length; } if (allTiePointGrids != null) { length += allTiePointGrids.length; } checkBoxes = new JCheckBox[length]; final JPanel checkersPane = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=4,anchor=NORTHWEST,fill=HORIZONTAL"); final ActionListener checkListener = createActionListener(); addBandCheckers(new StringBuffer(), checkersPane, gbc, checkListener); addTiePointCheckers(new StringBuffer(), checkersPane, gbc, checkListener); GridBagUtils.addVerticalFiller(checkersPane, gbc); return checkersPane; }
private void addTiePointCheckers(final StringBuffer description, final JPanel checkersPane, final GridBagConstraints gbc, final ActionListener checkListener) { for (int i = 0; i < allTiePointGrids.length; i++) { TiePointGrid grid = allTiePointGrids[i]; boolean checked = false; for (TiePointGrid selectedGrid : selectedTiePointGrids) { if (grid == selectedGrid) { checked = true; numSelected++; break; } } description.setLength(0); description.append(grid.getDescription() == null ? "" : grid.getDescription()); final JCheckBox check = new JCheckBox(getRasterDisplayName(grid), checked); check.setFont(SMALL_PLAIN_FONT); check.addActionListener(checkListener); final JLabel label = new JLabel(description.toString()); label.setFont(SMALL_ITALIC_FONT); gbc.gridy++; GridBagUtils.addToPanel(checkersPane, check, gbc, "weightx=0,gridx=0"); GridBagUtils.addToPanel(checkersPane, label, gbc, "weightx=1,gridx=1"); checkBoxes[i + allBands.length] = check; } }
public BandChooser(Window parent, String title, String helpID, boolean selectAtLeastOneBand, Band[] allBands, Band[] selectedBands, TiePointGrid[] allTiePointGrids, TiePointGrid[] selectedTiePointGrids, boolean addLoadSaveConfigurationButtons) { super(parent, title, ModalDialog.ID_OK_CANCEL, helpID); this.addLoadSaveConfigurationButtons = addLoadSaveConfigurationButtons; boolean multipleProducts = bandsAndGridsFromMoreThanOneProduct(allBands, allTiePointGrids); strategy = new DefaultBandChoosingStrategy(allBands, selectedBands, allTiePointGrids, selectedTiePointGrids, multipleProducts); this.selectAtLeastOneBand = selectAtLeastOneBand; initUI(); }
private void addBandCheckers(final StringBuffer description, final JPanel checkersPane, final GridBagConstraints gbc, final ActionListener checkListener) { for (int i = 0; i < allBands.length; i++) { Band band = allBands[i]; boolean checked = false; for (Band selectedBand : selectedBands) { if (band == selectedBand) { checked = true; numSelected++; break; } } description.setLength(0); description.append(band.getDescription() == null ? "" : band.getDescription()); if (band.getSpectralWavelength() > 0.0) { description.append(" ("); description.append(band.getSpectralWavelength()); description.append(" nm)"); } final JCheckBox check = new JCheckBox(getRasterDisplayName(band), checked); check.setFont(SMALL_PLAIN_FONT); check.addActionListener(checkListener); final JLabel label = new JLabel(description.toString()); label.setFont(SMALL_ITALIC_FONT); gbc.gridy++; GridBagUtils.addToPanel(checkersPane, check, gbc, "weightx=0,gridx=0"); GridBagUtils.addToPanel(checkersPane, label, gbc, "weightx=1,gridx=1"); checkBoxes[i] = check; } }
public void actionPerformed(ActionEvent e) { final JCheckBox check = (JCheckBox) e.getSource(); if (check.isSelected()) { numSelected++; } else { numSelected--; } updateCheckBoxStates(); } };
@Override public boolean atLeastOneBandSelected() { checkSelectedBandsAndGrids(); return selectedBands.length > 0; }
@Override public void selectNone() { select(false); }
private void select(boolean b) { for (JCheckBox checkBox : checkBoxes) { if (b && !checkBox.isSelected()) { numSelected++; } if (!b && checkBox.isSelected()) { numSelected--; } checkBox.setSelected(b); } updateCheckBoxStates(); }
@Override public Band[] getSelectedBands() { checkSelectedBandsAndGrids(); return selectedBands; }
@Override public void selectRasterDataNodes(String[] nodeNames) { for (int i = 0; i < allBands.length; i++) { Band band = allBands[i]; for (String nodeName : nodeNames) { if (nodeName.equals(band.getName())) { checkBoxes[i].setSelected(true); numSelected++; break; } } } for (int i = 0; i < allTiePointGrids.length; i++) { TiePointGrid grid = allTiePointGrids[i]; for (String nodeName : nodeNames) { if (nodeName.equals(grid.getName())) { checkBoxes[allBands.length + i].setSelected(true); numSelected++; break; } } } updateCheckBoxStates(); }