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 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.area;
  8. import java.io.Serializable;
  9. import java.util.ArrayList;
  10. // block areas hold either more block areas or line
  11. // areas can also be used as a block spacer
  12. // a block area may have children positioned by stacking
  13. // or by relative to the parent for floats, tables and lists
  14. // cacheable object
  15. // has id information
  16. /**
  17. * This is the block area class.
  18. * It holds child block areas such as other blocks or lines.
  19. */
  20. public class Block extends BlockParent implements Serializable {
  21. /**
  22. * Normally stacked with other blocks.
  23. */
  24. public static final int STACK = 0;
  25. /**
  26. * Placed relative to the flow position.
  27. * This effects the flow placement of stacking normally.
  28. */
  29. public static final int RELATIVE = 1;
  30. /**
  31. * Relative to the block parent but not effecting the stacking
  32. * Used for block-container, tables and lists.
  33. */
  34. public static final int ABSOLUTE = 2;
  35. private int stacking = TB;
  36. private int positioning = STACK;
  37. // a block with may contain the dominant styling info in
  38. // terms of most lines or blocks with info
  39. /**
  40. * Add the block to this block area.
  41. *
  42. * @param block the block area to add
  43. */
  44. public void addBlock(Block block) {
  45. if (children == null) {
  46. children = new ArrayList();
  47. }
  48. height += block.getHeight();
  49. children.add(block);
  50. }
  51. /**
  52. * Add the line area to this block area.
  53. *
  54. * @param line the line area to add
  55. */
  56. public void addLineArea(LineArea line) {
  57. if (children == null) {
  58. children = new ArrayList();
  59. }
  60. height += line.getHeight();
  61. children.add(line);
  62. }
  63. /**
  64. * Set the positioning of this area.
  65. *
  66. * @param pos the positioning to use when rendering this area
  67. */
  68. public void setPositioning(int pos) {
  69. positioning = pos;
  70. }
  71. /**
  72. * Get the positioning of this area.
  73. *
  74. * @return the positioning to use when rendering this area
  75. */
  76. public int getPositioning() {
  77. return positioning;
  78. }
  79. }