本文整理汇总了Java中org.esa.snap.ui.GridBagUtils.addToPanel方法的典型用法代码示例。如果您正苦于以下问题:Java GridBagUtils.addToPanel方法的具体用法?Java GridBagUtils.addToPanel怎么用?Java GridBagUtils.addToPanel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.esa.snap.ui.GridBagUtils
的用法示例。
在下文中一共展示了GridBagUtils.addToPanel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGeoCoordinatesPane
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private JPanel createGeoCoordinatesPane() {
JPanel geoCoordinatesPane = GridBagUtils.createPanel();
setComponentName(geoCoordinatesPane, "geoCoordinatesPane");
GridBagConstraints gbc = GridBagUtils.createConstraints(
"insets.left=3,anchor=WEST,fill=HORIZONTAL, weightx=1.0");
GridBagUtils.setAttributes(gbc, "insets.top=4");
GridBagUtils.addToPanel(geoCoordinatesPane, new JLabel("North latitude bound:"), gbc, "gridx=0,gridy=0");
GridBagUtils.addToPanel(geoCoordinatesPane, UIUtils.createSpinner(paramNorthLat1, 1.0, "#0.00#"),
gbc, "gridx=1,gridy=0");
GridBagUtils.setAttributes(gbc, "insets.top=1");
GridBagUtils.addToPanel(geoCoordinatesPane, new JLabel("West longitude bound:"), gbc, "gridx=0,gridy=1");
GridBagUtils.addToPanel(geoCoordinatesPane, UIUtils.createSpinner(paramWestLon1, 1.0, "#0.00#"),
gbc, "gridx=1,gridy=1");
GridBagUtils.setAttributes(gbc, "insets.top=4");
GridBagUtils.addToPanel(geoCoordinatesPane, new JLabel("South latitude bound:"), gbc, "gridx=0,gridy=2");
GridBagUtils.addToPanel(geoCoordinatesPane, UIUtils.createSpinner(paramSouthLat2, 1.0, "#0.00#"),
gbc, "gridx=1,gridy=2");
GridBagUtils.setAttributes(gbc, "insets.top=1");
GridBagUtils.addToPanel(geoCoordinatesPane, new JLabel("East longitude bound:"), gbc, "gridx=0,gridy=3");
GridBagUtils.addToPanel(geoCoordinatesPane, UIUtils.createSpinner(paramEastLon2, 1.0, "#0.00#"),
gbc, "gridx=1,gridy=3");
return geoCoordinatesPane;
}
示例2: createPixelCoordinatesPane
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private JPanel createPixelCoordinatesPane() {
GridBagConstraints gbc = GridBagUtils.createConstraints(
"insets.left=3,anchor=WEST,fill=HORIZONTAL, weightx=1.0");
JPanel pixelCoordinatesPane = GridBagUtils.createPanel();
setComponentName(pixelCoordinatesPane, "pixelCoordinatesPane");
GridBagUtils.setAttributes(gbc, "insets.top=4");
GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene start X:"), gbc, "gridx=0,gridy=0");
GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramX1, 25, "#0"),
gbc, "gridx=1,gridy=0");
GridBagUtils.setAttributes(gbc, "insets.top=1");
GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene start Y:"), gbc, "gridx=0,gridy=1");
GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramY1, 25, "#0"),
gbc, "gridx=1,gridy=1");
GridBagUtils.setAttributes(gbc, "insets.top=4");
GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene end X:"), gbc, "gridx=0,gridy=2");
GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramX2, 25, "#0"),
gbc, "gridx=1,gridy=2");
GridBagUtils.setAttributes(gbc, "insets.top=1");
GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene end Y:"), gbc, "gridx=0,gridy=3");
GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramY2, 25, "#0"),
gbc, "gridx=1,gridy=3");
return pixelCoordinatesPane;
}
示例3: addSubsetAcessory
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private void addSubsetAcessory() {
subsetButton = new JButton("Subset...");
subsetButton.setMnemonic('S');
subsetButton.addActionListener(e -> openProductSubsetDialog());
subsetButton.setEnabled(getSelectedFile() != null || productToExport != null);
sizeLabel = new JLabel("0 M");
sizeLabel.setHorizontalAlignment(JLabel.RIGHT);
JPanel panel = GridBagUtils.createPanel();
GridBagConstraints gbc = GridBagUtils.createConstraints(
"fill=HORIZONTAL,weightx=1,anchor=NORTHWEST,insets.left=7,insets.right=7,insets.bottom=4");
GridBagUtils.addToPanel(panel, subsetButton, gbc, "gridy=0");
GridBagUtils.addToPanel(panel, sizeLabel, gbc, "gridy=1");
GridBagUtils.addVerticalFiller(panel, gbc);
setAccessory(panel);
addPropertyChangeListener(e -> updateState());
}
示例4: createOptionsPanel
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private JPanel createOptionsPanel() {
toggleColorCheckBox = new JCheckBox("Invert plot colors");
toggleColorCheckBox.addActionListener(e -> toggleColor());
toggleColorCheckBox.setEnabled(false);
final JPanel optionsPanel = GridBagUtils.createPanel();
final GridBagConstraints gbc = GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=0,weightx=1,gridx=0");
GridBagUtils.addToPanel(optionsPanel, axisRangeControls[X_VAR].getPanel(), gbc, "gridy=0, insets.top=2");
GridBagUtils.addToPanel(optionsPanel, xProductList, gbc, "gridy=1,insets.left=4,insets.right=2");
GridBagUtils.addToPanel(optionsPanel, xBandList, gbc, "gridy=2,insets.left=4,insets.right=2");
GridBagUtils.addToPanel(optionsPanel, axisRangeControls[Y_VAR].getPanel(), gbc, "gridy=3,insets.left=0,insets.right=0");
GridBagUtils.addToPanel(optionsPanel, yProductList, gbc, "gridy=4,insets.left=4,insets.right=2");
GridBagUtils.addToPanel(optionsPanel, yBandList, gbc, "gridy=5,insets.left=4,insets.right=2");
GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=6");
GridBagUtils.addToPanel(optionsPanel, new JSeparator(), gbc, "gridy=7,insets.left=4,insets.right=2");
GridBagUtils.addToPanel(optionsPanel, toggleColorCheckBox, gbc, "gridy=8,insets.left=0,insets.right=0");
return optionsPanel;
}
示例5: createCheckersPane
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
public JPanel createCheckersPane() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
Map<String, Integer> groupNodeMap = initGrouping(root);
List<TreePath> selectedPaths = new ArrayList<>();
addBandCheckBoxes(root, selectedPaths, groupNodeMap);
addTiePointGridCheckBoxes(root, selectedPaths, groupNodeMap);
removeEmptyGroups(root, groupNodeMap);
TreeModel treeModel = new DefaultTreeModel(root);
checkBoxTree = new CheckBoxTree(treeModel);
checkBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(selectedPaths.toArray(new TreePath[selectedPaths.size()]));
checkBoxTree.setRootVisible(false);
checkBoxTree.setShowsRootHandles(true);
checkBoxTree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
updateCheckBoxStates();
}
});
final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
renderer.setFont(SMALL_ITALIC_FONT);
renderer.setLeafIcon(null);
renderer.setOpenIcon(null);
renderer.setClosedIcon(null);
Color color = new Color(240, 240, 240);
checkBoxTree.setBackground(color);
renderer.setBackgroundSelectionColor(color);
renderer.setBackgroundNonSelectionColor(color);
renderer.setBorderSelectionColor(color);
renderer.setTextSelectionColor(Color.BLACK);
GridBagConstraints gbc2 = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=BOTH");
final JPanel checkersPane = GridBagUtils.createPanel();
GridBagUtils.addToPanel(checkersPane, checkBoxTree, gbc2, "weightx=1.0,weighty=1.0");
return checkersPane;
}
示例6: addBandCheckers
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
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;
}
}
示例7: addTiePointCheckers
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
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;
}
}
示例8: buildUI
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private void buildUI() {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);
gbc.weighty = 0.01;
addTab("Windows Bundle", createTab(OSFamily.windows));
addTab("Linux Bundle", createTab(OSFamily.linux));
addTab("MacOSX Bundle", createTab(OSFamily.macosx));
GridBagUtils.addToPanel(this, this.bundleTabPane, gbc, "gridx=0, gridy=0, gridwidth=11, weightx=1");
GridBagUtils.addToPanel(this, new JLabel("Reflect in Variable:"), gbc, "gridx=0, gridy=1, gridwidth=1, weightx=0");
variablesCombo = getEditorComponent(OSFamily.all, "updateVariable", this.variables.stream().map(SystemVariable::getKey).toArray());
GridBagUtils.addToPanel(this, variablesCombo, gbc, "gridx=1, gridy=1, gridwidth=10, weightx=0");
GridBagUtils.addToPanel(this, new JLabel(" "), gbc, "gridx=0, gridy=2, gridwidth=11, weighty=1");
int selected = 0;
switch (Bundle.getCurrentOS()) {
case windows:
selected = 0;
break;
case linux:
selected = 1;
break;
case macosx:
selected = 2;
break;
}
this.bundleTabPane.setSelectedIndex(selected);
this.bundleTabPane.setUI(new BasicTabbedPaneUI());
}
示例9: addProductCheckers
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private void addProductCheckers(final StringBuffer description, final JPanel checkersPane,
final GridBagConstraints gbc) {
final ActionListener checkListener = createActionListener();
for (int i = 0; i < allProducts.length; i++) {
Product product = allProducts[i];
boolean checked = false;
for (Product selectedProduct : selectedProducts) {
if (product == selectedProduct) {
checked = true;
numSelected++;
break;
}
}
description.setLength(0);
description.append(product.getDescription() == null ? "" : product.getDescription());
final JCheckBox check = new JCheckBox(getDisplayName(product), 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;
}
}
示例10: createPanel
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
public JPanel createPanel() {
final JPanel roiMaskPanel = GridBagUtils.createPanel();
GridBagConstraints roiMaskPanelConstraints = GridBagUtils.createConstraints("anchor=SOUTHWEST,fill=HORIZONTAL,insets.top=2");
GridBagUtils.addToPanel(roiMaskPanel, useRoiMaskCheckBox, roiMaskPanelConstraints,
",gridy=0,gridx=0,weightx=1");
GridBagUtils.addToPanel(roiMaskPanel, roiMaskComboBox, roiMaskPanelConstraints,
"gridy=1,insets.left=4");
GridBagUtils.addToPanel(roiMaskPanel, showMaskManagerButton, roiMaskPanelConstraints,
"gridheight=2,gridy=0,gridx=1,weightx=0,ipadx=5,insets.left=0");
return roiMaskPanel;
}
示例11: createUI
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private JComponent createUI() {
editExpressionButton = new JButton("Edit Expression...");
editExpressionButton.setName("editExpressionButton");
editExpressionButton.addActionListener(createEditExpressionButtonListener());
final JPanel gridPanel = GridBagUtils.createPanel();
int line = 0;
final GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, paramBand.getEditor().getLabelComponent(), gbc,
"weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST");
GridBagUtils.addToPanel(gridPanel, paramBand.getEditor().getComponent(), gbc,
"weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST");
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, paramBandType.getEditor().getLabelComponent(), gbc,
"weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST");
GridBagUtils.addToPanel(gridPanel, paramBandType.getEditor().getComponent(), gbc,
"weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST");
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, paramBandUnit.getEditor().getLabelComponent(), gbc,
"weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST");
GridBagUtils.addToPanel(gridPanel, paramBandUnit.getEditor().getComponent(), gbc,
"weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST");
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, paramNoDataValue.getEditor().getLabelComponent(), gbc,
"weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST");
GridBagUtils.addToPanel(gridPanel, paramNoDataValue.getEditor().getComponent(), gbc,
"weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST");
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, paramExpression.getEditor().getLabelComponent(), gbc,
"weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=NORTHWEST");
GridBagUtils.addToPanel(gridPanel, paramExpression.getEditor().getComponent(), gbc,
"weightx=1, weighty=1, insets.top=3, gridwidth=2, fill=BOTH, anchor=WEST");
gbc.gridy = ++line;
GridBagUtils.addToPanel(gridPanel, editExpressionButton, gbc,
"weighty=0, insets.top=3, gridwidth=3, fill=NONE, anchor=EAST");
return gridPanel;
}
示例12: createUI
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private void createUI() {
ActionListener productNodeCheckListener = e -> updateUIState();
checkers = new ArrayList<>(10);
JPanel checkersPane = GridBagUtils.createPanel();
setComponentName(checkersPane, "CheckersPane");
GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL");
for (int i = 0; i < productNodes.length; i++) {
ProductNode productNode = productNodes[i];
String name = productNode.getName();
JCheckBox productNodeCheck = new JCheckBox(name);
productNodeCheck.setSelected(selected);
productNodeCheck.setFont(SMALL_PLAIN_FONT);
productNodeCheck.addActionListener(productNodeCheckListener);
if (includeAlways != null
&& StringUtils.containsIgnoreCase(includeAlways, name)) {
productNodeCheck.setSelected(true);
productNodeCheck.setEnabled(false);
} else if (givenProductSubsetDef != null) {
productNodeCheck.setSelected(givenProductSubsetDef.containsNodeName(name));
}
checkers.add(productNodeCheck);
String description = productNode.getDescription();
JLabel productNodeLabel = new JLabel(description != null ? description : " ");
productNodeLabel.setFont(SMALL_ITALIC_FONT);
GridBagUtils.addToPanel(checkersPane, productNodeCheck, gbc, "weightx=0,gridx=0,gridy=" + i);
GridBagUtils.addToPanel(checkersPane, productNodeLabel, gbc, "weightx=1,gridx=1,gridy=" + i);
}
// Add a last 'filler' row
GridBagUtils.addToPanel(checkersPane, new JLabel(" "), gbc,
"gridwidth=2,weightx=1,weighty=1,gridx=0,gridy=" + productNodes.length);
ActionListener allCheckListener = e -> {
if (e.getSource() == allCheck) {
checkAllProductNodes(true);
} else if (e.getSource() == noneCheck) {
checkAllProductNodes(false);
}
updateUIState();
};
allCheck = new JCheckBox("Select all");
allCheck.setName("selectAll");
allCheck.setMnemonic('a');
allCheck.addActionListener(allCheckListener);
noneCheck = new JCheckBox("Select none");
noneCheck.setName("SelectNone");
noneCheck.setMnemonic('n');
noneCheck.addActionListener(allCheckListener);
JScrollPane scrollPane = new JScrollPane(checkersPane);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel buttonRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
buttonRow.add(allCheck);
buttonRow.add(noneCheck);
setLayout(new BorderLayout());
add(scrollPane, BorderLayout.CENTER);
add(buttonRow, BorderLayout.SOUTH);
setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
updateUIState();
}
示例13: initComponents
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
@Override
protected void initComponents() {
init = true;
computePanel = new MultipleRoiComputePanel(this, getRaster());
exportButton = getExportButton();
final JPanel exportAndHelpPanel = GridBagUtils.createPanel();
GridBagConstraints helpPanelConstraints = GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,ipadx=0");
GridBagUtils.addToPanel(exportAndHelpPanel, new JSeparator(), helpPanelConstraints, "fill=HORIZONTAL,gridwidth=2,insets.left=5,insets.right=5");
GridBagUtils.addToPanel(exportAndHelpPanel, exportButton, helpPanelConstraints, "gridy=1,anchor=WEST,fill=NONE");
GridBagUtils.addToPanel(exportAndHelpPanel, getHelpButton(), helpPanelConstraints, "gridx=1,gridy=1,anchor=EAST,fill=NONE");
final JPanel rightPanel = GridBagUtils.createPanel();
GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,insets.right=-2");
GridBagUtils.addToPanel(rightPanel, computePanel, extendedOptionsPanelConstraints, "gridy=0,fill=BOTH,weighty=1");
GridBagUtils.addToPanel(rightPanel, createAccuracyPanel(), extendedOptionsPanelConstraints, "gridy=1,fill=BOTH,weighty=1");
GridBagUtils.addToPanel(rightPanel, exportAndHelpPanel, extendedOptionsPanelConstraints, "gridy=2,anchor=SOUTHWEST,fill=HORIZONTAL,weighty=0");
final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);
hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
hideAndShowButton.setToolTipText("Collapse Options Panel");
hideAndShowButton.setName("switchToChartButton");
hideAndShowButton.addActionListener(new ActionListener() {
private boolean rightPanelShown;
@Override
public void actionPerformed(ActionEvent e) {
rightPanel.setVisible(rightPanelShown);
if (rightPanelShown) {
hideAndShowButton.setIcon(collapseIcon);
hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
hideAndShowButton.setToolTipText("Collapse Options Panel");
} else {
hideAndShowButton.setIcon(expandIcon);
hideAndShowButton.setRolloverIcon(expandRolloverIcon);
hideAndShowButton.setToolTipText("Expand Options Panel");
}
rightPanelShown = !rightPanelShown;
}
});
contentPanel = new JPanel(new GridLayout(-1, 1));
contentPanel.setBackground(Color.WHITE);
contentPanel.addMouseListener(popupHandler);
final JScrollPane contentScrollPane = new JScrollPane(contentPanel);
contentScrollPane.setBorder(null);
contentScrollPane.setBackground(Color.WHITE);
backgroundPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
GridBagUtils.addToPanel(backgroundPanel, contentScrollPane, gbc, "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTH");
GridBagUtils.addToPanel(backgroundPanel, rightPanel, gbc, "gridx=1, fill=VERTICAL, weightx=0.0");
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.add(backgroundPanel);
layeredPane.add(hideAndShowButton);
add(layeredPane);
}
示例14: createAccuracyPanel
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
private JPanel createAccuracyPanel() {
final JPanel accuracyPanel = new JPanel(new GridBagLayout());
final GridBagConstraints gbc = new GridBagConstraints();
final JLabel label = new JLabel("Histogram accuracy:");
accuracyModel = new AccuracyModel();
final BindingContext bindingContext = new BindingContext(PropertyContainer.createObjectBacked(accuracyModel));
final SpinnerNumberModel accuracyNumberModel = new SpinnerNumberModel(accuracyModel.accuracy, 0, Util.MAX_ACCURACY, 1);
final JSpinner accuracySpinner = new JSpinner(accuracyNumberModel);
((JSpinner.DefaultEditor) accuracySpinner.getEditor()).getTextField().setEditable(false);
bindingContext.bind("accuracy", accuracySpinner);
final JCheckBox checkBox = new JCheckBox("Auto accuracy");
bindingContext.bind("useAutoAccuracy", checkBox);
final IntervalValidator rangeValidator = new IntervalValidator(new ValueRange(0, Util.MAX_ACCURACY));
final PropertyDescriptor accuracyDescriptor = bindingContext.getPropertySet().getDescriptor("accuracy");
accuracyDescriptor.setValidator(rangeValidator);
checkBox.setSelected(accuracyModel.useAutoAccuracy);
bindingContext.getPropertySet().getProperty("useAutoAccuracy").addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
label.setEnabled(!checkBox.isSelected());
accuracySpinner.setEnabled(!checkBox.isSelected());
if (checkBox.isSelected()) {
bindingContext.getBinding("accuracy").setPropertyValue(3);
}
computePanel.updateEnablement();
}
});
label.setEnabled(false);
accuracySpinner.setEnabled(false);
accuracySpinner.setToolTipText("Specify the number of histogram bins (#bins: 10^accuracy).");
accuracySpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
computePanel.updateEnablement();
}
});
GridBagUtils.addToPanel(accuracyPanel, new TitledSeparator("Histogram accuracy"), gbc, "fill=HORIZONTAL, weightx=1.0,anchor=NORTH,gridwidth=2");
GridBagUtils.addToPanel(accuracyPanel, checkBox, gbc, "gridy=1,insets.left=5,insets.top=2");
GridBagUtils.addToPanel(accuracyPanel, label, gbc, "gridy=2, insets.left=26,weightx=0.0,fill=NONE,anchor=WEST,gridwidth=1");
GridBagUtils.addToPanel(accuracyPanel, accuracySpinner, gbc, "gridx=1,weightx=1.0,fill=HORIZONTAL,insets.right=5,insets.left=5");
return accuracyPanel;
}
示例15: createUI
import org.esa.snap.ui.GridBagUtils; //导入方法依赖的package包/类
/**
* Responsible for creating the UI layout.
*
* @param chartPanel the panel of the chart
* @param optionsPanel the options panel for changing settings
* @param roiMaskSelector optional ROI mask selector, can be {@code null} if not wanted.
*/
protected void createUI(ChartPanel chartPanel, JPanel optionsPanel, RoiMaskSelector roiMaskSelector) {
this.roiMaskSelector = roiMaskSelector;
final JPanel extendedOptionsPanel = GridBagUtils.createPanel();
GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints("insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0");
if (this.roiMaskSelector != null) {
GridBagUtils.addToPanel(extendedOptionsPanel, this.roiMaskSelector.createPanel(), extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
GridBagUtils.addToPanel(extendedOptionsPanel, new JPanel(), extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
}
GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints, "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1");
GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST");
final SimpleScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
optionsScrollPane.setBorder(null);
optionsScrollPane.getVerticalScrollBar().setUnitIncrement(20);
final JPanel rightPanel = new JPanel(new BorderLayout());
rightPanel.add(createTopPanel(), BorderLayout.NORTH);
rightPanel.add(optionsScrollPane, BorderLayout.CENTER);
rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH);
final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);
hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
hideAndShowButton.setToolTipText("Collapse Options Panel");
hideAndShowButton.setName("switchToChartButton");
hideAndShowButton.addActionListener(new ActionListener() {
private boolean rightPanelShown;
@Override
public void actionPerformed(ActionEvent e) {
rightPanel.setVisible(rightPanelShown);
if (rightPanelShown) {
hideAndShowButton.setIcon(collapseIcon);
hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
hideAndShowButton.setToolTipText("Collapse Options Panel");
} else {
hideAndShowButton.setIcon(expandIcon);
hideAndShowButton.setRolloverIcon(expandRolloverIcon);
hideAndShowButton.setToolTipText("Expand Options Panel");
}
rightPanelShown = !rightPanelShown;
}
});
backgroundPanel = new JPanel(new BorderLayout());
backgroundPanel.add(chartPanel, BorderLayout.CENTER);
backgroundPanel.add(rightPanel, BorderLayout.EAST);
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.add(backgroundPanel, new Integer(0));
layeredPane.add(hideAndShowButton, new Integer(1));
add(layeredPane);
}