ij.measure.ResultsTable.d2s()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中ij.measure.ResultsTable.d2s方法的一些代码示例,展示了ResultsTable.d2s的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultsTable.d2s方法的具体详情如下:
包路径:ij.measure.ResultsTable
类名称:ResultsTable
方法名:d2s

ResultsTable.d2s介绍

[英]This is a version of IJ.d2s() that uses scientific notation for small numbes that would otherwise display as zero.
[中]这是IJ的一个版本。d2s(),它使用科学符号表示小数字,否则会显示为零。

代码示例

代码示例来源:origin: net.imagej/ij

private String n(double n) {
  String s;
  if ((int)n==n && precision>=0)
    s = d2s(n, 0);
  else
    s = d2s(n, precision);
  return s;
}

代码示例来源:origin: imagej/ImageJA

private String n(double n) {
  String s;
  if ((int)n==n && precision>=0)
    s = d2s(n, 0);
  else
    s = d2s(n, precision);
  return s;
}

代码示例来源:origin: net.imagej/ij

/** Converts a number to a formatted string with a tab at the end. */
public String n(double n) {
  String s;
  if (Math.round(n)==n)
    s = ResultsTable.d2s(n,0);
  else
    s = ResultsTable.d2s(n,precision);
  return s+"\t";
}

代码示例来源:origin: imagej/ImageJA

/** Converts a number to a formatted string with a tab at the end. */
public String n(double n) {
  String s;
  if (Math.round(n)==n)
    s = ResultsTable.d2s(n,0);
  else
    s = ResultsTable.d2s(n,precision);
  return s+"\t";
}

代码示例来源:origin: net.imagej/ij

String d2s(double n) {
  String s;
  if (n==(int)n)
    s = ResultsTable.d2s(n, 0);
  else
    s = ResultsTable.d2s(n, 2);
  if (s.indexOf(".")!=-1 && s.endsWith("0"))
    s = s.substring(0, s.length()-1);
  return s;
}

代码示例来源:origin: imagej/ImageJA

String d2s(double n) {
  String s;
  if (n==(int)n)
    s = ResultsTable.d2s(n, 0);
  else
    s = ResultsTable.d2s(n, 2);
  if (s.indexOf(".")!=-1 && s.endsWith("0"))
    s = s.substring(0, s.length()-1);
  return s;
}

代码示例来源:origin: net.imagej/ij

/** Converts a number to a String, such that it should not take much space (for the minLabel, maxLabel TextFields) */
String d2s(double x) {
  return Math.abs(x)>=1e6 ? IJ.d2s(x,-2) : ResultsTable.d2s(x,2);  //the latter uses exp notation also for small x
}

代码示例来源:origin: imagej/ImageJA

/** Converts a number to a String, such that it should not take much space (for the minLabel, maxLabel TextFields) */
String d2s(double x) {
  return Math.abs(x)>=1e6 ? IJ.d2s(x,-2) : ResultsTable.d2s(x,2);  //the latter uses exp notation also for small x
}

代码示例来源:origin: net.imagej/ij

private String getValueAsString(int column, int row) { 
  double value = columns[column][row];
  //IJ.log("getValueAsString1: col="+column+ ", row= "+row+", value= "+value+", size="+stringColumns.size());
  if (Double.isNaN(value) && stringColumns!=null) {
    String string = "NaN";
    ArrayList stringColumn = (ArrayList)stringColumns.get(new Integer(column));
    if (stringColumn==null)
      return string;
    //IJ.log("getValueAsString2: "+column+ +row+" "+stringColumn.size());
    if (row>=0 && row<stringColumn.size()) {
      string = (String)stringColumn.get(row);
      if (string!=null && string.contains("\n"))
        string = string.replaceAll("\n", "\\\\n");
      return string;
    } else
      return string;
  } else {
    int places = decimalPlaces[column];
    if (places==AUTO_FORMAT)
      return n(value);
    else
      return d2s(value, places);
  }
}

代码示例来源:origin: imagej/ImageJA

private String getValueAsString(int column, int row) { 
  double value = columns[column][row];
  //IJ.log("getValueAsString1: col="+column+ ", row= "+row+", value= "+value+", size="+stringColumns.size());
  if (Double.isNaN(value) && stringColumns!=null) {
    String string = "NaN";
    ArrayList stringColumn = (ArrayList)stringColumns.get(new Integer(column));
    if (stringColumn==null)
      return string;
    //IJ.log("getValueAsString2: "+column+ +row+" "+stringColumn.size());
    if (row>=0 && row<stringColumn.size()) {
      string = (String)stringColumn.get(row);
      if (string!=null && string.contains("\n"))
        string = string.replaceAll("\n", "\\\\n");
      return string;
    } else
      return string;
  } else {
    int places = decimalPlaces[column];
    if (places==AUTO_FORMAT)
      return n(value);
    else
      return d2s(value, places);
  }
}

