1 |
/* FontMetrics.java -- Information about about a fonts display characteristics |
/* FontMetrics.java -- Information about about a fonts display characteristics |
2 |
Copyright (C) 1999, 2002 Free Software Foundation, Inc. |
Copyright (C) 1999, 2002, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
40 |
|
|
41 |
import java.awt.font.FontRenderContext; |
import java.awt.font.FontRenderContext; |
42 |
import java.awt.font.LineMetrics; |
import java.awt.font.LineMetrics; |
43 |
|
import java.awt.geom.Rectangle2D; |
44 |
import java.text.CharacterIterator; |
import java.text.CharacterIterator; |
45 |
|
|
46 |
// FIXME: I leave many methods basically unimplemented. This |
// FIXME: I leave many methods basically unimplemented. This |
461 |
rc = gRC; |
rc = gRC; |
462 |
return font.getLineMetrics(ci, begin, limit, rc); |
return font.getLineMetrics(ci, begin, limit, rc); |
463 |
} |
} |
464 |
|
|
465 |
|
public Rectangle2D getStringBounds(String str, Graphics context) |
466 |
|
{ |
467 |
|
return font.getStringBounds(str, getFontRenderContext(context)); |
468 |
|
} |
469 |
|
|
470 |
|
public Rectangle2D getStringBounds(String str, int beginIndex, int limit, Graphics context) |
471 |
|
{ |
472 |
|
return font.getStringBounds(str, beginIndex, limit, getFontRenderContext(context)); |
473 |
|
} |
474 |
|
|
475 |
|
public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, Graphics context) |
476 |
|
{ |
477 |
|
return font.getStringBounds(chars, beginIndex, limit, getFontRenderContext(context)); |
478 |
|
} |
479 |
|
|
480 |
|
public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex, int limit, Graphics context) |
481 |
|
{ |
482 |
|
return font.getStringBounds(ci, beginIndex, limit, getFontRenderContext(context)); |
483 |
|
} |
484 |
|
|
485 |
|
private FontRenderContext getFontRenderContext(Graphics context) |
486 |
|
{ |
487 |
|
if (context instanceof Graphics2D) |
488 |
|
return ((Graphics2D) context).getFontRenderContext(); |
489 |
|
|
490 |
|
throw new UnsupportedOperationException("not implemented for Graphics contexts"); |
491 |
|
} |
492 |
} |
} |