]> _ Git - cubeextranet.git/blob
3cbc9ec1e38f019e9e15cca98c88ec252bb0a763
[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.COSArray;\r
20 import org.apache.pdfbox.cos.COSDictionary;\r
21 import org.apache.pdfbox.cos.COSName;\r
22 import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;\r
23 import org.apache.pdfbox.pdmodel.common.PDRectangle;\r
24 \r
25 /**\r
26  * This is the class that represents a rectangular or eliptical annotation\r
27  * Introduced in PDF 1.3 specification .\r
28  *\r
29  * @author Paul King\r
30  * @version $Revision: 1.1 $\r
31  */\r
32 public class PDAnnotationSquareCircle extends PDAnnotationMarkup\r
33 {\r
34 \r
35     /**\r
36      * Constant for a Rectangular type of annotation.\r
37      */\r
38     public static final String SUB_TYPE_SQUARE = "Square";\r
39     /**\r
40      * Constant for an Eliptical type of annotation.\r
41      */\r
42     public static final String SUB_TYPE_CIRCLE = "Circle";\r
43 \r
44     /**\r
45      * Creates a Circle or Square annotation of the specified sub type.\r
46      *\r
47      * @param subType the subtype the annotation represents.\r
48          */\r
49     public PDAnnotationSquareCircle( String subType )\r
50     {\r
51         super();\r
52         setSubtype( subType );\r
53     }\r
54 \r
55     /**\r
56      * Creates a Line annotation from a COSDictionary, expected to be a correct\r
57      * object definition.\r
58      *\r
59      * @param field\r
60      *            the PDF objet to represent as a field.\r
61      */\r
62     public PDAnnotationSquareCircle( COSDictionary field )\r
63     {\r
64         super( field );\r
65     }\r
66 \r
67 \r
68     /**\r
69      * This will set interior colour of the drawn area\r
70      * Colour is in DeviceRGB colourspace.\r
71      *\r
72      * @param ic\r
73      *            colour in the DeviceRGB colourspace.\r
74      *\r
75      */\r
76     public void setInteriorColour( PDGamma ic )\r
77     {\r
78         getDictionary().setItem( "IC", ic );\r
79     }\r
80 \r
81     /**\r
82      * This will retrieve the interior colour of the drawn area\r
83      * Colour is in DeviceRGB colourspace.\r
84      *\r
85      *\r
86      * @return PDGamma object representing the colour.\r
87      *\r
88      */\r
89     public PDGamma getInteriorColour()\r
90     {\r
91 \r
92         COSArray ic = (COSArray) getDictionary().getItem(\r
93                 COSName.getPDFName( "IC" ) );\r
94         if (ic != null)\r
95         {\r
96             return new PDGamma( ic );\r
97         }\r
98         else\r
99         {\r
100             return null;\r
101         }\r
102     }\r
103 \r
104 \r
105     /**\r
106      * This will set the border effect dictionary, specifying effects to be applied\r
107      * when drawing the line.\r
108      *\r
109      * @param be The border effect dictionary to set.\r
110      *\r
111      */\r
112     public void setBorderEffect( PDBorderEffectDictionary be )\r
113     {\r
114         getDictionary().setItem( "BE", be );\r
115     }\r
116 \r
117     /**\r
118      * This will retrieve the border effect dictionary, specifying effects to be\r
119      * applied used in drawing the line.\r
120      *\r
121      * @return The border effect dictionary\r
122      */\r
123     public PDBorderEffectDictionary getBorderEffect()\r
124     {\r
125         COSDictionary be = (COSDictionary) getDictionary().getDictionaryObject( "BE" );\r
126         if (be != null)\r
127         {\r
128             return new PDBorderEffectDictionary( be );\r
129         }\r
130         else\r
131         {\r
132             return null;\r
133         }\r
134     }\r
135 \r
136     /**\r
137      * This will set the rectangle difference rectangle. Giving the difference\r
138      * between the annotations rectangle and where the drawing occurs.\r
139          * (To take account of any effects applied through the BE entry forexample)\r
140      *\r
141      * @param rd the rectangle difference\r
142      *\r
143      */\r
144     public void setRectDifference( PDRectangle rd )\r
145     {\r
146         getDictionary().setItem( "RD", rd );\r
147     }\r
148 \r
149     /**\r
150      * This will get the rectangle difference rectangle. Giving the difference\r
151      * between the annotations rectangle and where the drawing occurs.\r
152          * (To take account of any effects applied through the BE entry forexample)\r
153      *\r
154      * @return the rectangle difference\r
155      */\r
156     public PDRectangle getRectDifference()\r
157     {\r
158         COSArray rd = (COSArray) getDictionary().getDictionaryObject( "RD" );\r
159         if (rd != null)\r
160         {\r
161             return new PDRectangle( rd );\r
162         }\r
163         else\r
164         {\r
165             return null;\r
166         }\r
167     }\r
168 \r
169     /**\r
170      * This will set the sub type (and hence appearance, AP taking precedence) For\r
171      * this annotation. See the SUB_TYPE_XXX constants for valid values.\r
172      *\r
173      * @param subType The subtype of the annotation\r
174      */\r
175     public void setSubtype( String subType )\r
176     {\r
177         getDictionary().setName( COSName.SUBTYPE, subType );\r
178     }\r
179 \r
180     /**\r
181      * This will retrieve the sub type (and hence appearance, AP taking precedence)\r
182      * For this annotation.\r
183      *\r
184      * @return The subtype of this annotation, see the SUB_TYPE_XXX constants.\r
185      */\r
186     public String getSubtype()\r
187     {\r
188         return getDictionary().getNameAsString( COSName.SUBTYPE);\r
189     }\r
190 \r
191     /**\r
192      * This will set the border style dictionary, specifying the width and dash\r
193      * pattern used in drawing the line.\r
194      *\r
195      * @param bs the border style dictionary to set.\r
196      * TODO not all annotations may have a BS entry\r
197      *\r
198      */\r
199     public void setBorderStyle( PDBorderStyleDictionary bs )\r
200     {\r
201         this.getDictionary().setItem( "BS", bs);\r
202     }\r
203 \r
204     /**\r
205      * This will retrieve the border style dictionary, specifying the width and\r
206      * dash pattern used in drawing the line.\r
207      *\r
208      * @return the border style dictionary.\r
209      * TODO not all annotations may have a BS entry\r
210      */\r
211     public PDBorderStyleDictionary getBorderStyle()\r
212     {\r
213         COSDictionary bs = (COSDictionary) this.getDictionary().getItem(\r
214                 COSName.getPDFName( "BS" ) );\r
215         if (bs != null)\r
216         {\r
217             return new PDBorderStyleDictionary( bs );\r
218         }\r
219         else\r
220         {\r
221             return null;\r
222         }\r
223     }\r
224 \r
225 }\r