use of java.awt.Component 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.Component in project GDSC-SMLM by aherbert.
the class GaussianFit method showDialog.
/*
* (non-Javadoc)
*
* @see ij.plugin.filter.ExtendedPlugInFilter#showDialog(ij.ImagePlus, java.lang.String,
* ij.plugin.filter.PlugInFilterRunner)
*/
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
double[] limits = getLimits(imp.getProcessor());
double minValue = limits[0];
double maxValue = limits[1];
if (background > maxValue)
background = (int) maxValue;
if (background < minValue)
background = (int) minValue;
GenericDialog gd = new GenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addMessage("Fit 2D Gaussian to identified maxima");
gd.addMessage("--- Image smoothing ---\n" + "- Within a 2n+1 box\n");
gd.addSlider("Smoothing", 0, 4.5, smooth);
gd.addMessage("--- Maxima identification ---\n" + "- Within a 2n+1 box\n");
gd.addSlider("Box_size", 1, 15, boxSize);
gd.addSlider("Background", minValue, maxValue, background);
gd.addSlider("Min_height", 0, maxValue, peakHeight);
gd.addSlider("Fraction_above_background", 0, 1.01, fractionAboveBackground);
gd.addSlider("Min_width", 0, 20, peakWidth);
gd.addSlider("Top_N", 0, 20, topN);
gd.addCheckbox("Block_find_algorithm", blockFindAlgorithm);
gd.addCheckbox("Neighbour_check", neighbourCheck);
gd.addSlider("Border", 0, 15, border);
gd.addMessage("--- Gaussian fitting ---");
Component splitLabel = gd.getMessage();
String[] functionNames = SettingsManager.getNames((Object[]) FitFunction.values());
gd.addChoice("Fit_function", functionNames, functionNames[fitFunction]);
gd.addCheckbox("Fit_background", fitBackground);
String[] criteriaNames = SettingsManager.getNames((Object[]) FitCriteria.values());
gd.addChoice("Fit_criteria", criteriaNames, criteriaNames[fitCriteria]);
gd.addNumericField("Max_iterations", maxIterations, 0);
gd.addNumericField("Significant_digits", significantDigits, 0);
gd.addNumericField("Coord_delta", delta, 4);
gd.addCheckbox("Single_fit", singleFit);
gd.addNumericField("Single_region_size", singleRegionSize, 0);
gd.addNumericField("Initial_StdDev", initialPeakStdDev, 3);
gd.addCheckbox("Log_progress", logProgress);
gd.addCheckbox("Show_deviations", showDeviations);
gd.addCheckbox("Filter_results", filterResults);
gd.addCheckbox("Show_fit", showFit);
gd.addPreviewCheckbox(pfr);
gd.addDialogListener(this);
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;
}
// 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() || !dialogItemChanged(gd, null)) {
// imp.getProcessor().reset();
imp.setOverlay(null);
return DONE;
}
return flags;
}
use of java.awt.Component 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;
}
use of java.awt.Component 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.Component in project adempiere by adempiere.
the class Env method updateUI.
// sleep
/**
* Update all windows after look and feel changes.
* @since 2006-11-27
*/
public static Set<Window> updateUI() {
Set<Window> updated = new HashSet<Window>();
for (Container c : s_windows) {
Window w = getFrame(c);
if (w == null)
continue;
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
for (Window w : s_hiddenWindows) {
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
return updated;
}
Aggregations