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

Method getPlotValues

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

Source from the content-addressed store, hash-verified

2469 }
2470
2471 double getPlotValues() {
2472 Variable xvar = getFirstArrayVariable();
2473 Variable yvar = getLastArrayVariable();
2474 float[] xvalues = new float[0];
2475 float[] yvalues = new float[0];
2476 ImagePlus imp = getImage();
2477 long maxDelay = 100; //https://forum.image.sc/t/plot-getvalues-returns-odd-results
2478 long t0 = System.currentTimeMillis();
2479 while ((System.currentTimeMillis()-t0)<maxDelay) {
2480 if (imp.getProperty("XValues")!=null || imp.getTitle().startsWith("Plot of"))
2481 break;
2482 IJ.wait(5);
2483 imp = getImage();
2484 }
2485 ImageWindow win = imp.getWindow();
2486 if (imp.getProperty("XValues")!=null) {
2487 xvalues = (float[])imp.getProperty("XValues");
2488 yvalues = (float[])imp.getProperty("YValues");
2489 } else if (win!=null && win instanceof PlotWindow) {
2490 PlotWindow pw = (PlotWindow)win;
2491 xvalues = pw.getXValues();
2492 yvalues = pw.getYValues();
2493 } else if (win!=null && win instanceof HistogramWindow) {
2494 HistogramWindow hw = (HistogramWindow)win;
2495 double[] x = hw.getXValues();
2496 xvalues = new float[x.length];
2497 for (int i=0; i<x.length; i++)
2498 xvalues[i] = (float)x[i];
2499 int[] y = hw.getHistogram();
2500 yvalues = new float[y.length];
2501 for (int i=0; i<y.length; i++)
2502 yvalues[i] = y[i];
2503 } else
2504 interp.error("No plot or histogram window");
2505 Variable[] xa = new Variable[xvalues.length];
2506 Variable[] ya = new Variable[yvalues.length];
2507 for (int i=0; i<xvalues.length; i++)
2508 xa[i] = new Variable(xvalues[i]);
2509 for (int i=0; i<yvalues.length; i++)
2510 ya[i] = new Variable(yvalues[i]);
2511 xvar.setArray(xa);
2512 yvar.setArray(ya);
2513 return Double.NaN;
2514 }
2515
2516 double showPlotValues(boolean useLabels) {
2517 String title = "Results";

Callers 1

doPlotMethod · 0.95

Calls 14

getFirstArrayVariableMethod · 0.95
getLastArrayVariableMethod · 0.95
getImageMethod · 0.95
getPropertyMethod · 0.95
getTitleMethod · 0.95
waitMethod · 0.95
getWindowMethod · 0.95
getXValuesMethod · 0.95
getYValuesMethod · 0.95
getXValuesMethod · 0.95
getHistogramMethod · 0.95
setArrayMethod · 0.95

Tested by

no test coverage detected