MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getValueAsString

Method getValueAsString

ij/src/main/java/ij/ImagePlus.java:2960–2992  ·  view source on GitHub ↗
(int x, int y)

Source from the content-addressed store, hash-verified

2958 }
2959
2960 private String getValueAsString(int x, int y) {
2961 if (win!=null && win instanceof PlotWindow)
2962 return "";
2963 Calibration cal = getCalibration();
2964 int[] v = getPixel(x, y);
2965 int type = getType();
2966 switch (type) {
2967 case GRAY8: case GRAY16: case COLOR_256:
2968 if (type==COLOR_256) {
2969 if (cal.getCValue(v[3])==v[3]) // not calibrated
2970 return(", index=" + v[3] + ", value=" + v[0] + "," + v[1] + "," + v[2]);
2971 else
2972 v[0] = v[3];
2973 }
2974 double cValue = cal.getCValue(v[0]);
2975 if (cValue==v[0])
2976 return(", value=" + v[0]);
2977 else
2978 return(", value=" + IJ.d2s(cValue) + " ("+v[0]+")");
2979 case GRAY32:
2980 double value = Float.intBitsToFloat(v[0]);
2981 String s = (int)value==value?IJ.d2s(value,0)+".0":IJ.d2s(value,4,7);
2982 return(", value=" + s);
2983 case COLOR_RGB:
2984 if (ip!=null && ip.getNChannels()==1)
2985 return(", value=" + v[0]);
2986 else {
2987 String hex = Colors.colorToString(new Color(v[0],v[1],v[2]));
2988 return(", value=" + IJ.pad(v[0],3) + "," + IJ.pad(v[1],3) + "," + IJ.pad(v[2],3) + " ("+hex + ")");
2989 }
2990 default: return("");
2991 }
2992 }
2993
2994 /** Copies the contents of the current selection to the internal
2995 clipboard and then clears the selection. */

Callers 1

mouseMovedMethod · 0.95

Calls 8

getCalibrationMethod · 0.95
getPixelMethod · 0.95
getTypeMethod · 0.95
getCValueMethod · 0.95
d2sMethod · 0.95
colorToStringMethod · 0.95
padMethod · 0.95
getNChannelsMethod · 0.45

Tested by

no test coverage detected