]> _ Git - cubeextranet.git/blob
f1dd12542c5b5647d23906c1dfa453e38070fbcd
[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.documentinterchange.taggedpdf;
18
19 import org.apache.pdfbox.cos.COSArray;
20 import org.apache.pdfbox.cos.COSDictionary;
21 import org.apache.pdfbox.cos.COSName;
22 import org.apache.pdfbox.pdmodel.common.PDRectangle;
23 import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent;
24
25 /**
26  * An artifact marked content.
27  *
28  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
29  * @version $Revision: $
30  *
31  */
32 public class PDArtifactMarkedContent extends PDMarkedContent
33 {
34
35     public PDArtifactMarkedContent(COSDictionary properties)
36     {
37         super(COSName.ARTIFACT, properties);
38     }
39
40
41     /**
42      * Gets the type (Type).
43      * 
44      * @return the type
45      */
46     public String getType()
47     {
48         return this.getProperties().getNameAsString(COSName.TYPE);
49     }
50
51     /**
52      * Gets the artifact's bounding box (BBox).
53      * 
54      * @return the artifact's bounding box
55      */
56     public PDRectangle getBBox()
57     {
58         PDRectangle retval = null;
59         COSArray a = (COSArray) this.getProperties().getDictionaryObject(
60             COSName.BBOX);
61         if (a != null)
62         {
63             retval = new PDRectangle(a);
64         }
65         return retval;
66     }
67
68     /**
69      * Is the artifact attached to the top edge?
70      * 
71      * @return <code>true</code> if the artifact is attached to the top edge,
72      * <code>false</code> otherwise
73      */
74     public boolean isTopAttached()
75     {
76         return this.isAttached("Top");
77     }
78
79     /**
80      * Is the artifact attached to the bottom edge?
81      * 
82      * @return <code>true</code> if the artifact is attached to the bottom edge,
83      * <code>false</code> otherwise
84      */
85     public boolean isBottomAttached()
86     {
87         return this.isAttached("Bottom");
88     }
89
90     /**
91      * Is the artifact attached to the left edge?
92      * 
93      * @return <code>true</code> if the artifact is attached to the left edge,
94      * <code>false</code> otherwise
95      */
96     public boolean isLeftAttached()
97     {
98         return this.isAttached("Left");
99     }
100
101     /**
102      * Is the artifact attached to the right edge?
103      * 
104      * @return <code>true</code> if the artifact is attached to the right edge,
105      * <code>false</code> otherwise
106      */
107     public boolean isRightAttached()
108     {
109         return this.isAttached("Right");
110     }
111
112     /**
113      * Gets the subtype (Subtype).
114      * 
115      * @return the subtype
116      */
117     public String getSubtype()
118     {
119         return this.getProperties().getNameAsString(COSName.SUBTYPE);
120     }
121
122
123     /**
124      * Is the artifact attached to the given edge?
125      * 
126      * @param edge the edge
127      * @return <code>true</code> if the artifact is attached to the given edge,
128      * <code>false</code> otherwise
129      */
130     private boolean isAttached(String edge)
131     {
132         COSArray a = (COSArray) this.getProperties().getDictionaryObject(
133             COSName.ATTACHED);
134         if (a != null)
135         {
136             for (int i = 0; i < a.size(); i++)
137             {
138                 if (edge.equals(a.getName(i)))
139                 {
140                     return true;
141                 }
142             }
143         }
144         return false;
145     }
146
147 }