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

Method toScaled

ij/src/main/java/ij/macro/Functions.java:7910–7950  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7908 }
7909
7910 void toScaled() { //pixel coordinates to calibrated coordinates
7911 ImagePlus imp = getImage();
7912 Plot plot = (Plot)(getImage().getProperty(Plot.PROPERTY_KEY)); //null if not a plot window
7913 int height = imp.getHeight();
7914 Calibration cal = imp.getCalibration();
7915 interp.getLeftParen();
7916 if (isArrayArg()) {
7917 Variable[] x = getArray();
7918 interp.getComma();
7919 Variable[] y = getArray();
7920 interp.getRightParen();
7921 for (int i=0; i<x.length; i++)
7922 x[i].setValue(plot==null ? cal.getX(x[i].getValue()) : plot.descaleX((int)(x[i].getValue()+0.5)));
7923 for (int i=0; i<y.length; i++)
7924 y[i].setValue(plot==null ? cal.getY(y[i].getValue(),height) : plot.descaleY((int)(y[i].getValue()+0.5)));
7925 } else {
7926 Variable xv = getVariable();
7927 Variable yv = null;
7928 Variable zv = null;
7929 boolean twoArgs = interp.nextToken()==',';
7930 if (twoArgs) {
7931 interp.getComma();
7932 yv = getVariable();
7933 }
7934 boolean threeArgs = interp.nextToken()==',';
7935 if (threeArgs) {
7936 interp.getComma();
7937 zv = getVariable();
7938 }
7939 interp.getRightParen();
7940 double x = xv.getValue();
7941 if (twoArgs) {
7942 double y = yv.getValue();
7943 xv.setValue(plot == null ? cal.getX(x) : plot.descaleX((int)(x+0.5)));
7944 yv.setValue(plot == null ? cal.getY(y,height) : plot.descaleY((int)(y+0.5)));
7945 if (threeArgs)
7946 zv.setValue(cal.getZ(zv.getValue()));
7947 } else //oneArg; convert horizontal length (not the x coordinate, no offset)
7948 xv.setValue(x * cal.pixelWidth) ;
7949 }
7950 }
7951
7952 void toUnscaled() { //calibrated coordinates to pixel coordinates
7953 ImagePlus imp = getImage();

Callers 1

doFunctionMethod · 0.95

Calls 15

getImageMethod · 0.95
getHeightMethod · 0.95
getCalibrationMethod · 0.95
isArrayArgMethod · 0.95
getArrayMethod · 0.95
setValueMethod · 0.95
getXMethod · 0.95
descaleXMethod · 0.95
getYMethod · 0.95
descaleYMethod · 0.95
getVariableMethod · 0.95
getValueMethod · 0.95

Tested by

no test coverage detected