import org.w3c.dom.Document;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.fop.afp.AFPBorderPainter;
+ import org.apache.fop.afp.AFPEventProducer;
+import org.apache.fop.afp.AFPObjectAreaInfo;
import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
import org.apache.fop.afp.AFPUnitConverter;
import org.apache.fop.afp.AbstractAFPPainter;
import org.apache.fop.afp.BorderPaintingInfo;
import org.apache.fop.afp.modca.PresentationTextObject;
import org.apache.fop.afp.ptoca.PtocaBuilder;
import org.apache.fop.afp.ptoca.PtocaProducer;
- import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
- import org.apache.fop.afp.util.ResourceAccessor;
+ import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.fonts.Font;
- import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.Typeface;
+import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.intermediate.AbstractIFPainter;
import org.apache.fop.render.intermediate.BorderPainter;
/**
* IFPainter implementation that produces AFP (MO:DCA).
*/
- public class AFPPainter extends AbstractIFPainter {
+ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> {
+
+
+
//** logging instance */
- //private static Log log = LogFactory.getLog(AFPPainter.class);
+ private static Log log = LogFactory.getLog(AFPPainter.class);
private static final int X = 0;
private static final int Y = 1;
* @param documentHandler the parent document handler
*/
public AFPPainter(AFPDocumentHandler documentHandler) {
- super();
- this.documentHandler = documentHandler;
+ super(documentHandler);
this.state = IFState.create();
+
this.borderPainter = new AFPBorderPainterAdapter(
- new AFPBorderPainter(getPaintingState(), getDataStream()));
+ new AFPBorderPainter(getPaintingState(), getDataStream()), this, documentHandler);
this.rectanglePainter = documentHandler.createRectanglePainter();
this.unitConv = getPaintingState().getUnitConverter();
+ this.eventProducer = AFPEventProducer.Provider.get(getUserAgent().getEventBroadcaster());
}
- /** {@inheritDoc} */
- @Override
- protected IFContext getContext() {
- return this.documentHandler.getContext();
- }
-
- FontInfo getFontInfo() {
- return this.documentHandler.getFontInfo();
+ private AFPPaintingState getPaintingState() {
+ return getDocumentHandler().getPaintingState();
}
- AFPPaintingState getPaintingState() {
- return this.documentHandler.getPaintingState();
+ private DataStream getDataStream() {
+ return getDocumentHandler().getDataStream();
}
- DataStream getDataStream() {
- return this.documentHandler.getDataStream();
+ @Override
+ public String getFontKey(FontTriplet triplet) throws IFException {
+ try {
+ return super.getFontKey(triplet);
+ } catch (IFException e) {
+ eventProducer.invalidConfiguration(null, e);
+ return super.getFontKey(FontTriplet.DEFAULT_FONT_TRIPLET);
+ }
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
protected RenderingContext createRenderingContext() {
- AFPRenderingContext psContext = new AFPRenderingContext(
+ AFPRenderingContext renderingContext = new AFPRenderingContext(
getUserAgent(),
- documentHandler.getResourceManager(),
+ getDocumentHandler().getResourceManager(),
getPaintingState(),
getFontInfo(),
getContext().getForeignAttributes());
if (top != null || bottom != null || left != null || right != null) {
try {
endTextObject();
- if (getPSUtil().getRenderingMode() == PSRenderingMode.SIZE
+ if (getDocumentHandler().getPSUtil().getRenderingMode() == PSRenderingMode.SIZE
&& hasOnlySolidBorders(top, bottom, left, right)) {
- super.drawBorderRect(rect, top, bottom, left, right);
+ super.drawBorderRect(rect, top, bottom, left, right, innerBackgroundColor);
} else {
- this.borderPainter.drawBorders(rect, top, bottom, left, right);
+ this.borderPainter.drawBorders(rect, top, bottom, left, right, innerBackgroundColor);
}
} catch (IOException ioe) {
throw new IFException("I/O error in drawBorderRect()", ioe);