KickJava   Java API By Example, From Geeks To Geeks.

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


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 a y location and the width is magnified
38  * to just fit on the screen.
39  *
40  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
41  * @version $Revision: 1.2 $
42  */

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

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

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

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

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

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

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

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

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

146     public void setRight( int x )
147     {
148         array.growToSize( 6 );
149         if( x == -1 )
150         {
151             array.set( 4, (COSBase)null );
152         }
153         else
154         {
155             array.setInt( 4, x );
156         }
157     }
158     
159     
160     /**
161      * Get the top y coordinate. A return value of -1 implies that the current y-coordinate
162      * will be used.
163      *
164      * @return The top y coordinate.
165      */

166     public int getTop()
167     {
168         return array.getInt( 5 );
169     }
170     
171     /**
172      * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
173      * will be used.
174      * @param y The top ycoordinate.
175      */

176     public void setTop( int y )
177     {
178         array.growToSize( 6 );
179         if( y == -1 )
180         {
181             array.set( 5, (COSBase)null );
182         }
183         else
184         {
185             array.setInt( 5, y );
186         }
187     }
188 }
189
Popular Tags