]> _ Git - cubeextranet.git/blob
549a186f28ed4049b62d2c4e5e728e416c57b91d
[cubeextranet.git] /
1 /*\r
2  * Licensed to the Apache Software Foundation (ASF) under one or more\r
3  * contributor license agreements.  See the NOTICE file distributed with\r
4  * this work for additional information regarding copyright ownership.\r
5  * The ASF licenses this file to You under the Apache License, Version 2.0\r
6  * (the "License"); you may not use this file except in compliance with\r
7  * the License.  You may obtain a copy of the License at\r
8  *\r
9  *      http://www.apache.org/licenses/LICENSE-2.0\r
10  *\r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 package org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination;\r
18 \r
19 import org.apache.pdfbox.cos.COSArray;\r
20 import org.apache.pdfbox.cos.COSBase;\r
21 \r
22 /**\r
23  * This represents a destination to a page at a x location and the height is magnified\r
24  * to just fit on the screen.\r
25  *\r
26  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>\r
27  * @version $Revision: 1.2 $\r
28  */\r
29 public class PDPageFitHeightDestination extends PDPageDestination\r
30 {\r
31     /**\r
32      * The type of this destination.\r
33      */\r
34     protected static final String TYPE = "FitV";\r
35     /**\r
36      * The type of this destination.\r
37      */\r
38     protected static final String TYPE_BOUNDED = "FitBV";\r
39 \r
40     /**\r
41      * Default constructor.\r
42      *\r
43      */\r
44     public PDPageFitHeightDestination()\r
45     {\r
46         super();\r
47         array.growToSize(3);\r
48         array.setName( 1, TYPE );\r
49 \r
50     }\r
51 \r
52     /**\r
53      * Constructor from an existing destination array.\r
54      *\r
55      * @param arr The destination array.\r
56      */\r
57     public PDPageFitHeightDestination( COSArray arr )\r
58     {\r
59         super( arr );\r
60     }\r
61 \r
62     /**\r
63      * Get the left x coordinate.  A return value of -1 implies that the current x-coordinate\r
64      * will be used.\r
65      *\r
66      * @return The left x coordinate.\r
67      */\r
68     public int getLeft()\r
69     {\r
70         return array.getInt( 2 );\r
71     }\r
72 \r
73     /**\r
74      * Set the left x-coordinate, a value of -1 implies that the current x-coordinate\r
75      * will be used.\r
76      * @param x The left x coordinate.\r
77      */\r
78     public void setLeft( int x )\r
79     {\r
80         array.growToSize( 3 );\r
81         if( x == -1 )\r
82         {\r
83             array.set( 2, (COSBase)null );\r
84         }\r
85         else\r
86         {\r
87             array.setInt( 2, x );\r
88         }\r
89     }\r
90 \r
91     /**\r
92      * A flag indicating if this page destination should just fit bounding box of the PDF.\r
93      *\r
94      * @return true If the destination should fit just the bounding box.\r
95      */\r
96     public boolean fitBoundingBox()\r
97     {\r
98         return TYPE_BOUNDED.equals( array.getName( 1 ) );\r
99     }\r
100 \r
101     /**\r
102      * Set if this page destination should just fit the bounding box.  The default is false.\r
103      *\r
104      * @param fitBoundingBox A flag indicating if this should fit the bounding box.\r
105      */\r
106     public void setFitBoundingBox( boolean fitBoundingBox )\r
107     {\r
108         array.growToSize( 2 );\r
109         if( fitBoundingBox )\r
110         {\r
111             array.setName( 1, TYPE_BOUNDED );\r
112         }\r
113         else\r
114         {\r
115             array.setName( 1, TYPE );\r
116         }\r
117     }\r
118 }\r