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.

Block.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright 1999-2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.area;
  18. import java.util.ArrayList;
  19. // block areas hold either more block areas or line
  20. // areas can also be used as a block spacer
  21. // a block area may have children positioned by stacking
  22. // or by relative to the parent for floats, tables and lists
  23. // cacheable object
  24. // has id information
  25. /**
  26. * This is the block area class.
  27. * It holds child block areas such as other blocks or lines.
  28. */
  29. public class Block extends BlockParent {
  30. /**
  31. * Normally stacked with other blocks.
  32. */
  33. public static final int STACK = 0;
  34. /**
  35. * Placed relative to the flow position.
  36. * This effects the flow placement of stacking normally.
  37. */
  38. public static final int RELATIVE = 1;
  39. /**
  40. * Relative to the block parent but not effecting the stacking
  41. * Used for block-container, tables and lists.
  42. */
  43. public static final int ABSOLUTE = 2;
  44. /**
  45. * Relative to a viewport/page but not effecting the stacking
  46. * Used for block-container.
  47. */
  48. public static final int FIXED = 3;
  49. private int stacking = TB;
  50. private int positioning = STACK;
  51. // a block with may contain the dominant styling info in
  52. // terms of most lines or blocks with info
  53. /**
  54. * Add the block to this block area.
  55. *
  56. * @param block the block area to add
  57. */
  58. public void addBlock(Block block) {
  59. addBlock(block, true);
  60. }
  61. /**
  62. * Add the block to this block area.
  63. *
  64. * @param block the block area to add
  65. * @param autoHeight increase the height of the block.
  66. */
  67. public void addBlock(Block block, boolean autoHeight) {
  68. if (autoHeight) {
  69. bpd += block.getAllocBPD();
  70. }
  71. addChildArea(block);
  72. }
  73. /**
  74. * Add the line area to this block area.
  75. *
  76. * @param line the line area to add
  77. */
  78. public void addLineArea(LineArea line) {
  79. bpd += line.getAllocBPD();
  80. addChildArea(line);
  81. }
  82. /**
  83. * Set the positioning of this area.
  84. *
  85. * @param pos the positioning to use when rendering this area
  86. */
  87. public void setPositioning(int pos) {
  88. positioning = pos;
  89. }
  90. /**
  91. * Get the positioning of this area.
  92. *
  93. * @return the positioning to use when rendering this area
  94. */
  95. public int getPositioning() {
  96. return positioning;
  97. }
  98. /**
  99. * @return the start-indent trait
  100. */
  101. public int getStartIndent() {
  102. Integer startIndent = (Integer)getTrait(Trait.START_INDENT);
  103. return (startIndent != null ? startIndent.intValue() : 0);
  104. }
  105. }