KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutmgr > inline > HyphContext


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 /* $Id: HyphContext.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.layoutmgr.inline;
21
22 /**
23  * This class is used to pass information to the getNextBreakPoss()
24  * method concerning hyphenation. A reference to an instance of the
25  * class is contained in the LayoutContext object passed to each
26  * LayoutManager. It contains information concerning the hyphenation
27  * points in a word and the how many of those have previously been
28  * processed by a Layout Manager to generate size information.
29  */

30 public class HyphContext {
31     private int[] hyphPoints;
32     private int currentOffset = 0;
33     private int currentIndex = 0;
34
35     public HyphContext(int[] hyphPoints) {
36         this.hyphPoints = hyphPoints;
37     }
38
39     public int getNextHyphPoint() {
40         for (; currentIndex < hyphPoints.length; currentIndex++) {
41             if (hyphPoints[currentIndex] > currentOffset) {
42                 return (hyphPoints[currentIndex] - currentOffset);
43             }
44         }
45         return -1; // AT END!
46
}
47
48     public boolean hasMoreHyphPoints() {
49         for (; currentIndex < hyphPoints.length; currentIndex++) {
50             if (hyphPoints[currentIndex] > currentOffset) {
51                 return true;
52             }
53         }
54         return false;
55     }
56
57     public void updateOffset(int iCharsProcessed) {
58         currentOffset += iCharsProcessed;
59     }
60 }
61
Popular Tags