]> _ Git - cubeextranet.git/blob
6243128d81ed1e248d2f1946197a7f050f01b8f1
[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.measurement;
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.pdmodel.common.COSObjectable;
24 import org.apache.pdfbox.pdmodel.common.PDRectangle;
25
26 /**
27  * This class represents a viewport dictionary.
28  * 
29  * @version $Revision: 1.0 $
30  *
31  */
32 public class PDViewportDictionary implements COSObjectable
33 {
34
35     /**
36      * The type of this annotation.
37      */
38     public static final String TYPE = "Viewport";
39     
40     private COSDictionary viewportDictionary;
41
42     /**
43      * Constructor.
44      */
45     public PDViewportDictionary()
46     {
47         this.viewportDictionary = new COSDictionary();
48     }
49
50     /**
51      * Constructor.
52      * 
53      * @param dictionary the dictionary
54      */
55     public PDViewportDictionary(COSDictionary dictionary)
56     {
57         this.viewportDictionary = dictionary;
58     }
59
60     /**
61      * {@inheritDoc} 
62      */
63     public COSBase getCOSObject()
64     {
65         return this.viewportDictionary;
66     }
67
68     /**
69      * This will return the corresponding dictionary.
70      * 
71      * @return the viewport dictionary
72      */
73     public COSDictionary getDictionary()
74     {
75         return this.viewportDictionary;
76     }
77
78     /**
79      * Returns the type of the viewport dictionary.
80      * It must be "Viewport"
81      * @return the type of the external data dictionary
82      */
83
84     public String getType()
85     {
86         return TYPE;
87     }
88
89     /**
90      * This will retrieve the rectangle specifying the location of the viewport.
91      * 
92      * @return the location
93      */
94     public PDRectangle getBBox()
95     {
96         COSArray bbox = (COSArray)this.getDictionary().getDictionaryObject("BBox");
97         if (bbox != null)
98         {
99             return new PDRectangle(bbox);
100         }
101         return null;
102     }
103
104     /**
105      * This will set the rectangle specifying the location of the viewport.
106      * 
107      * @param rectangle the rectangle specifying the location.
108      */
109     public void setBBox(PDRectangle rectangle)
110     {
111         this.getDictionary().setItem("BBox", rectangle);
112     }
113
114     /**
115      * This will retrieve the name of the viewport.
116      * 
117      * @return the name of the viewport
118      */
119     public String getName()
120     {
121         return this.getDictionary().getNameAsString(COSName.NAME);
122     }
123
124    /**
125     * This will set the name of the viewport.
126     *  
127     * @param name the name of the viewport
128     */
129     public void setName(String name)
130     {
131         this.getDictionary().setName(COSName.NAME, name);
132     }
133
134     /**
135      * This will retrieve the measure dictionary.
136      * 
137      * @return the measure dictionary
138      */
139     public PDMeasureDictionary getMeasure()
140     {
141         COSDictionary measure = (COSDictionary)this.getDictionary().getDictionaryObject("Measure");
142         if (measure != null)
143         {
144             return new PDMeasureDictionary(measure);
145         }
146         return null;
147     }
148
149     /**
150      * This will set the measure dictionary.
151      * 
152      * @param measure the measure dictionary
153      */
154     public void setMeasure(PDMeasureDictionary measure)
155     {
156         this.getDictionary().setItem("Measure", measure);
157     }
158
159 }