KickJava   Java API By Example, From Geeks To Geeks.

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


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 a page object'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 PDPageAdditionalActions implements COSObjectable
48 {
49     private COSDictionary actions;
50
51     /**
52      * Default constructor.
53      */

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

64     public PDPageAdditionalActions( 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 page
91      * is opened. This action is independent of any that may be
92      * defined by the OpenAction entry in the document catalog,
93      * and is executed after such an action.
94      *
95      * @return The O entry of page object's additional actions dictionary.
96      */

97     public PDAction getO()
98     {
99         COSDictionary o = (COSDictionary)actions.getDictionaryObject( "O" );
100         PDAction retval = null;
101         if( o != null )
102         {
103             retval = PDActionFactory.createAction( o );
104         }
105         return retval;
106     }
107
108     /**
109      * This will set an action to be performed when the page
110      * is opened. This action is independent of any that may be
111      * defined by the OpenAction entry in the document catalog,
112      * and is executed after such an action.
113      *
114      * @param o The action to be performed.
115      */

116     public void setO( PDAction o )
117     {
118         actions.setItem( "O", o );
119     }
120
121     /**
122      * This will get an action to be performed when the page
123      * is closed. This action applies to the page being closed,
124      * and is executed before any other page opened.
125      *
126      * @return The C entry of page object's additional actions dictionary.
127      */

128     public PDAction getC()
129     {
130         COSDictionary c = (COSDictionary)actions.getDictionaryObject( "C" );
131         PDAction retval = null;
132         if( c != null )
133         {
134             retval = PDActionFactory.createAction( c );
135         }
136         return retval;
137     }
138
139     /**
140      * This will set an action to be performed when the page
141      * is closed. This action applies to the page being closed,
142      * and is executed before any other page opened.
143      *
144      * @param c The action to be performed.
145      */

146     public void setC( PDAction c )
147     {
148         actions.setItem( "C", c );
149     }
150 }
Popular Tags