You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/02/19 20:41:05 UTC
svn commit: r1660988 - in
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation:
PDTransition.java PDTransitionDimension.java PDTransitionDirection.java
PDTransitionMotion.java PDTransitionStyle.java
Author: tilman
Date: Thu Feb 19 19:41:04 2015
New Revision: 1660988
URL: http://svn.apache.org/r1660988
Log:
PDFBOX-2689: implement page transitions, by Andrea Vacondio
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java (with props)
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java (with props)
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java (with props)
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java (with props)
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java (with props)
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java?rev=1660988&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java Thu Feb 19 19:41:04 2015
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.pagenavigation;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSBoolean;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSFloat;
+import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper;
+
+/**
+ * Represents a page transition as defined in paragraph 12.4.4.1 of PDF 32000-1:2008
+ *
+ * @author Andrea Vacondio
+ *
+ */
+public final class PDTransition extends PDDictionaryWrapper
+{
+
+ /**
+ * creates a new transition with default "replace" style {@link PDTransitionStyle#R}
+ */
+ public PDTransition()
+ {
+ this(PDTransitionStyle.R);
+ }
+
+ /**
+ * creates a new transition with the given style.
+ *
+ * @param style
+ */
+ public PDTransition(PDTransitionStyle style)
+ {
+ super();
+ getCOSDictionary().setName(COSName.TYPE, COSName.TRANS.getName());
+ getCOSDictionary().setName(COSName.S, style.name());
+ }
+
+ /**
+ * creates a new transition for an existing dictionary
+ *
+ * @param dictionary
+ */
+ public PDTransition(COSDictionary dictionary)
+ {
+ super(dictionary);
+ }
+
+ /**
+ * @return the style for this transition
+ * @see PDTransitionStyle#valueOf(String)
+ */
+ public String getStyle()
+ {
+ return getCOSDictionary().getNameAsString(COSName.S, PDTransitionStyle.R.name());
+ }
+
+ /**
+ * @return The dimension in which the specified transition effect shall occur or the default
+ * {@link PDTransitionDimension#H} if no dimension is found.
+ * @see PDTransitionDimension
+ */
+ public String getDimension()
+ {
+ return getCOSDictionary().getNameAsString(COSName.DM, PDTransitionDimension.H.name());
+ }
+
+ /**
+ * Sets the dimension in which the specified transition effect shall occur. Only for {@link PDTransitionStyle#Split}
+ * and {@link PDTransitionStyle#Blinds}.
+ */
+ public void setDimension(PDTransitionDimension dimension)
+ {
+ getCOSDictionary().setName(COSName.DM, dimension.name());
+ }
+
+ /**
+ * @return The direction of motion for the specified transition effect or the default {@link PDTransitionMotion#I}
+ * if no motion is found.
+ * @see PDTransitionMotion
+ */
+ public String getMotion()
+ {
+ return getCOSDictionary().getNameAsString(COSName.M, PDTransitionMotion.I.name());
+ }
+
+ /**
+ * Sets the direction of motion for the specified transition effect. Only for {@link PDTransitionStyle#Split},
+ * {@link PDTransitionStyle#Blinds} and {@link PDTransitionStyle#Fly}.
+ */
+ public void setMotion(PDTransitionMotion motion)
+ {
+ getCOSDictionary().setName(COSName.M, motion.name());
+ }
+
+ /**
+ * @return the direction in which the specified transition effect shall moves. It can be either a {@link COSInteger}
+ * or {@link COSName#NONE}. Default to {@link COSInteger#ZERO}
+ * @see PDTransitionDirection
+ */
+ public COSBase getDirection()
+ {
+ COSBase item = getCOSDictionary().getItem(COSName.DI);
+ if (item == null)
+ {
+ return COSInteger.ZERO;
+ }
+ return item;
+ }
+
+ /**
+ * Sets the direction in which the specified transition effect shall moves. Only for {@link PDTransitionStyle#Wipe},
+ * {@link PDTransitionStyle#Glitter}, {@link PDTransitionStyle#Fly}, {@link PDTransitionStyle#Cover},
+ * {@link PDTransitionStyle#Uncover} and {@link PDTransitionStyle#Push}.
+ */
+ public void setDirection(PDTransitionDirection direction)
+ {
+ getCOSDictionary().setItem(COSName.DI, direction.getCOSBase());
+ }
+
+ /**
+ * @return The duration in seconds of the transition effect or the default 1 if no duration is found.
+ */
+ public float getDuration()
+ {
+ return getCOSDictionary().getFloat(COSName.D, 1);
+ }
+
+ /**
+ * @param duration The duration of the transition effect, in seconds.
+ */
+ public void setDuration(float duration)
+ {
+ getCOSDictionary().setItem(COSName.D, new COSFloat(duration));
+ }
+
+ /**
+ * @return The starting or ending scale at which the changes shall be drawn or the default 1 if no scale is found.
+ * Only for {@link PDTransitionStyle#Fly}.
+ */
+ public float getFlyScale()
+ {
+ return getCOSDictionary().getFloat(COSName.SS, 1);
+ }
+
+ /**
+ * @param scale The starting or ending scale at which the changes shall be drawn. Only for
+ * {@link PDTransitionStyle#Fly}.
+ */
+ public void setFlyScale(float scale)
+ {
+ getCOSDictionary().setItem(COSName.SS, new COSFloat(scale));
+ }
+
+ /**
+ * @return true if the area that shall be flown in is rectangular and opaque. Default is false. Only for
+ * {@link PDTransitionStyle#Fly}.
+ */
+ public boolean isFlyAreaOpaque()
+ {
+ return getCOSDictionary().getBoolean(COSName.B, false);
+ }
+
+ /**
+ * @param opaque If true, the area that shall be flown in is rectangular and opaque. Only for
+ * {@link PDTransitionStyle#Fly}.
+ */
+ public void setFlyAreaOpaque(boolean opaque)
+ {
+ getCOSDictionary().setItem(COSName.B, COSBoolean.getBoolean(opaque));
+ }
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransition.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java?rev=1660988&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java Thu Feb 19 19:41:04 2015
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.pagenavigation;
+
+/**
+ * The dimension in which the specified transition effect shall occur. Only for {@link PDTransitionStyle#Split} and
+ * {@link PDTransitionStyle#Blinds}.
+ *
+ * @author Andrea Vacondio
+ *
+ */
+public enum PDTransitionDimension
+{
+ /**
+ * Horizontal
+ */
+ H,
+ /**
+ * Vertical
+ */
+ V;
+
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDimension.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java?rev=1660988&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java Thu Feb 19 19:41:04 2015
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.pagenavigation;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSName;
+
+/**
+ * The direction in which the specified transition effect shall moves, expressed in degrees counterclockwise starting
+ * from a left-to-right direction. Only for {@link PDTransitionStyle#Wipe}, {@link PDTransitionStyle#Glitter},
+ * {@link PDTransitionStyle#Fly}, {@link PDTransitionStyle#Cover}, {@link PDTransitionStyle#Uncover} and
+ * {@link PDTransitionStyle#Push}.
+ *
+ * @author Andrea Vacondio
+ *
+ */
+public enum PDTransitionDirection
+{
+ LEFT_TO_RIGHT(0),
+ /**
+ * Relevant only for the Wipe transition
+ */
+ BOTTOM_TO_TOP(90),
+ /**
+ * Relevant only for the Wipe transition
+ */
+ RIGHT_TO_LEFT(180), TOP_TO_BOTTOM(270),
+ /**
+ * Relevant only for the Glitter transition
+ */
+ TOP_LEFT_TO_BOTTOM_RIGHT(315),
+ /**
+ * Relevant only for the Fly transition when the value of SS is not 1.0
+ */
+ NONE(0)
+ {
+ @Override
+ public COSBase getCOSBase()
+ {
+ return COSName.NONE;
+ }
+ };
+
+ private int degrees;
+
+ private PDTransitionDirection(int degrees)
+ {
+ this.degrees = degrees;
+ }
+
+ /**
+ * @return the value for this direction
+ */
+ public COSBase getCOSBase()
+ {
+ return COSInteger.get(degrees);
+ }
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionDirection.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java?rev=1660988&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java Thu Feb 19 19:41:04 2015
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.pagenavigation;
+
+/**
+ * The direction of motion for the specified transition effect. Only for {@link PDTransitionStyle#Split},
+ * {@link PDTransitionStyle#Blinds} and {@link PDTransitionStyle#Fly}.
+ *
+ * @author Andrea Vacondio
+ *
+ */
+public enum PDTransitionMotion
+{
+ /**
+ * Inward from the edges of the page
+ */
+ I,
+ /**
+ * Outward from the center of the page
+ */
+ O;
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionMotion.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java?rev=1660988&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java Thu Feb 19 19:41:04 2015
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.pagenavigation;
+
+/**
+ * The transition style that shall be used when moving to the page from another during a presentation. Ref. table 162
+ * PDF32000-1:2008
+ *
+ * @author Andrea Vacondio
+ *
+ */
+public enum PDTransitionStyle
+{
+ Split, Blinds, Box, Wipe, Dissolve, Glitter, R, Fly, Push, Cover, Uncover, Fade;
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDTransitionStyle.java
------------------------------------------------------------------------------
svn:eol-style = native