(int sx, int sy)
| 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)}; |
no test coverage detected