You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LayoutProps.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /* $Id$ */
  18. package org.apache.fop.traits;
  19. import org.apache.fop.datatypes.KeepValue;
  20. import org.apache.fop.fo.Constants;
  21. /**
  22. * Store properties affecting layout: break-before, break-after, keeps, span.
  23. * for a block level FO.
  24. * Public "structure" allows direct member access.
  25. */
  26. public class LayoutProps {
  27. public int breakBefore; // enum constant BreakBefore.xxx
  28. public int breakAfter; // enum constant BreakAfter.xxx
  29. public KeepValue keepWithPrevious; /*LF*/
  30. public KeepValue keepWithNext; /*LF*/
  31. public KeepValue keepTogether; /*LF*/
  32. public int orphans; /*LF*/
  33. public int widows; /*LF*/
  34. public int blockProgressionUnit; /*LF*/
  35. public int lineStackingStrategy; /*LF*/
  36. public boolean bIsSpan;
  37. public SpaceVal spaceBefore;
  38. public SpaceVal spaceAfter;
  39. private static final int[] BREAK_PRIORITIES =
  40. new int[]{ Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE };
  41. public LayoutProps() {
  42. breakBefore = breakAfter = Constants.EN_AUTO;
  43. bIsSpan = false;
  44. }
  45. // public static int higherBreak(int brkParent, int brkChild) {
  46. // if (brkParent == brkChild) return brkChild;
  47. // for (int i=0; i < s_breakPriorities.length; i++) {
  48. // int bp = s_breakPriorities[i];
  49. // if (bp == brkParent) return brkChild;
  50. // else if (bp == brkChild) return brkParent;
  51. // }
  52. // return brkChild;
  53. // }
  54. public void combineWithParent(LayoutProps parentLP) {
  55. if (parentLP.breakBefore != breakBefore) {
  56. for (int i = 0; i < BREAK_PRIORITIES.length; i++) {
  57. int bp = BREAK_PRIORITIES[i];
  58. if (bp == breakBefore) {
  59. breakBefore = parentLP.breakBefore;
  60. break;
  61. } else if (bp == parentLP.breakBefore) {
  62. break;
  63. }
  64. }
  65. }
  66. // Parent span always overrides child span
  67. bIsSpan = parentLP.bIsSpan;
  68. }
  69. public String toString() {
  70. return "LayoutProps:\n" +
  71. "breakBefore = " + breakBefore + "; breakAfter = " + breakAfter + "\n" +
  72. "spaceBefore = " + ((spaceBefore != null) ? spaceBefore.toString() : "null") + "\n" +
  73. "spaceAfter = " + ((spaceAfter != null) ? spaceAfter.toString() : "null") + "\n" +
  74. "bIsSpan = " + bIsSpan + "\n";
  75. }
  76. }