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.measurement;
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;
27 * This class represents a viewport dictionary.
29 * @version $Revision: 1.0 $
32 public class PDViewportDictionary implements COSObjectable
36 * The type of this annotation.
38 public static final String TYPE = "Viewport";
40 private COSDictionary viewportDictionary;
45 public PDViewportDictionary()
47 this.viewportDictionary = new COSDictionary();
53 * @param dictionary the dictionary
55 public PDViewportDictionary(COSDictionary dictionary)
57 this.viewportDictionary = dictionary;
63 public COSBase getCOSObject()
65 return this.viewportDictionary;
69 * This will return the corresponding dictionary.
71 * @return the viewport dictionary
73 public COSDictionary getDictionary()
75 return this.viewportDictionary;
79 * Returns the type of the viewport dictionary.
80 * It must be "Viewport"
81 * @return the type of the external data dictionary
84 public String getType()
90 * This will retrieve the rectangle specifying the location of the viewport.
92 * @return the location
94 public PDRectangle getBBox()
96 COSArray bbox = (COSArray)this.getDictionary().getDictionaryObject("BBox");
99 return new PDRectangle(bbox);
105 * This will set the rectangle specifying the location of the viewport.
107 * @param rectangle the rectangle specifying the location.
109 public void setBBox(PDRectangle rectangle)
111 this.getDictionary().setItem("BBox", rectangle);
115 * This will retrieve the name of the viewport.
117 * @return the name of the viewport
119 public String getName()
121 return this.getDictionary().getNameAsString(COSName.NAME);
125 * This will set the name of the viewport.
127 * @param name the name of the viewport
129 public void setName(String name)
131 this.getDictionary().setName(COSName.NAME, name);
135 * This will retrieve the measure dictionary.
137 * @return the measure dictionary
139 public PDMeasureDictionary getMeasure()
141 COSDictionary measure = (COSDictionary)this.getDictionary().getDictionaryObject("Measure");
144 return new PDMeasureDictionary(measure);
150 * This will set the measure dictionary.
152 * @param measure the measure dictionary
154 public void setMeasure(PDMeasureDictionary measure)
156 this.getDictionary().setItem("Measure", measure);