]> _ Git - cubeextranet.git/blob
c76368d2a13df3673533d1cca47c0db990a4e756
[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 an x,y coordinate with a zoom setting.
24  * The default x,y,z will be whatever is the current value in the viewer application and
25  * are not required.
26  *
27  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
28  * @version $Revision: 1.2 $
29  */
30 public class PDPageXYZDestination extends PDPageDestination
31 {
32     /**
33      * The type of this destination.
34      */
35     protected static final String TYPE = "XYZ";
36
37     /**
38      * Default constructor.
39      *
40      */
41     public PDPageXYZDestination()
42     {
43         super();
44         array.growToSize(5);
45         array.setName( 1, TYPE );
46
47     }
48
49     /**
50      * Constructor from an existing destination array.
51      *
52      * @param arr The destination array.
53      */
54     public PDPageXYZDestination( COSArray arr )
55     {
56         super( arr );
57     }
58
59     /**
60      * Get the left x coordinate.  A return value of -1 implies that the current x-coordinate
61      * will be used.
62      *
63      * @return The left x coordinate.
64      */
65     public int getLeft()
66     {
67         return array.getInt( 2 );
68     }
69
70     /**
71      * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
72      * will be used.
73      * @param x The left x coordinate.
74      */
75     public void setLeft( int x )
76     {
77         array.growToSize( 3 );
78         if( x == -1 )
79         {
80             array.set( 2, (COSBase)null );
81         }
82         else
83         {
84             array.setInt( 2, x );
85         }
86     }
87
88     /**
89      * Get the top y coordinate.  A return value of -1 implies that the current y-coordinate
90      * will be used.
91      *
92      * @return The top y coordinate.
93      */
94     public int getTop()
95     {
96         return array.getInt( 3 );
97     }
98
99     /**
100      * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
101      * will be used.
102      * @param y The top ycoordinate.
103      */
104     public void setTop( int y )
105     {
106         array.growToSize( 4 );
107         if( y == -1 )
108         {
109             array.set( 3, (COSBase)null );
110         }
111         else
112         {
113             array.setInt( 3, y );
114         }
115     }
116
117     /**
118      * Get the zoom value.  A return value of -1 implies that the current zoom
119      * will be used.
120      *
121      * @return The zoom value for the page.
122      */
123     public int getZoom()
124     {
125         return array.getInt( 4 );
126     }
127
128     /**
129      * Set the zoom value for the page, a value of -1 implies that the current zoom
130      * will be used.
131      * @param zoom The zoom value.
132      */
133     public void setZoom( int zoom )
134     {
135         array.growToSize( 5 );
136         if( zoom == -1 )
137         {
138             array.set( 4, (COSBase)null );
139         }
140         else
141         {
142             array.setInt( 4, zoom );
143         }
144     }
145 }