]> _ Git - cubeextranet.git/blob
3dc1e55450ac9584f6948dc8300728e4c8661b95
[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.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;
27
28 /**
29  * This class represents an appearance characteristics dictionary.
30  *
31  * @version $Revision: 1.0 $ 
32  *
33  */
34 public class PDAppearanceCharacteristicsDictionary implements COSObjectable
35 {
36
37     private COSDictionary dictionary;
38
39     /**
40      * Constructor.
41      * 
42      * @param dict dictionary
43      */
44     public PDAppearanceCharacteristicsDictionary(COSDictionary dict)
45     {
46         this.dictionary = dict;
47     }
48
49
50     /**
51      * returns the dictionary.
52      * @return the dictionary
53      */
54     public COSDictionary getDictionary()
55     {
56         return this.dictionary;
57     }
58
59     /**
60      * {@inheritDoc}
61      * 
62      */
63     public COSBase getCOSObject()
64     {
65         return this.dictionary;
66     }
67
68     /**
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
72      */
73     public int getRotation()
74     {
75         return this.getDictionary().getInt(COSName.R, 0);
76     }
77
78     /**
79      * This will set the rotation.
80      * 
81      * @param rotation the rotation as a multiple of 90
82      */
83     public void setRotation(int rotation)
84     {
85         this.getDictionary().setInt(COSName.R, rotation);
86     }
87
88     /**
89      * This will retrieve the border color.
90      * 
91      * @return the border color.
92      */
93     public PDGamma getBorderColour()
94     {
95         COSBase c = this.getDictionary().getItem(COSName.getPDFName("BC"));
96         if (c instanceof COSArray)
97         {
98             return new PDGamma((COSArray) c);
99         }
100         return null;
101     }
102
103     /**
104      * This will set the border color.
105      * 
106      * @param c the border color
107      */
108     public void setBorderColour(PDGamma c)
109     {
110         this.getDictionary().setItem("BC", c);
111     }
112
113     /**
114      * This will retrieve the background color.
115      * 
116      * @return the background color.
117      */
118     public PDGamma getBackground()
119     {
120         COSBase c = this.getDictionary().getItem(COSName.getPDFName("BG"));
121         if (c instanceof COSArray)
122         {
123             return new PDGamma((COSArray) c);
124         }
125         return null;
126     }
127
128     /**
129      * This will set the background color.
130      * 
131      * @param c the background color
132      */
133     public void setBackground(PDGamma c)
134     {
135         this.getDictionary().setItem("BG", c);
136     }
137
138     /**
139      * This will retrieve the normal caption.
140      * 
141      * @return the normal caption.
142      */
143     public String getNormalCaption()
144     {
145         return this.getDictionary().getString("CA");
146     }
147
148     /**
149      * This will set the normal caption.
150      * 
151      * @param caption the normal caption
152      */
153     public void setNormalCaption(String caption)
154     {
155         this.getDictionary().setString("CA", caption);
156     }
157
158     /**
159      * This will retrieve the rollover caption.
160      * 
161      * @return the rollover caption.
162      */
163     public String getRolloverCaption()
164     {
165         return this.getDictionary().getString("RC");
166     }
167
168     /**
169      * This will set the rollover caption.
170      * 
171      * @param caption the rollover caption
172      */
173     public void setRolloverCaption(String caption)
174     {
175         this.getDictionary().setString("RC", caption);
176     }
177
178     /**
179      * This will retrieve the alternate caption.
180      * 
181      * @return the alternate caption.
182      */
183     public String getAlternateCaption()
184     {
185         return this.getDictionary().getString("AC");
186     }
187
188     /**
189      * This will set the alternate caption.
190      * 
191      * @param caption the alternate caption
192      */
193     public void setAlternateCaption(String caption)
194     {
195         this.getDictionary().setString("AC", caption);
196     }
197
198     /**
199      * This will retrieve the normal icon.
200      * 
201      * @return the normal icon.
202      */
203     public PDXObjectForm getNormalIcon()
204     {
205         COSBase i = this.getDictionary().getDictionaryObject("I");
206         if (i instanceof COSStream)
207         {
208             return new PDXObjectForm((COSStream) i);
209         }
210         return null;
211     }
212
213     /**
214      * This will retrieve the rollover icon.
215      * 
216      * @return the rollover icon
217      */
218     public PDXObjectForm getRolloverIcon()
219     {
220         COSBase i = this.getDictionary().getDictionaryObject("RI");
221         if (i instanceof COSStream)
222         {
223             return new PDXObjectForm((COSStream) i);
224         }
225         return null;
226     }
227
228     /**
229      * This will retrieve the alternate icon.
230      * 
231      * @return the alternate icon.
232      */
233     public PDXObjectForm getAlternateIcon()
234     {
235         COSBase i = this.getDictionary().getDictionaryObject("IX");
236         if (i instanceof COSStream)
237         {
238             return new PDXObjectForm((COSStream) i);
239         }
240         return null;
241     }
242
243 }