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

Method drawLine

ij/src/main/java/ij/gui/Line.java:115–150  ·  view source on GitHub ↗
(int sx, int sy)

Source from the content-addressed store, hash-verified

113 }
114
115 protected void drawLine(int sx, int sy) {
116 double xend = offScreenXD(sx);
117 double yend = offScreenYD(sy);
118 if (xend<0.0) xend=0.0; if (yend<0.0) yend=0.0;
119 if (xend>xMax-1) xend=xMax-1; if (yend>yMax-1) yend=yMax-1;
120 double xstart=getXBase()+x1R, ystart=getYBase()+y1R;
121 if (constrain) {
122 int i=0;
123 double dy = Math.abs(yend-ystart);
124 double dx = Math.abs(xend-xstart);
125 double comp = dy / dx;
126 for (;i<PI_SEARCH.length; i++) {
127 if(comp < PI_SEARCH[i]) {
128 break;
129 }
130 }
131 if (i < PI_SEARCH.length) {
132 if(yend > ystart) {
133 yend = ystart + dx*PI_MULT[i];
134 } else {
135 yend = ystart - dx*PI_MULT[i];
136 }
137 } else {
138 xend = xstart;
139 }
140 }
141 if (!magnificationForSubPixel() || IJ.controlKeyDown()) { //during creation, CTRL enforces integer coordinates
142 xstart=Math.round(xstart); ystart=Math.round(ystart);
143 xend=Math.round(xend); yend=Math.round(yend);
144 }
145 updateCoordinates(xstart, ystart, xend, yend);
146 updateClipRect();
147 imp.draw(clipX, clipY, clipWidth, clipHeight);
148 oldX=x; oldY=y;
149 oldWidth=width; oldHeight=height;
150 }
151
152 /** Used for angle searches in line ROI creation: tan = y/x for angle limits 1/2*45 degrees, and 3/2*45 deg */
153 private static final double[] PI_SEARCH = {Math.tan(Math.PI/8), Math.tan((3*Math.PI)/8)};

Callers 12

growMethod · 0.95
mouseMovedMethod · 0.95
drawPointMethod · 0.45
drawPlayPauseButtonMethod · 0.45
drawPlotMethod · 0.45
drawLogPlotMethod · 0.45
fill3DRectMethod · 0.45
drawIconMethod · 0.45
dMethod · 0.45
drawMethod · 0.45
fill3DRectMethod · 0.45
drawColumnLabelsMethod · 0.45

Calls 11

controlKeyDownMethod · 0.95
updateCoordinatesMethod · 0.95
getXBaseMethod · 0.80
getYBaseMethod · 0.80
updateClipRectMethod · 0.80
offScreenXDMethod · 0.45
offScreenYDMethod · 0.45
absMethod · 0.45
roundMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected