private void init() { int p = Analyzer.getPrecision(); if (p>precision) precision = (short)p; for (int i=0; i<decimalPlaces.length; i++) decimalPlaces[i] = AUTO_FORMAT; }
private void init() { int p = Analyzer.getPrecision(); if (p>precision) precision = (short)p; for (int i=0; i<decimalPlaces.length; i++) decimalPlaces[i] = AUTO_FORMAT; }
/** * Retrieves precision according to {@code Analyze>Set Measurements...} * * @return the number of decimal digits to be used in tables */ protected int getScientificNotationAwarePrecision() { final boolean sNotation = (Analyzer.getMeasurements() & Measurements.SCIENTIFIC_NOTATION) != 0; int precision = Analyzer.getPrecision(); if (sNotation) precision = -precision; return precision; }
/** Save the image as tab-delimited text using the specified path. */ public boolean saveAsText(String path) { DataOutputStream out = null; try { Calibration cal = imp.getCalibration(); int precision = Analyzer.getPrecision(); int measurements = Analyzer.getMeasurements(); boolean scientificNotation = (measurements&Measurements.SCIENTIFIC_NOTATION)!=0; if (scientificNotation) precision = -precision; TextEncoder file = new TextEncoder(imp.getProcessor(), cal, precision); out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path))); file.write(out); out.close(); } catch (IOException e) { showErrorMessage("saveAsText", path, e); return false; } finally { if (out!=null) try {out.close();} catch (IOException e) {} } return true; }
/** get the number of digits for writing a column to the results table or the clipboard */ static int getPrecision(float[] values) { int setDigits = Analyzer.getPrecision(); int measurements = Analyzer.getMeasurements(); boolean scientificNotation = (measurements&Measurements.SCIENTIFIC_NOTATION)!=0; if (scientificNotation) { if (setDigits<MIN_SCIENTIFIC_DIGITS) setDigits = MIN_SCIENTIFIC_DIGITS; return -setDigits; } boolean allInteger = true; float min = Float.MAX_VALUE, max = -Float.MAX_VALUE; for (int i=0; i<values.length; i++) { if ((int)values[i]!=values[i] && !Float.isNaN(values[i])) { allInteger = false; if (values[i] < min) min = values[i]; if (values[i] > max) max = values[i]; } } if (allInteger) return 0; int digits = (max - min) > 0 ? getDigits(min, max, MIN_FLOAT_PRECISION*(max-min), 15) : getDigits(max, MIN_FLOAT_PRECISION*Math.abs(max), 15); if (setDigits>Math.abs(digits)) digits = setDigits * (digits < 0 ? -1 : 1); //use scientific notation if needed return digits; }
/** Save the image as tab-delimited text using the specified path. */ public boolean saveAsText(String path) { DataOutputStream out = null; try { Calibration cal = imp.getCalibration(); int precision = Analyzer.getPrecision(); int measurements = Analyzer.getMeasurements(); boolean scientificNotation = (measurements&Measurements.SCIENTIFIC_NOTATION)!=0; if (scientificNotation) precision = -precision; TextEncoder file = new TextEncoder(imp.getProcessor(), cal, precision); out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path))); file.write(out); out.close(); } catch (IOException e) { showErrorMessage("saveAsText", path, e); return false; } finally { if (out!=null) try {out.close();} catch (IOException e) {} } return true; }
/** get the number of digits for writing a column to the results table or the clipboard */ static int getPrecision(float[] values) { int setDigits = Analyzer.getPrecision(); int measurements = Analyzer.getMeasurements(); boolean scientificNotation = (measurements&Measurements.SCIENTIFIC_NOTATION)!=0; if (scientificNotation) { if (setDigits<MIN_SCIENTIFIC_DIGITS) setDigits = MIN_SCIENTIFIC_DIGITS; return -setDigits; } boolean allInteger = true; float min = Float.MAX_VALUE, max = -Float.MAX_VALUE; for (int i=0; i<values.length; i++) { if ((int)values[i]!=values[i] && !Float.isNaN(values[i])) { allInteger = false; if (values[i] < min) min = values[i]; if (values[i] > max) max = values[i]; } } if (allInteger) return 0; int digits = (max - min) > 0 ? getDigits(min, max, MIN_FLOAT_PRECISION*(max-min), 15) : getDigits(max, MIN_FLOAT_PRECISION*Math.abs(max), 15); if (setDigits>Math.abs(digits)) digits = setDigits * (digits < 0 ? -1 : 1); //use scientific notation if needed return digits; }
void getValue (String title, String prompt, double defaultValue, int digits) { int places = Analyzer.getPrecision(); if (digits>0 || (int)defaultValue!=defaultValue) digits = Math.max(places, 1); gd = new GenericDialog(title); gd.addNumericField(prompt, defaultValue, digits, 8, null); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); }
void getValue (String title, String prompt, double defaultValue, int digits) { int places = Analyzer.getPrecision(); if (digits>0 || (int)defaultValue!=defaultValue) digits = Math.max(places, 1); gd = new GenericDialog(title); gd.addNumericField(prompt, defaultValue, digits, 8, null); gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); }
protected void drawHistogram(ImageProcessor ip) { int x, y; double minCount2 = histogram[0]; double maxCount2 = histogram[0]; int mode2 = 0; int saveModalCount; ip.setColor(Color.black); ip.setLineWidth(1); decimalPlaces = Analyzer.getPrecision(); digits = binSize!=1.0?decimalPlaces:0; for (int i = 1; i<histogram.length; i++) if (histogram[i] > maxCount2) { maxCount2 = histogram[i]; mode2 = i; } else if (histogram[i] < minCount2) minCount2 = histogram[i]; drawPlot(minCount2, maxCount2, ip); x = XMARGIN + 1; y = YMARGIN + HIST_HEIGHT + 2; y += BAR_HEIGHT+15; drawText(ip, x, y); }
decimalPlaces = Analyzer.getPrecision();
rt.setPrecision(allIntegers?0:Analyzer.getPrecision()); for (int i=0; i<fp.npoints; i++) { rt.incrementCounter();
saveSettingsCalled = true; measurements = Analyzer.getMeasurements(); decimalPlaces = Analyzer.getPrecision(); blackBackground = Prefs.blackBackground; autoContrast = Prefs.autoContrast;
saveSettingsCalled = true; measurements = Analyzer.getMeasurements(); decimalPlaces = Analyzer.getPrecision(); blackBackground = Prefs.blackBackground; autoContrast = Prefs.autoContrast;
decimalPlaces = Analyzer.getPrecision(); digits = cal.calibrated() || stats.binSize != 1.0 ? decimalPlaces : 0; saveModalCount = histogram[stats.mode];
rt.setPrecision(allIntegers?0:Analyzer.getPrecision()); for (int i=0; i<fp.npoints; i++) { rt.incrementCounter();
ip.setColor(Color.black); ip.setLineWidth(1); decimalPlaces = Analyzer.getPrecision(); digits = cal.calibrated()||stats.binSize!=1.0?decimalPlaces:0; saveModalCount = histogram[stats.mode];
ip.setColor(Color.black); ip.setLineWidth(1); decimalPlaces = Analyzer.getPrecision(); digits = cal.calibrated()||stats.binSize!=1.0?decimalPlaces:0; saveModalCount = histogram[stats.mode];
int yOffset = y; if (decimalPlaces == -1) decimalPlaces = Analyzer.getPrecision(); x = (int)(XMARGIN*zoom) + xOffset; y = (int)(YMARGIN*zoom) + yOffset;
int yOffset = y; if (decimalPlaces == -1) decimalPlaces = Analyzer.getPrecision(); x = (int)(XMARGIN*zoom) + xOffset; y = (int)(YMARGIN*zoom) + yOffset;