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.COSDictionary;
21 import org.apache.pdfbox.cos.COSName;
24 * This class represents a rectlinear measure dictionary.
26 * @version $Revision: 1.0 $
29 public class PDRectlinearMeasureDictionary extends PDMeasureDictionary
33 * The subtype of the rectlinear measure dictionary.
35 public static final String SUBTYPE = "RL";
40 public PDRectlinearMeasureDictionary()
42 this.setSubtype(SUBTYPE);
48 * @param dictionary the corresponding dictionary
50 public PDRectlinearMeasureDictionary(COSDictionary dictionary)
56 * This will return the scale ration.
58 * @return the scale ratio.
60 public String getScaleRatio()
62 return this.getDictionary().getString(COSName.R);
66 * This will set the scale ration.
68 * @param scaleRatio the scale ratio.
70 public void setScaleRatio(String scaleRatio)
72 this.getDictionary().setString(COSName.R, scaleRatio);
76 * This will return the changes along the x-axis.
78 * @return changes along the x-axis
80 public PDNumberFormatDictionary[] getChangeXs()
82 COSArray x = (COSArray)this.getDictionary().getDictionaryObject("X");
85 PDNumberFormatDictionary[] retval =
86 new PDNumberFormatDictionary[x.size()];
87 for (int i = 0; i < x.size(); i++)
89 COSDictionary dic = (COSDictionary) x.get(i);
90 retval[i] = new PDNumberFormatDictionary(dic);
98 * This will set the changes along the x-axis.
100 * @param changeXs changes along the x-axis
102 public void setChangeXs(PDNumberFormatDictionary[] changeXs)
104 COSArray array = new COSArray();
105 for (int i = 0; i < changeXs.length; i++)
107 array.add(changeXs[i]);
109 this.getDictionary().setItem("X", array);
113 * This will return the changes along the y-axis.
115 * @return changes along the y-axis
117 public PDNumberFormatDictionary[] getChangeYs()
119 COSArray y = (COSArray)this.getDictionary().getDictionaryObject("Y");
122 PDNumberFormatDictionary[] retval =
123 new PDNumberFormatDictionary[y.size()];
124 for (int i = 0; i < y.size(); i++)
126 COSDictionary dic = (COSDictionary) y.get(i);
127 retval[i] = new PDNumberFormatDictionary(dic);
135 * This will set the changes along the y-axis.
137 * @param changeYs changes along the y-axis
139 public void setChangeYs(PDNumberFormatDictionary[] changeYs)
141 COSArray array = new COSArray();
142 for (int i = 0; i < changeYs.length; i++)
144 array.add(changeYs[i]);
146 this.getDictionary().setItem("Y", array);
150 * This will return the distances.
154 public PDNumberFormatDictionary[] getDistances()
156 COSArray d = (COSArray)this.getDictionary().getDictionaryObject("D");
159 PDNumberFormatDictionary[] retval =
160 new PDNumberFormatDictionary[d.size()];
161 for (int i = 0; i < d.size(); i++)
163 COSDictionary dic = (COSDictionary) d.get(i);
164 retval[i] = new PDNumberFormatDictionary(dic);
172 * This will set the distances.
174 * @param distances distances
176 public void setDistances(PDNumberFormatDictionary[] distances)
178 COSArray array = new COSArray();
179 for (int i = 0; i < distances.length; i++)
181 array.add(distances[i]);
183 this.getDictionary().setItem("D", array);
187 * This will return the areas.
191 public PDNumberFormatDictionary[] getAreas()
193 COSArray a = (COSArray)this.getDictionary().getDictionaryObject(COSName.A);
196 PDNumberFormatDictionary[] retval =
197 new PDNumberFormatDictionary[a.size()];
198 for (int i = 0; i < a.size(); i++)
200 COSDictionary dic = (COSDictionary) a.get(i);
201 retval[i] = new PDNumberFormatDictionary(dic);
209 * This will set the areas.
213 public void setAreas(PDNumberFormatDictionary[] areas)
215 COSArray array = new COSArray();
216 for (int i = 0; i < areas.length; i++)
220 this.getDictionary().setItem(COSName.A, array);
224 * This will return the angles.
228 public PDNumberFormatDictionary[] getAngles()
230 COSArray t = (COSArray)this.getDictionary().getDictionaryObject("T");
233 PDNumberFormatDictionary[] retval =
234 new PDNumberFormatDictionary[t.size()];
235 for (int i = 0; i < t.size(); i++)
237 COSDictionary dic = (COSDictionary) t.get(i);
238 retval[i] = new PDNumberFormatDictionary(dic);
246 * This will set the angles.
248 * @param angles angles
250 public void setAngles(PDNumberFormatDictionary[] angles)
252 COSArray array = new COSArray();
253 for (int i = 0; i < angles.length; i++)
255 array.add(angles[i]);
257 this.getDictionary().setItem("T", array);
261 * This will return the sloaps of a line.
263 * @return the sloaps of a line
265 public PDNumberFormatDictionary[] getLineSloaps()
267 COSArray s = (COSArray)this.getDictionary().getDictionaryObject("S");
270 PDNumberFormatDictionary[] retval =
271 new PDNumberFormatDictionary[s.size()];
272 for (int i = 0; i < s.size(); i++)
274 COSDictionary dic = (COSDictionary) s.get(i);
275 retval[i] = new PDNumberFormatDictionary(dic);
283 * This will set the sloaps of a line.
285 * @param lineSloaps the sloaps of a line
287 public void setLineSloaps(PDNumberFormatDictionary[] lineSloaps)
289 COSArray array = new COSArray();
290 for (int i = 0; i < lineSloaps.length; i++)
292 array.add(lineSloaps[i]);
294 this.getDictionary().setItem("S", array);
298 * This will return the origin of the coordinate system.
302 public float[] getCoordSystemOrigin()
304 COSArray o = (COSArray)this.getDictionary().getDictionaryObject("O");
307 return o.toFloatArray();
313 * This will set the origin of the coordinate system.
315 * @param coordSystemOrigin the origin
317 public void setCoordSystemOrigin(float[] coordSystemOrigin)
319 COSArray array = new COSArray();
320 array.setFloatArray(coordSystemOrigin);
321 this.getDictionary().setItem("O", array);
325 * This will return the CYX factor.
329 public float getCYX()
331 return this.getDictionary().getFloat("CYX");
335 * This will set the CYX factor.
337 * @param cyx CYX factor
339 public void setCYX(float cyx)
341 this.getDictionary().setFloat("CYX", cyx);