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.COSBase;
21 import org.apache.pdfbox.cos.COSDictionary;
22 import org.apache.pdfbox.cos.COSName;
23 import org.apache.pdfbox.cos.COSStream;
24 import org.apache.pdfbox.pdmodel.common.COSObjectable;
25 import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
26 import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm;
29 * This class represents an appearance characteristics dictionary.
31 * @version $Revision: 1.0 $
34 public class PDAppearanceCharacteristicsDictionary implements COSObjectable
37 private COSDictionary dictionary;
42 * @param dict dictionary
44 public PDAppearanceCharacteristicsDictionary(COSDictionary dict)
46 this.dictionary = dict;
51 * returns the dictionary.
52 * @return the dictionary
54 public COSDictionary getDictionary()
56 return this.dictionary;
63 public COSBase getCOSObject()
65 return this.dictionary;
69 * This will retrieve the rotation of the annotation widget.
70 * It must be a multiple of 90. Default is 0
71 * @return the rotation
73 public int getRotation()
75 return this.getDictionary().getInt(COSName.R, 0);
79 * This will set the rotation.
81 * @param rotation the rotation as a multiple of 90
83 public void setRotation(int rotation)
85 this.getDictionary().setInt(COSName.R, rotation);
89 * This will retrieve the border color.
91 * @return the border color.
93 public PDGamma getBorderColour()
95 COSBase c = this.getDictionary().getItem(COSName.getPDFName("BC"));
96 if (c instanceof COSArray)
98 return new PDGamma((COSArray) c);
104 * This will set the border color.
106 * @param c the border color
108 public void setBorderColour(PDGamma c)
110 this.getDictionary().setItem("BC", c);
114 * This will retrieve the background color.
116 * @return the background color.
118 public PDGamma getBackground()
120 COSBase c = this.getDictionary().getItem(COSName.getPDFName("BG"));
121 if (c instanceof COSArray)
123 return new PDGamma((COSArray) c);
129 * This will set the background color.
131 * @param c the background color
133 public void setBackground(PDGamma c)
135 this.getDictionary().setItem("BG", c);
139 * This will retrieve the normal caption.
141 * @return the normal caption.
143 public String getNormalCaption()
145 return this.getDictionary().getString("CA");
149 * This will set the normal caption.
151 * @param caption the normal caption
153 public void setNormalCaption(String caption)
155 this.getDictionary().setString("CA", caption);
159 * This will retrieve the rollover caption.
161 * @return the rollover caption.
163 public String getRolloverCaption()
165 return this.getDictionary().getString("RC");
169 * This will set the rollover caption.
171 * @param caption the rollover caption
173 public void setRolloverCaption(String caption)
175 this.getDictionary().setString("RC", caption);
179 * This will retrieve the alternate caption.
181 * @return the alternate caption.
183 public String getAlternateCaption()
185 return this.getDictionary().getString("AC");
189 * This will set the alternate caption.
191 * @param caption the alternate caption
193 public void setAlternateCaption(String caption)
195 this.getDictionary().setString("AC", caption);
199 * This will retrieve the normal icon.
201 * @return the normal icon.
203 public PDXObjectForm getNormalIcon()
205 COSBase i = this.getDictionary().getDictionaryObject("I");
206 if (i instanceof COSStream)
208 return new PDXObjectForm((COSStream) i);
214 * This will retrieve the rollover icon.
216 * @return the rollover icon
218 public PDXObjectForm getRolloverIcon()
220 COSBase i = this.getDictionary().getDictionaryObject("RI");
221 if (i instanceof COSStream)
223 return new PDXObjectForm((COSStream) i);
229 * This will retrieve the alternate icon.
231 * @return the alternate icon.
233 public PDXObjectForm getAlternateIcon()
235 COSBase i = this.getDictionary().getDictionaryObject("IX");
236 if (i instanceof COSStream)
238 return new PDXObjectForm((COSStream) i);