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.documentinterchange.taggedpdf;
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;
26 * An artifact marked content.
28 * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
29 * @version $Revision: $
32 public class PDArtifactMarkedContent extends PDMarkedContent
35 public PDArtifactMarkedContent(COSDictionary properties)
37 super(COSName.ARTIFACT, properties);
42 * Gets the type (Type).
46 public String getType()
48 return this.getProperties().getNameAsString(COSName.TYPE);
52 * Gets the artifact's bounding box (BBox).
54 * @return the artifact's bounding box
56 public PDRectangle getBBox()
58 PDRectangle retval = null;
59 COSArray a = (COSArray) this.getProperties().getDictionaryObject(
63 retval = new PDRectangle(a);
69 * Is the artifact attached to the top edge?
71 * @return <code>true</code> if the artifact is attached to the top edge,
72 * <code>false</code> otherwise
74 public boolean isTopAttached()
76 return this.isAttached("Top");
80 * Is the artifact attached to the bottom edge?
82 * @return <code>true</code> if the artifact is attached to the bottom edge,
83 * <code>false</code> otherwise
85 public boolean isBottomAttached()
87 return this.isAttached("Bottom");
91 * Is the artifact attached to the left edge?
93 * @return <code>true</code> if the artifact is attached to the left edge,
94 * <code>false</code> otherwise
96 public boolean isLeftAttached()
98 return this.isAttached("Left");
102 * Is the artifact attached to the right edge?
104 * @return <code>true</code> if the artifact is attached to the right edge,
105 * <code>false</code> otherwise
107 public boolean isRightAttached()
109 return this.isAttached("Right");
113 * Gets the subtype (Subtype).
115 * @return the subtype
117 public String getSubtype()
119 return this.getProperties().getNameAsString(COSName.SUBTYPE);
124 * Is the artifact attached to the given edge?
126 * @param edge the edge
127 * @return <code>true</code> if the artifact is attached to the given edge,
128 * <code>false</code> otherwise
130 private boolean isAttached(String edge)
132 COSArray a = (COSArray) this.getProperties().getDictionaryObject(
136 for (int i = 0; i < a.size(); i++)
138 if (edge.equals(a.getName(i)))