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.2KB

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