private static void loadIcons() { updateIcon = UIUtils.loadImageIcon("/org/esa/snap/productlibrary/icons/refresh24.png", ProductLibraryToolView.class); searchIcon = UIUtils.loadImageIcon("/org/esa/snap/productlibrary/icons/search24.png", ProductLibraryToolView.class); stopIcon = UIUtils.loadImageIcon("icons/Stop24.gif"); addButtonIcon = UIUtils.loadImageIcon("icons/Plus24.gif"); removeButtonIcon = UIUtils.loadImageIcon("icons/Minus24.gif"); helpIcon = UIUtils.loadImageIcon("icons/Help24.gif"); }
/** * Centers the dialog within its parent window. */ public void center() { UIUtils.centerComponent(dialog, parent); }
public static Frame getRootFrame(Component component) { Guardian.assertNotNull("component", component); final Window window = getRootWindow(component); return (window instanceof Frame) ? (Frame) window : null; }
doPreSelection(lonBox, "lon"); doPreSelection(latBox, "lat"); radiusSpinner = UIUtils.createSpinner(defaultRadius, minRadius, maxRadius, smallRadiusStep, bigRadiusStep, "#0"); validMaskField = new JTextField(createDefaultValidMask(product));
/** * Returns the (main) screen's height in pixels. */ public static int getScreenHeight() { return getScreenSize().height; }
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; }
/** * Returns the (main) screen's width in pixels. */ public static int getScreenWidth() { return getScreenSize().width; }
/** * Gets the image icon loaded from the given resource path. * <p>Note that this method only works for images found in the classpath of the class loader which loaded this {@link UIUtils} class. * If you are not sure, you should better use {@link #getImageURL(String, Class)}.</p> * * @param resourcePath the resource path * * @return an image icon loaded from the given resource path or <code>null</code> if it could not be found */ public static ImageIcon loadImageIcon(String resourcePath) { return loadImageIcon(resourcePath, UIUtils.class); }
/** * Centers the given component within the screen area. * <p> The method performs the alignment by setting a newly computed location for the component. It does not alter * the component's size. * * @param comp the component whose location is to be altered * * @throws IllegalArgumentException if the component is <code>null</code> */ public static void centerComponent(Component comp) { centerComponent(comp, null); }
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; }
public static JFrame getRootJFrame(Component component) { Guardian.assertNotNull("component", component); final Window window = getRootWindow(component); return (window instanceof JFrame) ? (JFrame) window : null; }
Dimension screenSize = getScreenSize();
public static JComponent createToolBarSeparator() { if (_separatorIcon == null) { _separatorIcon = UIUtils.loadImageIcon("icons/Separator24.gif"); } return new JLabel(_separatorIcon); }
public void center() { UIUtils.centerComponent(dialog, frame); }
@Test public void testCreateSpinner_WithParameter() { final String labelname = "paramLabel"; final ParamProperties properties = new ParamProperties(Integer.class, Integer.valueOf(3)); properties.setLabel(labelname); final Parameter parameter = new Parameter("paramName", properties); final JSpinner spinner = UIUtils.createSpinner(parameter, Integer.valueOf(10), "#0"); assertEquals(labelname, spinner.getName()); }
private void showInformationDialog(String title, Component component) { final ModalDialog modalDialog = new ModalDialog(UIUtils.getRootWindow(parentComponent), title, AbstractDialog.ID_OK, null); /*I18N*/ modalDialog.setContent(component); modalDialog.show(); } }
@Test public void testGetScreenSize() { try { Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); assertNotNull(UIUtils.getScreenSize()); assertEquals(UIUtils.getScreenSize(), screenSize); } catch (HeadlessException e) { warnHeadless(); } }
private ImageIcon loadIcon(String iconPath) { final ImageIcon icon; URL resource = MaskManagerForm.class.getResource(iconPath); if (resource != null) { icon = new ImageIcon(resource); } else { icon = UIUtils.loadImageIcon(iconPath); } return icon; }
private JDialog createOptionsWindow() { form = new MagicWandForm(this); JDialog optionsWindow = new JDialog(SnapApp.getDefault().getMainFrame(), DIALOG_TITLE, false); UIUtils.centerComponent(optionsWindow, SnapApp.getDefault().getMainFrame()); optionsWindow.getContentPane().add(form.createPanel()); optionsWindow.pack(); return optionsWindow; }
final Comparable max = (Comparable) properties.getMaxValue(); final Double bigStep = spinnerStep.doubleValue() * 10; final JSpinner spinner = createSpinner(v, min, max, spinnerStep, bigStep, formatPattern); spinner.setName(properties.getLabel()); spinner.addChangeListener(e -> param.setValue(spinner.getValue(), null));