Draws this line on the image.
(Graphics g)
| 379 | |
| 380 | /** Draws this line on the image. */ |
| 381 | public void draw(Graphics g) { |
| 382 | Color color = strokeColor!=null? strokeColor:ROIColor; |
| 383 | boolean isActiveOverlayRoi = !overlay && isActiveOverlayRoi(); |
| 384 | mag = getMagnification(); |
| 385 | if (isActiveOverlayRoi) { |
| 386 | if (color==Color.cyan) |
| 387 | color = Color.magenta; |
| 388 | else |
| 389 | color = Color.cyan; |
| 390 | } |
| 391 | g.setColor(color); |
| 392 | x1d=getXBase()+x1R; y1d=getYBase()+y1R; x2d=getXBase()+x2R; y2d=getYBase()+y2R; |
| 393 | x1=(int)x1d; y1=(int)y1d; x2=(int)x2d; y2=(int)y2d; |
| 394 | int sx1 = screenXD(x1d); |
| 395 | int sy1 = screenYD(y1d); |
| 396 | int sx2 = screenXD(x2d); |
| 397 | int sy2 = screenYD(y2d); |
| 398 | int sx3 = sx1 + (sx2-sx1)/2; |
| 399 | int sy3 = sy1 + (sy2-sy1)/2; |
| 400 | Graphics2D g2d = (Graphics2D)g; |
| 401 | setRenderingHint(g2d); |
| 402 | boolean cbar = overlay && mag<1.0 && Math.abs(getStrokeWidth()-CalibrationBar.STROKE_WIDTH)<0.0001; |
| 403 | if (stroke!=null && !isActiveOverlayRoi && !cbar) |
| 404 | g2d.setStroke(getScaledStroke()); |
| 405 | else if (cbar) |
| 406 | g2d.setStroke(onePixelWide); |
| 407 | if (wideLine && !isActiveOverlayRoi && !cbar) { |
| 408 | double dx = sx2 - sx1; |
| 409 | double dy = sy2 - sy1; |
| 410 | double len = length(dx, dy); |
| 411 | dx *= 0.5*mag/len; //half-pixel extension, corresponding to getFloatPolygon or convertLineToArea |
| 412 | dy *= 0.5*mag/len; |
| 413 | g2d.draw(new Line2D.Double(sx1-dx, sy1-dy, sx2+dx, sy2+dy)); |
| 414 | } else |
| 415 | g.drawLine(sx1, sy1, sx2, sy2); |
| 416 | if (wideLine && !overlay) { |
| 417 | g2d.setStroke(onePixelWide); |
| 418 | g.setColor(getColor()); |
| 419 | g.drawLine(sx1, sy1, sx2, sy2); |
| 420 | } |
| 421 | if (!overlay) { |
| 422 | handleColor = strokeColor!=null?strokeColor:ROIColor; |
| 423 | drawHandle(g, sx1, sy1); |
| 424 | handleColor=Color.white; |
| 425 | drawHandle(g, sx2, sy2); |
| 426 | drawHandle(g, sx3, sy3); |
| 427 | } |
| 428 | if (state!=NORMAL) |
| 429 | showStatus(); |
| 430 | if (updateFullWindow) |
| 431 | {updateFullWindow = false; imp.draw();} |
| 432 | } |
| 433 | |
| 434 | public void showStatus() { |
| 435 | IJ.showStatus(imp.getLocationAsString((int)Math.round(x2d),(int)Math.round(y2d))+ |
no test coverage detected