Re: svn commit: r1745651 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java

2016-05-29 Thread Andreas Lehmkuehler


Am 27.05.2016 um 18:23 schrieb Maruan Sahyoun:

Hi,



Maruan Sahyoun

Am 27.05.2016 um 16:55 schrieb Andreas Lehmkuehler :

Hi,

looks like something is mixed up, PDFBOX-3364 is already resolved and the 
commit doesn't seem to fit in, or do I miss something? The same for r1745641


these should have gone to PDFBOX-3353

I've moved both comments and fixed the commit logs

BR
Andreas





BR
Andreas


Am 26.05.2016 um 23:34 schrieb msahy...@apache.org:
Author: msahyoun
Date: Thu May 26 21:34:19 2016
New Revision: 1745651

URL: http://svn.apache.org/viewvc?rev=1745651&view=rev
Log:
PDFBOX-3364: add handler for polygon annotation appearances

Added:
   
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
   (with props)

Added: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java?rev=1745651&view=auto
==
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
 (added)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
 Thu May 26 21:34:19 2016
@@ -0,0 +1,195 @@
+/*
+ * 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.annotation.handlers;
+
+import java.io.IOException;
+
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
+import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
+import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
+
+/**
+ * Handler to generate the polygon annotations appearance.
+ *
+ */
+public class PDPolygonAppearanceHandler extends PDAbstractAppearanceHandler
+{
+
+public PDPolygonAppearanceHandler(PDAnnotation annotation)
+{
+super(annotation);
+}
+
+@Override
+public void generateAppearanceStreams()
+{
+generateNormalAppearance();
+generateRolloverAppearance();
+generateDownAppearance();
+}
+
+@Override
+public void generateNormalAppearance()
+{
+// Adobe doesn't generate an appearance for a link annotation
+float lineWidth = getLineWidth();
+try
+{
+PDAnnotation annotation = getAnnotation();
+PDAppearanceContentStream contentStream = 
getNormalAppearanceAsContentStream();
+;
+contentStream.setStrokingColorOnDemand(getColor());
+
+// TODO: handle opacity settings
+
+contentStream.setBorderLine(lineWidth, ((PDAnnotationMarkup) 
annotation).getBorderStyle());
+
+// the differences rectangle
+// TODO: this only works for border effect solid. Cloudy needs a
+// different approach.
+setRectDifference(lineWidth);
+
+// Acrobat applies a padding to each side of the bbox so the line 
is
+// completely within
+// the bbox.
+
+// PDF 2.0: Path takes priority over Vertices
+COSBase path = 
annotation.getCOSObject().getDictionaryObject(COSName.getPDFName("Path"));
+if (path instanceof COSArray)
+{
+COSArray pathArray = (COSArray) path;
+for (int i = 0; i < pathArray.size(); i++)
+{
+COSBase points = pathArray.get(i);
+if (points instanceof COSArray)
+{
+float[] pointsArray = ((COSArray) 
points).toFloatArray();
+// first array shall be of size 2 a

Re: svn commit: r1745651 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java

2016-05-27 Thread Maruan Sahyoun
Hi,



Maruan Sahyoun
> Am 27.05.2016 um 16:55 schrieb Andreas Lehmkuehler :
> 
> Hi,
> 
> looks like something is mixed up, PDFBOX-3364 is already resolved and the 
> commit doesn't seem to fit in, or do I miss something? The same for r1745641

these should have gone to PDFBOX-3353


> 
> BR
> Andreas
> 
>> Am 26.05.2016 um 23:34 schrieb msahy...@apache.org:
>> Author: msahyoun
>> Date: Thu May 26 21:34:19 2016
>> New Revision: 1745651
>> 
>> URL: http://svn.apache.org/viewvc?rev=1745651&view=rev
>> Log:
>> PDFBOX-3364: add handler for polygon annotation appearances
>> 
>> Added:
>>
>> pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
>>(with props)
>> 
>> Added: 
>> pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
>> URL: 
>> http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java?rev=1745651&view=auto
>> ==
>> --- 
>> pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
>>  (added)
>> +++ 
>> pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
>>  Thu May 26 21:34:19 2016
>> @@ -0,0 +1,195 @@
>> +/*
>> + * 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.annotation.handlers;
>> +
>> +import java.io.IOException;
>> +
>> +import org.apache.pdfbox.cos.COSArray;
>> +import org.apache.pdfbox.cos.COSBase;
>> +import org.apache.pdfbox.cos.COSName;
>> +import org.apache.pdfbox.cos.COSNumber;
>> +import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
>> +import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
>> +import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
>> +import 
>> org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
>> +import 
>> org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
>> +
>> +/**
>> + * Handler to generate the polygon annotations appearance.
>> + *
>> + */
>> +public class PDPolygonAppearanceHandler extends PDAbstractAppearanceHandler
>> +{
>> +
>> +public PDPolygonAppearanceHandler(PDAnnotation annotation)
>> +{
>> +super(annotation);
>> +}
>> +
>> +@Override
>> +public void generateAppearanceStreams()
>> +{
>> +generateNormalAppearance();
>> +generateRolloverAppearance();
>> +generateDownAppearance();
>> +}
>> +
>> +@Override
>> +public void generateNormalAppearance()
>> +{
>> +// Adobe doesn't generate an appearance for a link annotation
>> +float lineWidth = getLineWidth();
>> +try
>> +{
>> +PDAnnotation annotation = getAnnotation();
>> +PDAppearanceContentStream contentStream = 
>> getNormalAppearanceAsContentStream();
>> +;
>> +contentStream.setStrokingColorOnDemand(getColor());
>> +
>> +// TODO: handle opacity settings
>> +
>> +contentStream.setBorderLine(lineWidth, ((PDAnnotationMarkup) 
>> annotation).getBorderStyle());
>> +
>> +// the differences rectangle
>> +// TODO: this only works for border effect solid. Cloudy needs a
>> +// different approach.
>> +setRectDifference(lineWidth);
>> +
>> +// Acrobat applies a padding to each side of the bbox so the 
>> line is
>> +// completely within
>> +// the bbox.
>> +
>> +// PDF 2.0: Path takes priority over Vertices
>> +COSBase path = 
>> annotation.getCOSObject().getDictionaryObject(COSName.getPDFName("Path"));
>> +if (path instanceof COSArray)
>> +{
>> +COSArray pathArray = (COSArray) path;
>> +for (int i = 0; i < pathArray.size(); i++)
>> +{
>> +COSBas

Re: svn commit: r1745651 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java

2016-05-27 Thread Andreas Lehmkuehler

Hi,

looks like something is mixed up, PDFBOX-3364 is already resolved and the commit 
doesn't seem to fit in, or do I miss something? The same for r1745641


BR
Andreas

Am 26.05.2016 um 23:34 schrieb msahy...@apache.org:

Author: msahyoun
Date: Thu May 26 21:34:19 2016
New Revision: 1745651

URL: http://svn.apache.org/viewvc?rev=1745651&view=rev
Log:
PDFBOX-3364: add handler for polygon annotation appearances

Added:

pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
   (with props)

Added: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java?rev=1745651&view=auto
==
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
 (added)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
 Thu May 26 21:34:19 2016
@@ -0,0 +1,195 @@
+/*
+ * 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.annotation.handlers;
+
+import java.io.IOException;
+
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
+import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
+import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
+
+/**
+ * Handler to generate the polygon annotations appearance.
+ *
+ */
+public class PDPolygonAppearanceHandler extends PDAbstractAppearanceHandler
+{
+
+public PDPolygonAppearanceHandler(PDAnnotation annotation)
+{
+super(annotation);
+}
+
+@Override
+public void generateAppearanceStreams()
+{
+generateNormalAppearance();
+generateRolloverAppearance();
+generateDownAppearance();
+}
+
+@Override
+public void generateNormalAppearance()
+{
+// Adobe doesn't generate an appearance for a link annotation
+float lineWidth = getLineWidth();
+try
+{
+PDAnnotation annotation = getAnnotation();
+PDAppearanceContentStream contentStream = 
getNormalAppearanceAsContentStream();
+;
+contentStream.setStrokingColorOnDemand(getColor());
+
+// TODO: handle opacity settings
+
+contentStream.setBorderLine(lineWidth, ((PDAnnotationMarkup) 
annotation).getBorderStyle());
+
+// the differences rectangle
+// TODO: this only works for border effect solid. Cloudy needs a
+// different approach.
+setRectDifference(lineWidth);
+
+// Acrobat applies a padding to each side of the bbox so the line 
is
+// completely within
+// the bbox.
+
+// PDF 2.0: Path takes priority over Vertices
+COSBase path = 
annotation.getCOSObject().getDictionaryObject(COSName.getPDFName("Path"));
+if (path instanceof COSArray)
+{
+COSArray pathArray = (COSArray) path;
+for (int i = 0; i < pathArray.size(); i++)
+{
+COSBase points = pathArray.get(i);
+if (points instanceof COSArray)
+{
+float[] pointsArray = ((COSArray) 
points).toFloatArray();
+// first array shall be of size 2 and specify the 
moveto
+// operator
+if (i == 0 && pointsArray.length == 2)
+{
+contentStream.moveTo(pointsArray[0], 
pointsArray[1]