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.

TableContentPosition.java 3.9KB

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.layoutmgr.table;
  19. import java.util.List;
  20. import org.apache.fop.fo.flow.table.EffRow;
  21. import org.apache.fop.fo.flow.table.TablePart;
  22. import org.apache.fop.layoutmgr.LayoutManager;
  23. import org.apache.fop.layoutmgr.Position;
  24. /**
  25. * This class represents a Position specific to TableContentLayoutManager. Used for normal
  26. * content cases.
  27. */
  28. class TableContentPosition extends Position {
  29. /** The position is the first of the row group. */
  30. public static final int FIRST_IN_ROWGROUP = 1;
  31. /** The position is the last of the row group. */
  32. public static final int LAST_IN_ROWGROUP = 2;
  33. /** the list of CellParts making up this position */
  34. protected List cellParts;
  35. /** effective row this position belongs to */
  36. private EffRow row;
  37. /** flags for the position */
  38. protected int flags;
  39. private EffRow newPageRow;
  40. /**
  41. * Creates a new TableContentPosition.
  42. * @param lm applicable layout manager
  43. * @param cellParts the list of CellPart instances
  44. * @param row effective row this position belongs to
  45. */
  46. protected TableContentPosition(LayoutManager lm, List cellParts,
  47. EffRow row) {
  48. super(lm);
  49. this.cellParts = cellParts;
  50. this.row = row;
  51. this.newPageRow = row;
  52. }
  53. /**
  54. * Sets the row corresponding to this position if it starts a new page. In which case,
  55. * if the delay mechanism is on, this is the delayed row that starts the page, and not
  56. * the current row being extended.
  57. *
  58. * @param newPageRow the row that will start the page if this position is the first
  59. * one on that page
  60. */
  61. void setNewPageRow(EffRow newPageRow) {
  62. this.newPageRow = newPageRow;
  63. }
  64. EffRow getNewPageRow() {
  65. return newPageRow;
  66. }
  67. EffRow getRow() {
  68. return row;
  69. }
  70. TablePart getTablePart() {
  71. return ((CellPart) cellParts.get(0)).pgu.getTablePart();
  72. }
  73. /**
  74. * Returns a flag for this GridUnit.
  75. * @param which the requested flag
  76. * @return the value of the flag
  77. */
  78. public boolean getFlag(int which) {
  79. return (flags & (1 << which)) != 0;
  80. }
  81. /**
  82. * Sets a flag on a GridUnit.
  83. * @param which the flag to set
  84. * @param value the new value for the flag
  85. */
  86. public void setFlag(int which, boolean value) {
  87. if (value) {
  88. flags |= (1 << which); //set flag
  89. } else {
  90. flags &= ~(1 << which); //clear flag
  91. }
  92. }
  93. /** {@inheritDoc} */
  94. public boolean generatesAreas() {
  95. return true;
  96. }
  97. /** {@inheritDoc} */
  98. public String toString() {
  99. StringBuffer sb = new StringBuffer("TableContentPosition:");
  100. sb.append(getIndex());
  101. sb.append("[");
  102. sb.append(row.getIndex()).append("/");
  103. sb.append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
  104. sb.append(getFlag(LAST_IN_ROWGROUP) ? "L" : "-").append("]");
  105. sb.append("(");
  106. sb.append(cellParts);
  107. sb.append(")");
  108. return sb.toString();
  109. }
  110. public Position getPosition() {
  111. return this;
  112. }
  113. }