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.

SpanArea.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 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.layout;
  8. // FOP
  9. import org.apache.fop.render.Renderer;
  10. import org.apache.fop.fo.properties.Position;
  11. import org.apache.fop.datatypes.IDReferences;
  12. // Java
  13. import java.util.Vector;
  14. import java.util.Enumeration;
  15. public class SpanArea extends AreaContainer {
  16. private int columnCount;
  17. private int currentColumn = 1;
  18. private int columnGap = 0;
  19. // has the area been balanced?
  20. private boolean isBalanced = false;
  21. public SpanArea(FontState fontState, int xPosition, int yPosition,
  22. int allocationWidth, int maxHeight, int columnCount,
  23. int columnGap) {
  24. super(fontState, xPosition, yPosition, allocationWidth, maxHeight,
  25. Position.ABSOLUTE);
  26. this.contentRectangleWidth = allocationWidth;
  27. this.columnCount = columnCount;
  28. this.columnGap = columnGap;
  29. int columnWidth = (allocationWidth - columnGap * (columnCount - 1))
  30. / columnCount;
  31. for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
  32. int colXPosition = (xPosition
  33. + columnIndex * (columnWidth + columnGap));
  34. int colYPosition = yPosition;
  35. ColumnArea colArea = new ColumnArea(fontState, colXPosition,
  36. colYPosition, columnWidth,
  37. maxHeight, columnCount);
  38. addChild(colArea);
  39. colArea.setColumnIndex(columnIndex + 1);
  40. }
  41. }
  42. public void end() {}
  43. public void start() {}
  44. public int spaceLeft() {
  45. return maxHeight - currentHeight;
  46. }
  47. public int getColumnCount() {
  48. return columnCount;
  49. }
  50. public int getCurrentColumn() {
  51. return currentColumn;
  52. }
  53. public void setCurrentColumn(int currentColumn) {
  54. if (currentColumn <= columnCount)
  55. this.currentColumn = currentColumn;
  56. else
  57. this.currentColumn = columnCount;
  58. }
  59. public AreaContainer getCurrentColumnArea() {
  60. return (AreaContainer)getChildren().elementAt(currentColumn - 1);
  61. }
  62. public boolean isBalanced() {
  63. return isBalanced;
  64. }
  65. public void setIsBalanced() {
  66. this.isBalanced = true;
  67. }
  68. public int getTotalContentHeight() {
  69. int totalContentHeight = 0;
  70. for (Enumeration e = getChildren().elements();
  71. e.hasMoreElements(); ) {
  72. totalContentHeight +=
  73. ((AreaContainer)e.nextElement()).getContentHeight();
  74. }
  75. return totalContentHeight;
  76. }
  77. public int getMaxContentHeight() {
  78. int maxContentHeight = 0;
  79. for (Enumeration e = getChildren().elements();
  80. e.hasMoreElements(); ) {
  81. AreaContainer nextElm = (AreaContainer)e.nextElement();
  82. if (nextElm.getContentHeight() > maxContentHeight)
  83. maxContentHeight = nextElm.getContentHeight();
  84. }
  85. return maxContentHeight;
  86. }
  87. public void setPage(Page page) {
  88. this.page = page;
  89. for (Enumeration e = getChildren().elements();
  90. e.hasMoreElements(); ) {
  91. ((AreaContainer)e.nextElement()).setPage(page);
  92. }
  93. }
  94. public boolean isLastColumn() {
  95. return (currentColumn == columnCount);
  96. }
  97. }