Author: koch
Date: Fri Apr 9 15:02:03 2010
New Revision: 932448
URL: http://svn.apache.org/viewvc?rev=932448&view=rev
Log:
Added some more stuff for tagged PDF
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDArtifactMarkedContent.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDExportFormatAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDFourColours.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDLayoutAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDListAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDPrintFieldAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDStandardAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDTableAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/StandardStructureTypes.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/package.html
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/Revisions.java
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java?rev=932448&r1=932447&r2=932448&view=diff
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
(original)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
Fri Apr 9 15:02:03 2010
@@ -16,9 +16,15 @@
*/
package org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure;
+import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.common.PDDictionaryWrapper;
+import
org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDExportFormatAttributeObject;
+import
org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDLayoutAttributeObject;
+import
org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDListAttributeObject;
+import
org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDPrintFieldAttributeObject;
+import
org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDTableAttributeObject;
/**
* An attribute object.
@@ -39,10 +45,36 @@ public abstract class PDAttributeObject
public static PDAttributeObject create(COSDictionary dictionary)
{
String owner = dictionary.getNameAsString(COSName.O);
- if (PDUserAttributeObject.USER_PROPERTIES.equals(owner))
+ if (PDUserAttributeObject.OWNER_USER_PROPERTIES.equals(owner))
{
return new PDUserAttributeObject(dictionary);
}
+ else if (PDListAttributeObject.OWNER_LIST.equals(owner))
+ {
+ return new PDListAttributeObject(dictionary);
+ }
+ else if (PDPrintFieldAttributeObject.OWNER_PRINT_FIELD.equals(owner))
+ {
+ return new PDPrintFieldAttributeObject(dictionary);
+ }
+ else if (PDTableAttributeObject.OWNER_TABLE.equals(owner))
+ {
+ return new PDTableAttributeObject(dictionary);
+ }
+ else if (PDLayoutAttributeObject.OWNER_LAYOUT.equals(owner))
+ {
+ return new PDLayoutAttributeObject(dictionary);
+ }
+ else if (PDExportFormatAttributeObject.OWNER_XML_1_00.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_HTML_3_20.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_HTML_4_01.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_OEB_1_00.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_RTF_1_05.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_CSS_1_00.equals(owner)
+ || PDExportFormatAttributeObject.OWNER_CSS_2_00.equals(owner))
+ {
+ return new PDExportFormatAttributeObject(dictionary);
+ }
return new PDDefaultAttributeObject(dictionary);
}
@@ -123,12 +155,12 @@ public abstract class PDAttributeObject
/**
* Notifies the attribute object change listeners if the attribute is
changed.
*
- * @param oldValue old value
- * @param newValue new value
+ * @param oldBase old value
+ * @param newBase new value
*/
- protected void potentiallyNotifyChanged(Object oldValue, Object newValue)
+ protected void potentiallyNotifyChanged(COSBase oldBase, COSBase newBase)
{
- if (this.isValueChanged(oldValue, newValue))
+ if (this.isValueChanged(oldBase, newBase))
{
this.notifyChanged();
}
@@ -142,7 +174,7 @@ public abstract class PDAttributeObject
* @return <code>true</code> if the value is changed, <code>false</code>
* otherwise
*/
- private boolean isValueChanged(Object oldValue, Object newValue)
+ private boolean isValueChanged(COSBase oldValue, COSBase newValue)
{
if (oldValue == null)
{
@@ -173,6 +205,12 @@ public abstract class PDAttributeObject
return new StringBuilder("O=").append(this.getOwner()).toString();
}
+ /**
+ * Creates a String representation of an Object array.
+ *
+ * @param array the Object array
+ * @return the String representation
+ */
protected static String arrayToString(Object[] array)
{
StringBuilder sb = new StringBuilder("[");
@@ -187,6 +225,12 @@ public abstract class PDAttributeObject
return sb.append(']').toString();
}
+ /**
+ * Creates a String representation of a float array.
+ *
+ * @param array the float array
+ * @return the String representation
+ */
protected static String arrayToString(float[] array)
{
StringBuilder sb = new StringBuilder("[");
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java?rev=932448&r1=932447&r2=932448&view=diff
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
(original)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
Fri Apr 9 15:02:03 2010
@@ -35,7 +35,7 @@ public class PDUserAttributeObject exten
/**
* Attribute owner for user properties
*/
- public static final String USER_PROPERTIES = "UserProperties";
+ public static final String OWNER_USER_PROPERTIES = "UserProperties";
/**
@@ -43,7 +43,7 @@ public class PDUserAttributeObject exten
*/
public PDUserAttributeObject()
{
- this.setOwner(USER_PROPERTIES);
+ this.setOwner(OWNER_USER_PROPERTIES);
}
/**
@@ -61,7 +61,7 @@ public class PDUserAttributeObject exten
*
* @return the user properties
*/
- public List<PDUserProperty> getUserProperties()
+ public List<PDUserProperty> getOwnerUserProperties()
{
COSArray p = (COSArray) this.getCOSDictionary()
.getDictionaryObject(COSName.P);
@@ -129,7 +129,7 @@ public class PDUserAttributeObject exten
{
return new StringBuilder().append(super.toString())
.append(", userProperties=")
- .append(this.getUserProperties()).toString();
+ .append(this.getOwnerUserProperties()).toString();
}
}
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/Revisions.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/Revisions.java?rev=932448&r1=932447&r2=932448&view=diff
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/Revisions.java
(original)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/Revisions.java
Fri Apr 9 15:02:03 2010
@@ -89,7 +89,7 @@ public class Revisions<T>
* @param object the object
* @param revisionNumber the revision number
*/
- protected void addObject(T object, int revisionNumber)
+ public void addObject(T object, int revisionNumber)
{
this.getObjects().add(object);
this.getRevisionNumbers().add(revisionNumber);
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDArtifactMarkedContent.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDArtifactMarkedContent.java?rev=932448&view=auto
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDArtifactMarkedContent.java
(added)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDArtifactMarkedContent.java
Fri Apr 9 15:02:03 2010
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
+
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import
org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent;
+
+/**
+ * An artifact marked content.
+ *
+ * @author <a href="mailto:johannes%20koch%20%[email protected]%3e">Johannes
Koch</a>
+ * @version $Revision: $
+ *
+ */
+public class PDArtifactMarkedContent extends PDMarkedContent
+{
+
+ public PDArtifactMarkedContent(COSDictionary properties)
+ {
+ super(COSName.ARTIFACT, properties);
+ }
+
+
+ /**
+ * Gets the type (Type).
+ *
+ * @return the type
+ */
+ public String getType()
+ {
+ return this.getProperties().getNameAsString(COSName.TYPE);
+ }
+
+ /**
+ * Gets the artifact's bounding box (BBox).
+ *
+ * @return the artifact's bounding box
+ */
+ public PDRectangle getBBox()
+ {
+ PDRectangle retval = null;
+ COSArray a = (COSArray) this.getProperties().getDictionaryObject(
+ COSName.BBOX);
+ if (a != null)
+ {
+ retval = new PDRectangle(a);
+ }
+ return retval;
+ }
+
+ /**
+ * Is the artifact attached to the top edge?
+ *
+ * @return <code>true</code> if the artifact is attached to the top edge,
+ * <code>false</code> otherwise
+ */
+ public boolean isTopAttached()
+ {
+ return this.isAttached("Top");
+ }
+
+ /**
+ * Is the artifact attached to the bottom edge?
+ *
+ * @return <code>true</code> if the artifact is attached to the bottom
edge,
+ * <code>false</code> otherwise
+ */
+ public boolean isBottomAttached()
+ {
+ return this.isAttached("Bottom");
+ }
+
+ /**
+ * Is the artifact attached to the left edge?
+ *
+ * @return <code>true</code> if the artifact is attached to the left edge,
+ * <code>false</code> otherwise
+ */
+ public boolean isLeftAttached()
+ {
+ return this.isAttached("Left");
+ }
+
+ /**
+ * Is the artifact attached to the right edge?
+ *
+ * @return <code>true</code> if the artifact is attached to the right edge,
+ * <code>false</code> otherwise
+ */
+ public boolean isRightAttached()
+ {
+ return this.isAttached("Right");
+ }
+
+ /**
+ * Gets the subtype (Subtype).
+ *
+ * @return the subtype
+ */
+ public String getSubtype()
+ {
+ return this.getProperties().getNameAsString(COSName.SUBTYPE);
+ }
+
+
+ /**
+ * Is the artifact attached to the given edge?
+ *
+ * @param edge the edge
+ * @return <code>true</code> if the artifact is attached to the given edge,
+ * <code>false</code> otherwise
+ */
+ private boolean isAttached(String edge)
+ {
+ COSArray a = (COSArray) this.getProperties().getDictionaryObject(
+ COSName.ATTACHED);
+ if (a != null)
+ {
+ for (int i = 0; i < a.size(); i++)
+ {
+ if (edge.equals(a.getName(i)))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDExportFormatAttributeObject.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDExportFormatAttributeObject.java?rev=932448&view=auto
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDExportFormatAttributeObject.java
(added)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDExportFormatAttributeObject.java
Fri Apr 9 15:02:03 2010
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
+
+import org.apache.pdfbox.cos.COSDictionary;
+import
org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
+
+/**
+ * An Export Format attribute object.
+ *
+ * @author <a href="mailto:johannes%20koch%20%[email protected]%3e">Johannes
Koch</a>
+ * @version $Revision: $
+ */
+public class PDExportFormatAttributeObject extends PDLayoutAttributeObject
+{
+
+ /**
+ * standard attribute owner: XML-1.00
+ */
+ public static final String OWNER_XML_1_00 = "XML-1.00";
+ /**
+ * standard attribute owner: HTML-3.2
+ */
+ public static final String OWNER_HTML_3_20 = "HTML-3.2";
+ /**
+ * standard attribute owner: HTML-4.01
+ */
+ public static final String OWNER_HTML_4_01 = "HTML-4.01";
+ /**
+ * standard attribute owner: OEB-1.00
+ */
+ public static final String OWNER_OEB_1_00 = "OEB-1.00";
+ /**
+ * standard attribute owner: RTF-1.05
+ */
+ public static final String OWNER_RTF_1_05 = "RTF-1.05";
+ /**
+ * standard attribute owner: CSS-1.00
+ */
+ public static final String OWNER_CSS_1_00 = "CSS-1.00";
+ /**
+ * standard attribute owner: CSS-2.00
+ */
+ public static final String OWNER_CSS_2_00 = "CSS-2.00";
+
+
+ /**
+ * Default constructor.
+ */
+ public PDExportFormatAttributeObject(String owner)
+ {
+ this.setOwner(owner);
+ }
+
+ /**
+ * Creates a new ExportFormat attribute object with a given dictionary.
+ *
+ * @param dictionary the dictionary
+ */
+ public PDExportFormatAttributeObject(COSDictionary dictionary)
+ {
+ super(dictionary);
+ }
+
+
+ /**
+ * Gets the list numbering (ListNumbering). The default value is
+ * {...@link #LIST_NUMBERING_NONE}.
+ *
+ * @return the list numbering
+ */
+ public String getListNumbering()
+ {
+ return this.getName(PDListAttributeObject.LIST_NUMBERING,
+ PDListAttributeObject.LIST_NUMBERING_NONE);
+ }
+
+ /**
+ * Sets the list numbering (ListNumbering). The value shall be one of the
+ * following:
+ * <ul>
+ * <li>{...@link #LIST_NUMBERING_NONE},</li>
+ * <li>{...@link #LIST_NUMBERING_DISC},</li>
+ * <li>{...@link #LIST_NUMBERING_CIRCLE},</li>
+ * <li>{...@link #LIST_NUMBERING_SQUARE},</li>
+ * <li>{...@link #LIST_NUMBERING_DECIMAL},</li>
+ * <li>{...@link #LIST_NUMBERING_UPPER_ROMAN},</li>
+ * <li>{...@link #LIST_NUMBERING_LOWER_ROMAN},</li>
+ * <li>{...@link #LIST_NUMBERING_UPPER_ALPHA},</li>
+ * <li>{...@link #LIST_NUMBERING_LOWER_ALPHA}.</li>
+ * </ul>
+ *
+ * @param listNumbering the list numbering
+ */
+ public void setListNumbering(String listNumbering)
+ {
+ this.setName(PDListAttributeObject.LIST_NUMBERING, listNumbering);
+ }
+
+ /**
+ * Gets the number of rows in the enclosing table that shall be spanned by
+ * the cell (RowSpan). The default value is 1.
+ *
+ * @return the row span
+ */
+ public int getRowSpan()
+ {
+ return this.getInteger(PDTableAttributeObject.ROW_SPAN, 1);
+ }
+
+ /**
+ * Sets the number of rows in the enclosing table that shall be spanned by
+ * the cell (RowSpan).
+ *
+ * @param rowSpan the row span
+ */
+ public void setRowSpan(int rowSpan)
+ {
+ this.setInteger(PDTableAttributeObject.ROW_SPAN, rowSpan);
+ }
+
+ /**
+ * Gets the number of columns in the enclosing table that shall be spanned
+ * by the cell (ColSpan). The default value is 1.
+ *
+ * @return the column span
+ */
+ public int getColSpan()
+ {
+ return this.getInteger(PDTableAttributeObject.COL_SPAN, 1);
+ }
+
+ /**
+ * Sets the number of columns in the enclosing table that shall be spanned
+ * by the cell (ColSpan).
+ *
+ * @param colSpan the column span
+ */
+ public void setColSpan(int colSpan)
+ {
+ this.setInteger(PDTableAttributeObject.COL_SPAN, colSpan);
+ }
+
+ /**
+ * Gets the headers (Headers). An array of byte strings, where each string
+ * shall be the element identifier (see the
+ * {...@link PDStructureElement#getElementIdentifier()}) for a TH structure
+ * element that shall be used as a header associated with this cell.
+ *
+ * @return the headers.
+ */
+ public String[] getHeaders()
+ {
+ return this.getArrayOfString(PDTableAttributeObject.HEADERS);
+ }
+
+ /**
+ * Sets the headers (Headers). An array of byte strings, where each string
+ * shall be the element identifier (see the
+ * {...@link PDStructureElement#getElementIdentifier()}) for a TH structure
+ * element that shall be used as a header associated with this cell.
+ *
+ * @param headers the headers
+ */
+ public void setHeaders(String[] headers)
+ {
+ this.setArrayOfString(PDTableAttributeObject.HEADERS, headers);
+ }
+
+ /**
+ * Gets the scope (Scope). It shall reflect whether the header cell applies
+ * to the rest of the cells in the row that contains it, the column that
+ * contains it, or both the row and the column that contain it.
+ *
+ * @return the scope
+ */
+ public String getScope()
+ {
+ return this.getName(PDTableAttributeObject.SCOPE);
+ }
+
+ /**
+ * Sets the scope (Scope). It shall reflect whether the header cell applies
+ * to the rest of the cells in the row that contains it, the column that
+ * contains it, or both the row and the column that contain it. The value
+ * shall be one of the following:
+ * <ul>
+ * <li>{...@link #SCOPE_ROW},</li>
+ * <li>{...@link #SCOPE_COLUMN}, or</li>
+ * <li>{...@link #SCOPE_BOTH}.</li>
+ * </ul>
+ *
+ * @param scope the scope
+ */
+ public void setScope(String scope)
+ {
+ this.setName(PDTableAttributeObject.SCOPE, scope);
+ }
+
+ /**
+ * Gets the summary of the tableâs purpose and structure.
+ *
+ * @return the summary
+ */
+ public String getSummary()
+ {
+ return this.getString(PDTableAttributeObject.SUMMARY);
+ }
+
+ /**
+ * Sets the summary of the tableâs purpose and structure.
+ *
+ * @param summary the summary
+ */
+ public void setSummary(String summary)
+ {
+ this.setString(PDTableAttributeObject.SUMMARY, summary);
+ }
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder().append(super.toString());
+ if (this.isSpecified(PDListAttributeObject.LIST_NUMBERING))
+ {
+ sb.append(", ListNumbering=").append(this.getListNumbering());
+ }
+ if (this.isSpecified(PDTableAttributeObject.ROW_SPAN))
+ {
+ sb.append(", RowSpan=").append(String.valueOf(this.getRowSpan()));
+ }
+ if (this.isSpecified(PDTableAttributeObject.COL_SPAN))
+ {
+ sb.append(", ColSpan=").append(String.valueOf(this.getColSpan()));
+ }
+ if (this.isSpecified(PDTableAttributeObject.HEADERS))
+ {
+ sb.append(", Headers=").append(arrayToString(this.getHeaders()));
+ }
+ if (this.isSpecified(PDTableAttributeObject.SCOPE))
+ {
+ sb.append(", Scope=").append(this.getScope());
+ }
+ if (this.isSpecified(PDTableAttributeObject.SUMMARY))
+ {
+ sb.append(", Summary=").append(this.getSummary());
+ }
+ return sb.toString();
+ }
+
+}
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDFourColours.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDFourColours.java?rev=932448&view=auto
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDFourColours.java
(added)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDFourColours.java
Fri Apr 9 15:02:03 2010
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
+
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNull;
+import org.apache.pdfbox.pdmodel.common.COSObjectable;
+import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
+
+/**
+ * An object for four colours.
+ *
+ * @author <a href="mailto:johannes%20koch%20%[email protected]%3e">Johannes
Koch</a>
+ * @version $Revision: $
+ */
+public class PDFourColours implements COSObjectable
+{
+
+ private COSArray array;
+
+ public PDFourColours()
+ {
+ this.array = new COSArray();
+ this.array.add(COSNull.NULL);
+ this.array.add(COSNull.NULL);
+ this.array.add(COSNull.NULL);
+ this.array.add(COSNull.NULL);
+ }
+
+ public PDFourColours(COSArray array)
+ {
+ this.array = array;
+ // ensure that array has 4 items
+ if (this.array.size() < 4)
+ {
+ for (int i = (this.array.size() - 1); i < 4; i++)
+ {
+ this.array.add(COSNull.NULL);
+ }
+ }
+ }
+
+
+ /**
+ * Gets the colour for the before edge.
+ *
+ * @return the colour for the before edge
+ */
+ public PDGamma getBeforeColour()
+ {
+ return this.getColourByIndex(0);
+ }
+
+ /**
+ * Sets the colour for the before edge.
+ *
+ * @param colour the colour for the before edge
+ */
+ public void setBeforeColour(PDGamma colour)
+ {
+ this.setColourByIndex(0, colour);
+ }
+
+ /**
+ * Gets the colour for the after edge.
+ *
+ * @return the colour for the after edge
+ */
+ public PDGamma getAfterColour()
+ {
+ return this.getColourByIndex(1);
+ }
+
+ /**
+ * Sets the colour for the after edge.
+ *
+ * @param colour the colour for the after edge
+ */
+ public void setAfterColour(PDGamma colour)
+ {
+ this.setColourByIndex(1, colour);
+ }
+
+ /**
+ * Gets the colour for the start edge.
+ *
+ * @return the colour for the start edge
+ */
+ public PDGamma getStartColour()
+ {
+ return this.getColourByIndex(2);
+ }
+
+ /**
+ * Sets the colour for the start edge.
+ *
+ * @param colour the colour for the start edge
+ */
+ public void setStartColour(PDGamma colour)
+ {
+ this.setColourByIndex(2, colour);
+ }
+
+ /**
+ * Gets the colour for the end edge.
+ *
+ * @return the colour for the end edge
+ */
+ public PDGamma getEndColour()
+ {
+ return this.getColourByIndex(3);
+ }
+
+ /**
+ * Sets the colour for the end edge.
+ *
+ * @param colour the colour for the end edge
+ */
+ public void setEndColour(PDGamma colour)
+ {
+ this.setColourByIndex(3, colour);
+ }
+
+
+ /**
+ * {...@inheritdoc}
+ */
+ public COSBase getCOSObject()
+ {
+ return this.array;
+ }
+
+
+ /**
+ * Gets the colour by edge index.
+ *
+ * @param index edge index
+ * @return the colour
+ */
+ private PDGamma getColourByIndex(int index)
+ {
+ PDGamma retval = null;
+ COSBase item = this.array.getObject(index);
+ if (item instanceof COSArray)
+ {
+ retval = new PDGamma((COSArray) item);
+ }
+ return retval;
+ }
+
+ /**
+ * Sets the colour by edge index.
+ *
+ * @param index the edge index
+ * @param colour the colour
+ */
+ private void setColourByIndex(int index, PDGamma colour)
+ {
+ COSBase base;
+ if (colour == null)
+ {
+ base = COSNull.NULL;
+ }
+ else
+ {
+ base = colour.getCOSArray();
+ }
+ this.array.set(index, base);
+ }
+
+}