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.

PageSequence.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.List;
  20. import java.util.Locale;
  21. /**
  22. * Represents a page sequence in the area tree.
  23. */
  24. public class PageSequence extends AreaTreeObject {
  25. private List<PageViewport> pages = new java.util.ArrayList<PageViewport>();
  26. private LineArea title;
  27. private Locale locale;
  28. /**
  29. * Main constructor
  30. * @param title the title for the page-sequence, may be null
  31. */
  32. public PageSequence(LineArea title) {
  33. setTitle(title);
  34. }
  35. /**
  36. * @return the title of the page sequence in form of a line area, or null if there's no title
  37. */
  38. public LineArea getTitle() {
  39. return this.title;
  40. }
  41. /**
  42. * Sets the page sequence's title.
  43. * @param title the title
  44. */
  45. public void setTitle(LineArea title) {
  46. this.title = title;
  47. }
  48. /**
  49. * Adds a new page to the page sequence
  50. * @param page the page to be added
  51. */
  52. public void addPage(PageViewport page) {
  53. this.pages.add(page);
  54. }
  55. /**
  56. * @return the number of pages currently in this page sequence
  57. */
  58. public int getPageCount() {
  59. return this.pages.size();
  60. }
  61. /**
  62. * Returns the page at the given index.
  63. * @param idx the index of the requested page
  64. * @return the requested page or null if it was not found
  65. */
  66. public PageViewport getPage(int idx) {
  67. return this.pages.get(idx);
  68. }
  69. /**
  70. * Indicates whether a page is the first in this page sequence.
  71. * @param page the page to be inspected
  72. * @return true if the page is the first in this page sequence, false otherwise
  73. */
  74. public boolean isFirstPage(PageViewport page) {
  75. return page.equals(getPage(0));
  76. }
  77. /**
  78. * Sets the locale that applies to this page-sequence.
  79. *
  80. * @param locale the locale to set
  81. */
  82. public void setLocale(Locale locale) {
  83. this.locale = locale;
  84. }
  85. /**
  86. * Returns the locale of this page-sequence.
  87. *
  88. * @return the locale, {@code null} if not set
  89. */
  90. public Locale getLocale() {
  91. return locale;
  92. }
  93. }