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