代码示例来源:origin: net.imagej/imagej-legacy

c = ResultsTable.d2s(d, dec[col]);
c = ResultsTable.d2s(d, ResultsTable.AUTO_FORMAT);

代码示例来源:origin: net.imagej/ij

protected void copyToClipboard() {
  Clipboard systemClipboard = null;
  try {systemClipboard = getToolkit().getSystemClipboard();}
  catch (Exception e) {systemClipboard = null; }
  if (systemClipboard==null)
    {IJ.error("Unable to copy to Clipboard."); return;}
  IJ.showStatus("Copying histogram values...");
  CharArrayWriter aw = new CharArrayWriter(stats.nBins*4);
  PrintWriter pw = new PrintWriter(aw);
  for (int i=0; i<stats.nBins; i++)
    pw.print(ResultsTable.d2s(cal.getCValue(stats.histMin+i*stats.binSize), digits)+"\t"+histogram[i]+"\n");
  String text = aw.toString();
  pw.close();
  StringSelection contents = new StringSelection(text);
  systemClipboard.setContents(contents, this);
  IJ.showStatus(text.length() + " characters copied to Clipboard");
}

代码示例来源:origin: zitmen/thunderstorm

protected void showList() {
  StringBuilder sb = new StringBuilder();
  String vheading = stats.binSize == 1.0 ? "value" : "bin start";
  if(cal.calibrated() && !cal.isSigned16Bit()) {
    for(int i = 0; i < stats.nBins; i++) {
      sb.append(i).append("\t").append(ResultsTable.d2s(cal.getCValue(stats.histMin + i * stats.binSize), digits)).append("\t").append(histogram[i]).append("\n");
    }
    TextWindow tw = new TextWindow(getTitle(), "level\t" + vheading + "\tcount", sb.toString(), 200, 400);
  } else {
    for(int i = 0; i < stats.nBins; i++) {
      sb.append(ResultsTable.d2s(cal.getCValue(stats.histMin + i * stats.binSize), digits)).append("\t").append(histogram[i]).append("\n");
    }
    TextWindow tw = new TextWindow(getTitle(), vheading + "\tcount", sb.toString(), 200, 400);
  }
}

代码示例来源:origin: imagej/ImageJA

protected void copyToClipboard() {
  Clipboard systemClipboard = null;
  try {systemClipboard = getToolkit().getSystemClipboard();}
  catch (Exception e) {systemClipboard = null; }
  if (systemClipboard==null)
    {IJ.error("Unable to copy to Clipboard."); return;}
  IJ.showStatus("Copying histogram values...");
  CharArrayWriter aw = new CharArrayWriter(stats.nBins*4);
  PrintWriter pw = new PrintWriter(aw);
  for (int i=0; i<stats.nBins; i++)
    pw.print(ResultsTable.d2s(cal.getCValue(stats.histMin+i*stats.binSize), digits)+"\t"+histogram[i]+"\n");
  String text = aw.toString();
  pw.close();
  StringSelection contents = new StringSelection(text);
  systemClipboard.setContents(contents, this);
  IJ.showStatus(text.length() + " characters copied to Clipboard");
}

代码示例来源:origin: zitmen/thunderstorm

protected void copyToClipboard() {
  Clipboard systemClipboard = null;
  try {
    systemClipboard = getToolkit().getSystemClipboard();
  } catch(Exception e) {
    systemClipboard = null;
  }
  if(systemClipboard == null) {
    IJ.error("Unable to copy to Clipboard.");
    return;
  }
  IJ.showStatus("Copying histogram values...");
  CharArrayWriter aw = new CharArrayWriter(stats.nBins * 4);
  PrintWriter pw = new PrintWriter(aw);
  for(int i = 0; i < stats.nBins; i++) {
    pw.print(ResultsTable.d2s(cal.getCValue(stats.histMin + i * stats.binSize), digits) + "\t" + histogram[i] + "\n");
  }
  String text = aw.toString();
  pw.close();
  StringSelection contents = new StringSelection(text);
  systemClipboard.setContents(contents, this);
  IJ.showStatus(text.length() + " characters copied to Clipboard");
}

