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

Method drawArrow

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

Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead @deprecated Use as a public method is not supported any more because it is incompatible with rescaling

(int x1, int y1, int x2, int y2, double size)

Source from the content-addressed store, hash-verified

3857 /** Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead
3858 * @deprecated Use as a public method is not supported any more because it is incompatible with rescaling */
3859 @Deprecated
3860 public void drawArrow(int x1, int y1, int x2, int y2, double size) {
3861 double dx = x2 - x1;
3862 double dy = y2 - y1;
3863 double ra = Math.sqrt(dx * dx + dy * dy);
3864 dx /= ra;
3865 dy /= ra;
3866 int x3 = (int) Math.round(x2 - dx * size); //arrow base
3867 int y3 = (int) Math.round(y2 - dy * size);
3868 double r = 0.3 * size;
3869 int x4 = (int) Math.round(x3 + dy * r);
3870 int y4 = (int) Math.round(y3 - dx * r);
3871 int x5 = (int) Math.round(x3 - dy * r);
3872 int y5 = (int) Math.round(y3 + dx * r);
3873 ip.moveTo(x1, y1); ip.lineTo(x2, y2);
3874 ip.moveTo(x4, y4); ip.lineTo(x2, y2); ip.lineTo(x5, y5);
3875 }
3876
3877 private void drawVerticalErrorBars(float[] x, float[] y, float[] e) {
3878 int nPoints = Math.min(Math.min(x.length, y.length), e.length);

Callers 1

drawPlotObjectMethod · 0.95

Calls 4

sqrtMethod · 0.45
roundMethod · 0.45
moveToMethod · 0.45
lineToMethod · 0.45

Tested by

no test coverage detected