KickJava   Java API By Example, From Geeks To Geeks.

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


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: RegionSE.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-start and fo:region-end.
32  */

33 public abstract class RegionSE extends SideRegion {
34     // The value of properties relevant for fo:region-[start|end].
35
// End of property values
36

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

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

47     public void bind(PropertyList pList) throws FOPException {
48         super.bind(pList);
49     }
50
51     /**
52      * Adjust the viewport reference rectangle for a region as a function
53      * of precedence.
54      * If before and after have precedence = true, the start and end
55      * regions only go to the limits of their extents, otherwise
56      * they extend in the BPD to the page reference rectangle
57      * diminish by extend of start and end if present.
58      * @param vpRefRect viewport reference rectangle
59      * @param wm writing mode
60      * @param siblingContext the context to use to resolve extent on siblings
61      */

62     protected void adjustIPD(Rectangle JavaDoc vpRefRect, int wm, PercentBaseContext siblingContext) {
63         int offset = 0;
64         RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE);
65         if (before != null && before.getPrecedence() == EN_TRUE) {
66             offset = before.getExtent().getValue(siblingContext);
67             vpRefRect.translate(0, offset);
68         }
69         RegionAfter after = (RegionAfter) getSiblingRegion(FO_REGION_AFTER);
70         if (after != null && after.getPrecedence() == EN_TRUE) {
71             offset += after.getExtent().getValue(siblingContext);
72         }
73         if (offset > 0) {
74             if (wm == EN_LR_TB || wm == EN_RL_TB) {
75                 vpRefRect.height -= offset;
76             } else {
77                 vpRefRect.width -= offset;
78             }
79         }
80     }
81 }
82
83
Popular Tags