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

Method drawFloatPolyline

ij/src/main/java/ij/gui/Plot.java:3904–3927  ·  view source on GitHub ↗

Draw a polygon line; NaN values interrupt it.

(ImageProcessor ip, float[] x, float[] y, int n)

Source from the content-addressed store, hash-verified

3902
3903 /** Draw a polygon line; NaN values interrupt it. */
3904 void drawFloatPolyline(ImageProcessor ip, float[] x, float[] y, int n) {
3905 if (x==null || x.length==0) return;
3906 int x1, y1;
3907 boolean isNaN0;
3908 boolean isNaN1 = true; //no previous point
3909 int x2 = scaleX(x[0]);
3910 int y2 = scaleY(y[0]);
3911 boolean isNaN2 = Float.isNaN(x[0]) || Float.isNaN(y[0]) || (logXAxis && x[0]<=0) || (logYAxis && y[0]<=0);
3912 for (int i=1; i<n; i++) {
3913 x1 = x2;
3914 y1 = y2;
3915 isNaN0 = isNaN1;
3916 isNaN1 = isNaN2;
3917 x2 = scaleX(x[i]);
3918 y2 = scaleY(y[i]);
3919 isNaN2 = Float.isNaN(x[i]) || Float.isNaN(y[i]) || (logXAxis && x[i]<=0) || (logYAxis && y[i]<=0);
3920 if (!isNaN1 && !isNaN2)
3921 ip.drawLine(x1, y1, x2, y2);
3922 else if (isNaN0 && !isNaN1 && isNaN2) // an isolated point
3923 ip.drawLine(x1, y1, x1, y1);
3924 }
3925 if (isNaN1 && !isNaN2)
3926 ip.drawLine(x2, y2, x2, y2); // the last (isolated) point
3927 }
3928
3929 /**
3930 * Fills space between polyline and y=0 with the current color (the secondary color of the plotObject)

Callers 1

drawPlotObjectMethod · 0.95

Calls 3

scaleXMethod · 0.95
scaleYMethod · 0.95
drawLineMethod · 0.45

Tested by

no test coverage detected