]> _ Git - cubeextranet.git/blob
1c6ecfbfe8bee001be33e4b6db1b474a56c8d224
[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.COSDictionary;
21 import org.apache.pdfbox.cos.COSName;
22
23 /**
24  * This class represents a rectlinear measure dictionary.
25  * 
26  * @version $Revision: 1.0 $
27  *
28  */
29 public class PDRectlinearMeasureDictionary extends PDMeasureDictionary
30 {
31
32     /**
33      * The subtype of the rectlinear measure dictionary.
34      */
35     public static final String SUBTYPE = "RL";
36
37     /**
38      * Constructor.
39      */
40     public PDRectlinearMeasureDictionary()
41     {
42         this.setSubtype(SUBTYPE);
43     }
44
45     /**
46      * Constructor.
47      * 
48      * @param dictionary the corresponding dictionary
49      */
50     public PDRectlinearMeasureDictionary(COSDictionary dictionary)
51     {
52         super(dictionary);
53     }
54
55     /**
56      * This will return the scale ration.
57      * 
58      * @return the scale ratio.
59      */
60     public String getScaleRatio()
61     {
62         return this.getDictionary().getString(COSName.R);
63     }
64
65     /**
66      * This will set the scale ration.
67      * 
68      * @param scaleRatio the scale ratio.
69      */
70     public void setScaleRatio(String scaleRatio)
71     {
72         this.getDictionary().setString(COSName.R, scaleRatio);
73     }
74
75     /**
76      * This will return the changes along the x-axis.
77      * 
78      * @return changes along the x-axis
79      */
80     public PDNumberFormatDictionary[] getChangeXs()
81     {
82         COSArray x = (COSArray)this.getDictionary().getDictionaryObject("X");
83         if (x != null)
84         {
85             PDNumberFormatDictionary[] retval =
86                 new PDNumberFormatDictionary[x.size()];
87             for (int i = 0; i < x.size(); i++)
88             {
89                 COSDictionary dic = (COSDictionary) x.get(i);
90                 retval[i] = new PDNumberFormatDictionary(dic);
91             }
92             return retval;
93         }
94         return null;
95     }
96
97     /**
98      * This will set the changes along the x-axis.
99      * 
100      * @param changeXs changes along the x-axis
101      */
102     public void setChangeXs(PDNumberFormatDictionary[] changeXs)
103     {
104         COSArray array = new COSArray();
105         for (int i = 0; i < changeXs.length; i++)
106         {
107             array.add(changeXs[i]);
108         }
109         this.getDictionary().setItem("X", array);
110     }
111
112     /**
113      * This will return the changes along the y-axis.
114      * 
115      * @return changes along the y-axis
116      */
117     public PDNumberFormatDictionary[] getChangeYs()
118     {
119         COSArray y = (COSArray)this.getDictionary().getDictionaryObject("Y");
120         if (y != null)
121         {
122             PDNumberFormatDictionary[] retval =
123                 new PDNumberFormatDictionary[y.size()];
124             for (int i = 0; i < y.size(); i++)
125             {
126                 COSDictionary dic = (COSDictionary) y.get(i);
127                 retval[i] = new PDNumberFormatDictionary(dic);
128             }
129             return retval;
130         }
131         return null;
132     }
133
134     /**
135      * This will set the changes along the y-axis.
136      * 
137      * @param changeYs changes along the y-axis
138      */
139     public void setChangeYs(PDNumberFormatDictionary[] changeYs)
140     {
141         COSArray array = new COSArray();
142         for (int i = 0; i < changeYs.length; i++)
143         {
144             array.add(changeYs[i]);
145         }
146         this.getDictionary().setItem("Y", array);
147     }
148
149     /**
150      * This will return the distances.
151      * 
152      * @return distances
153      */
154     public PDNumberFormatDictionary[] getDistances()
155     {
156         COSArray d = (COSArray)this.getDictionary().getDictionaryObject("D");
157         if (d != null)
158         {
159             PDNumberFormatDictionary[] retval =
160                 new PDNumberFormatDictionary[d.size()];
161             for (int i = 0; i < d.size(); i++)
162             {
163                 COSDictionary dic = (COSDictionary) d.get(i);
164                 retval[i] = new PDNumberFormatDictionary(dic);
165             }
166             return retval;
167         }
168         return null;
169     }
170
171     /**
172      * This will set the distances.
173      * 
174      * @param distances distances
175      */
176     public void setDistances(PDNumberFormatDictionary[] distances)
177     {
178         COSArray array = new COSArray();
179         for (int i = 0; i < distances.length; i++)
180         {
181             array.add(distances[i]);
182         }
183         this.getDictionary().setItem("D", array);
184     }
185
186     /**
187      * This will return the areas.
188      * 
189      * @return areas
190      */
191     public PDNumberFormatDictionary[] getAreas()
192     {
193         COSArray a = (COSArray)this.getDictionary().getDictionaryObject(COSName.A);
194         if (a != null)
195         {
196             PDNumberFormatDictionary[] retval =
197                 new PDNumberFormatDictionary[a.size()];
198             for (int i = 0; i < a.size(); i++)
199             {
200                 COSDictionary dic = (COSDictionary) a.get(i);
201                 retval[i] = new PDNumberFormatDictionary(dic);
202             }
203             return retval;
204         }
205         return null;
206     }
207
208     /**
209      * This will set the areas.
210      * 
211      * @param areas areas
212      */
213     public void setAreas(PDNumberFormatDictionary[] areas)
214     {
215         COSArray array = new COSArray();
216         for (int i = 0; i < areas.length; i++)
217         {
218             array.add(areas[i]);
219         }
220         this.getDictionary().setItem(COSName.A, array);
221     }
222
223     /**
224      * This will return the angles.
225      * 
226      * @return angles
227      */
228     public PDNumberFormatDictionary[] getAngles()
229     {
230         COSArray t = (COSArray)this.getDictionary().getDictionaryObject("T");
231         if (t != null)
232         {
233             PDNumberFormatDictionary[] retval =
234                 new PDNumberFormatDictionary[t.size()];
235             for (int i = 0; i < t.size(); i++)
236             {
237                 COSDictionary dic = (COSDictionary) t.get(i);
238                 retval[i] = new PDNumberFormatDictionary(dic);
239             }
240             return retval;
241         }
242         return null;
243     }
244
245     /**
246      * This will set the angles.
247      * 
248      * @param angles angles
249      */
250     public void setAngles(PDNumberFormatDictionary[] angles)
251     {
252         COSArray array = new COSArray();
253         for (int i = 0; i < angles.length; i++)
254         {
255             array.add(angles[i]);
256         }
257         this.getDictionary().setItem("T", array);
258     }
259
260     /**
261      * This will return the sloaps of a line.
262      * 
263      * @return the sloaps of a line
264      */
265     public PDNumberFormatDictionary[] getLineSloaps()
266     {
267         COSArray s = (COSArray)this.getDictionary().getDictionaryObject("S");
268         if (s != null)
269         {
270             PDNumberFormatDictionary[] retval =
271                 new PDNumberFormatDictionary[s.size()];
272             for (int i = 0; i < s.size(); i++)
273             {
274                 COSDictionary dic = (COSDictionary) s.get(i);
275                 retval[i] = new PDNumberFormatDictionary(dic);
276             }
277             return retval;
278         }
279         return null;
280     }
281
282     /**
283      * This will set the sloaps of a line.
284      * 
285      * @param lineSloaps the sloaps of a line
286      */
287     public void setLineSloaps(PDNumberFormatDictionary[] lineSloaps)
288     {
289         COSArray array = new COSArray();
290         for (int i = 0; i < lineSloaps.length; i++)
291         {
292             array.add(lineSloaps[i]);
293         }
294         this.getDictionary().setItem("S", array);
295     }
296
297     /**
298      * This will return the origin of the coordinate system.
299      * 
300      * @return the origin
301      */
302     public float[] getCoordSystemOrigin()
303     {
304         COSArray o = (COSArray)this.getDictionary().getDictionaryObject("O");
305         if (o != null)
306         {
307             return o.toFloatArray();
308         }
309         return null;
310     }
311
312     /**
313      * This will set the origin of the coordinate system.
314      * 
315      * @param coordSystemOrigin the origin
316      */
317     public void setCoordSystemOrigin(float[] coordSystemOrigin)
318     {
319         COSArray array = new COSArray();
320         array.setFloatArray(coordSystemOrigin);
321         this.getDictionary().setItem("O", array);
322     }
323
324     /**
325      * This will return the CYX factor.
326      * 
327      * @return CYX factor
328      */
329     public float getCYX()
330     {
331         return this.getDictionary().getFloat("CYX");
332     }
333
334     /**
335      * This will set the CYX factor.
336      * 
337      * @param cyx CYX factor
338      */
339     public void setCYX(float cyx)
340     {
341         this.getDictionary().setFloat("CYX", cyx);
342     }
343
344 }