KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > documents > interaction > ViewerPreferences


1 /*
2   Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright © 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.documents.interaction;
28
29 import it.stefanochizzolini.clown.documents.Document;
30 import it.stefanochizzolini.clown.files.File;
31 import it.stefanochizzolini.clown.objects.PdfAtomicObject;
32 import it.stefanochizzolini.clown.objects.PdfBoolean;
33 import it.stefanochizzolini.clown.objects.PdfDictionary;
34 import it.stefanochizzolini.clown.objects.PdfDirectObject;
35 import it.stefanochizzolini.clown.objects.PdfIndirectObject;
36 import it.stefanochizzolini.clown.objects.PdfName;
37 import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
38 import it.stefanochizzolini.clown.util.NotImplementedException;
39
40 /**
41   Viewer preferences [PDF:1.6:8.1].
42 */

43 public class ViewerPreferences
44   extends PdfObjectWrapper<PdfDictionary>
45 {
46   // <class>
47
// <dynamic>
48
// <constructors>
49
public ViewerPreferences(
50     Document context
51     )
52   {
53     super(
54       context.getFile(),
55       new PdfDictionary()
56       );
57   }
58
59   /**
60     <h3>Remarks</h3>
61     <p>For internal use only.</p>
62   */

63   public ViewerPreferences(
64     PdfDirectObject baseObject,
65     PdfIndirectObject container
66     )
67   {
68     super(
69       baseObject,
70       container
71       );
72   }
73   // </constructors>
74

75   // <interface>
76
// <public>
77
public Object JavaDoc clone(
78     Document context
79     )
80   {throw new NotImplementedException();}
81
82   public boolean getDisplayDocTitle(
83     )
84   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.DisplayDocTitle);}
85
86   public boolean getHideMenubar(
87     )
88   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.HideMenubar);}
89
90   public boolean getHideToolbar(
91     )
92   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.HideToolbar);}
93
94   public boolean getHideWindowUI(
95     )
96   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.HideWindowUI);}
97
98   public boolean getFitWindow(
99     )
100   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.FitWindow);}
101
102   public boolean getCenterWindow(
103     )
104   {return this.<Boolean JavaDoc,PdfBoolean>getEntry(PdfName.CenterWindow);}
105
106   public void setDisplayDocTitle(
107     boolean value
108     )
109   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.DisplayDocTitle,value,PdfBoolean.class);}
110
111   public void setHideMenubar(
112     boolean value
113     )
114   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.HideMenubar,value,PdfBoolean.class);}
115
116   public void setHideToolbar(
117     boolean value
118     )
119   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.HideToolbar,value,PdfBoolean.class);}
120
121   public void setHideWindowUI(
122     boolean value
123     )
124   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.HideWindowUI,value,PdfBoolean.class);}
125
126   public void setFitWindow(
127     boolean value
128     )
129   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.FitWindow,value,PdfBoolean.class);}
130
131   public void setCenterWindow(
132     boolean value
133     )
134   {this.<Boolean JavaDoc,PdfBoolean>setEntry(PdfName.CenterWindow,value,PdfBoolean.class);}
135   // </public>
136

137   // <protected>
138
protected <T,TPdf extends PdfAtomicObject<T>> T getEntry(
139     PdfName key
140     )
141   {
142     TPdf entry = (TPdf)File.resolve(getBaseDataObject().get(key));
143     if(entry == null)
144       return null;
145
146     return (T)entry.getValue();
147   }
148
149   protected <T,TPdf extends PdfAtomicObject<T>> void setEntry(
150     PdfName key,
151     T value,
152     Class JavaDoc<TPdf> entryType // This Class<TPdf> parameter is an ugly workaround to the horrific generics type erasure that precludes full reflection over parameterized types.
153
)
154   {
155     TPdf entry = (TPdf)File.resolve(getBaseDataObject().get(key));
156     if(entry == null)
157     {
158       try
159       {
160         getBaseDataObject().put(
161           key,
162           entry = entryType.newInstance()
163           );
164       }
165       catch(Exception JavaDoc e)
166       {throw new RuntimeException JavaDoc(e);}
167     }
168
169     entry.setValue(value);
170   }
171   // </protected>
172
// </interface>
173
// </dynamic>
174
// </class>
175
}
Popular Tags