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