private void addComponents(JPanel panel) { GridBagConstraints gbc = new GridBagConstraints(); JScrollPane scrollPane = new JScrollPane(checkBoxList); scrollPane.setPreferredSize(new Dimension(250, 100)); GridBagUtils.addToPanel(panel, statusLabel, gbc, "insets.top=5, anchor=WEST"); GridBagUtils.addToPanel(panel, progressBar, gbc, "gridx=1,fill=HORIZONTAL, weightx=1.0"); GridBagUtils.addToPanel(panel, percentageLabel, gbc, "insets.left=5, gridx=2, fill=NONE, weightx=0.0"); GridBagUtils.addToPanel(panel, field, gbc, "insets.left=0, gridx=0, gridy=1, gridwidth=3, fill=HORIZONTAL, weightx=1.0"); GridBagUtils.addToPanel(panel, scrollPane, gbc, "gridy=2"); GridBagUtils.addToPanel(panel, selectAllButton, gbc, "insets.right=5, gridy=3, gridwidth=1, fill=NONE, weightx=0"); GridBagUtils.addToPanel(panel, selectNoneButton, gbc, "gridx=1"); GridBagUtils.addToPanel(panel, applyButton, gbc, "insets.right=0, gridx=2, gridy=4, anchor=EAST"); }
public static void addHorizontalFiller(JPanel panel, GridBagConstraints gbc) { int fillOld = gbc.fill; int anchorOld = gbc.anchor; double weightxOld = gbc.weightx; if (gbc.gridx >= 0) { gbc.gridx++; } gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.weightx = 1.0; addToPanel(panel, new JLabel(" "), gbc); gbc.weightx = weightxOld; gbc.anchor = anchorOld; gbc.fill = fillOld; }
public static void addVerticalFiller(JPanel panel, GridBagConstraints gbc) { int fillOld = gbc.fill; int anchorOld = gbc.anchor; double weightyOld = gbc.weighty; if (gbc.gridy >= 0) { gbc.gridy++; } gbc.fill = GridBagConstraints.VERTICAL; gbc.anchor = GridBagConstraints.CENTER; gbc.weighty = 200.0; addToPanel(panel, new JLabel(" "), gbc); gbc.weighty = weightyOld; gbc.anchor = anchorOld; gbc.fill = fillOld; }
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; }
private JPanel createInfoPanel() { final JPanel infoPanel = GridBagUtils.createDefaultEmptyBorderPanel(); infoPanel.setBorder(UIUtils.createGroupBorder("Output Product Information")); final GridBagConstraints gbc2 = GridBagUtils.createDefaultConstraints(); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Width:"), gbc2); GridBagUtils.addToPanel(infoPanel, labelWidthInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Height:"), gbc2, "gridy=1, weightx=0"); GridBagUtils.addToPanel(infoPanel, labelHeightInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Latitude:"), gbc2, "gridy=2, weightx=0"); GridBagUtils.addToPanel(infoPanel, labelCenterLatInfo, gbc2, "weightx=1, gridwidth=2"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Longitude:"), gbc2, "gridy=3, weightx=0, gridwidth=1"); GridBagUtils.addToPanel(infoPanel, labelCenterLonInfo, gbc2, "weightx=1, gridwidth=2"); return infoPanel; }
private JPanel createInfoPanel() { _labelWidthInfo = new JLabel(_defaultNumberText); _labelHeightInfo = new JLabel(_defaultNumberText); _labelCenterLatInfo = new JLabel(_defaultLatLonText); _labelCenterLonInfo = new JLabel(_defaultLatLonText); final JPanel infoPanel = GridBagUtils.createDefaultEmptyBorderPanel(); infoPanel.setBorder(UIUtils.createGroupBorder("Output Product Information")); final GridBagConstraints gbc2 = GridBagUtils.createDefaultConstraints(); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Width:"), gbc2); GridBagUtils.addToPanel(infoPanel, _labelWidthInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Height:"), gbc2, "gridy=1, weightx=0"); GridBagUtils.addToPanel(infoPanel, _labelHeightInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Latitude:"), gbc2, "gridy=2, weightx=0"); GridBagUtils.addToPanel(infoPanel, _labelCenterLatInfo, gbc2, "weightx=1, gridwidth=2"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Longitude:"), gbc2, "gridy=3, weightx=0, gridwidth=1"); GridBagUtils.addToPanel(infoPanel, _labelCenterLonInfo, gbc2, "weightx=1, gridwidth=2"); return infoPanel; }
private JPanel createOptionsPanel() { toggleColorCheckBox = new JCheckBox("Invert plot colors"); toggleColorCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent 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"); GridBagUtils.addToPanel(optionsPanel, xBandList, gbc, "gridy=1,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, axisRangeControls[Y_VAR].getPanel(), gbc, "gridy=2,insets.left=0,insets.right=0"); GridBagUtils.addToPanel(optionsPanel, yBandList, gbc, "gridy=3,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=4"); GridBagUtils.addToPanel(optionsPanel, new JSeparator(), gbc, "gridy=5,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, toggleColorCheckBox, gbc, "gridy=6,insets.left=0,insets.right=0"); return optionsPanel; }
/** * Adds a component to a panel with a grid bag layout. <p>For the <code>code</code> parameter, see also {@link * #setAttributes(GridBagConstraints, String)}. * * @param panel the panel to which to add the component * @param comp the component to be added * @param gbc the grid bag constraints to be used, can be <code>null</code> if <code>code</code> is not * <code>null</code> * @param code the code containing the constraints, can be <code>null</code> if <code>gbc</code> is not * <code>null</code> * @see #setAttributes(GridBagConstraints, String) */ public static void addToPanel(JPanel panel, Component comp, GridBagConstraints gbc, String code) { addToPanel(panel, comp, setAttributes(gbc, code)); }
private void createUI() { _buttonHorizontal = new JRadioButton("horizontally"); _buttonVertical = new JRadioButton("vertically"); _buttonBoth = new JRadioButton("horizontally & vertically"); final ButtonGroup group = new ButtonGroup(); group.add(_buttonHorizontal); group.add(_buttonVertical); group.add(_buttonBoth); _buttonHorizontal.setSelected(true); int line = 0; JPanel dialogPane = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); gbc.gridy = ++line; GridBagUtils.addToPanel(dialogPane, new JLabel("Input Product:"), gbc, "fill=BOTH, gridwidth=4"); gbc.gridy = ++line; GridBagUtils.addToPanel(dialogPane, new JLabel(getSourceProduct().getDisplayName()), gbc); gbc.gridy = ++line; GridBagUtils.addToPanel(dialogPane, getNameAndDescPanel(), gbc, "insets.top=15"); gbc.gridy = ++line; GridBagUtils.addToPanel(dialogPane, new JLabel("Flip Data "), gbc, "gridwidth=1"); GridBagUtils.addToPanel(dialogPane, _buttonHorizontal, gbc); GridBagUtils.addToPanel(dialogPane, _buttonVertical, gbc); GridBagUtils.addToPanel(dialogPane, _buttonBoth, gbc); gbc.gridy = ++line; GridBagUtils.addToPanel(dialogPane, createInfoPanel(), gbc, "gridwidth=4"); setContent(dialogPane); }
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; }
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, (double) 1, "#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, (double) 1, "#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, (double) 1, "#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, (double) 1, "#0.00#"), gbc, "gridx=1,gridy=3"); return geoCoordinatesPane; }
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; } }
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; } }
/** * Creates the user interface from the UI component passed in tby the transform */ private void createUI() { JPanel dialogPane = GridBagUtils.createPanel(); dialogPane.setBorder(new EmptyBorder(2, 2, 2, 2)); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); GridBagUtils.addToPanel(dialogPane, getTransformUI().getUIComponent(), gbc, "gridwidth=1,insets.top=0"); setContent(dialogPane); } }
private void createUI() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createTitledBorder("Digital Elevation Model (DEM)")); /*I18N*/ final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add((AbstractButton) _paramProductDem.getEditor().getComponent()); buttonGroup.add((AbstractButton) _paramExternalDem.getEditor().getComponent()); GridBagUtils.setAttributes(gbc, "insets.top=3, fill=HORIZONTAL"); gbc.gridy++; GridBagUtils.addToPanel(this, _paramProductDem.getEditor().getComponent(), gbc); gbc.gridy++; GridBagUtils.addToPanel(this, _paramExternalDem.getEditor().getComponent(), gbc, "weightx=1"); GridBagUtils.addToPanel(this, _paramDem.getEditor().getComponent(), gbc, "weightx=999"); }
private JPanel getNameAndDescPanel() { int line = 0; final JPanel nameAndDescPanel = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbc, "insets.top=3, fill=HORIZONTAL"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, new JLabel("Output Product"), gbc, "weightx=1, gridwidth=2"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, _paramNewName.getEditor().getLabelComponent(), gbc, "gridwidth=1"); GridBagUtils.addToPanel(nameAndDescPanel, _paramNewName.getEditor().getComponent(), gbc, "weightx=999"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, _paramNewDesc.getEditor().getLabelComponent(), gbc, "weightx=1"); GridBagUtils.addToPanel(nameAndDescPanel, _paramNewDesc.getEditor().getComponent(), gbc, "weightx=999"); JComponent jComponent = _paramNewName.getEditor().getEditorComponent(); if (jComponent instanceof JTextComponent) { JTextComponent tc = (JTextComponent) jComponent; tc.selectAll(); } return nameAndDescPanel; }
private JPanel createPageUI() { Parameter param; GridBagConstraints gbc; final JPanel productCompatibility = GridBagUtils.createPanel(); productCompatibility.setBorder(UIUtils.createGroupBorder("Product Compatibility")); /*I18N*/ gbc = GridBagUtils.createConstraints("fill=HORIZONTAL, anchor=WEST, weightx=1, gridy=1"); param = getConfigParam(PROPERTY_KEY_GEOLOCATION_EPS); gbc.insets.bottom += 8; gbc.gridwidth = 3; productCompatibility.add(new JLabel("Consider products as spatially compatible:"), gbc); /*I18N*/ gbc.insets.bottom -= 8; gbc.gridy++; GridBagUtils.addToPanel(productCompatibility, param.getEditor().getLabelComponent(), gbc, "gridwidth=1"); GridBagUtils.addToPanel(productCompatibility, param.getEditor().getEditorComponent(), gbc, "weightx=1"); GridBagUtils.addToPanel(productCompatibility, param.getEditor().getPhysUnitLabelComponent(), gbc, "weightx=0"); // UI JPanel pageUI = GridBagUtils.createPanel(); gbc = GridBagUtils.createConstraints("fill=HORIZONTAL, anchor=WEST, weightx=1, gridy=1"); pageUI.add(productCompatibility, gbc); gbc.gridy++; return createPageUIContentPane(pageUI); } }
public void testGridBagPanel_sevenParams() { GridBagLayout gbl = new GridBagLayout(); JPanel panel = new JPanel(gbl); JLabel comp = new JLabel("text"); final GridBagConstraints gbconstraints = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbconstraints, "gridx=2, gridy=4, anchor=SOUTHEAST, weighty=1.3, insets.top=5"); GridBagUtils.addToPanel(panel, comp, gbconstraints); GridBagConstraints gbc = gbl.getConstraints(comp); assertEquals(GridBagConstraints.SOUTHEAST, gbc.anchor); assertEquals(5, gbc.insets.top); assertEquals(3, gbc.insets.left); assertEquals(0, gbc.insets.bottom); assertEquals(3, gbc.insets.right); assertEquals(2, gbc.gridx); assertEquals(4, gbc.gridy); assertEquals(0, gbc.weightx, 0.01); assertEquals(1.3, gbc.weighty, 0.01); assertEquals(0, gbc.ipadx); assertEquals(0, gbc.ipady); assertEquals(1, gbc.gridheight); assertEquals(1, gbc.gridwidth); }
public void testGridBagPanel_fourParams() { GridBagLayout gbl = new GridBagLayout(); JPanel panel = new JPanel(gbl); JLabel comp = new JLabel("text"); final GridBagConstraints gbconstr = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbconstr, "gridx=2, gridy=4"); GridBagUtils.addToPanel(panel, comp, gbconstr); GridBagConstraints gbc = gbl.getConstraints(comp); assertEquals(GridBagConstraints.WEST, gbc.anchor); assertEquals(0, gbc.insets.top); assertEquals(3, gbc.insets.left); assertEquals(0, gbc.insets.bottom); assertEquals(3, gbc.insets.right); assertEquals(2, gbc.gridx); assertEquals(4, gbc.gridy); assertEquals(0, gbc.weightx, 0.01); assertEquals(0, gbc.weighty, 0.01); assertEquals(0, gbc.ipadx); assertEquals(0, gbc.ipady); assertEquals(1, gbc.gridheight); assertEquals(1, gbc.gridwidth); }
public void testGridBagPanel_eightParams() { GridBagLayout gbl = new GridBagLayout(); JPanel panel = new JPanel(gbl); JLabel comp = new JLabel("text"); final GridBagConstraints gbconstraints = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbconstraints, "gridx=2, gridy=4, anchor=SOUTHEAST, weighty=1.3, insets.top=5, gridwidth=3"); GridBagUtils.addToPanel(panel, comp, gbconstraints); GridBagConstraints gbc = gbl.getConstraints(comp); assertEquals(GridBagConstraints.SOUTHEAST, gbc.anchor); assertEquals(5, gbc.insets.top); assertEquals(3, gbc.insets.left); assertEquals(0, gbc.insets.bottom); assertEquals(3, gbc.insets.right); assertEquals(2, gbc.gridx); assertEquals(4, gbc.gridy); assertEquals(0, gbc.weightx, 0.01); assertEquals(1.3, gbc.weighty, 0.01); assertEquals(0, gbc.ipadx); assertEquals(0, gbc.ipady); assertEquals(1, gbc.gridheight); assertEquals(3, gbc.gridwidth); }