代码示例来源:origin: sc.fiji/Colocalisation_Analysis

cursor.setPosition(j, 1);
sb.append(
    ResultsTable.d2s(xMin + (i * xBinWidth), xDecimalPlaces) + "\t" +
    ResultsTable.d2s(yMin + (j * yBinWidth), yDecimalPlaces) + "\t" +
    ResultsTable.d2s(cursor.get().getRealDouble(), 0) + "\n");

代码示例来源:origin: imagej/ImageJA

Variable[] printArray() {
  String prefix = null;
  interp.getLeftParen();
  if (!isArrayArg() && isStringArg()) {
    prefix = getString();
    interp.getComma();
  }
  Variable[] a = getArray();
  interp.getRightParen();
  int len = a.length;
  StringBuffer sb = new StringBuffer(len);
  if (prefix!=null)
    sb.append(prefix+" ");
  for (int i=0; i<len; i++) {
    String s = a[i].getString();
    if (s==null) {
      double v = a[i].getValue();
      if ((int)v==v)
        s = IJ.d2s(v,0);
      else
        s = ResultsTable.d2s(v,4);
    }
    sb.append(s);
    if (i!=len-1)
      sb.append(", ");
  }
  interp.log(sb.toString());
  return null;
}

代码示例来源:origin: net.imagej/ij

Variable[] printArray() {
  String prefix = null;
  interp.getLeftParen();
  if (!isArrayArg() && isStringArg()) {
    prefix = getString();
    interp.getComma();
  }
  Variable[] a = getArray();
  interp.getRightParen();
  int len = a.length;
  StringBuffer sb = new StringBuffer(len);
  if (prefix!=null)
    sb.append(prefix+" ");
  for (int i=0; i<len; i++) {
    String s = a[i].getString();
    if (s==null) {
      double v = a[i].getValue();
      if ((int)v==v)
        s = IJ.d2s(v,0);
      else
        s = ResultsTable.d2s(v,4);
    }
    sb.append(s);
    if (i!=len-1)
      sb.append(", ");
  }
  interp.log(sb.toString());
  return null;
}

代码示例来源:origin: net.imagej/ij

void updateLabels(ImagePlus imp, ImageProcessor ip) {
  if (minLabel==null || maxLabel==null)
    return;
  double min = ip.getMinThreshold();
  double max = ip.getMaxThreshold();
  if (min==ImageProcessor.NO_THRESHOLD) {
    minLabel.setText("");
    maxLabel.setText("");
  } else {
    Calibration cal = imp.getCalibration();
    if (cal.calibrated()) {
      min = cal.getCValue((int)min);
      max = cal.getCValue((int)max);
    }
    if ((((int)min==min && (int)max==max && Math.abs(min)<1e6 && Math.abs(max)<1e6)) ||
        (ip instanceof ShortProcessor && (cal.isSigned16Bit() || !cal.calibrated()))) {
      minLabel.setText(ResultsTable.d2s(min,0));
      maxLabel.setText(ResultsTable.d2s(max,0));
    } else {
      minLabel.setText(min==-1e30 ? "-1e30" : d2s(min));
      maxLabel.setText(max== 1e30 ? "1e30" : d2s(max));
    }
  }
}

代码示例来源:origin: imagej/ImageJA

void updateLabels(ImagePlus imp, ImageProcessor ip) {
  if (minLabel==null || maxLabel==null)
    return;
  double min = ip.getMinThreshold();
  double max = ip.getMaxThreshold();
  if (min==ImageProcessor.NO_THRESHOLD) {
    minLabel.setText("");
    maxLabel.setText("");
  } else {
    Calibration cal = imp.getCalibration();
    if (cal.calibrated()) {
      min = cal.getCValue((int)min);
      max = cal.getCValue((int)max);
    }
    if ((((int)min==min && (int)max==max && Math.abs(min)<1e6 && Math.abs(max)<1e6)) ||
        (ip instanceof ShortProcessor && (cal.isSigned16Bit() || !cal.calibrated()))) {
      minLabel.setText(ResultsTable.d2s(min,0));
      maxLabel.setText(ResultsTable.d2s(max,0));
    } else {
      minLabel.setText(min==-1e30 ? "-1e30" : d2s(min));
      maxLabel.setText(max== 1e30 ? "1e30" : d2s(max));
    }
  }
}

相关文章

微信公众号

最新文章

更多