]> _ Git - cubeextranet.git/blob
5cc6bcc4abcf0b7be50f777bb8cea16b1cfc6188
[cubeextranet.git] /
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 x location and the height 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 PDPageFitHeightDestination extends PDPageDestination
30 {
31     /**
32      * The type of this destination.
33      */
34     protected static final String TYPE = "FitV";
35     /**
36      * The type of this destination.
37      */
38     protected static final String TYPE_BOUNDED = "FitBV";
39
40     /**
41      * Default constructor.
42      *
43      */
44     public PDPageFitHeightDestination()
45     {
46         super();
47         array.growToSize(3);
48         array.setName( 1, TYPE );
49
50     }
51
52     /**
53      * Constructor from an existing destination array.
54      *
55      * @param arr The destination array.
56      */
57     public PDPageFitHeightDestination( COSArray arr )
58     {
59         super( arr );
60     }
61
62     /**
63      * Get the left x coordinate.  A return value of -1 implies that the current x-coordinate
64      * will be used.
65      *
66      * @return The left x coordinate.
67      */
68     public int getLeft()
69     {
70         return array.getInt( 2 );
71     }
72
73     /**
74      * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
75      * will be used.
76      * @param x The left x coordinate.
77      */
78     public void setLeft( int x )
79     {
80         array.growToSize( 3 );
81         if( x == -1 )
82         {
83             array.set( 2, (COSBase)null );
84         }
85         else
86         {
87             array.setInt( 2, x );
88         }
89     }
90
91     /**
92      * A flag indicating if this page destination should just fit bounding box of the PDF.
93      *
94      * @return true If the destination should fit just the bounding box.
95      */
96     public boolean fitBoundingBox()
97     {
98         return TYPE_BOUNDED.equals( array.getName( 1 ) );
99     }
100
101     /**
102      * Set if this page destination should just fit the bounding box.  The default is false.
103      *
104      * @param fitBoundingBox A flag indicating if this should fit the bounding box.
105      */
106     public void setFitBoundingBox( boolean fitBoundingBox )
107     {
108         array.growToSize( 2 );
109         if( fitBoundingBox )
110         {
111             array.setName( 1, TYPE_BOUNDED );
112         }
113         else
114         {
115             array.setName( 1, TYPE );
116         }
117     }
118 }