You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/08/27 14:35:51 UTC
svn commit: r689459 [5/7] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop:
pdf/ render/ render/afp/ render/afp/goca/ render/afp/ioca/
render/afp/modca/ render/afp/modca/resource/ render/afp/modca/triplets/
render/java2d/
Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java Wed Aug 27 05:35:44 2008
@@ -27,18 +27,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.render.afp.AFPFontAttributes;
+import org.apache.fop.render.afp.AFPResourceLevel;
import org.apache.fop.render.afp.LineDataInfo;
import org.apache.fop.render.afp.TextDataInfo;
-import org.apache.fop.render.afp.DataObjectInfo;
-import org.apache.fop.render.afp.ObjectAreaInfo;
-import org.apache.fop.render.afp.ResourceInfo;
-import org.apache.fop.render.afp.ResourceLevel;
import org.apache.fop.render.afp.fonts.AFPFont;
-import org.apache.fop.render.afp.modca.resource.ResourceFactory;
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
-import org.apache.fop.render.afp.modca.resource.StoreInfo;
import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
/**
@@ -56,7 +49,7 @@
* is accommodated by including resource objects in the documents that reference
* them.
*/
-public class AFPDataStream extends AbstractResourceGroupContainer {
+public class DataStream {
/** Static logging instance */
protected static Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
@@ -67,7 +60,7 @@
/** The application producing the AFP document */
// not used
// private String producer = null;
-
+
/** The AFP document object */
private Document document = null;
@@ -92,30 +85,37 @@
/** The rotation */
private int orientation;
- /** The outputstream for the data stream */
- private OutputStream outputStream = null;
-
- /** Maintain a reference count of instream objects for referencing purposes */
- private int instreamObjectCount = 0;
-
/** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */
private InterchangeSet interchangeSet
= InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2);
- private ResourceFactory factory;
+ private final Factory factory;
+
+ private OutputStream outputStream;
/**
- * Default constructor for the AFPDataStream.
+ * Default constructor for the AFPDocumentStream.
+ *
+ * @param factory the resource factory
+ * @param outputStream the outputstream to write to
*/
- public AFPDataStream() {
- this.resourceManager = new ResourceManager();
- this.factory = resourceManager.getFactory();
- this.document = factory.createDocument();
+ public DataStream(Factory factory, OutputStream outputStream) {
+ this.factory = factory;
+ this.outputStream = outputStream;
+ }
+
+ /**
+ * Returns the outputstream
+ *
+ * @return the outputstream
+ */
+ public OutputStream getOutputStream() {
+ return this.outputStream;
}
/**
* Returns the document object
- *
+ *
* @return the document object
*/
private Document getDocument() {
@@ -124,10 +124,10 @@
/**
* Returns the current page
- *
+ *
* @return the current page
*/
- protected AbstractPageObject getCurrentPage() {
+ public AbstractPageObject getCurrentPage() {
return this.currentPage;
}
@@ -146,18 +146,8 @@
}
}
- /**
- * Sets the OutputStream
- *
- * @param outputStream
- * the AFP OutputStream
- */
- public void setOutputStream(OutputStream outputStream) {
- this.outputStream = outputStream;
- }
-
/** {@inheritDoc} */
- public void write() throws IOException {
+ public void endDocument() throws IOException {
if (complete) {
String msg = "Invalid state - document already ended.";
log.warn("endDocument():: " + msg);
@@ -174,20 +164,10 @@
endPageGroup();
}
- if (interchangeSet.supportsLevel2()) {
- // Write out any external resource groups
- resourceManager.writeExternal();
-
- // Write out any print-file level resources
- if (hasResources()) {
- getResourceGroup().write(this.outputStream);
- }
- }
-
// Write out document
if (document != null) {
document.endDocument();
- document.write(this.outputStream);
+ document.writeToStream(this.outputStream);
}
this.outputStream.flush();
@@ -197,10 +177,6 @@
this.document = null;
this.outputStream = null;
-
- this.resourceManager.clearStore();
-
- this.resourceManager = null;
}
/**
@@ -221,7 +197,7 @@
public void startPage(int pageWidth, int pageHeight, int pageRotation,
int pageWidthRes, int pageHeightRes) {
currentPageObject = factory.createPage(pageWidth, pageHeight,
- pageRotation, pageWidthRes, pageHeightRes);
+ pageRotation, pageWidthRes, pageHeightRes);
currentPage = currentPageObject;
currentOverlay = null;
}
@@ -258,8 +234,10 @@
/**
* Helper method to mark the end of the current overlay.
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred
*/
- public void endOverlay() {
+ public void endOverlay() throws IOException {
if (currentOverlay != null) {
currentOverlay.endPage();
currentOverlay = null;
@@ -297,18 +275,22 @@
/**
* Helper method to mark the end of the current page.
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred
*/
- public void endPage() {
+ public void endPage() throws IOException {
if (currentPageObject != null) {
currentPageObject.endPage();
if (currentPageGroup != null) {
currentPageGroup.addPage(currentPageObject);
+ currentPageGroup.writeToStream(this.outputStream);
} else {
document.addPage(currentPageObject);
+ document.writeToStream(this.outputStream);
}
+ currentPageObject = null;
+ currentPage = null;
}
- currentPageObject = null;
- currentPage = null;
}
/**
@@ -328,14 +310,14 @@
/**
* Sets the orientation to be used for element positioning
- *
+ *
* @param orientation
* the orientation used for element positioning
*/
public void setOrientation(int orientation) {
this.orientation = orientation;
}
-
+
/**
* Creates the given page fonts in the current page
*
@@ -365,7 +347,7 @@
* the point size of the font
*/
public void createFont(int fontReference, AFPFont font, int size) {
- getCurrentPage().createFont(fontReference, font, size);
+ currentPage.createFont(fontReference, font, size);
}
/**
@@ -377,156 +359,17 @@
*/
public void createText(TextDataInfo textDataInfo) {
textDataInfo.setOrientation(orientation);
- getCurrentPage().createText(textDataInfo);
+ currentPage.createText(textDataInfo);
}
/**
- * Creates a data object in the datastream. The data object resides
- * according to its type, info and MO:DCA-L (resource) support.
- *
- * @param dataObjectInfo the data object info
- *
- * @throws java.io.IOException an I/O exception of some sort has occurred.
- */
- public void createObject(DataObjectInfo dataObjectInfo) throws IOException {
- ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
- String uri = resourceInfo.getUri();
-
- if (uri == null) {
- uri = "/";
- }
- // if this is an instream data object adjust uri to ensure that it is
- // unique
- if (uri.endsWith("/")) {
- uri += "#" + (++instreamObjectCount);
- resourceInfo.setUri(uri);
- }
-
- // Update placement with current state
- ObjectAreaInfo areaInfo = dataObjectInfo.getObjectAreaInfo();
- areaInfo.setX(areaInfo.getX());
- areaInfo.setY(areaInfo.getY());
- areaInfo.setRotation(this.rotation);
-
- // Do we have a recognised/registered object type?
- Registry registry = Registry.getInstance();
- Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
- if (objectType != null) {
- dataObjectInfo.setObjectType(objectType);
- } else {
- log.info("Unknown object type for '" + dataObjectInfo + "'");
- }
-
- StoreInfo storeInfo = resourceManager.create(dataObjectInfo);
-
- if (objectType != null) {
-
- ResourceLevel resourceLevel = resourceInfo.getLevel();
-
- // is MO:DCA-L available?
- if (interchangeSet.supportsLevel2()) {
-
- // Can this data object use the include object (IOB) referencing
- // mechanism?
- if (objectType.isIncludable()) {
-
- // Create and return include
- String objectName = storeInfo.getObjectName();
- IncludeObject includeObj = factory.createInclude(objectName, dataObjectInfo);
- getCurrentPage().addObject(includeObj);
-
- // Record the resource cache key (uri) in the ResourceGroup
- ResourceGroup resourceGroup = getResourceGroup(resourceLevel);
- resourceGroup.addObject(storeInfo);
- return;
- } else {
- log.warn("Data object located at '" + uri + "'"
- + " of type '" + objectType.getMimeType() + "'"
- + " cannot be referenced with an include"
- + " so it will be embedded directly in the page");
- }
- } else {
- if (resourceLevel.isExternal()) {
- log.warn(interchangeSet
- + ": not available, object " + getName() + " will reside inline");
- }
- }
- }
- // Unrecognised/unsupported object type so add object reference directly in current page
- currentPageObject.addObject(storeInfo);
- }
-
-// /**
-// * Sets the object view port taking into account rotation.
-// *
-// * @param x
-// * the x position of the object
-// * @param y
-// * the y position of the object
-// * @param w
-// * the width of the object
-// * @param h
-// * the height of the object
-// * @param wr
-// * the resolution width of the object
-// * @param hr
-// * the resolution height of the object
-// * @return a new graphics object
-// */
-// private void setObjectViewPort(AbstractDataObject dataObj, int x, int y,
-// int w, int h, int wr, int hr) {
-// int xOrigin;
-// int yOrigin;
-// int width;
-// int height;
-// int widthRes;
-// int heightRes;
-// switch (this.rotation) {
-// case 90:
-// xOrigin = getCurrentPage().getWidth() - y - yOffset;
-// yOrigin = x + xOffset;
-// width = h;
-// height = w;
-// widthRes = hr;
-// heightRes = wr;
-// break;
-// case 180:
-// xOrigin = getCurrentPage().getWidth() - x - xOffset;
-// yOrigin = getCurrentPage().getHeight() - y - yOffset;
-// width = w;
-// height = h;
-// widthRes = wr;
-// heightRes = hr;
-// break;
-// case 270:
-// xOrigin = y + yOffset;
-// yOrigin = getCurrentPage().getHeight() - x - xOffset;
-// width = h;
-// height = w;
-// widthRes = hr;
-// heightRes = wr;
-// break;
-// default:
-// xOrigin = x + xOffset;
-// yOrigin = y + yOffset;
-// width = w;
-// height = h;
-// widthRes = wr;
-// heightRes = hr;
-// break;
-// }
-// dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes,
-// heightRes, rotation);
-// }
-
- /**
* Method to create a line on the current page.
*
* @param lineDataInfo the line data information.
*/
public void createLine(LineDataInfo lineDataInfo) {
lineDataInfo.setOrientation(orientation);
- getCurrentPage().createLine(lineDataInfo);
+ currentPage.createLine(lineDataInfo);
}
/**
@@ -568,7 +411,7 @@
* the name of the medium map
*/
public void createInvokeMediumMap(String name) {
- getCurrentPageGroup().createInvokeMediumMap(name);
+ currentPageGroup.createInvokeMediumMap(name);
}
/**
@@ -586,23 +429,23 @@
int yOrigin;
switch (orientation) {
case 90:
- xOrigin = getCurrentPage().getWidth() - y;
+ xOrigin = currentPage.getWidth() - y;
yOrigin = x;
break;
case 180:
- xOrigin = getCurrentPage().getWidth() - x;
- yOrigin = getCurrentPage().getHeight() - y;
+ xOrigin = currentPage.getWidth() - x;
+ yOrigin = currentPage.getHeight() - y;
break;
case 270:
xOrigin = y;
- yOrigin = getCurrentPage().getHeight() - x;
+ yOrigin = currentPage.getHeight() - x;
break;
default:
xOrigin = x;
yOrigin = y;
break;
}
- getCurrentPage().createIncludePageSegment(name, xOrigin, yOrigin);
+ currentPage.createIncludePageSegment(name, xOrigin, yOrigin);
}
/**
@@ -613,9 +456,9 @@
*/
public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) {
for (int i = 0; i < attributes.length; i++) {
- String name = (String) attributes[i].getKey();
- String value = (String) attributes[i].getValue();
- getCurrentPage().createTagLogicalElement(name, value);
+ String name = attributes[i].getKey();
+ String value = attributes[i].getValue();
+ currentPage.createTagLogicalElement(name, value);
}
}
@@ -627,9 +470,9 @@
*/
public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) {
for (int i = 0; i < attributes.length; i++) {
- String name = (String) attributes[i].getKey();
- String value = (String) attributes[i].getValue();
- getCurrentPageGroup().createTagLogicalElement(name, value);
+ String name = attributes[i].getKey();
+ String value = attributes[i].getValue();
+ currentPageGroup.createTagLogicalElement(name, value);
}
}
@@ -645,7 +488,7 @@
if (currentPageGroup != null) {
currentPageGroup.createTagLogicalElement(name, value);
} else {
- getCurrentPage().createTagLogicalElement(name, value);
+ currentPage.createTagLogicalElement(name, value);
}
}
@@ -656,37 +499,50 @@
* byte data
*/
public void createNoOperation(String content) {
- getCurrentPage().createNoOperation(content);
+ currentPage.createNoOperation(content);
}
/**
* Returns the current page group
- *
+ *
* @return the current page group
*/
- private PageGroup getCurrentPageGroup() {
- if (currentPageGroup == null) {
- this.currentPageGroup = factory.createPageGroup();
- }
- return currentPageGroup;
+ public PageGroup getCurrentPageGroup() {
+ return this.currentPageGroup;
+ }
+
+ /**
+ * Start a new document.
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred
+ */
+ public void startDocument() throws IOException {
+ this.document = factory.createDocument();
+ document.writeToStream(this.outputStream);
}
/**
* Start a new page group. When processing has finished on the current page
* group the {@link #endPageGroup()}method must be invoked to mark the page
* group ending.
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred
*/
- public void startPageGroup() {
- getCurrentPageGroup();
+ public void startPageGroup() throws IOException {
+ endPageGroup();
+ this.currentPageGroup = factory.createPageGroup();
}
/**
* Helper method to mark the end of the page group.
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred
*/
- public void endPageGroup() {
+ public void endPageGroup() throws IOException {
if (currentPageGroup != null) {
currentPageGroup.endPageGroup();
- getDocument().addPageGroup(currentPageGroup);
+ document.addPageGroup(currentPageGroup);
+ document.writeToStream(outputStream);
currentPageGroup = null;
}
}
@@ -724,25 +580,22 @@
}
/**
- * Sets the default resource group file
+ * Sets the MO:DCA interchange set to use
*
- * @param filePath the default resource group file path
+ * @param interchangeSet the MO:DCA interchange set
*/
- public void setDefaultResourceGroupFilePath(String filePath) {
- resourceManager.getExternalManager().setDefaultFilePath(filePath);
+ public void setInterchangeSet(InterchangeSet interchangeSet) {
+ this.interchangeSet = interchangeSet;
}
-// /**
-// * Returns the external resource group manager
-// *
-// * @return the resource group manager
-// */
-// protected ExternalResourceGroupManager getExternalResourceGroupManager() {
-// if (externalResourceGroupManager == null) {
-// this.externalResourceGroupManager = new ExternalResourceGroupManager();
-// }
-// return this.externalResourceGroupManager;
-// }
+ /**
+ * Returns the MO:DCA interchange set in use
+ *
+ * @return the MO:DCA interchange set in use
+ */
+ public InterchangeSet getInterchangeSet() {
+ return this.interchangeSet;
+ }
/**
* Returns the resource group for a given resource info
@@ -750,43 +603,16 @@
* @param level a resource level
* @return a resource group for the given resource info
*/
- private ResourceGroup getResourceGroup(ResourceLevel level) {
+ public ResourceGroup getResourceGroup(AFPResourceLevel level) {
ResourceGroup resourceGroup = null;
- if (level.isExternal()) {
- resourceGroup = resourceManager.getExternalManager().getResourceGroup(level);
- // use print-file level resource group in the absence
- // of an external resource group file definition
- if (resourceGroup == null) {
- level.setLevel(ResourceLevel.PRINT_FILE);
- }
- }
- if (level.isPrintFile()) {
- resourceGroup = getResourceGroup();
- } else if (level.isDocument()) {
- resourceGroup = getDocument().getResourceGroup();
+ if (level.isDocument()) {
+ resourceGroup = document.getResourceGroup();
} else if (level.isPageGroup()) {
- resourceGroup = getCurrentPageGroup().getResourceGroup();
+ resourceGroup = currentPageGroup.getResourceGroup();
} else if (level.isPage()) {
resourceGroup = currentPageObject.getResourceGroup();
- }
+ }
return resourceGroup;
}
- /**
- * Sets the MO:DCA interchange set to use
- *
- * @param interchangeSet the MO:DCA interchange set
- */
- public void setInterchangeSet(InterchangeSet interchangeSet) {
- this.interchangeSet = interchangeSet;
- }
-
- /**
- * Returns the MO:DCA interchange set in use
- *
- * @return the MO:DCA interchange set in use
- */
- public InterchangeSet getInterchangeSet() {
- return this.interchangeSet;
- }
}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataStream.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java Wed Aug 27 05:35:44 2008
@@ -21,19 +21,19 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Iterator;
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
+import org.apache.fop.util.store.Streamable;
/**
* The document is the highest level of the MO:DCA data-stream document
- * component hierarchy. Documents can be made up of pages, and the pages,
- * which are at the intermediate level, can be made up of objects. Objects
- * are at the lowest level, and can be bar codes, graphics, images, and
- * presentation text.
+ * component hierarchy. Documents can be made up of pages, and the pages, which
+ * are at the intermediate level, can be made up of objects. Objects are at the
+ * lowest level, and can be bar codes, graphics, images, and presentation text.
*
- * At each level of the hierarchy certain sets of MO:DCA data structures,
- * called structured fields, are permissible. The document, pages and objects
- * are bounded by structured fields that define their beginnings and their ends.
+ * At each level of the hierarchy certain sets of MO:DCA data structures, called
+ * structured fields, are permissible. The document, pages and objects are
+ * bounded by structured fields that define their beginnings and their ends.
* These structured fields, called begin-end pairs, provide an envelope for the
* data-stream components. This feature enables a processor of the data stream
* that is not fully compliant with the architecture to bypass those objects
@@ -41,42 +41,32 @@
* abilities.
*
* A presentation document is one that has been formatted and is intended for
- * presentation, usually on a printer or display device. A data stream containing
- * a presentation document should produce the same document content in the
- * same format on different printers or display devices dependent, however,
- * on the capabilities of each of the printers or display devices. A presentation
- * document can reference resources that are to be included as part of the
- * document to be presented.
+ * presentation, usually on a printer or display device. A data stream
+ * containing a presentation document should produce the same document content
+ * in the same format on different printers or display devices dependent,
+ * however, on the capabilities of each of the printers or display devices. A
+ * presentation document can reference resources that are to be included as part
+ * of the document to be presented.
*
*/
-public final class Document extends AbstractResourceEnvironmentGroupContainer {
+public final class Document extends AbstractResourceEnvironmentGroupContainer implements Streamable {
- /**
- * Static default generated name reference
- */
- private static final String DEFAULT_NAME = "DOC00001";
-
- /**
- * The document completion state
- */
- private boolean complete = false;
+ /** The document started state */
+ private boolean started = false;
- /**
- * Default constructor for the document object.
- * @param resourceManager the resource manager
- */
- public Document(ResourceManager resourceManager) {
- this(resourceManager, DEFAULT_NAME);
- }
+ /** The document completion state */
+ private boolean complete = false;
/**
* Constructor for the document object.
- *
- * @param resourceManager the resource manager
- * @param name the name of the document
+ *
+ * @param factory
+ * the object factory
+ * @param name
+ * the name of the document
*/
- public Document(ResourceManager resourceManager, String name) {
- super(resourceManager, name);
+ public Document(Factory factory, String name) {
+ super(factory, name);
}
/**
@@ -88,25 +78,13 @@
/**
* Returns an indication if the page group is complete
- *
+ *
* @return whether or not this page group is complete
*/
public boolean isComplete() {
return complete;
}
- /**
- * Accessor method to write the AFP datastream for document.
- *
- * @param os The stream to write to
- * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
- */
- public void write(OutputStream os) throws IOException {
- if (isComplete()) {
- super.write(os);
- }
- }
-
/** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
byte[] data = new byte[17];
@@ -120,9 +98,33 @@
copySF(data, Type.END, Category.DOCUMENT);
os.write(data);
}
-
+
/** {@inheritDoc} */
public String toString() {
return this.name;
}
+
+ /** {@inheritDoc} */
+ public void writeToStream(OutputStream os) throws IOException {
+ if (!started) {
+ writeStart(os);
+ started = true;
+ }
+
+ Iterator it = objects.iterator();
+ while (it.hasNext()) {
+ AbstractAFPObject ao = (AbstractAFPObject)it.next();
+ if (ao instanceof PageGroup && ((PageGroup)ao).isComplete()
+ || ao instanceof PageObject && ((PageObject)ao).isComplete()) {
+ ao.writeToStream(os);
+ it.remove();
+ } else {
+ break;
+ }
+ }
+
+ if (complete) {
+ writeEnd(os);
+ }
+ }
}
\ No newline at end of file
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,522 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.OutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.goca.GraphicsData;
+import org.apache.fop.render.afp.ioca.ImageContent;
+import org.apache.fop.render.afp.ioca.ImageRasterData;
+import org.apache.fop.render.afp.ioca.ImageSegment;
+import org.apache.fop.render.afp.tools.StringUtils;
+
+/**
+ * Creator of MO:DCA data objects (mostly)
+ */
+public class Factory {
+
+ /** Static logging instance */
+ private static final Log log = LogFactory.getLog(Factory.class);
+
+ private static final String OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX = "OEG";
+
+ private static final String ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX = "AEG";
+
+ private static final String IMAGE_NAME_PREFIX = "IMG";
+
+ private static final String GRAPHIC_NAME_PREFIX = "GRA";
+
+ private static final String BARCODE_NAME_PREFIX = "BAR";
+
+// private static final String OTHER_NAME_PREFIX = "OTH";
+
+ private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC";
+
+ private static final String RESOURCE_NAME_PREFIX = "RES";
+
+ private static final String RESOURCE_GROUP_NAME_PREFIX = "RG";
+
+ private static final String PAGE_GROUP_NAME_PREFIX = "PGP";
+
+ private static final String PAGE_NAME_PREFIX = "PGN";
+
+ private static final String OVERLAY_NAME_PREFIX = "OVL";
+
+ private static final String PRESENTATION_TEXT_NAME_PREFIX = "PT";
+
+ private static final String DOCUMENT_NAME_PREFIX = "DOC";
+
+ private static final String IM_IMAGE_NAME_PREFIX = "IMIMG";
+
+ private static final String IMAGE_SEGMENT_NAME_PREFIX = "IS";
+
+
+ /** the page group count */
+ private int pageGroupCount = 0;
+
+ /** the page count */
+ private int pageCount = 0;
+
+ /** the image count */
+ private int imageCount = 0;
+
+ /** the im image count */
+ private int imImageCount = 0;
+
+ /** the image segment count */
+ private int imageSegmentCount = 0;
+
+ /** the graphic count */
+ private int graphicCount = 0;
+
+ /** the object container count */
+ private int objectContainerCount = 0;
+
+ /** the resource count */
+ private int resourceCount = 0;
+
+ /** the resource group count */
+ private int resourceGroupCount = 0;
+
+ /** the overlay count */
+ private int overlayCount = 0;
+
+ /** the presentation text object count */
+ private int textObjectCount = 0;
+
+ /** the active environment group count */
+ private int activeEnvironmentGroupCount = 0;
+
+ /** the document count */
+ private int documentCount = 0;
+
+ /** the object environment group count */
+ private int objectEnvironmentGroupCount = 0;
+
+ /**
+ * Main constructor
+ */
+ public Factory() {
+ }
+
+ /**
+ * Creates a new IOCA {@link ImageObject}
+ *
+ * @return a new {@link ImageObject}
+ */
+ public ImageObject createImageObject() {
+ String name = IMAGE_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++imageCount), '0', 5);
+ ImageObject imageObject = new ImageObject(this, name);
+ return imageObject;
+ }
+
+ /**
+ * Creates an IOCA {@link IMImageObject}
+ *
+ * @return a new {@link IMImageObject}
+ */
+ public IMImageObject createIMImageObject() {
+ String name = IM_IMAGE_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++imImageCount), '0', 3);
+ IMImageObject imImageObject = new IMImageObject(name);
+ return imImageObject;
+ }
+
+ /**
+ * Creates a new GOCA {@link GraphicsObject}
+ *
+ * @return a new {@link GraphicsObject}
+ */
+ public GraphicsObject createGraphic() {
+ String name = GRAPHIC_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5);
+ GraphicsObject graphicsObj = new GraphicsObject(this, name);
+ return graphicsObj;
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ObjectContainer}
+ *
+ * @return a new {@link ObjectContainer}
+ */
+ public ObjectContainer createObjectContainer() {
+ String name = OBJECT_CONTAINER_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++objectContainerCount), '0', 6);
+ return new ObjectContainer(this, name);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ResourceObject}
+ *
+ * @param resourceName the resource object name
+ * @return a new {@link ResourceObject}
+ */
+ public ResourceObject createResource(String resourceName) {
+ return new ResourceObject(resourceName);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ResourceObject}
+ *
+ * @return a new {@link ResourceObject}
+ */
+ public ResourceObject createResource() {
+ String name = RESOURCE_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++resourceCount), '0', 5);
+ return createResource(name);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link PageGroup}
+ *
+ * @return a new {@link PageGroup}
+ */
+ public PageGroup createPageGroup() {
+ String name = PAGE_GROUP_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++pageGroupCount), '0', 5);
+ return new PageGroup(this, name);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ActiveEnvironmentGroup}
+ *
+ * @param width the page width
+ * @param height the page height
+ * @param widthRes the page width resolution
+ * @param heightRes the page height resolution
+ * @return a new {@link ActiveEnvironmentGroup}
+ */
+ public ActiveEnvironmentGroup createActiveEnvironmentGroup(
+ int width, int height, int widthRes, int heightRes) {
+ String name = ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++activeEnvironmentGroupCount ), '0', 5);
+ return new ActiveEnvironmentGroup(this, name, width, height, widthRes, heightRes);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ResourceGroup}
+ *
+ * @return a new {@link ResourceGroup}
+ */
+ public ResourceGroup createResourceGroup() {
+ String name = RESOURCE_GROUP_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6);
+ return new ResourceGroup(name);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link StreamedResourceGroup}
+ *
+ * @param os the outputstream of the streamed resource group
+ * @return a new {@link StreamedResourceGroup}
+ */
+ public StreamedResourceGroup createStreamedResourceGroup(OutputStream os) {
+ String name = RESOURCE_GROUP_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6);
+ return new StreamedResourceGroup(name, os);
+ }
+
+ /**
+ * Creates a new MO:DCA {@link PageObject}.
+ *
+ * @param pageWidth
+ * the width of the page
+ * @param pageHeight
+ * the height of the page
+ * @param pageRotation
+ * the rotation of the page
+ * @param pageWidthRes
+ * the width resolution of the page
+ * @param pageHeightRes
+ * the height resolution of the page
+ *
+ * @return a new {@link PageObject}
+ */
+ public PageObject createPage(int pageWidth, int pageHeight, int pageRotation,
+ int pageWidthRes, int pageHeightRes) {
+ String pageName = PAGE_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++pageCount), '0', 5);
+ return new PageObject(this, pageName, pageWidth, pageHeight,
+ pageRotation, pageWidthRes, pageHeightRes);
+ }
+
+
+ /**
+ * Creates a new MO:DCA {@link PresentationTextObject}.
+ *
+ * @return a new {@link PresentationTextObject}
+ */
+ public PresentationTextObject createPresentationTextObject() {
+ String textObjectName = PRESENTATION_TEXT_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++textObjectCount), '0', 6);
+ return new PresentationTextObject(textObjectName);
+ }
+
+
+ /**
+ * Creates a new MO:DCA {@link Overlay}.
+ *
+ * @param width
+ * the width of the overlay
+ * @param height
+ * the height of the overlay
+ * @param widthRes
+ * the width resolution of the overlay
+ * @param heightRes
+ * the height resolution of the overlay
+ * @param overlayRotation
+ * the rotation of the overlay
+ *
+ * @return a new {@link Overlay}.
+ */
+ public Overlay createOverlay(int width, int height,
+ int widthRes, int heightRes, int overlayRotation) {
+ String overlayName = OVERLAY_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5);
+ Overlay overlay = new Overlay(this, overlayName, width, height,
+ overlayRotation, widthRes, heightRes);
+ return overlay;
+ }
+
+ /**
+ * Creates a MO:DCA {@link Document}
+ *
+ * @return a new {@link Document}
+ */
+ public Document createDocument() {
+ String documentName = DOCUMENT_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++documentCount), '0', 5);
+ Document document = new Document(this, documentName);
+ return document;
+ }
+
+ /**
+ * Creates a MO:DCA {@link MapCodedFont}
+ *
+ * @return a new {@link MapCodedFont}
+ */
+ public MapCodedFont createMapCodedFont() {
+ MapCodedFont mapCodedFont = new MapCodedFont();
+ return mapCodedFont;
+ }
+
+ /**
+ * Creates a MO:DCA {@link IncludePageSegment}
+ *
+ * @param name the page segment name
+ * @param x the x coordinate
+ * @param y the y coordinate
+ *
+ * @return a new {@link IncludePageSegment}
+ */
+ public IncludePageSegment createIncludePageSegment(String name, int x, int y) {
+ IncludePageSegment includePageSegment = new IncludePageSegment(name, x, y);
+ return includePageSegment;
+ }
+
+ /**
+ * Creates a MO:DCA {@link IncludeObject}
+ *
+ * @param name the name of this include object
+ * @return a new {@link IncludeObject}
+ */
+ public IncludeObject createInclude(String name) {
+ IncludeObject includeObject = new IncludeObject(name);
+ return includeObject;
+ }
+
+ /**
+ * Creates a MO:DCA {@link TagLogicalElement}
+ *
+ * @param name name of the element
+ * @param value value of the element
+ * @return a new {@link TagLogicalElement}
+ */
+ public TagLogicalElement createTagLogicalElement(String name, String value) {
+ TagLogicalElement tle = new TagLogicalElement(name, value);
+ return tle;
+ }
+
+ /**
+ * Creates an {@link DataStream}
+ *
+ * @param outputStream an outputstream to write to
+ * @return a new {@link DataStream}
+ */
+ public DataStream createDataStream(OutputStream outputStream) {
+ DataStream dataStream = new DataStream(this, outputStream);
+ return dataStream;
+ }
+
+ /**
+ * Creates a new MO:DCA {@link PageDescriptor}
+ *
+ * @param width the page width.
+ * @param height the page height.
+ * @param widthRes the page width resolution.
+ * @param heightRes the page height resolution.
+ * @return a new {@link PageDescriptor}
+ */
+ public PageDescriptor createPageDescriptor(int width, int height, int widthRes, int heightRes) {
+ PageDescriptor pageDescriptor = new PageDescriptor(width, height, widthRes, heightRes);
+ return pageDescriptor;
+ }
+
+ /**
+ * Returns a new MO:DCA {@link ObjectEnvironmentGroup}
+ *
+ * @return a new {@link ObjectEnvironmentGroup}
+ */
+ public ObjectEnvironmentGroup createObjectEnvironmentGroup() {
+ String oegName = OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++objectEnvironmentGroupCount), '0', 5);
+ ObjectEnvironmentGroup objectEnvironmentGroup = new ObjectEnvironmentGroup(this, oegName);
+ return objectEnvironmentGroup;
+ }
+
+ /**
+ * Creates a new GOCA {@link GraphicsData}
+ *
+ * @return a new {@link GraphicsData}
+ */
+ public GraphicsData createGraphicsData() {
+ GraphicsData graphicsData = new GraphicsData();
+ return graphicsData;
+ }
+
+ /**
+ * Creates a new {@link ObjectAreaDescriptor}
+ *
+ * @param width the object width.
+ * @param height the object height.
+ * @param widthRes the object width resolution.
+ * @param heightRes the object height resolution.
+ * @return a new {@link ObjectAreaDescriptor}
+ */
+ public ObjectAreaDescriptor createObjectAreaDescriptor(
+ int width, int height, int widthRes, int heightRes) {
+ ObjectAreaDescriptor objectAreaDescriptor
+ = new ObjectAreaDescriptor(width, height, widthRes, heightRes);
+ return objectAreaDescriptor;
+ }
+
+ /**
+ * Creates a new {@link ObjectAreaPosition}
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ * @param rotation The coordinate system rotation (must be 0, 90, 180, 270).
+ * @return a new {@link ObjectAreaPosition}
+ */
+ public ObjectAreaPosition createObjectAreaPosition(int x, int y,
+ int rotation) {
+ ObjectAreaPosition objectAreaPosition = new ObjectAreaPosition(
+ x, y, rotation);
+ return objectAreaPosition;
+ }
+
+ /**
+ * Creates a new {@link ImageDataDescriptor}
+ *
+ * @param width the image width
+ * @param height the image height
+ * @param widthRes the x resolution of the image
+ * @param heightRes the y resolution of the image
+ * @return a new {@link ImageDataDescriptor}
+ */
+ public ImageDataDescriptor createImageDataDescriptor(
+ int width, int height, int widthRes, int heightRes) {
+ ImageDataDescriptor imageDataDescriptor = new ImageDataDescriptor(
+ width, height, widthRes, heightRes);
+ return imageDataDescriptor;
+ }
+
+ /**
+ * Creates a new GOCA {@link GraphicsDataDescriptor}
+ *
+ * @param xlwind the left edge of the graphics window
+ * @param xrwind the right edge of the graphics window
+ * @param ybwind the top edge of the graphics window
+ * @param ytwind the bottom edge of the graphics window
+ * @param widthRes the x resolution of the graphics window
+ * @param heightRes the y resolution of the graphics window
+ * @return a new {@link GraphicsDataDescriptor}
+ */
+ public GraphicsDataDescriptor createGraphicsDataDescriptor(
+ int xlwind, int xrwind, int ybwind, int ytwind, int widthRes, int heightRes) {
+ GraphicsDataDescriptor graphicsDataDescriptor = new GraphicsDataDescriptor(
+ xlwind, xrwind, ybwind, ytwind, widthRes, heightRes);
+ return graphicsDataDescriptor;
+ }
+
+ /**
+ * Creates a new MO:DCA {@link ContainerDataDescriptor}
+ *
+ * @param width the container data width
+ * @param height the container data height
+ * @param widthRes the container data width resolution
+ * @param heightRes the container data height resolution
+ * @return a new {@link ContainerDataDescriptor}
+ */
+ public ContainerDataDescriptor createContainerDataDescriptor(
+ int width, int height, int widthRes, int heightRes) {
+ ContainerDataDescriptor containerDataDescriptor
+ = new ContainerDataDescriptor(width, height, widthRes, heightRes);
+ return containerDataDescriptor;
+ }
+
+ /**
+ * Creates a new IOCA {@link ImageSegment}
+ *
+ * @return a new {@link ImageSegment}
+ */
+ public ImageSegment createImageSegment() {
+ String name = IMAGE_SEGMENT_NAME_PREFIX
+ + StringUtils.lpad(String.valueOf(++imageSegmentCount), '0', 2);
+ ImageSegment imageSegment = new ImageSegment(this, name);
+ return imageSegment;
+ }
+
+ /**
+ * Creates an new IOCA {@link ImageContent}
+ *
+ * @return an {@link ImageContent}
+ */
+ public ImageContent createImageContent() {
+ ImageContent imageContent = new ImageContent();
+ return imageContent;
+ }
+
+
+ /**
+ * Creates a new IOCA {@link ImageRasterData}
+ *
+ * @param rasterData raster data
+ * @return a new {@link ImageRasterData}
+ */
+ public ImageRasterData createImageRasterData(byte[] rasterData) {
+ ImageRasterData imageRasterData = new ImageRasterData(rasterData);
+ return imageRasterData;
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Factory.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* 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.
@@ -27,59 +27,64 @@
/**
* GOCA Graphics Data Descriptor
*/
-public class GraphicsDataDescriptor extends AbstractAFPObject {
+public class GraphicsDataDescriptor extends AbstractDescriptor {
+
+ private final int xlwind;
+
+ private final int xrwind;
+
+ private final int ybwind;
+
+ private final int ytwind;
- private int xlwind;
- private int xrwind;
- private int ybwind;
- private int ytwind;
- private int xresol;
- private int yresol;
-
/**
* Main constructor
- * @param xresol the x resolution of the graphics window
- * @param yresol the y resolution of the graphics window
- * @param xlwind the left edge of the graphics window
- * @param xrwind the right edge of the graphics window
- * @param ybwind the top edge of the graphics window
- * @param ytwind the bottom edge of the graphics window
+ *
+ * @param xlwind
+ * the left edge of the graphics window
+ * @param xrwind
+ * the right edge of the graphics window
+ * @param ybwind
+ * the top edge of the graphics window
+ * @param ytwind
+ * the bottom edge of the graphics window
+ * @param widthRes
+ * the width resolution of the graphics window
+ * @param heightRes
+ * the height resolution of the graphics window
*/
- protected GraphicsDataDescriptor(int xresol, int yresol,
- int xlwind, int xrwind, int ybwind, int ytwind) {
- this.xresol = xresol;
- this.yresol = yresol;
+ protected GraphicsDataDescriptor(int xlwind, int xrwind, int ybwind,
+ int ytwind, int widthRes, int heightRes) {
this.xlwind = xlwind;
this.xrwind = xrwind;
this.ybwind = ybwind;
this.ytwind = ytwind;
- }
+ super.widthRes = widthRes;
+ super.heightRes = heightRes;
+ }
- private static final int ABS = 2;
- private static final int IMGRES = 8;
+ /** {@inheritDoc} */
+ public void writeToStream(OutputStream os) throws IOException {
+ byte[] headerData = new byte[9];
+ copySF(headerData, Type.DESCRIPTOR, Category.GRAPHICS);
+ byte[] drawingOrderSubsetData = getDrawingOrderSubset();
+ byte[] windowSpecificationData = getWindowSpecification();
+ byte[] len = BinaryUtils.convert(
+ 8 + drawingOrderSubsetData.length + windowSpecificationData.length, 2);
+ headerData[1] = len[0];
+ headerData[2] = len[1];
+ os.write(headerData);
+ os.write(drawingOrderSubsetData);
+ os.write(windowSpecificationData);
+ }
/**
- * {@inheritDoc}
+ * Returns the drawing order subset data
+ *
+ * @return the drawing order subset data
*/
- public void write(OutputStream os) throws IOException {
- byte[] xreswind = BinaryUtils.convert(xresol * 10, 2);
- byte[] yreswind = BinaryUtils.convert(yresol * 10, 2);
- byte[] xlcoord = BinaryUtils.convert(xlwind, 2);
- byte[] xrcoord = BinaryUtils.convert(xrwind, 2);
- byte[] xbcoord = BinaryUtils.convert(ybwind, 2);
- byte[] ytcoord = BinaryUtils.convert(ytwind, 2);
- byte[] imxyres = xreswind;
- byte[] data = new byte[] {
- 0x5A,
- 0x00,
- 0x25,
- (byte) 0xD3,
- (byte) 0xA6,
- (byte) 0xBB,
- 0x00, // Flags
- 0x00, // Reserved
- 0x00, // Reserved
-
+ private byte[] getDrawingOrderSubset() {
+ final byte[] data = new byte[] {
// Drawing order subset
(byte) 0xF7,
7, // LENGTH
@@ -89,21 +94,41 @@
0x02, // SUBLEV
0x00, // VERSION 0
0x01, // LENGTH (of following field)
- 0x00, // GEOM
+ 0x00 // GEOM
+ };
+ return data;
+ }
+
+ private static final int ABS = 2;
+ private static final int IMGRES = 8;
- // Window specification
- (byte) 0xF6,
- 18, // LENGTH
+ /**
+ * Returns the window specification data
+ *
+ * @return the window specification data
+ */
+ private byte[] getWindowSpecification() {
+ byte[] xlcoord = BinaryUtils.convert(xlwind, 2);
+ byte[] xrcoord = BinaryUtils.convert(xrwind, 2);
+ byte[] xbcoord = BinaryUtils.convert(ybwind, 2);
+ byte[] ytcoord = BinaryUtils.convert(ytwind, 2);
+ byte[] xResol = BinaryUtils.convert(widthRes * 10, 2);
+ byte[] yResol = BinaryUtils.convert(heightRes * 10, 2);
+ byte[] imxyres = xResol;
+
+ final byte[] data = new byte[] {
+ // Window specification
+ (byte) 0xF6, 18, // LENGTH
(ABS + IMGRES), // FLAGS (ABS)
0x00, // reserved (must be zero)
0x00, // CFORMAT (coordinate format - 16bit high byte first signed)
0x00, // UBASE (unit base - ten inches)
- xreswind[0], // XRESOL
- xreswind[1],
- yreswind[0], // YRESOL
- yreswind[1],
+ xResol[0], // XRESOL
+ xResol[1],
+ yResol[0], // YRESOL
+ yResol[1],
imxyres[0], // IMXYRES (Number of image points per ten inches
- imxyres[1], // in X and Y directions)
+ imxyres[1], // in X and Y directions)
xlcoord[0], // XLWIND
xlcoord[1],
xrcoord[0], // XRWIND
@@ -113,6 +138,6 @@
ytcoord[0], // YTWIND
ytcoord[1]
};
- os.write(data);
+ return data;
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* 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.
@@ -22,15 +22,14 @@
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.List;
-import org.apache.fop.render.afp.ObjectAreaInfo;
+import org.apache.fop.render.afp.AFPDataObjectInfo;
+import org.apache.fop.render.afp.AFPObjectAreaInfo;
import org.apache.fop.render.afp.goca.GraphicsBox;
import org.apache.fop.render.afp.goca.GraphicsData;
import org.apache.fop.render.afp.goca.GraphicsFillet;
import org.apache.fop.render.afp.goca.GraphicsFullArc;
-import org.apache.fop.render.afp.goca.GraphicsImageBegin;
-import org.apache.fop.render.afp.goca.GraphicsImageData;
-import org.apache.fop.render.afp.goca.GraphicsImageEnd;
import org.apache.fop.render.afp.goca.GraphicsLine;
import org.apache.fop.render.afp.goca.GraphicsSetArcParameters;
import org.apache.fop.render.afp.goca.GraphicsSetCharacterSet;
@@ -43,52 +42,43 @@
/**
* Top-level GOCA graphics object.
- *
+ *
* Acts as container and factory of all other graphic objects
*/
public class GraphicsObject extends AbstractDataObject {
-
+
/** The graphics data */
private GraphicsData graphicsData = null;
+ /** list of objects contained within this container */
+ protected List/*<PreparedAFPObject>*/ objects
+ = new java.util.ArrayList/*<PreparedAFPObject>*/();
+
/**
* Default constructor
- *
+ *
+ * @param factory the object factory
* @param name the name of graphics object
*/
- public GraphicsObject(String name) {
- super(name);
+ public GraphicsObject(Factory factory, String name) {
+ super(factory, name);
}
/** {@inheritDoc} */
- public void setViewport(ObjectAreaInfo objectAreaInfo) {
- super.setViewport(objectAreaInfo);
- getObjectEnvironmentGroup().setGraphicsData(
- objectAreaInfo.getWidthRes(),
- objectAreaInfo.getHeightRes(),
- 0,
- objectAreaInfo.getX() + objectAreaInfo.getWidth(),
- 0,
- objectAreaInfo.getY() + objectAreaInfo.getHeight());
- }
+ public void setViewport(AFPDataObjectInfo dataObjectInfo) {
+ super.setViewport(dataObjectInfo);
- /** {@inheritDoc} */
- protected byte getCategoryCode() {
- return (byte)0xBB;
- }
+ AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
+ GraphicsDataDescriptor graphicsDataDescriptor
+ = factory.createGraphicsDataDescriptor(
+ 0,
+ objectAreaInfo.getWidth(),
+ 0,
+ objectAreaInfo.getHeight(),
+ objectAreaInfo.getWidthRes(),
+ objectAreaInfo.getHeightRes());
- /** {@inheritDoc} */
- protected void writeStart(OutputStream os) throws IOException {
- byte[] data = new byte[17];
- copySF(data, Type.BEGIN, Category.GRAPHICS);
- os.write(data);
- }
-
- /** {@inheritDoc} */
- protected void writeEnd(OutputStream os) throws IOException {
- byte[] data = new byte[17];
- copySF(data, Type.END, Category.GRAPHICS);
- os.write(data);
+ getObjectEnvironmentGroup().setDataDescriptor(graphicsDataDescriptor);
}
/** {@inheritDoc} */
@@ -101,10 +91,10 @@
graphicsData.addObject(drawingOrder);
return drawingOrder;
}
-
+
/**
* Gets the current graphics data, creating a new one if necessary
- *
+ *
* @return the current graphics data
*/
private GraphicsData getData() {
@@ -113,21 +103,21 @@
}
return this.graphicsData;
}
-
+
/**
* Creates a new graphics data
- *
+ *
* @return a newly created graphics data
*/
private GraphicsData newData() {
- this.graphicsData = new GraphicsData();
- super.addObject(graphicsData);
+ this.graphicsData = factory.createGraphicsData();
+ objects.add(graphicsData);
return graphicsData;
}
-
+
/**
* Sets the current color
- *
+ *
* @param col the active color to use
*/
public void setColor(Color col) {
@@ -136,7 +126,7 @@
/**
* Sets the current position
- *
+ *
* @param coords the x and y coordinates of the current position
*/
public void setCurrentPosition(int[] coords) {
@@ -145,7 +135,7 @@
/**
* Sets the line width
- *
+ *
* @param multiplier the line width multiplier
*/
public void setLineWidth(int multiplier) {
@@ -155,17 +145,17 @@
/**
* Sets the line type
- *
+ *
* @param type the line type
*/
public void setLineType(byte type) {
GraphicsSetLineType lt = new GraphicsSetLineType(type);
addObject(lt);
- }
+ }
/**
* Sets whether to fill the next shape
- *
+ *
* @param fill whether to fill the next shape
*/
public void setFill(boolean fill) {
@@ -175,10 +165,10 @@
);
addObject(pat);
}
-
+
/**
* Sets the character set to use
- *
+ *
* @param fontReference the character set (font) reference
*/
public void setCharacterSet(int fontReference) {
@@ -187,7 +177,7 @@
/**
* Adds a line at the given x/y coordinates
- *
+ *
* @param coords the x/y coordinates (can be a series)
*/
public void addLine(int[] coords) {
@@ -196,7 +186,7 @@
/**
* Adds a box at the given coordinates
- *
+ *
* @param coords the x/y coordinates
*/
public void addBox(int[] coords) {
@@ -205,7 +195,7 @@
/**
* Adds a fillet (curve) at the given coordinates
- *
+ *
* @param coords the x/y coordinates
*/
public void addFillet(int[] coords) {
@@ -214,7 +204,7 @@
/**
* Sets the arc parameters
- *
+ *
* @param xmaj the maximum value of the x coordinate
* @param ymin the minimum value of the y coordinate
* @param xmin the minimum value of the x coordinate
@@ -226,7 +216,7 @@
/**
* Adds an arc
- *
+ *
* @param x the x coordinate
* @param y the y coordinate
* @param mh the integer portion of the multiplier
@@ -236,28 +226,22 @@
addObject(new GraphicsFullArc(x, y, mh, mhr));
}
- /**
- * Adds an image
- *
- * @param x the x coordinate
- * @param y the y coordinate
- * @param width the image width
- * @param height the image height
- * @param imgData the image data
- */
- public void addImage(int x, int y, int width, int height, byte[] imgData) {
- addObject(new GraphicsImageBegin(x, y, width, height));
- for (int startIndex = 0;
- startIndex <= imgData.length;
- startIndex += GraphicsImageData.MAX_DATA_LEN) {
- addObject(new GraphicsImageData(imgData, startIndex));
- }
- addObject(new GraphicsImageEnd());
- }
+// /**
+// * Adds an image
+// *
+// * @param x the x coordinate
+// * @param y the y coordinate
+// * @param width the image width
+// * @param height the image height
+// * @param imgData the image data
+// */
+// public void addImage(int x, int y, int width, int height, byte[] imgData) {
+// addObject(new GraphicsImage(x, y, width, height, imgData));
+// }
/**
* Adds a string
- *
+ *
* @param str the string
* @param x the x coordinate
* @param y the y coordinate
@@ -265,7 +249,7 @@
public void addString(String str, int x, int y) {
addObject(new GraphicsString(str, x, y));
}
-
+
/**
* Begins a graphics area (start of fill)
*/
@@ -284,7 +268,7 @@
graphicsData.endArea();
}
}
-
+
/** {@inheritDoc} */
public String toString() {
return "GraphicsObject: " + getName();
@@ -296,4 +280,24 @@
public void newSegment() {
getData().newSegment();
}
+
+ /** {@inheritDoc} */
+ protected void writeStart(OutputStream os) throws IOException {
+ byte[] data = new byte[17];
+ copySF(data, Type.BEGIN, Category.GRAPHICS);
+ os.write(data);
+ }
+
+ /** {@inheritDoc} */
+ protected void writeContent(OutputStream os) throws IOException {
+ super.writeContent(os);
+ super.writeObjects(objects, os);
+ }
+
+ /** {@inheritDoc} */
+ protected void writeEnd(OutputStream os) throws IOException {
+ byte[] data = new byte[17];
+ copySF(data, Type.END, Category.GRAPHICS);
+ os.write(data);
+ }
}
\ No newline at end of file
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.render.afp.ioca.ImageCellPosition;
+import org.apache.fop.render.afp.ioca.ImageInputDescriptor;
+import org.apache.fop.render.afp.ioca.ImageOutputControl;
+import org.apache.fop.render.afp.ioca.ImageRasterData;
+
+/**
+ * An IM image data object specifies the contents of a raster image and
+ * its placement on a page, overlay, or page segment. An IM image can be
+ * either simple or complex. A simple image is composed of one or more Image
+ * Raster Data (IRD) structured fields that define the raster pattern for the
+ * entire image. A complex image is divided into regions called image cells.
+ * Each image cell is composed of one or more IRD structured fields that define
+ * the raster pattern for the image cell, and one Image Cell Position (ICP)
+ * structured field that defines the position of the image cell relative to
+ * the origin of the entire image. Each ICP also specifies the size of the
+ * image cell and a fill rectangle into which the cell is replicated.
+ * <p/>
+ */
+public class IMImageObject extends AbstractNamedAFPObject {
+
+ /**
+ * The image output control
+ */
+ private ImageOutputControl imageOutputControl = null;
+
+ /**
+ * The image input descriptor
+ */
+ private ImageInputDescriptor imageInputDescriptor = null;
+
+ /**
+ * The image cell position
+ */
+ private ImageCellPosition imageCellPosition = null;
+
+ /**
+ * The image rastor data
+ */
+ private ImageRasterData imageRasterData = null;
+
+ /**
+ * Constructor for the image object with the specified name,
+ * the name must be a fixed length of eight characters.
+ *
+ * @param name The name of the image.
+ */
+ public IMImageObject(String name) {
+ super(name);
+ }
+
+ /**
+ * Sets the ImageOutputControl.
+ *
+ * @param imageOutputControl The imageOutputControl to set
+ */
+ public void setImageOutputControl(ImageOutputControl imageOutputControl) {
+ this.imageOutputControl = imageOutputControl;
+ }
+
+ /**
+ * Sets the ImageCellPosition.
+ *
+ * @param imageCellPosition The imageCellPosition to set
+ */
+ public void setImageCellPosition(ImageCellPosition imageCellPosition) {
+ this.imageCellPosition = imageCellPosition;
+ }
+
+ /**
+ * Sets the ImageInputDescriptor.
+ *
+ * @param imageInputDescriptor The imageInputDescriptor to set
+ */
+ public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) {
+ this.imageInputDescriptor = imageInputDescriptor;
+ }
+
+ /**
+ * Sets the ImageRastorData.
+ *
+ * @param imageRasterData The imageRasterData to set
+ */
+ public void setImageRasterData(ImageRasterData imageRasterData) {
+ this.imageRasterData = imageRasterData;
+ }
+
+ /** {@inheritDoc} */
+ protected void writeContent(OutputStream os) throws IOException {
+ super.writeContent(os);
+ if (imageOutputControl != null) {
+ imageOutputControl.writeToStream(os);
+ }
+ if (imageInputDescriptor != null) {
+ imageInputDescriptor.writeToStream(os);
+ }
+ if (imageCellPosition != null) {
+ imageCellPosition.writeToStream(os);
+ }
+ if (imageRasterData != null) {
+ imageRasterData.writeToStream(os);
+ }
+ }
+
+ /** {@inheritDoc} */
+ protected void writeStart(OutputStream os) throws IOException {
+ byte[] data = new byte[17];
+ copySF(data, Type.BEGIN, Category.IM_IMAGE);
+ os.write(data);
+ }
+
+ /** {@inheritDoc} */
+ protected void writeEnd(OutputStream os) throws IOException {
+ byte[] data = new byte[17];
+ copySF(data, Type.END, Category.IM_IMAGE);
+ os.write(data);
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java Wed Aug 27 05:35:44 2008
@@ -24,61 +24,32 @@
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
+ * ImageDataDescriptor
*/
-public class ImageDataDescriptor extends AbstractAFPObject {
+public class ImageDataDescriptor extends AbstractDescriptor {
- private int widthRes = 0;
- private int heightRes = 0;
- private int width = 0;
- private int height = 0;
-
/**
* Constructor for a ImageDataDescriptor for the specified
* resolution, width and height.
- *
- * @param widthRes The horizontal resolution of the image.
- * @param heightRes The vertical resolution of the image.
+ *
* @param width The width of the image.
* @param height The height of the height.
+ * @param widthRes The horizontal resolution of the image.
+ * @param heightRes The vertical resolution of the image.
*/
- public ImageDataDescriptor(int widthRes, int heightRes, int width, int height) {
- this.widthRes = widthRes;
- this.heightRes = heightRes;
- this.width = width;
- this.height = height;
+ public ImageDataDescriptor(int width, int height, int widthRes, int heightRes) {
+ super(width, height, widthRes, heightRes);
}
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
-
- byte[] data = new byte[] {
- 0x5A,
- 0x00,
- 0x20,
- (byte) 0xD3,
- (byte) 0xA6,
- (byte) 0xFB,
- 0x00, // Flags
- 0x00, // Reserved
- 0x00, // Reserved
- 0x00, // Unit base - 10 Inches
- 0x00, // XRESOL
- 0x00, //
- 0x00, // YRESOL
- 0x00, //
- 0x00, // XSIZE
- 0x00, //
- 0x00, // YSIZE
- 0x00, //
- (byte)0xF7, // ID = Set IOCA Function Set
- 0x02, // Length
- 0x01, // Category = Function set identifier
- 0x0B, // FCNSET = IOCA FS 11
- };
-
- byte[] l = BinaryUtils.convert(data.length - 1, 2);
- data[1] = l[0];
- data[2] = l[1];
+ public void writeToStream(OutputStream os) throws IOException {
+ byte[] data = new byte[22];
+ copySF(data, Type.DESCRIPTOR, Category.IMAGE);
+
+ // SF length
+ byte[] len = BinaryUtils.convert(data.length - 1, 2);
+ data[1] = len[0];
+ data[2] = len[1];
byte[] x = BinaryUtils.convert(widthRes, 2);
data[10] = x[0];
@@ -96,6 +67,11 @@
data[16] = h[0];
data[17] = h[1];
+ data[18] = (byte)0xF7; // ID = Set IOCA Function Set
+ data[19] = 0x02; // Length
+ data[20] = 0x01; // Category = Function set identifier
+ data[21] = 0x0B; // FCNSET = IOCA FS 11
+
os.write(data);
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java Wed Aug 27 05:35:44 2008
@@ -19,121 +19,105 @@
package org.apache.fop.render.afp.modca;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.fop.render.afp.tools.BinaryUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.fop.render.afp.AFPDataObjectInfo;
+import org.apache.fop.render.afp.AFPImageObjectInfo;
+import org.apache.fop.render.afp.AFPObjectAreaInfo;
+import org.apache.fop.render.afp.ioca.ImageSegment;
/**
* An IOCA Image Data Object
*/
public class ImageObject extends AbstractDataObject {
- /**
- * The image segment
- */
+ private static final int MAX_DATA_LEN = 32759;
+
+ /** the image segment */
private ImageSegment imageSegment = null;
/**
* Constructor for the image object with the specified name,
* the name must be a fixed length of eight characters.
- *
+ *
* @param name The name of the image.
+ * @param factory the resource manager
*/
- public ImageObject(String name) {
- super(name);
+ public ImageObject(Factory factory, String name) {
+ super(factory, name);
}
- /**
- * Set the dimensions of the image.
- *
- * @param xresol the x resolution of the image
- * @param yresol the y resolution of the image
- * @param width the image width
- * @param height the image height
- */
- public void setImageParameters(int xresol, int yresol, int width, int height) {
- getObjectEnvironmentGroup().setImageData(xresol, yresol, width, height);
+ private ImageSegment getImageSegment() {
if (imageSegment == null) {
- imageSegment = new ImageSegment();
+ this.imageSegment = factory.createImageSegment();
}
- imageSegment.setImageSize(xresol, yresol, width, height);
+ return imageSegment;
+ }
+
+ /** {@inheritDoc} */
+ public void setViewport(AFPDataObjectInfo dataObjectInfo) {
+ super.setViewport(dataObjectInfo);
+
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo;
+ int dataWidth = imageObjectInfo.getDataWidth();
+ int dataHeight = imageObjectInfo.getDataHeight();
+
+ AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
+ int widthRes = objectAreaInfo.getWidthRes();
+ int heightRes = objectAreaInfo.getHeightRes();
+
+ ImageDataDescriptor imageDataDescriptor
+ = factory.createImageDataDescriptor(dataWidth, dataHeight, widthRes, heightRes);
+ getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor);
+
+ getImageSegment().setImageSize(dataWidth, dataHeight, widthRes, heightRes);
}
/**
* Sets the image encoding.
- *
+ *
* @param encoding The image encoding.
*/
- public void setImageEncoding(byte encoding) {
- if (imageSegment == null) {
- imageSegment = new ImageSegment();
- }
- imageSegment.setImageEncoding(encoding);
+ public void setEncoding(byte encoding) {
+ getImageSegment().setEncoding(encoding);
}
/**
* Sets the image compression.
- *
+ *
* @param compression The image compression.
*/
- public void setImageCompression(byte compression) {
- if (imageSegment == null) {
- imageSegment = new ImageSegment();
- }
- imageSegment.setImageCompression(compression);
+ public void setCompression(byte compression) {
+ getImageSegment().setCompression(compression);
}
/**
* Sets the image IDE size.
- *
+ *
* @param size The IDE size.
*/
- public void setImageIDESize(byte size) {
- if (imageSegment == null) {
- imageSegment = new ImageSegment();
- }
- imageSegment.setImageIDESize(size);
+ public void setIDESize(byte size) {
+ getImageSegment().setIDESize(size);
}
/**
* Sets the image IDE color model.
- *
+ *
* @param colorModel the IDE color model.
*/
- public void setImageIDEColorModel(byte colorModel) {
- if (imageSegment == null) {
- imageSegment = new ImageSegment();
- }
- imageSegment.setImageIDEColorModel(colorModel);
+ public void setIDEColorModel(byte colorModel) {
+ getImageSegment().setIDEColorModel(colorModel);
}
/**
* Set the data of the image.
- *
- * @param data The image data
+ *
+ * @param data the image data
*/
- public void setImageData(byte[] data) {
- if (imageSegment == null) {
- imageSegment = new ImageSegment();
- }
- imageSegment.setImageData(data);
- }
-
- /**
- * Helper method to return the start of the image object.
- *
- * @param len the length of this ipd start
- * @return byte[] The data stream.
- */
- private byte[] getImageData(int len) {
- byte[] data = new byte[9];
- copySF(data, SF_CLASS, Type.DATA, Category.IMAGE);
- byte[] l = BinaryUtils.convert(len + 8, 2);
- data[1] = l[0];
- data[2] = l[1];
- return data;
+ public void setData(byte[] data) {
+ getImageSegment().setData(data);
}
/** {@inheritDoc} */
@@ -146,17 +130,17 @@
/** {@inheritDoc} */
protected void writeContent(OutputStream os) throws IOException {
super.writeContent(os);
+
if (imageSegment != null) {
+ // TODO save memory!
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- imageSegment.write(baos);
- byte[] b = baos.toByteArray();
- int off = 0;
- while (off < b.length) {
- int len = Math.min(30000, b.length - off);
- os.write(getImageData(len));
- os.write(b, off, len);
- off += len;
- }
+ imageSegment.writeToStream(baos);
+ byte[] data = baos.toByteArray();
+
+ final byte[] dataHeader = new byte[9];
+ copySF(dataHeader, SF_CLASS, Type.DATA, Category.IMAGE);
+ final int lengthOffset = 1;
+ writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os);
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java Wed Aug 27 05:35:44 2008
@@ -58,16 +58,16 @@
* the included object is of type barcode
*/
public static final byte TYPE_BARCODE = (byte)0xEB;
-
+
/**
* the included object is of type image
*/
public static final byte TYPE_IMAGE = (byte)0xFB;
-
+
/**
* The object type (default is other)
*/
- private byte dataObjectType = TYPE_OTHER;
+ private byte objectType = TYPE_OTHER;
/**
* The orientation on the include object
@@ -75,13 +75,13 @@
private int orientation = 0;
/**
- * The X-axis origin of the object area
+ * The X-axis origin of the object area
*/
- private int xOffset = 0;
-
+ private int xOffset = 0;
+
/**
- * The Y-axis origin of the object area
- */
+ * The Y-axis origin of the object area
+ */
private int yOffset = 0;
/**
@@ -93,7 +93,7 @@
* The Y-axis origin defined in the object
*/
private int yContentOffset = 0;
-
+
/**
* Constructor for the include object with the specified name, the name must
* be a fixed length of eight characters and is the name of the referenced
@@ -122,8 +122,8 @@
}
/**
- * Sets the x and y offset to the origin in the object area
- *
+ * Sets the x and y offset to the origin in the object area
+ *
* @param x the X-axis origin of the object area
* @param y the Y-axis origin of the object area
*/
@@ -131,10 +131,10 @@
this.xOffset = x;
this.yOffset = y;
}
-
+
/**
* Sets the x and y offset of the content area to the object area
- *
+ *
* @param x the X-axis origin defined in the object
* @param y the Y-axis origin defined in the object
*/
@@ -142,18 +142,18 @@
this.xContentOffset = x;
this.yContentOffset = y;
}
-
+
/**
* Sets the data object type
- *
+ *
* @param type the data object type
*/
- public void setDataObjectType(byte type) {
- this.dataObjectType = type;
+ public void setObjectType(byte type) {
+ this.objectType = type;
}
-
+
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[36];
super.copySF(data, Type.INCLUDE, Category.DATA_RESOURCE);
@@ -163,18 +163,18 @@
data[2] = len[1];
data[17] = 0x00; // reserved
- data[18] = dataObjectType;
+ data[18] = objectType;
//XoaOset (object area)
if (xOffset >= -1) {
byte[] x = BinaryUtils.convert(xOffset, 3);
data[19] = x[0];
data[20] = x[1];
- data[21] = x[2];
+ data[21] = x[2];
} else {
data[19] = (byte)0xFF;
data[20] = (byte)0xFF;
- data[21] = (byte)0xFF;
+ data[21] = (byte)0xFF;
}
// YoaOset (object area)
@@ -182,20 +182,21 @@
byte[] y = BinaryUtils.convert(yOffset, 3);
data[22] = y[0];
data[23] = y[1];
- data[24] = y[2];
+ data[24] = y[2];
} else {
data[22] = (byte)0xFF;
data[23] = (byte)0xFF;
- data[24] = (byte)0xFF;
+ data[24] = (byte)0xFF;
}
+ // XoaOrent/YoaOrent
switch (orientation) {
case -1: // use x/y axis orientation defined in object
data[25] = (byte)0xFF; // x axis rotation
data[26] = (byte)0xFF; //
data[27] = (byte)0xFF; // y axis rotation
data[28] = (byte)0xFF;
- break;
+ break;
case 90:
data[25] = 0x2D;
data[26] = 0x00;
@@ -227,7 +228,7 @@
byte[] y = BinaryUtils.convert(xContentOffset, 3);
data[29] = y[0];
data[30] = y[1];
- data[31] = y[2];
+ data[31] = y[2];
} else {
data[29] = (byte)0xFF;
data[30] = (byte)0xFF;
@@ -239,7 +240,7 @@
byte[] y = BinaryUtils.convert(yContentOffset, 3);
data[32] = y[0];
data[33] = y[1];
- data[34] = y[2];
+ data[34] = y[2];
} else {
data[32] = (byte)0xFF;
data[33] = (byte)0xFF;
@@ -249,12 +250,11 @@
// Write structured field data
os.write(data);
-
- // Write triplet for FQN internal/external object reference
- byte[] tripletData = super.getTripletData();
+
+ // Write triplet for FQN internal/external object reference
os.write(tripletData);
}
-
+
/** {@inheritDoc} */
public String toString() {
return "IOB: " + this.getName();
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java Wed Aug 27 05:35:44 2008
@@ -87,7 +87,7 @@
}
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[25]; //(9 +16)
copySF(data, Type.INCLUDE, Category.PAGE_OVERLAY);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java Wed Aug 27 05:35:44 2008
@@ -67,7 +67,7 @@
}
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[23]; //(9 +14)
copySF(data, Type.INCLUDE, Category.PAGE_SEGMENT);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java Wed Aug 27 05:35:44 2008
@@ -42,7 +42,7 @@
}
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[17];
copySF(data, Type.MAP, Category.MEDIUM_MAP);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java Wed Aug 27 05:35:44 2008
@@ -57,7 +57,7 @@
}
/** {@inheritDoc} */
- public void write(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] startData = new byte[9];
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org