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/05/14 14:26:20 UTC
svn commit: r656249 [1/3] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render:
./ afp/ afp/goca/ afp/modca/ afp/modca/triplets/
Author: acumiskey
Date: Wed May 14 05:26:18 2008
New Revision: 656249
URL: http://svn.apache.org/viewvc?rev=656249&view=rev
Log:
Further progress.
Added:
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/Writable.java
- copied, changed from r649456, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java
Removed:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.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/DataObjectInfo.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/AbstractPageObject.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/DataObjectAccessor.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/GraphicsDataDescriptor.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/ImageContent.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/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/MapPageOverlay.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.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/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/PresentationTextData.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/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/TagLogicalElement.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Wed May 14 05:26:18 2008
@@ -129,8 +129,7 @@
BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START);
BorderProps bpsEnd = (BorderProps)area.getTrait(Trait.BORDER_END);
- Trait.Background back;
- back = (Trait.Background)area.getTrait(Trait.BACKGROUND);
+ Trait.Background back = (Trait.Background)area.getTrait(Trait.BACKGROUND);
if (back != null) {
endTextObject();
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=656249&r1=656248&r2=656249&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 Wed May 14 05:26:18 2008
@@ -26,7 +26,6 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.RenderedImage;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -53,6 +52,7 @@
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.BlockViewport;
import org.apache.fop.area.BodyRegion;
@@ -65,9 +65,7 @@
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.WordArea;
import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
@@ -89,9 +87,7 @@
import org.apache.fop.render.afp.fonts.OutlineFont;
import org.apache.fop.render.afp.modca.AFPConstants;
import org.apache.fop.render.afp.modca.AFPDataStream;
-import org.apache.fop.render.afp.modca.AbstractNamedAFPObject;
import org.apache.fop.render.afp.modca.ImageObject;
-import org.apache.fop.render.afp.modca.IncludeObject;
import org.apache.fop.render.afp.modca.PageObject;
/**
@@ -142,11 +138,11 @@
* handle all types of inline area, text, image etc and draws various lines and
* rectangles.
* </p>
- *
- * Note: There are specific extensions that have been added to the
- * FO. They are specific to their location within the FO and have to be
- * processed accordingly (ie. at the start or end of the page).
- *
+ *
+ * Note: There are specific extensions that have been added to the FO. They are
+ * specific to their location within the FO and have to be processed accordingly
+ * (ie. at the start or end of the page).
+ *
*/
public class AFPRenderer extends AbstractPathOrientedRenderer {
@@ -173,12 +169,12 @@
/**
* The map of page segments
*/
- private Map pageSegmentsMap = null;
+ private Map/*<String, String>*/pageSegmentsMap = null;
/**
* The fonts on the current page
*/
- private Map currentPageFonts = null;
+ private Map/*<String, AFPFontAttributes<*/currentPageFontMap = null;
/**
* The current color object
@@ -277,57 +273,63 @@
/**
* Set up the font info
- *
- * @param inFontInfo font info to set up
+ *
+ * @param inFontInfo
+ * font info to set up
*/
public void setupFontInfo(FontInfo inFontInfo) {
this.fontInfo = inFontInfo;
int num = 1;
- if (super.embedFontInfoList != null && super.embedFontInfoList.size() > 0) {
+ if (super.embedFontInfoList != null
+ && super.embedFontInfoList.size() > 0) {
for (Iterator it = super.embedFontInfoList.iterator(); it.hasNext();) {
- AFPFontInfo afi = (AFPFontInfo)it.next();
- AFPFont bf = (AFPFont)afi.getAFPFont();
- for (Iterator it2 = afi.getFontTriplets().iterator(); it2.hasNext();) {
- FontTriplet ft = (FontTriplet)it2.next();
- this.fontInfo.addFontProperties("F" + num, ft.getName()
- , ft.getStyle(), ft.getWeight());
+ AFPFontInfo afi = (AFPFontInfo) it.next();
+ AFPFont bf = (AFPFont) afi.getAFPFont();
+ for (Iterator it2 = afi.getFontTriplets().iterator(); it2
+ .hasNext();) {
+ FontTriplet ft = (FontTriplet) it2.next();
+ this.fontInfo.addFontProperties("F" + num, ft.getName(), ft
+ .getStyle(), ft.getWeight());
this.fontInfo.addMetrics("F" + num, bf);
num++;
}
}
} else {
- AFPEventProducer eventProducer = AFPEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
+ AFPEventProducer eventProducer = AFPEventProducer.Provider
+ .get(getUserAgent().getEventBroadcaster());
eventProducer.warnDefaultFontSetup(this);
}
if (this.fontInfo.fontLookup("sans-serif", "normal", 400) == null) {
- CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500", "CZH200 ",
- 1, new Helvetica());
+ CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500",
+ "CZH200 ", 1, new Helvetica());
AFPFont bf = new OutlineFont("Helvetica", cs);
- this.fontInfo.addFontProperties("F" + num, "sans-serif", "normal", 400);
+ this.fontInfo.addFontProperties("F" + num, "sans-serif", "normal",
+ 400);
this.fontInfo.addMetrics("F" + num, bf);
num++;
}
if (this.fontInfo.fontLookup("serif", "normal", 400) == null) {
- CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500", "CZN200 ",
- 1, new TimesRoman());
+ CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500",
+ "CZN200 ", 1, new TimesRoman());
AFPFont bf = new OutlineFont("Helvetica", cs);
this.fontInfo.addFontProperties("F" + num, "serif", "normal", 400);
this.fontInfo.addMetrics("F" + num, bf);
num++;
}
if (this.fontInfo.fontLookup("monospace", "normal", 400) == null) {
- CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500", "CZ4200 ",
- 1, new Courier());
+ CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500",
+ "CZ4200 ", 1, new Courier());
AFPFont bf = new OutlineFont("Helvetica", cs);
- this.fontInfo.addFontProperties("F" + num, "monospace", "normal", 400);
+ this.fontInfo.addFontProperties("F" + num, "monospace", "normal",
+ 400);
this.fontInfo.addMetrics("F" + num, bf);
num++;
}
if (this.fontInfo.fontLookup("any", "normal", 400) == null) {
- FontTriplet ft = this.fontInfo.fontLookup("sans-serif", "normal", 400);
- this.fontInfo.addFontProperties(
- this.fontInfo.getInternalFontKey(ft), "any", "normal", 400);
+ FontTriplet ft = this.fontInfo.fontLookup("sans-serif", "normal",
+ 400);
+ this.fontInfo.addFontProperties(this.fontInfo
+ .getInternalFontKey(ft), "any", "normal", 400);
}
}
@@ -338,16 +340,24 @@
super.setUserAgent(agent);
}
+ private Map/* <String, AFPFontAttributes */getCurrentPageFonts() {
+ if (currentPageFontMap == null) {
+ this.currentPageFontMap = new java.util.HashMap/*
+ * <String,
+ * AFPFontAttributes
+ */();
+ }
+ return this.currentPageFontMap;
+ }
+
/**
* {@inheritDoc}
*/
public void startRenderer(OutputStream outputStream) throws IOException {
- currentPageFonts = new java.util.HashMap();
- currentColor = new Color(255, 255, 255);
- this.afpDataStream = new AFPDataStream();
- afpDataStream.setPortraitRotation(portraitRotation);
- afpDataStream.setLandscapeRotation(landscapeRotation);
- afpDataStream.setOutputStream(outputStream);
+ this.currentColor = new Color(255, 255, 255);
+ getAFPDataStream().setPortraitRotation(portraitRotation);
+ getAFPDataStream().setLandscapeRotation(landscapeRotation);
+ getAFPDataStream().setOutputStream(outputStream);
}
/**
@@ -361,18 +371,26 @@
/**
* {@inheritDoc}
*/
+ public void startPageSequence(LineArea seqTitle) {
+ getAFPDataStream().endPageGroup();
+ getAFPDataStream().startPageGroup();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean supportsOutOfOrder() {
- //return false;
+ // return false;
return true;
}
/**
- * Prepare a page for rendering. This is called if the renderer supports
- * out of order rendering. The renderer should prepare the page so that a
- * page further on in the set of pages can be rendered. The body of the
- * page should not be rendered. The page will be rendered at a later time
- * by the call to render page.
- *
+ * Prepare a page for rendering. This is called if the renderer supports out
+ * of order rendering. The renderer should prepare the page so that a page
+ * further on in the set of pages can be rendered. The body of the page
+ * should not be rendered. The page will be rendered at a later time by the
+ * call to render page.
+ *
* {@inheritDoc}
*/
public void preparePage(PageViewport page) {
@@ -381,7 +399,7 @@
// this.currentFontFamily = "";
this.currentFontSize = 0;
this.pageFontCounter = 0;
- this.currentPageFonts.clear();
+ this.currentPageFontMap = null;
// this.lineCache = new HashSet();
Rectangle2D bounds = page.getViewArea();
@@ -431,12 +449,15 @@
}
/**
- * Renders a region viewport. <p>
- *
- * The region may clip the area and it establishes a position from where
- * the region is placed.</p>
- *
- * @param port The region viewport to be rendered
+ * Renders a region viewport.
+ * <p>
+ *
+ * The region may clip the area and it establishes a position from where the
+ * region is placed.
+ * </p>
+ *
+ * @param port
+ * The region viewport to be rendered
*/
public void renderRegionViewport(RegionViewport port) {
if (port != null) {
@@ -451,11 +472,10 @@
handleRegionTraits(port);
/*
- _afpDataStream.startOverlay(mpts2units(view.getX())
- , mpts2units(view.getY())
- , mpts2units(view.getWidth())
- , mpts2units(view.getHeight())
- , rotation);
+ * _afpDataStream.startOverlay(mpts2units(view.getX()) ,
+ * mpts2units(view.getY()) , mpts2units(view.getWidth()) ,
+ * mpts2units(view.getHeight())
+ * , rotation);
*/
pushViewPortPos(new ViewPortPos(view, regionReference.getCTM()));
@@ -466,7 +486,7 @@
renderRegion(regionReference);
}
/*
- _afpDataStream.endOverlay();
+ * _afpDataStream.endOverlay();
*/
popViewPortPos();
}
@@ -475,6 +495,41 @@
/**
* {@inheritDoc}
*/
+ // TODO - AC fix
+ protected void drawBackAndBorders(Area area, float startx, float starty,
+ float width, float height) {
+ super.drawBackAndBorders(area, startx, starty, width, height);
+ Trait.Background back = (Trait.Background) area
+ .getTrait(Trait.BACKGROUND);
+
+ // the current block has a background so its contents are placed inside
+ // an overlay
+ // after drawing the background and borders
+ if (back != null) {
+ int x = pts2units(startx);
+ int y = pts2units(starty);
+ int w = mpts2units(width);
+ int h = mpts2units(height);
+ int res = getResolution();
+ final int rotation = 0;
+ getAFPDataStream().startOverlay(x, y, w, h, res, res, rotation);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void renderBlock(Block block) {
+ // new block so start page segment
+ getAFPDataStream().startPageSegment();
+ super.renderBlock(block);
+ getAFPDataStream().endOverlay();
+ getAFPDataStream().endPageSegment();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
protected void renderBlockViewport(BlockViewport bv, List children) {
// clip and position viewport if necessary
@@ -485,16 +540,17 @@
CTM ctm = bv.getCTM();
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
- //This is the content-rect
- float width = (float)bv.getIPD() / 1000f;
- float height = (float)bv.getBPD() / 1000f;
+ // This is the content-rect
+ float width = (float) bv.getIPD() / 1000f;
+ float height = (float) bv.getBPD() / 1000f;
if (bv.getPositioning() == Block.ABSOLUTE
|| bv.getPositioning() == Block.FIXED) {
- //For FIXED, we need to break out of the current viewports to the
- //one established by the page. We save the state stack for restoration
- //after the block-container has been painted. See below.
+ // For FIXED, we need to break out of the current viewports to the
+ // one established by the page. We save the state stack for
+ // restoration
+ // after the block-container has been painted. See below.
List breakOutList = null;
if (bv.getPositioning() == Block.FIXED) {
breakOutList = breakOutOfStateStack();
@@ -503,45 +559,55 @@
AffineTransform positionTransform = new AffineTransform();
positionTransform.translate(bv.getXOffset(), bv.getYOffset());
- //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
- positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
-
- //skipping fox:transform here
-
- //saveGraphicsState();
- //Viewport position
- //concatenateTransformationMatrix(mptToPt(positionTransform));
-
- //Background and borders
- float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
- float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
+ // "left/"top" (bv.getX/YOffset()) specify the position of the
+ // content rectangle
+ positionTransform.translate(-borderPaddingStart,
+ -borderPaddingBefore);
+
+ // skipping fox:transform here
+
+ // saveGraphicsState();
+ // Viewport position
+ // concatenateTransformationMatrix(mptToPt(positionTransform));
+
+ // Background and borders
+ float bpwidth = (borderPaddingStart + bv
+ .getBorderAndPaddingWidthEnd()) / 1000f;
+ float bpheight = (borderPaddingBefore + bv
+ .getBorderAndPaddingWidthAfter()) / 1000f;
Point2D ptSrc = new Point(0, 0);
Point2D ptDst = positionTransform.transform(ptSrc, null);
- Rectangle2D borderRect = new Rectangle2D.Double(ptDst.getX(), ptDst.getY(),
- 1000 * (width + bpwidth), 1000 * (height + bpheight));
- pushViewPortPos(new ViewPortPos(borderRect, new CTM(positionTransform)));
+ Rectangle2D borderRect = new Rectangle2D.Double(ptDst.getX(), ptDst
+ .getY(), 1000 * (width + bpwidth),
+ 1000 * (height + bpheight));
+ pushViewPortPos(new ViewPortPos(borderRect, new CTM(
+ positionTransform)));
drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight);
- //Shift to content rectangle after border painting
+ // Shift to content rectangle after border painting
AffineTransform contentRectTransform = new AffineTransform();
- contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
- //concatenateTransformationMatrix(mptToPt(contentRectTransform));
+ contentRectTransform.translate(borderPaddingStart,
+ borderPaddingBefore);
+ // concatenateTransformationMatrix(mptToPt(contentRectTransform));
ptSrc = new Point(0, 0);
ptDst = contentRectTransform.transform(ptSrc, null);
- Rectangle2D contentRect = new Rectangle2D.Double(ptDst.getX(), ptDst.getY(),
- 1000 * width, 1000 * height);
- pushViewPortPos(new ViewPortPos(contentRect, new CTM(contentRectTransform)));
-
- //Clipping is not supported, yet
- //Rectangle2D clippingRect = null;
- //clippingRect = new Rectangle(0, 0, bv.getIPD(), bv.getBPD());
+ Rectangle2D contentRect = new Rectangle2D.Double(ptDst.getX(),
+ ptDst.getY(), 1000 * width, 1000 * height);
+ pushViewPortPos(new ViewPortPos(contentRect, new CTM(
+ contentRectTransform)));
+
+ // Clipping is not supported, yet
+ // Rectangle2D clippingRect = null;
+ // clippingRect = new Rectangle(0, 0, bv.getIPD(), bv.getBPD());
- //saveGraphicsState();
- //Set up coordinate system for content rectangle
+ // saveGraphicsState();
+ // Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
- //concatenateTransformationMatrix(mptToPt(contentTransform));
- contentRect = new Rectangle2D.Double(0, 0, 1000 * width, 1000 * height);
- pushViewPortPos(new ViewPortPos(contentRect, new CTM(contentTransform)));
+ // concatenateTransformationMatrix(mptToPt(contentTransform));
+ contentRect = new Rectangle2D.Double(0, 0, 1000 * width,
+ 1000 * height);
+ pushViewPortPos(new ViewPortPos(contentRect, new CTM(
+ contentTransform)));
currentIPPosition = 0;
currentBPPosition = 0;
@@ -549,9 +615,9 @@
popViewPortPos();
popViewPortPos();
- //restoreGraphicsState();
+ // restoreGraphicsState();
popViewPortPos();
- //restoreGraphicsState();
+ // restoreGraphicsState();
if (breakOutList != null) {
restoreStateStackAfterBreakOut(breakOutList);
@@ -563,41 +629,42 @@
currentBPPosition += bv.getSpaceBefore();
- //borders and background in the old coordinate system
+ // borders and background in the old coordinate system
handleBlockTraits(bv);
- //Advance to start of content area
+ // Advance to start of content area
currentIPPosition += bv.getStartIndent();
CTM tempctm = new CTM(containingIPPosition, currentBPPosition);
ctm = tempctm.multiply(ctm);
- //Now adjust for border/padding
+ // Now adjust for border/padding
currentBPPosition += borderPaddingBefore;
Rectangle2D clippingRect = null;
clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
bv.getIPD(), bv.getBPD());
- //startVParea(ctm, clippingRect);
+ // startVParea(ctm, clippingRect);
pushViewPortPos(new ViewPortPos(clippingRect, ctm));
currentIPPosition = 0;
currentBPPosition = 0;
renderBlocks(bv, children);
- //endVParea();
+ // endVParea();
popViewPortPos();
currentIPPosition = saveIP;
currentBPPosition = saveBP;
- currentBPPosition += (int)(bv.getAllocBPD());
+ currentBPPosition += (int) (bv.getAllocBPD());
}
}
/** {@inheritDoc} */
protected void concatenateTransformationMatrix(AffineTransform at) {
- //Not used here since AFPRenderer defines its own renderBlockViewport() method.
+ // Not used here since AFPRenderer defines its own renderBlockViewport()
+ // method.
throw new UnsupportedOperationException("NYI");
}
@@ -611,7 +678,7 @@
// this.currentFontFamily = "";
this.currentFontSize = 0;
this.pageFontCounter = 0;
- this.currentPageFonts.clear();
+ this.currentPageFontMap = null;
// this.lineCache = new HashSet();
Rectangle2D bounds = pageViewport.getViewArea();
@@ -621,7 +688,8 @@
if (pages != null && pages.containsKey(pageViewport)) {
- getAFPDataStream().restorePage((PageObject) pages.remove(pageViewport));
+ getAFPDataStream().restorePage(
+ (PageObject) pages.remove(pageViewport));
} else {
// renderPageGroupExtensions(page);
@@ -638,19 +706,21 @@
renderPageAreas(pageViewport.getPage());
- Iterator i = currentPageFonts.values().iterator();
- while (i.hasNext()) {
- AFPFontAttributes afpFontAttributes = (AFPFontAttributes) i.next();
-
- getAFPDataStream().createFont(
- (byte)afpFontAttributes.getFontReference(),
- afpFontAttributes.getFont(),
- afpFontAttributes.getPointSize());
-
+ if (currentPageFontMap != null) {
+ Iterator iter = currentPageFontMap.values().iterator();
+ while (iter.hasNext()) {
+ AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter
+ .next();
+
+ getAFPDataStream().createFont(
+ (byte) afpFontAttributes.getFontReference(),
+ afpFontAttributes.getFont(),
+ afpFontAttributes.getPointSize());
+ }
}
getAFPDataStream().endPage();
-
+
popViewPortPos();
}
@@ -694,22 +764,12 @@
*/
public void fillRect(float x, float y, float width, float height) {
/*
- afpDataStream.createShading(
- pts2units(x),
- pts2units(y),
- pts2units(width),
- pts2units(height),
- currentColor.getRed(),
- currentColor.getGreen(),
- currentColor.getBlue());
+ * getAFPDataStream().createShading( pts2units(x), pts2units(y),
+ * pts2units(width), pts2units(height), currentColor);
*/
- getAFPDataStream().createLine(
- pts2units(x),
- pts2units(y),
- pts2units(x + width),
- pts2units(y),
- pts2units(height),
- currentColor);
+ getAFPDataStream().createLine(pts2units(x), pts2units(y),
+ pts2units(x + width), pts2units(y), pts2units(height),
+ currentColor);
}
/**
@@ -723,197 +783,118 @@
log.error("Negative extent received. Border won't be painted.");
return;
}
-
+
switch (style) {
- case Constants.EN_DOUBLE:
- if (horz) {
- float h3 = h / 3;
- float ym1 = y1;
- float ym2 = ym1 + h3 + h3;
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(ym1),
- pts2units(x2),
- pts2units(ym1),
- pts2units(h3),
- col
- );
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(ym2),
- pts2units(x2),
- pts2units(ym2),
- pts2units(h3),
- col
- );
- } else {
- float w3 = w / 3;
- float xm1 = x1;
- float xm2 = xm1 + w3 + w3;
- afpDataStream.createLine(
- pts2units(xm1),
- pts2units(y1),
- pts2units(xm1),
- pts2units(y2),
- pts2units(w3),
- col
- );
- afpDataStream.createLine(
- pts2units(xm2),
- pts2units(y1),
- pts2units(xm2),
- pts2units(y2),
- pts2units(w3),
- col
- );
+ case Constants.EN_DOUBLE:
+ if (horz) {
+ float h3 = h / 3;
+ float ym1 = y1;
+ float ym2 = ym1 + h3 + h3;
+ getAFPDataStream().createLine(pts2units(x1), pts2units(ym1),
+ pts2units(x2), pts2units(ym1), pts2units(h3), col);
+ getAFPDataStream().createLine(pts2units(x1), pts2units(ym2),
+ pts2units(x2), pts2units(ym2), pts2units(h3), col);
+ } else {
+ float w3 = w / 3;
+ float xm1 = x1;
+ float xm2 = xm1 + w3 + w3;
+ getAFPDataStream().createLine(pts2units(xm1), pts2units(y1),
+ pts2units(xm1), pts2units(y2), pts2units(w3), col);
+ getAFPDataStream().createLine(pts2units(xm2), pts2units(y1),
+ pts2units(xm2), pts2units(y2), pts2units(w3), col);
+ }
+ break;
+ case Constants.EN_DASHED:
+ if (horz) {
+ float w2 = 2 * h;
+ while (x1 + w2 < x2) {
+ getAFPDataStream().createLine(pts2units(x1), pts2units(y1),
+ pts2units(x1 + w2), pts2units(y1), pts2units(h),
+ col);
+ x1 += 2 * w2;
}
- break;
- case Constants.EN_DASHED:
- if (horz) {
- float w2 = 2 * h;
- while (x1 + w2 < x2) {
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(y1),
- pts2units(x1 + w2),
- pts2units(y1),
- pts2units(h),
- col
- );
- x1 += 2 * w2;
- }
- } else {
- float h2 = 2 * w;
- while (y1 + h2 < y2) {
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(y1),
- pts2units(x1),
- pts2units(y1 + h2),
- pts2units(w),
- col
- );
- y1 += 2 * h2;
- }
+ } else {
+ float h2 = 2 * w;
+ while (y1 + h2 < y2) {
+ getAFPDataStream().createLine(pts2units(x1), pts2units(y1),
+ pts2units(x1), pts2units(y1 + h2), pts2units(w),
+ col);
+ y1 += 2 * h2;
}
- break;
- case Constants.EN_DOTTED:
- if (horz) {
- while (x1 + h < x2) {
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(y1),
- pts2units(x1 + h),
- pts2units(y1),
- pts2units(h),
- col
- );
- x1 += 2 * h;
- }
- } else {
- while (y1 + w < y2) {
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(y1),
- pts2units(x1),
- pts2units(y1 + w),
- pts2units(w),
- col
- );
- y1 += 2 * w;
- }
+ }
+ break;
+ case Constants.EN_DOTTED:
+ if (horz) {
+ while (x1 + h < x2) {
+ getAFPDataStream()
+ .createLine(pts2units(x1), pts2units(y1),
+ pts2units(x1 + h), pts2units(y1),
+ pts2units(h), col);
+ x1 += 2 * h;
}
- break;
- case Constants.EN_GROOVE:
- case Constants.EN_RIDGE:
- {
- float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
- if (horz) {
- Color uppercol = lightenColor(col, -colFactor);
- Color lowercol = lightenColor(col, colFactor);
- float h3 = h / 3;
- float ym1 = y1;
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(ym1),
- pts2units(x2),
- pts2units(ym1),
- pts2units(h3),
- uppercol
- );
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(ym1 + h3),
- pts2units(x2),
- pts2units(ym1 + h3),
- pts2units(h3),
- col
- );
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(ym1 + h3 + h3),
- pts2units(x2),
- pts2units(ym1 + h3 + h3),
- pts2units(h3),
- lowercol
- );
- } else {
- Color leftcol = lightenColor(col, -colFactor);
- Color rightcol = lightenColor(col, colFactor);
- float w3 = w / 3;
- float xm1 = x1 + (w3 / 2);
- afpDataStream.createLine(
- pts2units(xm1),
- pts2units(y1),
- pts2units(xm1),
- pts2units(y2),
- pts2units(w3),
- leftcol
- );
- afpDataStream.createLine(
- pts2units(xm1 + w3),
- pts2units(y1),
- pts2units(xm1 + w3),
- pts2units(y2),
- pts2units(w3),
- col
- );
- afpDataStream.createLine(
- pts2units(xm1 + w3 + w3),
- pts2units(y1),
- pts2units(xm1 + w3 + w3),
- pts2units(y2),
- pts2units(w3),
- rightcol
- );
+ } else {
+ while (y1 + w < y2) {
+ getAFPDataStream()
+ .createLine(pts2units(x1), pts2units(y1),
+ pts2units(x1), pts2units(y1 + w),
+ pts2units(w), col);
+ y1 += 2 * w;
}
- break;
}
- case Constants.EN_HIDDEN:
- break;
- case Constants.EN_INSET:
- case Constants.EN_OUTSET:
- default:
- afpDataStream.createLine(
- pts2units(x1),
- pts2units(y1),
- pts2units(horz ? x2 : x1),
- pts2units(horz ? y1 : y2),
- pts2units(Math.abs(horz ? (y2 - y1) : (x2 - x1))),
- col
- );
+ break;
+ case Constants.EN_GROOVE:
+ case Constants.EN_RIDGE: {
+ float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
+ if (horz) {
+ Color uppercol = lightenColor(col, -colFactor);
+ Color lowercol = lightenColor(col, colFactor);
+ float h3 = h / 3;
+ float ym1 = y1;
+ getAFPDataStream().createLine(pts2units(x1), pts2units(ym1),
+ pts2units(x2), pts2units(ym1), pts2units(h3), uppercol);
+ getAFPDataStream().createLine(pts2units(x1),
+ pts2units(ym1 + h3), pts2units(x2),
+ pts2units(ym1 + h3), pts2units(h3), col);
+ getAFPDataStream().createLine(pts2units(x1),
+ pts2units(ym1 + h3 + h3), pts2units(x2),
+ pts2units(ym1 + h3 + h3), pts2units(h3), lowercol);
+ } else {
+ Color leftcol = lightenColor(col, -colFactor);
+ Color rightcol = lightenColor(col, colFactor);
+ float w3 = w / 3;
+ float xm1 = x1 + (w3 / 2);
+ getAFPDataStream().createLine(pts2units(xm1), pts2units(y1),
+ pts2units(xm1), pts2units(y2), pts2units(w3), leftcol);
+ getAFPDataStream().createLine(pts2units(xm1 + w3),
+ pts2units(y1), pts2units(xm1 + w3), pts2units(y2),
+ pts2units(w3), col);
+ getAFPDataStream().createLine(pts2units(xm1 + w3 + w3),
+ pts2units(y1), pts2units(xm1 + w3 + w3), pts2units(y2),
+ pts2units(w3), rightcol);
+ }
+ break;
+ }
+ case Constants.EN_HIDDEN:
+ break;
+ case Constants.EN_INSET:
+ case Constants.EN_OUTSET:
+ default:
+ getAFPDataStream().createLine(pts2units(x1), pts2units(y1),
+ pts2units(horz ? x2 : x1), pts2units(horz ? y1 : y2),
+ pts2units(Math.abs(horz ? (y2 - y1) : (x2 - x1))), col);
}
}
/**
* {@inheritDoc}
*/
- protected RendererContext createRendererContext(int x, int y, int width, int height,
- Map foreignAttributes) {
+ protected RendererContext createRendererContext(int x, int y, int width,
+ int height, Map foreignAttributes) {
RendererContext context;
- context = super.createRendererContext(x, y, width, height, foreignAttributes);
- context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
- Boolean.valueOf(!this.colorImages));
+ context = super.createRendererContext(x, y, width, height,
+ foreignAttributes);
+ context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean
+ .valueOf(!this.colorImages));
context.setProperty(AFPRendererContextConstants.AFP_FONT_INFO,
this.fontInfo);
context.setProperty(AFPRendererContextConstants.AFP_RESOLUTION,
@@ -922,67 +903,61 @@
new Integer(this.bitsPerPixel));
context.setProperty(AFPRendererContextConstants.AFP_DATASTREAM,
getAFPDataStream());
- context.setProperty(AFPRendererContextConstants.AFP_STATE,
- getState());
+ context.setProperty(AFPRendererContextConstants.AFP_STATE, getState());
return context;
}
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[]
- {ImageFlavor.RAW_CCITTFAX,
- ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE,
- ImageFlavor.XML_DOM};
+ private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
+ ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D,
+ ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE,
+ ImageFlavor.XML_DOM };
-
/** {@inheritDoc} */
public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
uri = URISpecification.getURL(uri);
- Rectangle posInt = new Rectangle(
- (int)pos.getX(),
- (int)pos.getY(),
- (int)pos.getWidth(),
- (int)pos.getHeight());
+ Rectangle posInt = new Rectangle((int) pos.getX(), (int) pos.getY(),
+ (int) pos.getWidth(), (int) pos.getHeight());
Point origin = new Point(currentIPPosition, currentBPPosition);
int x = origin.x + posInt.x;
int y = origin.y + posInt.y;
- String name = (String)getPageSegments().get(uri);
+ String name = (String) getPageSegments().get(uri);
if (name != null) {
- getAFPDataStream().createIncludePageSegment(name, mpts2units(x), mpts2units(y));
+ getAFPDataStream().createIncludePageSegment(name, mpts2units(x),
+ mpts2units(y));
} else {
- ImageManager manager = getUserAgent().getFactory().getImageManager();
+ ImageManager manager = getUserAgent().getFactory()
+ .getImageManager();
ImageInfo info = null;
InputStream in = null;
try {
- ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
+ ImageSessionContext sessionContext = getUserAgent()
+ .getImageSessionContext();
info = manager.getImageInfo(uri, sessionContext);
- //Only now fully load/prepare the image
+ // Only now fully load/prepare the image
Map hints = ImageUtil.getDefaultHints(sessionContext);
- org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, FLAVORS, hints, sessionContext);
+ org.apache.xmlgraphics.image.loader.Image img = manager
+ .getImage(info, FLAVORS, hints, sessionContext);
- //...and process the image
+ // ...and process the image
if (img instanceof ImageGraphics2D) {
- ImageGraphics2D imageG2D = (ImageGraphics2D)img;
- RendererContext context = createRendererContext(
- posInt.x, posInt.y,
- posInt.width, posInt.height, foreignAttributes);
- getGraphics2DAdapter().paintImage(imageG2D.getGraphics2DImagePainter(),
- context,
+ ImageGraphics2D imageG2D = (ImageGraphics2D) img;
+ RendererContext context = createRendererContext(posInt.x,
+ posInt.y, posInt.width, posInt.height,
+ foreignAttributes);
+ getGraphics2DAdapter().paintImage(
+ imageG2D.getGraphics2DImagePainter(), context,
origin.x + posInt.x, origin.y + posInt.y,
posInt.width, posInt.height);
} else if (img instanceof ImageRendered) {
- ImageRendered imgRend = (ImageRendered)img;
+ ImageRendered imgRend = (ImageRendered) img;
RenderedImage ri = imgRend.getRenderedImage();
- drawBufferedImage(info, ri, getResolution(),
- posInt.x + currentIPPosition,
- posInt.y + currentBPPosition,
- posInt.width,
- posInt.height, foreignAttributes);
+ drawBufferedImage(info, ri, getResolution(), posInt.x
+ + currentIPPosition, posInt.y + currentBPPosition,
+ posInt.width, posInt.height, foreignAttributes);
} else if (img instanceof ImageRawCCITTFax) {
- ImageRawCCITTFax ccitt = (ImageRawCCITTFax)img;
+ ImageRawCCITTFax ccitt = (ImageRawCCITTFax) img;
in = ccitt.createInputStream();
byte[] buf = IOUtils.toByteArray(in);
int afpx = mpts2units(posInt.x + currentIPPosition);
@@ -990,7 +965,7 @@
int afpw = mpts2units(posInt.getWidth());
int afph = mpts2units(posInt.getHeight());
int afpres = getResolution();
-
+
// create image object parameters
ImageObjectInfo imageObjectInfo = new ImageObjectInfo();
imageObjectInfo.setUri(uri);
@@ -1002,179 +977,44 @@
imageObjectInfo.setWidthRes(afpres);
imageObjectInfo.setHeightRes(afpres);
imageObjectInfo.setData(buf);
- imageObjectInfo.setDataHeight(ccitt.getSize().getHeightPx());
+ imageObjectInfo
+ .setDataHeight(ccitt.getSize().getHeightPx());
imageObjectInfo.setDataWidth(ccitt.getSize().getWidthPx());
imageObjectInfo.setColor(colorImages);
imageObjectInfo.setBitsPerPixel(bitsPerPixel);
imageObjectInfo.setCompression(ccitt.getCompression());
- imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
-
+ imageObjectInfo
+ .setResourceInfoFromForeignAttributes(foreignAttributes);
getAFPDataStream().createObject(imageObjectInfo);
-
-
-// ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw, afph,
-// afpres, afpres);
-// io.setImageParameters(
-// (int) (ccitt.getSize().getDpiHorizontal() * 10),
-// (int) (ccitt.getSize().getDpiVertical() * 10),
-// ccitt.getSize().getWidthPx(),
-// ccitt.getSize().getHeightPx());
-// int compression = ccitt.getCompression();
-// switch (compression) {
-// case TIFFImage.COMP_FAX_G3_1D :
-// io.setImageEncoding((byte) 0x80);
-// break;
-// case TIFFImage.COMP_FAX_G3_2D :
-// io.setImageEncoding((byte) 0x81);
-// break;
-// case TIFFImage.COMP_FAX_G4_2D :
-// io.setImageEncoding((byte) 0x82);
-// break;
-// default:
-// throw new IllegalStateException(
-// "Invalid compression scheme: " + compression);
-// }
-// InputStream in = ccitt.createInputStream();
-// try {
-// byte[] buf = IOUtils.toByteArray(in);
-// io.setImageData(buf);
-// } finally {
-// IOUtils.closeQuietly(in);
-// }
} else if (img instanceof ImageXMLDOM) {
- ImageXMLDOM imgXML = (ImageXMLDOM)img;
- renderDocument(imgXML.getDocument(), imgXML.getRootNamespace(),
- pos, foreignAttributes);
+ ImageXMLDOM imgXML = (ImageXMLDOM) img;
+ renderDocument(imgXML.getDocument(), imgXML
+ .getRootNamespace(), pos, foreignAttributes);
} else {
- throw new UnsupportedOperationException("Unsupported image type: " + img);
+ throw new UnsupportedOperationException(
+ "Unsupported image type: " + img);
}
} catch (ImageException ie) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider
+ .get(getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, (info != null ? info.toString()
+ : uri), ie, null);
} catch (FileNotFoundException fe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider
+ .get(getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(this, (info != null ? info
+ .toString() : uri), fe, null);
} catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider
+ .get(getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info
+ .toString() : uri), ioe, null);
} finally {
if (in != null) {
IOUtils.closeQuietly(in);
}
}
-
- /*
- ImageFactory fact = userAgent.getFactory().getImageFactory();
- FopImage fopimage = fact.getImage(url, userAgent);
- if (fopimage == null) {
- return;
- }
- if (!fopimage.load(FopImage.DIMENSIONS)) {
- return;
- }
- String mime = fopimage.getMimeType();
- if ("text/xml".equals(mime) || MimeConstants.MIME_SVG.equals(mime)) {
- if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
- return;
- }
- Document doc = ((XMLImage) fopimage).getDocument();
- String ns = ((XMLImage) fopimage).getNameSpace();
-
- renderDocument(doc, ns, pos, foreignAttributes);
- } else if (MimeConstants.MIME_EPS.equals(mime)) {
- log.warn("EPS images are not supported by this renderer");
- */
- /*
- * } else if (MimeConstants.MIME_JPEG.equals(mime)) { if
- * (!fopimage.load(FopImage.ORIGINAL_DATA)) { return; }
- * fact.releaseImage(url, userAgent);
- *
- * int x = mpts2units(pos.getX() + currentIPPosition); int y =
- * mpts2units(pos.getY() + currentBPPosition); int w =
- * mpts2units(pos.getWidth()); int h =
- * mpts2units(pos.getHeight()); ImageObject io =
- * _afpDataStream.getImageObject(); io.setImageViewport(x, y, w,
- * h); io.setImageParameters(
- * (int)(fopimage.getHorizontalResolution() * 10),
- * (int)(fopimage.getVerticalResolution() * 10),
- * fopimage.getWidth(), fopimage.getHeight() );
- * io.setImageIDESize((byte)fopimage.getBitsPerPixel());
- * io.setImageEncoding((byte)0x83);
- * io.setImageData(fopimage.getRessourceBytes());
- *//*
- } else if (MimeConstants.MIME_TIFF.equals(mime)
- && fopimage instanceof TIFFImage) {
- TIFFImage tiffImage = (TIFFImage) fopimage;
- int x = mpts2units(pos.getX() + currentIPPosition);
- int y = mpts2units(pos.getY() + currentBPPosition);
- int w = mpts2units(pos.getWidth());
- int h = mpts2units(pos.getHeight());
- ImageObject io = afpDataStream.getImageObject(x, y, w, h,
- getResolution(), getResolution());
- io.setImageParameters(
- (int)(fopimage.getHorizontalResolution() * 10),
- (int)(fopimage.getVerticalResolution() * 10),
- fopimage.getWidth(),
- fopimage.getHeight()
- );
- if (tiffImage.getStripCount() == 1) {
- int comp = tiffImage.getCompression();
- if (comp == 3) {
- if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
- return;
- }
- io.setImageEncoding((byte)0x81);
- io.setImageData(fopimage.getRessourceBytes());
- } else if (comp == 4) {
- if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
- return;
- }
- io.setImageEncoding((byte)0x82);
- io.setImageData(fopimage.getRessourceBytes());
- } else {
- if (!fopimage.load(FopImage.BITMAP)) {
- return;
- }
- convertToGrayScaleImage(io, fopimage.getBitmaps(),
- fopimage.getWidth(), fopimage.getHeight());
- }
- } else {
- if (!fopimage.load(FopImage.BITMAP)) {
- return;
- }
- convertToGrayScaleImage(io, fopimage.getBitmaps(),
- fopimage.getWidth(), fopimage.getHeight());
- }
- } else {
- if (!fopimage.load(FopImage.BITMAP)) {
- return;
- }
- fact.releaseImage(url, userAgent);
-
- int x = mpts2units(pos.getX() + currentIPPosition);
- int y = mpts2units(pos.getY() + currentBPPosition);
- int w = mpts2units(pos.getWidth());
- int h = mpts2units(pos.getHeight());
- ImageObject io = afpDataStream.getImageObject(x, y, w, h,
- getResolution(), getResolution());
- io.setImageParameters(
- (int)(fopimage.getHorizontalResolution() * 10),
- (int)(fopimage.getVerticalResolution() * 10),
- fopimage.getWidth(),
- fopimage.getHeight()
- );
- if (colorImages) {
- io.setImageIDESize((byte)24);
- io.setImageData(fopimage.getBitmaps());
- } else {
- convertToGrayScaleImage(io, fopimage.getBitmaps(),
- fopimage.getWidth(), fopimage.getHeight());
- }
- }*/
}
}
@@ -1186,9 +1026,9 @@
* @param out
* the OutputStream
* @throws IOException
- * In case of an I/O error.
- * @deprecated
- * use ImageEncodingHelper.encodeRenderedImageAsRGB(image, out) directly instead
+ * In case of an I/O error.
+ * @deprecated use ImageEncodingHelper.encodeRenderedImageAsRGB(image, out)
+ * directly instead
*/
public static void writeImage(RenderedImage image, OutputStream out)
throws IOException {
@@ -1198,8 +1038,8 @@
/**
* Draws a BufferedImage to AFP.
*
- * @param uri
- * the uri of the image
+ * @param imageInfo
+ * the image info
* @param image
* the RenderedImage
* @param imageRes
@@ -1212,34 +1052,29 @@
* the width of the viewport (in mpt)
* @param h
* the height of the viewport (in mpt)
+ * @param foreignAttributes
+ * a mapping of foreign attributes
*/
- public void drawBufferedImage(ImageInfo info, RenderedImage image, int imageRes, int x,
- int y, int w, int h, Map foreignAttributes) {
-// int afpx = mpts2units(x);
-// int afpy = mpts2units(y);
-// int afpw = mpts2units(w);
-// int afph = mpts2units(h);
+ public void drawBufferedImage(ImageInfo imageInfo, RenderedImage image,
+ int imageRes, int x, int y, int w, int h, Map foreignAttributes) {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
try {
// Serialize image
- //TODO Eventually, this should be changed not to buffer as this increases the
- //memory consumption (see PostScript output)
+ // TODO Eventually, this should be changed not to buffer as this
+ // increases the
+ // memory consumption (see PostScript output)
ImageEncodingHelper.encodeRenderedImageAsRGB(image, baout);
} catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider
+ .get(getUserAgent().getEventBroadcaster());
eventProducer.imageWritingError(this, ioe);
return;
}
- //int res = getResolution();
-// String uri = null;// = image.getProperty(name);
-// String uri = image.getProperty(name);
- // Generate image
-
+
// create image object parameters
ImageObjectInfo imageObjectInfo = new ImageObjectInfo();
- imageObjectInfo.setUri(info.getOriginalURI());
- imageObjectInfo.setMimeType(info.getMimeType());
+ imageObjectInfo.setUri(imageInfo.getOriginalURI());
+ imageObjectInfo.setMimeType(imageInfo.getMimeType());
imageObjectInfo.setX(mpts2units(x));
imageObjectInfo.setY(mpts2units(y));
imageObjectInfo.setWidth(mpts2units(w));
@@ -1253,26 +1088,11 @@
imageObjectInfo.setBitsPerPixel(bitsPerPixel);
imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
- //AbstractNamedAFPObject obj =
getAFPDataStream().createObject(imageObjectInfo);
-// ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw,
-// afph, afpres, afpres);
-// io.setImageParameters(imageResolution, imageResolution,
-// image.getWidth(), image.getHeight());
-// if (colorImages) {
-// io.setImageIDESize((byte)24);
-// io.setImageData(buf);
-// } else {
-// // TODO Teach it how to handle grayscale BufferedImages directly
-// // because this is pretty inefficient
-// convertToGrayScaleImage(io, buf,
-// image.getWidth(), image.getHeight(), this.bitsPerPixel);
-// }
}
/**
- * Establishes a new foreground or fill color.
- * {@inheritDoc}
+ * Establishes a new foreground or fill color. {@inheritDoc}
*/
public void updateColor(Color col, boolean fill) {
if (fill) {
@@ -1282,7 +1102,9 @@
/**
* Restores the state stack after a break out.
- * @param breakOutList the state stack to restore.
+ *
+ * @param breakOutList
+ * the state stack to restore.
*/
public void restoreStateStackAfterBreakOut(List breakOutList) {
@@ -1290,6 +1112,7 @@
/**
* Breaks out of the state stack to handle fixed block-containers.
+ *
* @return the saved state stack to recreate later
*/
public List breakOutOfStateStack() {
@@ -1330,194 +1153,158 @@
renderInlineAreaBackAndBorders(text);
String name = getInternalFontNameForArea(text);
- currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
- AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
+ this.currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE))
+ .intValue();
+ AFPFont font = (AFPFont) fontInfo.getFonts().get(name);
Color col = (Color) text.getTrait(Trait.COLOR);
- int vsci = mpts2units(tf.getWidth(' ', currentFontSize) / 1000
- + text.getTextWordSpaceAdjust()
- + text.getTextLetterSpaceAdjust());
+ int vsci = mpts2units(font.getWidth(' ', currentFontSize) / 1000
+ + text.getTextWordSpaceAdjust()
+ + text.getTextLetterSpaceAdjust());
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
- // where previous line area failed to take up entire allocated space
+ // where previous line area failed to take up entire allocated space
int rx = currentIPPosition + text.getBorderAndPaddingWidthStart();
- int bl = currentBPPosition + text.getOffset() + text.getBaselineOffset();
+ int bl = currentBPPosition + text.getOffset()
+ + text.getBaselineOffset();
// Set letterSpacing
- //float ls = fs.getLetterSpacing() / this.currentFontSize;
+ // float ls = fs.getLetterSpacing() / this.currentFontSize;
String worddata = text.getText();
// Create an AFPFontAttributes object from the current font details
- AFPFontAttributes afpFontAttributes = new AFPFontAttributes(name, tf, currentFontSize);
+ AFPFontAttributes afpFontAttributes = new AFPFontAttributes(name, font,
+ currentFontSize);
- if (!currentPageFonts.containsKey(afpFontAttributes.getFontKey())) {
+ if (!getCurrentPageFonts().containsKey(afpFontAttributes.getFontKey())) {
// Font not found on current page, so add the new one
- pageFontCounter++;
+ this.pageFontCounter++;
afpFontAttributes.setFontReference(pageFontCounter);
- currentPageFonts.put(
- afpFontAttributes.getFontKey(),
- afpFontAttributes);
-
+ getCurrentPageFonts().put(afpFontAttributes.getFontKey(),
+ afpFontAttributes);
} else {
// Use the previously stored font attributes
- afpFontAttributes = (AFPFontAttributes) currentPageFonts.get(
- afpFontAttributes.getFontKey());
+ afpFontAttributes = (AFPFontAttributes) currentPageFontMap
+ .get(afpFontAttributes.getFontKey());
}
// Try and get the encoding to use for the font
String encoding = null;
try {
- encoding = tf.getCharacterSet(currentFontSize).getEncoding();
+ encoding = font.getCharacterSet(currentFontSize).getEncoding();
} catch (Throwable ex) {
encoding = AFPConstants.EBCIDIC_ENCODING;
- log.warn(
- "renderText():: Error getting encoding for font '"
- + tf.getFullName()
- + "' - using default encoding "
- + encoding);
+ log.warn("renderText():: Error getting encoding for font '"
+ + font.getFullName() + "' - using default encoding "
+ + encoding);
}
try {
- getAFPDataStream().createText(
- afpFontAttributes.getFontReference(),
- mpts2units(rx),
- mpts2units(bl),
- col,
- vsci,
- mpts2units(text.getTextLetterSpaceAdjust()),
- worddata.getBytes(encoding));
+ getAFPDataStream().createText(afpFontAttributes.getFontReference(),
+ mpts2units(rx), mpts2units(bl), col, vsci,
+ mpts2units(text.getTextLetterSpaceAdjust()),
+ worddata.getBytes(encoding));
} catch (UnsupportedEncodingException usee) {
- log.error(
- "renderText:: Font "
- + afpFontAttributes.getFontKey()
- + " caused UnsupportedEncodingException");
+ log.error("renderText:: Font " + afpFontAttributes.getFontKey()
+ + " caused UnsupportedEncodingException");
}
super.renderText(text);
- renderTextDecoration(tf, currentFontSize, text, bl, rx);
- }
-
- /**
- * {@inheritDoc}
- */
- public void renderWord(WordArea word) {
- // UNUSED
- // String name = getInternalFontNameForArea(word.getParentArea());
- // int size = ((Integer)
- // word.getParentArea().getTrait(Trait.FONT_SIZE)).intValue();
- // AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
- //
- // String s = word.getWord();
- //
- // FontMetrics metrics = fontInfo.getMetricsFor(name);
-
- super.renderWord(word);
+ renderTextDecoration(font, currentFontSize, text, bl, rx);
}
/**
- * {@inheritDoc}
- */
- public void renderSpace(SpaceArea space) {
- // UNUSED
- // String name = getInternalFontNameForArea(space.getParentArea());
- // int size = ((Integer)
- // space.getParentArea().getTrait(Trait.FONT_SIZE)).intValue();
- // AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
- //
- // String s = space.getSpace();
- //
- // FontMetrics metrics = fontInfo.getMetricsFor(name);
-
- super.renderSpace(space);
- }
-
- /**
- * Render leader area.
- * This renders a leader area which is an area with a rule.
- * @param area the leader area to render
+ * Render leader area. This renders a leader area which is an area with a
+ * rule.
+ *
+ * @param area
+ * the leader area to render
*/
public void renderLeader(Leader area) {
renderInlineAreaBackAndBorders(area);
int style = area.getRuleStyle();
- float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
+ float startx = (currentIPPosition + area
+ .getBorderAndPaddingWidthStart()) / 1000f;
float starty = (currentBPPosition + area.getOffset()) / 1000f;
- float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
- + area.getIPD()) / 1000f;
+ float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area
+ .getIPD()) / 1000f;
float ruleThickness = area.getRuleThickness() / 1000f;
- Color col = (Color)area.getTrait(Trait.COLOR);
+ Color col = (Color) area.getTrait(Trait.COLOR);
switch (style) {
- case EN_SOLID:
- case EN_DASHED:
- case EN_DOUBLE:
- case EN_DOTTED:
- case EN_GROOVE:
- case EN_RIDGE:
- drawBorderLine(startx, starty, endx, starty + ruleThickness,
- true, true, style, col);
- break;
- default:
- throw new UnsupportedOperationException("rule style not supported");
+ case EN_SOLID:
+ case EN_DASHED:
+ case EN_DOUBLE:
+ case EN_DOTTED:
+ case EN_GROOVE:
+ case EN_RIDGE:
+ drawBorderLine(startx, starty, endx, starty + ruleThickness, true,
+ true, style, col);
+ break;
+ default:
+ throw new UnsupportedOperationException("rule style not supported");
}
super.renderLeader(area);
}
/**
* Sets the AFPRenderer options
- * @param options the <code>Map</code> containing the options
+ *
+ * @param options
+ * the <code>Map</code> containing the options
*/
-// UNUSED
-// public void setOptions(Map options) {
-//
-// this.afpOptions = options;
-//
-// }
+ // UNUSED
+ // public void setOptions(Map options) {
+ //
+ // this.afpOptions = options;
+ //
+ // }
/**
* Determines the orientation from the string representation, this method
* guarantees to return a value of either 0, 90, 180 or 270.
- *
+ *
* @return the orientation
*/
-// UNUSED
-// private int getOrientation(String orientationString) {
-//
-// int orientation = 0;
-// if (orientationString != null && orientationString.length() > 0) {
-// try {
-// orientation = Integer.parseInt(orientationString);
-// } catch (NumberFormatException nfe) {
-// log.error("Cannot use orientation of " + orientation
-// + " defaulting to zero.");
-// orientation = 0;
-// }
-// } else {
-// orientation = 0;
-// }
-// switch (orientation) {
-// case 0:
-// break;
-// case 90:
-// break;
-// case 180:
-// break;
-// case 270:
-// break;
-// default:
-// log.error("Cannot use orientation of " + orientation
-// + " defaulting to zero.");
-// orientation = 0;
-// break;
-// }
-//
-// return orientation;
-//
-// }
+ // UNUSED
+ // private int getOrientation(String orientationString) {
+ //
+ // int orientation = 0;
+ // if (orientationString != null && orientationString.length() > 0) {
+ // try {
+ // orientation = Integer.parseInt(orientationString);
+ // } catch (NumberFormatException nfe) {
+ // log.error("Cannot use orientation of " + orientation
+ // + " defaulting to zero.");
+ // orientation = 0;
+ // }
+ // } else {
+ // orientation = 0;
+ // }
+ // switch (orientation) {
+ // case 0:
+ // break;
+ // case 90:
+ // break;
+ // case 180:
+ // break;
+ // case 270:
+ // break;
+ // default:
+ // log.error("Cannot use orientation of " + orientation
+ // + " defaulting to zero.");
+ // orientation = 0;
+ // break;
+ // }
+ //
+ // return orientation;
+ //
+ // }
/**
* Sets the rotation to be used for portrait pages, valid values are 0
* (default), 90, 180, 270.
@@ -1526,18 +1313,15 @@
* The rotation in degrees.
*/
public void setPortraitRotation(int rotation) {
-
- if (rotation == 0
- || rotation == 90
- || rotation == 180
- || rotation == 270) {
+ if (rotation == 0 || rotation == 90 || rotation == 180
+ || rotation == 270) {
portraitRotation = rotation;
} else {
- throw new IllegalArgumentException("The portrait rotation must be one"
- + " of the values 0, 90, 180, 270");
+ throw new IllegalArgumentException(
+ "The portrait rotation must be one"
+ + " of the values 0, 90, 180, 270");
}
-
}
/**
@@ -1548,58 +1332,57 @@
* The rotation in degrees.
*/
public void setLandscapeRotation(int rotation) {
-
- if (rotation == 0
- || rotation == 90
- || rotation == 180
- || rotation == 270) {
+ if (rotation == 0 || rotation == 90 || rotation == 180
+ || rotation == 270) {
landscapeRotation = rotation;
} else {
- throw new IllegalArgumentException("The landscape rotation must be one"
- + " of the values 0, 90, 180, 270");
+ throw new IllegalArgumentException(
+ "The landscape rotation must be one"
+ + " of the values 0, 90, 180, 270");
}
-
}
/**
* Get the MIME type of the renderer.
*
- * @return The MIME type of the renderer
+ * @return The MIME type of the renderer
*/
public String getMimeType() {
return MimeConstants.MIME_AFP;
}
- private Map getPageSegments() {
+ private Map/*<String,String>*/getPageSegments() {
if (pageSegmentsMap == null) {
- pageSegmentsMap = new java.util.HashMap();
+ pageSegmentsMap = new java.util.HashMap/*<String,String>*/();
}
return pageSegmentsMap;
}
-
+
/**
* Method to render the page extension.
* <p>
*
- * @param pageViewport the page object
+ * @param pageViewport
+ * the page object
*/
private void renderPageObjectExtensions(PageViewport pageViewport) {
- pageSegmentsMap = null;
+ this.pageSegmentsMap = null;
if (pageViewport.getExtensionAttachments() != null
&& pageViewport.getExtensionAttachments().size() > 0) {
// Extract all AFPPageSetup instances from the attachment list on
// the s-p-m
Iterator i = pageViewport.getExtensionAttachments().iterator();
while (i.hasNext()) {
- ExtensionAttachment attachment = (ExtensionAttachment)i.next();
+ ExtensionAttachment attachment = (ExtensionAttachment) i.next();
if (AFPPageSetup.CATEGORY.equals(attachment.getCategory())) {
AFPPageSetup aps = (AFPPageSetup) attachment;
String element = aps.getElementName();
if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
String overlay = aps.getName();
if (overlay != null) {
- getAFPDataStream().createIncludePageOverlay(overlay);
+ getAFPDataStream()
+ .createIncludePageOverlay(overlay);
}
} else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT
.equals(element)) {
@@ -1617,9 +1400,6 @@
getAFPDataStream().createNoOperation(content);
}
}
-// else if (AFPElementMapping.RESOURCE.equals(element)) {
-// log.info("resource: " + attachment);
-// }
}
}
}
@@ -1628,7 +1408,9 @@
/**
* Converts FOP mpt measurement to afp measurement units
- * @param mpt the millipoints value
+ *
+ * @param mpt
+ * the millipoints value
*/
private int mpts2units(int mpt) {
return mpts2units((double) mpt);
@@ -1636,7 +1418,9 @@
/**
* Converts FOP pt measurement to afp measurement units
- * @param mpt the millipoints value
+ *
+ * @param mpt
+ * the millipoints value
*/
private int pts2units(float mpt) {
return mpts2units(mpt * 1000d);
@@ -1650,7 +1434,8 @@
* @return afp measurement unit value
*/
private int mpts2units(double mpt) {
- return (int)Math.round(mpt / (DPI_CONVERSION_FACTOR / getResolution()));
+ return (int) Math
+ .round(mpt / (DPI_CONVERSION_FACTOR / getResolution()));
}
/**
@@ -1668,8 +1453,8 @@
* @param bitsPerPixel
* the number of bits to use per pixel
*/
- protected static void convertToGrayScaleImage(ImageObject io, byte[] raw, int width,
- int height, int bitsPerPixel) {
+ protected static void convertToGrayScaleImage(ImageObject io, byte[] raw,
+ int width, int height, int bitsPerPixel) {
int pixelsPerByte = 8 / bitsPerPixel;
int bytewidth = (width / pixelsPerByte);
if ((width % pixelsPerByte) != 0) {
@@ -1823,7 +1608,8 @@
private void popViewPortPos() {
viewPortPositions.remove(viewPortPositions.size() - 1);
if (viewPortPositions.size() > 0) {
- ViewPortPos vpp = (ViewPortPos)viewPortPositions.get(viewPortPositions.size() - 1);
+ ViewPortPos vpp = (ViewPortPos) viewPortPositions
+ .get(viewPortPositions.size() - 1);
getAFPDataStream().setOffsets(vpp.x, vpp.y, vpp.rot);
}
}
@@ -1837,9 +1623,9 @@
public void setBitsPerPixel(int bitsPerPixel) {
this.bitsPerPixel = bitsPerPixel;
switch (bitsPerPixel) {
- case 1:
- case 4:
- case 8:
+ case 1:
+ case 4:
+ case 8:
break;
default:
log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8.");
@@ -1885,12 +1671,13 @@
/**
* Returns the output/device resolution.
+ *
* @return the resolution in dpi
*/
public int getResolution() {
return this.resolution;
}
-
+
private AFPState getState() {
if (currentState == null) {
currentState = new AFPState();
@@ -1901,7 +1688,8 @@
private boolean gocaEnabled = false;
/**
- * @param enabled true if AFP GOCA is enabled for SVG support
+ * @param enabled
+ * true if AFP GOCA is enabled for SVG support
*/
protected void setGOCAEnabled(boolean enabled) {
this.gocaEnabled = enabled;
@@ -1913,10 +1701,5 @@
protected boolean isGOCAEnabled() {
return this.gocaEnabled;
}
-
- /** {@inheritDoc} */
- public void startPageSequence(LineArea seqTitle) {
- getAFPDataStream().endPageGroup();
- getAFPDataStream().startPageGroup();
- }
+
}
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=656249&r1=656248&r2=656249&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 Wed May 14 05:26:18 2008
@@ -36,6 +36,8 @@
import org.apache.fop.render.afp.fonts.FopCharacterSet;
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;
/**
@@ -240,29 +242,43 @@
afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger(240));
}
- // a default external resource group file setting
- Configuration resourceGroupFileCfg = cfg.getChild("resource-group-file", false);
- if (resourceGroupFileCfg != null) {
- String resourceGroupDest = null;
- try {
- resourceGroupDest = resourceGroupFileCfg.getValue();
- } catch (ConfigurationException e) {
- LogUtil.handleException(log, e,
- userAgent.getFactory().validateUserConfigStrictly());
- }
- File resourceGroupFile = new File(resourceGroupDest);
- if (resourceGroupFile.canWrite()) {
- afpRenderer.getAFPDataStream().setDefaultResourceGroupFile(resourceGroupFile);
- } else {
- log.warn("Unable to write to default external resource group file '"
- + resourceGroupDest);
- }
- }
+ // the MO:DCA interchange set in use (defaults to MO:DCA-L)
+ Configuration interchangeSetCfg = cfg.getChild("interchange-set", false);
+ if (interchangeSetCfg != null) {
+ String interchangeSetString = interchangeSetCfg.getAttribute(
+ "name", InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2);
+ AFPDataStream afpDatastream = afpRenderer.getAFPDataStream();
+ InterchangeSet interchangeSet = InterchangeSet.valueOf(interchangeSetString);
+ afpDatastream.setInterchangeSet(interchangeSet);
- // goca enabled
- Configuration gocaSupportCfg = cfg.getChild("goca-enabled", false);
- if (gocaSupportCfg != null) {
- afpRenderer.setGOCAEnabled(true);
+ if (interchangeSet.supportsLevel2()) {
+
+ // a default external resource group file setting
+ Configuration resourceGroupFileCfg
+ = interchangeSetCfg.getChild("resource-group-file", false);
+ if (resourceGroupFileCfg != null) {
+ String resourceGroupDest = null;
+ try {
+ resourceGroupDest = resourceGroupFileCfg.getValue();
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
+ }
+ File resourceGroupFile = new File(resourceGroupDest);
+ if (resourceGroupFile.canWrite()) {
+ afpDatastream.setDefaultResourceGroupFile(resourceGroupFile);
+ } else {
+ log.warn("Unable to write to default external resource group file '"
+ + resourceGroupDest);
+ }
+ }
+ }
+
+ // goca enabled
+ Configuration gocaSupportCfg = interchangeSetCfg.getChild("goca-enabled", false);
+ if (gocaSupportCfg != null) {
+ afpRenderer.setGOCAEnabled(true);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org