KickJava   Java API By Example, From Geeks To Geeks.

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


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.GVTGlyphVector;
22
23 /**
24  * One line Class Desc
25  *
26  * Complete Class Desc
27  *
28  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
29  * @version $Id: GlyphGroupInfo.java,v 1.2 2005/03/27 08:58:34 cam Exp $
30  */

31 class GlyphGroupInfo {
32     int start, end;
33     int glyphCount, lastGlyphCount;
34     boolean hideLast;
35     float advance, lastAdvance;
36     int range;
37     GVTGlyphVector gv;
38     boolean [] hide;
39
40     public GlyphGroupInfo(GVTGlyphVector gv,
41                           int start,
42                           int end,
43                           boolean [] glyphHide,
44                           boolean glyphGroupHideLast,
45                           float [] glyphPos,
46                           float [] advAdj,
47                           float [] lastAdvAdj,
48                           boolean [] space) {
49         this.gv = gv;
50         this.start = start;
51         this.end = end;
52         this.hide = new boolean[this.end-this.start+1];
53         this.hideLast = glyphGroupHideLast;
54         System.arraycopy(glyphHide, this.start, this.hide, 0,
55                          this.hide.length);
56
57         float adv = glyphPos[2*end+2]-glyphPos[2*start];
58         float ladv = adv;
59         adv += advAdj[end];
60         int glyphCount = end-start+1;
61         for (int g=start; g<end; g++) {
62             if (glyphHide[g]) glyphCount--;
63         }
64         int lastGlyphCount = glyphCount;
65         for (int g=end; g>=start; g--) {
66             ladv += lastAdvAdj[g];
67             if (!space[g]) break;
68             lastGlyphCount--;
69         }
70         if (hideLast) lastGlyphCount--;
71
72         this.glyphCount = glyphCount;
73         this.lastGlyphCount = lastGlyphCount;
74         this.advance = adv;
75         this.lastAdvance = ladv;
76     }
77
78     /**
79      * Get the GlyphVector for this GlyphGroup.
80      */

81     public GVTGlyphVector getGlyphVector() { return gv; }
82
83     /** get the start glyph index for this glyph group. */
84     public int getStart() { return start; }
85     /** get the end glyph index for this glyph group. */
86     public int getEnd() { return end; }
87
88     /** get the number of glyphs that count when it's not the
89      * last in the line (basically end-start+1-sum(hide) ).
90      */

91     public int getGlyphCount() { return glyphCount; }
92     /** get the number of glyphs that 'cout' when it is the
93      * last in the line. This is glyphCount minus any
94      * trailing spaces, and minus the last glyph if hideLast
95      * is true.
96      */

97     public int getLastGlyphCount() { return lastGlyphCount; }
98
99     public boolean [] getHide() { return hide; }
100
101     /** return true if 'end' glyph should be hidden in cases
102      * where this is not the last glyph group in a span */

103     public boolean getHideLast() { return hideLast; }
104     /**
105      * returns the advance to use when this glyphGroup is
106      * not the last glyph group in a span.
107      */

108     public float getAdvance() { return advance; }
109     /**
110      * returns the advance to use when this glyphGroup is
111      * the last glyph group in a span. This generally includes
112      * the width of the last glyph if 'HideLast' is true. Also
113      * in Japanese some glyphs should not be counted for line
114      * width (they may go outside the flow area).
115      */

116     public float getLastAdvance() { return lastAdvance; }
117
118     public void setRange(int range) { this.range = range; }
119     public int getRange() { return this.range; }
120 }
121
122
Popular Tags