KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > font > GVTGlyphMetrics


1 /*
2
3    Copyright 2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt.font;
19
20 import java.awt.font.GlyphMetrics JavaDoc;
21 import java.awt.geom.Rectangle2D JavaDoc;
22
23 /**
24  * GVTGlyphMetrics is essentially a wrapper class for java.awt.font.GlyphMetrics
25  * with the addition of horizontal and vertical advance values.
26  *
27  * @author <a HREF="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
28  * @version $Id: GVTGlyphMetrics.java,v 1.6 2004/08/18 07:14:35 vhardy Exp $
29  */

30 public class GVTGlyphMetrics {
31
32     private GlyphMetrics JavaDoc gm;
33     private float verticalAdvance;
34
35     /**
36      * Constructs a new GVTGlyphMetrics object based upon the specified
37      * GlyphMetrics object and an additional vertical advance value.
38      *
39      * @param gm The glyph metrics.
40      * @param verticalAdvance The vertical advance of the glyph.
41      */

42     public GVTGlyphMetrics(GlyphMetrics JavaDoc gm, float verticalAdvance) {
43         this.gm = gm;
44         this.verticalAdvance = verticalAdvance;
45     }
46
47     /**
48      * Constructs a new GVTGlyphMetrics object using the specified parameters.
49      *
50      * @param horizontalAdvance The horizontal advance of the glyph.
51      * @param verticalAdvance The vertical advance of the glyph.
52      * @param bounds The black box bounds of the glyph.
53      * @param glyphType The type of the glyph.
54      */

55     public GVTGlyphMetrics(float horizontalAdvance,
56                            float verticalAdvance,
57                            Rectangle2D JavaDoc bounds,
58                            byte glyphType) {
59         this.gm = new GlyphMetrics JavaDoc(horizontalAdvance, bounds, glyphType);
60         this.verticalAdvance = verticalAdvance;
61     }
62
63     /**
64      * Returns the horizontal advance of the glyph.
65      */

66     public float getHorizontalAdvance() {
67         return gm.getAdvance();
68     }
69
70     /**
71      * Returns the vertical advance of the glyph.
72      */

73     public float getVerticalAdvance() {
74         return verticalAdvance;
75     }
76
77     /**
78      * Returns the black box bounds of the glyph.
79      */

80     public Rectangle2D JavaDoc getBounds2D() {
81         return gm.getBounds2D();
82     }
83
84     /**
85      * Returns the left (top) side bearing of the glyph.
86      */

87     public float getLSB() {
88         return gm.getLSB();
89     }
90
91     /**
92      * Returns the right (bottom) side bearing of the glyph.
93      */

94     public float getRSB() {
95         return gm.getRSB();
96     }
97
98     /**
99      * Returns the raw glyph type code.
100      */

101     public int getType() {
102         return gm.getType();
103     }
104
105     /**
106      * Returns true if this is a combining glyph.
107      */

108     public boolean isCombining() {
109         return gm.isCombining();
110     }
111
112     /**
113      * Returns true if this is a component glyph.
114      */

115     public boolean isComponent() {
116         return gm.isComponent();
117     }
118
119     /**
120      * Returns true if this is a ligature glyph.
121      */

122     public boolean isLigature() {
123         return gm.isLigature();
124     }
125
126     /**
127      * Returns true if this is a standard glyph.
128      */

129     public boolean isStandard() {
130         return gm.isStandard();
131     }
132
133     /**
134      * Returns true if this is a whitespace glyph.
135      */

136     public boolean isWhitespace() {
137         return gm.isWhitespace();
138     }
139
140 }
141
Popular Tags