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 package org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination; 18 19 import org.apache.pdfbox.cos.COSArray; 20 import org.apache.pdfbox.cos.COSBase; 21 22 /** 23 * This represents a destination to a page at a y location and the width is magnified 24 * to just fit on the screen. 25 * 26 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a> 27 * @version $Revision: 1.2 $ 28 */ 29 public class PDPageFitRectangleDestination extends PDPageDestination 30 { 31 /** 32 * The type of this destination. 33 */ 34 protected static final String TYPE = "FitR"; 35 36 /** 37 * Default constructor. 38 * 39 */ 40 public PDPageFitRectangleDestination() 41 { 42 super(); 43 array.growToSize(6); 44 array.setName( 1, TYPE ); 45 46 } 47 48 /** 49 * Constructor from an existing destination array. 50 * 51 * @param arr The destination array. 52 */ 53 public PDPageFitRectangleDestination( COSArray arr ) 54 { 55 super( arr ); 56 } 57 58 /** 59 * Get the left x coordinate. A return value of -1 implies that the current x-coordinate 60 * will be used. 61 * 62 * @return The left x coordinate. 63 */ 64 public int getLeft() 65 { 66 return array.getInt( 2 ); 67 } 68 69 /** 70 * Set the left x-coordinate, a value of -1 implies that the current x-coordinate 71 * will be used. 72 * @param x The left x coordinate. 73 */ 74 public void setLeft( int x ) 75 { 76 array.growToSize( 3 ); 77 if( x == -1 ) 78 { 79 array.set( 2, (COSBase)null ); 80 } 81 else 82 { 83 array.setInt( 2, x ); 84 } 85 } 86 87 /** 88 * Get the bottom y coordinate. A return value of -1 implies that the current y-coordinate 89 * will be used. 90 * 91 * @return The bottom y coordinate. 92 */ 93 public int getBottom() 94 { 95 return array.getInt( 3 ); 96 } 97 98 /** 99 * Set the bottom y-coordinate, a value of -1 implies that the current y-coordinate 100 * will be used. 101 * @param y The bottom y coordinate. 102 */ 103 public void setBottom( int y ) 104 { 105 array.growToSize( 6 ); 106 if( y == -1 ) 107 { 108 array.set( 3, (COSBase)null ); 109 } 110 else 111 { 112 array.setInt( 3, y ); 113 } 114 } 115 116 /** 117 * Get the right x coordinate. A return value of -1 implies that the current x-coordinate 118 * will be used. 119 * 120 * @return The right x coordinate. 121 */ 122 public int getRight() 123 { 124 return array.getInt( 4 ); 125 } 126 127 /** 128 * Set the right x-coordinate, a value of -1 implies that the current x-coordinate 129 * will be used. 130 * @param x The right x coordinate. 131 */ 132 public void setRight( int x ) 133 { 134 array.growToSize( 6 ); 135 if( x == -1 ) 136 { 137 array.set( 4, (COSBase)null ); 138 } 139 else 140 { 141 array.setInt( 4, x ); 142 } 143 } 144 145 146 /** 147 * Get the top y coordinate. A return value of -1 implies that the current y-coordinate 148 * will be used. 149 * 150 * @return The top y coordinate. 151 */ 152 public int getTop() 153 { 154 return array.getInt( 5 ); 155 } 156 157 /** 158 * Set the top y-coordinate, a value of -1 implies that the current y-coordinate 159 * will be used. 160 * @param y The top ycoordinate. 161 */ 162 public void setTop( int y ) 163 { 164 array.growToSize( 6 ); 165 if( y == -1 ) 166 { 167 array.set( 5, (COSBase)null ); 168 } 169 else 170 { 171 array.setInt( 5, y ); 172 } 173 } 174 }