]> _ Git - cubeextranet.git/blob
5351df799ac058da15fc99d4ded65ee9f5b13b31
[cubeextranet.git] /
1 /*\r
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
8  *\r
9  *      http://www.apache.org/licenses/LICENSE-2.0\r
10  *\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
16  */\r
17 package org.apache.pdfbox.pdmodel.interactive.annotation;\r
18 \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
22 \r
23 /**\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
26  *\r
27  * @author Paul King\r
28  * @version $Revision: 1.1 $\r
29  */\r
30 public class PDAnnotationTextMarkup extends PDAnnotationMarkup\r
31 {\r
32 \r
33     /**\r
34      * The types of annotation.\r
35      */\r
36     public static final String SUB_TYPE_HIGHLIGHT = "Highlight";\r
37     /**\r
38      * The types of annotation.\r
39      */\r
40     public static final String SUB_TYPE_UNDERLINE = "Underline";\r
41     /**\r
42      * The types of annotation.\r
43      */\r
44     public static final String SUB_TYPE_SQUIGGLY = "Squiggly";\r
45     /**\r
46      * The types of annotation.\r
47      */\r
48     public static final String SUB_TYPE_STRIKEOUT = "StrikeOut";\r
49 \r
50 \r
51     private PDAnnotationTextMarkup()\r
52     {\r
53         // Must be constructed with a subType or dictionary parameter\r
54     }\r
55 \r
56     /**\r
57      * Creates a TextMarkup annotation of the specified sub type.\r
58      *\r
59      * @param subType the subtype the annotation represents\r
60      */\r
61     public PDAnnotationTextMarkup(String subType)\r
62     {\r
63         super();\r
64         setSubtype( subType );\r
65 \r
66         // Quad points are required, set and empty array\r
67         setQuadPoints( new float[0] );\r
68     }\r
69 \r
70     /**\r
71      * Creates a TextMarkup annotation from a COSDictionary, expected to be a\r
72      * correct object definition.\r
73      *\r
74      * @param field the PDF objet to represent as a field.\r
75      */\r
76     public PDAnnotationTextMarkup( COSDictionary field )\r
77     {\r
78         super( field );\r
79     }\r
80 \r
81     /**\r
82      * This will set the set of quadpoints which encompass the areas of this\r
83      * annotation.\r
84      *\r
85      * @param quadPoints\r
86      *            an array representing the set of area covered\r
87      */\r
88     public void setQuadPoints( float[] quadPoints )\r
89     {\r
90         COSArray newQuadPoints = new COSArray();\r
91         newQuadPoints.setFloatArray( quadPoints );\r
92         getDictionary().setItem( "QuadPoints", newQuadPoints );\r
93     }\r
94 \r
95     /**\r
96      * This will retrieve the set of quadpoints which encompass the areas of\r
97      * this annotation.\r
98      *\r
99      * @return An array of floats representing the quad points.\r
100      */\r
101     public float[] getQuadPoints()\r
102     {\r
103         COSArray quadPoints = (COSArray) getDictionary().getDictionaryObject( "QuadPoints" );\r
104         if (quadPoints != null)\r
105         {\r
106             return quadPoints.toFloatArray();\r
107         }\r
108         else\r
109         {\r
110             return null; // Should never happen as this is a required item\r
111         }\r
112     }\r
113 \r
114     /**\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
117      *\r
118      * @param subType The subtype of the annotation\r
119      */\r
120     public void setSubtype( String subType )\r
121     {\r
122         getDictionary().setName( COSName.SUBTYPE, subType );\r
123     }\r
124 \r
125     /**\r
126      * This will retrieve the sub type (and hence appearance, AP taking precedence)\r
127      * For this annotation.\r
128      *\r
129      * @return The subtype of this annotation, see the SUB_TYPE_XXX constants.\r
130      */\r
131     public String getSubtype()\r
132     {\r
133         return getDictionary().getNameAsString( COSName.SUBTYPE);\r
134     }\r
135 \r
136 \r
137 }\r