]> _ Git - cubeextranet.git/blob
a0060005202b1c5b792ddcf2e1bee52eefbc3797
[cubeextranet.git] /
1 /*\r
2  * Licensed to the Apache Software Foundation (ASF) under one or more\r
3  * contributor license agreements.  See the NOTICE file distributed with\r
4  * this work for additional information regarding copyright ownership.\r
5  * The ASF licenses this file to You under the Apache License, Version 2.0\r
6  * (the "License"); you may not use this file except in compliance with\r
7  * the License.  You may obtain a copy of the License at\r
8  *\r
9  *      http://www.apache.org/licenses/LICENSE-2.0\r
10  *\r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;\r
18 \r
19 import org.apache.pdfbox.cos.COSArray;\r
20 import org.apache.pdfbox.cos.COSDictionary;\r
21 import org.apache.pdfbox.cos.COSName;\r
22 import org.apache.pdfbox.pdmodel.common.PDRectangle;\r
23 import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent;\r
24 \r
25 /**\r
26  * An artifact marked content.\r
27  *\r
28  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>\r
29  * @version $Revision: $\r
30  *\r
31  */\r
32 public class PDArtifactMarkedContent extends PDMarkedContent\r
33 {\r
34 \r
35     public PDArtifactMarkedContent(COSDictionary properties)\r
36     {\r
37         super(COSName.ARTIFACT, properties);\r
38     }\r
39 \r
40 \r
41     /**\r
42      * Gets the type (Type).\r
43      * \r
44      * @return the type\r
45      */\r
46     public String getType()\r
47     {\r
48         return this.getProperties().getNameAsString(COSName.TYPE);\r
49     }\r
50 \r
51     /**\r
52      * Gets the artifact's bounding box (BBox).\r
53      * \r
54      * @return the artifact's bounding box\r
55      */\r
56     public PDRectangle getBBox()\r
57     {\r
58         PDRectangle retval = null;\r
59         COSArray a = (COSArray) this.getProperties().getDictionaryObject(\r
60             COSName.BBOX);\r
61         if (a != null)\r
62         {\r
63             retval = new PDRectangle(a);\r
64         }\r
65         return retval;\r
66     }\r
67 \r
68     /**\r
69      * Is the artifact attached to the top edge?\r
70      * \r
71      * @return <code>true</code> if the artifact is attached to the top edge,\r
72      * <code>false</code> otherwise\r
73      */\r
74     public boolean isTopAttached()\r
75     {\r
76         return this.isAttached("Top");\r
77     }\r
78 \r
79     /**\r
80      * Is the artifact attached to the bottom edge?\r
81      * \r
82      * @return <code>true</code> if the artifact is attached to the bottom edge,\r
83      * <code>false</code> otherwise\r
84      */\r
85     public boolean isBottomAttached()\r
86     {\r
87         return this.isAttached("Bottom");\r
88     }\r
89 \r
90     /**\r
91      * Is the artifact attached to the left edge?\r
92      * \r
93      * @return <code>true</code> if the artifact is attached to the left edge,\r
94      * <code>false</code> otherwise\r
95      */\r
96     public boolean isLeftAttached()\r
97     {\r
98         return this.isAttached("Left");\r
99     }\r
100 \r
101     /**\r
102      * Is the artifact attached to the right edge?\r
103      * \r
104      * @return <code>true</code> if the artifact is attached to the right edge,\r
105      * <code>false</code> otherwise\r
106      */\r
107     public boolean isRightAttached()\r
108     {\r
109         return this.isAttached("Right");\r
110     }\r
111 \r
112     /**\r
113      * Gets the subtype (Subtype).\r
114      * \r
115      * @return the subtype\r
116      */\r
117     public String getSubtype()\r
118     {\r
119         return this.getProperties().getNameAsString(COSName.SUBTYPE);\r
120     }\r
121 \r
122 \r
123     /**\r
124      * Is the artifact attached to the given edge?\r
125      * \r
126      * @param edge the edge\r
127      * @return <code>true</code> if the artifact is attached to the given edge,\r
128      * <code>false</code> otherwise\r
129      */\r
130     private boolean isAttached(String edge)\r
131     {\r
132         COSArray a = (COSArray) this.getProperties().getDictionaryObject(\r
133             COSName.ATTACHED);\r
134         if (a != null)\r
135         {\r
136             for (int i = 0; i < a.size(); i++)\r
137             {\r
138                 if (edge.equals(a.getName(i)))\r
139                 {\r
140                     return true;\r
141                 }\r
142             }\r
143         }\r
144         return false;\r
145     }\r
146 \r
147 }\r