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 2018/05/19 15:19:34 UTC

svn commit: r1831899 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java

Author: tilman
Date: Sat May 19 15:19:34 2018
New Revision: 1831899

URL: http://svn.apache.org/viewvc?rev=1831899&view=rev
Log:
PDFBOX-3353: support /LE array (line start / ending styles)

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java?rev=1831899&r1=1831898&r2=1831899&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationPolyline.java Sat May 19 15:19:34 2018
@@ -20,6 +20,7 @@ import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import static org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLine.LE_NONE;
 import org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDAppearanceHandler;
 import org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDPolylineAppearanceHandler;
 
@@ -55,6 +56,90 @@ public class PDAnnotationPolyline extend
     }
 
     /**
+     * This will set the line ending style for the start point, see the LE_ constants for the possible values.
+     *
+     * @param style The new style.
+     */
+    public void setStartPointEndingStyle(String style)
+    {
+        if (style == null)
+        {
+            style = LE_NONE;
+        }
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        COSArray array;
+        if (!(base instanceof COSArray) || ((COSArray) base).size() == 0)
+        {
+            array = new COSArray();
+            array.add(COSName.getPDFName(style));
+            array.add(COSName.getPDFName(LE_NONE));
+            getCOSObject().setItem(COSName.LE, array);
+        }
+        else
+        {
+            array = (COSArray) base;
+            array.setName(0, style);
+        }
+    }
+
+    /**
+     * This will retrieve the line ending style for the start point, possible values shown in the LE_ constants section.
+     *
+     * @return The ending style for the start point, LE_NONE if missing, never null.
+     */
+    public String getStartPointEndingStyle()
+    {
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        if (base instanceof COSArray && ((COSArray) base).size() >= 2)
+        {
+            return ((COSArray) base).getName(0, LE_NONE);
+        }
+        return LE_NONE;
+    }
+
+    /**
+     * This will set the line ending style for the end point, see the LE_ constants for the possible values.
+     *
+     * @param style The new style.
+     */
+    public void setEndPointEndingStyle(String style)
+    {
+        if (style == null)
+        {
+            style = LE_NONE;
+        }
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        COSArray array;
+        if (!(base instanceof COSArray) || ((COSArray) base).size() < 2)
+        {
+            array = new COSArray();
+            array.add(COSName.getPDFName(LE_NONE));
+            array.add(COSName.getPDFName(style));
+            getCOSObject().setItem(COSName.LE, array);
+        }
+        else
+        {
+            array = (COSArray) base;
+            array.setName(1, style);
+        }
+    }
+
+    /**
+     * This will retrieve the line ending style for the end point, possible values shown in the LE_ constants section.
+     *
+     * @return The ending style for the end point, LE_NONE if missing, never null.
+     */
+    public String getEndPointEndingStyle()
+    {
+        COSBase base = getCOSObject().getDictionaryObject(COSName.LE);
+        if (base instanceof COSArray && ((COSArray) base).size() >= 2)
+        {
+            return ((COSArray) base).getName(1, LE_NONE);
+        }
+        return LE_NONE;
+    }
+
+    /**
      * This will set interior color of the line endings defined in the LE entry.
      *
      * @param ic color.