OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [java/] [awt/] [font/] [TextLayout.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* TextLayout.java --
2
   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package java.awt.font;
40
 
41
import gnu.java.awt.ClasspathToolkit;
42
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
43
 
44
import java.awt.Font;
45
import java.awt.Graphics2D;
46
import java.awt.Shape;
47
import java.awt.Toolkit;
48
import java.awt.geom.AffineTransform;
49
import java.awt.geom.Rectangle2D;
50
import java.text.AttributedCharacterIterator;
51
import java.text.AttributedString;
52
import java.util.Map;
53
 
54
/**
55
 * @author Michael Koch
56
 */
57
public final class TextLayout implements Cloneable
58
{
59
  public static final CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy ();
60
  ClasspathTextLayoutPeer peer;
61
 
62
  public static class CaretPolicy
63
  {
64
    public CaretPolicy ()
65
    {
66
      // Do nothing here.
67
    }
68
 
69
    public TextHitInfo getStrongCaret (TextHitInfo hit1, TextHitInfo hit2,
70
                                       TextLayout layout)
71
    {
72
      return layout.peer.getStrongCaret(hit1, hit2);
73
    }
74
  }
75
 
76
  public TextLayout (AttributedCharacterIterator text, FontRenderContext frc)
77
  {
78
    AttributedString as = new AttributedString (text);
79
    ClasspathToolkit tk = (ClasspathToolkit)(Toolkit.getDefaultToolkit ());
80
    peer = tk.getClasspathTextLayoutPeer(as, frc);
81
  }
82
 
83
  public TextLayout (String string, Font font, FontRenderContext frc)
84
  {
85
    AttributedString as = new AttributedString (string);
86
    as.addAttribute (TextAttribute.FONT, font);
87
    ClasspathToolkit tk = (ClasspathToolkit)(Toolkit.getDefaultToolkit ());
88
    peer = tk.getClasspathTextLayoutPeer(as, frc);
89
  }
90
 
91
  public TextLayout (String string, Map attributes, FontRenderContext frc)
92
  {
93
    AttributedString as = new AttributedString (string, attributes);
94
    ClasspathToolkit tk = (ClasspathToolkit)(Toolkit.getDefaultToolkit ());
95
    peer = tk.getClasspathTextLayoutPeer(as, frc);
96
  }
97
 
98
  protected Object clone ()
99
  {
100
    try
101
      {
102
        TextLayout tl = (TextLayout) super.clone ();
103
        tl.peer = (ClasspathTextLayoutPeer) this.peer.clone();
104
        return tl;
105
      }
106
    catch (CloneNotSupportedException e)
107
      {
108
        // This should never occur
109
        throw new InternalError ();
110
      }
111
  }
112
 
113
 
114
  public void draw (Graphics2D g2, float x, float y)
115
  {
116
    peer.draw(g2, x, y);
117
  }
118
 
119
  public boolean equals (Object obj)
120
  {
121
    if (! (obj instanceof TextLayout))
122
      return false;
123
 
124
    return equals ((TextLayout) obj);
125
  }
126
 
127
  public boolean equals (TextLayout tl)
128
  {
129
    return this.peer.equals(tl.peer);
130
  }
131
 
132
  public float getAdvance ()
133
  {
134
    return peer.getAdvance();
135
  }
136
 
137
  public float getAscent ()
138
  {
139
    return peer.getAscent();
140
  }
141
 
142
  public byte getBaseline ()
143
  {
144
    return peer.getBaseline();
145
  }
146
 
147
  public float[] getBaselineOffsets ()
148
  {
149
    return peer.getBaselineOffsets();
150
  }
151
 
152
  public Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint)
153
  {
154
    return peer.getBlackBoxBounds(firstEndpoint, secondEndpoint);
155
  }
156
 
157
  public Rectangle2D getBounds()
158
  {
159
    return peer.getBounds();
160
  }
161
 
162
  public float[] getCaretInfo (TextHitInfo hit)
163
  {
164
    return getCaretInfo(hit, getBounds());
165
  }
166
 
167
  public float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds)
168
  {
169
    return peer.getCaretInfo(hit, bounds);
170
  }
171
 
172
  public Shape getCaretShape (TextHitInfo hit)
173
  {
174
    return getCaretShape(hit, getBounds());
175
  }
176
 
177
  public Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds)
178
  {
179
    return peer.getCaretShape(hit, bounds);
180
  }
