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

Method makeSelection

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

Source from the content-addressed store, hash-verified

2199 }
2200
2201 void makeSelection() {
2202 String type = null;
2203 int roiType = -1;
2204 interp.getLeftParen();
2205 if (isStringArg()) {
2206 type = getString().toLowerCase();
2207 roiType = Roi.POLYGON;
2208 if (type.contains("free"))
2209 roiType = Roi.FREEROI;
2210 if (type.contains("traced"))
2211 roiType = Roi.TRACED_ROI;
2212 if (type.contains("line")) {
2213 if (type.contains("free"))
2214 roiType = Roi.FREELINE;
2215 else
2216 roiType = Roi.POLYLINE;
2217 }
2218 if (type.contains("angle"))
2219 roiType = Roi.ANGLE;
2220 if (type.contains("point")||type.contains("cross")||type.contains("circle")||type.contains("dot"))
2221 roiType = Roi.POINT;
2222 } else {
2223 roiType = (int)interp.getExpression();
2224 if (roiType<0 || roiType==Roi.COMPOSITE)
2225 interp.error("Invalid selection type ("+roiType+")");
2226 if (roiType==Roi.RECTANGLE) roiType = Roi.POLYGON;
2227 if (roiType==Roi.OVAL) roiType = Roi.FREEROI;
2228 }
2229 double[] x = getNextArray();
2230 int n = x.length;
2231 interp.getComma();
2232 double[] y = getNumericArray();
2233 if (interp.nextToken()==',') {
2234 n = (int)getLastArg();
2235 if (n>x.length || n>y.length)
2236 interp.error("Array too short");
2237 } else {
2238 interp.getRightParen();
2239 if (y.length!=n)
2240 interp.error("Arrays are not the same length");
2241 }
2242 ImagePlus imp = getImage();
2243 boolean floatCoordinates = false;
2244 for (int i=0; i<n; i++) {
2245 if (x[i]!=(int)x[i] || y[i]!=(int)y[i]) {
2246 floatCoordinates = true;
2247 break;
2248 }
2249 }
2250 int[] xcoord = null;
2251 int[] ycoord = null;
2252 float[] xfcoord = null;
2253 float[] yfcoord = null;
2254 if (floatCoordinates) {
2255 xfcoord = new float[n];
2256 yfcoord = new float[n];
2257 for (int i=0; i<n; i++) {
2258 xfcoord[i] = (float)x[i];

Callers 1

doFunctionMethod · 0.95

Calls 15

isStringArgMethod · 0.95
getStringMethod · 0.95
getNextArrayMethod · 0.95
getNumericArrayMethod · 0.95
getLastArgMethod · 0.95
getImageMethod · 0.95
getRoiMethod · 0.95
saveRoiMethod · 0.95
setRoiMethod · 0.95
updateRoiMethod · 0.95
getLeftParenMethod · 0.80
getExpressionMethod · 0.80

Tested by

no test coverage detected