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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.apache.pdfbox.pdmodel.interactive.annotation;
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;
26 * This is the class that represents a rectangular or eliptical annotation
27 * Introduced in PDF 1.3 specification .
30 * @version $Revision: 1.1 $
32 public class PDAnnotationSquareCircle extends PDAnnotationMarkup
36 * Constant for a Rectangular type of annotation.
38 public static final String SUB_TYPE_SQUARE = "Square";
40 * Constant for an Eliptical type of annotation.
42 public static final String SUB_TYPE_CIRCLE = "Circle";
45 * Creates a Circle or Square annotation of the specified sub type.
47 * @param subType the subtype the annotation represents.
49 public PDAnnotationSquareCircle( String subType )
52 setSubtype( subType );
56 * Creates a Line annotation from a COSDictionary, expected to be a correct
60 * the PDF objet to represent as a field.
62 public PDAnnotationSquareCircle( COSDictionary field )
69 * This will set interior colour of the drawn area
70 * Colour is in DeviceRGB colourspace.
73 * colour in the DeviceRGB colourspace.
76 public void setInteriorColour( PDGamma ic )
78 getDictionary().setItem( "IC", ic );
82 * This will retrieve the interior colour of the drawn area
83 * Colour is in DeviceRGB colourspace.
86 * @return PDGamma object representing the colour.
89 public PDGamma getInteriorColour()
92 COSArray ic = (COSArray) getDictionary().getItem(
93 COSName.getPDFName( "IC" ) );
96 return new PDGamma( ic );
106 * This will set the border effect dictionary, specifying effects to be applied
107 * when drawing the line.
109 * @param be The border effect dictionary to set.
112 public void setBorderEffect( PDBorderEffectDictionary be )
114 getDictionary().setItem( "BE", be );
118 * This will retrieve the border effect dictionary, specifying effects to be
119 * applied used in drawing the line.
121 * @return The border effect dictionary
123 public PDBorderEffectDictionary getBorderEffect()
125 COSDictionary be = (COSDictionary) getDictionary().getDictionaryObject( "BE" );
128 return new PDBorderEffectDictionary( be );
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)
141 * @param rd the rectangle difference
144 public void setRectDifference( PDRectangle rd )
146 getDictionary().setItem( "RD", rd );
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)
154 * @return the rectangle difference
156 public PDRectangle getRectDifference()
158 COSArray rd = (COSArray) getDictionary().getDictionaryObject( "RD" );
161 return new PDRectangle( rd );
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.
173 * @param subType The subtype of the annotation
175 public void setSubtype( String subType )
177 getDictionary().setName( COSName.SUBTYPE, subType );
181 * This will retrieve the sub type (and hence appearance, AP taking precedence)
182 * For this annotation.
184 * @return The subtype of this annotation, see the SUB_TYPE_XXX constants.
186 public String getSubtype()
188 return getDictionary().getNameAsString( COSName.SUBTYPE);
192 * This will set the border style dictionary, specifying the width and dash
193 * pattern used in drawing the line.
195 * @param bs the border style dictionary to set.
196 * TODO not all annotations may have a BS entry
199 public void setBorderStyle( PDBorderStyleDictionary bs )
201 this.getDictionary().setItem( "BS", bs);
205 * This will retrieve the border style dictionary, specifying the width and
206 * dash pattern used in drawing the line.
208 * @return the border style dictionary.
209 * TODO not all annotations may have a BS entry
211 public PDBorderStyleDictionary getBorderStyle()
213 COSDictionary bs = (COSDictionary) this.getDictionary().getItem(
214 COSName.getPDFName( "BS" ) );
217 return new PDBorderStyleDictionary( bs );