(int sx, int sy)
| 1169 | } |
| 1170 | |
| 1171 | void move(int sx, int sy) { |
| 1172 | if (constrain) { // constrain translation in 90deg steps |
| 1173 | int dx = sx - previousSX; |
| 1174 | int dy = sy - previousSY; |
| 1175 | if (Math.abs(dx) > Math.abs(dy)) |
| 1176 | dy = 0; |
| 1177 | else |
| 1178 | dx = 0; |
| 1179 | sx = previousSX + dx; |
| 1180 | sy = previousSY + dy; |
| 1181 | } |
| 1182 | int xNew = ic.offScreenX(sx); |
| 1183 | int yNew = ic.offScreenY(sy); |
| 1184 | int dx = xNew - startX; |
| 1185 | int dy = yNew - startY; |
| 1186 | if (dx==0 && dy==0) |
| 1187 | return; |
| 1188 | x += dx; |
| 1189 | y += dy; |
| 1190 | if (bounds!=null) |
| 1191 | setLocation(bounds.x + dx, bounds.y + dy); |
| 1192 | boolean isImageRoi = this instanceof ImageRoi; |
| 1193 | if (clipboard==null && type==RECTANGLE && !isImageRoi) { |
| 1194 | if (x<0) x=0; if (y<0) y=0; |
| 1195 | if ((x+width)>xMax) x = xMax-width; |
| 1196 | if ((y+height)>yMax) y = yMax-height; |
| 1197 | } |
| 1198 | startX = xNew; |
| 1199 | startY = yNew; |
| 1200 | if (type==POINT || ((this instanceof TextRoi) && ((TextRoi)this).getAngle()!=0.0)) |
| 1201 | ignoreClipRect = true; |
| 1202 | updateClipRect(); |
| 1203 | if ((lineWidth>1 && isLine()) || ignoreClipRect || ((this instanceof PolygonRoi)&&((PolygonRoi)this).isSplineFit())) |
| 1204 | imp.draw(); |
| 1205 | else |
| 1206 | imp.draw(clipX, clipY, clipWidth, clipHeight); |
| 1207 | oldX = x; |
| 1208 | oldY = y; |
| 1209 | oldWidth = width; |
| 1210 | oldHeight=height; |
| 1211 | if (isImageRoi) showStatus(); |
| 1212 | } |
| 1213 | |
| 1214 | /** Nudge ROI one pixel on arrow key press. */ |
| 1215 | public void nudge(int key) { |
no test coverage detected