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.

BlockParent.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.area;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. /**
  22. * A BlockParent holds block-level areas.
  23. */
  24. public class BlockParent extends Area {
  25. /**
  26. *
  27. */
  28. private static final long serialVersionUID = 7076916890348533805L;
  29. // this position is used for absolute position
  30. // or as an indent
  31. // this has the size in the block progression dimension
  32. /**
  33. * The x offset position of this block parent.
  34. * Used for relative (serves as left-offset trait) and absolute positioning
  35. * (serves as left-position trait).
  36. */
  37. protected int xOffset = 0;
  38. /**
  39. * The y offset position of this block parent.
  40. * Used for relative (serves as top-offset trait) and absolute positioning
  41. * (serves as top-position trait).
  42. */
  43. protected int yOffset = 0;
  44. /**
  45. * The children of this block parent area.
  46. */
  47. protected List children = null;
  48. // orientation if reference area
  49. // private int orientation = ORIENT_0;
  50. /** {@inheritDoc} */
  51. public void addChildArea(Area childArea) {
  52. if (children == null) {
  53. children = new ArrayList();
  54. }
  55. children.add(childArea);
  56. }
  57. /**
  58. * Add the block area to this block parent.
  59. *
  60. * @param block the child block area to add
  61. */
  62. public void addBlock(Block block) {
  63. addChildArea(block);
  64. }
  65. /**
  66. * Get the list of child areas for this block area.
  67. *
  68. * @return the list of child areas
  69. */
  70. public List getChildAreas() {
  71. return children;
  72. }
  73. /**
  74. * Check whether there are child areas.
  75. *
  76. * @return the result.
  77. */
  78. public boolean isEmpty() {
  79. return children == null || children.size() == 0;
  80. }
  81. /**
  82. * Set the X offset of this block parent area.
  83. *
  84. * @param off the x offset of the block parent area
  85. */
  86. public void setXOffset(int off) {
  87. xOffset = off;
  88. }
  89. /**
  90. * Set the Y offset of this block parent area.
  91. *
  92. * @param off the y offset of the block parent area
  93. */
  94. public void setYOffset(int off) {
  95. yOffset = off;
  96. }
  97. /**
  98. * Get the X offset of this block parent area.
  99. *
  100. * @return the x offset of the block parent area
  101. */
  102. public int getXOffset() {
  103. return xOffset;
  104. }
  105. /**
  106. * Get the Y offset of this block parent area.
  107. *
  108. * @return the y offset of the block parent area
  109. */
  110. public int getYOffset() {
  111. return yOffset;
  112. }
  113. }