(Graphics g)
| 279 | } |
| 280 | |
| 281 | void drawText(Graphics g) { |
| 282 | g.setColor( strokeColor!=null? strokeColor:ROIColor); |
| 283 | Java2.setAntialiasedText(g, getAntiAlias()); |
| 284 | double mag = getMagnification(); |
| 285 | int xi = (int)Math.round(getXBase()); |
| 286 | int yi = (int)Math.round(getYBase()); |
| 287 | double widthd = bounds!=null?bounds.width:this.width; |
| 288 | double heightd = bounds!=null?bounds.height:this.height; |
| 289 | int widthi = (int)Math.round(widthd); |
| 290 | int heighti = (int)Math.round(heightd); |
| 291 | Font font = getScaledFont(); |
| 292 | FontMetrics metrics = g.getFontMetrics(font); |
| 293 | int fontHeight = metrics.getHeight(); |
| 294 | int descent = metrics.getDescent(); |
| 295 | g.setFont(font); |
| 296 | Graphics2D g2d = (Graphics2D)g; |
| 297 | int sx = nonScalable?xi:screenXD(getXBase()); |
| 298 | int sy = nonScalable?yi:screenYD(getYBase()); |
| 299 | int sw = nonScalable?widthi:(int)(getMagnification()*widthd); |
| 300 | int sh = nonScalable?heighti:(int)(getMagnification()*heightd); |
| 301 | AffineTransform at = null; |
| 302 | if (angle!=0.0) { |
| 303 | at = g2d.getTransform(); |
| 304 | double cx=sx, cy=sy; |
| 305 | double theta = Math.toRadians(angle); |
| 306 | g2d.rotate(-theta, cx, cy); |
| 307 | } |
| 308 | int i = 0; |
| 309 | if (fillColor!=null) { |
| 310 | Color c = g.getColor(); |
| 311 | int alpha = fillColor.getAlpha(); |
| 312 | g.setColor(fillColor); |
| 313 | g.fillRect(sx, sy, sw, sh); |
| 314 | g.setColor(c); |
| 315 | } |
| 316 | while (i<MAX_LINES && theText[i]!=null) { |
| 317 | switch (justification) { |
| 318 | case LEFT: |
| 319 | g.drawString(theText[i], sx, sy+fontHeight-descent); |
| 320 | break; |
| 321 | case CENTER: |
| 322 | int tw = metrics.stringWidth(theText[i]); |
| 323 | g.drawString(theText[i], sx+(sw-tw)/2, sy+fontHeight-descent); |
| 324 | break; |
| 325 | case RIGHT: |
| 326 | tw = metrics.stringWidth(theText[i]); |
| 327 | g.drawString(theText[i], sx+sw-tw, sy+fontHeight-descent); |
| 328 | break; |
| 329 | } |
| 330 | i++; |
| 331 | sy += fontHeight; |
| 332 | } |
| 333 | if (at!=null) // restore transformation matrix used to rotate text |
| 334 | g2d.setTransform(at); |
| 335 | } |
| 336 | |
| 337 | /** Returns the name of the default font. Use getCurrentFont().getName() |
| 338 | to get the name of the font that this TextRoi is using. */ |
no test coverage detected