KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > pagination > RegionBA


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: RegionBA.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.fo.pagination;
21
22 // Java
23
import java.awt.Rectangle JavaDoc;
24
25 import org.apache.fop.apps.FOPException;
26 import org.apache.fop.datatypes.PercentBaseContext;
27 import org.apache.fop.fo.FONode;
28 import org.apache.fop.fo.PropertyList;
29
30 /**
31  * Abstract base class for fo:region-before and fo:region-after.
32  */

33 public abstract class RegionBA extends SideRegion {
34     // The value of properties relevant for fo:region-[before|after].
35
private int precedence;
36     // End of property values
37

38     /**
39      * @see org.apache.fop.fo.FONode#FONode(FONode)
40      */

41     protected RegionBA(FONode parent) {
42         super(parent);
43     }
44
45     /**
46      * @see org.apache.fop.fo.FObj#bind(PropertyList)
47      */

48     public void bind(PropertyList pList) throws FOPException {
49         super.bind(pList);
50         precedence = pList.get(PR_PRECEDENCE).getEnum();
51     }
52
53     /**
54      * @return the "precedence" property.
55      */

56     public int getPrecedence() {
57         return precedence;
58     }
59
60     /**
61      * Adjust the viewport reference rectangle for a region as a function
62      * of precedence.
63      * If precedence is false on a before or after region, its
64      * inline-progression-dimension is limited by the extent of the start
65      * and end regions if they are present.
66      * @param vpRefRect viewport reference rectangle
67      * @param wm writing mode
68      * @param siblingContext the context to use to resolve extent on siblings
69      */

70     protected void adjustIPD(Rectangle JavaDoc vpRefRect, int wm, PercentBaseContext siblingContext) {
71         int offset = 0;
72         RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START);
73         if (start != null) {
74             offset = start.getExtent().getValue(siblingContext);
75             vpRefRect.translate(offset, 0); // move (x, y) units
76
}
77         RegionEnd end = (RegionEnd) getSiblingRegion(FO_REGION_END);
78         if (end != null) {
79             offset += end.getExtent().getValue(siblingContext);
80         }
81         if (offset > 0) {
82             if (wm == EN_LR_TB || wm == EN_RL_TB) {
83                 vpRefRect.width -= offset;
84             } else {
85                 vpRefRect.height -= offset;
86             }
87         }
88     }
89 }
90
91
Popular Tags