KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > flow > WordInfo


1 /*
2
3    Copyright 2004 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
19 package org.apache.batik.gvt.flow;
20
21 import org.apache.batik.gvt.font.GVTFont;
22 import org.apache.batik.gvt.font.GVTLineMetrics;
23
24 /**
25  * One line Class Desc
26  *
27  * Complete Class Desc
28  *
29  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
30  * @version $Id: WordInfo.java,v 1.2 2005/03/27 08:58:34 cam Exp $
31  */

32 class WordInfo {
33     int index = -1;
34     float ascent=-1, descent=-1, lineHeight=-1;
35     GlyphGroupInfo [] glyphGroups=null;
36     Object JavaDoc flowLine=null;
37
38     WordInfo(int index) {
39         this.index = index;
40     }
41
42     WordInfo(int index,
43              float ascent, float descent, float lineHeight,
44              GlyphGroupInfo [] glyphGroups) {
45         this.index = index;
46         this.ascent = ascent;
47         this.descent = descent;
48         this.lineHeight = lineHeight;
49         this.glyphGroups = glyphGroups;
50     }
51
52     public int getIndex() { return index; }
53
54     public float getAscent() { return ascent; }
55     public void setAscent(float ascent) { this.ascent = ascent; }
56
57     public float getDescent() { return descent; }
58     public void setDescent(float descent) { this.descent = descent; }
59
60     public void addLineMetrics(GVTFont font, GVTLineMetrics lm) {
61         if (ascent < lm.getAscent())
62             ascent = lm.getAscent();
63         if (descent < lm.getDescent())
64             descent = lm.getDescent();
65     }
66
67
68     public float getLineHeight() { return this.lineHeight; }
69     public void setLineHeight(float lineHeight) {
70         this.lineHeight = lineHeight; }
71     public void addLineHeight(float lineHeight) {
72         if (this.lineHeight < lineHeight)
73             this.lineHeight = lineHeight;
74     }
75
76     public Object JavaDoc getFlowLine() { return this.flowLine; }
77     public void setFlowLine(Object JavaDoc fl) { this.flowLine = fl; }
78
79     public int getNumGlyphGroups() {
80         if (glyphGroups == null)
81             return -1;
82         return glyphGroups.length;
83     }
84     public void setGlyphGroups(GlyphGroupInfo []glyphGroups) {
85         this.glyphGroups = glyphGroups;
86     }
87     public GlyphGroupInfo getGlyphGroup(int idx) {
88         if (glyphGroups == null) return null;
89         return glyphGroups[idx];
90     }
91 }
92
Popular Tags