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