KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > documentnavigation > destination > PDPageXYZDestination


1 /**
2  * Copyright (c) 2005, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.interactive.documentnavigation.destination;
32
33 import org.pdfbox.cos.COSArray;
34 import org.pdfbox.cos.COSBase;
35
36 /**
37  * This represents a destination to a page at an x,y coordinate with a zoom setting.
38  * The default x,y,z will be whatever is the current value in the viewer application and
39  * are not required.
40  *
41  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
42  * @version $Revision: 1.2 $
43  */

44 public class PDPageXYZDestination extends PDPageDestination
45 {
46     /**
47      * The type of this destination.
48      */

49     protected static final String JavaDoc TYPE = "XYZ";
50     
51     /**
52      * Default constructor.
53      *
54      */

55     public PDPageXYZDestination()
56     {
57         super();
58         array.growToSize(5);
59         array.setName( 1, TYPE );
60         
61     }
62     
63     /**
64      * Constructor from an existing destination array.
65      *
66      * @param arr The destination array.
67      */

68     public PDPageXYZDestination( COSArray arr )
69     {
70         super( arr );
71     }
72     
73     /**
74      * Get the left x coordinate. A return value of -1 implies that the current x-coordinate
75      * will be used.
76      *
77      * @return The left x coordinate.
78      */

79     public int getLeft()
80     {
81         return array.getInt( 2 );
82     }
83     
84     /**
85      * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
86      * will be used.
87      * @param x The left x coordinate.
88      */

89     public void setLeft( int x )
90     {
91         array.growToSize( 3 );
92         if( x == -1 )
93         {
94             array.set( 2, (COSBase)null );
95         }
96         else
97         {
98             array.setInt( 2, x );
99         }
100     }
101     
102     /**
103      * Get the top y coordinate. A return value of -1 implies that the current y-coordinate
104      * will be used.
105      *
106      * @return The top y coordinate.
107      */

108     public int getTop()
109     {
110         return array.getInt( 3 );
111     }
112     
113     /**
114      * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
115      * will be used.
116      * @param y The top ycoordinate.
117      */

118     public void setTop( int y )
119     {
120         array.growToSize( 4 );
121         if( y == -1 )
122         {
123             array.set( 3, (COSBase)null );
124         }
125         else
126         {
127             array.setInt( 3, y );
128         }
129     }
130     
131     /**
132      * Get the zoom value. A return value of -1 implies that the current zoom
133      * will be used.
134      *
135      * @return The zoom value for the page.
136      */

137     public int getZoom()
138     {
139         return array.getInt( 4 );
140     }
141     
142     /**
143      * Set the zoom value for the page, a value of -1 implies that the current zoom
144      * will be used.
145      * @param zoom The zoom value.
146      */

147     public void setZoom( int zoom )
148     {
149         array.growToSize( 5 );
150         if( zoom == -1 )
151         {
152             array.set( 4, (COSBase)null );
153         }
154         else
155         {
156             array.setInt( 4, zoom );
157         }
158     }
159 }
160
Popular Tags