181
 
182
  public Shape[] getCaretShapes (int offset)
183
  {
184
    return getCaretShapes(offset, getBounds());
185
  }
186
 
187
  public Shape[] getCaretShapes (int offset, Rectangle2D bounds)
188
  {
189
    return getCaretShapes(offset, getBounds(), DEFAULT_CARET_POLICY);
190
  }
191
 
192
  public Shape[] getCaretShapes (int offset, Rectangle2D bounds,
193
                                 TextLayout.CaretPolicy policy)
194
  {
195
    return peer.getCaretShapes(offset, bounds, policy);
196
  }
197
 
198
  public int getCharacterCount ()
199
  {
200
    return peer.getCharacterCount();
201
  }
202
 
203
  public byte getCharacterLevel (int index)
204
  {
205
    return peer.getCharacterLevel(index);
206
  }
207
 
208
  public float getDescent ()
209
  {
210
    return peer.getDescent();
211
  }
212
 
213
  public TextLayout getJustifiedLayout (float justificationWidth)
214
  {
215
    return peer.getJustifiedLayout(justificationWidth);
216
  }
217
 
218
  public float getLeading ()
219
  {
220
    return peer.getLeading();
221
  }
222
 
223
  public Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint)
224
  {
225
    return getLogicalHighlightShape (firstEndpoint, secondEndpoint, getBounds());
226
  }
227
 
228
  public Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
229
                                         Rectangle2D bounds)
230
  {
231
    return peer.getLogicalHighlightShape(firstEndpoint, secondEndpoint, bounds);
232
  }
233
 
234
  public int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint,
235
                                                   TextHitInfo secondEndpoint)
236
  {
237
    return peer.getLogicalRangesForVisualSelection(firstEndpoint, secondEndpoint);
238
  }
239
 
240
  public TextHitInfo getNextLeftHit (int offset)
241
  {
242
    return getNextLeftHit(offset, DEFAULT_CARET_POLICY);
243
  }
244
 
245
  public TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy)
246
  {
247
    return peer.getNextLeftHit(offset, policy);
248
  }
249
 
250
  public TextHitInfo getNextLeftHit (TextHitInfo hit)
251
  {
252
    return getNextLeftHit(hit.getCharIndex());
253
  }
254
 
255
  public TextHitInfo getNextRightHit (int offset)
256
  {
257
    return getNextRightHit(offset, DEFAULT_CARET_POLICY);
258
  }
259
 
260
  public TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy)
261
  {
262
    return peer.getNextRightHit(offset, policy);
263
  }
264
 
265
  public TextHitInfo getNextRightHit (TextHitInfo hit)
266
  {
267
    return getNextRightHit(hit.getCharIndex());
268
  }
269
 
270
  public Shape getOutline (AffineTransform tx)
271
  {
272
    return peer.getOutline(tx);
273
  }
274
 
275
  public float getVisibleAdvance ()
276
  {
277
    return peer.getVisibleAdvance();
278
  }
279
 
280
  public Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
281
                                        TextHitInfo secondEndpoint)
282
  {
283
    return getVisualHighlightShape(firstEndpoint, secondEndpoint, getBounds());
284
  }
285
 
286
  public Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
287
                                        TextHitInfo secondEndpoint,
288
                                        Rectangle2D bounds)
289
  {
290
    return peer.getVisualHighlightShape(firstEndpoint, secondEndpoint, bounds);
291
  }
292
 
293
  public TextHitInfo getVisualOtherHit (TextHitInfo hit)
294
  {
295
    return peer.getVisualOtherHit(hit);
296
  }
297
 
298
  protected void handleJustify (float justificationWidth)
299
  {
300
    peer.handleJustify(justificationWidth);
301
  }
302
 
303
  public int hashCode ()
304
  {
305
    return peer.hashCode();
306
  }
307
 
308
  public TextHitInfo hitTestChar (float x, float y)
309
  {
310
    return hitTestChar(x, y, getBounds());
311
  }
312
 
313
  public TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds)
314
  {
315
    return peer.hitTestChar(x, y, bounds);
316
  }
317
 
318
  public boolean isLeftToRight ()
319
  {
320
    return peer.isLeftToRight();
321
  }
322
 
323
  public boolean isVertical ()
324
  {
325
    return peer.isVertical();
326
  }
327
 
328
  public String toString ()
329
  {
330
    return peer.toString();
331
  }
332
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.