001: /*
002: * Copyright 2002 by Josselin PUJO.
003: *
004: * The contents of this file are subject to the Mozilla Public License Version 1.1
005: * (the "License"); you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
007: *
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
010: * for the specific language governing rights and limitations under the License.
011: *
012: * The Original Code is 'iText, a free JAVA-PDF library'.
013: *
014: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
015: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
016: * All Rights Reserved.
017: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
018: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
019: *
020: * Contributor(s): all the names of the contributors are added in the source code
021: * where applicable.
022: *
023: * Alternatively, the contents of this file may be used under the terms of the
024: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
025: * provisions of LGPL are applicable instead of those above. If you wish to
026: * allow use of your version of this file only under the terms of the LGPL
027: * License and not to allow others to use your version of this file under
028: * the MPL, indicate your decision by deleting the provisions above and
029: * replace them with the notice and other provisions required by the LGPL.
030: * If you do not delete the provisions above, a recipient may use your version
031: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
032: *
033: * This library is free software; you can redistribute it and/or modify it
034: * under the terms of the MPL as stated above or under the terms of the GNU
035: * Library General Public License as published by the Free Software Foundation;
036: * either version 2 of the License, or any later version.
037: *
038: * This library is distributed in the hope that it will be useful, but WITHOUT
039: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
040: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
041: * details.
042: *
043: * If you didn't download this code from the following link, you should check if
044: * you aren't using an obsolete version:
045: * http://www.lowagie.com/iText/
046: */
047:
048: package com.lowagie.text.pdf;
049:
050: public class PdfTransition {
051: /**
052: * Out Vertical Split
053: */
054: public static final int SPLITVOUT = 1;
055: /**
056: * Out Horizontal Split
057: */
058: public static final int SPLITHOUT = 2;
059: /**
060: * In Vertical Split
061: */
062: public static final int SPLITVIN = 3;
063: /**
064: * IN Horizontal Split
065: */
066: public static final int SPLITHIN = 4;
067: /**
068: * Vertical Blinds
069: */
070: public static final int BLINDV = 5;
071: /**
072: * Vertical Blinds
073: */
074: public static final int BLINDH = 6;
075: /**
076: * Inward Box
077: */
078: public static final int INBOX = 7;
079: /**
080: * Outward Box
081: */
082: public static final int OUTBOX = 8;
083: /**
084: * Left-Right Wipe
085: */
086: public static final int LRWIPE = 9;
087: /**
088: * Right-Left Wipe
089: */
090: public static final int RLWIPE = 10;
091: /**
092: * Bottom-Top Wipe
093: */
094: public static final int BTWIPE = 11;
095: /**
096: * Top-Bottom Wipe
097: */
098: public static final int TBWIPE = 12;
099: /**
100: * Dissolve
101: */
102: public static final int DISSOLVE = 13;
103: /**
104: * Left-Right Glitter
105: */
106: public static final int LRGLITTER = 14;
107: /**
108: * Top-Bottom Glitter
109: */
110: public static final int TBGLITTER = 15;
111: /**
112: * Diagonal Glitter
113: */
114: public static final int DGLITTER = 16;
115:
116: /**
117: * duration of the transition effect
118: */
119: protected int duration;
120: /**
121: * type of the transition effect
122: */
123: protected int type;
124:
125: /**
126: * Constructs a <CODE>Transition</CODE>.
127: *
128: */
129: public PdfTransition() {
130: this (BLINDH);
131: }
132:
133: /**
134: * Constructs a <CODE>Transition</CODE>.
135: *
136: *@param type type of the transition effect
137: */
138: public PdfTransition(int type) {
139: this (type, 1);
140: }
141:
142: /**
143: * Constructs a <CODE>Transition</CODE>.
144: *
145: *@param type type of the transition effect
146: *@param duration duration of the transition effect
147: */
148: public PdfTransition(int type, int duration) {
149: this .duration = duration;
150: this .type = type;
151: }
152:
153: public int getDuration() {
154: return duration;
155: }
156:
157: public int getType() {
158: return type;
159: }
160:
161: public PdfDictionary getTransitionDictionary() {
162: PdfDictionary trans = new PdfDictionary(PdfName.TRANS);
163: switch (type) {
164: case SPLITVOUT:
165: trans.put(PdfName.S, PdfName.SPLIT);
166: trans.put(PdfName.D, new PdfNumber(duration));
167: trans.put(PdfName.DM, PdfName.V);
168: trans.put(PdfName.M, PdfName.O);
169: break;
170: case SPLITHOUT:
171: trans.put(PdfName.S, PdfName.SPLIT);
172: trans.put(PdfName.D, new PdfNumber(duration));
173: trans.put(PdfName.DM, PdfName.H);
174: trans.put(PdfName.M, PdfName.O);
175: break;
176: case SPLITVIN:
177: trans.put(PdfName.S, PdfName.SPLIT);
178: trans.put(PdfName.D, new PdfNumber(duration));
179: trans.put(PdfName.DM, PdfName.V);
180: trans.put(PdfName.M, PdfName.I);
181: break;
182: case SPLITHIN:
183: trans.put(PdfName.S, PdfName.SPLIT);
184: trans.put(PdfName.D, new PdfNumber(duration));
185: trans.put(PdfName.DM, PdfName.H);
186: trans.put(PdfName.M, PdfName.I);
187: break;
188: case BLINDV:
189: trans.put(PdfName.S, PdfName.BLINDS);
190: trans.put(PdfName.D, new PdfNumber(duration));
191: trans.put(PdfName.DM, PdfName.V);
192: break;
193: case BLINDH:
194: trans.put(PdfName.S, PdfName.BLINDS);
195: trans.put(PdfName.D, new PdfNumber(duration));
196: trans.put(PdfName.DM, PdfName.H);
197: break;
198: case INBOX:
199: trans.put(PdfName.S, PdfName.BOX);
200: trans.put(PdfName.D, new PdfNumber(duration));
201: trans.put(PdfName.M, PdfName.I);
202: break;
203: case OUTBOX:
204: trans.put(PdfName.S, PdfName.BOX);
205: trans.put(PdfName.D, new PdfNumber(duration));
206: trans.put(PdfName.M, PdfName.O);
207: break;
208: case LRWIPE:
209: trans.put(PdfName.S, PdfName.WIPE);
210: trans.put(PdfName.D, new PdfNumber(duration));
211: trans.put(PdfName.DI, new PdfNumber(0));
212: break;
213: case RLWIPE:
214: trans.put(PdfName.S, PdfName.WIPE);
215: trans.put(PdfName.D, new PdfNumber(duration));
216: trans.put(PdfName.DI, new PdfNumber(180));
217: break;
218: case BTWIPE:
219: trans.put(PdfName.S, PdfName.WIPE);
220: trans.put(PdfName.D, new PdfNumber(duration));
221: trans.put(PdfName.DI, new PdfNumber(90));
222: break;
223: case TBWIPE:
224: trans.put(PdfName.S, PdfName.WIPE);
225: trans.put(PdfName.D, new PdfNumber(duration));
226: trans.put(PdfName.DI, new PdfNumber(270));
227: break;
228: case DISSOLVE:
229: trans.put(PdfName.S, PdfName.DISSOLVE);
230: trans.put(PdfName.D, new PdfNumber(duration));
231: break;
232: case LRGLITTER:
233: trans.put(PdfName.S, PdfName.GLITTER);
234: trans.put(PdfName.D, new PdfNumber(duration));
235: trans.put(PdfName.DI, new PdfNumber(0));
236: break;
237: case TBGLITTER:
238: trans.put(PdfName.S, PdfName.GLITTER);
239: trans.put(PdfName.D, new PdfNumber(duration));
240: trans.put(PdfName.DI, new PdfNumber(270));
241: break;
242: case DGLITTER:
243: trans.put(PdfName.S, PdfName.GLITTER);
244: trans.put(PdfName.D, new PdfNumber(duration));
245: trans.put(PdfName.DI, new PdfNumber(315));
246: break;
247: }
248: return trans;
249: }
250: }
|