use of java.awt.Component in project adempiere by adempiere.
the class ProcessPanel method formatEditor.
public void formatEditor(CEditor editor1, CEditor editor2) {
log.fine("");
VEditor editor = (VEditor) editor1;
VEditor editorTo = (VEditor) editor2;
if (editor == null) {
return;
}
configColumns(editor, editorTo);
// Create label
CLabel label = VEditorFactory.getLabel(editor.getField());
if (label == null) {
// left gap
centerPanel.add(Box.createHorizontalStrut(12), new ALayoutConstraint(row, cols++));
} else {
int currentWidth = label.getPreferredSize().width;
labelMinWidth = currentWidth > labelMinWidth ? currentWidth : labelMinWidth;
// label.setSize(label.getPreferredSize());
// label.setMinimumSize(label.getPreferredSize());
// label.putClientProperty("LabelUI.truncationString", ">");
centerPanel.add(label, new ALayoutConstraint(row, cols++));
}
//
Component component = (Component) editor;
fieldMinWidth = component.getPreferredSize().width > fieldMinWidth ? component.getPreferredSize().width : fieldMinWidth;
centerPanel.add((Component) editor, new ALayoutConstraint(row, cols++));
// To
if (editorTo == null) {
m_separators.add(null);
return;
}
// Add
CLabel dash = new CLabel(" - ");
centerPanel.add(dash, new ALayoutConstraint(row, cols++));
m_separators.add(dash);
//
centerPanel.add((Component) editorTo, new ALayoutConstraint(row, cols++));
}
use of java.awt.Component in project GDSC-SMLM by aherbert.
the class CreateData method showSimpleDialog.
/**
* Show a dialog allowing the parameters for a simple/benchmark simulation to be performed
*
* @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) {
// Allow mask but not the grid
gd.addChoice("Distribution", Arrays.copyOf(DISTRIBUTION, DISTRIBUTION.length - 1), settings.distribution);
gd.addCheckbox("Sample_per_frame", settings.samplePerFrame);
}
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);
gd.addNumericField("Depth-of-field (nm)", settings.depthOfField, 0);
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.samplePerFrame = gd.getNextBoolean();
}
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) Math.abs(gd.getNextNumber());
settings.removeOutliers = gd.getNextBoolean();
if (simpleMode)
settings.densityRadius = (float) gd.getNextNumber();
settings.depthOfField = (float) Math.abs(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.isPositive("Histogram bins", settings.histogramBins);
if (simpleMode)
Parameters.isPositive("Density radius", settings.densityRadius);
} catch (IllegalArgumentException e) {
IJ.error(TITLE, e.getMessage());
return false;
}
if (settings.distribution.equals(DISTRIBUTION[MASK])) {
String[] 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());
}
SettingsManager.saveSettings(globalSettings);
}
return getHistogramOptions();
}
use of java.awt.Component in project adempiere by adempiere.
the class VCellRenderer method getTableCellRendererComponent.
/**
* Get TableCell RendererComponent.
* @param table table
* @param value value
* @param isSelected selected
* @param hasFocus focus
* @param row row
* @param col col
* @return component
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// log.finest(m_columnName
// + ": Value=" + (value == null ? "null" : value.toString())
// + ", Row=" + row + ", Col=" + col);
Component c = null;
if (m_displayType == DisplayType.YesNo)
c = m_check;
else {
// returns JLabel
c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
//c.setFont(AdempierePLAF.getFont_Field());
c.setFont(table.getFont());
}
// Background & Foreground
Color bg = AdempierePLAF.getFieldBackground_Normal();
Color fg = AdempierePLAF.getTextColor_Normal();
// Inactive Background
boolean ro = !table.isCellEditable(row, col);
if (ro) {
bg = AdempierePLAF.getFieldBackground_Inactive();
if (isSelected && !hasFocus)
bg = bg.darker();
}
// Foreground
int cCode = 0;
// Grid
if (table instanceof org.compiere.grid.VTable)
cCode = ((org.compiere.grid.VTable) table).getColorCode(row);
else // MiniGrid
if (table instanceof org.compiere.minigrid.MiniTable)
cCode = ((org.compiere.minigrid.MiniTable) table).getColorCode(row);
//
if (cCode == 0)
// Black
;
else if (cCode < 0)
// Red
fg = AdempierePLAF.getTextColor_Issue();
else
// Blue
fg = AdempierePLAF.getTextColor_OK();
// Highlighted row
if (isSelected) {
// Windows is white on blue
bg = table.getSelectionBackground();
fg = table.getSelectionForeground();
if (hasFocus)
bg = org.adempiere.apps.graph.GraphUtil.brighter(bg, .9);
}
// Set Color
c.setBackground(bg);
c.setForeground(fg);
//
// log.fine( "r=" + row + " c=" + col, // + " - " + c.getClass().getName(),
// "sel=" + isSelected + ", focus=" + hasFocus + ", edit=" + table.isCellEditable(row, col));
// Log.trace(7, "BG=" + (bg.equals(Color.white) ? "white" : bg.toString()), "FG=" + (fg.equals(Color.black) ? "black" : fg.toString()));
// Format it
setValue(value);
return c;
}
use of java.awt.Component in project adempiere by adempiere.
the class VBrowserTable method autoSize.
/**
* Size Columns.
* Uses Mimimun Column Size
*/
public void autoSize() {
if (!autoResize)
return;
long start = System.currentTimeMillis();
//
// making sure it fits in a column
final int SLACK = 8;
// max size of a column
final int MAXSIZE = 300;
//
TableModel model = this.getModel();
int size = model.getColumnCount();
// for all columns
for (int col = 0; col < size; col++) {
// Column & minimum width
TableColumn tc = this.getColumnModel().getColumn(col);
int width = 0;
if (m_minWidth.size() > col)
width = ((Integer) m_minWidth.get(col)).intValue();
// log.config( "Column=" + col + " " + column.getHeaderValue());
// Header
TableCellRenderer renderer = tc.getHeaderRenderer();
if (renderer == null)
renderer = new DefaultTableCellRenderer();
Component comp = renderer.getTableCellRendererComponent(this, tc.getHeaderValue(), false, false, 0, 0);
// log.fine( "Hdr - preferred=" + comp.getPreferredSize().width + ", width=" + comp.getWidth());
width = Math.max(width, comp.getPreferredSize().width + SLACK);
// Cells
// first 30 rows
int maxRow = Math.min(30, getRowCount());
for (int row = 0; row < maxRow; row++) {
renderer = getCellRenderer(row, col);
comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col);
if (comp != null) {
int rowWidth = comp.getPreferredSize().width + SLACK;
width = Math.max(width, rowWidth);
}
}
// Width not greater ..
width = Math.min(MAXSIZE, width);
tc.setPreferredWidth(width);
// log.fine( "width=" + width);
}
// for all columns
log.finer("Cols=" + size + " - " + (System.currentTimeMillis() - start) + "ms");
}
use of java.awt.Component in project adempiere by adempiere.
the class VPanel method getComponentsRecursive.
//[ 1757088 ]
public Component[] getComponentsRecursive() {
java.util.ArrayList<Component> list = new java.util.ArrayList<Component>();
for (int i = 0; i < this.getTabCount(); i++) {
list.add(this.getComponentAt(i));
if (this.getComponentAt(i) instanceof CPanel) {
CPanel panel = (CPanel) this.getComponentAt(i);
findChildComponents(panel, list);
}
}
Component[] result = new Component[list.size()];
list.toArray(result);
return result;
}
Aggregations