KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > traits > LayoutProps


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: LayoutProps.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.traits;
21
22 import org.apache.fop.datatypes.KeepValue;
23 import org.apache.fop.fo.Constants;
24
25 /**
26  * Store properties affecting layout: break-before, break-after, keeps, span.
27  * for a block level FO.
28  * Public "structure" allows direct member access.
29  */

30 public class LayoutProps {
31
32     public int breakBefore; // enum constant BreakBefore.xxx
33
public int breakAfter; // enum constant BreakAfter.xxx
34
public KeepValue keepWithPrevious; /*LF*/
35     public KeepValue keepWithNext; /*LF*/
36     public KeepValue keepTogether; /*LF*/
37     public int orphans; /*LF*/
38     public int widows; /*LF*/
39     public int blockProgressionUnit; /*LF*/
40     public int lineStackingStrategy; /*LF*/
41     public boolean bIsSpan;
42     public SpaceVal spaceBefore;
43     public SpaceVal spaceAfter;
44
45     private static final int[] BREAK_PRIORITIES =
46         new int[]{ Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE };
47
48
49     public LayoutProps() {
50         breakBefore = breakAfter = Constants.EN_AUTO;
51         bIsSpan = false;
52     }
53
54     // public static int higherBreak(int brkParent, int brkChild) {
55
// if (brkParent == brkChild) return brkChild;
56
// for (int i=0; i < s_breakPriorities.length; i++) {
57
// int bp = s_breakPriorities[i];
58
// if (bp == brkParent) return brkChild;
59
// else if (bp == brkChild) return brkParent;
60
// }
61
// return brkChild;
62
// }
63

64     public void combineWithParent(LayoutProps parentLP) {
65         if (parentLP.breakBefore != breakBefore) {
66             for (int i = 0; i < BREAK_PRIORITIES.length; i++) {
67                 int bp = BREAK_PRIORITIES[i];
68                 if (bp == breakBefore) {
69                     breakBefore = parentLP.breakBefore;
70                     break;
71                 } else if (bp == parentLP.breakBefore) {
72                     break;
73                 }
74             }
75         }
76         // Parent span always overrides child span
77
bIsSpan = parentLP.bIsSpan;
78     }
79
80     public String JavaDoc toString() {
81         return "LayoutProps:\n" +
82         "breakBefore = " + breakBefore + "; breakAfter = " + breakAfter + "\n" +
83         "spaceBefore = " + ((spaceBefore != null) ? spaceBefore.toString() : "null") + "\n" +
84         "spaceAfter = " + ((spaceAfter != null) ? spaceAfter.toString() : "null") + "\n" +
85         "bIsSpan = " + bIsSpan + "\n";
86     }
87 }
88
89
Popular Tags