OSDN Git Service

* java/awt/Component.java (toString): Implemented.
[pf3gnuchains/gcc-fork.git] / libjava / java / awt / FontMetrics.java
1 /* Copyright (C) 2000  Free Software Foundation
2
3    This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7 details.  */
8
9 package java.awt;
10
11 /**
12  * Status:  Stubbed; A very incomplete implementation.
13  */
14
15 public class FontMetrics implements java.io.Serializable
16 {
17   protected Font font;
18   
19   protected FontMetrics(Font font)
20   {
21     this.font = font;
22   }
23
24   public Font getFont()
25   {
26     return font;
27   }
28
29   public int getLeading()
30   {
31     // FIXME??
32     return getHeight() - (getDescent() + getAscent());
33   }
34
35   public int getAscent()
36   {
37     // FIXME??
38     return getHeight() - (getDescent() + getLeading());
39   }
40
41   public int getDescent()
42   {
43     // FIXME??
44     return getHeight() - getDescent();
45   }
46
47   public int getHeight()
48   {
49     // FIXME??
50     return getLeading() + getAscent() + getDescent();
51   }
52
53   public int getMaxAscent()
54   {
55     // FIXME
56     return 0;
57   }
58
59   public int getMaxDescent()
60   {
61     // FIXME
62     return 0;
63   }
64
65   /* @deprecated Use getMaxDescent() instead. */
66   public int getMaxDecent()
67   {
68     return getMaxDescent();
69   }
70
71   public int getMaxAdvance()
72   {
73     // FIXME
74     return 0;
75   }
76
77   public int charWidth(int ch)
78   {
79     // FIXME
80     return 0;
81   }
82
83   public int charWidth(char ch)
84   {
85     // FIXME
86     return 0;
87   }
88
89   public int stringWidth(String str)
90   {
91     return charsWidth(str.toCharArray(), 0, str.length());
92   }
93
94   public int charsWidth(char[] data, int off, int len)
95   {
96     // FIXME
97     return -1;
98   }
99
100   public int bytesWidth(byte[] data, int off, int len)
101   {
102     // FIXME?
103     return -1;
104   }
105
106   public int[] getWidths()
107   {
108     // FIXME
109     return new int[0];
110   }
111
112   public boolean hasUniformLineMetrics()
113   {
114     // FIXME
115     return false;
116   }
117
118   // Don't have LineMetrics yet...
119   /*
120   public LineMetrics getLineMetrics(String str, Graphics context)
121
122   public LineMetrics getLineMetrics(String str, int beginIndex, int limit,
123                                     Graphics context)
124
125   public LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit,
126                                     Graphics context)
127
128   public LineMetrics getLineMetrics(CharacterIterator ci, int beginIndex,
129                                     int limit, Graphics context)
130   */
131
132   // Don't have Java2D yet.
133   /*
134   public Rectangle2D getStringBounds(String str, Graphics context)
135
136   public Rectangle2D getStringBounds(String str, int beginIndex, int limit,
137                                      Graphics context)
138
139   public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit,
140                                      Graphics context)
141
142   public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex,
143                                      int limit, Graphics context)
144
145   public Rectangle2D getMaxCharBounds(Graphics context)
146   */
147
148   public String toString()
149   {
150     return this.getClass() + "[font=" + font + ",ascent=" + getAscent() 
151            + ",descent=" + getDescent() + ",height=" + getHeight() + "]";
152   }
153 }