()
| 2308 | } |
| 2309 | |
| 2310 | double doPlot() { |
| 2311 | interp.getToken(); |
| 2312 | if (interp.token!='.') |
| 2313 | interp.error("'.' expected"); |
| 2314 | interp.getToken(); |
| 2315 | if (!(interp.token==WORD || interp.token==PREDEFINED_FUNCTION || interp.token==STRING_FUNCTION)) |
| 2316 | interp.error("Function name expected: "); |
| 2317 | String name = interp.tokenString; |
| 2318 | if (name.equals("create")) { |
| 2319 | return newPlot(); |
| 2320 | } else if (name.equals("getValues")) { |
| 2321 | return getPlotValues(); |
| 2322 | } else if (name.equals("showValues")) { |
| 2323 | return showPlotValues(/*useLabels=*/false); |
| 2324 | } else if (name.equals("showValuesWithLabels")) { |
| 2325 | return showPlotValues(/*useLabels=*/true); |
| 2326 | } |
| 2327 | // the following commands work with a plot under construction or an image with a plot created previously |
| 2328 | Plot currentPlot = plot; |
| 2329 | if (currentPlot == null) |
| 2330 | currentPlot = (Plot)(getImage().getProperty(Plot.PROPERTY_KEY)); |
| 2331 | if (currentPlot==null) |
| 2332 | interp.error("No plot window and no plot under construction"); |
| 2333 | if (name.equals("setFrameSize")) { |
| 2334 | currentPlot.setFrameSize((int)getFirstArg(), (int)getLastArg()); |
| 2335 | return Double.NaN; |
| 2336 | } else if (name.equals("setLimits")) { |
| 2337 | currentPlot.setLimits(getFirstArg(), getNextArg(), getNextArg(), getLastArg()); |
| 2338 | return Double.NaN; |
| 2339 | } else if (name.equals("setLimitsToFit")) { |
| 2340 | interp.getParens(); |
| 2341 | currentPlot.setLimitsToFit(true); |
| 2342 | return Double.NaN; |
| 2343 | } else if (name.equals("setLogScaleX")) { |
| 2344 | if (interp.nextNextToken()==')') { //no-argument call setLogScaleX() means true |
| 2345 | interp.getParens(); |
| 2346 | currentPlot.setAxisXLog(true); |
| 2347 | } else |
| 2348 | currentPlot.setAxisXLog(getBooleanArg()); |
| 2349 | currentPlot.updateImage(); |
| 2350 | return Double.NaN; |
| 2351 | } else if (name.equals("setLogScaleY")) { |
| 2352 | if (interp.nextNextToken()==')') { |
| 2353 | interp.getParens(); |
| 2354 | currentPlot.setAxisYLog(true); |
| 2355 | } else |
| 2356 | currentPlot.setAxisYLog(getBooleanArg()); |
| 2357 | currentPlot.updateImage(); |
| 2358 | return Double.NaN; |
| 2359 | } else if (name.equals("getLimits")) { |
| 2360 | return getPlotLimits(currentPlot); |
| 2361 | } else if (name.equals("freeze")) { |
| 2362 | currentPlot.setFrozen(getBooleanArg()); |
| 2363 | return Double.NaN; |
| 2364 | } else if (name.equals("removeNaNs")) { |
| 2365 | interp.getParens(); |
| 2366 | currentPlot.removeNaNs(); |
| 2367 | return Double.NaN; |
no test coverage detected