use of java.awt.Label 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.Label 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.Label in project GDSC-SMLM by aherbert.
the class FolderOpenerDialog method setStackInfo.
void setStackInfo() {
int n = getNumber(numberField.elementAt(0));
int start = getNumber(numberField.elementAt(1));
int inc = getNumber(numberField.elementAt(2));
// Filter by name
TextField tf = (TextField) stringField.elementAt(0);
String filter = tf.getText();
tf = (TextField) stringField.elementAt(1);
String regex = tf.getText();
java.util.regex.Pattern p = null;
if (!regex.equals("")) {
filter = regex;
p = java.util.regex.Pattern.compile(filter);
}
if (!filter.equals("") && !filter.equals("*")) {
int n2 = 0;
for (int i = 0; i < list.length; i++) {
if (p != null && p.matcher(list[i]).matches())
n2++;
else if (list[i].indexOf(filter) >= 0)
n2++;
}
if (n2 < n)
n = n2;
}
// Now count using the input settings
if (start < 1 || start > n)
start = 1;
if (inc < 1)
inc = 1;
int count = 0;
for (int i = start - 1; i < list.length && count < n; i += inc, count++) ;
int frames = imp.getStackSize() * count;
((Label) theLabel).setText(String.format("%d image%s (%d frame%s)", count, (count == 1) ? "" : "s", frames, (frames == 1) ? "" : "s"));
}
use of java.awt.Label in project GDSC-SMLM by aherbert.
the class FIRE method showDialog.
private boolean showDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Compute the resolution using Fourier Ring Correlation");
gd.addHelp(About.HELP_URL);
boolean single = results2 == null;
gd.addMessage("Image construction options:");
gd.addChoice("Image_scale", SCALE_ITEMS, SCALE_ITEMS[imageScaleIndex]);
gd.addChoice("Auto_image_size", IMAGE_SIZE_ITEMS, IMAGE_SIZE_ITEMS[imageSizeIndex]);
if (extraOptions)
gd.addCheckbox("Use_signal (if present)", useSignal);
gd.addNumericField("Max_per_bin", maxPerBin, 0);
gd.addMessage("Fourier options:");
String[] fourierMethodNames = SettingsManager.getNames((Object[]) FRC.FourierMethod.values());
gd.addChoice("Fourier_method", fourierMethodNames, fourierMethodNames[fourierMethodIndex]);
String[] samplingMethodNames = SettingsManager.getNames((Object[]) FRC.SamplingMethod.values());
gd.addChoice("Sampling_method", samplingMethodNames, samplingMethodNames[samplingMethodIndex]);
gd.addSlider("Sampling_factor", 0.2, 4, perimeterSamplingFactor);
gd.addMessage("FIRE options:");
String[] thresholdMethodNames = SettingsManager.getNames((Object[]) FRC.ThresholdMethod.values());
gd.addChoice("Threshold_method", thresholdMethodNames, thresholdMethodNames[thresholdMethodIndex]);
gd.addCheckbox("Show_FRC_curve", showFRCCurve);
if (single) {
gd.addMessage("For single datasets:");
Label l = (Label) gd.getMessage();
gd.addNumericField("Block_size", blockSize, 0);
gd.addCheckbox("Random_split", randomSplit);
gd.addNumericField("Repeats", repeats, 0);
gd.addCheckbox("Show_FRC_curve_repeats", showFRCCurveRepeats);
gd.addCheckbox("Show_FRC_time_evolution", showFRCTimeEvolution);
gd.addCheckbox("Spurious correlation correction", spuriousCorrelationCorrection);
gd.addNumericField("Q-value", qValue, 3);
gd.addNumericField("Precision_Mean", mean, 2, 6, "nm");
gd.addNumericField("Precision_Sigma", sigma, 2, 6, "nm");
if (extraOptions)
gd.addNumericField("Threads", getLastNThreads(), 0);
// Rearrange the dialog
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 == l) {
xOffset += 2;
// Skip title row
yOffset = yOffset - rowCount + 1;
}
// 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;
imageScaleIndex = gd.getNextChoiceIndex();
imageSizeIndex = gd.getNextChoiceIndex();
if (extraOptions)
myUseSignal = useSignal = gd.getNextBoolean();
maxPerBin = Math.abs((int) gd.getNextNumber());
fourierMethodIndex = gd.getNextChoiceIndex();
fourierMethod = FourierMethod.values()[fourierMethodIndex];
samplingMethodIndex = gd.getNextChoiceIndex();
samplingMethod = SamplingMethod.values()[samplingMethodIndex];
perimeterSamplingFactor = gd.getNextNumber();
thresholdMethodIndex = gd.getNextChoiceIndex();
thresholdMethod = FRC.ThresholdMethod.values()[thresholdMethodIndex];
showFRCCurve = gd.getNextBoolean();
if (single) {
blockSize = Math.max(1, (int) gd.getNextNumber());
randomSplit = gd.getNextBoolean();
repeats = Math.max(1, (int) gd.getNextNumber());
showFRCCurveRepeats = gd.getNextBoolean();
showFRCTimeEvolution = gd.getNextBoolean();
spuriousCorrelationCorrection = gd.getNextBoolean();
qValue = Math.abs(gd.getNextNumber());
mean = Math.abs(gd.getNextNumber());
sigma = Math.abs(gd.getNextNumber());
if (extraOptions) {
setThreads((int) gd.getNextNumber());
lastNThreads = this.nThreads;
}
}
// Check arguments
try {
Parameters.isAboveZero("Perimeter sampling factor", perimeterSamplingFactor);
if (single && spuriousCorrelationCorrection) {
Parameters.isAboveZero("Q-value", qValue);
Parameters.isAboveZero("Precision Mean", mean);
Parameters.isAboveZero("Precision Sigma", sigma);
// Set these for use in FIRE computation
setCorrectionParameters(qValue, mean, sigma);
}
} catch (IllegalArgumentException e) {
IJ.error(TITLE, e.getMessage());
return false;
}
return true;
}
use of java.awt.Label in project GDSC-SMLM by aherbert.
the class LoadLocalisations method getFields.
private static boolean getFields() {
GenericDialog gd = new GenericDialog(TITLE);
gd.addMessage("Load delimited localisations");
gd.addStringField("Dataset_name", name, 30);
gd.addMessage("Calibration:");
gd.addNumericField("Pixel_size", pixelPitch, 3, 8, "nm");
gd.addNumericField("Gain", gain, 3, 8, "Count/photon");
gd.addNumericField("Exposure_time", exposureTime, 3, 8, "ms");
gd.addMessage("Records:");
gd.addNumericField("Header_lines", header, 0);
gd.addStringField("Comment", comment);
gd.addStringField("Delimiter", delimiter);
String[] dUnits = SettingsManager.getNames((Object[]) DistanceUnit.values());
gd.addChoice("Distance_unit", dUnits, dUnits[distanceUnit]);
String[] iUnits = SettingsManager.getNames((Object[]) IntensityUnit.values());
gd.addChoice("Intensity_unit", iUnits, iUnits[intensityUnit]);
gd.addMessage("Define the fields:");
Label l = (Label) gd.getMessage();
gd.addNumericField("T", it, 0);
gd.addNumericField("ID", iid, 0);
gd.addNumericField("X", ix, 0);
gd.addNumericField("Y", iy, 0);
gd.addNumericField("Z", iz, 0);
gd.addNumericField("Intensity", ii, 0);
gd.addNumericField("Sx", isx, 0);
gd.addNumericField("Sy", isy, 0);
gd.addNumericField("Precision", ip, 0);
// Rearrange
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 == l) {
xOffset += 2;
// Skip title row
yOffset = yOffset - rowCount + 1;
}
// 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;
}
name = getNextString(gd, name);
pixelPitch = gd.getNextNumber();
gain = gd.getNextNumber();
exposureTime = gd.getNextNumber();
header = (int) gd.getNextNumber();
comment = gd.getNextString();
delimiter = getNextString(gd, delimiter);
distanceUnit = gd.getNextChoiceIndex();
intensityUnit = gd.getNextChoiceIndex();
int[] columns = new int[9];
for (int i = 0; i < columns.length; i++) columns[i] = (int) gd.getNextNumber();
{
int i = 0;
it = columns[i++];
iid = columns[i++];
ix = columns[i++];
iy = columns[i++];
iz = columns[i++];
ii = columns[i++];
isx = columns[i++];
isy = columns[i++];
ip = columns[i++];
}
if (gd.invalidNumber()) {
IJ.error(TITLE, "Invalid number in input fields");
return false;
}
for (int i = 0; i < columns.length; i++) {
if (columns[i] < 0)
continue;
for (int j = i + 1; j < columns.length; j++) {
if (columns[j] < 0)
continue;
if (columns[i] == columns[j]) {
IJ.error(TITLE, "Duplicate indicies: " + columns[i]);
return false;
}
}
}
if (gain <= 0 || pixelPitch <= 0) {
IJ.error(TITLE, "Require positive gain and pixel pitch");
return false;
}
if (ix < 0 || iy < 0) {
IJ.error(TITLE, "Require valid X and Y indices");
return false;
}
return true;
}
Aggregations