KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > viewerpreferences > PDViewerPreferences


1 /**
2  * Copyright (c) 2003-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.viewerpreferences;
32
33 import org.pdfbox.cos.COSBase;
34 import org.pdfbox.cos.COSDictionary;
35
36 import org.pdfbox.pdmodel.common.COSObjectable;
37
38 /**
39  * This is the document viewing preferences.
40  *
41  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
42  * @version $Revision: 1.3 $
43  */

44 public class PDViewerPreferences implements COSObjectable
45 {
46     /**
47      * From PDF Reference: "Neither document outline nor thumbnail images visible".
48      */

49     public static final String JavaDoc NON_FULL_SCREEN_PAGE_MODE_USE_NONE = "UseNone";
50     /**
51      * From PDF Reference: "Document outline visible".
52      */

53     public static final String JavaDoc NON_FULL_SCREEN_PAGE_MODE_USE_OUTLINES = "UseOutlines";
54     /**
55      * From PDF Reference: "Thumbnail images visible".
56      */

57     public static final String JavaDoc NON_FULL_SCREEN_PAGE_MODE_USE_THUMBS = "UseThumbs";
58     /**
59      * From PDF Reference: "Optional content group panel visible".
60      */

61     public static final String JavaDoc NON_FULL_SCREEN_PAGE_MODE_USE_OPTIONAL_CONTENT = "UseOC";
62     
63     /**
64      * Reading direction.
65      */

66     public static final String JavaDoc READING_DIRECTION_L2R = "L2R";
67     /**
68      * Reading direction.
69      */

70     public static final String JavaDoc READING_DIRECTION_R2L = "R2L";
71     
72     /**
73      * Boundary constant.
74      */

75     public static final String JavaDoc BOUNDARY_MEDIA_BOX = "MediaBox";
76     /**
77      * Boundary constant.
78      */

79     public static final String JavaDoc BOUNDARY_CROP_BOX = "CropBox";
80     /**
81      * Boundary constant.
82      */

83     public static final String JavaDoc BOUNDARY_BLEED_BOX = "BleedBox";
84     /**
85      * Boundary constant.
86      */

87     public static final String JavaDoc BOUNDARY_TRIM_BOX = "TrimBox";
88     /**
89      * Boundary constant.
90      */

91     public static final String JavaDoc BOUNDARY_ART_BOX = "ArtBox";
92     
93     
94     private COSDictionary prefs;
95
96     /**
97      * Constructor that is used for a preexisting dictionary.
98      *
99      * @param dic The underlying dictionary.
100      */

101     public PDViewerPreferences( COSDictionary dic )
102     {
103         prefs = dic;
104     }
105
106     /**
107      * This will get the underlying dictionary that this object wraps.
108      *
109      * @return The underlying info dictionary.
110      */

111     public COSDictionary getDictionary()
112     {
113         return prefs;
114     }
115     
116     /**
117      * Convert this standard java object to a COS object.
118      *
119      * @return The cos object that matches this Java object.
120      */

121     public COSBase getCOSObject()
122     {
123         return prefs;
124     }
125     
126     /**
127      * Get the toolbar preference.
128      *
129      * @return the toolbar preference.
130      */

131     public boolean hideToolbar()
132     {
133         return prefs.getBoolean( "HideToolbar", false );
134     }
135     
136     /**
137      * Set the toolbar preference.
138      *
139      * @param value Set the toolbar preference.
140      */

141     public void setHideToolbar( boolean value )
142     {
143         prefs.setBoolean( "HideToolbar", value );
144     }
145     
146     /**
147      * Get the menubar preference.
148      *
149      * @return the menubar preference.
150      */

151     public boolean hideMenubar()
152     {
153         return prefs.getBoolean( "HideMenubar", false );
154     }
155     
156     /**
157      * Set the menubar preference.
158      *
159      * @param value Set the menubar preference.
160      */

161     public void setHideMenubar( boolean value )
162     {
163         prefs.setBoolean( "HideMenubar", value );
164     }
165     
166     /**
167      * Get the window UI preference.
168      *
169      * @return the window UI preference.
170      */

171     public boolean hideWindowUI()
172     {
173         return prefs.getBoolean( "HideWindowUI", false );
174     }
175     
176     /**
177      * Set the window UI preference.
178      *
179      * @param value Set the window UI preference.
180      */

181     public void setHideWindowUI( boolean value )
182     {
183         prefs.setBoolean( "HideWindowUI", value );
184     }
185     
186     /**
187      * Get the fit window preference.
188      *
189      * @return the fit window preference.
190      */

191     public boolean fitWindow()
192     {
193         return prefs.getBoolean( "FitWindow", false );
194     }
195     
196     /**
197      * Set the fit window preference.
198      *
199      * @param value Set the fit window preference.
200      */

201     public void setFitWindow( boolean value )
202     {
203         prefs.setBoolean( "FitWindow", value );
204     }
205     
206     /**
207      * Get the center window preference.
208      *
209      * @return the center window preference.
210      */

211     public boolean centerWindow()
212     {
213         return prefs.getBoolean( "CenterWindow", false );
214     }
215     
216     /**
217      * Set the center window preference.
218      *
219      * @param value Set the center window preference.
220      */

221     public void setCenterWindow( boolean value )
222     {
223         prefs.setBoolean( "CenterWindow", value );
224     }
225     
226     /**
227      * Get the display doc title preference.
228      *
229      * @return the display doc title preference.
230      */

231     public boolean displayDocTitle()
232     {
233         return prefs.getBoolean( "DisplayDocTitle", false );
234     }
235     
236     /**
237      * Set the display doc title preference.
238      *
239      * @param value Set the display doc title preference.
240      */

241     public void setDisplayDocTitle( boolean value )
242     {
243         prefs.setBoolean( "DisplayDocTitle", value );
244     }
245     
246     /**
247      * Get the non full screen page mode preference.
248      *
249      * @return the non full screen page mode preference.
250      */

251     public String JavaDoc getNonFullScreenPageMode()
252     {
253         return prefs.getNameAsString( "NonFullScreenPageMode", NON_FULL_SCREEN_PAGE_MODE_USE_NONE);
254     }
255     
256     /**
257      * Set the non full screen page mode preference.
258      *
259      * @param value Set the non full screen page mode preference.
260      */

261     public void setNonFullScreenPageMode( String JavaDoc value )
262     {
263         prefs.setName( "NonFullScreenPageMode", value );
264     }
265     
266     /**
267      * Get the reading direction preference.
268      *
269      * @return the reading direction preference.
270      */

271     public String JavaDoc getReadingDirection()
272     {
273         return prefs.getNameAsString( "Direction", READING_DIRECTION_L2R);
274     }
275     
276     /**
277      * Set the reading direction preference.
278      *
279      * @param value Set the reading direction preference.
280      */

281     public void setReadingDirection( String JavaDoc value )
282     {
283         prefs.setName( "Direction", value );
284     }
285     
286     /**
287      * Get the ViewArea preference. See BOUNDARY_XXX constants.
288      *
289      * @return the ViewArea preference.
290      */

291     public String JavaDoc getViewArea()
292     {
293         return prefs.getNameAsString( "ViewArea", BOUNDARY_CROP_BOX);
294     }
295     
296     /**
297      * Set the ViewArea preference. See BOUNDARY_XXX constants.
298      *
299      * @param value Set the ViewArea preference.
300      */

301     public void setViewArea( String JavaDoc value )
302     {
303         prefs.setName( "ViewArea", value );
304     }
305     
306     /**
307      * Get the ViewClip preference. See BOUNDARY_XXX constants.
308      *
309      * @return the ViewClip preference.
310      */

311     public String JavaDoc getViewClip()
312     {
313         return prefs.getNameAsString( "ViewClip", BOUNDARY_CROP_BOX);
314     }
315     
316     /**
317      * Set the ViewClip preference. See BOUNDARY_XXX constants.
318      *
319      * @param value Set the ViewClip preference.
320      */

321     public void setViewClip( String JavaDoc value )
322     {
323         prefs.setName( "ViewClip", value );
324     }
325     
326     /**
327      * Get the PrintArea preference. See BOUNDARY_XXX constants.
328      *
329      * @return the PrintArea preference.
330      */

331     public String JavaDoc getPrintArea()
332     {
333         return prefs.getNameAsString( "PrintArea", BOUNDARY_CROP_BOX);
334     }
335     
336     /**
337      * Set the PrintArea preference. See BOUNDARY_XXX constants.
338      *
339      * @param value Set the PrintArea preference.
340      */

341     public void setPrintArea( String JavaDoc value )
342     {
343         prefs.setName( "PrintArea", value );
344     }
345     
346     /**
347      * Get the PrintClip preference. See BOUNDARY_XXX constants.
348      *
349      * @return the PrintClip preference.
350      */

351     public String JavaDoc getPrintClip()
352     {
353         return prefs.getNameAsString( "PrintClip", BOUNDARY_CROP_BOX);
354     }
355     
356     /**
357      * Set the PrintClip preference. See BOUNDARY_XXX constants.
358      *
359      * @param value Set the PrintClip preference.
360      */

361     public void setPrintClip( String JavaDoc value )
362     {
363         prefs.setName( "PrintClip", value );
364     }
365 }
Popular Tags