2 * Licensed to the Apache Software Foundation (ASF) under one or more
\r
3 * contributor license agreements. See the NOTICE file distributed with
\r
4 * this work for additional information regarding copyright ownership.
\r
5 * The ASF licenses this file to You under the Apache License, Version 2.0
\r
6 * (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 package org.apache.pdfbox.pdmodel.interactive.annotation;
\r
19 import org.apache.pdfbox.cos.COSDictionary;
\r
20 import org.apache.pdfbox.cos.COSArray;
\r
21 import org.apache.pdfbox.cos.COSName;
\r
24 * This is the abstract class that represents a text markup annotation
\r
25 * Introduced in PDF 1.3 specification, except Squiggly lines in 1.4.
\r
28 * @version $Revision: 1.1 $
\r
30 public class PDAnnotationTextMarkup extends PDAnnotationMarkup
\r
34 * The types of annotation.
\r
36 public static final String SUB_TYPE_HIGHLIGHT = "Highlight";
\r
38 * The types of annotation.
\r
40 public static final String SUB_TYPE_UNDERLINE = "Underline";
\r
42 * The types of annotation.
\r
44 public static final String SUB_TYPE_SQUIGGLY = "Squiggly";
\r
46 * The types of annotation.
\r
48 public static final String SUB_TYPE_STRIKEOUT = "StrikeOut";
\r
51 private PDAnnotationTextMarkup()
\r
53 // Must be constructed with a subType or dictionary parameter
\r
57 * Creates a TextMarkup annotation of the specified sub type.
\r
59 * @param subType the subtype the annotation represents
\r
61 public PDAnnotationTextMarkup(String subType)
\r
64 setSubtype( subType );
\r
66 // Quad points are required, set and empty array
\r
67 setQuadPoints( new float[0] );
\r
71 * Creates a TextMarkup annotation from a COSDictionary, expected to be a
\r
72 * correct object definition.
\r
74 * @param field the PDF objet to represent as a field.
\r
76 public PDAnnotationTextMarkup( COSDictionary field )
\r
82 * This will set the set of quadpoints which encompass the areas of this
\r
86 * an array representing the set of area covered
\r
88 public void setQuadPoints( float[] quadPoints )
\r
90 COSArray newQuadPoints = new COSArray();
\r
91 newQuadPoints.setFloatArray( quadPoints );
\r
92 getDictionary().setItem( "QuadPoints", newQuadPoints );
\r
96 * This will retrieve the set of quadpoints which encompass the areas of
\r
99 * @return An array of floats representing the quad points.
\r
101 public float[] getQuadPoints()
\r
103 COSArray quadPoints = (COSArray) getDictionary().getDictionaryObject( "QuadPoints" );
\r
104 if (quadPoints != null)
\r
106 return quadPoints.toFloatArray();
\r
110 return null; // Should never happen as this is a required item
\r
115 * This will set the sub type (and hence appearance, AP taking precedence) For
\r
116 * this annotation. See the SUB_TYPE_XXX constants for valid values.
\r
118 * @param subType The subtype of the annotation
\r
120 public void setSubtype( String subType )
\r
122 getDictionary().setName( COSName.SUBTYPE, subType );
\r
126 * This will retrieve the sub type (and hence appearance, AP taking precedence)
\r
127 * For this annotation.
\r
129 * @return The subtype of this annotation, see the SUB_TYPE_XXX constants.
\r
131 public String getSubtype()
\r
133 return getDictionary().getNameAsString( COSName.SUBTYPE);
\r