01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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 = new int[] {
46: Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE };
47:
48: public LayoutProps() {
49: breakBefore = breakAfter = Constants.EN_AUTO;
50: bIsSpan = false;
51: }
52:
53: // public static int higherBreak(int brkParent, int brkChild) {
54: // if (brkParent == brkChild) return brkChild;
55: // for (int i=0; i < s_breakPriorities.length; i++) {
56: // int bp = s_breakPriorities[i];
57: // if (bp == brkParent) return brkChild;
58: // else if (bp == brkChild) return brkParent;
59: // }
60: // return brkChild;
61: // }
62:
63: public void combineWithParent(LayoutProps parentLP) {
64: if (parentLP.breakBefore != breakBefore) {
65: for (int i = 0; i < BREAK_PRIORITIES.length; i++) {
66: int bp = BREAK_PRIORITIES[i];
67: if (bp == breakBefore) {
68: breakBefore = parentLP.breakBefore;
69: break;
70: } else if (bp == parentLP.breakBefore) {
71: break;
72: }
73: }
74: }
75: // Parent span always overrides child span
76: bIsSpan = parentLP.bIsSpan;
77: }
78:
79: public String toString() {
80: return "LayoutProps:\n"
81: + "breakBefore = "
82: + breakBefore
83: + "; breakAfter = "
84: + breakAfter
85: + "\n"
86: + "spaceBefore = "
87: + ((spaceBefore != null) ? spaceBefore.toString()
88: : "null")
89: + "\n"
90: + "spaceAfter = "
91: + ((spaceAfter != null) ? spaceAfter.toString()
92: : "null") + "\n" + "bIsSpan = " + bIsSpan
93: + "\n";
94: }
95: }
|