author | berghofe |
Tue, 16 Oct 2001 16:48:30 +0200 | |
changeset 11799 | 533a95523f61 |
child 11810 | 4768258b29a5 |
permissions | -rw-r--r-- |
11799
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
1 |
/*************************************************************************** |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
2 |
Title: GraphBrowser/DefaultFontMetrics.java |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
3 |
ID: $Id$ |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
4 |
Author: Stefan Berghofer, TU Muenchen |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
5 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
6 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
7 |
Default font metrics which is used when no graphics context |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
8 |
is available. |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
9 |
***************************************************************************/ |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
10 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
11 |
package GraphBrowser; |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
12 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
13 |
import java.awt.*; |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
14 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
15 |
public class DefaultFontMetrics extends FontMetrics |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
16 |
{ |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
17 |
public DefaultFontMetrics(Font f) |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
18 |
{ super(f); } |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
19 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
20 |
// note : values are rather inaccurate ! |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
21 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
22 |
public int getLeading() |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
23 |
{ return 1; } |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
24 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
25 |
public int getAscent() |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
26 |
{ return (int)(Math.round(font.getSize()*5.0/6.0)); } |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
27 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
28 |
public int getDescent() |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
29 |
{ return (int)(Math.round(font.getSize()/6.0)); } |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
30 |
|
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
31 |
public int stringWidth(String s) |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
32 |
{ return (int)(Math.round(s.length()*font.getSize()/2.0)); } |
533a95523f61
Font metrics used for batch mode layout (without X11 connection).
berghofe
parents:
diff
changeset
|
33 |
} |