(Graphics g, int index, Roi roi)
| 486 | } |
| 487 | |
| 488 | void drawRoiLabel(Graphics g, int index, Roi roi) { |
| 489 | if (roi.isCursor()) |
| 490 | return; |
| 491 | boolean pointRoi = roi instanceof PointRoi; |
| 492 | Rectangle r = roi.getBounds(); |
| 493 | int x = screenX(r.x); |
| 494 | int y = screenY(r.y); |
| 495 | double mag = getMagnification(); |
| 496 | int width = (int)(r.width*mag); |
| 497 | int height = (int)(r.height*mag); |
| 498 | int size = width>40 || height>40?12:9; |
| 499 | int pointSize = 0; |
| 500 | int crossSize = 0; |
| 501 | if (pointRoi) { |
| 502 | pointSize = ((PointRoi)roi).getSize(); |
| 503 | switch (pointSize) { |
| 504 | case 0: case 1: size=9; break; |
| 505 | case 2: case 3: size=10; break; |
| 506 | case 4: size=12; break; |
| 507 | } |
| 508 | crossSize = pointSize + 10 + 2*pointSize; |
| 509 | } |
| 510 | if (font!=null) { |
| 511 | g.setFont(font); |
| 512 | size = font.getSize(); |
| 513 | } else if (size==12) |
| 514 | g.setFont(largeFont); |
| 515 | else |
| 516 | g.setFont(smallFont); |
| 517 | boolean drawingList = index >= LIST_OFFSET; |
| 518 | if (drawingList) index -= LIST_OFFSET; |
| 519 | String label = "" + (index+1); |
| 520 | if (drawNames) |
| 521 | label = roi.getName(); |
| 522 | if (label==null) |
| 523 | return; |
| 524 | FontMetrics metrics = g.getFontMetrics(); |
| 525 | int w = metrics.stringWidth(label); |
| 526 | x = x + width/2 - w/2; |
| 527 | y = y + height/2 + Math.max(size/2,6); |
| 528 | int h = metrics.getAscent() + metrics.getDescent(); |
| 529 | int xoffset=0, yoffset=0; |
| 530 | if (pointRoi) { |
| 531 | xoffset = 6 + pointSize; |
| 532 | yoffset = h - 6 + pointSize; |
| 533 | } |
| 534 | if (bgColor!=null) { |
| 535 | int h2 = h; |
| 536 | if (font!=null && font.getSize()>14) |
| 537 | h2 = (int)(h2*0.8); |
| 538 | g.setColor(bgColor); |
| 539 | g.fillRoundRect(x-1+xoffset, y-h2+2+yoffset, w+1, h2-2, 5, 5); |
| 540 | } |
| 541 | if (labelRects!=null && index<labelRects.length) { |
| 542 | if (pointRoi) { |
| 543 | int x2 = screenX(r.x); |
| 544 | int y2 = screenY(r.y); |
| 545 | int crossSize2 = crossSize/2; |
no test coverage detected