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