You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/08/27 14:35:51 UTC
svn commit: r689459 [3/7] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop:
pdf/ render/ render/afp/ render/afp/goca/ render/afp/ioca/
render/afp/modca/ render/afp/modca/resource/ render/afp/modca/triplets/
render/java2d/
Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceLevel.java (from r682300, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceLevel.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceLevel.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceLevel.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceLevel.java&r1=682300&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceLevel.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceLevel.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,8 +22,8 @@
/**
* A resource level
*/
-public class ResourceLevel {
-
+public class AFPResourceLevel {
+
/** page level **/
public static final int PAGE = 0;
@@ -38,7 +38,7 @@
/** external level **/
public static final int EXTERNAL = 4;
-
+
private static final String NAME_PAGE = "page";
private static final String NAME_PAGE_GROUP = "page-group";
private static final String NAME_DOCUMENT = "document";
@@ -48,8 +48,8 @@
private static final String[] NAMES
= new String[] {NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL};
-
-
+
+
/** where the resource will reside in the AFP output */
private int level = PRINT_FILE; // default is print-file level
@@ -58,36 +58,37 @@
/**
* Sets the resource placement level within the AFP output
- *
- * @param lvl the resource level (page, page-group, document, print-file or external)
+ *
+ * @param levelString the resource level (page, page-group, document, print-file or external)
* @return true if the resource level was successfully set
*/
- public static ResourceLevel valueOf(String lvl) {
- ResourceLevel level = null;
- for (int i = 0; i < NAMES.length; i++) {
- if (NAMES[i].equals(lvl)) {
- level = new ResourceLevel(i);
- break;
+ public static AFPResourceLevel valueOf(String levelString) {
+ if (levelString != null) {
+ levelString = levelString.toLowerCase();
+ AFPResourceLevel resourceLevel = null;
+ for (int i = 0; i < NAMES.length; i++) {
+ if (NAMES[i].equals(levelString)) {
+ resourceLevel = new AFPResourceLevel(i);
+ break;
+ }
}
+ return resourceLevel;
}
- if (lvl == null) {
- throw new IllegalArgumentException("Unknown resource level '" + lvl + "'");
- }
- return level;
+ return null;
}
-
+
/**
* Main constructor
- *
+ *
* @param level the resource level
*/
- public ResourceLevel(int level) {
+ public AFPResourceLevel(int level) {
setLevel(level);
}
/**
* Sets the resource level
- *
+ *
* @param level the resource level
*/
public void setLevel(int level) {
@@ -95,53 +96,62 @@
}
/**
- * Returns true if this is a page level resource group
- *
- * @return true if this is a page level resource group
+ * Returns true if this is a page level
+ *
+ * @return true if this is a page level
*/
public boolean isPage() {
return level == PAGE;
}
-
+
/**
- * Returns true if this is a page group level resource group
- *
- * @return true if this is a page group level resource group
+ * Returns true if this is page group level
+ *
+ * @return true if this is page group level
*/
public boolean isPageGroup() {
return level == PAGE_GROUP;
}
/**
- * Returns true if this is a document level resource group
- *
- * @return true if this is a document level resource group
+ * Returns true if this is document level
+ *
+ * @return true if this is document level
*/
public boolean isDocument() {
return level == DOCUMENT;
}
/**
- * Returns true if this is an external level resource group
- *
- * @return true if this is an external level resource group
+ * Returns true if this is external level
+ *
+ * @return true if this is external level
*/
public boolean isExternal() {
return level == EXTERNAL;
}
/**
- * Returns true if this is a print-file level resource group
- *
- * @return true if this is a print-file level resource group
+ * Returns true if this is print-file level
+ *
+ * @return true if this is print-file level
*/
public boolean isPrintFile() {
return level == PRINT_FILE;
}
-
+
+ /**
+ * Returns true if this resource level is inlined
+ *
+ * @return true if this resource level is inlined
+ */
+ public boolean isInlined() {
+ return isPage() || isPageGroup() || isDocument();
+ }
+
/**
* Returns the destination file path of the external resource group file
- *
+ *
* @return the destination file path of the external resource group file
*/
public String getExternalFilePath() {
@@ -150,7 +160,7 @@
/**
* Sets the external destination of the resource
- *
+ *
* @param filePath the external resource group file
*/
public void setExternalFilePath(String filePath) {
@@ -161,22 +171,22 @@
public String toString() {
return NAMES[level] + (isExternal() ? ", file=" + extFilePath : "");
}
-
+
/** {@inheritDoc} */
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
- if ((obj == null) || !(obj instanceof ResourceLevel)) {
+ if ((obj == null) || !(obj instanceof AFPResourceLevel)) {
return false;
}
- ResourceLevel rl = (ResourceLevel)obj;
+ AFPResourceLevel rl = (AFPResourceLevel)obj;
return (level == level)
&& (extFilePath == rl.extFilePath
|| extFilePath != null && extFilePath.equals(rl.extFilePath));
}
-
+
/** {@inheritDoc} */
public int hashCode() {
int hash = 7;
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,184 @@
+/*
+ * 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.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.modca.AbstractDataObject;
+import org.apache.fop.render.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.render.afp.modca.DataStream;
+import org.apache.fop.render.afp.modca.Factory;
+import org.apache.fop.render.afp.modca.ImageObject;
+import org.apache.fop.render.afp.modca.IncludeObject;
+import org.apache.fop.render.afp.modca.Registry;
+import org.apache.fop.render.afp.modca.ResourceGroup;
+
+/**
+ * Manages the creation and storage of document resources
+ */
+public class AFPResourceManager {
+ /** Static logging instance */
+ private static final Log log = LogFactory.getLog(AFPResourceManager.class);
+
+ /** The AFP datastream (document tree) */
+ private DataStream dataStream;
+
+ /** Resource creation factory */
+ private final Factory factory;
+
+ private final AFPStreamer streamer;
+
+ private final AFPDataObjectFactory dataObjectFactory;
+
+ /** Maintain a reference count of instream objects for referencing purposes */
+ private int instreamObjectCount = 0;
+
+ /** a mapping of resourceInfo --> include name */
+ private final Map/*<ResourceInfo,String>*/ includeNameMap
+ = new java.util.HashMap()/*<ResourceInfo,String>*/;
+
+ /**
+ * Main constructor
+ */
+ public AFPResourceManager() {
+ this.factory = new Factory();
+ this.streamer = new AFPStreamer(factory);
+ this.dataObjectFactory = new AFPDataObjectFactory(factory);
+ }
+
+ /**
+ * Sets the outputstream
+ *
+ * @param outputStream the outputstream
+ */
+ public void setOutputStream(OutputStream outputStream) {
+ this.dataStream = streamer.createDataStream();
+ streamer.setOutputStream(outputStream);
+ }
+
+ /**
+ * Returns the AFPDocumentStream
+ *
+ * @return the AFPDocumentStream
+ */
+ public DataStream getDataStream() {
+ return this.dataStream;
+ }
+
+ /**
+ * Tells the streamer to write
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred.
+ */
+ public void writeToStream() throws IOException {
+ streamer.close();
+ }
+
+ /**
+ * Sets the default resource group file path
+ *
+ * @param filePath the default resource group file path
+ */
+
+ public void setDefaultResourceGroupFilePath(String filePath) {
+ streamer.setDefaultResourceGroupFilePath(filePath);
+ }
+
+ /**
+ * Creates and returns a new data object
+ *
+ * @param dataObjectInfo the data object info
+ *
+ * @throws IOException thrown if an I/O exception of some sort has occurred.
+ */
+ public void createObject(AFPDataObjectInfo dataObjectInfo) throws IOException {
+ AbstractNamedAFPObject namedObj = null;
+
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ String uri = resourceInfo.getUri();
+ if (uri == null) {
+ uri = "/";
+ }
+ // if this is an instream data object adjust uri to ensure that it is
+ // unique
+ if (uri.endsWith("/")) {
+ uri += "#" + (++instreamObjectCount);
+ resourceInfo.setUri(uri);
+ }
+
+ // try and find an include name for the same resource
+ String includeName = (String)includeNameMap.get(resourceInfo);
+ if (includeName == null) {
+
+ // new resource so create
+ if (dataObjectInfo instanceof AFPImageObjectInfo) {
+ namedObj = dataObjectFactory.createImage((AFPImageObjectInfo)dataObjectInfo);
+ } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) {
+ namedObj = dataObjectFactory.createGraphic((AFPGraphicsObjectInfo)dataObjectInfo);
+ } else {
+ throw new IllegalArgumentException("Unknown data object type: " + dataObjectInfo);
+ }
+
+ if (namedObj instanceof AbstractDataObject) {
+ AbstractDataObject dataObj = (AbstractDataObject)namedObj;
+ dataObj.setViewport(dataObjectInfo);
+ }
+
+ AFPResourceLevel resourceLevel = resourceInfo.getLevel();
+
+ Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+ boolean canInclude = (namedObj instanceof ImageObject
+ || objectType != null && objectType.isIncludable());
+ if (canInclude) {
+ // if it is to reside within a resource group at print-file or external level
+ if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) {
+ // wrap newly created data object in a resource object
+ namedObj = dataObjectFactory.createResource(namedObj, resourceInfo, objectType);
+ }
+
+ // add data object into its resource group destination
+ ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
+ resourceGroup.addObject(namedObj);
+
+ // add an include to the current page
+ includeName = namedObj.getName();
+ IncludeObject includeObject
+ = dataObjectFactory.createInclude(includeName, dataObjectInfo);
+ dataStream.getCurrentPage().addObject(includeObject);
+
+ // record name of data object for the resource
+ includeNameMap.put(resourceInfo, namedObj.getName());
+ } else {
+ // add data object directly into the current page
+ dataStream.getCurrentPage().addObject(namedObj);
+ }
+ } else {
+ // existing resource so reference by adding an include to the current page
+ IncludeObject includeObject
+ = dataObjectFactory.createInclude(includeName, dataObjectInfo);
+ dataStream.getCurrentPage().addObject(includeObject);
+ }
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPResourceManager.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
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=689459&r1=689458&r2=689459&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 Wed Aug 27 05:35:44 2008
@@ -37,7 +37,6 @@
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.AFPDataStream;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
import org.apache.xmlgraphics.util.QName;
@@ -50,8 +49,12 @@
*/
public class AFPSVGHandler extends AbstractGenericSVGHandler {
+ /** foreign attribute reader */
+ private final AFPForeignAttributeReader foreignAttributeReader
+ = new AFPForeignAttributeReader();
+
/** {@inheritDoc} */
- public void handleXML(RendererContext context,
+ public void handleXML(RendererContext context,
Document doc, String ns) throws Exception {
if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
renderSVGDocument(context, doc);
@@ -75,21 +78,21 @@
AFPRendererContextConstants.AFP_FONT_INFO));
afpi.setState((AFPState)context.getProperty(
AFPRendererContextConstants.AFP_STATE));
- afpi.setAFPDataStream((AFPDataStream)context.getProperty(
- AFPRendererContextConstants.AFP_DATASTREAM));
+ afpi.setResourceManager(((AFPResourceManager)context.getProperty(
+ AFPRendererContextConstants.AFP_RESOURCE_MANAGER)));
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
- if (foreign != null
+ if (foreign != null
&& "bitmap".equalsIgnoreCase((String)foreign.get(qName))) {
- afpi.paintAsBitmap = true;
+ afpi.setPaintAsBitmap(true);
}
return afpi;
}
-
+
/**
* 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
@@ -99,7 +102,9 @@
AFPRenderer renderer = (AFPRenderer)context.getRenderer();
AFPInfo afpInfo = getAFPInfo(context);
- if (afpInfo.paintAsBitmap) {
+
+ // fallback paint as bitmap
+ if (afpInfo.paintAsBitmap()) {
try {
super.renderSVGDocument(context, doc);
} catch (IOException ioe) {
@@ -111,31 +116,52 @@
}
String uri = ((AbstractDocument)doc).getDocumentURI();
- AFPState currentState = (AFPState)renderer.getState();
- currentState.setImageUri(uri);
+ AFPState state = (AFPState)renderer.getState();
+ state.setImageUri(uri);
- // set the data object parameters
- ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo();
+ // set the data object parameters
+ AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
- int x = (int)Math.round((afpInfo.getX() * 25.4f) / 1000f);
- objectAreaInfo.setX(x);
+ AFPUnitConverter unitConv = state.getUnitConverter();
- int y = (int)Math.round((afpInfo.getY() * 25.4f) / 1000f);
- objectAreaInfo.setY(y);
+// RendererContextWrapper rctx = RendererContext.wrapRendererContext(context);
+// int currx = rctx.getCurrentXPosition();
+// int curry = rctx.getCurrentYPosition();
+// int afpx = Math.round(unitConv.mpt2units(currx));
+// int afpy = Math.round(unitConv.mpt2units(curry));
+// objectAreaInfo.setOffsetX(afpx);
+// objectAreaInfo.setOffsetY(afpy);
+
+ AffineTransform at = state.getData().getTransform();
+ float transX = (float)at.getTranslateX();
+ float transY = (float)at.getTranslateY();
+// int afpx = Math.round(unitConv.mpt2units(currx));
+// objectAreaInfo.setX(afpx);
+// int afpy = Math.round(unitConv.mpt2units(curry));
+// objectAreaInfo.setY(afpy);
+// objectAreaInfo.setX(coords[0]);
+// objectAreaInfo.setY(coords[1]);
+ objectAreaInfo.setX(Math.round(transX));
+ objectAreaInfo.setY(Math.round(transY));
+
+// AffineTransform at = currentState.getData().getTransform();
+// int x = (int)Math.round(at.getTranslateX());
+// objectAreaInfo.setX(x);
+//
+// int y = (int)Math.round(at.getTranslateY());
+// 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);
+ int width = Math.round(unitConv.mpt2units(afpInfo.getWidth()));
objectAreaInfo.setWidth(width);
- int height = (int)Math.round((afpInfo.getHeight() * resolution)
- / AFPConstants.DPI_72_MPTS);
+ int height = Math.round(unitConv.mpt2units(afpInfo.getHeight()));
objectAreaInfo.setHeight(height);
- DataObjectInfo dataObjectInfo = new GraphicsObjectInfo();
+ AFPDataObjectInfo dataObjectInfo = new AFPGraphicsObjectInfo();
dataObjectInfo.setUri(uri);
// Configure Graphics2D implementation
@@ -143,11 +169,10 @@
AFPGraphics2D graphics = new AFPGraphics2D(textAsShapes);
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
graphics.setAFPInfo(afpInfo);
-
+
// Configure GraphicsObjectPainter with the Graphics2D implementation
- GraphicsObjectPainter painter = new GraphicsObjectPainter();
- painter.setGraphics2D(graphics);
- ((GraphicsObjectInfo)dataObjectInfo).setPainter(painter);
+ AFPGraphicsObjectPainter painter = new AFPGraphicsObjectPainter(graphics);
+ ((AFPGraphicsObjectInfo)dataObjectInfo).setPainter(painter);
boolean strokeText = false;
Configuration cfg = afpInfo.getHandlerConfiguration();
@@ -156,25 +181,26 @@
}
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);
graphics.setCustomTextHandler(afpTextHandler);
AFPTextPainter textPainter = new AFPTextPainter(afpTextHandler);
- ctx.setTextPainter(textPainter);
+ ctx.setTextPainter(textPainter);
AFPTextElementBridge tBridge = new AFPTextElementBridge(textPainter);
ctx.putBridge(tBridge);
}
-
+
Map/*<QName, String>*/ foreignAttributes
= (Map/*<QName, String>*/)context.getProperty(
RendererContextConstants.FOREIGN_ATTRIBUTES);
- dataObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
-
+ AFPResourceInfo resourceInfo = foreignAttributeReader.getResourceInfo(foreignAttributes);
+ dataObjectInfo.setResourceInfo(resourceInfo);
+
// Build the SVG DOM and provide the painter with it
GraphicsNode root;
GVTBuilder builder = new GVTBuilder();
@@ -187,18 +213,18 @@
eventProducer.svgNotBuilt(this, e, uri);
return;
}
-
+
+ // convert to afp inches
Dimension2D dim = ctx.getDocumentSize();
double w = dim.getWidth() * 1000f;
double h = dim.getHeight() * 1000f;
-
- // convert to afp inches
- 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;
-
+ double wx = (afpInfo.getWidth() / w);
+ double hx = (afpInfo.getHeight() / h);
+ double scaleX = unitConv.pt2units((float)wx);
+ double scaleY = unitConv.pt2units((float)hx);
+ double xOffset = unitConv.mpt2units(afpInfo.getX());
+ double yOffset = unitConv.mpt2units(afpInfo.getHeight());
+
// Transformation matrix that establishes the local coordinate system
// for the SVG graphic in relation to the current coordinate system
// (note: y axis is inverted)
@@ -208,10 +234,12 @@
// Set the object area info
dataObjectInfo.setObjectAreaInfo(objectAreaInfo);
- // Create the object
- afpInfo.getAFPDataStream().createObject(dataObjectInfo);
+ AFPResourceManager resourceManager = afpInfo.getAFPResourceManager();
+
+ // Create the graphics object
+ resourceManager.createObject(dataObjectInfo);
}
-
+
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof AFPRenderer);
@@ -222,4 +250,5 @@
//Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean.FALSE);
}
+
}
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=689459&r1=689458&r2=689459&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 Wed Aug 27 05:35:44 2008
@@ -23,11 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.AbstractState;
/**
* This keeps information about the current state when writing to an AFP datastream.
*/
-public class AFPState extends org.apache.fop.render.AbstractState {
+public class AFPState extends org.apache.fop.render.AbstractState implements Cloneable {
+
+ private static final long serialVersionUID = 8206711712452344473L;
private static Log log = LogFactory.getLog("org.apache.fop.render.afp.AFPState");
@@ -38,7 +41,7 @@
private int landscapeRotation = 270;
/** Flag to the set the output object type for images */
- private boolean colorImages = false;
+ private boolean colorImages = true;
/** Default value for image depth */
private int bitsPerPixel = 8;
@@ -49,6 +52,9 @@
/** The current page */
private AFPPageState pageState = new AFPPageState();
+ /** A unit converter */
+ private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this);
+
/**
* Sets the rotation to be used for portrait pages, valid values are 0
* (default), 90, 180, 270.
@@ -70,7 +76,7 @@
/**
* Returns the rotation to be used for portrait pages
- *
+ *
* @return the rotation to be used for portrait pages
*/
protected int getPortraitRotation() {
@@ -97,7 +103,7 @@
/**
* Returns the landscape rotation
- *
+ *
* @return the landscape rotation
*/
protected int getLandscapeRotation() {
@@ -126,7 +132,7 @@
/**
* Returns the number of bits per pixel
- *
+ *
* @return the number of bits per pixel
*/
public int getBitsPerPixel() {
@@ -145,7 +151,7 @@
/**
* Returns true if color images are to be used
- *
+ *
* @return true if color images are to be used
*/
protected boolean isColorImages() {
@@ -179,9 +185,14 @@
return new AFPData();
}
+ /** {@inheritDoc} */
+ protected AbstractState instantiateState() {
+ return new AFPState();
+ }
+
/**
* Returns the state of the current page
- *
+ *
* @return the state of the current page
*/
protected AFPPageState getPageState() {
@@ -190,7 +201,7 @@
/**
* 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
*/
@@ -204,7 +215,7 @@
/**
* Gets the current page fonts
- *
+ *
* @return the current page fonts
*/
protected AFPPageFonts getPageFonts() {
@@ -213,7 +224,7 @@
/**
* Increments and returns the page font count
- *
+ *
* @return the page font count
*/
public int incrementPageFontCount() {
@@ -222,7 +233,7 @@
/**
* Sets the page width
- *
+ *
* @param pageWidth the page width
*/
public void setPageWidth(int pageWidth) {
@@ -231,7 +242,7 @@
/**
* Returns the page width
- *
+ *
* @return the page width
*/
public int getPageWidth() {
@@ -240,7 +251,7 @@
/**
* Sets the page height
- *
+ *
* @param pageHeight the page height
*/
public void setPageHeight(int pageHeight) {
@@ -249,7 +260,7 @@
/**
* Returns the page height
- *
+ *
* @return the page height
*/
public int getPageHeight() {
@@ -258,7 +269,7 @@
/**
* Sets the uri of the current image
- *
+ *
* @param uri the uri of the current image
*/
protected void setImageUri(String uri) {
@@ -267,7 +278,7 @@
/**
* Gets the uri of the current image
- *
+ *
* @return the uri of the current image
*/
public String getImageUri() {
@@ -276,7 +287,7 @@
/**
* Returns the current orientation
- *
+ *
* @return the current orientation
*/
public int getOrientation() {
@@ -295,21 +306,43 @@
return orientation;
}
+ /**
+ * Returns the unit converter
+ *
+ * @return the unit converter
+ */
+ public AFPUnitConverter getUnitConverter() {
+ return this.unitConv;
+ }
+
+ /** {@inheritDoc} */
+ public Object clone() {
+ AFPState state = (AFPState)super.clone();
+ state.pageState = (AFPPageState)this.pageState.clone();
+ state.portraitRotation = this.portraitRotation;
+ state.landscapeRotation = this.landscapeRotation;
+ state.bitsPerPixel = this.bitsPerPixel;
+ state.colorImages = this.colorImages;
+ state.resolution = this.resolution;
+ return state;
+ }
+
/** {@inheritDoc} */
public String toString() {
- return "AFPState{portraitRotation=" + portraitRotation
+ return "AFPState{" + "portraitRotation=" + portraitRotation
+ ", landscapeRotation=" + landscapeRotation
+ ", colorImages=" + colorImages
+ ", bitsPerPixel=" + bitsPerPixel
+ ", resolution=" + resolution
+ ", pageState=" + pageState
+ + super.toString()
+ "}";
}
/**
* Page level state data
*/
- private class AFPPageState {
+ private class AFPPageState implements Cloneable {
/** The current page width */
private int width = 0;
@@ -324,7 +357,7 @@
/**
* Returns the page width
- *
+ *
* @return the page width
*/
protected int getWidth() {
@@ -333,7 +366,7 @@
/**
* Sets the page width
- *
+ *
* @param width the page width
*/
protected void setWidth(int width) {
@@ -342,7 +375,7 @@
/**
* Returns the page height
- *
+ *
* @return the page height
*/
protected int getHeight() {
@@ -351,7 +384,7 @@
/**
* Sets the page height
- *
+ *
* @param height the page height
*/
protected void setHeight(int height) {
@@ -360,7 +393,7 @@
/**
* Returns the page fonts
- *
+ *
* @return the page fonts
*/
protected AFPPageFonts getFonts() {
@@ -369,7 +402,7 @@
/**
* Sets the current page fonts
- *
+ *
* @param fonts the current page fonts
*/
protected void setFonts(AFPPageFonts fonts) {
@@ -378,7 +411,7 @@
/**
* Increments and returns the current page font count
- *
+ *
* @return increment and return the current page font count
*/
protected int incrementFontCount() {
@@ -386,6 +419,16 @@
}
/** {@inheritDoc} */
+ public Object clone() {
+ AFPPageState state = new AFPPageState();
+ state.fonts = new AFPPageFonts(this.fonts);
+ state.height = this.height;
+ state.width = this.width;
+ state.fontCount = this.fontCount;
+ return state;
+ }
+
+ /** {@inheritDoc} */
public String toString() {
return "AFPPageState{width=" + width
+ ", height=" + height
@@ -396,7 +439,7 @@
}
/**
- * Block level data
+ * Block level state data
*/
private class AFPData extends org.apache.fop.render.AbstractState.AbstractData {
private static final long serialVersionUID = -1789481244175275686L;
@@ -407,7 +450,7 @@
private String imageUri = null;
/** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
+ public Object clone() {
AFPData obj = (AFPData)super.clone();
obj.filled = this.filled;
obj.imageUri = this.imageUri;
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,214 @@
+/*
+ * 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.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.RandomAccessFile;
+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.DataStream;
+import org.apache.fop.render.afp.modca.Factory;
+import org.apache.fop.render.afp.modca.ResourceGroup;
+import org.apache.fop.render.afp.modca.StreamedResourceGroup;
+import org.apache.fop.util.store.Streamable;
+
+/**
+ * Manages the streaming of the AFP output
+ */
+public class AFPStreamer implements Streamable {
+ /** Static logging instance */
+ private static final Log log = LogFactory.getLog(AFPStreamer.class);
+
+ private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_";
+
+ private static final int BUFFER_SIZE = 4096;
+
+ private static final String DEFAULT_EXTERNAL_RESOURCE_FILENAME = "resources.afp";
+
+
+ private final Factory factory;
+
+ /** A mapping of external resource destinations to resource groups */
+ private final Map/*<String,AFPExternalResourceGroup>*/pathResourceGroupMap
+ = new java.util.HashMap/*<String,AFPExternalResourceGroup>*/();
+
+ private StreamedResourceGroup printFileResourceGroup;
+
+ /** Sets the default resource group file path */
+ private String defaultResourceGroupFilePath = DEFAULT_EXTERNAL_RESOURCE_FILENAME;
+
+ private File tempFile;
+
+ /** temporary document outputstream */
+ private OutputStream documentOutputStream;
+
+ /** the final outputstream */
+ private OutputStream outputStream;
+
+ private RandomAccessFile documentFile;
+
+ private DataStream dataStream;
+
+ /**
+ * Main constructor
+ *
+ * @param factory a factory
+ */
+ public AFPStreamer(Factory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * Creates a new DataStream
+ *
+ * @return a new {@link DataStream}
+ */
+ public DataStream createDataStream() {
+ try {
+ this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null);
+ this.documentFile = new RandomAccessFile(tempFile, "rw");
+ this.documentOutputStream = new BufferedOutputStream(
+ new FileOutputStream(documentFile.getFD()));
+ this.dataStream = factory.createDataStream(documentOutputStream);
+ } catch (IOException e) {
+ log.error(e.getMessage());
+ }
+ return dataStream;
+ }
+
+ /**
+ * Sets the default resource group file path
+ *
+ * @param filePath the default resource group file path
+ */
+ public void setDefaultResourceGroupFilePath(String filePath) {
+ this.defaultResourceGroupFilePath = filePath;
+ }
+
+ /**
+ * Returns the resource group for a given resource info
+ *
+ * @param level a resource level
+ * @return a resource group for the given resource info
+ */
+ public ResourceGroup getResourceGroup(AFPResourceLevel level) {
+ ResourceGroup resourceGroup = null;
+ if (level.isExternal()) {
+ String filePath = level.getExternalFilePath();
+ if (filePath == null) {
+ log.warn("No file path provided for external resource, using default.");
+ filePath = defaultResourceGroupFilePath;
+ }
+ resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath);
+ if (resourceGroup == null) {
+ OutputStream os = null;
+ try {
+ os = new BufferedOutputStream(new FileOutputStream(filePath));
+ } catch (FileNotFoundException fnfe) {
+ log.error("Failed to create/open external resource group file '"
+ + filePath + "'");
+ } finally {
+ if (os != null) {
+ resourceGroup = factory.createStreamedResourceGroup(os);
+ pathResourceGroupMap.put(filePath, resourceGroup);
+ }
+ }
+ }
+ } else if (level.isPrintFile()) {
+ if (printFileResourceGroup == null) {
+ // use final outputstream for print-file resource group
+ printFileResourceGroup = factory.createStreamedResourceGroup(outputStream);
+ }
+ resourceGroup = printFileResourceGroup;
+ } else {
+ // resource group in afp document datastream
+ resourceGroup = dataStream.getResourceGroup(level);
+ }
+ return resourceGroup;
+ }
+
+ /**
+ * Closes off the AFP stream writing the document stream
+ *
+ * @throws IOException if an an I/O exception of some sort has occurred
+ */
+ public void close() throws IOException {
+ // write out any external resource groups
+ Iterator it = pathResourceGroupMap.entrySet().iterator();
+ while (it.hasNext()) {
+ StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next();
+ resourceGroup.close();
+ }
+
+ // close any open print-file resource group
+ if (printFileResourceGroup != null) {
+ printFileResourceGroup.close();
+ }
+
+ // write out document
+ writeToStream(outputStream);
+
+ outputStream.close();
+
+ // delete temporary file
+ tempFile.delete();
+ }
+
+ /**
+ * Sets the final outputstream
+ *
+ * @param outputStream an outputstream
+ */
+ public void setOutputStream(OutputStream outputStream) {
+ this.outputStream = outputStream;
+ }
+
+ /** {@inheritDoc} */
+ public void writeToStream(OutputStream os) throws IOException {
+ int len = (int)documentFile.length();
+ int numChunks = len / BUFFER_SIZE;
+ int remainingChunkSize = len % BUFFER_SIZE;
+ byte[] buffer;
+
+ documentFile.seek(0);
+ if (numChunks > 0) {
+ buffer = new byte[BUFFER_SIZE];
+ for (int i = 0; i < numChunks; i++) {
+ documentFile.read(buffer, 0, BUFFER_SIZE);
+ os.write(buffer, 0, BUFFER_SIZE);
+ }
+ } else {
+ buffer = new byte[remainingChunkSize];
+ }
+ if (remainingChunkSize > 0) {
+ documentFile.read(buffer, 0, remainingChunkSize);
+ os.write(buffer, 0, remainingChunkSize);
+ }
+ os.flush();
+ }
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPStreamer.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,120 @@
+/*
+ * 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.awt.geom.AffineTransform;
+
+
+/**
+ * AFP Unit converter
+ */
+public class AFPUnitConverter {
+
+ /** the AFP state */
+ private final AFPState state;
+
+ /**
+ * Unit converter
+ *
+ * @param state the AFP state
+ */
+ public AFPUnitConverter(AFPState state) {
+ this.state = state;
+ }
+
+ /**
+ * Converts millipoints to units
+ *
+ * @param srcPts source points
+ * @param dstPts destination points
+ * @return transformed points
+ */
+ public int[] mpts2units(float[] srcPts, float[] dstPts) {
+ return transformPoints(srcPts, dstPts, true);
+ }
+
+ /**
+ * Converts points to units
+ *
+ * @param srcPts source points
+ * @param dstPts destination points
+ * @return transformed points
+ */
+ public int[] pts2units(float[] srcPts, float[] dstPts) {
+ return transformPoints(srcPts, dstPts, false);
+ }
+
+ /**
+ * Converts millipoints to units
+ *
+ * @param srcPts source points
+ * @return transformed points
+ */
+ public int[] mpts2units(float[] srcPts) {
+ return transformPoints(srcPts, null, true);
+ }
+
+ /**
+ * Converts points to units
+ *
+ * @param srcPts source points
+ * @return transformed points
+ */
+ public int[] pts2units(float[] srcPts) {
+ return transformPoints(srcPts, null, false);
+ }
+
+ /**
+ * Converts point to unit
+ *
+ * @param pt point
+ * @return transformed point
+ */
+ public float pt2units(float pt) {
+ return pt / ((float)AFPConstants.DPI_72 / state.getResolution());
+ }
+
+ /**
+ * Converts millipoint to unit
+ *
+ * @param mpt millipoint
+ * @return transformed point
+ */
+ public float mpt2units(float mpt) {
+ return mpt / ((float)AFPConstants.DPI_72_MPTS / state.getResolution());
+ }
+
+ private int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) {
+ if (dstPts == null) {
+ dstPts = new float[srcPts.length];
+ }
+ AffineTransform at = state.getData().getTransform();
+ at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2);
+ int[] coords = new int[srcPts.length];
+ for (int i = 0; i < srcPts.length; i++) {
+ if (!milli) {
+ dstPts[i] *= 1000;
+ }
+ coords[i] = Math.round(dstPts[i]);
+ }
+ return coords;
+ }
+
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPUnitConverter.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/LineDataInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/LineDataInfo.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/LineDataInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/LineDataInfo.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,164 +23,163 @@
/** Line data information */
public class LineDataInfo {
-
+
/** the x1 coordinate */
int x1;
-
+
/** the y1 coordinate */
int y1;
-
+
/** the x2 coordinate */
int x2;
-
+
/** the y2 coordinate */
int y2;
-
+
/** the thickness */
int thickness;
-
+
/** the painting color */
Color color;
-
+
/** the orientation */
int orientation;
-
+
/**
* Default constructor
*/
public LineDataInfo() {
}
-
+
/**
* Returns the X1 coordinate
- *
+ *
* @return the X1 coordinate
*/
public int getX1() {
return x1;
}
-
+
/**
* Sets the X1 coordinate
- *
+ *
* @param x1 the X1 coordinate
*/
public void setX1(int x1) {
this.x1 = x1;
}
-
+
/**
* Returns the Y1 coordinate
- *
+ *
* @return the Y1 coordinate
*/
public int getY1() {
return y1;
}
-
+
/**
* Sets the Y1 coordinate
- *
+ *
* @param y1 the Y1 coordinate
*/
public void setY1(int y1) {
this.y1 = y1;
}
-
+
/**
* Returns the X2 coordinate
- *
+ *
* @return the X2 coordinate
*/
public int getX2() {
return x2;
}
-
+
/**
* Sets the X2 coordinate
- *
+ *
* @param x2 the X2 coordinate
*/
public void setX2(int x2) {
this.x2 = x2;
}
-
+
/**
* Returns the Y2 coordinate
- *
+ *
* @return the Y2 coordinate
*/
public int getY2() {
return y2;
}
-
+
/**
* Sets the Y2 coordinate
- *
+ *
* @param y2 the Y2 coordinate
*/
public void setY2(int y2) {
this.y2 = y2;
}
-
+
/**
* Returns the line thickness
- *
+ *
* @return the line thickness
*/
public int getThickness() {
return thickness;
}
-
+
/**
* Sets the line thickness
- *
+ *
* @param thickness the line thickness
*/
public void setThickness(int thickness) {
this.thickness = thickness;
}
-
+
/**
* Returns line color
- *
+ *
* @return the line color
*/
public Color getColor() {
return color;
}
-
+
/**
* Sets the line color
- *
+ *
* @param color the line color
*/
public void setColor(Color color) {
this.color = color;
}
-
+
/**
* Returns line orientation
- *
+ *
* @return the line orientation
*/
public int getOrientation() {
return orientation;
}
-
+
/**
* Sets the orientation
- *
+ *
* @param orientation the orientation
*/
public void setOrientation(int orientation) {
this.orientation = orientation;
}
-
+
/** {@inheritDoc} */
public String toString() {
- return "LineDataInfo{"
- + ", x1=" + x1
+ return "LineDataInfo{x1=" + x1
+ ", y1=" + y1
+ ", x2=" + x2
+ ", y2=" + y2
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java Wed Aug 27 05:35:44 2008
@@ -31,14 +31,18 @@
protected int[] coords = null;
/**
+ * Constructor
+ *
* @param coords the x/y coordinates for this object
*/
public AbstractGraphicsCoord(int[] coords) {
this.coords = coords;
prepareData();
}
-
+
/**
+ * Constructor
+ *
* @param x the x coordinate for this object
* @param y the y coordinate for this object
*/
@@ -47,6 +51,8 @@
}
/**
+ * Constructor
+ *
* @param x1 the x1 coordinate for this object
* @param y1 the y1 coordinate for this object
* @param x2 the x2 coordinate for this object
@@ -57,13 +63,17 @@
}
/**
+ * Returns the order code to use
+ *
* @return the order code to use
*/
protected abstract byte getOrderCode();
/**
+ * Returns the length of this order code (typically this is the same as the coordinate length)
+ *
* @return the length of this order code
- * (typically this is the same as the coordinate length)
+ *
*/
protected int getLength() {
return this.coords.length * 2;
@@ -71,6 +81,7 @@
/**
* Creates a newly created and initialized byte data
+ *
* @return a newly created and initialized byte data
*/
protected byte[] createData() {
@@ -81,9 +92,7 @@
return data;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = createData();
int fromIndex = data.length - getLength();
@@ -92,6 +101,7 @@
/**
* Adds the coordinates to the structured field data
+ *
* @param data the structured field data
* @param fromIndex the start index
*/
@@ -100,11 +110,13 @@
for (int i = 0; i < coords.length; i++, fromIndex += 2) {
byte[] coord = BinaryUtils.convert(coords[i], 2);
data[fromIndex] = coord[0];
- data[fromIndex + 1] = coord[1];
+ data[fromIndex + 1] = coord[1];
}
}
-
+
/**
+ * Returns the short name of this GOCA object
+ *
* @return the short name of this GOCA object
*/
public String getName() {
@@ -112,16 +124,14 @@
return className.substring(className.lastIndexOf(".") + 1);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
String coordsStr = "";
for (int i = 0; i < coords.length; i++) {
coordsStr += (i % 2 == 0) ? "x" : "y";
- coordsStr += (i / 2) + "=" + coords[i] + ",";
+ coordsStr += (i / 2) + "=" + coords[i] + ",";
}
coordsStr = coordsStr.substring(0, coordsStr.length() - 1);
- return getName() + "(" + coordsStr + ")";
- }
+ return getName() + "{" + coordsStr + "}";
+ }
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java Wed Aug 27 05:35:44 2008
@@ -29,44 +29,39 @@
*/
public final class GraphicsArea extends AbstractPreparedObjectContainer {
+ private static final int RES1 = 1;
+ private static final int BOUNDARY = 2;
+ private static final int NO_BOUNDARY = 0;
+
/** draw boundary lines around this area */
private boolean drawBoundary = false;
-
+
/**
* Sets whether boundary lines are drawn
+ *
* @param drawBoundaryLines whether boundary lines are drawn
*/
public void setDrawBoundaryLines(boolean drawBoundaryLines) {
this.drawBoundary = drawBoundaryLines;
}
-
- private static final int RES1 = 1;
- private static final int BOUNDARY = 2;
- private static final int NO_BOUNDARY = 0;
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public int getDataLength() {
// start len + end len + data len
return 4 + super.getDataLength();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
super.writeStart(os);
byte[] data = new byte[] {
(byte)0x68, // GBAR order code
- (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY))
+ (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY))
};
os.write(data);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void writeEnd(OutputStream os) throws IOException {
byte[] endData = new byte[] {
(byte)0x60, // GEAR order code
@@ -75,10 +70,8 @@
os.write(endData);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
- return "GraphicsArea";
+ return "GraphicsArea{drawBoundary=" + drawBoundary + "}";
}
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java Wed Aug 27 05:35:44 2008
@@ -25,42 +25,37 @@
public final class GraphicsBox extends AbstractGraphicsCoord {
/**
+ * Constructor
+ *
* @param coords the x/y coordinates for this object
*/
public GraphicsBox(int[] coords) {
super(coords);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
return (byte)0xC0;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
protected int getLength() {
return 10;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = createData();
final int fromIndex = 4;
addCoords(data, fromIndex);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte[] createData() {
byte[] data = super.createData();
data[2] = (byte)0x20; // CONTROL draw control flags
data[3] = 0x00; // reserved
return data;
}
+
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java Wed Aug 27 05:35:44 2008
@@ -45,7 +45,7 @@
/**
* Main constructor
- *
+ *
* @param name
* the name of this graphics segment
*/
@@ -55,7 +55,7 @@
/**
* Constructor
- *
+ *
* @param name
* the name of this graphics segment
* @param previous
@@ -80,21 +80,23 @@
return dataLen;
}
- /** {@inheritDoc} */
- protected int getNameLength() {
- return 4;
- }
-
private static final byte APPEND_NEW_SEGMENT = 0;
// private static final byte PROLOG = 4;
// private static final byte APPEND_TO_EXISING = 48;
+ private static final int NAME_LENGTH = 4;
+
+ /** {@inheritDoc} */
+ protected int getNameLength() {
+ return NAME_LENGTH;
+ }
+
/** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
super.writeStart(os);
int len = super.getDataLength();
byte[] segLen = BinaryUtils.convert(len, 2);
-
+
byte[] nameBytes = getNameBytes();
byte[] data = new byte[] {
0x70, // BEGIN_SEGMENT
@@ -115,7 +117,7 @@
// P/S NAME (predecessor name)
if (previous != null) {
nameBytes = previous.getNameBytes();
- System.arraycopy(nameBytes, 0, data, 10, 4);
+ System.arraycopy(nameBytes, 0, data, 10, NAME_LENGTH);
}
os.write(data);
}
@@ -126,7 +128,7 @@
if (previous == null) {
GraphicsChainedSegment current = this.next;
while (current != null) {
- current.write(os);
+ current.writeToStream(os);
current = current.next;
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java Wed Aug 27 05:35:44 2008
@@ -30,28 +30,20 @@
/**
* A GOCA graphics data
*/
-public final class GraphicsData extends AbstractPreparedObjectContainer {
-
- /**
- * The maximum graphics data length
- */
+public final class GraphicsData extends AbstractPreparedObjectContainer {
+
+ /** The maximum graphics data length */
public static final int MAX_DATA_LEN = 32767;
- /**
- * The graphics segment
- */
+ /** The graphics segment */
private GraphicsChainedSegment currentSegment = null;
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public int getDataLength() {
return 8 + super.getDataLength();
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
super.writeStart(os);
int l = getDataLength();
@@ -76,7 +68,7 @@
public void beginArea() {
getSegment().beginArea();
}
-
+
/**
* Ends a graphics area (end of fill)
*/
@@ -86,16 +78,18 @@
/**
* Returns a new segment name
+ *
* @return a new segment name
*/
private String createSegmentName() {
return StringUtils.lpad(String.valueOf(
(super.objects != null ? super.objects.size() : 0) + 1),
- '0', 4);
+ '0', 4);
}
-
+
/**
* Returns the current graphics segment, creating one if one does not exist
+ *
* @return the current graphics chained segment
*/
private GraphicsChainedSegment getSegment() {
@@ -107,24 +101,23 @@
/**
* Creates a new graphics segment
+ *
* @return a newly created graphics segment
*/
public GraphicsChainedSegment newSegment() {
String name = createSegmentName();
if (currentSegment == null) {
- this.currentSegment = new GraphicsChainedSegment(name);
+ this.currentSegment = new GraphicsChainedSegment(name);
} else {
- this.currentSegment = new GraphicsChainedSegment(name, currentSegment);
+ this.currentSegment = new GraphicsChainedSegment(name, currentSegment);
}
super.addObject(currentSegment);
return currentSegment;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) {
- if (currentSegment == null
+ if (currentSegment == null
|| (currentSegment.getDataLength() + drawingOrder.getDataLength())
>= GraphicsChainedSegment.MAX_DATA_LEN) {
newSegment();
@@ -132,10 +125,8 @@
currentSegment.addObject(drawingOrder);
return drawingOrder;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public String toString() {
return "GraphicsData";
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,18 +24,19 @@
* straight lines drawn from the given position or current position
*/
public final class GraphicsFillet extends AbstractGraphicsCoord {
-
+
/**
+ * Constructor
+ *
* @param coords the x/y coordinates for this object
*/
public GraphicsFillet(int[] coords) {
super(coords);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
return (byte)0xC5;
}
+
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,12 +26,14 @@
*/
public class GraphicsFullArc extends AbstractGraphicsCoord {
/** the integer portion of the multiplier */
- private int mh;
-
+ private final int mh;
+
/** the fractional portion of the multiplier */
- private int mhr;
-
+ private final int mhr;
+
/**
+ * Constructor
+ *
* @param x the x coordinate of the center of the circle/ellipse
* @param y the y coordinate of the center of the circle/ellipse
* @param mh the integer portion of the multiplier
@@ -44,38 +46,33 @@
// integer portion of multiplier
data[data.length - 2] = BinaryUtils.convert(mh, 1)[0];
// fractional portion of multiplier
- data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0];
+ data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0];
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
return (byte)0xC7;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected int getLength() {
return super.getLength() + 2;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = super.createData();
final int fromIndex = 2;
super.addCoords(data, fromIndex);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
- return super.getName()
- + "(centerx=" + coords[0] + ",centery=" + coords[1]
- + ",mh=" + mh + ",mhr=" + mhr + ")";
+ return "GraphicsFullArc{"
+ + ", centerx=" + coords[0]
+ + ", centery=" + coords[1]
+ + ", mh=" + mh
+ + ", mhr=" + mhr
+ + "}";
}
}
\ No newline at end of file
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.goca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractStructuredAFPObject;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * A GOCA Image
+ */
+public class GraphicsImage extends AbstractStructuredAFPObject {
+
+ /** x coordinate */
+ private final int x;
+
+ /** y coordinate */
+ private final int y;
+
+ /** width */
+ private final int width;
+
+ /** height */
+ private final int height;
+
+ /** image data */
+ private final byte[] imageData;
+
+ /**
+ * Main constructor
+ *
+ * @param x the x coordinate of the image
+ * @param y the y coordinate of the image
+ * @param width the image width
+ * @param height the image height
+ * @param imageData the image data
+ */
+ public GraphicsImage(int x, int y, int width, int height, byte[] imageData) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ this.imageData = imageData;
+ }
+
+ /** {@inheritDoc} */
+ protected void writeStart(OutputStream os) throws IOException {
+ byte[] xcoord = BinaryUtils.convert(x, 2);
+ byte[] ycoord = BinaryUtils.convert(y, 2);
+ byte[] w = BinaryUtils.convert(width, 2);
+ byte[] h = BinaryUtils.convert(height, 2);
+ byte[] data = new byte[] {
+ (byte) 0xD1, // GBIMG order code
+ (byte) 0x0A, // LENGTH
+ xcoord[0],
+ xcoord[1],
+ ycoord[0],
+ ycoord[1],
+ 0x00, // FORMAT
+ 0x00, // RES
+ w[0], // WIDTH
+ w[1], //
+ h[0], // HEIGHT
+ h[1] //
+ };
+ os.write(data);
+ }
+
+ /** the maximum image data length */
+ public static final short MAX_DATA_LEN = 255;
+
+ /** {@inheritDoc} */
+ protected void writeContent(OutputStream os) throws IOException {
+ byte[] dataHeader = new byte[] {
+ (byte) 0x92 // GIMD
+ };
+ final int lengthOffset = 1;
+ writeChunksToStream(imageData, dataHeader, lengthOffset, MAX_DATA_LEN, os);
+ }
+
+ /** {@inheritDoc} */
+ protected void writeEnd(OutputStream os) throws IOException {
+ byte[] data = new byte[] {
+ (byte) 0x93, // GEIMG order code
+ 0x00 // LENGTH
+ };
+ os.write(data);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "GraphicsImage{x=" + x
+ + ", y=" + y
+ + ", width=" + width
+ + ", height=" + height
+ + "}";
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java Wed Aug 27 05:35:44 2008
@@ -27,16 +27,17 @@
public class GraphicsLine extends AbstractGraphicsCoord {
/**
+ * Constructor
+ *
* @param coords the x/y coordinates for this object
*/
public GraphicsLine(int[] coords) {
super(coords);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
- return (byte)0xC1;
+ return (byte)0xC1;
}
+
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java Wed Aug 27 05:35:44 2008
@@ -25,6 +25,8 @@
public class GraphicsSetArcParameters extends AbstractGraphicsCoord {
/**
+ * Constructor
+ *
* @param xmaj x coordinate of the major axis point
* @param ymin y coordinate of the minor axis point
* @param xmin x coordinate of the minor axis point
@@ -34,20 +36,16 @@
super(xmaj, ymin, xmin, ymaj);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
return 0x22;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public String toString() {
- return getName() + "(xmaj=" + coords[0]
+ return getName() + "{xmaj=" + coords[0]
+ ",ymin=" + coords[1]
+ ",xmin=" + coords[2]
- + ",ymaj=" + coords[3] + ")";
+ + ",ymaj=" + coords[3] + "}";
}
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java Wed Aug 27 05:35:44 2008
@@ -23,11 +23,12 @@
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
- * Sets the current character set (font) to be used for following graphics strings
+ * Sets the current character set (font) to be used for following graphics strings
*/
public class GraphicsSetCharacterSet extends AbstractPreparedAFPObject {
+
/** font character set reference */
- private int fontReference;
+ private final int fontReference;
/**
* @param fontReference character set font reference
@@ -37,9 +38,7 @@
prepareData();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = new byte[] {
0x38, // GSCS order code
@@ -47,9 +46,7 @@
};
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
return "GraphicsSetCharacterSet(" + fontReference + ")";
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java Wed Aug 27 05:35:44 2008
@@ -26,15 +26,15 @@
public class GraphicsSetCurrentPosition extends AbstractGraphicsCoord {
/**
+ * Constructor
+ *
* @param coords the x/y coordinates for this object
*/
public GraphicsSetCurrentPosition(int[] coords) {
super(coords);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected byte getOrderCode() {
return (byte)0x21;
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,64 +25,62 @@
* Sets the value of the current line type attribute when stroking GOCA shapes (structured fields)
*/
public class GraphicsSetLineType extends AbstractPreparedAFPObject {
+
/** the default line type */
- public static final byte DEFAULT = 0x00; // normally SOLID
+ public static final byte DEFAULT = 0x00; // normally SOLID
/** the default line type */
- public static final byte DOTTED = 0x01;
+ public static final byte DOTTED = 0x01;
/** short dashed line type */
- public static final byte SHORT_DASHED = 0x02;
+ public static final byte SHORT_DASHED = 0x02;
/** dashed dotted line type */
- public static final byte DASH_DOT = 0x03;
+ public static final byte DASH_DOT = 0x03;
/** double dotted line type */
- public static final byte DOUBLE_DOTTED = 0x04;
+ public static final byte DOUBLE_DOTTED = 0x04;
/** long dashed line type */
- public static final byte LONG_DASHED = 0x05;
+ public static final byte LONG_DASHED = 0x05;
/** dash double dotted line type */
- public static final byte DASH_DOUBLE_DOTTED = 0x06;
+ public static final byte DASH_DOUBLE_DOTTED = 0x06;
/** solid line type */
- public static final byte SOLID = 0x07;
+ public static final byte SOLID = 0x07;
/** invisible line type */
public static final byte INVISIBLE = 0x08;
-
+
/** line type */
private byte type = DEFAULT;
-
+
/**
* Main constructor
+ *
* @param type line type
*/
public GraphicsSetLineType(byte type) {
this.type = type;
prepareData();
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = new byte[] {
0x18, // GSLW order code
type // line type
};
}
-
+
private static final String[] TYPES = {
- "DEFAULT", "DOTTED", "SHORT_DASHED", "DASH_DOT", "DOUBLE_DOTTED",
- "LONG_DASHED", "DASH_DOUBLE_DOTTED", "SOLID", "INVISIBLE"
+ "default (solid)", "dotted", "short dashed", "dash dotted", "double dotted",
+ "long dashed", "dash double dotted", "solid", "invisible"
};
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String toString() {
- return "GraphicsSetLineType(type=" + TYPES[type] + ")";
+ return "GraphicsSetLineType{type=" + TYPES[type] + "}";
}
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java Wed Aug 27 05:35:44 2008
@@ -30,6 +30,7 @@
/**
* Main constructor
+ *
* @param multiplier the line width multiplier
*/
public GraphicsSetLineWidth(int multiplier) {
@@ -37,20 +38,16 @@
prepareData();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = new byte[] {
0x19, // GSLW order code
(byte)multiplier // MH (line-width)
};
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public String toString() {
- return "GraphicsSetLineWidth(multiplier=" + multiplier + ")";
+ return "GraphicsSetLineWidth{multiplier=" + multiplier + "}";
}
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java Wed Aug 27 05:35:44 2008
@@ -66,7 +66,7 @@
/** diagonal lines, top left to bottom right 2 */
public static final byte DIAGONAL_LINES_TLBR_2 = 0x0E;
-
+
/** no fill */
public static final byte NO_FILL = 0x0F;
@@ -75,12 +75,13 @@
/** blank (same as no fill) */
public static final byte BLANK = 0x40; // processed same as NO_FILL
-
+
/** the graphics pattern symbol to use */
- private byte symbol;
+ private final byte symbol;
/**
* Main constructor
+ *
* @param symb the pattern symbol to use
*/
public GraphicsSetPatternSymbol(byte symb) {
@@ -88,19 +89,15 @@
prepareData();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
super.data = new byte[] {
0x28, // GSPT order code
symbol
};
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public String toString() {
return "GraphicsSetPatternSymbol(fill="
+ (symbol == SOLID_FILL ? true : false) + ")";
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java Wed Aug 27 05:35:44 2008
@@ -30,10 +30,11 @@
*/
public class GraphicsSetProcessColor extends AbstractPreparedAFPObject {
/** the color to set */
- private Color col;
+ private final Color col;
/**
* Main constructor
+ *
* @param col the color to set
*/
public GraphicsSetProcessColor(Color col) {
@@ -41,9 +42,7 @@
prepareData();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void prepareData() {
// COLSPCE
byte colspace;
@@ -56,7 +55,7 @@
GraphicsObject.log.error("unsupported colorspace " + colSpaceType);
colspace = 0x01;
}
-
+
// COLSIZE(S)
float[] colcomp = col.getColorComponents(null);
byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00};
@@ -66,7 +65,7 @@
int len = 10 + colcomp.length;
super.data = new byte[len + 2];
- data[0] = (byte)0xB2; // GSPCOL order code
+ data[0] = (byte)0xB2; // GSPCOL order code
data[1] = (byte)len; // LEN
data[2] = 0x00; // reserved; must be zero
data[3] = colspace; // COLSPCE
@@ -83,10 +82,8 @@
data[i + 12] = (byte)(colcomp[i] * 255);
}
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public String toString() {
return "GraphicsSetProcessColor(col=" + col + ")";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org