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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations