List of usage examples for java.awt GridBagLayout setConstraints
public void setConstraints(Component comp, GridBagConstraints constraints)
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
public void init() { this.addWindowListener(getWindowClosingListener()); this.setTitle(windowTitle); this.setSize(windowWidth, windowHeight); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JPanel containerPanel = new JPanel(); getContentPane().add(containerPanel); /*//from ww w . j a va 2 s. c om * Use a BorderLayout for the main container so we can use the SOUTH * panel as a status bar and use the NORTH panel as a menu bar, etc. */ containerPanel.setLayout(new BorderLayout()); JPanel bottomPanel = new JPanel(); containerPanel.add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); bottomPanel.add(buttonPanel, BorderLayout.CENTER); GridLayout gridLayout = new GridLayout(1, 2, 5, 5); buttonPanel.setLayout(gridLayout); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); startButton = new JButton(startButtonText); startButton.addActionListener(getStartButtonActionListener(false)); buttonPanel.add(startButton); debugButton = new JButton(debugButtonText); debugButton.addActionListener(getStartButtonActionListener(true)); buttonPanel.add(debugButton); continueButton = new JButton(continueButtonText); continueButton.addActionListener(getContinueButtonActionListener()); buttonPanel.add(continueButton); continueButton.setEnabled(false); stopButton = new JButton(stopButtonText); stopButton.addActionListener(getStopButtonActionListener()); buttonPanel.add(stopButton); stopButton.setEnabled(false); JPanel statusPanel = new JPanel(); bottomPanel.add(statusPanel, BorderLayout.SOUTH); statusLabel = new JLabel(statusNotRunning); statusPanel.add(statusLabel); /* * Next make a grid bag for the thirteen input elements with labels on * the left and spinners on the right. */ JPanel mainPanel = new JPanel(); GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST; mainPanel.setLayout(gridBagLayout); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); containerPanel.add(mainPanel, BorderLayout.CENTER); List<Cipher> ciphers = cipherDao.findAll(); cipherMap = new HashMap<String, Cipher>(); cipherComboBox = new JComboBox<String>(); String cipherName; for (Cipher cipher : ciphers) { cipherName = cipher.getName(); cipherMap.put(cipherName, cipher); cipherComboBox.addItem(cipherName); if (cipher.getName().equals(defaultCipher)) { cipherComboBox.setSelectedItem(cipherName); } } JLabel cipherNameLabel = new JLabel(cipherNameText); cipherComboBox.addActionListener(getCipherComboBoxActionListener()); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(cipherNameLabel, constraints); mainPanel.add(cipherNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(cipherComboBox, constraints); mainPanel.add(cipherComboBox); appendGenerationsSpinner(gridBagLayout, constraints, mainPanel); appendRunContinuouslyCheckBox(gridBagLayout, constraints, mainPanel); appendPopulationSpinner(gridBagLayout, constraints, mainPanel); appendLifespanSpinner(gridBagLayout, constraints, mainPanel); appendSurvivalRateSpinner(gridBagLayout, constraints, mainPanel); appendMutationRateSpinner(gridBagLayout, constraints, mainPanel); appendMaxMutationsPerIndividualSpinner(gridBagLayout, constraints, mainPanel); appendCrossoverRateSpinner(gridBagLayout, constraints, mainPanel); appendMutateDuringCrossoverCheckBox(gridBagLayout, constraints, mainPanel); appendFitnessEvaluatorComboBox(gridBagLayout, constraints, mainPanel); appendCrossoverAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendMutationAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectionAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectorComboBox(gridBagLayout, constraints, mainPanel); appendCompareToKnownSolutionCheckBox(gridBagLayout, constraints, mainPanel); SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(true); toFront(); } }); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private JPanel setUpFieldListPanel() { JPanel inputPanel = new JPanel(); // Panel Layout GridBagLayout gbl = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); con.weightx = 0;//from w ww .j a v a 2 s .c o m con.insets = new Insets(5, 5, 0, 5); con.fill = GridBagConstraints.HORIZONTAL; inputPanel.setLayout(gbl); // Border TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), Localization.lang("Work options")); inputPanel.setBorder(titledBorder1); inputPanel.setMinimumSize(new Dimension(10, 10)); JScrollPane fieldScroller = new JScrollPane(fieldList); fieldScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); // insert buttons insertButton.addActionListener(event -> insertTextForTag(override.isSelected())); // Radio buttons append.setToolTipText(Localization.lang("Append the selected text to BibTeX field")); append.setMnemonic(KeyEvent.VK_A); append.setSelected(true); override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text")); override.setMnemonic(KeyEvent.VK_O); override.setSelected(false); //Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(append); group.add(override); JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(append); radioPanel.add(override); // insert sub components JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields")); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(label1, con); inputPanel.add(label1); con.gridwidth = GridBagConstraints.REMAINDER; con.gridheight = 8; con.weighty = 1; con.fill = GridBagConstraints.BOTH; gbl.setConstraints(fieldScroller, con); inputPanel.add(fieldScroller); con.fill = GridBagConstraints.HORIZONTAL; con.weighty = 0; con.gridwidth = 2; gbl.setConstraints(radioPanel, con); inputPanel.add(radioPanel); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(insertButton, con); inputPanel.add(insertButton); return inputPanel; }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);//from w ww . j a v a 2s. c o m compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * Creates a new RegistryBrowser object. *//*from w w w.j a va 2 s. com*/ @SuppressWarnings("unchecked") private RegistryBrowser() { instance = this; classLoader = getClass().getClassLoader(); // new // JAXRBrowserClassLoader(getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); /* * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch * (ClassNotFoundException e) { * log.error("Could not find class javax.xml.soap.SOAPMessage", e); } */ UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane())); // add listener for 'locale' bound property addPropertyChangeListener(PROPERTY_LOCALE, this); menuBar = new JMenuBar(); fileMenu = new JMenu(); editMenu = new JMenu(); viewMenu = new JMenu(); helpMenu = new JMenu(); JSeparator JSeparator1 = new JSeparator(); newItem = new JMenuItem(); importItem = new JMenuItem(); saveItem = new JMenuItem(); saveAsItem = new JMenuItem(); exitItem = new JMenuItem(); cutItem = new JMenuItem(); copyItem = new JMenuItem(); pasteItem = new JMenuItem(); aboutItem = new JMenuItem(); setJMenuBar(menuBar); setTitle(resourceBundle.getString("title.registryBrowser.java")); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); // Scale window to be centered using 70% of screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7), (int) (dim.getHeight() * .75)); setVisible(false); saveFileDialog.setMode(FileDialog.SAVE); saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title")); GridBagLayout gb = new GridBagLayout(); topPanel.setLayout(gb); getContentPane().add("North", topPanel); GridBagConstraints c = new GridBagConstraints(); toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); toolbarPanel.setBounds(0, 0, 488, 29); discoveryToolBar = createDiscoveryToolBar(); toolbarPanel.add(discoveryToolBar); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(toolbarPanel, c); topPanel.add(toolbarPanel); // Panel containing context info like registry location and user context JPanel contextPanel = new JPanel(); GridBagLayout gb1 = new GridBagLayout(); contextPanel.setLayout(gb1); locationLabel = new JLabel(resourceBundle.getString("label.registryLocation")); // locationLabel.setPreferredSize(new Dimension(80, 23)); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.5; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 0, 0); gb1.setConstraints(locationLabel, c); // contextPanel.setBackground(Color.green); contextPanel.add(locationLabel); selectAnItemText = new ItemText(selectAnItem); registryCombo.addItem(selectAnItemText.toString()); ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType(); RegistryURIListType urlList = uiConfigurationType.getRegistryURIList(); List<String> urls = urlList.getRegistryURI(); Iterator<String> urlsIter = urls.iterator(); while (urlsIter.hasNext()) { ItemText url = new ItemText(urlsIter.next()); registryCombo.addItem(url.toString()); } registryCombo.setEditable(true); registryCombo.setEnabled(true); registryCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final String url = (String) registryCombo.getSelectedItem(); if ((url == null) || (url.equals(selectAnItem))) { return; } // Clean tabbedPaneParent. Will create new content tabbedPaneParent.removeAll(); conceptsTreeDialog = null; ConceptsTreeDialog.clearCache(); // design: // 1. connect and construct tabbedPane in a now swing thread // 2. add tabbedPane in swing thread // 3. call reloadModel that should use WingWorkers final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) { public Object doNonUILogic() { try { // Try to connect if (connectToRegistry(url)) { return new JBTabbedPane(); } } catch (JAXRException e1) { displayError(e1); } return null; } public void doUIUpdateLogic() { tabbedPane = (JBTabbedPane) get(); if (tabbedPane != null) { tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER); tabbedPane.reloadModel(); try { // DBH 1/30/04 - Add the submissions panel if // the user is authenticated. ConnectionImpl connection = RegistryBrowser.client.connection; boolean newValue = connection.isAuthenticated(); firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue); getRootPane().updateUI(); } catch (JAXRException e1) { displayError(e1); } } } }; worker1.start(); } }); // c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 5, 0); gb1.setConstraints(registryCombo, c); contextPanel.add(registryCombo); JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"), SwingConstants.TRAILING); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); gb1.setConstraints(currentUserLabel, c); // contextPanel.add(currentUserLabel); currentUserText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @SuppressWarnings("unused") String text = currentUserText.getText(); } }); currentUserText.setEditable(false); c.gridx = 3; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 5, 5); gb1.setConstraints(currentUserText, c); // contextPanel.add(currentUserText); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(contextPanel, c); topPanel.add(contextPanel, c); tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); tabbedPaneParent.setLayout(new BorderLayout()); tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip")); getContentPane().add("Center", tabbedPaneParent); fileMenu.setText(resourceBundle.getString("menu.file")); fileMenu.setActionCommand("File"); fileMenu.setMnemonic((int) 'F'); menuBar.add(fileMenu); saveItem.setHorizontalTextPosition(SwingConstants.TRAILING); saveItem.setText(resourceBundle.getString("menu.save")); saveItem.setActionCommand("Save"); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); saveItem.setMnemonic((int) 'S'); // fileMenu.add(saveItem); fileMenu.add(JSeparator1); importItem.setText(resourceBundle.getString("menu.import")); importItem.setActionCommand("Import"); importItem.setMnemonic((int) 'I'); importItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); importFromFile(); RegistryBrowser.setDefaultCursor(); } }); fileMenu.add(importItem); exitItem.setText(resourceBundle.getString("menu.exit")); exitItem.setActionCommand("Exit"); exitItem.setMnemonic((int) 'X'); fileMenu.add(exitItem); editMenu.setText(resourceBundle.getString("menu.edit")); editMenu.setActionCommand("Edit"); editMenu.setMnemonic((int) 'E'); // menuBar.add(editMenu); cutItem.setHorizontalTextPosition(SwingConstants.TRAILING); cutItem.setText(resourceBundle.getString("menu.cut")); cutItem.setActionCommand("Cut"); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.setMnemonic((int) 'T'); editMenu.add(cutItem); copyItem.setHorizontalTextPosition(SwingConstants.TRAILING); copyItem.setText(resourceBundle.getString("menu.copy")); copyItem.setActionCommand("Copy"); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.setMnemonic((int) 'C'); editMenu.add(copyItem); pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING); pasteItem.setText(resourceBundle.getString("menu.paste")); pasteItem.setActionCommand("Paste"); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setMnemonic((int) 'P'); editMenu.add(pasteItem); viewMenu.setText(resourceBundle.getString("menu.view")); viewMenu.setActionCommand("view"); viewMenu.setMnemonic((int) 'V'); themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes); viewMenu.add(themeMenu); menuBar.add(viewMenu); helpMenu.setText(resourceBundle.getString("menu.help")); helpMenu.setActionCommand("Help"); helpMenu.setMnemonic((int) 'H'); menuBar.add(helpMenu); aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING); aboutItem.setText(resourceBundle.getString("menu.about")); aboutItem.setActionCommand("About..."); aboutItem.setMnemonic((int) 'A'); aboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] aboutArgs = { BROWSER_VERSION }; MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text")); JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs), resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE); } }); helpMenu.add(aboutItem); // REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); saveItem.addActionListener(lSymAction); exitItem.addActionListener(lSymAction); SwingUtilities.updateComponentTreeUI(getContentPane()); SwingUtilities.updateComponentTreeUI(menuBar); SwingUtilities.updateComponentTreeUI(fileChooser); // Auto select the registry that is configured to connect to by default String selectedIndexStr = ProviderProperties.getInstance() .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0"); int index = Integer.parseInt(selectedIndexStr); try { registryCombo.setSelectedIndex(index); } catch (IllegalArgumentException e) { Object[] invalidIndexArguments = { new Integer(index) }; MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex")); displayError(form.format(invalidIndexArguments), e); } }
From source file:gdsc.smlm.ij.plugins.PeakFit.java
@SuppressWarnings("unchecked") private int showDialog(ImagePlus imp) { // Executing as an ImageJ plugin. // Override the defaults with those in the configuration file String filename = SettingsManager.getSettingsFilename(); if (simpleFit) { return showSimpleDialog(filename); }//www . j a v a 2 s . c om GlobalSettings settings = SettingsManager.loadSettings(filename); calibration = settings.getCalibration(); config = settings.getFitEngineConfiguration(); fitConfig = config.getFitConfiguration(); resultsSettings = settings.getResultsSettings(); boolean isCrop = (bounds != null && imp != null && (bounds.width < imp.getWidth() || bounds.height < imp.getHeight())); if (!extraOptions) { integrateFrames = 1; resultsSettings.imageRollingWindow = 0; fitConfig.setBackgroundFitting(true); fitConfig.setMinIterations(0); fitConfig.setNoise(0); config.setNoiseMethod(Method.QUICK_RESIDUALS_LEAST_MEAN_OF_SQUARES); showProcessedFrames = false; } GenericDialog gd = new GenericDialog(TITLE); gd.addHelp(About.HELP_URL); gd.addMessage( (maximaIdentification) ? "Identify candidate maxima" : "Fit 2D Gaussian to identified maxima"); gd.addStringField("Config_file", filename, 40); gd.addNumericField("Calibration (nm/px)", calibration.nmPerPixel, 2); gd.addNumericField("Gain (ADU/photon)", calibration.gain, 2); gd.addCheckbox("EM-CCD", calibration.emCCD); gd.addNumericField("Exposure_time (ms)", calibration.exposureTime, 2); if (isCrop) gd.addCheckbox("Ignore_bounds_for_noise", optionIgnoreBoundsForNoise); // This is already set to false before the dialog is displayed //else // ignoreBoundsForNoise = false; gd.addNumericField("Initial_StdDev0", fitConfig.getInitialPeakStdDev0(), 3); if (!maximaIdentification) { gd.addNumericField("Initial_StdDev1", fitConfig.getInitialPeakStdDev1(), 3); gd.addNumericField("Initial_Angle", fitConfig.getInitialAngle(), 3); } String[] filterTypes = SettingsManager.getNames((Object[]) DataFilterType.values()); gd.addChoice("Spot_filter_type", filterTypes, filterTypes[config.getDataFilterType().ordinal()]); String[] filterNames = SettingsManager.getNames((Object[]) DataFilter.values()); gd.addChoice("Spot_filter", filterNames, filterNames[config.getDataFilter(0).ordinal()]); gd.addSlider("Smoothing", 0, 2.5, config.getSmooth(0)); gd.addSlider("Search_width", 0.5, 2.5, config.getSearch()); gd.addSlider("Border", 0.5, 2.5, config.getBorder()); gd.addSlider("Fitting_width", 2, 4.5, config.getFitting()); if (extraOptions && !fitMaxima) { gd.addCheckbox("Interlaced_data", optionInterlacedData); gd.addSlider("Integrate_frames", 1, 5, optionIntegrateFrames); } Component discardLabel = null; if (!maximaIdentification) { gd.addMessage("--- Gaussian fitting ---"); String[] solverNames = SettingsManager.getNames((Object[]) FitSolver.values()); gd.addChoice("Fit_solver", solverNames, solverNames[fitConfig.getFitSolver().ordinal()]); String[] functionNames = SettingsManager.getNames((Object[]) FitFunction.values()); gd.addChoice("Fit_function", functionNames, functionNames[fitConfig.getFitFunction().ordinal()]); if (extraOptions) gd.addCheckbox("Fit_background", fitConfig.isBackgroundFitting()); // Parameters specific to each Fit solver are collected in a second dialog gd.addNumericField("Fail_limit", config.getFailuresLimit(), 0); gd.addCheckbox("Include_neighbours", config.isIncludeNeighbours()); gd.addSlider("Neighbour_height", 0.01, 1, config.getNeighbourHeightThreshold()); gd.addSlider("Residuals_threshold", 0.01, 1, config.getResidualsThreshold()); gd.addSlider("Duplicate_distance", 0, 1.5, fitConfig.getDuplicateDistance()); gd.addMessage("--- Peak filtering ---\nDiscard fits that shift; are too low; or expand/contract"); discardLabel = gd.getMessage(); gd.addSlider("Shift_factor", 0.01, 2, fitConfig.getCoordinateShiftFactor()); gd.addNumericField("Signal_strength", fitConfig.getSignalStrength(), 2); gd.addNumericField("Min_photons", fitConfig.getMinPhotons(), 0); if (extraOptions) { gd.addNumericField("Noise", fitConfig.getNoise(), 2); String[] noiseMethodNames = SettingsManager.getNames((Object[]) Method.values()); gd.addChoice("Noise_method", noiseMethodNames, noiseMethodNames[config.getNoiseMethod().ordinal()]); } gd.addSlider("Width_factor", 0.01, 5, fitConfig.getWidthFactor()); gd.addNumericField("Precision", fitConfig.getPrecisionThreshold(), 2); } gd.addMessage("--- Results ---"); gd.addCheckbox("Log_progress", resultsSettings.logProgress); if (!maximaIdentification) { gd.addCheckbox("Show_deviations", resultsSettings.showDeviations); } String[] tableNames = SettingsManager.getNames((Object[]) ResultsTable.values()); gd.addChoice("Results_table", tableNames, tableNames[resultsSettings.getResultsTable().ordinal()]); String[] imageNames = SettingsManager.getNames((Object[]) ResultsImage.values()); gd.addMessage("--- Image output ---"); gd.addChoice("Image", imageNames, imageNames[resultsSettings.getResultsImage().ordinal()]); gd.addCheckbox("Weighted", resultsSettings.weightedImage); gd.addCheckbox("Equalised", resultsSettings.equalisedImage); gd.addSlider("Image_Precision (nm)", 5, 30, resultsSettings.precision); gd.addSlider("Image_Scale", 1, 15, resultsSettings.imageScale); if (extraOptions) { gd.addNumericField("Image_window", resultsSettings.imageRollingWindow, 0); gd.addCheckbox("Show_processed_frames", optionShowProcessedFrames); } gd.addMessage("--- File output ---"); gd.addStringField("Results_dir", resultsSettings.resultsDirectory); gd.addCheckbox("Binary_results", resultsSettings.binaryResults); gd.addMessage(" "); gd.addCheckbox("Results_in_memory", resultsSettings.resultsInMemory); // Re-arrange the standard layout which has a GridBagLayout with 2 columns (label,field) // to 4 columns: (label,field) x 2 if (gd.getLayout() != null) { GridBagLayout grid = (GridBagLayout) gd.getLayout(); int xOffset = 0, yOffset = 0; int lastY = -1, rowCount = 0; for (Component comp : gd.getComponents()) { // Check if this should be the second major column if (comp == discardLabel) { xOffset += 2; yOffset -= rowCount; } // Reposition the field GridBagConstraints c = grid.getConstraints(comp); if (lastY != c.gridy) rowCount++; lastY = c.gridy; c.gridx = c.gridx + xOffset; c.gridy = c.gridy + yOffset; c.insets.left = c.insets.left + 10 * xOffset; c.insets.top = 0; c.insets.bottom = 0; grid.setConstraints(comp, c); } if (IJ.isLinux()) gd.setBackground(new Color(238, 238, 238)); } // Add a mouse listener to the config file field if (!(java.awt.GraphicsEnvironment.isHeadless() || IJ.isMacro())) { Vector<TextField> texts = (Vector<TextField>) gd.getStringFields(); Vector<TextField> numerics = (Vector<TextField>) gd.getNumericFields(); Vector<Checkbox> checkboxes = (Vector<Checkbox>) gd.getCheckboxes(); Vector<Choice> choices = (Vector<Choice>) gd.getChoices(); int n = 0; int t = 0; int b = 0; int ch = 0; textConfigFile = texts.get(t++); textConfigFile.addMouseListener(this); textConfigFile.addTextListener(this); // TODO: add a value changed listener to detect when typing a new file textNmPerPixel = numerics.get(n++); textGain = numerics.get(n++); textEMCCD = checkboxes.get(b++); textExposure = numerics.get(n++); textInitialPeakStdDev0 = numerics.get(n++); if (!maximaIdentification) { textInitialPeakStdDev1 = numerics.get(n++); textInitialAngleD = numerics.get(n++); } textDataFilterType = choices.get(ch++); textDataFilter = choices.get(ch++); textSmooth = numerics.get(n++); textSearch = numerics.get(n++); textBorder = numerics.get(n++); textFitting = numerics.get(n++); if (extraOptions && !fitMaxima) { b++; // Skip over the interlaced data option n++; // Skip over the integrate frames option } if (!maximaIdentification) { textFitSolver = choices.get(ch++); textFitFunction = choices.get(ch++); if (extraOptions) textFitBackground = checkboxes.get(b++); textFailuresLimit = numerics.get(n++); textIncludeNeighbours = checkboxes.get(b++); textNeighbourHeightThreshold = numerics.get(n++); textResidualsThreshold = numerics.get(n++); textDuplicateDistance = numerics.get(n++); textCoordinateShiftFactor = numerics.get(n++); textSignalStrength = numerics.get(n++); textMinPhotons = numerics.get(n++); textWidthFactor = numerics.get(n++); textPrecisionThreshold = numerics.get(n++); if (extraOptions) { textNoise = numerics.get(n++); textNoiseMethod = choices.get(ch++); } } textLogProgress = checkboxes.get(b++); if (!maximaIdentification) textShowDeviations = checkboxes.get(b++); textResultsTable = choices.get(ch++); textResultsImage = choices.get(ch++); textWeightedImage = checkboxes.get(b++); textEqualisedImage = checkboxes.get(b++); textPrecision = numerics.get(n++); textImageScale = numerics.get(n++); if (extraOptions) { textImageRollingWindow = numerics.get(n++); b++; // Skip over show processed frames option } textResultsDirectory = texts.get(t++); textResultsDirectory.addMouseListener(this); textBinaryResults = checkboxes.get(b++); textResultsInMemory = checkboxes.get(b++); } gd.showDialog(); if (gd.wasCanceled() || !readDialog(settings, gd, isCrop)) return DONE; if (imp != null) { // Store whether the user selected to process all the images. int flags = IJ.setupDialog(imp, plugin_flags); // Check if cancelled if ((flags & DONE) != 0) return DONE; if ((flags & DOES_STACKS) == 0) { // Save the slice number for the overlay singleFrame = imp.getCurrentSlice(); // Account for interlaced data if (interlacedData) { int start = singleFrame; // Calculate the first frame that is not skipped while (ignoreFrame(start) && start > dataStart) start--; if (start < dataStart) { log("The current frame (%d) is before the start of the interlaced data", singleFrame); return DONE; } if (start != singleFrame) log("Updated the current frame (%d) to a valid interlaced data frame (%d)", singleFrame, start); singleFrame = start; } // Account for integrated frames int endFrame = singleFrame; if (integrateFrames > 1) { int totalFrames = 1; while (totalFrames < integrateFrames) { endFrame++; if (!ignoreFrame(endFrame)) totalFrames++; } log("Updated the image end frame (%d) to %d allow %d integrated frames", singleFrame, endFrame, integrateFrames); } // Create a new image source with the correct frames setSource(new IJImageSource(imp, singleFrame, endFrame - singleFrame)); // Store the image so the results can be added as an overlay this.imp = imp; this.imp.setOverlay(null); } } // Allow interlaced data by wrapping the image source if (interlacedData) { setSource(new InterlacedImageSource(this.source, dataStart, dataBlock, dataSkip)); } // Allow frame aggregation by wrapping the image source if (integrateFrames > 1) { setSource(new AggregatedImageSource(this.source, integrateFrames)); } // Ask if the user wants to log progress on multiple frame images if (resultsSettings.logProgress && source.getFrames() > 1) { gd = new GenericDialog(TITLE); gd.addMessage("Warning: Log progress on multiple-frame image will be slow"); gd.addCheckbox("Log_progress", resultsSettings.logProgress); gd.showDialog(); if (gd.wasCanceled()) return DONE; resultsSettings.logProgress = gd.getNextBoolean(); if (!resultsSettings.logProgress) SettingsManager.saveSettings(settings, filename); } // Get a bias if required if (resultsSettings.getResultsTable() == ResultsTable.CALIBRATED && calibration.bias == 0) { gd = new GenericDialog(TITLE); gd.addMessage("Calibrated results requires a camera bias"); gd.addNumericField("Camera_bias (ADUs)", calibration.bias, 2); gd.showDialog(); if (!gd.wasCanceled()) { calibration.bias = Math.abs(gd.getNextNumber()); if (calibration.bias > 0) SettingsManager.saveSettings(settings, filename); } } // Return the plugin flags (without the DOES_STACKS flag). // The call to run(ImageProcessor) will process the image in 'this.imp' so we only want a // single call to be made. return plugin_flags; }
From source file:gdsc.smlm.ij.plugins.CreateData.java
/** * Show a dialog allowing the parameters for a simple/benchmark simulation to be performed * /*from w ww . java 2 s . com*/ * @return True if the parameters were collected */ private boolean showSimpleDialog() { GenericDialog gd = new GenericDialog(TITLE); globalSettings = SettingsManager.loadSettings(); settings = globalSettings.getCreateDataSettings(); // Image size gd.addMessage("--- Image Size ---"); gd.addNumericField("Pixel_pitch (nm)", settings.pixelPitch, 2); gd.addNumericField("Size (px)", settings.size, 0); if (!benchmarkMode) { gd.addNumericField("Depth (nm)", settings.depth, 0); gd.addCheckbox("Fixed_depth", settings.fixedDepth); } // Noise model gd.addMessage("--- Noise Model ---"); if (extraOptions) gd.addCheckbox("No_poisson_noise", !settings.poissonNoise); gd.addNumericField("Background (photons)", settings.background, 2); gd.addNumericField("EM_gain", settings.getEmGain(), 2); gd.addNumericField("Camera_gain (ADU/e-)", settings.getCameraGain(), 4); gd.addNumericField("Quantum_efficiency", settings.getQuantumEfficiency(), 2); gd.addNumericField("Read_noise (e-)", settings.readNoise, 2); gd.addNumericField("Bias", settings.bias, 0); // PSF Model List<String> imageNames = addPSFOptions(gd); gd.addMessage("--- Fluorophores ---"); Component splitLabel = gd.getMessage(); // Do not allow grid or mask distribution if (simpleMode) gd.addChoice("Distribution", Arrays.copyOf(DISTRIBUTION, DISTRIBUTION.length - 2), settings.distribution); gd.addNumericField("Particles", settings.particles, 0); if (simpleMode) gd.addNumericField("Density (um^-2)", settings.density, 2); else if (benchmarkMode) { gd.addNumericField("X_position (nm)", settings.xPosition, 2); gd.addNumericField("Y_position (nm)", settings.yPosition, 2); gd.addNumericField("Z_position (nm)", settings.zPosition, 2); } gd.addNumericField("Min_Photons", settings.photonsPerSecond, 0); gd.addNumericField("Max_Photons", settings.photonsPerSecondMaximum, 0); gd.addMessage("--- Save options ---"); gd.addCheckbox("Raw_image", settings.rawImage); gd.addCheckbox("Save_image", settings.saveImage); gd.addCheckbox("Save_image_results", settings.saveImageResults); gd.addCheckbox("Save_localisations", settings.saveLocalisations); gd.addMessage("--- Report options ---"); gd.addCheckbox("Show_histograms", settings.showHistograms); gd.addCheckbox("Choose_histograms", settings.chooseHistograms); gd.addNumericField("Histogram_bins", settings.histogramBins, 0); gd.addCheckbox("Remove_outliers", settings.removeOutliers); if (simpleMode) gd.addSlider("Density_radius (N x HWHM)", 0, 4.5, settings.densityRadius); // Split into two columns // Re-arrange the standard layout which has a GridBagLayout with 2 columns (label,field) // to 4 columns: (label,field) x 2 if (gd.getLayout() != null) { GridBagLayout grid = (GridBagLayout) gd.getLayout(); int xOffset = 0, yOffset = 0; int lastY = -1, rowCount = 0; for (Component comp : gd.getComponents()) { // Check if this should be the second major column if (comp == splitLabel) { xOffset += 2; yOffset -= rowCount; rowCount = 0; } // Reposition the field GridBagConstraints c = grid.getConstraints(comp); if (lastY != c.gridy) rowCount++; lastY = c.gridy; c.gridx = c.gridx + xOffset; c.gridy = c.gridy + yOffset; c.insets.left = c.insets.left + 10 * xOffset; c.insets.top = 0; c.insets.bottom = 0; grid.setConstraints(comp, c); } if (IJ.isLinux()) gd.setBackground(new Color(238, 238, 238)); } gd.showDialog(); if (gd.wasCanceled()) return false; settings.pixelPitch = Math.abs(gd.getNextNumber()); settings.size = Math.abs((int) gd.getNextNumber()); if (!benchmarkMode) { // Allow negative depth settings.depth = gd.getNextNumber(); settings.fixedDepth = gd.getNextBoolean(); } if (extraOptions) poissonNoise = settings.poissonNoise = !gd.getNextBoolean(); settings.background = Math.abs(gd.getNextNumber()); settings.setEmGain(Math.abs(gd.getNextNumber())); settings.setCameraGain(Math.abs(gd.getNextNumber())); settings.setQuantumEfficiency(Math.abs(gd.getNextNumber())); settings.readNoise = Math.abs(gd.getNextNumber()); settings.bias = Math.abs((int) gd.getNextNumber()); if (!collectPSFOptions(gd, imageNames)) return false; if (simpleMode) settings.distribution = gd.getNextChoice(); settings.particles = Math.abs((int) gd.getNextNumber()); if (simpleMode) settings.density = Math.abs(gd.getNextNumber()); else if (benchmarkMode) { settings.xPosition = gd.getNextNumber(); settings.yPosition = gd.getNextNumber(); settings.zPosition = gd.getNextNumber(); } settings.photonsPerSecond = Math.abs((int) gd.getNextNumber()); settings.photonsPerSecondMaximum = Math.abs((int) gd.getNextNumber()); settings.rawImage = gd.getNextBoolean(); settings.saveImage = gd.getNextBoolean(); settings.saveImageResults = gd.getNextBoolean(); settings.saveLocalisations = gd.getNextBoolean(); settings.showHistograms = gd.getNextBoolean(); settings.chooseHistograms = gd.getNextBoolean(); settings.histogramBins = (int) gd.getNextNumber(); settings.removeOutliers = gd.getNextBoolean(); if (simpleMode) settings.densityRadius = (float) gd.getNextNumber(); // Save before validation so that the current values are preserved. SettingsManager.saveSettings(globalSettings); if (gd.invalidNumber()) return false; // Check arguments try { Parameters.isAboveZero("Pixel Pitch", settings.pixelPitch); Parameters.isAboveZero("Size", settings.size); if (!benchmarkMode && !settings.fixedDepth) Parameters.isPositive("Depth", settings.depth); Parameters.isPositive("Background", settings.background); Parameters.isPositive("EM gain", settings.getEmGain()); Parameters.isPositive("Camera gain", settings.getCameraGain()); Parameters.isPositive("Read noise", settings.readNoise); double noiseRange = settings.readNoise * settings.getCameraGain() * 4; Parameters.isEqualOrAbove("Bias must prevent clipping the read noise (@ +/- 4 StdDev) so ", settings.bias, noiseRange); Parameters.isAboveZero("Particles", settings.particles); if (simpleMode) Parameters.isAboveZero("Density", settings.density); Parameters.isAboveZero("Min Photons", settings.photonsPerSecond); if (settings.photonsPerSecondMaximum < settings.photonsPerSecond) settings.photonsPerSecondMaximum = settings.photonsPerSecond; if (!imagePSF) { Parameters.isAboveZero("Wavelength", settings.wavelength); Parameters.isAboveZero("NA", settings.numericalAperture); Parameters.isBelow("NA", settings.numericalAperture, 2); } Parameters.isAbove("Histogram bins", settings.histogramBins, 1); if (simpleMode) Parameters.isPositive("Density radius", settings.densityRadius); } catch (IllegalArgumentException e) { IJ.error(TITLE, e.getMessage()); return false; } return getHistogramOptions(); }
From source file:gdsc.smlm.ij.plugins.CreateData.java
/** * Show a dialog allowing the parameters for a simulation to be performed * /* w w w .jav a2s . com*/ * @return True if the parameters were collected */ private boolean showDialog() { GenericDialog gd = new GenericDialog(TITLE); globalSettings = SettingsManager.loadSettings(); settings = globalSettings.getCreateDataSettings(); if (settings.stepsPerSecond < 1) settings.stepsPerSecond = 1; String[] backgroundImages = createBackgroundImageList(); gd.addNumericField("Pixel_pitch (nm)", settings.pixelPitch, 2); gd.addNumericField("Size (px)", settings.size, 0); gd.addNumericField("Depth (nm)", settings.depth, 0); gd.addCheckbox("Fixed_depth", settings.fixedDepth); gd.addNumericField("Seconds", settings.seconds, 0); gd.addNumericField("Exposure_time (ms)", settings.exposureTime, 0); gd.addSlider("Steps_per_second", 1, 15, settings.stepsPerSecond); gd.addChoice("Illumination", ILLUMINATION, settings.illumination); gd.addNumericField("Pulse_interval", settings.pulseInterval, 0); gd.addNumericField("Pulse_ratio", settings.pulseRatio, 2); if (backgroundImages != null) gd.addChoice("Background_image", backgroundImages, settings.backgroundImage); if (extraOptions) gd.addCheckbox("No_poisson_noise", !settings.poissonNoise); gd.addNumericField("Background (photons)", settings.background, 2); gd.addNumericField("EM_gain", settings.getEmGain(), 2); gd.addNumericField("Camera_gain (ADU/e-)", settings.getCameraGain(), 4); gd.addNumericField("Quantum_efficiency", settings.getQuantumEfficiency(), 2); gd.addNumericField("Read_noise (e-)", settings.readNoise, 2); gd.addNumericField("Bias", settings.bias, 0); List<String> imageNames = addPSFOptions(gd); gd.addMessage("--- Fluorophores ---"); Component splitLabel = gd.getMessage(); gd.addChoice("Distribution", DISTRIBUTION, settings.distribution); gd.addNumericField("Particles", settings.particles, 0); gd.addCheckbox("Compound_molecules", settings.compoundMolecules); gd.addNumericField("Diffusion_rate (um^2/sec)", settings.diffusionRate, 2); gd.addCheckbox("Use_grid_walk", settings.useGridWalk); gd.addSlider("Fixed_fraction (%)", 0, 100, settings.fixedFraction * 100); gd.addChoice("Confinement", CONFINEMENT, settings.confinement); gd.addNumericField("Photons (sec^-1)", settings.photonsPerSecond, 0); gd.addCheckbox("Custom_photon_distribution", settings.customPhotonDistribution); gd.addNumericField("Photon shape", settings.photonShape, 2); gd.addNumericField("Correlation (to total tOn)", settings.correlation, 2); gd.addNumericField("On_time (ms)", settings.tOn, 2); gd.addNumericField("Off_time_short (ms)", settings.tOffShort, 2); gd.addNumericField("Off_time_long (ms)", settings.tOffLong, 2); gd.addNumericField("n_Blinks_Short", settings.nBlinksShort, 2); gd.addNumericField("n_Blinks_Long", settings.nBlinksLong, 2); gd.addCheckbox("Use_geometric_distribution", settings.nBlinksGeometricDistribution); gd.addMessage("--- Peak filtering ---"); gd.addSlider("Min_Photons", 0, 50, settings.minPhotons); gd.addSlider("Min_SNR_t1", 0, 20, settings.minSNRt1); gd.addSlider("Min_SNR_tN", 0, 10, settings.minSNRtN); gd.addMessage("--- Save options ---"); Component splitLabel2 = gd.getMessage(); gd.addCheckbox("Raw_image", settings.rawImage); gd.addCheckbox("Save_image", settings.saveImage); gd.addCheckbox("Save_image_results", settings.saveImageResults); gd.addCheckbox("Save_fluorophores", settings.saveFluorophores); gd.addCheckbox("Save_localisations", settings.saveLocalisations); gd.addMessage("--- Report options ---"); gd.addCheckbox("Show_histograms", settings.showHistograms); gd.addCheckbox("Choose_histograms", settings.chooseHistograms); gd.addNumericField("Histogram_bins", settings.histogramBins, 0); gd.addCheckbox("Remove_outliers", settings.removeOutliers); gd.addSlider("Density_radius (N x HWHM)", 0, 4.5, settings.densityRadius); // Split into two columns // Re-arrange the standard layout which has a GridBagLayout with 2 columns (label,field) // to 4 columns: (label,field) x 2 if (gd.getLayout() != null) { GridBagLayout grid = (GridBagLayout) gd.getLayout(); int xOffset = 0, yOffset = 0; int lastY = -1, rowCount = 0; for (Component comp : gd.getComponents()) { // Check if this should be the second major column if (comp == splitLabel || comp == splitLabel2) { xOffset += 2; yOffset -= rowCount; rowCount = 0; } // Reposition the field GridBagConstraints c = grid.getConstraints(comp); if (lastY != c.gridy) rowCount++; lastY = c.gridy; c.gridx = c.gridx + xOffset; c.gridy = c.gridy + yOffset; c.insets.left = c.insets.left + 10 * xOffset; c.insets.top = 0; c.insets.bottom = 0; grid.setConstraints(comp, c); } if (IJ.isLinux()) gd.setBackground(new Color(238, 238, 238)); } gd.showDialog(); if (gd.wasCanceled()) return false; settings.pixelPitch = Math.abs(gd.getNextNumber()); settings.size = Math.abs((int) gd.getNextNumber()); settings.depth = Math.abs(gd.getNextNumber()); settings.fixedDepth = gd.getNextBoolean(); settings.seconds = Math.abs((int) gd.getNextNumber()); settings.exposureTime = Math.abs((int) gd.getNextNumber()); settings.stepsPerSecond = Math.abs((int) gd.getNextNumber()); settings.illumination = gd.getNextChoice(); settings.pulseInterval = Math.abs((int) gd.getNextNumber()); settings.pulseRatio = Math.abs(gd.getNextNumber()); if (backgroundImages != null) settings.backgroundImage = gd.getNextChoice(); if (extraOptions) poissonNoise = settings.poissonNoise = !gd.getNextBoolean(); settings.background = Math.abs(gd.getNextNumber()); settings.setEmGain(Math.abs(gd.getNextNumber())); settings.setCameraGain(Math.abs(gd.getNextNumber())); settings.setQuantumEfficiency(Math.abs(gd.getNextNumber())); settings.readNoise = Math.abs(gd.getNextNumber()); settings.bias = Math.abs((int) gd.getNextNumber()); if (!collectPSFOptions(gd, imageNames)) return false; settings.distribution = gd.getNextChoice(); settings.particles = Math.abs((int) gd.getNextNumber()); settings.compoundMolecules = gd.getNextBoolean(); settings.diffusionRate = Math.abs(gd.getNextNumber()); settings.useGridWalk = gd.getNextBoolean(); settings.fixedFraction = Math.abs(gd.getNextNumber() / 100.0); settings.confinement = gd.getNextChoice(); settings.photonsPerSecond = Math.abs((int) gd.getNextNumber()); settings.customPhotonDistribution = gd.getNextBoolean(); settings.photonShape = Math.abs(gd.getNextNumber()); settings.correlation = gd.getNextNumber(); settings.tOn = Math.abs(gd.getNextNumber()); settings.tOffShort = Math.abs(gd.getNextNumber()); settings.tOffLong = Math.abs(gd.getNextNumber()); settings.nBlinksShort = Math.abs(gd.getNextNumber()); settings.nBlinksLong = Math.abs(gd.getNextNumber()); settings.nBlinksGeometricDistribution = gd.getNextBoolean(); minPhotons = settings.minPhotons = gd.getNextNumber(); minSNRt1 = settings.minSNRt1 = gd.getNextNumber(); minSNRtN = settings.minSNRtN = gd.getNextNumber(); settings.rawImage = gd.getNextBoolean(); settings.saveImage = gd.getNextBoolean(); settings.saveImageResults = gd.getNextBoolean(); settings.saveFluorophores = gd.getNextBoolean(); settings.saveLocalisations = gd.getNextBoolean(); settings.showHistograms = gd.getNextBoolean(); settings.chooseHistograms = gd.getNextBoolean(); settings.histogramBins = (int) gd.getNextNumber(); settings.removeOutliers = gd.getNextBoolean(); settings.densityRadius = (float) gd.getNextNumber(); // Ensure tN threshold is more lenient if (settings.minSNRt1 < settings.minSNRtN) { double tmp = settings.minSNRt1; settings.minSNRt1 = settings.minSNRtN; settings.minSNRtN = tmp; } // Save before validation so that the current values are preserved. SettingsManager.saveSettings(globalSettings); // Check arguments try { Parameters.isAboveZero("Pixel Pitch", settings.pixelPitch); Parameters.isAboveZero("Size", settings.size); if (!settings.fixedDepth) Parameters.isPositive("Depth", settings.depth); Parameters.isAboveZero("Seconds", settings.seconds); Parameters.isAboveZero("Exposure time", settings.exposureTime); Parameters.isAboveZero("Steps per second", settings.stepsPerSecond); Parameters.isPositive("Background", settings.background); Parameters.isPositive("EM gain", settings.getEmGain()); Parameters.isPositive("Camera gain", settings.getCameraGain()); Parameters.isPositive("Read noise", settings.readNoise); double noiseRange = settings.readNoise * settings.getCameraGain() * 4; Parameters.isEqualOrAbove("Bias must prevent clipping the read noise (@ +/- 4 StdDev) so ", settings.bias, noiseRange); Parameters.isAboveZero("Particles", settings.particles); Parameters.isAboveZero("Photons", settings.photonsPerSecond); Parameters.isEqualOrBelow("Correlation", settings.correlation, 1); Parameters.isEqualOrAbove("Correlation", settings.correlation, -1); if (!imagePSF) { Parameters.isAboveZero("Wavelength", settings.wavelength); Parameters.isAboveZero("NA", settings.numericalAperture); Parameters.isBelow("NA", settings.numericalAperture, 2); } Parameters.isPositive("Diffusion rate", settings.diffusionRate); Parameters.isPositive("Fixed fraction", settings.fixedFraction); Parameters.isPositive("Pulse interval", settings.pulseInterval); Parameters.isAboveZero("Pulse ratio", settings.pulseRatio); Parameters.isAboveZero("tOn", settings.tOn); Parameters.isAboveZero("tOff Short", settings.tOffShort); Parameters.isAboveZero("tOff Long", settings.tOffLong); Parameters.isPositive("n-Blinks Short", settings.nBlinksShort); Parameters.isPositive("n-Blinks Long", settings.nBlinksLong); Parameters.isPositive("Min photons", settings.minPhotons); Parameters.isPositive("Min SNR t1", settings.minSNRt1); Parameters.isPositive("Min SNR tN", settings.minSNRtN); Parameters.isAbove("Histogram bins", settings.histogramBins, 1); Parameters.isPositive("Density radius", settings.densityRadius); } catch (IllegalArgumentException e) { IJ.error(TITLE, e.getMessage()); return false; } if (gd.invalidNumber()) return false; if (!getHistogramOptions()) return false; String[] maskImages = null; if (settings.distribution.equals(DISTRIBUTION[MASK])) { maskImages = createDistributionImageList(); if (maskImages != null) { gd = new GenericDialog(TITLE); gd.addMessage("Select the mask image for the distribution"); gd.addChoice("Distribution_mask", maskImages, settings.distributionMask); if (maskListContainsStacks) gd.addNumericField("Distribution_slice_depth (nm)", settings.distributionMaskSliceDepth, 0); gd.showDialog(); if (gd.wasCanceled()) return false; settings.distributionMask = gd.getNextChoice(); if (maskListContainsStacks) settings.distributionMaskSliceDepth = Math.abs(gd.getNextNumber()); } } else if (settings.distribution.equals(DISTRIBUTION[GRID])) { gd = new GenericDialog(TITLE); gd.addMessage("Select grid for the distribution"); gd.addNumericField("Cell_size", settings.cellSize, 0); gd.addSlider("p-binary", 0, 1, settings.probabilityBinary); gd.addNumericField("Min_binary_distance (nm)", settings.minBinaryDistance, 0); gd.addNumericField("Max_binary_distance (nm)", settings.maxBinaryDistance, 0); gd.showDialog(); if (gd.wasCanceled()) return false; settings.cellSize = (int) gd.getNextNumber(); settings.probabilityBinary = gd.getNextNumber(); settings.minBinaryDistance = gd.getNextNumber(); settings.maxBinaryDistance = gd.getNextNumber(); // Check arguments try { Parameters.isAboveZero("Cell size", settings.cellSize); Parameters.isPositive("p-binary", settings.probabilityBinary); Parameters.isEqualOrBelow("p-binary", settings.probabilityBinary, 1); Parameters.isPositive("Min binary distance", settings.minBinaryDistance); Parameters.isPositive("Max binary distance", settings.maxBinaryDistance); Parameters.isEqualOrBelow("Min binary distance", settings.minBinaryDistance, settings.maxBinaryDistance); } catch (IllegalArgumentException e) { IJ.error(TITLE, e.getMessage()); return false; } } SettingsManager.saveSettings(globalSettings); if (settings.diffusionRate > 0 && settings.fixedFraction < 1) { if (settings.confinement.equals(CONFINEMENT[CONFINEMENT_SPHERE])) { gd = new GenericDialog(TITLE); gd.addMessage("Select the sphere radius for the diffusion confinement"); gd.addSlider("Confinement_radius (nm)", 0, 2000, settings.confinementRadius); gd.showDialog(); if (gd.wasCanceled()) return false; settings.confinementRadius = gd.getNextNumber(); } else if (settings.confinement.equals(CONFINEMENT[CONFINEMENT_MASK])) { if (maskImages == null) maskImages = createDistributionImageList(); if (maskImages != null) { gd = new GenericDialog(TITLE); gd.addMessage("Select the mask image for the diffusion confinement"); gd.addChoice("Confinement_mask", maskImages, settings.confinementMask); if (maskListContainsStacks) gd.addNumericField("Confinement_slice_depth (nm)", settings.confinementMaskSliceDepth, 0); gd.showDialog(); if (gd.wasCanceled()) return false; settings.confinementMask = gd.getNextChoice(); if (maskListContainsStacks) settings.confinementMaskSliceDepth = Math.abs(gd.getNextNumber()); } } } SettingsManager.saveSettings(globalSettings); if (settings.compoundMolecules) { // Show a second dialog where the molecule configuration is specified gd = new GenericDialog(TITLE); gd.addMessage("Specify the compound molecules"); gd.addTextAreas(settings.compoundText, null, 20, 80); gd.addCheckbox("Rotate_initial_orientation", settings.rotateInitialOrientation); gd.addCheckbox("Rotate_during_simulation", settings.rotateDuringSimulation); gd.addCheckbox("Enable_2D_rotation", settings.rotate2D); gd.addCheckbox("Show_example_compounds", false); if (!(java.awt.GraphicsEnvironment.isHeadless() || IJ.isMacro())) { @SuppressWarnings("rawtypes") Vector v = gd.getCheckboxes(); Checkbox cb = (Checkbox) v.get(v.size() - 1); cb.addItemListener(this); } gd.showDialog(); if (gd.wasCanceled()) return false; settings.compoundText = gd.getNextText(); settings.rotateInitialOrientation = gd.getNextBoolean(); settings.rotateDuringSimulation = gd.getNextBoolean(); settings.rotate2D = gd.getNextBoolean(); if (gd.getNextBoolean()) { logExampleCompounds(); return false; } } SettingsManager.saveSettings(globalSettings); return true; }
From source file:net.sourceforge.pmd.util.designer.CreateXMLRulePanel.java
public CreateXMLRulePanel(JTextArea xpathQueryArea, CodeEditorTextPane codeEditorPane) { super();/*from w w w. j a v a 2s .co m*/ this.xpathQueryArea = xpathQueryArea; this.codeEditorPane = codeEditorPane; GridBagConstraints gbc = new GridBagConstraints(); // We use a gridbaglayout for a nice and sturdy look and feel GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; gbc.weightx = 0.5; JLabel rulenameLabel = new JLabel("Rule name : "); gbl.setConstraints(rulenameLabel, gbc); add(rulenameLabel); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; gbc.gridx = 1; gbl.setConstraints(rulenameField, gbc); add(rulenameField); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.EAST; gbc.weightx = 0.5; JLabel rulemsgLabel = new JLabel("Rule msg : "); gbl.setConstraints(rulemsgLabel, gbc); add(rulemsgLabel); gbc.gridx = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 0.5; gbl.setConstraints(rulemsgField, gbc); add(rulemsgField); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.EAST; gbc.weightx = 0.5; JLabel ruledescLabel = new JLabel("Rule desc : "); gbl.setConstraints(ruledescLabel, gbc); add(ruledescLabel); gbc.gridx = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 0.5; ruledescField.setLineWrap(true); gbl.setConstraints(ruledescField, gbc); add(ruledescField); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.NORTH; JButton createRuleBtn = new JButton("Create rule XML"); createRuleBtn.addActionListener(this); gbl.setConstraints(createRuleBtn, gbc); add(createRuleBtn); gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; JScrollPane ruleXMLPane = new JScrollPane(ruleXMLArea); gbl.setConstraints(ruleXMLPane, gbc); add(ruleXMLPane); repaint(); }
From source file:org.jab.docsearch.DocSearch.java
/** * Constructor/*from www .j a v a 2 s . c o m*/ */ public DocSearch() { super(I18n.getString("ds.windowtitle")); // get logger logger = Logger.getLogger(getClass().getName()); // File testCDFi = new File(cdRomDefaultHome); Properties sys = new Properties(System.getProperties()); if (testCDFi.exists()) { sys.setProperty("disableLuceneLocks", "true"); logger.info("DocSearch() Disabling Lucene Locks for CDROM indexes"); } else { sys.setProperty("disableLuceneLocks", "false"); } // checkCDROMDir(); defaultHndlr = getBrowserFile(); loadSettings(); // pPanel = new ProgressPanel("", 100L); pPanel.init(); phrase = new JRadioButton(I18n.getString("label.phrase")); searchField = new JComboBox(); searchIn = new JComboBox(searchOptsLabels); JLabel searchTypeLabel = new JLabel(I18n.getString("label.search_type")); JLabel searchInLabel = new JLabel(I18n.getString("label.search_in")); keywords = new JRadioButton(I18n.getString("label.keyword")); // searchLabel = new JLabel(I18n.getString("label.search_for")); searchButton = new JButton(I18n.getString("button.search")); searchButton.setActionCommand("ac_search"); searchButton.setMnemonic(KeyEvent.VK_A); // TODO alt text to resource htmlTag = "<img src=\"" + fEnv.getIconURL(FileType.HTML.getIcon()) + "\" border=\"0\" alt=\"Web Page Document\">"; wordTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_WORD.getIcon()) + "\" border=\"0\" alt=\"MS Word Document\">"; excelTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_EXCEL.getIcon()) + "\" border=\"0\" alt=\"MS Excel Document\">"; pdfTag = "<img src=\"" + fEnv.getIconURL(FileType.PDF.getIcon()) + "\" border=\"0\" alt=\"PDF Document\">"; textTag = "<img src=\"" + fEnv.getIconURL(FileType.TEXT.getIcon()) + "\" border=\"0\" alt=\"Text Document\">"; rtfTag = "<img src=\"" + fEnv.getIconURL(FileType.RTF.getIcon()) + "\" border=\"0\" alt=\"RTF Document\">"; ooImpressTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_IMPRESS.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Impress Document\">"; ooWriterTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_WRITER.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Writer Document\">"; ooCalcTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_CALC.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Calc Document\">"; ooDrawTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_DRAW.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Draw Document\">"; openDocumentTextTag = "<img src=\"" + fEnv.getIconURL(FileType.OPENDOCUMENT_TEXT.getIcon()) + "\" border=\"0\" alt=\"OpenDocument Text Document\">"; // idx = new Index(this); colors = new String[2]; colors[0] = "ffeffa"; colors[1] = "fdffda"; if (env.isWebStart()) { startPageString = getClass().getResource("/" + FileEnvironment.FILENAME_START_PAGE_WS).toString(); helpPageString = getClass().getResource("/" + FileEnvironment.FILENAME_HELP_PAGE_WS).toString(); if (startPageString != null) { logger.debug("DocSearch() Start Page is: " + startPageString); hasStartPage = true; } else { logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString); } } else { startPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_START_PAGE); helpPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_HELP_PAGE); File startPageFile = new File(startPageString); if (startPageFile.exists()) { logger.debug("DocSearch() Start Page is: " + startPageString); hasStartPage = true; } else { logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString); } } defaultSaveFolder = FileUtils.addFolder(fEnv.getWorkingDirectory(), "saved_searches"); searchField.setEditable(true); searchField.addItem(""); bg = new ButtonGroup(); bg.add(phrase); bg.add(keywords); keywords.setSelected(true); keywords.setToolTipText(I18n.getString("tooltip.keyword")); phrase.setToolTipText(I18n.getString("tooltip.phrase")); int iconInt = 2; searchField.setPreferredSize(new Dimension(370, 22)); // application icon Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/ds.gif")); this.setIconImage(iconImage); // menu bar JMenuBar menuBar = createMenuBar(); // add menu to frame setJMenuBar(menuBar); // tool bar JToolBar toolbar = createToolBar(); editorPane = new JEditorPane("text/html", lastSearch); editorPane.setEditable(false); editorPane.addHyperlinkListener(new Hyperactive()); if (hasStartPage) { try { editorPane.setContentType("text/html"); if (setPage("home")) { logger.info("DocSearch() loaded start page: " + startPageString); } } catch (Exception e) { editorPane.setText(lastSearch); } } else { logger.warn("DocSearch() no start page loaded"); } scrollPane = new JScrollPane(editorPane); scrollPane.setPreferredSize(new Dimension(1024, 720)); scrollPane.setMinimumSize(new Dimension(900, 670)); scrollPane.setMaximumSize(new Dimension(1980, 1980)); // create panels // add printing stuff vista = new JComponentVista(editorPane, new PageFormat()); JPanel topPanel = new JPanel(); topPanel.add(searchLabel); topPanel.add(searchField); topPanel.add(searchButton); JPanel bottomPanel = new JPanel(); bottomPanel.add(searchTypeLabel); bottomPanel.add(keywords); bottomPanel.add(phrase); bottomPanel.add(searchInLabel); bottomPanel.add(searchIn); // GUI items for advanced searching useDate = new JCheckBox(I18n.getString("label.use_date_property")); fromField = new JTextField(11); JLabel fromLabel = new JLabel(I18n.getString("label.from")); JLabel toLabel = new JLabel(I18n.getString("label.to")); toField = new JTextField(11); cbl = new CheckBoxListener(); authorPanel = new JPanel(); useAuthor = new JCheckBox(I18n.getString("label.use_auth_property")); authorField = new JTextField(31); JLabel authorLabel = new JLabel(I18n.getString("label.author")); authorPanel.add(useAuthor); authorPanel.add(authorLabel); authorPanel.add(authorField); // combine stuff JPanel datePanel = new JPanel(); datePanel.add(useDate); datePanel.add(fromLabel); datePanel.add(fromField); datePanel.add(toLabel); datePanel.add(toField); JPanel metaPanel = new JPanel(); metaPanel.setLayout(new BorderLayout()); metaPanel.setBorder(new TitledBorder(I18n.getString("label.date_and_author"))); metaPanel.add(datePanel, BorderLayout.NORTH); metaPanel.add(authorPanel, BorderLayout.SOUTH); useDate.addActionListener(cbl); useAuthor.addActionListener(cbl); fromField.setText(DateTimeUtils.getLastYear()); toField.setText(DateTimeUtils.getToday()); authorField.setText(System.getProperty("user.name")); JPanel[] panels = new JPanel[numPanels]; for (int i = 0; i < numPanels; i++) { panels[i] = new JPanel(); } // add giu to panels panels[0].setLayout(new BorderLayout()); panels[0].add(topPanel, BorderLayout.NORTH); panels[0].add(bottomPanel, BorderLayout.SOUTH); panels[0].setBorder(new TitledBorder(I18n.getString("label.search_critera"))); searchButton.addActionListener(this); JPanel fileTypePanel = new JPanel(); useType = new JCheckBox(I18n.getString("label.use_filetype_property")); useType.addActionListener(cbl); fileType = new JComboBox(fileTypesToFindLabel); JLabel fileTypeLabel = new JLabel(I18n.getString("label.find_only_these_filetypes")); fileTypePanel.add(useType); fileTypePanel.add(fileTypeLabel); fileTypePanel.add(fileType); JPanel sizePanel = new JPanel(); useSize = new JCheckBox(I18n.getString("label.use_filesize_property")); useSize.addActionListener(cbl); // TODO l18n kbytes JLabel sizeFromLabel = new JLabel(I18n.getString("label.from") + " KByte"); JLabel sizeToLabel = new JLabel(I18n.getString("label.to") + " KByte"); sizeFromField = new JTextField(10); sizeFromField.setText("0"); sizeToField = new JTextField(10); sizeToField.setText("100"); sizePanel.add(useSize); sizePanel.add(sizeFromLabel); sizePanel.add(sizeFromField); sizePanel.add(sizeToLabel); sizePanel.add(sizeToField); JPanel sizeAndTypePanel = new JPanel(); sizeAndTypePanel.setLayout(new BorderLayout()); sizeAndTypePanel.setBorder(new TitledBorder(I18n.getString("label.filetype_and_size"))); sizeAndTypePanel.add(fileTypePanel, BorderLayout.NORTH); sizeAndTypePanel.add(sizePanel, BorderLayout.SOUTH); // set up the tabbed pane JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(I18n.getString("label.general"), null, panels[0], I18n.getString("tooltip.general_search_criteria")); tabbedPane.addTab(I18n.getString("label.date_and_author"), null, metaPanel, I18n.getString("tooltip.date_auth_options")); tabbedPane.addTab(I18n.getString("label.filetype_and_size"), null, sizeAndTypePanel, I18n.getString("tooltip.filetype_and_size_options")); // gridbag getContentPane().setLayout(new GridLayout(1, numPanels + iconInt + 1)); GridBagLayout gridbaglayout = new GridBagLayout(); GridBagConstraints gridbagconstraints = new GridBagConstraints(); getContentPane().setLayout(gridbaglayout); gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = 0; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(toolbar, gridbagconstraints); getContentPane().add(toolbar); int start = 1; for (int i = 0; i < numPanels; i++) { if (i == 0) { gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = i + start; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(tabbedPane, gridbagconstraints); getContentPane().add(tabbedPane); } else { gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = i + start; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(panels[i], gridbagconstraints); getContentPane().add(panels[i]); } } // now add the results area gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = iconInt; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 1.0D; gridbaglayout.setConstraints(scrollPane, gridbagconstraints); getContentPane().add(scrollPane); JPanel statusP = new JPanel(); statusP.setLayout(new BorderLayout()); statusP.add(dirLabel, BorderLayout.WEST); statusP.add(pPanel, BorderLayout.EAST); // now add the status label gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = numPanels + iconInt; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(statusP, gridbagconstraints); getContentPane().add(statusP); // File testArchDir = new File(fEnv.getArchiveDirectory()); if (!testArchDir.exists()) { boolean madeDir = testArchDir.mkdir(); if (!madeDir) { logger.warn("DocSearch() Error creating directory: " + fEnv.getArchiveDirectory()); } else { logger.info("DocSearch() Directory created: " + fEnv.getArchiveDirectory()); } } loadIndexes(); // DocTypeHandler String handlersFiName; if (!isCDSearchTool) { handlersFiName = FileUtils.addFolder(fEnv.getWorkingDirectory(), DocTypeHandlerUtils.HANDLER_FILE); } else { handlersFiName = FileUtils.addFolder(cdRomDefaultHome, DocTypeHandlerUtils.HANDLER_FILE); } DocTypeHandlerUtils dthUtils = new DocTypeHandlerUtils(); if (!FileUtils.fileExists(handlersFiName)) { logger.warn("DocSearch() Handlers file not found at: " + handlersFiName); handlerList = dthUtils.getInitialHandler(env); } else { handlerList = dthUtils.loadHandler(handlersFiName); } }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
private void addGrid(GridBagLayout gbl, GridBagConstraints gbc, Component c, Rectangle rect, double weightx, double weighty) { gbc.gridx = rect.x;//from w w w . ja va2 s . c o m gbc.gridy = rect.y; gbc.gridwidth = rect.width; gbc.gridheight = rect.height; gbc.weightx = weightx; gbc.weighty = weighty; gbl.setConstraints(c, gbc); add(c); }