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 ma...@apache.org on 2006/04/27 17:08:24 UTC
svn commit: r397562 [3/6] - in /xmlgraphics/fop/trunk/src/sandbox:
META-INF/services/ org/apache/fop/render/afp/
org/apache/fop/render/afp/apps/ org/apache/fop/render/afp/exceptions/
org/apache/fop/render/afp/extensions/ org/apache/fop/render/afp/fonts...
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.fonts;
+
+import java.util.HashMap;
+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.exceptions.FontRuntimeException;
+
+/**
+ * A font where each character is stored as an array of pixels (a bitmap). Such
+ * fonts are not easily scalable, in contrast to vectored fonts. With this type
+ * of font, the font metrics information is held in character set files (one for
+ * each size and style). <p/>
+ *
+ */
+public class RasterFont extends AFPFont {
+
+ /** Static logging instance */
+ protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.fonts");
+
+ private HashMap _characterSets = new HashMap();
+
+ private CharacterSet _characterSet = null;
+
+ /**
+ * Constructor for the raster font requires the name, weight and style
+ * attribute to be available as this forms the key to the font.
+ *
+ * @param name
+ * the name of the font
+ */
+ public RasterFont(String name) {
+ super(name);
+ }
+
+ public void addCharacterSet(int size, CharacterSet characterSet) {
+
+ _characterSets.put(String.valueOf(size), characterSet);
+
+ _characterSet = characterSet;
+
+ }
+
+ /**
+ * Get the character set metrics for the specified point size.
+ *
+ * @param size the point size
+ * @return the character set metrics
+ */
+ public CharacterSet getCharacterSet(int size) {
+
+ String pointsize = String.valueOf(size / 1000);
+ CharacterSet csm = (CharacterSet) _characterSets.get(pointsize);
+ if (csm == null) {
+ csm = (CharacterSet) _characterSets.get(size + "mpt");
+ }
+ if (csm == null) {
+ // Get char set with nearest font size
+ int distance = Integer.MAX_VALUE;
+ for (Iterator it = _characterSets.entrySet().iterator(); it.hasNext(); ) {
+ Map.Entry me = (Map.Entry)it.next();
+ String key = (String)me.getKey();
+ if (!key.endsWith("mpt")) {
+ int mpt = Integer.parseInt(key) * 1000;
+ if (Math.abs(size - mpt) < distance) {
+ distance = Math.abs(size - mpt);
+ pointsize = (String)me.getKey();
+ csm = (CharacterSet)me.getValue();
+ }
+ }
+ }
+ if (csm != null) {
+ _characterSets.put(size + "mpt", csm);
+ String msg = "No " + (size / 1000) + "pt font " + _name
+ + " found, substituted with " + pointsize + "pt font";
+ log.warn(msg);
+ }
+ }
+ if (csm == null) {
+ String msg = "No font found for font " + _name
+ + " with point size " + pointsize;
+ log.error(msg);
+ throw new FontRuntimeException(msg);
+ }
+ return csm;
+
+ }
+
+ /**
+ * Get the first character in this font.
+ */
+ public int getFirstChar() {
+
+ Iterator i = _characterSets.values().iterator();
+ if (i.hasNext()) {
+ CharacterSet csm = (CharacterSet) i.next();
+ return csm.getFirstChar();
+ } else {
+ String msg = "getFirstChar() - No character set found for font:" + _name;
+ log.error(msg);
+ throw new FontRuntimeException(msg);
+ }
+
+ }
+
+ /**
+ * Get the last character in this font.
+ */
+ public int getLastChar() {
+
+ Iterator i = _characterSets.values().iterator();
+ if (i.hasNext()) {
+ CharacterSet csm = (CharacterSet) i.next();
+ return csm.getLastChar();
+ } else {
+ String msg = "getLastChar() - No character set found for font:" + _name;
+ log.error(msg);
+ throw new FontRuntimeException(msg);
+ }
+
+ }
+
+ /**
+ * The ascender is the part of a lowercase letter that extends above the
+ * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also
+ * used to denote the part of the letter extending above the x-height.
+ *
+ * @param size the point size
+ */
+ public int getAscender(int size) {
+
+ return getCharacterSet(size).getAscender();
+
+ }
+
+ /**
+ * Obtains the height of capital letters for the specified point size.
+ *
+ * @param size the point size
+ */
+ public int getCapHeight(int size) {
+
+ return getCharacterSet(size).getCapHeight();
+
+ }
+
+ /**
+ * The descender is the part of a lowercase letter that extends below the
+ * base line, such as "g", "j", or "p". Also used to denote the part of the
+ * letter extending below the base line.
+ *
+ * @param size the point size
+ */
+ public int getDescender(int size) {
+
+ return getCharacterSet(size).getDescender();
+
+ }
+
+ /**
+ * The "x-height" (the height of the letter "x").
+ *
+ * @param size the point size
+ */
+ public int getXHeight(int size) {
+
+ return getCharacterSet(size).getXHeight();
+
+ }
+
+ /**
+ * Obtain the width of the character for the specified point size.
+ */
+ public int getWidth(int character, int size) {
+
+ return getCharacterSet(size).width(character);
+
+ }
+
+ /**
+ * Get the getWidth (in 1/1000ths of a point size) of all characters in this
+ * character set.
+ *
+ * @param size
+ * the point size
+ * @return the widths of all characters
+ */
+ public int[] getWidths(int size) {
+
+ return getCharacterSet(size).getWidths();
+
+ }
+
+ /**
+ * Get the getWidth (in 1/1000ths of a point size) of all characters in this
+ * character set.
+ *
+ * @return the widths of all characters
+ */
+ public int[] getWidths() {
+
+ return getWidths(1000);
+
+ }
+
+ /**
+ * Map a Unicode character to a code point in the font.
+ * @param c character to map
+ * @return the mapped character
+ */
+ public char mapChar(char c) {
+ return _characterSet.mapChar(c);
+ }
+
+ /**
+ * Get the encoding of the font.
+ * @return the encoding
+ */
+ public String getEncoding() {
+ return _characterSet.getEncoding();
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/RasterFont.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+
+/**
+ * Constants used by the AFP renderer.
+ *
+ */
+public interface AFPConstants {
+
+ /**
+ * The encoding to use to convert to EBCIDIC
+ */
+ public String EBCIDIC_ENCODING = "Cp1146";
+
+ /**
+ * The encoding to use to convert to ASCII
+ */
+ public String ASCII_ENCODING = "Cp1252";
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPConstants.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,650 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.AFPFontColor;
+import org.apache.fop.render.afp.fonts.AFPFont;
+import org.apache.fop.render.afp.tools.StringUtils;
+
+/**
+ * A data stream is a continuous ordered stream of data elements and objects
+ * conforming to a given format. Application programs can generate data streams
+ * destined for a presentation service, archive library, presentation device or
+ * another application program. The strategic presentation data stream
+ * architectures used is Mixed Object Document Content Architecture (MO:DCA�).
+ *
+ * The MO:DCA architecture defines the data stream used by applications to
+ * describe documents and object envelopes for interchange with other
+ * applications and application services. Documents defined in the MO:DCA format
+ * may be archived in a database, then later retrieved, viewed, annotated and
+ * printed in local or distributed systems environments. Presentation fidelity
+ * is accommodated by including resource objects in the documents that reference
+ * them.
+ *
+ */
+public class AFPDataStream {
+
+ /**
+ * Static logging instance
+ */
+ protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
+
+ /**
+ * Boolean completion indicator
+ */
+ private boolean _complete = false;
+
+ /**
+ * The application producing the AFP document
+ */
+ private String _producer = null;
+
+ /**
+ * The AFP document object
+ */
+ private Document _document = null;
+
+ /**
+ * The current page group object
+ */
+ private PageGroup _currentPageGroup = null;
+
+ /**
+ * The current page object
+ */
+ private PageObject _currentPageObject = null;
+
+ /**
+ * The current overlay object
+ */
+ private Overlay _currentOverlay = null;
+
+ /**
+ * The current page
+ */
+ private AbstractPageObject _currentPage = null;
+
+ /**
+ * The page count
+ */
+ private int _pageCount = 0;
+
+ /**
+ * The page group count
+ */
+ private int _pageGroupCount = 0;
+
+ /**
+ * The overlay count
+ */
+ private int _ovlCount = 0;
+
+ /**
+ * The portrait rotation
+ */
+ private int _portraitRotation = 0;
+
+ /**
+ * The landscape rotation
+ */
+ private int _landscapeRotation = 270;
+
+ /**
+ * The x offset
+ */
+ private int _xOffset = 0;
+
+ /**
+ * The y offset
+ */
+ private int _yOffset = 0;
+
+ /**
+ * The rotation
+ */
+ private int _rotation;
+
+ /**
+ * The outputstream for the data stream
+ */
+ private OutputStream _outputStream = null;
+
+ /**
+ * Default constructor for the AFPDataStream.
+ */
+ public AFPDataStream() {
+ }
+
+ /**
+ * The document is started by invoking this method which creates an instance
+ * of the AFP Document object.
+ */
+ public void startDocument(OutputStream outputStream) {
+
+ if (_document != null) {
+ String msg = "Invalid state - document already started.";
+ log.warn("startDocument():: " + msg);
+ throw new IllegalStateException(msg);
+ }
+
+ _document = new Document();
+ _outputStream = outputStream;
+
+ }
+
+ /**
+ * The document is ended by invoking this method which creates an instance
+ * of the AFP Document object and registers the start with a validation map
+ * which ensures that methods are not invoked out of the correct sequence.
+ */
+ public void endDocument()
+ throws IOException {
+
+ if (_complete) {
+ String msg = "Invalid state - document already ended.";
+ log.warn("endDocument():: " + msg);
+ throw new IllegalStateException(msg);
+ }
+
+ if (_currentPageObject != null) {
+ // End the current page if necessary
+ endPage();
+ }
+
+ if (_currentPageGroup != null) {
+ // End the current page group if necessary
+ endPageGroup();
+ }
+
+ _document.endDocument();
+ _document.writeDataStream(_outputStream);
+ _outputStream.flush();
+
+ _complete = true;
+
+ _document = null;
+
+ _outputStream = null;
+ }
+
+ /**
+ * Start a new page. When processing has finished on the current page, the
+ * {@link #endPage()}method must be invoked to mark the page ending.
+ *
+ * @param pageWidth
+ * the width of the page
+ * @param pageHeight
+ * the height of the page
+ * @param pageRotation
+ * the rotation of the page
+ */
+ public void startPage(int pageWidth, int pageHeight, int pageRotation) {
+
+ String pageName = "PGN"
+ + StringUtils.lpad(String.valueOf(_pageCount++), '0', 5);
+
+ _currentPageObject = new PageObject(pageName, pageWidth, pageHeight, pageRotation);
+ _currentPage = _currentPageObject;
+ _currentOverlay = null;
+ setOffsets(0, 0, 0);
+ }
+
+ /**
+ * Start a new overlay. When processing has finished on the current overlay, the
+ * {@link #endOverlay()}method must be invoked to mark the overlay ending.
+ *
+ * @param overlayX
+ * the x position of the overlay on the page
+ * @param overlayY
+ * the y position of the overlay on the page
+ * @param overlayWidth
+ * the width of the overlay
+ * @param overlayHeight
+ * the height of the overlay
+ * @param overlayRotation
+ * the rotation of the overlay
+ */
+ public void startOverlay(int overlayX, int overlayY, int overlayWidth, int overlayHeight, int overlayRotation) {
+
+ String overlayName = "OVL"
+ + StringUtils.lpad(String.valueOf(_ovlCount++), '0', 5);
+
+ _currentOverlay = new Overlay(overlayName, overlayWidth, overlayHeight, overlayRotation);
+ _currentPageObject.addOverlay(_currentOverlay);
+ _currentPageObject.createIncludePageOverlay(overlayName, overlayX, overlayY, 0);
+ _currentPage = _currentOverlay;
+ setOffsets(0, 0, 0);
+ }
+
+ /**
+ * Helper method to mark the end of the current overlay.
+ */
+ public void endOverlay() {
+
+ _currentOverlay.endPage();
+ _currentOverlay = null;
+ _currentPage = _currentPageObject;
+
+ }
+
+ /**
+ * Helper method to save the current page.
+ */
+ public PageObject savePage() {
+
+ PageObject pageObject = _currentPageObject;
+ if (_currentPageGroup != null) {
+ _currentPageGroup.addPage(_currentPageObject);
+ } else {
+ _document.addPage(_currentPageObject);
+ }
+ _currentPageObject = null;
+ _currentPage = null;
+ return pageObject;
+
+ }
+
+ /**
+ * Helper method to restore the current page.
+ */
+ public void restorePage(PageObject pageObject) {
+
+ _currentPageObject = pageObject;
+ _currentPage = pageObject;
+
+ }
+
+ /**
+ * Helper method to mark the end of the current page.
+ */
+ public void endPage()
+ throws IOException {
+
+ _currentPageObject.endPage();
+ if (_currentPageGroup != null) {
+ _currentPageGroup.addPage(_currentPageObject);
+ } else {
+ _document.addPage(_currentPageObject);
+ _document.writeDataStream(_outputStream);
+ }
+
+ _currentPageObject = null;
+ _currentPage = null;
+
+ }
+
+ /**
+ * Sets the offsets to be used for element positioning
+ *
+ * @param xOffset
+ * the offset in the x direction
+ * @param yOffset
+ * the offset in the y direction
+ * @param rotation
+ * the rotation
+ */
+ public void setOffsets(int xOffset, int yOffset, int rotation) {
+ _xOffset = xOffset;
+ _yOffset = yOffset;
+ _rotation = rotation;
+ }
+
+ /**
+ * Helper method to create a map coded font object on the current page, this
+ * method delegates the construction of the map coded font object to the
+ * active environment group on the current page.
+ *
+ * @param fontReference
+ * the font number used as the resource identifier
+ * @param font
+ * the font
+ * @param size
+ * the point size of the font
+ */
+ public void createFont(byte fontReference, AFPFont font, int size) {
+
+ _currentPage.createFont(fontReference, font, size);
+
+ }
+
+ /**
+ * Helper method to create text on the current page, this method delegates
+ * to the current presentation text object in order to construct the text.
+ *
+ * @param fontNumber
+ * the font number used as the resource identifier
+ * @param x
+ * the x coordinate of the text
+ * @param y
+ * the y coordinate of the text
+ * @param col
+ * the text color
+ * @param vsci
+ * The variable space character increment.
+ * @param ica
+ * The inter character adjustment.
+ * @param data
+ * the text data to create
+ */
+ public void createText(int fontNumber, int x, int y, AFPFontColor col, int vsci, int ica, byte[] data) {
+
+ _currentPage.createText(fontNumber, x + _xOffset, y + _yOffset, _rotation, col, vsci, ica, data);
+
+ }
+
+ /**
+ * Returns an ImageObject used to create an image in the datastream.
+ *
+ * @param x
+ * the x position of the image
+ * @param y
+ * the y position of the image
+ * @param w
+ * the width of the image
+ * @param h
+ * the height of the image
+ */
+ public ImageObject getImageObject(int x, int y, int w, int h) {
+
+ int xOrigin;
+ int yOrigin;
+ int width;
+ int height;
+ switch (_rotation) {
+ case 90:
+ xOrigin = _currentPage.getWidth() - y - _yOffset;
+ yOrigin = x + _xOffset;
+ width = h;
+ height = w;
+ break;
+ case 180:
+ xOrigin = _currentPage.getWidth() - x - _xOffset;
+ yOrigin = _currentPage.getHeight() - y - _yOffset;
+ width = w;
+ height = h;
+ break;
+ case 270:
+ xOrigin = y + _yOffset;
+ yOrigin = _currentPage.getHeight() - x - _xOffset;
+ width = h;
+ height = w;
+ break;
+ default:
+ xOrigin = x + _xOffset;
+ yOrigin = y + _yOffset;
+ width = w;
+ height = h;
+ break;
+ }
+ ImageObject io = _currentPage.getImageObject();
+ io.setImageViewport(xOrigin, yOrigin, width, height, _rotation);
+ return io;
+
+ }
+
+ /**
+ * Method to create a line on the current page.
+ *
+ * @param x1
+ * the first x coordinate of the line
+ * @param y1
+ * the first y coordinate of the line
+ * @param x2
+ * the second x coordinate of the line
+ * @param y2
+ * the second y coordinate of the line
+ * @param thickness
+ * the thickness of the line
+ * @param col
+ * The text color.
+ */
+ public void createLine(int x1, int y1, int x2, int y2, int thickness, AFPFontColor col) {
+
+ _currentPage.createLine(x1 + _xOffset, y1 + _yOffset, x2 + _xOffset, y2 + _yOffset, thickness, _rotation, col);
+
+ }
+
+ /**
+ * Sets the application producing the AFP.
+ *
+ * @param producer
+ * the application producing the AFP datastream
+ */
+ public void setProducer(String producer) {
+ _producer = producer;
+ }
+
+ /**
+ * This method will create shading on the page using the specified
+ * coordinates (the shading contrast is controlled via the red, green, blue
+ * parameters, by converting this to grey scale).
+ *
+ * @param x
+ * the x coordinate of the shading
+ * @param y
+ * the y coordinate of the shading
+ * @param w
+ * the width of the shaded area
+ * @param h
+ * the height of the shaded area
+ * @param red
+ * the red value
+ * @param green
+ * the green value
+ * @param blue
+ * the blue value
+ */
+ public void createShading(int x, int y, int w, int h, int red, int green,
+ int blue) {
+
+ _currentPage.createShading(x + _xOffset, y + _xOffset, w, h, red, green, blue);
+
+ }
+
+ /**
+ * Helper method which allows creation of the MPO object, via the AEG. And
+ * the IPO via the Page. (See actual object for descriptions.)
+ *
+ * @param name
+ * the name of the static overlay
+ */
+ public void createIncludePageOverlay(String name) {
+
+ _currentPageObject.createIncludePageOverlay(name, 0, 0, _rotation);
+ ActiveEnvironmentGroup aeg = _currentPageObject.getActiveEnvironmentGroup();
+ aeg.createOverlay(name);
+
+ }
+
+ /**
+ * Helper method which allows creation of the IMM object.
+ *
+ * @param name
+ * the name of the medium map
+ */
+ public void createInvokeMediumMap(String name) {
+
+ if (_currentPageGroup == null) {
+ startPageGroup();
+ }
+ _currentPageGroup.createInvokeMediumMap(name);
+
+ }
+
+ /**
+ * Creates an IncludePageSegment on the current page.
+ *
+ * @param name
+ * the name of the include page segment
+ * @param x
+ * the x coordinate for the overlay
+ * @param y
+ * the y coordinate for the overlay
+ */
+ public void createIncludePageSegment(String name, int x, int y) {
+
+ int xOrigin;
+ int yOrigin;
+ switch (_rotation) {
+ case 90:
+ xOrigin = _currentPage.getWidth() - y - _yOffset;
+ yOrigin = x + _xOffset;
+ break;
+ case 180:
+ xOrigin = _currentPage.getWidth() - x - _xOffset;
+ yOrigin = _currentPage.getHeight() - y - _yOffset;
+ break;
+ case 270:
+ xOrigin = y + _yOffset;
+ yOrigin = _currentPage.getHeight() - x - _xOffset;
+ break;
+ default:
+ xOrigin = x + _xOffset;
+ yOrigin = y + _yOffset;
+ break;
+ }
+ _currentPage.createIncludePageSegment(name, xOrigin, yOrigin);
+
+ }
+
+ /**
+ * Creates a TagLogicalElement on the current page.
+ *
+ * @param attributes
+ * the array of key value pairs.
+ */
+ public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) {
+
+ for (int i = 0; i < attributes.length; i++) {
+ String name = (String) attributes[i].getKey();
+ String value = (String) attributes[i].getValue();
+ _currentPage.createTagLogicalElement(name, value);
+ }
+
+ }
+
+ /**
+ * Creates a TagLogicalElement on the current page group.
+ *
+ * @param attributes
+ * the array of key value pairs.
+ */
+ public void createPageGroupTagLogicalElement(
+ TagLogicalElementBean[] attributes) {
+
+ for (int i = 0; i < attributes.length; i++) {
+ String name = (String) attributes[i].getKey();
+ String value = (String) attributes[i].getValue();
+ _currentPageGroup.createTagLogicalElement(name, value);
+ }
+
+ }
+
+ /**
+ * Creates a TagLogicalElement on the current page or page group
+ *
+ * @param name
+ * The tag name
+ * @param value
+ * The tag value
+ */
+ public void createTagLogicalElement(String name, String value) {
+
+ if (_currentPageGroup != null) {
+ _currentPageGroup.createTagLogicalElement(name, value);
+ } else {
+ _currentPage.createTagLogicalElement(name, value);
+ }
+
+ }
+
+ /**
+ * Start a new page group. When processing has finished on the current page
+ * group the {@link #endPageGroup()}method must be invoked to mark the page
+ * group ending.
+ *
+ * @param name
+ * the name of the page group
+ */
+ public void startPageGroup() {
+
+ String pageGroupName = "PGP"
+ + StringUtils.lpad(String.valueOf(_pageCount++), '0', 5);
+
+ _currentPageGroup = new PageGroup(pageGroupName);
+
+ }
+
+ /**
+ * Helper method to mark the end of the page group.
+ */
+ public void endPageGroup()
+ throws IOException {
+
+ _currentPageGroup.endPageGroup();
+ _document.addPageGroup(_currentPageGroup);
+ _document.writeDataStream(_outputStream);
+ _currentPageGroup = null;
+
+ }
+
+ /**
+ * Sets the rotation to be used for portrait pages, valid values are 0
+ * (default), 90, 180, 270.
+ *
+ * @param rotation
+ * The rotation in degrees.
+ */
+ public void setPortraitRotation(int rotation) {
+
+ 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");
+ }
+
+ }
+
+ /**
+ * Sets the rotation to be used for landscape pages, valid values are 0, 90,
+ * 180, 270 (default).
+ *
+ * @param rotation
+ * The rotation in degrees.
+ */
+ public void setLandscapeRotation(int rotation) {
+
+ 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");
+ }
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This is the base class for all data stream objects. Page objects are
+ * responsible for building and generating the binary datastream in an
+ * AFP format.
+ *
+ */
+public abstract class AbstractAFPObject {
+
+ /**
+ * Static logging instance
+ */
+ protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
+
+ /**
+ * DataStream objects must implement the writeDataStream()
+ * method to write its data to the given OutputStream
+ * @param os The outputsteam stream
+ * @throws java.io.IOException
+ */
+ public abstract void writeDataStream(OutputStream os) throws IOException;
+
+ /**
+ * Help method to write a set of AFPObjects to the AFP datastream.
+ * @afpObjects a list of AFPObjects
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ protected void writeObjectList(List afpObjects, OutputStream os)
+ throws IOException {
+
+ for (Iterator it = afpObjects.iterator(); it.hasNext(); ) {
+ ((AbstractAFPObject)it.next()).writeDataStream(os);
+ }
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractAFPObject.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,409 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.fop.render.afp.AFPFontColor;
+import org.apache.fop.render.afp.fonts.AFPFont;
+import org.apache.fop.render.afp.tools.StringUtils;
+
+/**
+ * Pages contain the data objects that comprise a presentation document. Each
+ * page has a set of data objects associated with it. Each page within a
+ * document is independent from any other page, and each must establish its own
+ * environment parameters.
+ *
+ * The page is the level in the document component hierarchy that is used for
+ * printing or displaying a document's content. The data objects contained in
+ * the page envelope in the data stream are presented when the page is
+ * presented. Each data object has layout information associated with it that
+ * directs the placement and orientation of the data on the page. In addition,
+ * each page contains layout information that specifies the measurement units,
+ * page width, and page depth.
+ *
+ * A page is initiated by a begin page structured field and terminated by an end
+ * page structured field. Structured fields that define objects and active
+ * environment groups or that specify attributes of the page may be encountered
+ * in page state.
+ *
+ */
+public abstract class AbstractPageObject extends AbstractNamedAFPObject {
+
+ /**
+ * The active environment group for the page
+ */
+ protected ActiveEnvironmentGroup _activeEnvironmentGroup = null;
+
+ /**
+ * The presentation text object, we only have one per page
+ */
+ private PresentationTextObject _presentationTextObject = null;
+
+ /**
+ * The list of objects within the page
+ */
+ protected List _objects = new ArrayList();
+
+ /**
+ * The list of tag logical elements
+ */
+ protected ArrayList _tagLogicalElements = new ArrayList();
+
+ /**
+ * The list of the include page segments
+ */
+ protected ArrayList _segments = new ArrayList();
+
+ /**
+ * The page width
+ */
+ private int _width;
+
+ /**
+ * The page height
+ */
+ private int _height;
+
+ /**
+ * The page rotation
+ */
+ private int _rotation = 0;
+
+ /**
+ * The page state
+ */
+ private boolean _complete = false;
+
+ /**
+ * Construct a new page object for the specified name argument, the page
+ * name should be an 8 character identifier.
+ *
+ * @param name
+ * the name of the page.
+ * @param width
+ * the width of the page.
+ * @param height
+ * the height of the page.
+ * @param rotation
+ * the rotation of the page.
+ */
+ public AbstractPageObject(String name, int width, int height, int rotation) {
+
+ super(name);
+
+ _name = name;
+
+ _rotation = rotation;
+ _width = width;
+ _height = height;
+
+ /**
+ * Every page object must have an ActiveEnvironmentGroup
+ */
+ _activeEnvironmentGroup = new ActiveEnvironmentGroup(_width, _height);
+
+ if (_rotation != 0) {
+ switch (_rotation) {
+ case 90:
+ _activeEnvironmentGroup.setPosition(_width, 0, _rotation);
+ break;
+ case 180:
+ _activeEnvironmentGroup.setPosition(_width, _height, _rotation);
+ break;
+ case 270:
+ _activeEnvironmentGroup.setPosition(0, _height, _rotation);
+ break;
+ }
+ }
+
+ /**
+ * We have a presentation text object per page
+ */
+ _presentationTextObject = new PresentationTextObject();
+ _objects.add(_presentationTextObject);
+
+ }
+
+ /**
+ * Helper method to create a map coded font object on the current page, this
+ * method delegates the construction of the map coded font object to the
+ * active environment group on the page.
+ *
+ * @param fontReference
+ * the font number used as the resource identifier
+ * @param font
+ * the font
+ * @param size
+ * the point size of the font
+ */
+ public void createFont(byte fontReference, AFPFont font, int size) {
+
+ _activeEnvironmentGroup.createFont(fontReference, font, size, 0);
+
+ }
+
+ /**
+ * Helper method to create a line on the current page, this method delegates
+ * to the presentation text object in order to construct the line.
+ *
+ * @param x1
+ * the first x coordinate of the line
+ * @param y1
+ * the first y coordinate of the line
+ * @param x2
+ * the second x coordinate of the line
+ * @param y2
+ * the second y coordinate of the line
+ * @param thickness
+ * the thickness of the line
+ * @param rotation
+ * the rotation of the line
+ * @param col
+ * The text color.
+ */
+ public void createLine(int x1, int y1, int x2, int y2, int thickness, int rotation, AFPFontColor col) {
+
+ if (_presentationTextObject == null) {
+ _presentationTextObject = new PresentationTextObject();
+ _objects.add(_presentationTextObject);
+ }
+ _presentationTextObject.createLineData(x1, y1, x2, y2, thickness, rotation, col);
+
+ }
+
+ /**
+ * Helper method to create text on the current page, this method delegates
+ * to the presentation text object in order to construct the text.
+ *
+ * @param fontNumber
+ * the font number used as the resource identifier
+ * @param x
+ * the x coordinate of the text data
+ * @param y
+ * the y coordinate of the text data
+ * @param rotation
+ * the rotation of the text data
+ * @param col
+ * the text color
+ * @param vsci
+ * The variable space character increment.
+ * @param ica
+ * The inter character adjustment.
+ * @param data
+ * the text data to create
+ */
+ public void createText(int fontNumber, int x, int y, int rotation, AFPFontColor col, int vsci, int ica, byte[] data) {
+
+ if (_presentationTextObject == null) {
+ _presentationTextObject = new PresentationTextObject();
+ _objects.add(_presentationTextObject);
+ }
+ _presentationTextObject.createTextData(fontNumber, x, y, rotation, col, vsci, ica, data);
+
+ }
+
+ /**
+ * Helper method to mark the end of the page. This should end the control
+ * sequence on the current presenation text object.
+ */
+ public void endPage() {
+
+ _presentationTextObject.endControlSequence();
+
+ _complete = true;
+
+ }
+
+ /**
+ * This method will create shading on the page using the specified
+ * coordinates (the shading contrast is controlled via the red, green blue
+ * parameters, by converting this to grey scale).
+ *
+ * @param x
+ * the x coordinate of the shading
+ * @param y
+ * the y coordinate of the shading
+ * @param w
+ * the width of the shaded area
+ * @param h
+ * the height of the shaded area
+ * @param red
+ * the red value
+ * @param green
+ * the green value
+ * @param blue
+ * the blue value
+ */
+ public void createShading(int x, int y, int w, int h, int red, int green,
+ int blue) {
+
+ int xCoord = 0;
+ int yCoord = 0;
+ int width = 0;
+ int height = 0;
+
+ switch (_rotation) {
+ case 90:
+ xCoord = _width - y - h;
+ yCoord = x;
+ width = h;
+ height = w;
+ break;
+ case 180:
+ xCoord = _width - x - w;
+ yCoord = _height - y - h;
+ width = w;
+ height = h;
+ break;
+ case 270:
+ xCoord = y;
+ yCoord = _height - x - w;
+ width = h;
+ height = w;
+ break;
+ default:
+ xCoord = x;
+ yCoord = y;
+ width = w;
+ height = h;
+ break;
+ }
+
+ // Convert the color to grey scale
+ float shade = (float) ((red * 0.3) + (green * 0.59) + (blue * 0.11));
+
+ int greyscale = Math.round((shade / 255) * 16);
+
+ String imageName = "IMG"
+ + StringUtils.lpad(String.valueOf(_objects.size() + 1),
+ '0', 5);
+
+ IMImageObject io = new IMImageObject(imageName);
+ ImageOutputControl ioc = new ImageOutputControl(0, 0);
+ ImageInputDescriptor iid = new ImageInputDescriptor();
+ ImageCellPosition icp = new ImageCellPosition(xCoord, yCoord);
+ icp.setXFillSize(width);
+ icp.setYFillSize(height);
+ icp.setXSize(64);
+ icp.setYSize(8);
+
+ //defing this as a resource
+ ImageRasterData ird = new ImageRasterData(ImageRasterPattern
+ .getRasterData(greyscale));
+
+ io.setImageOutputControl(ioc);
+ io.setImageInputDescriptor(iid);
+ io.setImageCellPosition(icp);
+ io.setImageRasterData(ird);
+ _objects.add(io);
+
+ }
+
+ /**
+ * Helper method to create an image on the current page and to return
+ * the object.
+ */
+ public ImageObject getImageObject() {
+
+ if (_presentationTextObject != null) {
+ _presentationTextObject.endControlSequence();
+ }
+ _presentationTextObject = null;
+
+ String imageName = "IMG"
+ + StringUtils.lpad(String.valueOf(_objects.size() + 1),
+ '0', 5);
+
+ ImageObject io = new ImageObject(imageName);
+ _objects.add(io);
+ return io;
+ }
+
+ /**
+ * Creates a TagLogicalElement on the page.
+ *
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
+ */
+ public void createTagLogicalElement(String name, String value) {
+
+ TagLogicalElement tle = new TagLogicalElement(name, value);
+ _tagLogicalElements.add(tle);
+
+ }
+
+ /**
+ * Creates an IncludePageSegment on the current page.
+ *
+ * @param name
+ * the name of the page segment
+ * @param xCoor
+ * the x cooridinate of the page segment.
+ * @param yCoor
+ * the y cooridinate of the page segment.
+ */
+ public void createIncludePageSegment(String name, int xCoor, int yCoor) {
+
+ IncludePageSegment ips = new IncludePageSegment(name, xCoor, yCoor);
+ _segments.add(ips);
+
+ }
+
+ /**
+ * Returns the ActiveEnvironmentGroup associated with this page.
+ *
+ * @return the ActiveEnvironmentGroup object
+ */
+ public ActiveEnvironmentGroup getActiveEnvironmentGroup() {
+ return _activeEnvironmentGroup;
+ }
+
+ /**
+ * Returns an indication if the page is complete
+ */
+ public boolean isComplete() {
+ return _complete;
+ }
+
+ /**
+ * Returns the height of the page
+ */
+ public int getHeight() {
+ return _height;
+ }
+
+ /**
+ * Returns the width of the page
+ */
+ public int getWidth() {
+ return _width;
+ }
+
+ /**
+ * Returns the rotation of the page
+ */
+ public int getRotation() {
+ return _rotation;
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,345 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import org.apache.fop.render.afp.fonts.AFPFont;
+
+/**
+ * An Active Environment Group (AEG) is associated with each page,
+ * and is contained in the page's begin-end envelope in the data stream.
+ * The active environment group contains layout and formatting information
+ * that defines the measurement units and size of the page, and may contain
+ * resource information.
+ *
+ * Any objects that are required for page presentation and that are to be
+ * treated as resource objects must be mapped with a map structured field
+ * in the AEG. The scope of an active environment group is the scope of its
+ * containing page or overlay.
+ *
+ */
+public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
+
+ /**
+ * Default name for the active environment group
+ */
+ private static final String DEFAULT_NAME = "AEG00001";
+
+ /**
+ * The collection of MapCodedFont objects
+ */
+ private ArrayList _mapCodedFonts = new ArrayList();
+
+ /**
+ * The Object Area Descriptor for the active environment group
+ */
+ private ObjectAreaDescriptor _objectAreaDescriptor = null;
+
+ /**
+ * The Object Area Position for the active environment group
+ */
+ private ObjectAreaPosition _objectAreaPosition = null;
+
+ /**
+ * The PresentationTextDescriptor for the active environment group
+ */
+ private PresentationTextDescriptor _presentationTextDataDescriptor = null;
+
+ /**
+ * The PageDescriptor for the active environment group
+ */
+ private PageDescriptor _pageDescriptor = null;
+
+ /**
+ * The collection of MapPageOverlay objects
+ */
+ private ArrayList _mapPageOverlays = new ArrayList();
+
+ /**
+ * Default constructor for the ActiveEnvironmentGroup.
+ * @param width the page width
+ * @param height the page height
+ */
+ public ActiveEnvironmentGroup(int width, int height) {
+
+ this(DEFAULT_NAME, width, height);
+
+ }
+
+ /**
+ * Constructor for the ActiveEnvironmentGroup, this takes a
+ * name parameter which must be 8 characters long.
+ * @param name the active environment group name
+ * @param width the page width
+ * @param height the page height
+ */
+ public ActiveEnvironmentGroup(String name, int width, int height) {
+
+ super(name);
+
+ // Create PageDescriptor
+ _pageDescriptor = new PageDescriptor(width, height);
+
+ // Create ObjectAreaDescriptor
+ _objectAreaDescriptor = new ObjectAreaDescriptor(width, height);
+
+ // Create PresentationTextDataDescriptor
+ _presentationTextDataDescriptor =
+ new PresentationTextDescriptor(width, height);
+
+ }
+
+ /**
+ * Set the position of the object area
+ * @param x the x offset
+ * @param y the y offset
+ * @param rotation the rotation
+ */
+ public void setPosition(int x, int y, int rotation) {
+
+ // Create ObjectAreaPosition
+ _objectAreaPosition = new ObjectAreaPosition(x, y, rotation);
+
+ }
+
+ /**
+ * Accessor method to obtain the PageDescriptor object of the
+ * active environment group.
+ * @return the page descriptor object
+ */
+ public PageDescriptor getPageDescriptor() {
+
+ return _pageDescriptor;
+
+ }
+
+ /**
+ * Accessor method to obtain the PresentationTextDataDescriptor object of
+ * the active environment group.
+ * @return the presentation text descriptor
+ */
+ public PresentationTextDescriptor getPresentationTextDataDescriptor() {
+
+ return _presentationTextDataDescriptor;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the active environment group.
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ writeObjectList(_mapCodedFonts, os);
+
+ writeObjectList(_mapPageOverlays, os);
+
+ _pageDescriptor.writeDataStream(os);
+
+ if (_objectAreaDescriptor != null && _objectAreaPosition != null) {
+ _objectAreaDescriptor.writeDataStream(os);
+ _objectAreaPosition.writeDataStream(os);
+ }
+
+ _presentationTextDataDescriptor.writeDataStream(os);
+
+ writeEnd(os);
+
+ }
+
+ /**
+ * Helper method to write the start of the active environment group.
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA8; // Structured field id byte 2
+ data[5] = (byte) 0xC9; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the active environment group.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA9; // Structured field id byte 2
+ data[5] = (byte) 0xC9; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Method to create a map coded font object
+ * @param fontReference the font number used as the resource identifier
+ * @param font the font
+ * @param size the point size of the font
+ * @param orientation the orientation of the font (e.g. 0, 90, 180, 270)
+ */
+ public void createFont(
+ byte fontReference,
+ AFPFont font,
+ int size,
+ int orientation) {
+
+ MapCodedFont mcf = getCurrentMapCodedFont();
+
+ if (mcf == null) {
+ mcf = new MapCodedFont();
+ _mapCodedFonts.add(mcf);
+ }
+
+ try {
+
+ mcf.addFont(
+ fontReference,
+ font,
+ size,
+ orientation);
+
+ } catch (MaximumSizeExceededException msee) {
+
+ mcf = new MapCodedFont();
+ _mapCodedFonts.add(mcf);
+
+ try {
+
+ mcf.addFont(
+ fontReference,
+ font,
+ size,
+ orientation);
+
+ } catch (MaximumSizeExceededException ex) {
+
+ // Should never happen (but log just in case)
+ log.error("createFont():: resulted in a MaximumSizeExceededException");
+
+ }
+
+ }
+
+ }
+
+ /**
+ * Actually creates the MPO object.
+ * Also creates the supporting object (an IPO)
+ * @param name the name of the overlay to be used
+ */
+ public void createOverlay(String name) {
+
+ MapPageOverlay mpo = getCurrentMapPageOverlay();
+
+ if (mpo == null) {
+ mpo = new MapPageOverlay();
+ _mapPageOverlays.add(mpo);
+ }
+
+ try {
+
+ mpo.addOverlay(name);
+
+ } catch (MaximumSizeExceededException msee) {
+ mpo = new MapPageOverlay();
+ _mapPageOverlays.add(mpo);
+ try {
+ mpo.addOverlay(name);
+ } catch (MaximumSizeExceededException ex) {
+ // Should never happen (but log just in case)
+ log.error("createOverlay():: resulted in a MaximumSizeExceededException");
+ }
+ }
+ }
+
+ /**
+ * Getter method for the most recent MapCodedFont added to the
+ * Active Environment Group (returns null if no MapCodedFonts exist)
+ * @return the most recent Map Coded Font.
+ */
+ private MapCodedFont getCurrentMapCodedFont() {
+
+ int size = _mapCodedFonts.size();
+ if (size > 0) {
+ return (MapCodedFont) _mapCodedFonts.get(_mapCodedFonts.size() - 1);
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * Getter method for the most recent MapPageOverlay added to the
+ * Active Environment Group (returns null if no MapPageOverlay exist)
+ * @return the most recent Map Coded Font
+ */
+ private MapPageOverlay getCurrentMapPageOverlay() {
+
+ int size = _mapPageOverlays.size();
+ if (size > 0) {
+ return (MapPageOverlay) _mapPageOverlays.get(
+ _mapPageOverlays.size() - 1);
+ } else {
+ return null;
+ }
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+/**
+ * The document is the highest level of the MO:DCA data-stream document
+ * component hierarchy. Documents can be made up of pages, and the pages,
+ * which are at the intermediate level, can be made up of objects. Objects
+ * are at the lowest level, and can be bar codes, graphics, images, and
+ * presentation text.
+ *
+ * At each level of the hierarchy certain sets of MO:DCA data structures,
+ * called structured fields, are permissible. The document, pages and objects
+ * are bounded by structured fields that define their beginnings and their ends.
+ * These structured fields, called begin-end pairs, provide an envelope for the
+ * data-stream components. This feature enables a processor of the data stream
+ * that is not fully compliant with the architecture to bypass those objects
+ * that are beyond its scope, and to process the data stream to the best of its
+ * abilities.
+ *
+ * A presentation document is one that has been formatted and is intended for
+ * presentation, usually on a printer or display device. A data stream containing
+ * a presentation document should produce the same document content in the
+ * same format on different printers or display devices dependent, however,
+ * on the capabilities of each of the printers or display devices. A presentation
+ * document can reference resources that are to be included as part of the
+ * document to be presented.
+ *
+ */
+public final class Document extends AbstractNamedAFPObject {
+
+ /**
+ * Ststic default name reference
+ */
+ private final static String DEFAULT_NAME = "DOC00001";
+
+ /**
+ * A list of the objects in the document
+ */
+ private ArrayList _objects = new ArrayList();
+
+ /**
+ * The document started state
+ */
+ private boolean _started = false;
+
+ /**
+ * The document completion state
+ */
+ private boolean _complete = false;
+
+ /**
+ * Default constructor for the document object.
+ */
+ public Document() {
+ this(DEFAULT_NAME);
+ }
+
+ /**
+ * Constructor for the document object.
+ * @param name The name of the document
+ */
+ public Document(String name) {
+
+ super(name);
+
+ }
+
+ /**
+ * Adds a page to the document.
+ * @param page - the Page object
+ */
+ public void addPage(PageObject page) {
+ if (!_objects.contains(page)) {
+ _objects.add(page);
+ }
+ }
+
+ /**
+ * Adds a PageGroup to the document.
+ * @param pageGroup the PageGroup object
+ */
+ public void addPageGroup(PageGroup pageGroup) {
+ _objects.add(pageGroup);
+ }
+
+ /**
+ * Method to mark the end of the page group.
+ */
+ public void endDocument() {
+
+ _complete = true;
+
+ }
+
+ /**
+ * Returns an indication if the page group is complete
+ */
+ public boolean isComplete() {
+ return _complete;
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for document.
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ if (!_started) {
+ writeStart(os);
+ _started = true;
+ }
+
+ for (Iterator it = _objects.iterator(); it.hasNext(); ) {
+ AbstractAFPObject ao = (AbstractAFPObject)it.next();
+ if (ao instanceof PageObject && ((PageObject)ao).isComplete()
+ || ao instanceof PageGroup && ((PageGroup)ao).isComplete()) {
+ ao.writeDataStream(os);
+ it.remove();
+ } else {
+ break;
+ }
+ }
+
+ if (_complete) {
+ writeEnd(os);
+ }
+
+ }
+
+ /**
+ * Helper method to write the start of the Document
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA8; // Structured field id byte 2
+ data[5] = (byte) 0xA8; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the Document.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA9; // Structured field id byte 2
+ data[5] = (byte) 0xA8; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Document.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The End Named Page Group (ENG) structured field terminates a page group that was
+ * initiated by a Begin Named Page Group structured field.
+ *
+ * Note :This object will be used to represent an ENG
+ * structured field. It is necessary as you can't end
+ * a PageGroup because you don't know where the group
+ * will end (as this is controlled by the tags in the FO).
+ * <p>
+ *
+ */
+public class EndPageGroup extends AbstractNamedAFPObject {
+
+ public EndPageGroup(String groupId) {
+
+ super(groupId);
+
+ log.debug("A ENG is being created for group: " + groupId);
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the End Page Group.
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA9; // Structured field id byte 2
+ data[5] = (byte) 0xAD; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/EndPageGroup.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * An IM image data object specifies the contents of a raster image and
+ * its placement on a page, overlay, or page segment. An IM image can be
+ * either simple or complex. A simple image is composed of one or more Image
+ * Raster Data (IRD) structured fields that define the raster pattern for the
+ * entire image. A complex image is divided into regions called image cells.
+ * Each image cell is composed of one or more IRD structured fields that define
+ * the raster pattern for the image cell, and one Image Cell Position (ICP)
+ * structured field that defines the position of the image cell relative to
+ * the origin of the entire image. Each ICP also specifies the size of the
+ * image cell and a fill rectangle into which the cell is replicated.
+ * <p/>
+ */
+public class IMImageObject extends AbstractNamedAFPObject {
+
+ /**
+ * The image output control
+ */
+ private ImageOutputControl _imageOutputControl = null;
+
+ /**
+ * The image input descriptor
+ */
+ private ImageInputDescriptor _imageInputDescriptor = null;
+
+ /**
+ * The image cell position
+ */
+ private ImageCellPosition _imageCellPosition = null;
+
+ /**
+ * The image rastor data
+ */
+ private ImageRasterData _imageRastorData = null;
+
+ /**
+ * Constructor for the image object with the specified name,
+ * the name must be a fixed length of eight characters.
+ * @param name The name of the image.
+ */
+ public IMImageObject(String name) {
+
+ super(name);
+
+ }
+
+ /**
+ * Sets the ImageOutputControl.
+ * @param imageOutputControl The imageOutputControl to set
+ */
+ public void setImageOutputControl(ImageOutputControl imageOutputControl) {
+ _imageOutputControl = imageOutputControl;
+ }
+
+ /**
+ * Sets the ImageCellPosition.
+ * @param imageCellPosition The imageCellPosition to set
+ */
+ public void setImageCellPosition(ImageCellPosition imageCellPosition) {
+ _imageCellPosition = imageCellPosition;
+ }
+
+ /**
+ * Sets the ImageInputDescriptor.
+ * @param imageInputDescriptor The imageInputDescriptor to set
+ */
+ public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) {
+ _imageInputDescriptor = imageInputDescriptor;
+ }
+
+ /**
+ * Sets the ImageRastorData.
+ * @param imageRastorData The imageRastorData to set
+ */
+ public void setImageRasterData(ImageRasterData imageRastorData) {
+ _imageRastorData = imageRastorData;
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the IM Image Objetc
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ if (_imageOutputControl != null) {
+ _imageOutputControl.writeDataStream(os);
+ }
+
+ if (_imageInputDescriptor != null) {
+ _imageInputDescriptor.writeDataStream(os);
+ }
+
+ if (_imageCellPosition != null) {
+ _imageCellPosition.writeDataStream(os);
+ }
+
+ if (_imageRastorData != null) {
+ _imageRastorData.writeDataStream(os);
+ }
+
+ writeEnd(os);
+
+ }
+
+ /**
+ * Helper method to write the start of the IM Image Object.
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA8; // Structured field id byte 2
+ data[5] = (byte) 0x7B; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the IM Image Object.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA9; // Structured field id byte 2
+ data[5] = (byte) 0x7B; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The IM Image Cell Position structured field specifies the placement,
+ * size, and replication of IM image cells.
+ */
+public class ImageCellPosition extends AbstractAFPObject {
+
+ /**
+ * Offset of image cell in X direction
+ */
+ private int _XcoSet = 0;
+
+ /**
+ * Offset of image cell in Y direction
+ */
+ private int _YcoSet = 0;
+
+ /**
+ * Size of image cell in X direction
+ */
+ private byte[] _XcSize = new byte[] { (byte)0xFF, (byte)0xFF };
+
+ /**
+ * Size of image cell in Y direction
+ */
+ private byte[] _YcSize = new byte[] { (byte)0xFF, (byte)0xFF };
+
+ /**
+ * Size of fill rectangle in X direction
+ */
+ private byte[] _XFillSize = new byte[] { (byte)0xFF, (byte)0xFF };
+
+ /**
+ * Size of fill rectangle in Y direction
+ */
+ private byte[] _YFillSize = new byte[] { (byte)0xFF, (byte)0xFF };
+
+ /**
+ * Constructor for the ImageCellPosition
+ * @param x The offset of image cell in X direction
+ * @param y The offset of image cell in Y direction
+ */
+ public ImageCellPosition(int x, int y) {
+
+ _XcoSet = x;
+ _YcoSet = y;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Cell Position
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[21];
+
+ data[0] = 0x5A;
+
+ data[1] = 0x00;
+ data[2] = 0x14;
+
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xAC;
+ data[5] = (byte) 0x7B;
+ data[6] = 0x00;
+ data[7] = 0x00;
+ data[8] = 0x00;
+
+ /**
+ * Specifies the offset along the Xp direction, in image points,
+ * of this image cell from the IM image object area origin.
+ */
+ byte[] x1 = BinaryUtils.convert(_XcoSet, 2);
+ data[9] = x1[0];
+ data[10] = x1[1];
+
+ /**
+ * Specifies the offset along the Yp direction, in image points,
+ * of this image cell from the IM image object area origin.
+ */
+ byte[] x2 = BinaryUtils.convert(_YcoSet, 2);
+ data[11] = x2[0];
+ data[12] = x2[1];
+
+ data[13] = _XcSize[0];
+ data[14] = _XcSize[1];
+
+ data[15] = _YcSize[0];
+ data[16] = _YcSize[1];
+
+ data[17] = _XFillSize[0];
+ data[18] = _XFillSize[1];
+
+ data[19] = _YFillSize[0];
+ data[20] = _YFillSize[1];
+
+ os.write(data);
+
+ }
+
+ /**
+ * Specifies the extent in the X direction, in image points,
+ * of this image cell. A value of X'FFFF' indicates that the
+ * default extent specified in bytes 28 and 29 of the Image
+ * Input Descriptor (IID) is to be used.
+ * @param xcSize The size to set.
+ */
+ public void setXSize(int xcSize) {
+
+ byte[] x = BinaryUtils.convert(xcSize, 2);
+ _XcSize[0] = x[0];
+ _XcSize[1] = x[1];
+
+ }
+
+ /**
+ * Specifies the extent of the fill rectangle in the X direction,
+ * in image points. This value can be smaller than, equal to, or
+ * larger than the image cell extent in the X direction (XCSize).
+ * A value of X'FFFF' indicates that the image cell X-extent should
+ * be used as the fill rectangle X-extent. The fill rectangle is
+ * filled in the X direction by repeating the image cell in the
+ * X direction. The image cell can be truncated to fit the rectangle.
+ * @param xFillSize The size to set.
+ */
+ public void setXFillSize(int xFillSize) {
+
+ byte[] x = BinaryUtils.convert(xFillSize, 2);
+ _XFillSize[0] = x[0];
+ _XFillSize[1] = x[1];
+
+ }
+
+ /**
+ * Specifies the extent in the Y direction, in image points,
+ * of this image cell. A value of X'FFFF' indicates that the
+ * default extent specified in bytes 30 and 31 of the Image
+ * Input Descriptor (IID) is to be used.
+ * @param ycSize The size to set.
+ */
+ public void setYSize(int ycSize) {
+
+ byte[] x = BinaryUtils.convert(ycSize, 2);
+ _YcSize[0] = x[0];
+ _YcSize[1] = x[1];
+
+ }
+
+ /**
+ * Specifies the extent of the fill rectangle in the Y direction,
+ * in image points. This value can be smaller than, equal to, or
+ * larger than the image cell extent in the Y direction (YCSize).
+ * A value of X'FFFF' indicates that the image cell Y-extent should
+ * be used as the fill rectangle Y-extent. The fill rectangle is
+ * filled in the Y direction by repeating the image cell in the
+ * Y direction. The image cell can be truncated to fit the rectangle.
+ * @param yFillSize The size to set.
+ */
+ public void setYFillSize(int yFillSize) {
+
+ byte[] x = BinaryUtils.convert(yFillSize, 2);
+ _YFillSize[0] = x[0];
+ _YFillSize[1] = x[1];
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageCellPosition.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org