KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > annotation > PDAnnotationSquareCircle


1 /**
2  * Copyright (c) 2005, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.interactive.annotation;
32
33 import org.pdfbox.cos.COSArray;
34 import org.pdfbox.cos.COSDictionary;
35 import org.pdfbox.cos.COSName;
36 import org.pdfbox.pdmodel.graphics.color.PDGamma;
37 import org.pdfbox.pdmodel.common.PDRectangle;
38
39 /**
40  * This is the class that represents a rectangular or eliptical annotation
41  * Introduced in PDF 1.3 specification .
42  *
43  * @author Paul King
44  * @version $Revision: 1.1 $
45  */

46 public class PDAnnotationSquareCircle extends PDAnnotationMarkup
47 {
48
49     /**
50      * Constant for a Rectangular type of annotation.
51      */

52     public static final String JavaDoc SUB_TYPE_SQUARE = "Square";
53     /**
54      * Constant for an Eliptical type of annotation.
55      */

56     public static final String JavaDoc SUB_TYPE_CIRCLE = "Circle";
57
58     private PDAnnotationSquareCircle()
59     {
60         // Must be constructed with a subType or dictionary parameter
61
}
62
63     
64     /**
65      * Creates a Circle or Square annotation of the specified sub type.
66      *
67      * @param subType the subtype the annotation represents.
68          */

69     public PDAnnotationSquareCircle( String JavaDoc subType )
70     {
71         super();
72         setSubtype( subType );
73     }
74
75     /**
76      * Creates a Line annotation from a COSDictionary, expected to be a correct
77      * object definition.
78      *
79      * @param field
80      * the PDF objet to represent as a field.
81      */

82     public PDAnnotationSquareCircle( COSDictionary field )
83     {
84         super( field );
85     }
86
87
88     /**
89      * This will set interior colour of the drawn area
90      * Colour is in DeviceRGB colourspace.
91      *
92      * @param ic
93      * colour in the DeviceRGB colourspace.
94      *
95      */

96     public void setInteriorColour( PDGamma ic )
97     {
98         getDictionary().setItem( "IC", ic );
99     }
100
101     /**
102      * This will retrieve the interior colour of the drawn area
103      * Colour is in DeviceRGB colourspace.
104      *
105      *
106      * @return PDGamma object representing the colour.
107      *
108      */

109     public PDGamma getInteriorColour()
110     {
111
112         COSArray ic = (COSArray) getDictionary().getItem(
113                 COSName.getPDFName( "IC" ) );
114         if (ic != null)
115         {
116             return new PDGamma( ic );
117         }
118         else
119         {
120             return null;
121         }
122     }
123
124
125     /**
126      * This will set the border effect dictionary, specifying effects to be applied
127      * when drawing the line.
128      *
129      * @param be The border effect dictionary to set.
130      *
131      */

132     public void setBorderEffect( PDBorderEffectDictionary be )
133     {
134         getDictionary().setItem( "BE", be );
135     }
136
137     /**
138      * This will retrieve the border effect dictionary, specifying effects to be
139      * applied used in drawing the line.
140      *
141      * @return The border effect dictionary
142      */

143     public PDBorderEffectDictionary getBorderEffect()
144     {
145         COSDictionary be = (COSDictionary) getDictionary().getDictionaryObject( "BE" );
146         if (be != null)
147         {
148             return new PDBorderEffectDictionary( be );
149         }
150         else
151         {
152             return null;
153         }
154     }
155
156     /**
157      * This will set the rectangle difference rectangle. Giving the difference
158      * between the annotations rectangle and where the drawing occurs.
159          * (To take account of any effects applied through the BE entry forexample)
160      *
161      * @param rd the rectangle difference
162      *
163      */

164     public void setRectDifference( PDRectangle rd )
165     {
166         getDictionary().setItem( "RD", rd );
167     }
168
169     /**
170      * This will get the rectangle difference rectangle. Giving the difference
171      * between the annotations rectangle and where the drawing occurs.
172          * (To take account of any effects applied through the BE entry forexample)
173      *
174      * @return the rectangle difference
175      */

176     public PDRectangle getRectDifference()
177     {
178         COSArray rd = (COSArray) getDictionary().getDictionaryObject( "RD" );
179         if (rd != null)
180         {
181             return new PDRectangle( rd );
182         }
183         else
184         {
185             return null;
186         }
187     }
188
189     /**
190      * This will set the sub type (and hence appearance, AP taking precedence) For
191      * this annotation. See the SUB_TYPE_XXX constants for valid values.
192      *
193      * @param subType The subtype of the annotation
194      */

195     public void setSubtype( String JavaDoc subType )
196     {
197         getDictionary().setName( COSName.SUBTYPE, subType );
198     }
199
200     /**
201      * This will retrieve the sub type (and hence appearance, AP taking precedence)
202      * For this annotation.
203      *
204      * @return The subtype of this annotation, see the SUB_TYPE_XXX constants.
205      */

206     public String JavaDoc getSubtype()
207     {
208         return getDictionary().getNameAsString( COSName.SUBTYPE);
209     }
210
211 }
Popular Tags