KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > action > PDAnnotationAdditionalActions


1 /**
2  * Copyright (c) 2004, 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.action;
32
33 import org.pdfbox.cos.COSBase;
34 import org.pdfbox.cos.COSDictionary;
35
36 import org.pdfbox.pdmodel.common.COSObjectable;
37 import org.pdfbox.pdmodel.interactive.action.type.PDAction;
38
39 /**
40  * This class represents an annotation's dictionary of actions
41  * that occur due to events.
42  *
43  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
44  * @author Panagiotis Toumasis (ptoumasis@mail.gr)
45  * @version $Revision: 1.2 $
46  */

47 public class PDAnnotationAdditionalActions implements COSObjectable
48 {
49     private COSDictionary actions;
50
51     /**
52      * Default constructor.
53      */

54     public PDAnnotationAdditionalActions()
55     {
56         actions = new COSDictionary();
57     }
58
59     /**
60      * Constructor.
61      *
62      * @param a The action dictionary.
63      */

64     public PDAnnotationAdditionalActions( COSDictionary a )
65     {
66         actions = a;
67     }
68
69     /**
70      * Convert this standard java object to a COS object.
71      *
72      * @return The cos object that matches this Java object.
73      */

74     public COSBase getCOSObject()
75     {
76         return actions;
77     }
78
79     /**
80      * Convert this standard java object to a COS object.
81      *
82      * @return The cos object that matches this Java object.
83      */

84     public COSDictionary getCOSDictionary()
85     {
86         return actions;
87     }
88
89     /**
90      * This will get an action to be performed when the cursor
91      * enters the annotation's active area.
92      *
93      * @return The E entry of annotation's additional actions dictionary.
94      */

95     public PDAction getE()
96     {
97         COSDictionary e = (COSDictionary)actions.getDictionaryObject( "E" );
98         PDAction retval = null;
99         if( e != null )
100         {
101             retval = PDActionFactory.createAction( e );
102         }
103         return retval;
104     }
105
106     /**
107      * This will set an action to be performed when the cursor
108      * enters the annotation's active area.
109      *
110      * @param e The action to be performed.
111      */

112     public void setE( PDAction e )
113     {
114         actions.setItem( "E", e );
115     }
116
117     /**
118      * This will get an action to be performed when the cursor
119      * exits the annotation's active area.
120      *
121      * @return The X entry of annotation's additional actions dictionary.
122      */

123     public PDAction getX()
124     {
125         COSDictionary x = (COSDictionary)actions.getDictionaryObject( "X" );
126         PDAction retval = null;
127         if( x != null )
128         {
129             retval = PDActionFactory.createAction( x );
130         }
131         return retval;
132     }
133
134     /**
135      * This will set an action to be performed when the cursor
136      * exits the annotation's active area.
137      *
138      * @param x The action to be performed.
139      */

140     public void setX( PDAction x )
141     {
142         actions.setItem( "X", x );
143     }
144
145     /**
146      * This will get an action to be performed when the mouse button
147      * is pressed inside the annotation's active area.
148      * The name D stands for "down".
149      *
150      * @return The d entry of annotation's additional actions dictionary.
151      */

152     public PDAction getD()
153     {
154         COSDictionary d = (COSDictionary)actions.getDictionaryObject( "D" );
155         PDAction retval = null;
156         if( d != null )
157         {
158             retval = PDActionFactory.createAction( d );
159         }
160         return retval;
161     }
162
163     /**
164      * This will set an action to be performed when the mouse button
165      * is pressed inside the annotation's active area.
166      * The name D stands for "down".
167      *
168      * @param d The action to be performed.
169      */

170     public void setD( PDAction d )
171     {
172         actions.setItem( "D", d );
173     }
174
175     /**
176      * This will get an action to be performed when the mouse button
177      * is released inside the annotation's active area.
178      * The name U stands for "up".
179      *
180      * @return The U entry of annotation's additional actions dictionary.
181      */

182     public PDAction getU()
183     {
184         COSDictionary u = (COSDictionary)actions.getDictionaryObject( "U" );
185         PDAction retval = null;
186         if( u != null )
187         {
188             retval = PDActionFactory.createAction( u );
189         }
190         return retval;
191     }
192
193     /**
194      * This will set an action to be performed when the mouse button
195      * is released inside the annotation's active area.
196      * The name U stands for "up".
197      *
198      * @param u The action to be performed.
199      */

200     public void setU( PDAction u )
201     {
202         actions.setItem( "U", u );
203     }
204
205     /**
206      * This will get an action to be performed when the annotation
207      * receives the input focus.
208      *
209      * @return The Fo entry of annotation's additional actions dictionary.
210      */

211     public PDAction getFo()
212     {
213         COSDictionary fo = (COSDictionary)actions.getDictionaryObject( "Fo" );
214         PDAction retval = null;
215         if( fo != null )
216         {
217             retval = PDActionFactory.createAction( fo );
218         }
219         return retval;
220     }
221
222     /**
223      * This will set an action to be performed when the annotation
224      * receives the input focus.
225      *
226      * @param fo The action to be performed.
227      */

228     public void setFo( PDAction fo )
229     {
230         actions.setItem( "Fo", fo );
231     }
232
233     /**
234      * This will get an action to be performed when the annotation
235      * loses the input focus.
236      * The name Bl stands for "blurred".
237      *
238      * @return The Bl entry of annotation's additional actions dictionary.
239      */

240     public PDAction getBl()
241     {
242         COSDictionary bl = (COSDictionary)actions.getDictionaryObject( "Bl" );
243         PDAction retval = null;
244         if( bl != null )
245         {
246             retval = PDActionFactory.createAction( bl );
247         }
248         return retval;
249     }
250
251     /**
252      * This will set an action to be performed when the annotation
253      * loses the input focus.
254      * The name Bl stands for "blurred".
255      *
256      * @param bl The action to be performed.
257      */

258     public void setBl( PDAction bl )
259     {
260         actions.setItem( "Bl", bl );
261     }
262
263     /**
264      * This will get an action to be performed when the page containing
265      * the annotation is opened. The action is executed after the O action
266      * in the page's additional actions dictionary and the OpenAction entry
267      * in the document catalog, if such actions are present.
268      *
269      * @return The PO entry of annotation's additional actions dictionary.
270      */

271     public PDAction getPO()
272     {
273         COSDictionary po = (COSDictionary)actions.getDictionaryObject( "PO" );
274         PDAction retval = null;
275         if( po != null )
276         {
277             retval = PDActionFactory.createAction( po );
278         }
279         return retval;
280     }
281
282     /**
283      * This will set an action to be performed when the page containing
284      * the annotation is opened. The action is executed after the O action
285      * in the page's additional actions dictionary and the OpenAction entry
286      * in the document catalog, if such actions are present.
287      *
288      * @param po The action to be performed.
289      */

290     public void setPO( PDAction po )
291     {
292         actions.setItem( "PO", po );
293     }
294
295     /**
296      * This will get an action to be performed when the page containing
297      * the annotation is closed. The action is executed before the C action
298      * in the page's additional actions dictionary, if present.
299      *
300      * @return The PC entry of annotation's additional actions dictionary.
301      */

302     public PDAction getPC()
303     {
304         COSDictionary pc = (COSDictionary)actions.getDictionaryObject( "PC" );
305         PDAction retval = null;
306         if( pc != null )
307         {
308             retval = PDActionFactory.createAction( pc );
309         }
310         return retval;
311     }
312
313     /**
314      * This will set an action to be performed when the page containing
315      * the annotation is closed. The action is executed before the C action
316      * in the page's additional actions dictionary, if present.
317      *
318      * @param pc The action to be performed.
319      */

320     public void setPC( PDAction pc )
321     {
322         actions.setItem( "PC", pc );
323     }
324
325     /**
326      * This will get an action to be performed when the page containing
327      * the annotation becomes visible in the viewer application's user interface.
328      *
329      * @return The PV entry of annotation's additional actions dictionary.
330      */

331     public PDAction getPV()
332     {
333         COSDictionary pv = (COSDictionary)actions.getDictionaryObject( "PV" );
334         PDAction retval = null;
335         if( pv != null )
336         {
337             retval = PDActionFactory.createAction( pv );
338         }
339         return retval;
340     }
341
342     /**
343      * This will set an action to be performed when the page containing
344      * the annotation becomes visible in the viewer application's user interface.
345      *
346      * @param pv The action to be performed.
347      */

348     public void setPV( PDAction pv )
349     {
350         actions.setItem( "PV", pv );
351     }
352
353     /**
354      * This will get an action to be performed when the page containing the annotation
355      * is no longer visible in the viewer application's user interface.
356      *
357      * @return The PI entry of annotation's additional actions dictionary.
358      */

359     public PDAction getPI()
360     {
361         COSDictionary pi = (COSDictionary)actions.getDictionaryObject( "PI" );
362         PDAction retval = null;
363         if( pi != null )
364         {
365             retval = PDActionFactory.createAction( pi );
366         }
367         return retval;
368     }
369
370     /**
371      * This will set an action to be performed when the page containing the annotation
372      * is no longer visible in the viewer application's user interface.
373      *
374      * @param pi The action to be performed.
375      */

376     public void setPI( PDAction pi )
377     {
378         actions.setItem( "PI", pi );
379     }
380 }
Popular Tags