001: /**
002: * Copyright (c) 2004, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.interactive.action;
031:
032: import org.pdfbox.cos.COSBase;
033: import org.pdfbox.cos.COSDictionary;
034:
035: import org.pdfbox.pdmodel.common.COSObjectable;
036: import org.pdfbox.pdmodel.interactive.action.type.PDAction;
037:
038: /**
039: * This class represents an annotation's dictionary of actions
040: * that occur due to events.
041: *
042: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
043: * @author Panagiotis Toumasis (ptoumasis@mail.gr)
044: * @version $Revision: 1.2 $
045: */
046: public class PDAnnotationAdditionalActions implements COSObjectable {
047: private COSDictionary actions;
048:
049: /**
050: * Default constructor.
051: */
052: public PDAnnotationAdditionalActions() {
053: actions = new COSDictionary();
054: }
055:
056: /**
057: * Constructor.
058: *
059: * @param a The action dictionary.
060: */
061: public PDAnnotationAdditionalActions(COSDictionary a) {
062: actions = a;
063: }
064:
065: /**
066: * Convert this standard java object to a COS object.
067: *
068: * @return The cos object that matches this Java object.
069: */
070: public COSBase getCOSObject() {
071: return actions;
072: }
073:
074: /**
075: * Convert this standard java object to a COS object.
076: *
077: * @return The cos object that matches this Java object.
078: */
079: public COSDictionary getCOSDictionary() {
080: return actions;
081: }
082:
083: /**
084: * This will get an action to be performed when the cursor
085: * enters the annotation's active area.
086: *
087: * @return The E entry of annotation's additional actions dictionary.
088: */
089: public PDAction getE() {
090: COSDictionary e = (COSDictionary) actions
091: .getDictionaryObject("E");
092: PDAction retval = null;
093: if (e != null) {
094: retval = PDActionFactory.createAction(e);
095: }
096: return retval;
097: }
098:
099: /**
100: * This will set an action to be performed when the cursor
101: * enters the annotation's active area.
102: *
103: * @param e The action to be performed.
104: */
105: public void setE(PDAction e) {
106: actions.setItem("E", e);
107: }
108:
109: /**
110: * This will get an action to be performed when the cursor
111: * exits the annotation's active area.
112: *
113: * @return The X entry of annotation's additional actions dictionary.
114: */
115: public PDAction getX() {
116: COSDictionary x = (COSDictionary) actions
117: .getDictionaryObject("X");
118: PDAction retval = null;
119: if (x != null) {
120: retval = PDActionFactory.createAction(x);
121: }
122: return retval;
123: }
124:
125: /**
126: * This will set an action to be performed when the cursor
127: * exits the annotation's active area.
128: *
129: * @param x The action to be performed.
130: */
131: public void setX(PDAction x) {
132: actions.setItem("X", x);
133: }
134:
135: /**
136: * This will get an action to be performed when the mouse button
137: * is pressed inside the annotation's active area.
138: * The name D stands for "down".
139: *
140: * @return The d entry of annotation's additional actions dictionary.
141: */
142: public PDAction getD() {
143: COSDictionary d = (COSDictionary) actions
144: .getDictionaryObject("D");
145: PDAction retval = null;
146: if (d != null) {
147: retval = PDActionFactory.createAction(d);
148: }
149: return retval;
150: }
151:
152: /**
153: * This will set an action to be performed when the mouse button
154: * is pressed inside the annotation's active area.
155: * The name D stands for "down".
156: *
157: * @param d The action to be performed.
158: */
159: public void setD(PDAction d) {
160: actions.setItem("D", d);
161: }
162:
163: /**
164: * This will get an action to be performed when the mouse button
165: * is released inside the annotation's active area.
166: * The name U stands for "up".
167: *
168: * @return The U entry of annotation's additional actions dictionary.
169: */
170: public PDAction getU() {
171: COSDictionary u = (COSDictionary) actions
172: .getDictionaryObject("U");
173: PDAction retval = null;
174: if (u != null) {
175: retval = PDActionFactory.createAction(u);
176: }
177: return retval;
178: }
179:
180: /**
181: * This will set an action to be performed when the mouse button
182: * is released inside the annotation's active area.
183: * The name U stands for "up".
184: *
185: * @param u The action to be performed.
186: */
187: public void setU(PDAction u) {
188: actions.setItem("U", u);
189: }
190:
191: /**
192: * This will get an action to be performed when the annotation
193: * receives the input focus.
194: *
195: * @return The Fo entry of annotation's additional actions dictionary.
196: */
197: public PDAction getFo() {
198: COSDictionary fo = (COSDictionary) actions
199: .getDictionaryObject("Fo");
200: PDAction retval = null;
201: if (fo != null) {
202: retval = PDActionFactory.createAction(fo);
203: }
204: return retval;
205: }
206:
207: /**
208: * This will set an action to be performed when the annotation
209: * receives the input focus.
210: *
211: * @param fo The action to be performed.
212: */
213: public void setFo(PDAction fo) {
214: actions.setItem("Fo", fo);
215: }
216:
217: /**
218: * This will get an action to be performed when the annotation
219: * loses the input focus.
220: * The name Bl stands for "blurred".
221: *
222: * @return The Bl entry of annotation's additional actions dictionary.
223: */
224: public PDAction getBl() {
225: COSDictionary bl = (COSDictionary) actions
226: .getDictionaryObject("Bl");
227: PDAction retval = null;
228: if (bl != null) {
229: retval = PDActionFactory.createAction(bl);
230: }
231: return retval;
232: }
233:
234: /**
235: * This will set an action to be performed when the annotation
236: * loses the input focus.
237: * The name Bl stands for "blurred".
238: *
239: * @param bl The action to be performed.
240: */
241: public void setBl(PDAction bl) {
242: actions.setItem("Bl", bl);
243: }
244:
245: /**
246: * This will get an action to be performed when the page containing
247: * the annotation is opened. The action is executed after the O action
248: * in the page's additional actions dictionary and the OpenAction entry
249: * in the document catalog, if such actions are present.
250: *
251: * @return The PO entry of annotation's additional actions dictionary.
252: */
253: public PDAction getPO() {
254: COSDictionary po = (COSDictionary) actions
255: .getDictionaryObject("PO");
256: PDAction retval = null;
257: if (po != null) {
258: retval = PDActionFactory.createAction(po);
259: }
260: return retval;
261: }
262:
263: /**
264: * This will set 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: * @param po The action to be performed.
270: */
271: public void setPO(PDAction po) {
272: actions.setItem("PO", po);
273: }
274:
275: /**
276: * This will get an action to be performed when the page containing
277: * the annotation is closed. The action is executed before the C action
278: * in the page's additional actions dictionary, if present.
279: *
280: * @return The PC entry of annotation's additional actions dictionary.
281: */
282: public PDAction getPC() {
283: COSDictionary pc = (COSDictionary) actions
284: .getDictionaryObject("PC");
285: PDAction retval = null;
286: if (pc != null) {
287: retval = PDActionFactory.createAction(pc);
288: }
289: return retval;
290: }
291:
292: /**
293: * This will set an action to be performed when the page containing
294: * the annotation is closed. The action is executed before the C action
295: * in the page's additional actions dictionary, if present.
296: *
297: * @param pc The action to be performed.
298: */
299: public void setPC(PDAction pc) {
300: actions.setItem("PC", pc);
301: }
302:
303: /**
304: * This will get an action to be performed when the page containing
305: * the annotation becomes visible in the viewer application's user interface.
306: *
307: * @return The PV entry of annotation's additional actions dictionary.
308: */
309: public PDAction getPV() {
310: COSDictionary pv = (COSDictionary) actions
311: .getDictionaryObject("PV");
312: PDAction retval = null;
313: if (pv != null) {
314: retval = PDActionFactory.createAction(pv);
315: }
316: return retval;
317: }
318:
319: /**
320: * This will set an action to be performed when the page containing
321: * the annotation becomes visible in the viewer application's user interface.
322: *
323: * @param pv The action to be performed.
324: */
325: public void setPV(PDAction pv) {
326: actions.setItem("PV", pv);
327: }
328:
329: /**
330: * This will get an action to be performed when the page containing the annotation
331: * is no longer visible in the viewer application's user interface.
332: *
333: * @return The PI entry of annotation's additional actions dictionary.
334: */
335: public PDAction getPI() {
336: COSDictionary pi = (COSDictionary) actions
337: .getDictionaryObject("PI");
338: PDAction retval = null;
339: if (pi != null) {
340: retval = PDActionFactory.createAction(pi);
341: }
342: return retval;
343: }
344:
345: /**
346: * This will set an action to be performed when the page containing the annotation
347: * is no longer visible in the viewer application's user interface.
348: *
349: * @param pi The action to be performed.
350: */
351: public void setPI(PDAction pi) {
352: actions.setItem("PI", pi);
353: }
354: }
|