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/07/17 21:13:58 UTC
svn commit: r677689 [1/4] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources: conf/
src/java/org/apache/fop/render/ src/java/org/apache/fop/render/afp/
src/java/org/apache/fop/render/afp/goca/
src/java/org/apache/fop/render/afp/modca/ src/java/org/ap...
Author: acumiskey
Date: Thu Jul 17 12:13:56 2008
New Revision: 677689
URL: http://svn.apache.org/viewvc?rev=677689&view=rev
Log:
* Added new DataObjectFactory to take care of MO:DCA DataObject creation/instantiation.
* Created a DataObjectCache which is now used to cache all resource objects such as images to a RandomAccessFile so all the memory isn't eaten by them during rendering.
* Added new GraphicsObjectPainter class invoked by DataObjectFactory on creation of GraphicsObject.
* Added Category and Type inner interfaces and handy copySF() to base AbstractAFPObject with more code reuse, simplifications/optimizations of writeStart() and writeEnd().
* SVG entry and isImage() isGraphic() convenience methods added to MO:DCA Registry.
* Updated AFPSVGHandler to use similar fox:conversion-mode foreign attribute mechanism for bitmap painting fallback used by PCLRenderer and PDFRenderer.
Added:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java (with props)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java (with props)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java (with props)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java (with props)
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/conf/fop.xconf
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ImageObjectInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceLevel.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSegment.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Writable.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/conf/fop.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/conf/fop.xconf?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/conf/fop.xconf (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/conf/fop.xconf Thu Jul 17 12:13:56 2008
@@ -111,7 +111,6 @@
<images mode="b+w" bits-per-pixel="8"/>
<renderer-resolution>240</renderer-resolution>
<resource-group-file>resources.afp</resource-group-file>
- <goca-enabled/>
<fonts>
<!--
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java Thu Jul 17 12:13:56 2008
@@ -64,6 +64,7 @@
/**
* Render the SVG document.
+ *
* @param context the renderer context
* @param doc the SVG document
* @throws IOException In case of an I/O error while painting the image
@@ -84,12 +85,12 @@
//Build the GVT tree
final GraphicsNode root;
- final String uri = getDocumentURI(doc);
try {
root = builder.build(ctx, doc);
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
+ final String uri = getDocumentURI(doc);
eventProducer.svgNotBuilt(this, e, uri);
return;
}
@@ -123,6 +124,7 @@
/**
* Gets the document URI from a Document instance if possible.
+ *
* @param doc the Document
* @return the URI or null
*/
@@ -138,6 +140,7 @@
/**
* Override this method to update the renderer context if it needs special settings for
* certain conditions.
+ *
* @param context the renderer context
*/
protected void updateRendererContext(RendererContext context) {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java Thu Jul 17 12:13:56 2008
@@ -218,24 +218,24 @@
// coordinates
int type = iter.currentSegment(vals);
if (type == PathIterator.SEG_MOVETO) {
- log.debug("SEG_MOVETO");
+// log.debug("SEG_MOVETO");
openingCoords[0] = currCoords[0] = (int)Math.round(vals[0]);
openingCoords[1] = currCoords[1] = (int)Math.round(vals[1]);
} else {
int numCoords;
if (type == PathIterator.SEG_LINETO) {
- log.debug("SEG_LINETO");
+// log.debug("SEG_LINETO");
numCoords = 2;
} else if (type == PathIterator.SEG_QUADTO) {
- log.debug("SEG_QUADTO");
+// log.debug("SEG_QUADTO");
numCoords = 4;
} else if (type == PathIterator.SEG_CUBICTO) {
- log.debug("SEG_CUBICTO");
+// log.debug("SEG_CUBICTO");
numCoords = 6;
} else {
// close of the graphics segment
if (type == PathIterator.SEG_CLOSE) {
- log.debug("SEG_CLOSE");
+// log.debug("SEG_CLOSE");
coords = new int[] {
coords[coords.length - 2],
coords[coords.length - 1],
@@ -317,17 +317,13 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void draw(Shape shape) {
log.debug("draw() shape=" + shape);
doDrawing(shape, false);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void fill(Shape shape) {
log.debug("fill() shape=" + shape);
doDrawing(shape, true);
@@ -345,9 +341,7 @@
ioe.printStackTrace();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void drawString(String s, float x, float y) {
try {
if (customTextHandler != null && !textAsShapes) {
@@ -360,78 +354,86 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public GraphicsConfiguration getDeviceConfiguration() {
return new AFPGraphicsConfiguration();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
log.debug("copyArea() NYI: ");
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Graphics create() {
return new AFPGraphics2D(this);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void dispose() {
this.graphicsObj = null;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
return drawImage(img, x, y, img.getWidth(observer), img.getHeight(observer), observer);
}
- /**
- * {@inheritDoc}
- */
+// private BufferedImage buildBufferedImage(Dimension size) {
+// return new BufferedImage(size.width, size.height,
+// BufferedImage.TYPE_INT_ARGB);
+// }
+
+ /** {@inheritDoc} */
public boolean drawImage(Image img, int x, int y, int width, int height,
ImageObserver observer) {
- //TODO: this might be achieved by creating a new IOCA image (ImageObject)
- // and placing it in an Overlay - but then stacking order would not be preserved.
log.debug("drawImage(): NYI img=" + img + ", x=" + x + ", y=" + y
+ ", width=" + width + ", height=" + height + ", obs=" + observer);
return false;
+// Dimension size = new Dimension(width, height);
+// BufferedImage buf = buildBufferedImage(size);
+//
+// java.awt.Graphics2D graphics2D = buf.createGraphics();
+// graphics2D.setComposite(AlphaComposite.SrcOver);
+// graphics2D.setBackground(new Color(1, 1, 1, 0));
+// graphics2D.setPaint(new Color(1, 1, 1, 0));
+// graphics2D.fillRect(0, 0, width, height);
+// graphics2D.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
+// graphics2D.setComposite(gc.getComposite());
+//
+// if (!graphics2D.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) {
+// return false;
+// }
+//
+// ImageInfo info = new ImageInfo(null, "image/unknown");
+//
+// ImageSize bufsize = new ImageSize(buf.getWidth(), buf.getHeight(), 72);
+// info.setSize(bufsize);
+// ImageRendered imgRend = new ImageRendered(info, buf, null);
+//
+// AFPDataStream afpDataStream = afpInfo.getAFPDataStream();
+// ImageObjectInfo imageObjectInfo = new ImageObjectInfo();
+// afpDataStream.createObject(imageObjectInfo);
+// return true;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
log.debug("drawRenderedImage() NYI: img=" + img + ", xform=" + xform);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public FontMetrics getFontMetrics(Font f) {
log.debug("getFontMetrics() NYI: f=" + f);
return null;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void setXORMode(Color col) {
log.debug("setXORMode() NYI: col=" + col);
}
@@ -449,6 +451,8 @@
}
/**
+ * Returns the GOCA graphics object
+ *
* @return the GOCA graphics object
*/
protected GraphicsObject getGraphicsObject() {
@@ -456,18 +460,12 @@
}
/**
- * Sets the graphics object
- * @param obj the graphics object
+ * Sets the GOCA graphics object
+ *
+ * @param obj the GOCA graphics object
*/
- protected void setGraphicsObject(GraphicsObject obj) {
+ public void setGraphicsObject(GraphicsObject obj) {
this.graphicsObj = obj;
}
-// /**
-// * Sets the SVG document URI
-// * @param documentURI the SVG document URI
-// */
-// public void setDocumentURI(String documentURI) {
-// this.documentURI = documentURI;
-// }
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java Thu Jul 17 12:13:56 2008
@@ -19,20 +19,19 @@
package org.apache.fop.render.afp;
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContext.RendererContextWrapper;
/**
* Graphics2DAdapter implementation for AFP.
@@ -52,27 +51,57 @@
public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
- RendererContext.RendererContextWrapper wrappedContext
- = new RendererContext.RendererContextWrapper(context);
- AFPRenderer afp = (AFPRenderer)context.getRenderer();
- Boolean grayObj = (Boolean)context.getProperty(AFPRendererContextConstants.AFP_GRAYSCALE);
- boolean gray = (grayObj != null ? grayObj.booleanValue() : false);
- FOUserAgent userAgent = context.getUserAgent();
+ AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context);
+
+ final boolean textAsShapes = false;
+ AFPGraphics2D graphics = new AFPGraphics2D(textAsShapes);
+ graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
- //Paint to a BufferedImage
- int resolution = (int)Math.round(userAgent.getTargetResolution());
- BufferedImage bi
- = paintToBufferedImage(painter, wrappedContext, resolution, gray, false);
- ImageManager manager = userAgent.getFactory().getImageManager();
- ImageSessionContext sessionContext = userAgent.getImageSessionContext();
- AFPState state = (AFPState)context.getProperty(AFPRendererContextConstants.AFP_STATE);
- try {
- ImageInfo info = manager.getImageInfo(state.getImageUri(), sessionContext);
- java.util.Map foreignAttributes = null;
- afp.drawBufferedImage(info, bi, resolution, x, y, width, height, foreignAttributes);
- } catch (ImageException e) {
- log.error(e);
+ if (afpInfo.paintAsBitmap) {
+ //Fallback solution: Paint to a BufferedImage
+ int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
+ RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
+ BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);
+
+ float scale = AFPRenderer.NORMAL_AFP_RESOLUTION
+ / context.getUserAgent().getTargetResolution();
+ graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
+ } else {
+ // get the 'width' and 'height' attributes of the SVG document
+ Dimension dim = painter.getImageSize();
+ float imw = (float)dim.getWidth() / 1000f;
+ float imh = (float)dim.getHeight() / 1000f;
+
+ Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
+ painter.paint(graphics, area);
}
+
+// RendererContext.RendererContextWrapper wrappedContext
+// = new RendererContext.RendererContextWrapper(context);
+//AFPRenderer renderer = (AFPRenderer)context.getRenderer();
+//Boolean grayObj = (Boolean)context.getProperty(AFPRendererContextConstants.AFP_GRAYSCALE);
+//boolean gray = (grayObj != null ? grayObj.booleanValue() : false);
+//
+//FOUserAgent userAgent = context.getUserAgent();
+//
+////Paint to a BufferedImage
+//int resolution = (int)Math.round(userAgent.getTargetResolution());
+//BufferedImage bi
+// = paintToBufferedImage(painter, wrappedContext, resolution, gray, false);
+//
+//ImageManager manager = userAgent.getFactory().getImageManager();
+//ImageSessionContext sessionContext = userAgent.getImageSessionContext();
+//AFPState state = (AFPState)context.getProperty(AFPRendererContextConstants.AFP_STATE);
+//String uri = state.getImageUri();
+//try {
+// ImageInfo info = manager.getImageInfo(uri, sessionContext);
+// java.util.Map foreignAttributes = null;
+// renderer.drawBufferedImage(info, bi, resolution, x, y, width, height, foreignAttributes);
+//} catch (ImageException e) {
+// log.error(e);
+//}
+
+// painter.paint(g2d, area)
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java Thu Jul 17 12:13:56 2008
@@ -51,8 +51,12 @@
/** See AFP_STATE */
private AFPState afpState;
+ /** true if SVG should be rendered as a bitmap instead of natively */
+ public boolean paintAsBitmap;
+
/**
* Returns the width.
+ *
* @return the width
*/
public int getWidth() {
@@ -61,6 +65,7 @@
/**
* Sets the width.
+ *
* @param width The pageWidth to set
*/
public void setWidth(int width) {
@@ -69,6 +74,7 @@
/**
* Returns the height.
+ *
* @return the height
*/
public int getHeight() {
@@ -77,6 +83,7 @@
/**
* Sets the height.
+ *
* @param height The height to set
*/
public void setHeight(int height) {
@@ -84,7 +91,9 @@
}
/**
- * @return Configuration the handler configuration
+ * Returns the handler configuration
+ *
+ * @return the handler configuration
*/
public Configuration getHandlerConfiguration() {
return this.cfg;
@@ -92,6 +101,7 @@
/**
* Sets the handler configuration
+ *
* @param cfg the handler configuration
*/
public void setHandlerConfiguration(Configuration cfg) {
@@ -99,27 +109,35 @@
}
/**
- * @return FontInfo the font info
+ * Return the font info
+ *
+ * @return the font info
*/
public FontInfo getFontInfo() {
return this.fontInfo;
}
/**
- * @return Map the current page fonts
+ * Returns the current AFP state
+ *
+ * @return the current AFP state
*/
public AFPState getState() {
return this.afpState;
}
/**
- * @return AFPDataStream the afp datastream
+ * Returns the AFPDataStream the afp datastream
+ *
+ * @return the AFPDataStream the afp datastream
*/
public AFPDataStream getAFPDataStream() {
return this.afpDataStream;
}
/**
+ * Returns true if supports color
+ *
* @return true if supports color
*/
public boolean isColorSupported() {
@@ -127,6 +145,8 @@
}
/**
+ * Returns the current x position coordinate
+ *
* @return the current x position coordinate
*/
protected int getX() {
@@ -134,6 +154,8 @@
}
/**
+ * Returns the current y position coordinate
+ *
* @return the current y position coordinate
*/
protected int getY() {
@@ -141,6 +163,8 @@
}
/**
+ * Returns the resolution
+ *
* @return the resolution
*/
protected int getResolution() {
@@ -148,6 +172,7 @@
}
/**
+ * Returns the number of bits per pixel to use
* @return the number of bits per pixel to use
*/
protected int getBitsPerPixel() {
@@ -156,6 +181,7 @@
/**
* Sets the current x position coordinate
+ *
* @param x the current x position coordinate
*/
protected void setX(int x) {
@@ -164,6 +190,7 @@
/**
* Sets the current y position coordinate
+ *
* @param y the current y position coordinate
*/
protected void setY(int y) {
@@ -172,6 +199,7 @@
/**
* Sets the current font info
+ *
* @param fontInfo the current font info
*/
protected void setFontInfo(FontInfo fontInfo) {
@@ -180,6 +208,7 @@
/**
* Sets the AFP state
+ *
* @param state the AFP state
*/
public void setState(AFPState state) {
@@ -188,12 +217,14 @@
/**
* Sets the AFP datastream
+ *
* @param dataStream the AFP datastream
*/
public void setAFPDataStream(AFPDataStream dataStream) {
this.afpDataStream = dataStream;
}
+
/** {@inheritDoc} */
public String toString() {
return "width=" + width
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java Thu Jul 17 12:13:56 2008
@@ -136,6 +136,9 @@
*/
public class AFPRenderer extends AbstractPathOrientedRenderer {
+ /** Normal PDF resolution (72dpi) */
+ public static final int NORMAL_AFP_RESOLUTION = 72;
+
private static final int X = 0;
private static final int Y = 1;
@@ -166,8 +169,6 @@
/** drawing state */
private AFPState currentState = new AFPState();
- private boolean gocaEnabled = false;
-
/**
* Constructor for AFPRenderer.
*/
@@ -226,7 +227,8 @@
renderPageObjectExtensions(page);
- getPages().put(page, getAFPDataStream().savePage());
+ PageObject currentPage = getAFPDataStream().savePage();
+ getPages().put(page, currentPage);
}
private Map/*<PageViewport, PageObject>*/ getPages() {
@@ -987,6 +989,11 @@
return MimeConstants.MIME_AFP;
}
+ /**
+ * Returns the page segments map
+ *
+ * @return the page segments map
+ */
private Map/*<String,String>*/getPageSegments() {
if (pageSegmentsMap == null) {
pageSegmentsMap = new java.util.HashMap/*<String,String>*/();
@@ -1002,7 +1009,6 @@
* the page object
*/
private void renderPageObjectExtensions(PageViewport pageViewport) {
-
this.pageSegmentsMap = null;
if (pageViewport.getExtensionAttachments() != null
&& pageViewport.getExtensionAttachments().size() > 0) {
@@ -1094,6 +1100,8 @@
}
/**
+ * Returns the current AFP state
+ *
* @return the current AFP state
*/
protected AbstractState getState() {
@@ -1103,21 +1111,6 @@
return currentState;
}
- /**
- * @param enabled
- * true if AFP GOCA is enabled for SVG support
- */
- protected void setGOCAEnabled(boolean enabled) {
- this.gocaEnabled = enabled;
- }
-
- /**
- * @return true of AFP GOCA is enabled for SVG support
- */
- protected boolean isGOCAEnabled() {
- return this.gocaEnabled;
- }
-
// TODO: remove this and use the superclass implementation
/** {@inheritDoc} */
protected void renderReferenceArea(Block block) {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Thu Jul 17 12:13:56 2008
@@ -37,7 +37,6 @@
import org.apache.fop.render.afp.fonts.OutlineFont;
import org.apache.fop.render.afp.fonts.RasterFont;
import org.apache.fop.render.afp.modca.AFPDataStream;
-import org.apache.fop.render.afp.modca.InterchangeSet;
import org.apache.fop.util.LogUtil;
/**
@@ -47,6 +46,7 @@
/**
* Default constructor
+ *
* @param userAgent user agent
*/
public AFPRendererConfigurator(FOUserAgent userAgent) {
@@ -183,6 +183,7 @@
/**
* Builds a list of AFPFontInfo objects for use with the setup() method.
+ *
* @param cfg Configuration object
* @return List the newly created list of fonts
* @throws ConfigurationException if something's wrong with the config data
@@ -212,6 +213,7 @@
/**
* Configure the AFP renderer.
+ *
* @param renderer AFP renderer
* @throws FOPException fop exception
* @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
@@ -252,12 +254,6 @@
// afpRenderer.getAFPDataStream().setInterchangeSet(interchangeSet);
// }
- // goca enabled
- Configuration gocaSupportCfg = cfg.getChild("goca-enabled", false);
- if (gocaSupportCfg != null) {
- afpRenderer.setGOCAEnabled(true);
- }
-
// a default external resource group file setting
Configuration resourceGroupFileCfg
= cfg.getChild("resource-group-file", false);
@@ -271,7 +267,8 @@
}
File resourceGroupFile = new File(resourceGroupDest);
if (resourceGroupFile.canWrite()) {
- afpRenderer.getAFPDataStream().setDefaultResourceGroupFile(resourceGroupFile);
+ AFPDataStream datastream = afpRenderer.getAFPDataStream();
+ datastream.setDefaultResourceGroupFilePath(resourceGroupDest);
} else {
log.warn("Unable to write to default external resource group file '"
+ resourceGroupDest + "'");
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java Thu Jul 17 12:13:56 2008
@@ -21,23 +21,27 @@
// FOP
import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.BridgeException;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.render.afp.modca.AFPConstants;
import org.apache.fop.render.afp.modca.AFPDataStream;
-import org.apache.fop.render.afp.modca.GraphicsObject;
+import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
+import org.apache.xmlgraphics.util.QName;
import org.w3c.dom.Document;
/**
@@ -50,10 +54,8 @@
/** {@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);
+ renderSVGDocument(context, doc);
}
}
@@ -76,6 +78,13 @@
AFPRendererContextConstants.AFP_STATE));
afpi.setAFPDataStream((AFPDataStream)context.getProperty(
AFPRendererContextConstants.AFP_DATASTREAM));
+
+ Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
+ QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
+ if (foreign != null
+ && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) {
+ afpi.paintAsBitmap = true;
+ }
return afpi;
}
@@ -84,28 +93,74 @@
*
* @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 Document doc) throws IOException {
+
+ AFPRenderer renderer = (AFPRenderer)context.getRenderer();
+ AFPInfo afpInfo = getAFPInfo(context);
+ if (afpInfo.paintAsBitmap) {
+ try {
+ super.renderSVGDocument(context, doc);
+ } catch (IOException ioe) {
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
+ }
+ return;
+ }
+
+ String uri = ((AbstractDocument)doc).getDocumentURI();
+ AFPState currentState = (AFPState)renderer.getState();
+ currentState.setImageUri(uri);
+
+ // set the data object parameters
+ ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo();
+
+ int x = (int)Math.round((afpInfo.getX() * 25.4f) / 1000f);
+ objectAreaInfo.setX(x);
+
+ int y = (int)Math.round((afpInfo.getY() * 25.4f) / 1000f);
+ objectAreaInfo.setY(y);
+
+ int resolution = afpInfo.getResolution();
+ objectAreaInfo.setWidthRes(resolution);
+ objectAreaInfo.setHeightRes(resolution);
+
+ int width = (int)Math.round((afpInfo.getWidth() * resolution)
+ / AFPConstants.DPI_72_MPTS);
+ objectAreaInfo.setWidth(width);
+
+ int height = (int)Math.round((afpInfo.getHeight() * resolution)
+ / AFPConstants.DPI_72_MPTS);
+ objectAreaInfo.setHeight(height);
+
+ DataObjectInfo dataObjectInfo = new GraphicsObjectInfo();
+ dataObjectInfo.setUri(uri);
+
+ // Configure Graphics2D implementation
final boolean textAsShapes = false;
AFPGraphics2D graphics = new AFPGraphics2D(textAsShapes);
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
graphics.setAFPInfo(afpInfo);
- GVTBuilder builder = new GVTBuilder();
+ // Configure GraphicsObjectPainter with the Graphics2D implementation
+ GraphicsObjectPainter painter = new GraphicsObjectPainter();
+ painter.setGraphics2D(graphics);
+ ((GraphicsObjectInfo)dataObjectInfo).setPainter(painter);
boolean strokeText = false;
Configuration cfg = afpInfo.getHandlerConfiguration();
if (cfg != null) {
strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
}
- SVGUserAgent svgUserAgent = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
-
+ SVGUserAgent svgUserAgent
+ = new SVGUserAgent(context.getUserAgent(), 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);
@@ -115,79 +170,52 @@
AFPTextElementBridge tBridge = new AFPTextElementBridge(textPainter);
ctx.putBridge(tBridge);
}
+
+ Map/*<QName, String>*/ foreignAttributes
+ = (Map/*<QName, String>*/)context.getProperty(
+ RendererContextConstants.FOREIGN_ATTRIBUTES);
+ dataObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
+ // Build the SVG DOM and provide the painter with it
GraphicsNode root;
+ GVTBuilder builder = new GVTBuilder();
try {
root = builder.build(ctx, doc);
- } catch (Exception e) {
- log.error("SVG graphic could not be built: "
- + e.getMessage(), e);
+ painter.setGraphicsNode(root);
+ } catch (BridgeException e) {
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgNotBuilt(this, e, uri);
return;
}
- log.debug("Generating SVG at "
- + afpInfo.getResolution() + "dpi.");
-
- int res = afpInfo.getResolution();
- double w = ctx.getDocumentSize().getWidth() * 1000f;
- double h = ctx.getDocumentSize().getHeight() * 1000f;
+
+ Dimension2D dim = ctx.getDocumentSize();
+ double w = dim.getWidth() * 1000f;
+ double h = dim.getHeight() * 1000f;
// convert to afp inches
- double scaleX = ((afpInfo.getWidth() / w) * res) / AFPConstants.DPI_72;
- double scaleY = ((afpInfo.getHeight() / h) * res) / AFPConstants.DPI_72;
- double xOffset = (afpInfo.getX() * res) / AFPConstants.DPI_72_MPTS;
- double yOffset = ((afpInfo.getHeight() - afpInfo.getY()) * res) / AFPConstants.DPI_72_MPTS;
-
- // Transformation matrix that establishes the local coordinate system for the SVG graphic
- // in relation to the current coordinate system (note: y axis is inverted)
+ double scaleX = ((afpInfo.getWidth() / w) * resolution) / AFPConstants.DPI_72;
+ double scaleY = ((afpInfo.getHeight() / h) * resolution) / AFPConstants.DPI_72;
+ double xOffset = (afpInfo.getX() * resolution) / AFPConstants.DPI_72_MPTS;
+ double yOffset
+ = ((afpInfo.getHeight() - afpInfo.getY()) * resolution) / AFPConstants.DPI_72_MPTS;
+
+ // 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(scaleX, 0, 0, -scaleY, xOffset, yOffset);
graphics.setTransform(trans);
-
- int x = (int)Math.round((afpInfo.getX() * 25.4f) / 1000f);
- int y = (int)Math.round((afpInfo.getY() * 25.4f) / 1000f);
- int width = (int)Math.round((afpInfo.getWidth() * res) / AFPConstants.DPI_72_MPTS);
- int height = (int)Math.round((afpInfo.getHeight() * res) / AFPConstants.DPI_72_MPTS);
-
- // set the data object parameters
- DataObjectInfo dataObjectInfo = new DataObjectInfo();
-
- String docUri = ((AbstractDocument)doc).getDocumentURI();
- dataObjectInfo.setUri(docUri);
- ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo();
- objectAreaInfo.setX(x);
- objectAreaInfo.setY(y);
- objectAreaInfo.setWidth(width);
- objectAreaInfo.setHeight(height);
- objectAreaInfo.setWidthRes(res);
- objectAreaInfo.setHeightRes(res);
-
+ // Set the object area info
dataObjectInfo.setObjectAreaInfo(objectAreaInfo);
-
- Map/*<QName, String>*/ foreignAttributes
- = (Map/*<QName, String>*/)context.getProperty(
- RendererContextConstants.FOREIGN_ATTRIBUTES);
- dataObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
- AFPDataStream afpDataStream = afpInfo.getAFPDataStream();
- GraphicsObject graphicsObj = (GraphicsObject)afpDataStream.createObject(dataObjectInfo);
- graphics.setGraphicsObject(graphicsObj);
-
- try {
- root.paint(graphics);
- } catch (Exception e) {
- log.error("SVG graphic could not be rendered: " + e.getMessage(), e);
- }
-
- graphics.dispose();
+ // Create the object
+ afpInfo.getAFPDataStream().createObject(dataObjectInfo);
}
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
- if (renderer instanceof AFPRenderer) {
- AFPRenderer afpRenderer = (AFPRenderer)renderer;
- return afpRenderer.isGOCAEnabled();
- }
- return false;
+ return (renderer instanceof AFPRenderer);
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java Thu Jul 17 12:13:56 2008
@@ -29,36 +29,27 @@
private static Log log = LogFactory.getLog("org.apache.fop.render.afp.AFPState");
- /**
- * The portrait rotation
- */
+ /** The portrait rotation */
private int portraitRotation = 0;
- /**
- * The landscape rotation
- */
+ /** The landscape rotation */
private int landscapeRotation = 270;
- /**
- * Flag to the set the output object type for images
- */
+ /** Flag to the set the output object type for images */
private boolean colorImages = false;
- /**
- * Default value for image depth
- */
+ /** Default value for image depth */
private int bitsPerPixel = 8;
- /**
- * The output resolution
- */
+ /** The output resolution */
private int resolution = 240; // 240 dpi
- /**
- * The current page
- */
+ /** The current page */
private AFPPageState pageState = new AFPPageState();
+ /** Whether or not GOCA is used for handling SVG */
+ private boolean goca = false; // false by default
+
/**
* Sets the rotation to be used for portrait pages, valid values are 0
* (default), 90, 180, 270.
@@ -79,6 +70,8 @@
}
/**
+ * Returns the rotation to be used for portrait pages
+ *
* @return the rotation to be used for portrait pages
*/
protected int getPortraitRotation() {
@@ -104,6 +97,8 @@
}
/**
+ * Returns the landscape rotation
+ *
* @return the landscape rotation
*/
protected int getLandscapeRotation() {
@@ -131,6 +126,8 @@
}
/**
+ * Returns the number of bits per pixel
+ *
* @return the number of bits per pixel
*/
public int getBitsPerPixel() {
@@ -148,6 +145,8 @@
}
/**
+ * Returns true if color images are to be used
+ *
* @return true if color images are to be used
*/
protected boolean isColorImages() {
@@ -182,6 +181,8 @@
}
/**
+ * Returns the state of the current page
+ *
* @return the state of the current page
*/
protected AFPPageState getPageState() {
@@ -189,7 +190,26 @@
}
/**
+ * Sets if GOCA is to be used for SVG handling
+ *
+ * @param value is true if GOCA is used for SVG handling
+ */
+ public void setUseGOCA(boolean value) {
+ this.goca = value;
+ }
+
+ /**
+ * Returns true if GOCA is enabled for SVG handling
+ *
+ * @return true if GOCA is enabled for SVG handling
+ */
+ public boolean useGOCA() {
+ return this.goca;
+ }
+
+ /**
* Sets if the current painted shape is to be filled
+ *
* @param fill true if the current painted shape is to be filled
* @return true if the fill value has changed
*/
@@ -203,6 +223,7 @@
/**
* Gets the current page fonts
+ *
* @return the current page fonts
*/
protected AFPPageFonts getPageFonts() {
@@ -211,6 +232,7 @@
/**
* Increments and returns the page font count
+ *
* @return the page font count
*/
public int incrementPageFontCount() {
@@ -219,6 +241,7 @@
/**
* Sets the page width
+ *
* @param pageWidth the page width
*/
public void setPageWidth(int pageWidth) {
@@ -226,6 +249,8 @@
}
/**
+ * Returns the page width
+ *
* @return the page width
*/
public int getPageWidth() {
@@ -234,6 +259,7 @@
/**
* Sets the page height
+ *
* @param pageHeight the page height
*/
public void setPageHeight(int pageHeight) {
@@ -241,6 +267,8 @@
}
/**
+ * Returns the page height
+ *
* @return the page height
*/
public int getPageHeight() {
@@ -249,6 +277,7 @@
/**
* Sets the uri of the current image
+ *
* @param uri the uri of the current image
*/
protected void setImageUri(String uri) {
@@ -257,6 +286,7 @@
/**
* Gets the uri of the current image
+ *
* @return the uri of the current image
*/
public String getImageUri() {
@@ -291,6 +321,8 @@
private int fontCount = 0;
/**
+ * Returns the page width
+ *
* @return the page width
*/
protected int getWidth() {
@@ -299,6 +331,7 @@
/**
* Sets the page width
+ *
* @param width the page width
*/
protected void setWidth(int width) {
@@ -306,6 +339,8 @@
}
/**
+ * Returns the page height
+ *
* @return the page height
*/
protected int getHeight() {
@@ -314,6 +349,7 @@
/**
* Sets the page height
+ *
* @param height the page height
*/
protected void setHeight(int height) {
@@ -321,6 +357,8 @@
}
/**
+ * Returns the page fonts
+ *
* @return the page fonts
*/
protected AFPPageFonts getFonts() {
@@ -329,6 +367,7 @@
/**
* Sets the current page fonts
+ *
* @param fonts the current page fonts
*/
protected void setFonts(AFPPageFonts fonts) {
@@ -336,6 +375,8 @@
}
/**
+ * Increments and returns the current page font count
+ *
* @return increment and return the current page font count
*/
protected int incrementFontCount() {
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java?rev=677689&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java Thu Jul 17 12:13:56 2008
@@ -0,0 +1,196 @@
+/*
+ * 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;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.render.afp.modca.DataObjectFactory;
+
+/**
+ * Caches and creates (as necessary using an instance of DataObjectFactory)
+ * descendants of AbstractDataObject
+ */
+public final class DataObjectCache {
+
+ /** Static logging instance */
+ private static final Log log = LogFactory.getLog(DataObjectCache.class);
+
+ private static final String CACHE_FILENAME_PREFIX = "AFP_";
+
+ /** Static mapping of data object caches id --> cache */
+ private static Map/*<Integer,DataObjectCache>*/ cacheMap
+ = new java.util.HashMap/*<Integer,DataObjectCache>*/();
+
+
+ /** Mapping of data object uri --> cache entry */
+ private Map/*<String,DataObjectCache.Entry>*/ cacheRecordMap
+ = new java.util.HashMap/*<String,DataObjectCache.Entry>*/();
+
+ /** Used for create data objects */
+ private DataObjectFactory factory = new DataObjectFactory();
+
+ /** Used for storage of data objects */
+ private RandomAccessFile raFile;
+
+ /** File channel used for manipulating the temporary file */
+ private FileChannel channel;
+
+ /** The temporary cache file */
+ private File tempFile;
+
+ /** The cache id */
+ private int id;
+
+ /** The next file pointer position in the cache file */
+ private long nextPos;
+
+ /**
+ * Returns an instance of the cache
+ *
+ * @return an instance of the cache or null if failed
+ */
+ public static DataObjectCache getInstance() {
+ synchronized (cacheMap) {
+ int id = System.identityHashCode(Thread.currentThread());
+ Integer cacheKey = new Integer(id);
+ DataObjectCache cache = (DataObjectCache)cacheMap.get(cacheKey);
+ if (cache == null) {
+ try {
+ cache = new DataObjectCache();
+ cacheMap.put(cacheKey, cache);
+ } catch (IOException e) {
+ log.error("Failed to create cache");
+ }
+ }
+ return cache;
+ }
+ }
+
+ /**
+ * Default constructor
+ */
+ private DataObjectCache() throws IOException {
+ this.id = System.identityHashCode(Thread.currentThread());
+ this.tempFile = File.createTempFile(CACHE_FILENAME_PREFIX + id, null);
+ this.raFile = new RandomAccessFile(tempFile, "rw");
+ this.channel = raFile.getChannel();
+ }
+
+ /**
+ * Clears the data object cache
+ */
+ public void clear() {
+ try {
+ raFile.close();
+ tempFile.delete();
+ } catch (IOException e) {
+ log.error("Failed to close temporary file");
+ }
+ }
+
+ /**
+ * Creates and adds a new data object and record to the cache as necessary.
+ *
+ * @param dataObjectInfo a data object info
+ *
+ * @return the name of the related data object
+ */
+ public String put(DataObjectInfo dataObjectInfo) {
+ ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ Record record = (Record)cacheRecordMap.get(resourceInfo);
+ if (record == null) {
+ record = new Record();
+ AbstractNamedAFPObject dataObj = factory.createObject(dataObjectInfo);
+ record.objectName = dataObj.getName();
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ try {
+ channel.position(nextPos);
+ record.position = channel.position();
+ dataObj.write(os);
+ record.size = os.size();
+ MappedByteBuffer byteBuffer
+ = channel.map(FileChannel.MapMode.READ_WRITE, record.position, record.size);
+ byteBuffer.put(os.toByteArray());
+ channel.write(byteBuffer);
+ nextPos += record.size + 1;
+ } catch (IOException e) {
+ log.error("Failed to write cache record for '"
+ + resourceInfo + "', " + e.getMessage());
+ }
+ cacheRecordMap.put(resourceInfo, record);
+ }
+ return record.objectName;
+ }
+
+ /**
+ * Returns the written binary data of the AbstractDataObject from the cache file
+ *
+ * @param resourceInfo the data resource info
+ * @return the binary data of the AbstractDataObject or null if failed.
+ */
+ public byte[] get(ResourceInfo resourceInfo) {
+ Record record = (Record)cacheRecordMap.get(resourceInfo);
+ if (record == null) {
+ throw new IllegalArgumentException("Unknown data object " + resourceInfo);
+ }
+ MappedByteBuffer byteBuffer = null;
+ try {
+ byteBuffer = channel.map(FileChannel.MapMode.READ_ONLY, record.position, record.size);
+ } catch (IOException e) {
+ log.error("Failed to read cache record for '" + resourceInfo + "', " + e.getMessage());
+ return null;
+ }
+ if (byteBuffer.hasArray()) {
+ return byteBuffer.array();
+ } else {
+ byte[] data = new byte[record.size];
+ byteBuffer.get(data);
+ return data;
+ }
+ }
+
+ /**
+ * Returns the data object factory
+ *
+ * @return the data object factory
+ */
+ public DataObjectFactory getFactory() {
+ return this.factory;
+ }
+
+ /**
+ * A cache record
+ */
+ private class Record {
+ protected long position;
+ protected int size;
+ protected String objectName;
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectCache.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java Thu Jul 17 12:13:56 2008
@@ -39,18 +39,14 @@
private static final String RESOURCE_LEVEL = "afp:resource-level";
private static final String RESOURCE_GROUP_FILE = "afp:resource-group-file";
- private static final ResourceInfo DEFAULT_RESOURCE_INFO = new ResourceInfo();
-
- private String uri;
-
/** the object area info */
private ObjectAreaInfo objectAreaInfo;
/** object type entry */
- private ObjectType objectType;
+ private Registry.ObjectType objectType;
/** resource info */
- private ResourceInfo resourceInfo = DEFAULT_RESOURCE_INFO;
+ private ResourceInfo resourceInfo;
/**
* Default constructor
@@ -59,23 +55,8 @@
}
/**
- * Sets the data object uri
- * @param uri the data object uri
- */
- public void setUri(String uri) {
- this.uri = uri;
- }
-
-
- /**
- * @return the uri of this data object
- */
- public String getUri() {
- return uri;
- }
-
- /**
* Sets the object type
+ *
* @param objectType the object type
*/
public void setObjectType(Registry.ObjectType objectType) {
@@ -83,6 +64,8 @@
}
/**
+ * Returns the object type MOD:CA Registry entry
+ *
* @return the object type MOD:CA Registry entry
*/
public ObjectType getObjectType() {
@@ -90,14 +73,20 @@
}
/**
+ * Returns the resource level at which this data object should reside
+ *
* @return the resource level at which this data object should reside
*/
public ResourceInfo getResourceInfo() {
+ if (resourceInfo == null) {
+ this.resourceInfo = new ResourceInfo();
+ }
return resourceInfo;
}
/**
* Sets the resource level at which this object should reside
+ *
* @param resourceInfo the resource level at which this data object should reside
*/
public void setResourceInfo(ResourceInfo resourceInfo) {
@@ -106,6 +95,7 @@
/**
* Sets the object area info
+ *
* @param objectAreaInfo the object area info
*/
public void setObjectAreaInfo(ObjectAreaInfo objectAreaInfo) {
@@ -113,6 +103,8 @@
}
/**
+ * Returns the object area info
+ *
* @return the object area info
*/
public ObjectAreaInfo getObjectAreaInfo() {
@@ -121,6 +113,7 @@
/**
* Sets the resource group settings using the given foreign attributes
+ *
* @param foreignAttributes a mapping of element attributes names to values
*/
public void setResourceInfoFromForeignAttributes(Map/*<QName, String>*/ foreignAttributes) {
@@ -165,7 +158,7 @@
log.warn("overwritting external resource file: "
+ resourceExternalDest);
}
- resourceLevel.setExternalResourceGroupFile(resourceExternalGroupFile);
+ resourceLevel.setExternalFilePath(resourceExternalDest);
} catch (SecurityException ex) {
log.error("unable to gain read access to external resource file: "
+ resourceExternalDest);
@@ -180,13 +173,28 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
- return "uri=" + uri
- + (objectAreaInfo != null ? "objectAreaInfo=" + objectAreaInfo : "")
+ return (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
+ (objectType != null ? ", objectType=" + objectType : "")
+ (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
}
+
+ /**
+ * Returns the uri of this data object
+ *
+ * @return the uri of this data object
+ */
+ public String getUri() {
+ return getResourceInfo().getUri();
+ }
+
+ /**
+ * Sets the data object uri
+ *
+ * @param uri the data object uri
+ */
+ public void setUri(String uri) {
+ getResourceInfo().setUri(uri);
+ }
}
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java?rev=677689&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java Thu Jul 17 12:13:56 2008
@@ -0,0 +1,100 @@
+package org.apache.fop.render.afp;
+
+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.modca.ResourceGroup;
+
+/**
+ * Manages the use of resource groups (external and internal)
+ */
+public class ExternalResourceGroupManager {
+
+ /** Static logging instance */
+ protected static Log log = LogFactory.getLog(ExternalResourceGroupManager.class);
+
+ /** A mapping of external resource destinations to resource groups */
+ private Map/*<String,ResourceGroup>*/externalResourceGroups
+ = new java.util.HashMap/*<String,ResourceGroup>*/();
+
+ /** Sets the default resource group file */
+ private String defaultResourceGroupFilePath;
+
+ /**
+ * Default constructor
+ */
+ public ExternalResourceGroupManager() {
+ }
+
+ /**
+ * Sets the default resource group file
+ *
+ * @param resourceGroupFilePath the default resource group file path
+ */
+ public void setDefaultResourceGroupFilePath(String resourceGroupFilePath) {
+ this.defaultResourceGroupFilePath = resourceGroupFilePath;
+ }
+
+ /**
+ * Returns the corresponding resource group for the given resource level
+ *
+ * @param level the resource level
+ * @return the corresponding resource group for the given resource level
+ * or null if not found.
+ */
+ public ResourceGroup getResourceGroup(ResourceLevel level) {
+ ResourceGroup resourceGroup = null;
+ // this resource info does not have an external resource group
+ // file definition
+ String filePath = level.getExternalFilePath();
+ if (filePath != null) {
+ filePath = level.getExternalFilePath();
+ resourceGroup = (ResourceGroup)externalResourceGroups.get(filePath);
+ if (resourceGroup == null) {
+ resourceGroup = new ResourceGroup();
+ externalResourceGroups.put(filePath, resourceGroup);
+ }
+ } else if (defaultResourceGroupFilePath != null) {
+ // fallback to default resource group file
+ level.setExternalFilePath(defaultResourceGroupFilePath);
+ resourceGroup = getResourceGroup(level);
+ }
+ return resourceGroup;
+ }
+
+ /**
+ * Writes out all external resource groups
+ */
+ public void write() {
+ // write any external resources
+ Iterator it = externalResourceGroups.keySet().iterator();
+ while (it.hasNext()) {
+ String filePath = (String)it.next();
+ ResourceGroup resourceGroup
+ = (ResourceGroup)externalResourceGroups.get(filePath);
+ OutputStream os = null;
+ try {
+ log.debug("Writing external AFP resource file " + filePath);
+ os = new java.io.FileOutputStream(filePath);
+ resourceGroup.write(os);
+ } catch (IOException e) {
+ log.error(
+ "An error occurred when attempting to write external AFP resource file "
+ + filePath);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ log.error("Failed to close outputstream for external AFP resource file "
+ + filePath);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java?rev=677689&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java Thu Jul 17 12:13:56 2008
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+/**
+ * A graphics object info which contains necessary painting objects
+ */
+public class GraphicsObjectInfo extends DataObjectInfo {
+
+ private GraphicsObjectPainter painter;
+
+ /**
+ * Returns the graphics painter
+ *
+ * @return the graphics painter
+ */
+ public GraphicsObjectPainter getPainter() {
+ return painter;
+ }
+
+ /**
+ * Sets the graphics painter
+ *
+ * @param graphicsPainter the graphics painter
+ */
+ public void setPainter(GraphicsObjectPainter graphicsPainter) {
+ this.painter = graphicsPainter;
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java?rev=677689&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java Thu Jul 17 12:13:56 2008
@@ -0,0 +1,100 @@
+/*
+ * 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$ */
+
+/*
+ * 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;
+
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.modca.GraphicsObject;
+
+/**
+ * A simple AFP Graphics 2D painter
+ */
+public class GraphicsObjectPainter {
+ /** Static logging instance */
+ protected static Log log = LogFactory.getLog(GraphicsObjectPainter.class);
+
+ private AFPGraphics2D graphics2D;
+
+ private GraphicsNode root;
+
+ /**
+ * Default constructor
+ */
+ public GraphicsObjectPainter() {
+ }
+
+ /**
+ * Returns the graphics 2D
+ *
+ * @return the graphics 2D
+ */
+ public AFPGraphics2D getGraphics2D() {
+ return graphics2D;
+ }
+
+ /**
+ * Sets the graphics 2D
+ *
+ * @param graphics the AFP graphics 2D
+ */
+ public void setGraphics2D(AFPGraphics2D graphics) {
+ this.graphics2D = graphics;
+ }
+
+ /**
+ * Sets the graphics node
+ *
+ * @param rootNode the graphics root node
+ */
+ public void setGraphicsNode(GraphicsNode rootNode) {
+ this.root = rootNode;
+ }
+
+ /**
+ * Paints the graphics object
+ *
+ * @param graphicsObj the graphics object
+ */
+ public void paint(GraphicsObject graphicsObj) {
+ log.debug("Generating SVG");
+ graphics2D.setGraphicsObject(graphicsObj);
+ root.paint(graphics2D);
+ graphics2D.dispose();
+ }
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ImageObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ImageObjectInfo.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ImageObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ImageObjectInfo.java Thu Jul 17 12:13:56 2008
@@ -41,6 +41,7 @@
/**
* Sets the number of bits per pixel
+ *
* @param bitsPerPixel the number of bits per pixel
*/
public void setBitsPerPixel(int bitsPerPixel) {
@@ -49,6 +50,7 @@
/**
* Sets if this image is color
+ *
* @param color true if this is a color image
*/
public void setColor(boolean color) {
@@ -57,6 +59,7 @@
/**
* Sets the image data
+ *
* @param data the image data
*/
public void setData(byte[] data) {
@@ -65,6 +68,7 @@
/**
* Sets the image mime type
+ *
* @param mimeType the image mime type
*/
public void setMimeType(String mimeType) {
@@ -72,6 +76,8 @@
}
/**
+ * Returns the number of bits used per pixel
+ *
* @return the number of bits used per pixel
*/
public int getBitsPerPixel() {
@@ -79,6 +85,8 @@
}
/**
+ * Returns true if this is a color image
+ *
* @return true if this is a color image
*/
public boolean isColor() {
@@ -86,6 +94,8 @@
}
/**
+ * Returns the image data
+ *
* @return the image data
*/
public byte[] getData() {
@@ -93,13 +103,17 @@
}
/**
- * @return true of this image uses compression
+ * Returns true if this image uses compression
+ *
+ * @return true if this image uses compression
*/
public boolean hasCompression() {
return compression > -1;
}
/**
+ * Returns the compression type
+ *
* @return the compression type
*/
public int getCompression() {
@@ -107,7 +121,8 @@
}
/**
- * Sets the compression used with this image
+ * Sets the compression used with this image
+ *
* @param compression the type of compression used with this image
*/
public void setCompression(int compression) {
@@ -115,6 +130,8 @@
}
/**
+ * Returns the image data width
+ *
* @return the image data width
*/
public int getDataWidth() {
@@ -123,6 +140,7 @@
/**
* Sets the image data width
+ *
* @param imageDataWidth the image data width
*/
public void setDataWidth(int imageDataWidth) {
@@ -130,6 +148,8 @@
}
/**
+ * Returns the image data height
+ *
* @return the image data height
*/
public int getDataHeight() {
@@ -138,6 +158,7 @@
/**
* Sets the image data height
+ *
* @param imageDataHeight the image data height
*/
public void setDataHeight(int imageDataHeight) {
@@ -145,6 +166,8 @@
}
/**
+ * Returns the mime type of this image
+ *
* @return the mime type of this image
*/
public String getMimeType() {
@@ -153,6 +176,7 @@
/**
* Sets whether or not this is info about a buffered image
+ *
* @param buffered true if this is info about a buffered image
*/
public void setBuffered(boolean buffered) {
@@ -160,15 +184,15 @@
}
/**
+ * Returns true if this image info is about a buffered image
+ *
* @return true if this image info is about a buffered image
*/
public boolean isBuffered() {
return this.buffered;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
return super.toString()
+ ", mimeType=" + mimeType
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java Thu Jul 17 12:13:56 2008
@@ -19,6 +19,10 @@
package org.apache.fop.render.afp;
+/**
+ * A common class used to convey locations,
+ * dimensions and resolutions of data objects.
+ */
public class ObjectAreaInfo {
private int x;
private int y;
@@ -30,6 +34,7 @@
/**
* Sets the x position of the data object
+ *
* @param x the x position of the data object
*/
public void setX(int x) {
@@ -38,6 +43,7 @@
/**
* Sets the y position of the data object
+ *
* @param y the y position of the data object
*/
public void setY(int y) {
@@ -46,6 +52,7 @@
/**
* Sets the data object width
+ *
* @param width the width of the data object
*/
public void setWidth(int width) {
@@ -54,6 +61,7 @@
/**
* Sets the data object height
+ *
* @param height the height of the data object
*/
public void setHeight(int height) {
@@ -62,6 +70,7 @@
/**
* Sets the width resolution
+ *
* @param widthRes the width resolution
*/
public void setWidthRes(int widthRes) {
@@ -70,6 +79,7 @@
/**
* Sets the height resolution
+ *
* @param heightRes the height resolution
*/
public void setHeightRes(int heightRes) {
@@ -77,6 +87,8 @@
}
/**
+ * Returns the x coordinate of this data object
+ *
* @return the x coordinate of this data object
*/
public int getX() {
@@ -84,6 +96,8 @@
}
/**
+ * Returns the y coordinate of this data object
+ *
* @return the y coordinate of this data object
*/
public int getY() {
@@ -91,6 +105,8 @@
}
/**
+ * Returns the width of this data object
+ *
* @return the width of this data object
*/
public int getWidth() {
@@ -98,6 +114,8 @@
}
/**
+ * Returns the height of this data object
+ *
* @return the height of this data object
*/
public int getHeight() {
@@ -105,6 +123,8 @@
}
/**
+ * Returns the width resolution of this data object
+ *
* @return the width resolution of this data object
*/
public int getWidthRes() {
@@ -112,6 +132,8 @@
}
/**
+ * Returns the height resolution of this data object
+ *
* @return the height resolution of this data object
*/
public int getHeightRes() {
@@ -119,6 +141,8 @@
}
/**
+ * Returns the rotation of this data object
+ *
* @return the rotation of this data object
*/
public int getRotation() {
@@ -127,15 +151,14 @@
/**
* Sets the data object rotation
+ *
* @param rotation the data object rotation
*/
public void setRotation(int rotation) {
this.rotation = rotation;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
return "x=" + x
+ ", y=" + y
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java?rev=677689&r1=677688&r2=677689&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java Thu Jul 17 12:13:56 2008
@@ -23,19 +23,36 @@
* The level at which a resource is to reside in the AFP output
*/
public class ResourceInfo {
+ /** the uri of this resource */
+ private String uri;
- /**
- * the reference name of this resource
- */
+ /** the reference name of this resource */
private String name = null;
+ /** the resource level (default to print-file) */
+ private ResourceLevel level = new ResourceLevel(ResourceLevel.PRINT_FILE);
+
/**
- * the resource level (default to print-file)
+ * Sets the data object uri
+ *
+ * @param uri the data object uri
*/
- private ResourceLevel level = new ResourceLevel(ResourceLevel.PRINT_FILE);
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
/**
+ * Returns the uri of this data object
+ *
+ * @return the uri of this data object
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ /**
* Sets the resource reference name
+ *
* @param resourceName the resource reference name
*/
public void setName(String resourceName) {
@@ -43,6 +60,8 @@
}
/**
+ * Returns the resource reference name
+ *
* @return the resource reference name
*/
public String getName() {
@@ -50,14 +69,8 @@
}
/**
- * {@inheritDoc}
- */
- public String toString() {
- return "ResourceInfo(" + (name != null ? "name=" + name
- + ", " : "") + "level=" + level + ")";
- }
-
- /**
+ * Returns the resource level
+ *
* @return the resource level
*/
public ResourceLevel getLevel() {
@@ -66,9 +79,41 @@
/**
* Sets the resource level
+ *
* @param resourceLevel the resource level
*/
public void setLevel(ResourceLevel resourceLevel) {
this.level = resourceLevel;
}
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "ResourceInfo(uri=" + uri
+ + (name != null ? ", name=" + name : "")
+ + (level != null ? ", level=" + level : "") + ")";
+ }
+
+ /** {@inheritDoc} */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if ((obj == null) || !(obj instanceof ResourceInfo)) {
+ return false;
+ }
+
+ ResourceInfo ri = (ResourceInfo)obj;
+ return (uri == ri.uri || uri != null && uri.equals(ri.uri))
+ && (name == ri.name || name != null && name.equals(ri.name))
+ && (level == ri.level || level != null && level.equals(ri.level));
+ }
+
+ /** {@inheritDoc} */
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + (null == uri ? 0 : uri.hashCode());
+ hash = 31 * hash + (null == name ? 0 : name.hashCode());
+ hash = 31 * hash + (null == level ? 0 : level.hashCode());
+ return hash;
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org