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 je...@apache.org on 2008/03/06 14:34:59 UTC
svn commit: r634267 [13/39] - in
/xmlgraphics/fop/branches/Temp_ProcessingFeedback: ./ examples/embedding/
examples/embedding/java/embedding/
examples/embedding/java/embedding/intermediate/ examples/embedding/xml/xml/
examples/fo/ examples/fo/advanced/...
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java Thu Mar 6 05:33:44 2008
@@ -32,18 +32,4 @@
*/
String AFP_GRAYSCALE = "afpGrayscale";
- /** The font information for the AFP renderer. */
- String AFP_FONT_INFO = "afpFontInfo";
-
- /** The afp resolution. */
- String AFP_RESOLUTION = "afpResolution";
-
- /** The afp datastream */
- String AFP_DATASTREAM = "afpDataStream";
-
- /** The afp state */
- String AFP_STATE = "afpPageState";
-
- /** The afp bits per pixel */
- String AFP_BITS_PER_PIXEL = "afpBitsPerPixel";
}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPSVGHandler.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPSVGHandler.java Thu Mar 6 05:33:44 2008
@@ -15,27 +15,14 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.render.afp;
// FOP
-import java.awt.geom.AffineTransform;
-import java.io.IOException;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.afp.modca.AFPDataStream;
-import org.apache.fop.svg.SVGUserAgent;
-import org.w3c.dom.Document;
/**
* AFP XML handler for SVG. Uses Apache Batik for SVG processing.
@@ -44,126 +31,17 @@
*/
public class AFPSVGHandler extends AbstractGenericSVGHandler {
- /** logging instance */
- private static Log log = LogFactory.getLog(AFPSVGHandler.class);
-
- /** {@inheritDoc} */
- public void handleXML(RendererContext context,
- Document doc, String ns) throws Exception {
- AFPInfo afpi = getAFPInfo(context);
-
- if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
- renderSVGDocument(context, doc, afpi);
- }
- }
-
- /**
- * Get the afp information from the render context.
- *
- * @param context the renderer context
- * @return the afp information retrieved from the context
- */
- public static AFPInfo getAFPInfo(RendererContext context) {
- AFPInfo afpi = new AFPInfo();
- afpi.width = ((Integer)context.getProperty(WIDTH)).intValue();
- afpi.height = ((Integer)context.getProperty(HEIGHT)).intValue();
- afpi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue();
- afpi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue();
- afpi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION);
- afpi.fontInfo = (org.apache.fop.fonts.FontInfo)context.getProperty(
- AFPRendererContextConstants.AFP_FONT_INFO);
- afpi.resolution = ((Integer)context.getProperty(
- AFPRendererContextConstants.AFP_RESOLUTION)).intValue();
- afpi.afpState = (AFPState)context.getProperty(
- AFPRendererContextConstants.AFP_STATE);
- afpi.afpDataStream = (AFPDataStream)context.getProperty(
- AFPRendererContextConstants.AFP_DATASTREAM);
- afpi.grayscale = ((Boolean)context.getProperty(
- AFPRendererContextConstants.AFP_GRAYSCALE)).booleanValue();
- afpi.bitsPerPixel = ((Integer)context.getProperty(
- AFPRendererContextConstants.AFP_BITS_PER_PIXEL)).intValue();
- return afpi;
- }
-
- /**
- * Render the SVG document.
- * @param context the renderer context
- * @param doc the SVG document
- * @param afpInfo the AFPInfo renderer parameters
- * @throws IOException In case of an I/O error while painting the image
- */
- protected void renderSVGDocument(final RendererContext context,
- final Document doc, AFPInfo afpInfo) throws IOException {
-
- final boolean textAsShapes = false;
- AFPGraphics2D graphics = new AFPGraphics2D(textAsShapes);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
- graphics.setAFPInfo(afpInfo);
-
- GVTBuilder builder = new GVTBuilder();
-
- boolean strokeText = false;
- Configuration cfg = afpInfo.cfg;
- if (cfg != null) {
- strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
- }
-
- final float uaResolution = context.getUserAgent().getSourceResolution();
- SVGUserAgent svgUserAgent = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
-
- BridgeContext ctx = new BridgeContext(svgUserAgent);
- AFPTextHandler afpTextHandler = null;
- //Controls whether text painted by Batik is generated using text or path operations
- if (!strokeText) {
- afpTextHandler = new AFPTextHandler(graphics);
- graphics.setCustomTextHandler(afpTextHandler);
- AFPTextPainter textPainter = new AFPTextPainter(afpTextHandler);
- ctx.setTextPainter(textPainter);
- AFPTextElementBridge tBridge = new AFPTextElementBridge(textPainter);
- ctx.putBridge(tBridge);
- }
-
- GraphicsNode root;
- try {
- root = builder.build(ctx, doc);
- } catch (Exception e) {
- log.error("SVG graphic could not be built: "
- + e.getMessage(), e);
- return;
- }
- log.debug("Generating SVG at "
- + afpInfo.resolution + "dpi.");
-
- int res = afpInfo.resolution;
-
- double w = ctx.getDocumentSize().getWidth() * 1000f;
- double h = ctx.getDocumentSize().getHeight() * 1000f;
-
- // convert to afp inches
- double sx = ((afpInfo.width / w) * res) / 72f;
- double sy = ((afpInfo.height / h) * res) / 72f;
- double xOffset = (afpInfo.currentXPosition * res) / 72000f;
- double yOffset = ((afpInfo.height - afpInfo.currentYPosition) * res) / 72000f;
-
- // Transformation matrix that establishes the local coordinate system for the SVG graphic
- // in relation to the current coordinate system (note: y axis is inverted)
- AffineTransform trans = new AffineTransform(sx, 0, 0, -sy, xOffset, yOffset);
- graphics.setTransform(trans);
- try {
- root.paint(graphics);
- } catch (Exception e) {
- log.error("SVG graphic could not be rendered: " + e.getMessage(), e);
- }
- }
-
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof AFPRenderer);
}
/** {@inheritDoc} */
- public String getNamespace() {
- return SVGDOMImplementation.SVG_NAMESPACE_URI;
+ protected void updateRendererContext(RendererContext context) {
+ //Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
+ context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
+ Boolean.FALSE);
}
+
}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Thu Mar 6 05:33:44 2008
@@ -1,121 +1,121 @@
-/*
- * 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.extensions;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fop.util.ContentHandlerFactory;
-import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * ContentHandler (parser) for restoring AFPExtension objects from XML.
- */
-public class AFPExtensionHandler extends DefaultHandler
- implements ContentHandlerFactory.ObjectSource {
-
- /** Logger instance */
- protected static Log log = LogFactory.getLog(AFPExtensionHandler.class);
-
- private StringBuffer content = new StringBuffer();
- private Attributes lastAttributes;
-
- private AFPPageSetup returnedObject;
- private ObjectBuiltListener listener;
-
- /** {@inheritDoc} */
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- boolean handled = false;
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
- handled = true;
- if (localName.equals(AFPElementMapping.NO_OPERATION)
- || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
- || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
- || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
- || localName.equals(AFPElementMapping.PAGE)
- || localName.equals(AFPElementMapping.PAGE_GROUP)) {
- //handled in endElement
- } else {
- handled = false;
- }
- }
- if (!handled) {
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- throw new SAXException("Unhandled element " + localName
- + " in namespace: " + uri);
- } else {
- log.warn("Unhandled element " + localName
- + " in namespace: " + uri);
- }
- }
- }
-
- /** {@inheritDoc} */
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- this.returnedObject = new AFPPageSetup(localName);
- String name = lastAttributes.getValue("name");
- if (name != null) {
- returnedObject.setName(name);
- }
- String value = lastAttributes.getValue("value");
- if (value != null) {
- returnedObject.setValue(value);
- }
- if (content.length() > 0) {
- returnedObject.setContent(content.toString());
- content.setLength(0); //Reset text buffer (see characters())
- }
- }
- }
-
- /** {@inheritDoc} */
- public void characters(char[] ch, int start, int length) throws SAXException {
- content.append(ch, start, length);
- }
-
- /**
- * {@inheritDoc}
- */
- public void endDocument() throws SAXException {
- if (listener != null) {
- listener.notifyObjectBuilt(getObject());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getObject() {
- return returnedObject;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setObjectBuiltListener(ObjectBuiltListener listen) {
- this.listener = listen;
- }
-
-}
+/*
+ * 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.extensions;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.util.ContentHandlerFactory;
+import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * ContentHandler (parser) for restoring AFPExtension objects from XML.
+ */
+public class AFPExtensionHandler extends DefaultHandler
+ implements ContentHandlerFactory.ObjectSource {
+
+ /** Logger instance */
+ protected static Log log = LogFactory.getLog(AFPExtensionHandler.class);
+
+ private StringBuffer content = new StringBuffer();
+ private Attributes lastAttributes;
+
+ private AFPPageSetup returnedObject;
+ private ObjectBuiltListener listener;
+
+ /** {@inheritDoc} */
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ boolean handled = false;
+ if (AFPPageSetup.CATEGORY.equals(uri)) {
+ lastAttributes = attributes;
+ handled = true;
+ if (localName.equals(AFPElementMapping.NO_OPERATION)
+ || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
+ || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
+ || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
+ || localName.equals(AFPElementMapping.PAGE)
+ || localName.equals(AFPElementMapping.PAGE_GROUP)) {
+ //handled in endElement
+ } else {
+ handled = false;
+ }
+ }
+ if (!handled) {
+ if (AFPPageSetup.CATEGORY.equals(uri)) {
+ throw new SAXException("Unhandled element " + localName
+ + " in namespace: " + uri);
+ } else {
+ log.warn("Unhandled element " + localName
+ + " in namespace: " + uri);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (AFPPageSetup.CATEGORY.equals(uri)) {
+ this.returnedObject = new AFPPageSetup(localName);
+ String name = lastAttributes.getValue("name");
+ if (name != null) {
+ returnedObject.setName(name);
+ }
+ String value = lastAttributes.getValue("value");
+ if (value != null) {
+ returnedObject.setValue(value);
+ }
+ if (content.length() > 0) {
+ returnedObject.setContent(content.toString());
+ content.setLength(0); //Reset text buffer (see characters())
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ content.append(ch, start, length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void endDocument() throws SAXException {
+ if (listener != null) {
+ listener.notifyObjectBuilt(getObject());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getObject() {
+ return returnedObject;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setObjectBuiltListener(ObjectBuiltListener listen) {
+ this.listener = listen;
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java Thu Mar 6 05:33:44 2008
@@ -1,41 +1,41 @@
-/*
- * 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.extensions;
-
-import org.apache.fop.util.ContentHandlerFactory;
-import org.xml.sax.ContentHandler;
-
-/**
- * Factory for the ContentHandler that handles serialized AFPPageSetup instances.
- */
-public class AFPExtensionHandlerFactory implements ContentHandlerFactory {
-
- private static final String[] NAMESPACES = new String[] {AFPPageSetup.CATEGORY};
-
- /** {@inheritDoc} */
- public String[] getSupportedNamespaces() {
- return NAMESPACES;
- }
-
- /** {@inheritDoc} */
- public ContentHandler createContentHandler() {
- return new AFPExtensionHandler();
- }
-}
+/*
+ * 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.extensions;
+
+import org.apache.fop.util.ContentHandlerFactory;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Factory for the ContentHandler that handles serialized AFPPageSetup instances.
+ */
+public class AFPExtensionHandlerFactory implements ContentHandlerFactory {
+
+ private static final String[] NAMESPACES = new String[] {AFPPageSetup.CATEGORY};
+
+ /** {@inheritDoc} */
+ public String[] getSupportedNamespaces() {
+ return NAMESPACES;
+ }
+
+ /** {@inheritDoc} */
+ public ContentHandler createContentHandler() {
+ return new AFPExtensionHandler();
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/fonts/RasterFont.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/fonts/RasterFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/fonts/RasterFont.java Thu Mar 6 05:33:44 2008
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.properties.FixedLength;
import org.apache.fop.render.afp.exceptions.FontRuntimeException;
/**
@@ -75,7 +76,7 @@
String pointsize = String.valueOf(size / 1000);
CharacterSet csm = (CharacterSet) charSets.get(pointsize);
if (csm == null) {
- csm = (CharacterSet) charSets.get(size + "mpt");
+ csm = (CharacterSet) charSets.get(size + FixedLength.MPT);
}
if (csm == null) {
// Get char set with nearest font size
@@ -83,7 +84,7 @@
for (Iterator it = charSets.entrySet().iterator(); it.hasNext();) {
Map.Entry me = (Map.Entry)it.next();
String key = (String)me.getKey();
- if (!key.endsWith("mpt")) {
+ if (!key.endsWith(FixedLength.MPT)) {
int mpt = Integer.parseInt(key) * 1000;
if (Math.abs(size - mpt) < distance) {
distance = Math.abs(size - mpt);
@@ -93,7 +94,7 @@
}
}
if (csm != null) {
- charSets.put(size + "mpt", csm);
+ charSets.put(size + FixedLength.MPT, csm);
String msg = "No " + (size / 1000) + "pt font " + getFontName()
+ " found, substituted with " + pointsize + "pt font";
log.warn(msg);
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java Thu Mar 6 05:33:44 2008
@@ -22,12 +22,9 @@
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
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.fonts.AFPFont;
import org.apache.fop.render.afp.tools.StringUtils;
@@ -135,7 +132,7 @@
* The outputstream for the data stream
*/
private OutputStream outputStream = null;
-
+
/**
* Default constructor for the AFPDataStream.
*/
@@ -150,6 +147,7 @@
* the outputStream which the document is written to.
*/
public void startDocument(OutputStream docOutputStream) {
+
if (document != null) {
String msg = "Invalid state - document already started.";
log.warn("startDocument():: " + msg);
@@ -158,6 +156,7 @@
this.document = new Document();
this.outputStream = docOutputStream;
+
}
/**
@@ -169,6 +168,7 @@
* throws an I/O exception of some sort has occurred
*/
public void endDocument() throws IOException {
+
if (complete) {
String msg = "Invalid state - document already ended.";
log.warn("endDocument():: " + msg);
@@ -206,19 +206,19 @@
* the height of the page
* @param pageRotation
* the rotation of the page
- * @param pageWidthRes
+ * @param pageWidthResolution
* the width resolution of the page
- * @param pageHeightRes
+ * @param pageHeightResolution
* the height resolution of the page
*/
public void startPage(int pageWidth, int pageHeight, int pageRotation,
- int pageWidthRes, int pageHeightRes) {
+ int pageWidthResolution, int pageHeightResolution) {
String pageName = "PGN"
+ StringUtils.lpad(String.valueOf(pageCount++), '0', 5);
currentPageObject = new PageObject(pageName, pageWidth, pageHeight,
- pageRotation, pageWidthRes, pageHeightRes);
+ pageRotation, pageWidthResolution, pageHeightResolution);
currentPage = currentPageObject;
currentOverlay = null;
setOffsets(0, 0, 0);
@@ -265,9 +265,11 @@
* Helper method to mark the end of the current overlay.
*/
public void endOverlay() {
+
currentOverlay.endPage();
currentOverlay = null;
currentPage = currentPageObject;
+
}
/**
@@ -276,6 +278,7 @@
* @return current page object that was saved
*/
public PageObject savePage() {
+
PageObject pageObject = currentPageObject;
if (currentPageGroup != null) {
currentPageGroup.addPage(currentPageObject);
@@ -285,6 +288,7 @@
currentPageObject = null;
currentPage = null;
return pageObject;
+
}
/**
@@ -294,8 +298,10 @@
* page object
*/
public void restorePage(PageObject pageObject) {
+
currentPageObject = pageObject;
currentPage = pageObject;
+
}
/**
@@ -305,6 +311,7 @@
* thrown when an I/O exception of some sort has occurred
*/
public void endPage() throws IOException {
+
currentPageObject.endPage();
if (currentPageGroup != null) {
currentPageGroup.addPage(currentPageObject);
@@ -312,8 +319,10 @@
document.addPage(currentPageObject);
document.writeDataStream(this.outputStream);
}
+
currentPageObject = null;
currentPage = null;
+
}
/**
@@ -333,21 +342,6 @@
}
/**
- * Creates the given page fonts in the current page
- * @param pageFonts a collection of AFP font attributes
- */
- public void addFontsToCurrentPage(Map pageFonts) {
- Iterator iter = pageFonts.values().iterator();
- while (iter.hasNext()) {
- AFPFontAttributes afpFontAttributes = (AFPFontAttributes)iter.next();
- createFont(
- afpFontAttributes.getFontReference(),
- afpFontAttributes.getFont(),
- afpFontAttributes.getPointSize());
- }
- }
-
- /**
* Helper method to create a map coded font object on the current page, this
* method delegates the construction of the map coded font object to the
* active environment group on the current page.
@@ -359,17 +353,18 @@
* @param size
* the point size of the font
*/
- public void createFont(int fontReference, AFPFont font, int size) {
+ public void createFont(byte fontReference, AFPFont font, int size) {
+
currentPage.createFont(fontReference, font, size);
- }
+ }
/**
* Helper method to create text on the current page, this method delegates
* to the current presentation text object in order to construct the text.
*
- * @param fontReference
- * the font reference used as the resource identifier
+ * @param fontNumber
+ * the font number used as the resource identifier
* @param x
* the x coordinate of the text
* @param y
@@ -383,125 +378,81 @@
* @param data
* the text data to create
*/
- public void createText(int fontReference, int x, int y, Color col, int vsci,
+ public void createText(int fontNumber, int x, int y, Color col, int vsci,
int ica, byte[] data) {
- currentPage.createText(fontReference, x + xOffset, y + yOffset, rotation,
+
+ currentPage.createText(fontNumber, x + xOffset, y + yOffset, rotation,
col, vsci, ica, data);
+
}
/**
* Returns an ImageObject used to create an image in the datastream.
- *
+ *
* @param x
* the x position of the image
* @param y
* the y position of the image
- * @param width
- * the width of the image
- * @param height
- * the height of the image
- * @param widthRes
- * the resolution width of the image
- * @param heightRes
- * the resolution height of the image
- * @return
- * a new image object
- */
- public ImageObject getImageObject(int x, int y, int width, int height,
- int widthRes, int heightRes) {
- ImageObject imageObj = currentPage.getImageObject();
- setObjectViewPort(imageObj, x, y, width, height, widthRes, heightRes);
- return imageObj;
- }
-
- /**
- * Returns an GraphicObject used to create an graphic in the datastream.
- *
- * @param x
- * the x position of the graphic
- * @param y
- * the y position of the graphic
- * @param width
- * the width of the graphic
- * @param height
- * the height of the graphic
- * @param widthRes
- * the resolution width of the graphic
- * @param heightRes
- * the resolution height of the graphic
- * @return
- * a new graphics object
- */
- public GraphicsObject getGraphicsObject(int x, int y, int width, int height,
- int widthRes, int heightRes) {
- GraphicsObject graphicsObj = currentPage.getGraphicsObject();
- setObjectViewPort(graphicsObj, x, y, width, height, widthRes, heightRes);
- return graphicsObj;
- }
-
- /**
- * 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
+ * the width of the image
* @param h
- * the height of the object
+ * the height of the image
* @param wr
- * the resolution width of the object
+ * the width resolution of the image
* @param hr
- * the resolution height of the object
- * @return
- * a new graphics object
+ * the height resolution of the image
+ * @return ImageObject used to create an image in the datastream
*/
- private void setObjectViewPort(AbstractDataObject dataObj,
- int x, int y, int w, int h, int wr, int hr) {
+ public ImageObject getImageObject(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) {
+ int widthResolution;
+ int heightResolution;
+
+ switch (rotation) {
case 90:
xOrigin = currentPage.getWidth() - y - yOffset;
yOrigin = x + xOffset;
width = h;
height = w;
- widthRes = hr;
- heightRes = wr;
+ widthResolution = hr;
+ heightResolution = wr;
break;
case 180:
xOrigin = currentPage.getWidth() - x - xOffset;
yOrigin = currentPage.getHeight() - y - yOffset;
width = w;
height = h;
- widthRes = wr;
- heightRes = hr;
+ widthResolution = wr;
+ heightResolution = hr;
break;
case 270:
xOrigin = y + yOffset;
yOrigin = currentPage.getHeight() - x - xOffset;
width = h;
height = w;
- widthRes = hr;
- heightRes = wr;
+ widthResolution = hr;
+ heightResolution = wr;
break;
default:
xOrigin = x + xOffset;
yOrigin = y + yOffset;
width = w;
height = h;
- widthRes = wr;
- heightRes = hr;
+ widthResolution = wr;
+ heightResolution = hr;
break;
}
- dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes, heightRes, rotation);
+ ImageObject io = currentPage.getImageObject();
+ io.setImageViewport(xOrigin, yOrigin, width, height, rotation,
+ widthResolution, heightResolution);
+ return io;
+
}
-
+
/**
* Method to create a line on the current page.
*
@@ -520,8 +471,10 @@
*/
public void createLine(int x1, int y1, int x2, int y2, int thickness,
Color col) {
+
currentPage.createLine(x1 + xOffset, y1 + yOffset, x2 + xOffset, y2
+ yOffset, thickness, rotation, col);
+
}
/**
@@ -546,8 +499,10 @@
*/
public void createShading(int x, int y, int w, int h, int red, int green,
int blue) {
+
currentPage.createShading(x + xOffset, y + xOffset, w, h, red, green,
blue);
+
}
/**
@@ -558,10 +513,12 @@
* the name of the static overlay
*/
public void createIncludePageOverlay(String name) {
+
currentPageObject.createIncludePageOverlay(name, 0, 0, rotation);
ActiveEnvironmentGroup aeg = currentPageObject
.getActiveEnvironmentGroup();
aeg.createOverlay(name);
+
}
/**
@@ -571,10 +528,12 @@
* the name of the medium map
*/
public void createInvokeMediumMap(String name) {
+
if (currentPageGroup == null) {
startPageGroup();
}
currentPageGroup.createInvokeMediumMap(name);
+
}
/**
@@ -588,6 +547,7 @@
* the y coordinate for the overlay
*/
public void createIncludePageSegment(String name, int x, int y) {
+
int xOrigin;
int yOrigin;
switch (rotation) {
@@ -609,6 +569,7 @@
break;
}
currentPage.createIncludePageSegment(name, xOrigin, yOrigin);
+
}
/**
@@ -618,11 +579,13 @@
* the array of key value pairs.
*/
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();
currentPage.createTagLogicalElement(name, value);
}
+
}
/**
@@ -631,12 +594,15 @@
* @param attributes
* the array of key value pairs.
*/
- public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) {
+ 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();
currentPageGroup.createTagLogicalElement(name, value);
}
+
}
/**
@@ -648,11 +614,13 @@
* The tag value
*/
public void createTagLogicalElement(String name, String value) {
+
if (currentPageGroup != null) {
currentPageGroup.createTagLogicalElement(name, value);
} else {
currentPage.createTagLogicalElement(name, value);
}
+
}
/**
@@ -729,4 +697,5 @@
}
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java Thu Mar 6 05:33:44 2008
@@ -44,7 +44,7 @@
* DataStream objects must implement the writeDataStream()
* method to write its data to the given OutputStream
* @param os The outputsteam stream
- * @throws java.io.IOException in the event that an I/O exception occurred
+ * @throws java.io.IOException
*/
public abstract void writeDataStream(OutputStream os) throws IOException;
@@ -52,14 +52,15 @@
* Help method to write a set of AFPObjects to the AFP datastream.
* @param afpObjects a list of AFPObjects
* @param os The stream to write to
- * @throws java.io.IOException in the event that an I/O exception occurred
+ * @throws java.io.IOException
*/
protected void writeObjectList(List afpObjects, OutputStream os)
- throws IOException {
+ throws IOException {
- Iterator it = afpObjects.iterator();
- while (it.hasNext()) {
+ for (Iterator it = afpObjects.iterator(); it.hasNext(); ) {
((AbstractAFPObject)it.next()).writeDataStream(os);
}
+
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java Thu Mar 6 05:33:44 2008
@@ -28,22 +28,22 @@
/** height of this descriptor */
protected int height = 0;
/** width resolution of this descriptor */
- protected int widthRes = 0;
+ protected int widthResolution = 0;
/** height resolution of this descriptor */
- protected int heightRes = 0;
+ protected int heightResolution = 0;
/**
* Constructor a PresentationTextDescriptor for the specified
* width and height.
* @param width The width of the page.
* @param height The height of the page.
- * @param widthRes The width resolution of the page.
- * @param heightRes The height resolution of the page.
+ * @param widthResolution The width resolution of the page.
+ * @param heightResolution The height resolution of the page.
*/
- public AbstractDescriptor(int width, int height, int widthRes, int heightRes) {
+ public AbstractDescriptor(int width, int height, int widthResolution, int heightResolution) {
this.width = width;
this.height = height;
- this.widthRes = widthRes;
- this.heightRes = heightRes;
+ this.widthResolution = widthResolution;
+ this.heightResolution = heightResolution;
}
}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java Thu Mar 6 05:33:44 2008
@@ -25,7 +25,7 @@
* A named data stream object has an 8 byte EBCIDIC name.
*/
public abstract class AbstractNamedAFPObject extends AbstractAFPObject {
-
+
/**
* The actual name of the object
*/
@@ -35,50 +35,35 @@
* The name of the object in EBCIDIC bytes
*/
protected byte[] nameBytes;
-
- /**
- * Default constructor
- */
- protected AbstractNamedAFPObject() {
- }
-
- private static final int DEFAULT_NAME_LENGTH = 8;
-
- /**
- * @return the name length of this object
- */
- protected int getNameLength() {
- return DEFAULT_NAME_LENGTH;
- }
-
+
/**
* Constructor for the ActiveEnvironmentGroup, this takes a
* name parameter which should be 8 characters long.
* @param name the object name
*/
public AbstractNamedAFPObject(String name) {
- int nameLen = getNameLength();
- if (name.length() < nameLen) {
- this.name = (name + " ").substring(0, nameLen);
- } else if (name.length() > nameLen) {
- log.warn("Constructor:: name truncated to " + nameLen + " chars: " + name);
- this.name = name.substring(0, nameLen);
- } else {
- this.name = name;
+
+ this.name = name;
+ if (name.length() < 8) {
+ name = (name + " ").substring(0, 8);
+ } else if (name.length() > 8) {
+ log.warn("Constructor:: name truncated to 8 chars" + name);
+ name = name.substring(0, 8);
}
try {
- this.nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
+ nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
} catch (UnsupportedEncodingException usee) {
- this.nameBytes = name.getBytes();
+ nameBytes = name.getBytes();
log.warn(
"Constructor:: UnsupportedEncodingException translating the name "
+ name);
}
- }
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java Thu Mar 6 05:33:44 2008
@@ -105,13 +105,13 @@
* the height of the page.
* @param rotation
* the rotation of the page.
- * @param widthRes
+ * @param widthResolution
* the width resolution of the page.
- * @param heightRes
+ * @param heightResolution
* the height resolution of the page.
*/
public AbstractPageObject(String name, int width, int height, int rotation,
- int widthRes, int heightRes) {
+ int widthResolution, int heightResolution) {
super(name);
this.width = width;
@@ -121,7 +121,8 @@
/**
* Every page object must have an ActiveEnvironmentGroup
*/
- activeEnvironmentGroup = new ActiveEnvironmentGroup(width, height, widthRes, heightRes);
+ activeEnvironmentGroup = new ActiveEnvironmentGroup(width, height,
+ widthResolution, heightResolution);
if (rotation != 0) {
switch (rotation) {
@@ -137,6 +138,13 @@
default:
}
}
+
+ /**
+ * We have a presentation text object per page
+ */
+ presentationTextObject = new PresentationTextObject();
+ objects.add(presentationTextObject);
+
}
/**
@@ -151,8 +159,10 @@
* @param size
* the point size of the font
*/
- public void createFont(int fontReference, AFPFont font, int size) {
+ public void createFont(byte fontReference, AFPFont font, int size) {
+
activeEnvironmentGroup.createFont(fontReference, font, size, 0);
+
}
/**
@@ -176,14 +186,20 @@
*/
public void createLine(int x1, int y1, int x2, int y2, int thickness,
int lineRotation, Color col) {
- getPresentationTextObject().createLineData(x1, y1, x2, y2, thickness, lineRotation, col);
+
+ if (presentationTextObject == null) {
+ presentationTextObject = new PresentationTextObject();
+ objects.add(presentationTextObject);
+ }
+ presentationTextObject.createLineData(x1, y1, x2, y2, thickness, lineRotation, col);
+
}
/**
* Helper method to create text on the current page, this method delegates
* to the presentation text object in order to construct the text.
*
- * @param fontReference
+ * @param fontNumber
* the font number used as the resource identifier
* @param x
* the x coordinate of the text data
@@ -200,10 +216,15 @@
* @param data
* the text data to create
*/
- public void createText(int fontReference, int x, int y, int textRotation, Color col,
+ public void createText(int fontNumber, int x, int y, int textRotation, Color col,
int vsci, int ica, byte[] data) {
- getPresentationTextObject().createTextData(
- fontReference, x, y, textRotation, col, vsci, ica, data);
+
+ if (presentationTextObject == null) {
+ presentationTextObject = new PresentationTextObject();
+ objects.add(presentationTextObject);
+ }
+ presentationTextObject.createTextData(fontNumber, x, y, textRotation, col, vsci, ica, data);
+
}
/**
@@ -211,10 +232,13 @@
* sequence on the current presenation text object.
*/
public void endPage() {
+
if (presentationTextObject != null) {
presentationTextObject.endControlSequence();
}
+
complete = true;
+
}
/**
@@ -303,19 +327,6 @@
}
/**
- * Helper method to create a presentation text object
- * on the current page and to return the object.
- * @return the presentation text object
- */
- private PresentationTextObject getPresentationTextObject() {
- if (presentationTextObject == null) {
- this.presentationTextObject = new PresentationTextObject();
- objects.add(this.presentationTextObject);
- }
- return presentationTextObject;
- }
-
- /**
* Helper method to create an image on the current page and to return
* the object.
* @return the image object
@@ -324,32 +335,16 @@
if (presentationTextObject != null) {
presentationTextObject.endControlSequence();
- presentationTextObject = null;
}
+ presentationTextObject = null;
+
String imageName = "IMG"
+ StringUtils.lpad(String.valueOf(objects.size() + 1),
'0', 5);
- ImageObject imageObj = new ImageObject(imageName);
- objects.add(imageObj);
- return imageObj;
- }
- /**
- * Helper method to create a graphic on the current page and to return
- * the object.
- * @return the graphics object
- */
- public GraphicsObject getGraphicsObject() {
- if (presentationTextObject != null) {
- presentationTextObject.endControlSequence();
- presentationTextObject = null;
- }
- String graphicName = "GRA"
- + StringUtils.lpad(String.valueOf(objects.size() + 1),
- '0', 5);
- GraphicsObject graphicsObj = new GraphicsObject(graphicName);
- objects.add(graphicsObj);
- return graphicsObj;
+ ImageObject io = new ImageObject(imageName);
+ objects.add(io);
+ return io;
}
/**
@@ -361,8 +356,10 @@
* the value of the tag
*/
public void createTagLogicalElement(String name, String value) {
+
TagLogicalElement tle = new TagLogicalElement(name, value);
tagLogicalElements.add(tle);
+
}
/**
@@ -371,8 +368,10 @@
* @param content the byte data
*/
public void createNoOperation(String content) {
+
NoOperation noOp = new NoOperation(content);
objects.add(noOp);
+
}
/**
@@ -381,13 +380,15 @@
* @param name
* the name of the page segment
* @param xCoor
- * the x coordinate of the page segment.
+ * the x cooridinate of the page segment.
* @param yCoor
- * the y coordinate of the page segment.
+ * the y cooridinate of the page segment.
*/
public void createIncludePageSegment(String name, int xCoor, int yCoor) {
+
IncludePageSegment ips = new IncludePageSegment(name, xCoor, yCoor);
segments.add(ips);
+
}
/**
@@ -430,4 +431,5 @@
public int getRotation() {
return rotation;
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java Thu Mar 6 05:33:44 2008
@@ -20,7 +20,7 @@
package org.apache.fop.render.afp.modca;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.List;
+import java.util.ArrayList;
import org.apache.fop.render.afp.fonts.AFPFont;
@@ -47,7 +47,7 @@
/**
* The collection of MapCodedFont objects
*/
- private List mapCodedFonts = new java.util.ArrayList();
+ private ArrayList mapCodedFonts = new ArrayList();
/**
* The Object Area Descriptor for the active environment group
@@ -72,19 +72,19 @@
/**
* The collection of MapPageOverlay objects
*/
- private List mapPageOverlays = new java.util.ArrayList();
+ private ArrayList mapPageOverlays = new ArrayList();
/**
* Default constructor for the ActiveEnvironmentGroup.
* @param width the page width
* @param height the page height
- * @param widthRes the page width resolution
- * @param heightRes the page height resolution
+ * @param widthResolution the page width resolution
+ * @param heightResolution the page height resolution
*/
public ActiveEnvironmentGroup(int width, int height,
- int widthRes, int heightRes) {
+ int widthResolution, int heightResolution) {
- this(DEFAULT_NAME, width, height, widthRes, heightRes);
+ this(DEFAULT_NAME, width, height, widthResolution, heightResolution);
}
@@ -94,24 +94,24 @@
* @param name the active environment group name
* @param width the page width
* @param height the page height
- * @param widthRes the page width resolution
- * @param heightRes the page height resolution
+ * @param widthResolution the page width resolution
+ * @param heightResolution the page height resolution
*/
public ActiveEnvironmentGroup(String name, int width, int height,
- int widthRes, int heightRes) {
+ int widthResolution, int heightResolution) {
super(name);
// Create PageDescriptor
- pageDescriptor = new PageDescriptor(width, height, widthRes, heightRes);
+ pageDescriptor = new PageDescriptor(width, height, widthResolution, heightResolution);
// Create ObjectAreaDescriptor
objectAreaDescriptor = new ObjectAreaDescriptor(width, height,
- widthRes, heightRes);
+ widthResolution, heightResolution);
// Create PresentationTextDataDescriptor
presentationTextDataDescriptor = new PresentationTextDescriptor(width, height,
- widthRes, heightRes);
+ widthResolution, heightResolution);
}
@@ -243,7 +243,7 @@
* @param orientation the orientation of the font (e.g. 0, 90, 180, 270)
*/
public void createFont(
- int fontReference,
+ byte fontReference,
AFPFont font,
int size,
int orientation) {
@@ -256,7 +256,7 @@
}
try {
-
+
mcf.addFont(
fontReference,
font,
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageContent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageContent.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageContent.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageContent.java Thu Mar 6 05:33:44 2008
@@ -18,45 +18,43 @@
/* $Id$ */
package org.apache.fop.render.afp.modca;
-
import java.io.IOException;
import java.io.OutputStream;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
- * Image content IOCA object
*/
public class ImageContent extends AbstractAFPObject {
/**
* The image size parameter
*/
- private ImageSizeParameter imageSizeParam = null;
+ private ImageSizeParameter _imageSizeParameter = null;
/**
* The image encoding
*/
- private byte encoding = 0x03;
+ private byte _encoding = 0x03;
/**
* The image ide size
*/
- private byte size = 1;
+ private byte _size = 1;
/**
* The image compression
*/
- private byte compression = (byte)0xC0;
+ private byte _compression = (byte)0xC0;
/**
* The image color model
*/
- private byte colorModel = 0x01;
+ private byte _colorModel = 0x01;
/**
* The image data
*/
- private byte[] data = null;
+ private byte _data[] = null;
/**
* Constructor for the image content
@@ -74,60 +72,60 @@
* @param vsize The vertival size of the image.
*/
public void setImageSize(int hresol, int vresol, int hsize, int vsize) {
- this.imageSizeParam = new ImageSizeParameter(hresol, vresol, hsize, vsize);
+ _imageSizeParameter = new ImageSizeParameter(hresol, vresol, hsize, vsize);
}
/**
* Sets the image encoding.
- * @param enc The image encoding.
+ * @param encoding The image encoding.
*/
- public void setImageEncoding(byte enc) {
- this.encoding = enc;
+ public void setImageEncoding(byte encoding) {
+ _encoding = encoding;
}
/**
* Sets the image compression.
- * @param comp The image compression.
+ * @param compression The image compression.
*/
- public void setImageCompression(byte comp) {
- this.compression = comp;
+ public void setImageCompression(byte compression) {
+ _compression = compression;
}
/**
* Sets the image IDE size.
- * @param siz The IDE size.
+ * @param size The IDE size.
*/
- public void setImageIDESize(byte siz) {
- this.size = siz;
+ public void setImageIDESize(byte size) {
+ _size = size;
}
/**
* Sets the image IDE color model.
- * @param model the IDE color model.
+ * @param colorModel the IDE color model.
*/
- public void setImageIDEColorModel(byte model) {
- this.colorModel = model;
+ public void setImageIDEColorModel(byte colorModel) {
+ _colorModel = colorModel;
}
/**
* Set the data of the image.
- * @param dat the image data
*/
- public void setImageData(byte[] dat) {
- this.data = dat;
+ public void setImageData(byte data[]) {
+ _data = data;
}
/**
* Accessor method to write the AFP datastream for the Image Content
* @param os The stream to write to
- * @throws java.io.IOException if an I/O exception occurs
+ * @throws java.io.IOException
*/
- public void writeDataStream(OutputStream os) throws IOException {
+ public void writeDataStream(OutputStream os)
+ throws IOException {
writeStart(os);
- if (imageSizeParam != null) {
- imageSizeParam.writeDataStream(os);
+ if (_imageSizeParameter != null) {
+ _imageSizeParameter.writeDataStream(os);
}
os.write(getImageEncodingParameter());
@@ -138,12 +136,12 @@
os.write(getExternalAlgorithmParameter());
- if (data != null) {
+ if (_data != null) {
int off = 0;
- while (off < data.length) {
- int len = Math.min(30000, data.length - off);
+ while (off < _data.length) {
+ int len = Math.min(30000, _data.length - off);
os.write(getImageDataStart(len));
- os.write(data, off, len);
+ os.write(_data, off, len);
off += len;
}
}
@@ -156,25 +154,33 @@
* Helper method to write the start of the Image Content.
* @param os The stream to write to
*/
- private void writeStart(OutputStream os) throws IOException {
- byte[] startData = new byte[] {
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
(byte)0x91, // ID
0x01, // Length
(byte)0xff, // Object Type = IOCA Image Object
};
- os.write(startData);
+
+ os.write(data);
+
}
/**
* Helper method to write the end of the Image Content.
* @param os The stream to write to
*/
- private void writeEnd(OutputStream os) throws IOException {
- byte[] endData = new byte[] {
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
(byte)0x93, // ID
0x00, // Length
};
- os.write(endData);
+
+ os.write(data);
+
}
/**
@@ -182,16 +188,21 @@
* @return byte[] The data stream.
*/
private byte[] getImageDataStart(int len) {
- byte[] imageDataStartData = new byte[] {
+
+ byte[] data = new byte[] {
(byte)0xFE, // ID
(byte)0x92, // ID
0x00, // Length
0x00, // Length
};
+
byte[] l = BinaryUtils.convert(len, 2);
- imageDataStartData[2] = l[0];
- imageDataStartData[3] = l[1];
- return imageDataStartData;
+ data[2] = l[0];
+ data[3] = l[1];
+
+
+ return data;
+
}
/**
@@ -199,13 +210,16 @@
* @return byte[] The data stream.
*/
private byte[] getImageEncodingParameter() {
- byte[] imageEncParamData = new byte[] {
+
+ byte[] data = new byte[] {
(byte)0x95, // ID
0x02, // Length
- encoding,
+ _encoding,
0x01, // RECID
};
- return imageEncParamData;
+
+ return data;
+
}
/**
@@ -213,8 +227,9 @@
* @return byte[] The data stream.
*/
private byte[] getExternalAlgorithmParameter() {
- if (encoding == (byte)0x83 && compression != 0) {
- byte[] extAlgParamData = new byte[] {
+
+ if (_encoding == (byte)0x83 && _compression != 0) {
+ byte[] data = new byte[] {
(byte)0x95, // ID
0x00, // Length
0x10, // ALGTYPE = Compression Algorithm
@@ -223,13 +238,13 @@
0x00, // Reserved
0x00, // Reserved
0x00, // Reserved
- compression, // MARKER
+ _compression, // MARKER
0x00, // Reserved
0x00, // Reserved
0x00, // Reserved
};
- extAlgParamData[1] = (byte)(extAlgParamData.length - 2);
- return extAlgParamData;
+ data[1] = (byte)(data.length - 2);
+ return data;
}
return new byte[0];
}
@@ -239,12 +254,15 @@
* @return byte[] The data stream.
*/
private byte[] getImageIDESizeParameter() {
- byte[] imageIDESizeParamData = new byte[] {
+
+ byte[] data = new byte[] {
(byte)0x96, // ID
0x01, // Length
- size,
+ _size,
};
- return imageIDESizeParamData;
+
+ return data;
+
}
/**
@@ -252,14 +270,15 @@
* @return byte[] The data stream.
*/
private byte[] getIDEStructureParameter() {
- if (colorModel != 0 && size == 24) {
- byte bits = (byte)(size / 3);
- byte[] ideStructParamData = new byte[] {
+
+ if (_colorModel != 0 && _size == 24) {
+ byte bits = (byte)(_size / 3);
+ byte[] data = new byte[] {
(byte)0x9B, // ID
0x00, // Length
0x00, // FLAGS
0x00, // Reserved
- colorModel, // COLOR MODEL
+ _colorModel, // COLOR MODEL
0x00, // Reserved
0x00, // Reserved
0x00, // Reserved
@@ -267,9 +286,10 @@
bits,
bits,
};
- ideStructParamData[1] = (byte)(ideStructParamData.length - 2);
- return ideStructParamData;
+ data[1] = (byte)(data.length - 2);
+ return data;
}
return new byte[0];
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java Thu Mar 6 05:33:44 2008
@@ -27,17 +27,10 @@
*/
public class ImageDataDescriptor extends AbstractAFPObject {
- /** x resolution */
- private int xresol = 0;
-
- /** y resolution */
- private int yresol = 0;
-
- /** width */
- private int width = 0;
-
- /** height */
- private int height = 0;
+ private int _xresol = 0;
+ private int _yresol = 0;
+ private int _width = 0;
+ private int _height = 0;
/**
* Constructor for a ImageDataDescriptor for the specified
@@ -48,25 +41,26 @@
* @param height The height of the height.
*/
public ImageDataDescriptor(int xresol, int yresol, int width, int height) {
- this.xresol = xresol;
- this.yresol = yresol;
- this.width = width;
- this.height = height;
+
+ _xresol = xresol;
+ _yresol = yresol;
+ _width = width;
+ _height = height;
+
}
/**
- * {@inheritDoc}
+ * Accessor method to write the AFP datastream for the Image Data Descriptor
+ * @param os The stream to write to
+ * @throws java.io.IOException
*/
- public void writeDataStream(OutputStream os) throws IOException {
- byte[] len = BinaryUtils.convert(21, 2);
- byte[] xres = BinaryUtils.convert(xresol, 2);
- byte[] yres = BinaryUtils.convert(yresol, 2);
- byte[] w = BinaryUtils.convert(width, 2);
- byte[] h = BinaryUtils.convert(height, 2);
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
byte[] data = new byte[] {
0x5A,
- len[0],
- len[1],
+ 0x00,
+ 0x20,
(byte) 0xD3,
(byte) 0xA6,
(byte) 0xFB,
@@ -74,19 +68,42 @@
0x00, // Reserved
0x00, // Reserved
0x00, // Unit base - 10 Inches
- xres[0], // XRESOL
- xres[1], //
- yres[0], // YRESOL
- yres[1], //
- w[0], // XSIZE
- w[1], //
- h[0], // YSIZE
- h[1], //
+ 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];
+
+ byte[] x = BinaryUtils.convert(_xresol, 2);
+ data[10] = x[0];
+ data[11] = x[1];
+
+ byte[] y = BinaryUtils.convert(_yresol, 2);
+ data[12] = y[0];
+ data[13] = y[1];
+
+ byte[] w = BinaryUtils.convert(_width, 2);
+ data[14] = w[0];
+ data[15] = w[1];
+
+ byte[] h = BinaryUtils.convert(_height, 2);
+ data[16] = h[0];
+ data[17] = h[1];
+
os.write(data);
+
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageObject.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageObject.java Thu Mar 6 05:33:44 2008
@@ -27,7 +27,12 @@
/**
* An IOCA Image Data Object
*/
-public class ImageObject extends AbstractDataObject {
+public class ImageObject extends AbstractNamedAFPObject {
+
+ /**
+ * The object environment group
+ */
+ private ObjectEnvironmentGroup objectEnvironmentGroup = null;
/**
* The image segment
@@ -40,7 +45,34 @@
* @param name The name of the image.
*/
public ImageObject(String name) {
+
super(name);
+
+ }
+
+ /**
+ * Sets the image display area position and size.
+ *
+ * @param x
+ * the x position of the image
+ * @param y
+ * the y position of the image
+ * @param w
+ * the width of the image
+ * @param h
+ * the height of the image
+ * @param r
+ * the rotation of the image
+ * @param wr
+ * the width resolution of the image
+ * @param hr
+ * the height resolution of the image
+ */
+ public void setImageViewport(int x, int y, int w, int h, int r, int wr, int hr) {
+ if (objectEnvironmentGroup == null) {
+ objectEnvironmentGroup = new ObjectEnvironmentGroup();
+ }
+ objectEnvironmentGroup.setObjectArea(x, y, w, h, r, wr, hr);
}
/**
@@ -117,16 +149,24 @@
}
/**
+ * Sets the ObjectEnvironmentGroup.
+ * @param objectEnvironmentGroup The objectEnvironmentGroup to set
+ */
+ public void setObjectEnvironmentGroup(ObjectEnvironmentGroup objectEnvironmentGroup) {
+ this.objectEnvironmentGroup = objectEnvironmentGroup;
+ }
+
+ /**
* 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[] getIPDStart(int len) {
- byte[] l = BinaryUtils.convert(len + 8, 2);
+
byte[] data = new byte[] {
+
0x5A, // Structured field identifier
- l[0], // Length byte 1
- l[1], // Length byte 2
+ 0x00, // Length byte 1
+ 0x10, // Length byte 2
(byte) 0xD3, // Structured field id byte 1
(byte) 0xEE, // Structured field id byte 2
(byte) 0xFB, // Structured field id byte 3
@@ -134,14 +174,29 @@
0x00, // Reserved
0x00, // Reserved
};
+
+ byte[] l = BinaryUtils.convert(len + 8, 2);
+ data[1] = l[0];
+ data[2] = l[1];
+
return data;
+
}
/**
- * {@inheritDoc}
+ * Accessor method to write the AFP datastream for the Image Object
+ * @param os The stream to write to
+ * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
- protected void writeContent(OutputStream os) throws IOException {
- super.writeContent(os);
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ if (objectEnvironmentGroup != null) {
+ objectEnvironmentGroup.writeDataStream(os);
+ }
+
if (imageSegment != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageSegment.writeDataStream(baos);
@@ -154,13 +209,20 @@
off += len;
}
}
+
+ writeEnd(os);
+
}
/**
- * {@inheritDoc}
+ * Helper method to write the start of the Image Object.
+ * @param os The stream to write to
*/
- protected void writeStart(OutputStream os) throws IOException {
+ private void writeStart(OutputStream os)
+ throws IOException {
+
byte[] data = new byte[17];
+
data[0] = 0x5A; // Structured field identifier
data[1] = 0x00; // Length byte 1
data[2] = 0x10; // Length byte 2
@@ -170,19 +232,26 @@
data[6] = 0x00; // Flags
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved
+
for (int i = 0; i < nameBytes.length; i++) {
+
data[9 + i] = nameBytes[i];
+
}
+
os.write(data);
+
}
/**
* Helper method to write the end of the Image Object.
* @param os The stream to write to
- * @throws IOException in the event
*/
- protected void writeEnd(OutputStream os) throws IOException {
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
byte[] data = new byte[17];
+
data[0] = 0x5A; // Structured field identifier
data[1] = 0x00; // Length byte 1
data[2] = 0x10; // Length byte 2
@@ -192,9 +261,15 @@
data[6] = 0x00; // Flags
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved
+
for (int i = 0; i < nameBytes.length; i++) {
+
data[9 + i] = nameBytes[i];
+
}
+
os.write(data);
+
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageSegment.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ImageSegment.java Thu Mar 6 05:33:44 2008
@@ -18,7 +18,6 @@
/* $Id$ */
package org.apache.fop.render.afp.modca;
-
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
@@ -68,12 +67,15 @@
* @param name The name of the image.
*/
public ImageSegment(String name) {
+
if (name.length() != 4) {
String msg = "Image segment name must be 4 characters long " + name;
log.error("Constructor:: " + msg);
throw new IllegalArgumentException(msg);
}
+
this.name = name;
+
try {
this.nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
} catch (UnsupportedEncodingException usee) {
@@ -160,18 +162,24 @@
* @throws java.io.IOException if an I/O exception occurred
*/
public void writeDataStream(OutputStream os) throws IOException {
+
writeStart(os);
+
if (imageContent != null) {
imageContent.writeDataStream(os);
}
+
writeEnd(os);
+
}
/**
* Helper method to write the start of the Image Segment.
* @param os The stream to write to
*/
- private void writeStart(OutputStream os) throws IOException {
+ private void writeStart(OutputStream os)
+ throws IOException {
+
byte[] data = new byte[] {
0x70, // ID
0x04, // Length
@@ -180,9 +188,13 @@
0x00, // Name byte 3
0x00, // Name byte 4
};
+
for (int i = 0; i < nameBytes.length; i++) {
+
data[2 + i] = nameBytes[i];
+
}
+
os.write(data);
}
@@ -192,6 +204,7 @@
* @param os The stream to write to
*/
private void writeEnd(OutputStream os) throws IOException {
+
byte[] data = new byte[] {
0x71, // ID
0x00, // Length
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/NoOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java Thu Mar 6 05:33:44 2008
@@ -35,11 +35,11 @@
* and object height.
* @param width The page width.
* @param height The page height.
- * @param widthRes The page width resolution.
- * @param heightRes The page height resolution.
+ * @param widthResolution The page width resolution.
+ * @param heightResolution The page height resolution.
*/
- public ObjectAreaDescriptor(int width, int height, int widthRes, int heightRes) {
- super(width, height, widthRes, heightRes);
+ public ObjectAreaDescriptor(int width, int height, int widthResolution, int heightResolution) {
+ super(width, height, widthResolution, heightResolution);
}
/**
@@ -47,7 +47,8 @@
* @param os The stream to write to
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
- public void writeDataStream(OutputStream os) throws IOException {
+ public void writeDataStream(OutputStream os)
+ throws IOException {
byte[] data = new byte[29];
data[0] = 0x5A;
@@ -71,12 +72,12 @@
data[15] = 0x00; // YaoBase = 10 inches
// XaoUnits
- byte[] xdpi = BinaryUtils.convert(this.widthRes * 10, 2);
+ byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2);
data[16] = xdpi[0];
data[17] = xdpi[1];
// YaoUnits
- byte[] ydpi = BinaryUtils.convert(this.heightRes * 10, 2);
+ byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2);
data[18] = ydpi[0];
data[19] = ydpi[1];
@@ -84,16 +85,18 @@
data[21] = 0x4C; // tid = Object Area Size
data[22] = 0x02; // Size Type
- byte[] x = BinaryUtils.convert(this.width, 3);
+ byte[] x = BinaryUtils.convert(width, 3);
data[23] = x[0];
data[24] = x[1];
data[25] = x[2];
- byte[] y = BinaryUtils.convert(this.height, 3);
+ byte[] y = BinaryUtils.convert(height, 3);
data[26] = y[0];
data[27] = y[1];
data[28] = y[2];
os.write(data);
+
}
+
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java?rev=634267&r1=634266&r2=634267&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java Thu Mar 6 05:33:44 2008
@@ -30,9 +30,9 @@
*/
public class ObjectAreaPosition extends AbstractAFPObject {
- private int x;
- private int y;
- private int rotation;
+ private int _x = 0;
+ private int _y = 0;
+ private int _rot = 0;
/**
* Construct an object area position for the specified object y, y position.
@@ -41,25 +41,24 @@
* @param rotation The coordinate system rotation (must be 0, 90, 180, 270).
*/
public ObjectAreaPosition(int x, int y, int rotation) {
- this.x = x;
- this.y = y;
- this.rotation = rotation;
+
+ _x = x;
+ _y = y;
+ _rot = rotation;
}
/**
* Accessor method to write the AFP datastream for the Object Area Position
* @param os The stream to write to
- * @throws java.io.IOException in the event that an I/O exception of some sort has occurred.
+ * @throws java.io.IOException
*/
- public void writeDataStream(OutputStream os) throws IOException {
- byte[] len = BinaryUtils.convert(32, 2);
- byte[] xcoord = BinaryUtils.convert(x, 3);
- byte[] ycoord = BinaryUtils.convert(y, 3);
+ public void writeDataStream(OutputStream os)
+ throws IOException {
byte[] data = new byte[] {
0x5A,
- len[0], // Length
- len[1], // Length
+ 0x00, // Length
+ 0x20, // Length
(byte) 0xD3,
(byte) 0xAC,
(byte) 0x6B,
@@ -68,15 +67,15 @@
0x00, // Reserved
0x01, // OAPosID = 1
0x17, // RGLength = 23
- xcoord[0], // XoaOSet
- xcoord[1],
- xcoord[2],
- ycoord[0], // YoaOSet
- ycoord[1],
- ycoord[2],
- (byte)(rotation / 2), // XoaOrent
+ 0x00, // XoaOSet
+ 0x00,
+ 0x00,
+ 0x00, // YoaOSet
+ 0x00,
+ 0x00,
+ (byte)(_rot / 2), // XoaOrent
0x00,
- (byte)(rotation / 2 + 45), // YoaOrent
+ (byte)(_rot / 2 + 45), // YoaOrent
0x00,
0x00, // Reserved
0x00, // XocaOSet
@@ -89,9 +88,23 @@
0x00,
0x2D, // YocaOrent
0x00,
- 0x00, // RefCSys
+ 0x01, // RefCSys
};
-
+
+ byte[] l = BinaryUtils.convert(data.length - 1, 2);
+ data[1] = l[0];
+ data[2] = l[1];
+
+ byte[] x = BinaryUtils.convert(_x, 3);
+ data[11] = x[0];
+ data[12] = x[1];
+ data[13] = x[2];
+
+ byte[] y = BinaryUtils.convert(_y, 3);
+ data[14] = y[0];
+ data[15] = y[1];
+ data[16] = y[2];
+
os.write(data);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org