Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

BlockParent.java 3.1KB

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