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.

BlockViewport.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.awt.Rectangle;
  20. /**
  21. * A BlockViewport.
  22. * This is used for block level Viewport/reference pairs.
  23. * The block-container creates this area.
  24. */
  25. public class BlockViewport extends Block implements Viewport {
  26. private static final long serialVersionUID = -7840580922580735157L;
  27. // clipping for this viewport
  28. private boolean clip;
  29. // transform if rotated or absolute
  30. private CTM viewportCTM;
  31. /**
  32. * Create a new block viewport area.
  33. */
  34. public BlockViewport() {
  35. this(false);
  36. }
  37. /**
  38. * Create a new block viewport area.
  39. * @param allowBPDUpdate true allows the BPD to be updated when children are added
  40. */
  41. public BlockViewport(boolean allowBPDUpdate) {
  42. this.allowBPDUpdate = allowBPDUpdate;
  43. }
  44. /**
  45. * Set the transform of this viewport.
  46. * If the viewport is rotated or has an absolute positioning
  47. * this transform will do the work.
  48. *
  49. * @param ctm the transformation
  50. */
  51. public void setCTM(CTM ctm) {
  52. viewportCTM = ctm;
  53. }
  54. /**
  55. * Get the transform of this block viewport.
  56. *
  57. * @return the transformation of this viewport
  58. * or null if normally stacked without rotation
  59. */
  60. public CTM getCTM() {
  61. return viewportCTM;
  62. }
  63. /**
  64. * Set the clipping for this viewport.
  65. *
  66. * @param cl the clipping for the viewport
  67. */
  68. public void setClip(boolean cl) {
  69. clip = cl;
  70. }
  71. /** {@inheritDoc} */
  72. public boolean hasClip() {
  73. return clip;
  74. }
  75. /** {@inheritDoc} */
  76. public Rectangle getClipRectangle() {
  77. if (clip) {
  78. return new Rectangle(getIPD(), getBPD());
  79. } else {
  80. return null;
  81. }
  82. }
  83. }