Search in sources :

Example 11 with Panel

use of java.awt.Panel in project GDSC-SMLM by aherbert.

the class MultiDialog method buildButtonPanel.

protected Panel buildButtonPanel() {
    Panel buttons = new Panel();
    buttons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));
    all = new Button("All");
    all.addActionListener(this);
    all.addKeyListener(this);
    buttons.add(all);
    none = new Button("None");
    none.addActionListener(this);
    none.addKeyListener(this);
    buttons.add(none);
    okay = new Button("OK");
    okay.addActionListener(this);
    okay.addKeyListener(this);
    buttons.add(okay);
    cancel = new Button("Cancel");
    cancel.addActionListener(this);
    cancel.addKeyListener(this);
    buttons.add(cancel);
    return buttons;
}
Also used : Panel(java.awt.Panel) FlowLayout(java.awt.FlowLayout) Button(java.awt.Button)

Example 12 with Panel

use of java.awt.Panel in project GDSC-SMLM by aherbert.

the class SpotAnalysis method createChoicePanel.

private Panel createChoicePanel(Choice list, String label) {
    Panel panel = new Panel();
    panel.setLayout(new BorderLayout());
    Label listLabel = new Label(label, 0);
    //listLabel.setFont(monoFont);
    //list.setSize(fontWidth * 3, fontWidth);
    panel.add(listLabel, BorderLayout.WEST);
    panel.add(list, BorderLayout.CENTER);
    return panel;
}
Also used : Panel(java.awt.Panel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Label(java.awt.Label)

Example 13 with Panel

use of java.awt.Panel in project GDSC-SMLM by aherbert.

the class SpotAnalysis method createFrame.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void createFrame() {
    Panel mainPanel = new Panel();
    add(mainPanel);
    inputChoice = new Choice();
    mainPanel.add(createChoicePanel(inputChoice, ""));
    widthTextField = new TextField();
    mainPanel.add(createTextPanel(widthTextField, "PSF width", "1.2"));
    blurTextField = new TextField();
    mainPanel.add(createTextPanel(blurTextField, "Blur (relative to width)", "1"));
    gainTextField = new TextField();
    mainPanel.add(createTextPanel(gainTextField, "Gain", "37.7"));
    exposureTextField = new TextField();
    mainPanel.add(createTextPanel(exposureTextField, "ms/Frame", "20"));
    smoothingTextField = new TextField();
    mainPanel.add(createTextPanel(smoothingTextField, "Smoothing", "0.25"));
    profileButton = new Button("Profile");
    profileButton.addActionListener(this);
    addButton = new Button("Add");
    addButton.addActionListener(this);
    deleteButton = new Button("Remove");
    deleteButton.addActionListener(this);
    saveButton = new Button("Save");
    saveButton.addActionListener(this);
    saveTracesButton = new Button("Save Traces");
    saveTracesButton.addActionListener(this);
    currentLabel = new Label();
    mainPanel.add(createLabelPanel(currentLabel, "", ""));
    rawFittedLabel = new Label();
    mainPanel.add(createLabelPanel(rawFittedLabel, "", ""));
    blurFittedLabel = new Label();
    mainPanel.add(createLabelPanel(blurFittedLabel, "", ""));
    JPanel buttonPanel = new JPanel();
    FlowLayout l = new FlowLayout();
    l.setVgap(0);
    buttonPanel.setLayout(l);
    buttonPanel.add(profileButton, BorderLayout.CENTER);
    buttonPanel.add(addButton, BorderLayout.CENTER);
    buttonPanel.add(deleteButton, BorderLayout.CENTER);
    buttonPanel.add(saveButton, BorderLayout.CENTER);
    buttonPanel.add(saveTracesButton, BorderLayout.CENTER);
    mainPanel.add(buttonPanel);
    listModel = new DefaultListModel();
    onFramesList = new JList(listModel);
    onFramesList.setVisibleRowCount(15);
    onFramesList.addListSelectionListener(this);
    //mainPanel.add(onFramesList);
    JScrollPane scrollPane = new JScrollPane(onFramesList);
    scrollPane.getVerticalScrollBarPolicy();
    mainPanel.add(scrollPane);
    GridBagLayout mainGrid = new GridBagLayout();
    int y = 0;
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    c.insets = new Insets(2, 2, 2, 2);
    for (Component comp : mainPanel.getComponents()) {
        c.gridy = y++;
        mainGrid.setConstraints(comp, c);
    }
    mainPanel.setLayout(mainGrid);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Choice(java.awt.Choice) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Label(java.awt.Label) DefaultListModel(javax.swing.DefaultListModel) Point(java.awt.Point) Panel(java.awt.Panel) JPanel(javax.swing.JPanel) Button(java.awt.Button) TextField(java.awt.TextField) Component(java.awt.Component) JList(javax.swing.JList)

Example 14 with Panel

use of java.awt.Panel in project GDSC-SMLM by aherbert.

the class SMLMTools method addPlugin.

private int addPlugin(Panel mainPanel, GridBagLayout grid, String commandName, final String command, int col, int row) {
    // Disect the ImageJ plugins.config string, e.g.:
    // Plugins>GDSC SMLM, "Peak Fit", gdsc.smlm.ij.plugins.PeakFit
    commandName = commandName.replaceAll("\"", "");
    Button button = new Button(commandName);
    String className = command;
    String arg = "";
    int index = command.indexOf('(');
    if (index > 0) {
        className = command.substring(0, index);
        int argStart = command.indexOf('"');
        if (argStart > 0) {
            int argEnd = command.lastIndexOf('"');
            arg = command.substring(argStart + 1, argEnd);
        }
    }
    // Add to Plugins menu so that the macros/toolset will work
    if (!ij.Menus.commandInUse(commandName)) {
        if (addSpacer) {
            try {
                ij.Menus.getImageJMenu("Plugins").addSeparator();
            } catch (NoSuchMethodError e) {
            // Ignore. This ImageJ method is from IJ 1.48+
            }
        }
        ij.Menus.installPlugin(command, ij.Menus.PLUGINS_MENU, commandName, "", IJ.getInstance());
    }
    // Store the command to be invoked when the button is clicked
    plugins.put(commandName, new String[] { className, arg });
    button.addActionListener(this);
    if (addSpacer) {
        addSpacer = false;
        if (row != 0)
            row = add(mainPanel, grid, new Panel(), col, row);
    }
    row = add(mainPanel, grid, button, col, row);
    return row;
}
Also used : Panel(java.awt.Panel) Button(java.awt.Button) Point(java.awt.Point)

Example 15 with Panel

use of java.awt.Panel in project GDSC-SMLM by aherbert.

the class SMLMTools method createFrame.

private boolean createFrame() {
    // Locate all the GDSC SMLM plugins using the plugins.config:
    InputStream readmeStream = getToolsPluginsConfig();
    ij.Menus.installPlugin("", ij.Menus.PLUGINS_MENU, "-", "", IJ.getInstance());
    // Read into memory
    ArrayList<String[]> plugins = new ArrayList<String[]>();
    int gaps = 0;
    BufferedReader input = null;
    try {
        input = new BufferedReader(new UnicodeReader(readmeStream, null));
        String line;
        while ((line = input.readLine()) != null) {
            if (line.startsWith("#"))
                continue;
            String[] tokens = line.split(",");
            if (tokens.length == 3) {
                // Only copy the entries from the Plugins menu
                if (!ignore(tokens)) {
                    if (!plugins.isEmpty()) {
                        // Multiple gaps indicates a new column
                        if (gaps > 1) {
                            plugins.add(new String[] { "next", "" });
                        }
                    }
                    gaps = 0;
                    plugins.add(new String[] { tokens[1].trim(), tokens[2].trim() });
                }
            } else
                gaps++;
            // Put a spacer between plugins if specified
            if ((tokens.length == 2 && tokens[0].startsWith("Plugins") && tokens[1].trim().equals("\"-\"")) || line.length() == 0) {
                plugins.add(new String[] { "spacer", "" });
            }
        }
    } catch (IOException e) {
    // Ignore 
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
            // Ignore
            }
        }
    }
    if (plugins.isEmpty())
        return false;
    // Arrange on a grid
    Panel mainPanel = new Panel();
    GridBagLayout grid = new GridBagLayout();
    mainPanel.setLayout(grid);
    add(mainPanel);
    addSpacer = false;
    int col = 0, row = 0;
    for (String[] plugin : plugins) {
        if (plugin[0].equals("next")) {
            col++;
            row = 0;
        } else if (plugin[0].equals("spacer"))
            addSpacer = true;
        else
            row = addPlugin(mainPanel, grid, plugin[0], plugin[1], col, row);
    }
    return true;
}
Also used : Panel(java.awt.Panel) GridBagLayout(java.awt.GridBagLayout) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) UnicodeReader(gdsc.core.utils.UnicodeReader) IOException(java.io.IOException) Point(java.awt.Point)

Aggregations

Panel (java.awt.Panel)70 BorderLayout (java.awt.BorderLayout)26 Button (java.awt.Button)25 Label (java.awt.Label)25 Frame (java.awt.Frame)18 GridBagLayout (java.awt.GridBagLayout)17 TextField (java.awt.TextField)17 GridBagConstraints (java.awt.GridBagConstraints)16 JPanel (javax.swing.JPanel)14 Dimension (java.awt.Dimension)13 Insets (java.awt.Insets)10 Point (java.awt.Point)10 Choice (java.awt.Choice)9 FlowLayout (java.awt.FlowLayout)9 Graphics (java.awt.Graphics)9 Checkbox (java.awt.Checkbox)7 GridLayout (java.awt.GridLayout)7 Font (java.awt.Font)6 JButton (javax.swing.JButton)6 Component (java.awt.Component)5