001/* 002 * $Id: PdfTransition.java 4784 2011-03-15 08:33:00Z blowagie $ 003 * 004 * This file is part of the iText (R) project. 005 * Copyright (c) 1998-2011 1T3XT BVBA 006 * Authors: Bruno Lowagie, Paulo Soares, et al. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU Affero General Public License version 3 010 * as published by the Free Software Foundation with the addition of the 011 * following permission added to Section 15 as permitted in Section 7(a): 012 * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT, 013 * 1T3XT DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 014 * 015 * This program is distributed in the hope that it will be useful, but 016 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 017 * or FITNESS FOR A PARTICULAR PURPOSE. 018 * See the GNU Affero General Public License for more details. 019 * You should have received a copy of the GNU Affero General Public License 020 * along with this program; if not, see http://www.gnu.org/licenses or write to 021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 022 * Boston, MA, 02110-1301 USA, or download the license from the following URL: 023 * http://itextpdf.com/terms-of-use/ 024 * 025 * The interactive user interfaces in modified source and object code versions 026 * of this program must display Appropriate Legal Notices, as required under 027 * Section 5 of the GNU Affero General Public License. 028 * 029 * In accordance with Section 7(b) of the GNU Affero General Public License, 030 * a covered work must retain the producer line in every PDF that is created 031 * or manipulated using iText. 032 * 033 * You can be released from the requirements of the license by purchasing 034 * a commercial license. Buying such a license is mandatory as soon as you 035 * develop commercial activities involving the iText software without 036 * disclosing the source code of your own applications. 037 * These activities include: offering paid services to customers as an ASP, 038 * serving PDFs on the fly in a web application, shipping iText with a closed 039 * source product. 040 * 041 * For more information, please contact iText Software Corp. at this 042 * address: sales@itextpdf.com 043 */ 044package com.itextpdf.text.pdf; 045 046public class PdfTransition { 047 /** 048 * Out Vertical Split 049 */ 050 public static final int SPLITVOUT = 1; 051 /** 052 * Out Horizontal Split 053 */ 054 public static final int SPLITHOUT = 2; 055 /** 056 * In Vertical Split 057 */ 058 public static final int SPLITVIN = 3; 059 /** 060 * IN Horizontal Split 061 */ 062 public static final int SPLITHIN = 4; 063 /** 064 * Vertical Blinds 065 */ 066 public static final int BLINDV = 5; 067 /** 068 * Vertical Blinds 069 */ 070 public static final int BLINDH = 6; 071 /** 072 * Inward Box 073 */ 074 public static final int INBOX = 7; 075 /** 076 * Outward Box 077 */ 078 public static final int OUTBOX = 8; 079 /** 080 * Left-Right Wipe 081 */ 082 public static final int LRWIPE = 9; 083 /** 084 * Right-Left Wipe 085 */ 086 public static final int RLWIPE = 10; 087 /** 088 * Bottom-Top Wipe 089 */ 090 public static final int BTWIPE = 11; 091 /** 092 * Top-Bottom Wipe 093 */ 094 public static final int TBWIPE = 12; 095 /** 096 * Dissolve 097 */ 098 public static final int DISSOLVE = 13; 099 /** 100 * Left-Right Glitter 101 */ 102 public static final int LRGLITTER = 14; 103 /** 104 * Top-Bottom Glitter 105 */ 106 public static final int TBGLITTER = 15; 107 /** 108 * Diagonal Glitter 109 */ 110 public static final int DGLITTER = 16; 111 112 /** 113 * duration of the transition effect 114 */ 115 protected int duration; 116 /** 117 * type of the transition effect 118 */ 119 protected int type; 120 121 /** 122 * Constructs a <CODE>Transition</CODE>. 123 * 124 */ 125 public PdfTransition() { 126 this(BLINDH); 127 } 128 129 /** 130 * Constructs a <CODE>Transition</CODE>. 131 * 132 *@param type type of the transition effect 133 */ 134 public PdfTransition(int type) { 135 this(type,1); 136 } 137 138 /** 139 * Constructs a <CODE>Transition</CODE>. 140 * 141 *@param type type of the transition effect 142 *@param duration duration of the transition effect 143 */ 144 public PdfTransition(int type, int duration) { 145 this.duration = duration; 146 this.type = type; 147 } 148 149 150 public int getDuration() { 151 return duration; 152 } 153 154 155 public int getType() { 156 return type; 157 } 158 159 public PdfDictionary getTransitionDictionary() { 160 PdfDictionary trans = new PdfDictionary(PdfName.TRANS); 161 switch (type) { 162 case SPLITVOUT: 163 trans.put(PdfName.S,PdfName.SPLIT); 164 trans.put(PdfName.D,new PdfNumber(duration)); 165 trans.put(PdfName.DM,PdfName.V); 166 trans.put(PdfName.M,PdfName.O); 167 break; 168 case SPLITHOUT: 169 trans.put(PdfName.S,PdfName.SPLIT); 170 trans.put(PdfName.D,new PdfNumber(duration)); 171 trans.put(PdfName.DM,PdfName.H); 172 trans.put(PdfName.M,PdfName.O); 173 break; 174 case SPLITVIN: 175 trans.put(PdfName.S,PdfName.SPLIT); 176 trans.put(PdfName.D,new PdfNumber(duration)); 177 trans.put(PdfName.DM,PdfName.V); 178 trans.put(PdfName.M,PdfName.I); 179 break; 180 case SPLITHIN: 181 trans.put(PdfName.S,PdfName.SPLIT); 182 trans.put(PdfName.D,new PdfNumber(duration)); 183 trans.put(PdfName.DM,PdfName.H); 184 trans.put(PdfName.M,PdfName.I); 185 break; 186 case BLINDV: 187 trans.put(PdfName.S,PdfName.BLINDS); 188 trans.put(PdfName.D,new PdfNumber(duration)); 189 trans.put(PdfName.DM,PdfName.V); 190 break; 191 case BLINDH: 192 trans.put(PdfName.S,PdfName.BLINDS); 193 trans.put(PdfName.D,new PdfNumber(duration)); 194 trans.put(PdfName.DM,PdfName.H); 195 break; 196 case INBOX: 197 trans.put(PdfName.S,PdfName.BOX); 198 trans.put(PdfName.D,new PdfNumber(duration)); 199 trans.put(PdfName.M,PdfName.I); 200 break; 201 case OUTBOX: 202 trans.put(PdfName.S,PdfName.BOX); 203 trans.put(PdfName.D,new PdfNumber(duration)); 204 trans.put(PdfName.M,PdfName.O); 205 break; 206 case LRWIPE: 207 trans.put(PdfName.S,PdfName.WIPE); 208 trans.put(PdfName.D,new PdfNumber(duration)); 209 trans.put(PdfName.DI,new PdfNumber(0)); 210 break; 211 case RLWIPE: 212 trans.put(PdfName.S,PdfName.WIPE); 213 trans.put(PdfName.D,new PdfNumber(duration)); 214 trans.put(PdfName.DI,new PdfNumber(180)); 215 break; 216 case BTWIPE: 217 trans.put(PdfName.S,PdfName.WIPE); 218 trans.put(PdfName.D,new PdfNumber(duration)); 219 trans.put(PdfName.DI,new PdfNumber(90)); 220 break; 221 case TBWIPE: 222 trans.put(PdfName.S,PdfName.WIPE); 223 trans.put(PdfName.D,new PdfNumber(duration)); 224 trans.put(PdfName.DI,new PdfNumber(270)); 225 break; 226 case DISSOLVE: 227 trans.put(PdfName.S,PdfName.DISSOLVE); 228 trans.put(PdfName.D,new PdfNumber(duration)); 229 break; 230 case LRGLITTER: 231 trans.put(PdfName.S,PdfName.GLITTER); 232 trans.put(PdfName.D,new PdfNumber(duration)); 233 trans.put(PdfName.DI,new PdfNumber(0)); 234 break; 235 case TBGLITTER: 236 trans.put(PdfName.S,PdfName.GLITTER); 237 trans.put(PdfName.D,new PdfNumber(duration)); 238 trans.put(PdfName.DI,new PdfNumber(270)); 239 break; 240 case DGLITTER: 241 trans.put(PdfName.S,PdfName.GLITTER); 242 trans.put(PdfName.D,new PdfNumber(duration)); 243 trans.put(PdfName.DI,new PdfNumber(315)); 244 break; 245 } 246 return trans; 247 } 248} 249