KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > PdfTransition


1 /*
2  * Copyright 2002 by Josselin PUJO.
3  *
4  * The contents of this file are subject to the Mozilla Public License Version 1.1
5  * (the "License"); you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the License.
11  *
12  * The Original Code is 'iText, a free JAVA-PDF library'.
13  *
14  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
15  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
16  * All Rights Reserved.
17  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
18  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
19  *
20  * Contributor(s): all the names of the contributors are added in the source code
21  * where applicable.
22  *
23  * Alternatively, the contents of this file may be used under the terms of the
24  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
25  * provisions of LGPL are applicable instead of those above. If you wish to
26  * allow use of your version of this file only under the terms of the LGPL
27  * License and not to allow others to use your version of this file under
28  * the MPL, indicate your decision by deleting the provisions above and
29  * replace them with the notice and other provisions required by the LGPL.
30  * If you do not delete the provisions above, a recipient may use your version
31  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
32  *
33  * This library is free software; you can redistribute it and/or modify it
34  * under the terms of the MPL as stated above or under the terms of the GNU
35  * Library General Public License as published by the Free Software Foundation;
36  * either version 2 of the License, or any later version.
37  *
38  * This library is distributed in the hope that it will be useful, but WITHOUT
39  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
40  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
41  * details.
42  *
43  * If you didn't download this code from the following link, you should check if
44  * you aren't using an obsolete version:
45  * http://www.lowagie.com/iText/
46  */

47
48 package com.lowagie.text.pdf;
49
50 public class PdfTransition {
51     /**
52      * Out Vertical Split
53      */

54     public static final int SPLITVOUT = 1;
55     /**
56      * Out Horizontal Split
57      */

58     public static final int SPLITHOUT = 2;
59     /**
60      * In Vertical Split
61      */

62     public static final int SPLITVIN = 3;
63     /**
64      * IN Horizontal Split
65      */

66     public static final int SPLITHIN = 4;
67     /**
68      * Vertical Blinds
69      */

70     public static final int BLINDV = 5;
71     /**
72      * Vertical Blinds
73      */

74     public static final int BLINDH = 6;
75     /**
76      * Inward Box
77      */

78     public static final int INBOX = 7;
79     /**
80      * Outward Box
81      */

82     public static final int OUTBOX = 8;
83     /**
84      * Left-Right Wipe
85      */

86     public static final int LRWIPE = 9;
87     /**
88      * Right-Left Wipe
89      */

90     public static final int RLWIPE = 10;
91     /**
92      * Bottom-Top Wipe
93      */

94     public static final int BTWIPE = 11;
95     /**
96      * Top-Bottom Wipe
97      */

98     public static final int TBWIPE = 12;
99     /**
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     
154     public int getDuration() {
155         return duration;
156     }
157     
158     
159     public int getType() {
160         return type;
161     }
162     
163     public PdfDictionary getTransitionDictionary() {
164         PdfDictionary trans = new PdfDictionary(PdfName.TRANS);
165         switch (type) {
166             case SPLITVOUT:
167                 trans.put(PdfName.S,PdfName.SPLIT);
168                 trans.put(PdfName.D,new PdfNumber(duration));
169                 trans.put(PdfName.DM,PdfName.V);
170                 trans.put(PdfName.M,PdfName.O);
171                 break;
172             case SPLITHOUT:
173                 trans.put(PdfName.S,PdfName.SPLIT);
174                 trans.put(PdfName.D,new PdfNumber(duration));
175                 trans.put(PdfName.DM,PdfName.H);
176                 trans.put(PdfName.M,PdfName.O);
177                 break;
178             case SPLITVIN:
179                 trans.put(PdfName.S,PdfName.SPLIT);
180                 trans.put(PdfName.D,new PdfNumber(duration));
181                 trans.put(PdfName.DM,PdfName.V);
182                 trans.put(PdfName.M,PdfName.I);
183                 break;
184             case SPLITHIN:
185                 trans.put(PdfName.S,PdfName.SPLIT);
186                 trans.put(PdfName.D,new PdfNumber(duration));
187                 trans.put(PdfName.DM,PdfName.H);
188                 trans.put(PdfName.M,PdfName.I);
189                 break;
190             case BLINDV:
191                 trans.put(PdfName.S,PdfName.BLINDS);
192                 trans.put(PdfName.D,new PdfNumber(duration));
193                 trans.put(PdfName.DM,PdfName.V);
194                 break;
195             case BLINDH:
196                 trans.put(PdfName.S,PdfName.BLINDS);
197                 trans.put(PdfName.D,new PdfNumber(duration));
198                 trans.put(PdfName.DM,PdfName.H);
199                 break;
200             case INBOX:
201                 trans.put(PdfName.S,PdfName.BOX);
202                 trans.put(PdfName.D,new PdfNumber(duration));
203                 trans.put(PdfName.M,PdfName.I);
204                 break;
205             case OUTBOX:
206                 trans.put(PdfName.S,PdfName.BOX);
207                 trans.put(PdfName.D,new PdfNumber(duration));
208                 trans.put(PdfName.M,PdfName.O);
209                 break;
210             case LRWIPE:
211                 trans.put(PdfName.S,PdfName.WIPE);
212                 trans.put(PdfName.D,new PdfNumber(duration));
213                 trans.put(PdfName.DI,new PdfNumber(0));
214                 break;
215             case RLWIPE:
216                 trans.put(PdfName.S,PdfName.WIPE);
217                 trans.put(PdfName.D,new PdfNumber(duration));
218                 trans.put(PdfName.DI,new PdfNumber(180));
219                 break;
220             case BTWIPE:
221                 trans.put(PdfName.S,PdfName.WIPE);
222                 trans.put(PdfName.D,new PdfNumber(duration));
223                 trans.put(PdfName.DI,new PdfNumber(90));
224                 break;
225             case TBWIPE:
226                 trans.put(PdfName.S,PdfName.WIPE);
227                 trans.put(PdfName.D,new PdfNumber(duration));
228                 trans.put(PdfName.DI,new PdfNumber(270));
229                 break;
230             case DISSOLVE:
231                 trans.put(PdfName.S,PdfName.DISSOLVE);
232                 trans.put(PdfName.D,new PdfNumber(duration));
233                 break;
234             case LRGLITTER:
235                 trans.put(PdfName.S,PdfName.GLITTER);
236                 trans.put(PdfName.D,new PdfNumber(duration));
237                 trans.put(PdfName.DI,new PdfNumber(0));
238                 break;
239             case TBGLITTER:
240                 trans.put(PdfName.S,PdfName.GLITTER);
241                 trans.put(PdfName.D,new PdfNumber(duration));
242                 trans.put(PdfName.DI,new PdfNumber(270));
243                 break;
244             case DGLITTER:
245                 trans.put(PdfName.S,PdfName.GLITTER);
246                 trans.put(PdfName.D,new PdfNumber(duration));
247                 trans.put(PdfName.DI,new PdfNumber(315));
248                 break;
249         }
250         return trans;
251     }
252 }
253
254
Popular Tags