Преглед изворни кода

Bugzilla #43041:

Added a configuration setting for the renderer/device resolution to the AFP renderer.
Many Checkstyle violations fixed.
Submitted by: Adrian Cumiskey <dev.at.cumiskey.com>

Changes to the patch by jeremias:
- Bugfix: SVGs were rendered in the wrong size when the target-resolution and the renderer-resolution differ.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@582131 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Jeremias Maerki пре 16 година
родитељ
комит
d2a740ec8e
27 измењених фајлова са 1160 додато и 954 уклоњено
  1. 7
    0
      src/documentation/content/xdocs/trunk/output.xml
  2. 356
    306
      src/java/org/apache/fop/render/afp/AFPRenderer.java
  3. 10
    5
      src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
  4. 230
    176
      src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
  5. 49
    0
      src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java
  6. 7
    7
      src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java
  7. 84
    74
      src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
  8. 45
    38
      src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
  9. 20
    21
      src/java/org/apache/fop/render/afp/modca/Document.java
  10. 10
    6
      src/java/org/apache/fop/render/afp/modca/EndPageGroup.java
  11. 24
    24
      src/java/org/apache/fop/render/afp/modca/IMImageObject.java
  12. 43
    40
      src/java/org/apache/fop/render/afp/modca/ImageObject.java
  13. 10
    11
      src/java/org/apache/fop/render/afp/modca/IncludeObject.java
  14. 12
    13
      src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java
  15. 15
    16
      src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java
  16. 3
    4
      src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java
  17. 43
    48
      src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
  18. 20
    17
      src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
  19. 22
    14
      src/java/org/apache/fop/render/afp/modca/Overlay.java
  20. 40
    39
      src/java/org/apache/fop/render/afp/modca/PageDescriptor.java
  21. 18
    18
      src/java/org/apache/fop/render/afp/modca/PageGroup.java
  22. 23
    18
      src/java/org/apache/fop/render/afp/modca/PageObject.java
  23. 32
    37
      src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
  24. 13
    8
      src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java
  25. 12
    10
      src/java/org/apache/fop/render/afp/modca/ResourceGroup.java
  26. 9
    4
      src/java/org/apache/fop/render/ps/PSTextPainter.java
  27. 3
    0
      status.xml

+ 7
- 0
src/documentation/content/xdocs/trunk/output.xml Прегледај датотеку

@@ -544,6 +544,13 @@ out = proc.getOutputStream();]]></source>
<font-triplet name="Courier" style="normal" weight="bold"/>
</font>]]></source>
</section>
<section id="afp-renderer-resolution-config">
<title>Output Resolution</title>
<p>By default the AFP Renderer creates output with a resolution of 240 dpi.
This can be overridden by the &lt;renderer-resolution/&gt; configuration element. Example:</p>
<source><![CDATA[
<renderer-resolution>240</renderer-resolution>]]></source>
</section>
<section id="afp-image-config">
<title>Images</title>
<p>By default the AFP Renderer converts all images to 8 bit grey level.

+ 356
- 306
src/java/org/apache/fop/render/afp/AFPRenderer.java
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 10
- 5
src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Прегледај датотеку

@@ -41,7 +41,7 @@ import org.apache.fop.util.LogUtil;
* AFP Renderer configurator
*/
public class AFPRendererConfigurator extends PrintRendererConfigurator {
/**
* Default constructor
* @param userAgent user agent
@@ -229,13 +229,18 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator {
LogUtil.handleException(log, e,
userAgent.getFactory().validateUserConfigStrictly());
}
Configuration images = cfg.getChild("images");
if (!"color".equalsIgnoreCase(images.getAttribute("mode", "b+w"))) {
afpRenderer.setBitsPerPixel(images.getAttributeAsInteger("bits-per-pixel", 8));
Configuration imagesCfg = cfg.getChild("images");
if (!"color".equalsIgnoreCase(imagesCfg.getAttribute("mode", "b+w"))) {
afpRenderer.setBitsPerPixel(imagesCfg.getAttributeAsInteger("bits-per-pixel", 8));
} else {
afpRenderer.setColorImages(true);
}
Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
if (rendererResolutionCfg != null) {
afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger(240));
}
}
}
}

+ 230
- 176
src/java/org/apache/fop/render/afp/modca/AFPDataStream.java Прегледај датотеку

@@ -34,7 +34,7 @@ import org.apache.fop.render.afp.tools.StringUtils;
* 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
@@ -42,94 +42,96 @@ import org.apache.fop.render.afp.tools.StringUtils;
* 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");
protected static Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");

/**
* Boolean completion indicator
*/
private boolean _complete = false;
private boolean complete = false;

/**
* The application producing the AFP document
*/
private String _producer = null;
// not used
// private String producer = null;

/**
* The AFP document object
*/
private Document _document = null;
private Document document = null;

/**
* The current page group object
*/
private PageGroup _currentPageGroup = null;
private PageGroup currentPageGroup = null;

/**
* The current page object
*/
private PageObject _currentPageObject = null;
private PageObject currentPageObject = null;

/**
* The current overlay object
*/
private Overlay _currentOverlay = null;
private Overlay currentOverlay = null;

/**
* The current page
*/
private AbstractPageObject _currentPage = null;
private AbstractPageObject currentPage = null;

/**
* The page count
*/
private int _pageCount = 0;
private int pageCount = 0;

/**
* The page group count
*/
private int _pageGroupCount = 0;
// not used
// private int pageGroupCount = 0;

/**
* The overlay count
*/
private int _ovlCount = 0;
private int ovlCount = 0;

/**
* The portrait rotation
*/
private int _portraitRotation = 0;
private int portraitRotation = 0;

/**
* The landscape rotation
*/
private int _landscapeRotation = 270;
private int landscapeRotation = 270;

/**
* The x offset
*/
private int _xOffset = 0;
private int xOffset = 0;

/**
* The y offset
*/
private int _yOffset = 0;
private int yOffset = 0;

/**
* The rotation
*/
private int _rotation;
private int rotation;

/**
* The outputstream for the data stream
*/
private OutputStream _outputStream = null;
private OutputStream outputStream = null;

/**
* Default constructor for the AFPDataStream.
@@ -140,17 +142,20 @@ public class AFPDataStream {
/**
* The document is started by invoking this method which creates an instance
* of the AFP Document object.
*
* @param docOutputStream
* the outputStream which the document is written to.
*/
public void startDocument(OutputStream outputStream) {
public void startDocument(OutputStream docOutputStream) {

if (_document != null) {
if (document != null) {
String msg = "Invalid state - document already started.";
log.warn("startDocument():: " + msg);
throw new IllegalStateException(msg);
}

_document = new Document();
_outputStream = outputStream;
this.document = new Document();
this.outputStream = docOutputStream;

}

@@ -158,63 +163,72 @@ public class AFPDataStream {
* 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.
*
* @throws java.io.IOException
* throws an I/O exception of some sort has occurred
*/
public void endDocument()
throws IOException {
public void endDocument() throws IOException {

if (_complete) {
if (complete) {
String msg = "Invalid state - document already ended.";
log.warn("endDocument():: " + msg);
throw new IllegalStateException(msg);
}

if (_currentPageObject != null) {
if (currentPageObject != null) {
// End the current page if necessary
endPage();
}

if (_currentPageGroup != null) {
if (currentPageGroup != null) {
// End the current page group if necessary
endPageGroup();
}

_document.endDocument();
_document.writeDataStream(_outputStream);
_outputStream.flush();
document.endDocument();
document.writeDataStream(this.outputStream);
this.outputStream.flush();

_complete = true;
complete = true;

_document = null;
document = null;

_outputStream = null;
this.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
* @param pageWidthResolution
* the width resolution of the page
* @param pageHeightResolution
* the height resolution of the page
*/
public void startPage(int pageWidth, int pageHeight, int pageRotation) {
public void startPage(int pageWidth, int pageHeight, int pageRotation,
int pageWidthResolution, int pageHeightResolution) {

String pageName = "PGN"
+ StringUtils.lpad(String.valueOf(_pageCount++), '0', 5);
+ StringUtils.lpad(String.valueOf(pageCount++), '0', 5);

_currentPageObject = new PageObject(pageName, pageWidth, pageHeight, pageRotation);
_currentPage = _currentPageObject;
_currentOverlay = null;
currentPageObject = new PageObject(pageName, pageWidth, pageHeight,
pageRotation, pageWidthResolution, pageHeightResolution);
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.
*
* 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
@@ -223,18 +237,27 @@ public class AFPDataStream {
* the width of the overlay
* @param overlayHeight
* the height of the overlay
* @param overlayWidthResolution
* the width resolution of the overlay
* @param overlayHeightResolution
* the height resolution of the overlay
* @param overlayRotation
* the rotation of the overlay
*/
public void startOverlay(int overlayX, int overlayY, int overlayWidth, int overlayHeight, int overlayRotation) {
public void startOverlay(int overlayX, int overlayY, int overlayWidth,
int overlayHeight, int overlayWidthResolution,
int overlayHeightResolution, 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;
+ StringUtils.lpad(String.valueOf(ovlCount++), '0', 5);

currentOverlay = new Overlay(overlayName, overlayWidth, overlayHeight,
overlayWidthResolution, overlayHeightResolution,
overlayRotation);
currentPageObject.addOverlay(currentOverlay);
currentPageObject.createIncludePageOverlay(overlayName, overlayX,
overlayY, 0);
currentPage = currentOverlay;
setOffsets(0, 0, 0);
}

@@ -243,79 +266,86 @@ public class AFPDataStream {
*/
public void endOverlay() {

_currentOverlay.endPage();
_currentOverlay = null;
_currentPage = _currentPageObject;
currentOverlay.endPage();
currentOverlay = null;
currentPage = currentPageObject;

}

/**
* Helper method to save the current page.
*
* @return current page object that was saved
*/
public PageObject savePage() {

PageObject pageObject = _currentPageObject;
if (_currentPageGroup != null) {
_currentPageGroup.addPage(_currentPageObject);
PageObject pageObject = currentPageObject;
if (currentPageGroup != null) {
currentPageGroup.addPage(currentPageObject);
} else {
_document.addPage(_currentPageObject);
document.addPage(currentPageObject);
}
_currentPageObject = null;
_currentPage = null;
currentPageObject = null;
currentPage = null;
return pageObject;

}

/**
* Helper method to restore the current page.
*
* @param pageObject
* page object
*/
public void restorePage(PageObject pageObject) {

_currentPageObject = pageObject;
_currentPage = pageObject;
currentPageObject = pageObject;
currentPage = pageObject;

}

/**
* Helper method to mark the end of the current page.
*
* @throws java.io.IOException
* thrown when an I/O exception of some sort has occurred
*/
public void endPage()
throws IOException {
public void endPage() throws IOException {

_currentPageObject.endPage();
if (_currentPageGroup != null) {
_currentPageGroup.addPage(_currentPageObject);
currentPageObject.endPage();
if (currentPageGroup != null) {
currentPageGroup.addPage(currentPageObject);
} else {
_document.addPage(_currentPageObject);
_document.writeDataStream(_outputStream);
document.addPage(currentPageObject);
document.writeDataStream(this.outputStream);
}

_currentPageObject = null;
_currentPage = null;
currentPageObject = null;
currentPage = null;

}

/**
* Sets the offsets to be used for element positioning
*
* @param xOffset
*
* @param xOff
* the offset in the x direction
* @param yOffset
* @param yOff
* the offset in the y direction
* @param rotation
* @param rot
* the rotation
*/
public void setOffsets(int xOffset, int yOffset, int rotation) {
_xOffset = xOffset;
_yOffset = yOffset;
_rotation = rotation;
public void setOffsets(int xOff, int yOff, int rot) {
this.xOffset = xOff;
this.yOffset = yOff;
this.rotation = rot;
}

/**
* 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
@@ -325,14 +355,14 @@ public class AFPDataStream {
*/
public void createFont(byte fontReference, AFPFont font, int size) {

_currentPage.createFont(fontReference, font, 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
@@ -348,15 +378,17 @@ public class AFPDataStream {
* @param data
* the text data to create
*/
public void createText(int fontNumber, int x, int y, Color col, int vsci, int ica, byte[] data) {
public void createText(int fontNumber, int x, int y, Color col, int vsci,
int ica, byte[] data) {

_currentPage.createText(fontNumber, x + _xOffset, y + _yOffset, _rotation, col, vsci, ica, 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
@@ -365,48 +397,65 @@ public class AFPDataStream {
* the width of the image
* @param h
* the height of the image
* @param wr
* the width resolution of the image
* @param hr
* the height resolution of the image
* @return ImageObject used to create an image in the datastream
*/
public ImageObject getImageObject(int x, int y, int w, int h) {
public ImageObject getImageObject(int x, int y, int w, int h, int wr, int hr) {

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;
int widthResolution;
int heightResolution;

switch (rotation) {
case 90:
xOrigin = currentPage.getWidth() - y - yOffset;
yOrigin = x + xOffset;
width = h;
height = w;
widthResolution = hr;
heightResolution = wr;
break;
case 180:
xOrigin = currentPage.getWidth() - x - xOffset;
yOrigin = currentPage.getHeight() - y - yOffset;
width = w;
height = h;
widthResolution = wr;
heightResolution = hr;
break;
case 270:
xOrigin = y + yOffset;
yOrigin = currentPage.getHeight() - x - xOffset;
width = h;
height = w;
widthResolution = hr;
heightResolution = wr;
break;
default:
xOrigin = x + xOffset;
yOrigin = y + yOffset;
width = w;
height = h;
widthResolution = wr;
heightResolution = hr;
break;
}
ImageObject io = _currentPage.getImageObject();
io.setImageViewport(xOrigin, yOrigin, width, height, _rotation);
ImageObject io = currentPage.getImageObject();
io.setImageViewport(xOrigin, yOrigin, width, height, rotation,
widthResolution, heightResolution);
return io;

}

/**
* Method to create a line on the current page.
*
*
* @param x1
* the first x coordinate of the line
* @param y1
@@ -420,9 +469,11 @@ public class AFPDataStream {
* @param col
* The text color.
*/
public void createLine(int x1, int y1, int x2, int y2, int thickness, Color col) {
public void createLine(int x1, int y1, int x2, int y2, int thickness,
Color col) {

_currentPage.createLine(x1 + _xOffset, y1 + _yOffset, x2 + _xOffset, y2 + _yOffset, thickness, _rotation, col);
currentPage.createLine(x1 + xOffset, y1 + yOffset, x2 + xOffset, y2
+ yOffset, thickness, rotation, col);

}

@@ -430,7 +481,7 @@ public class AFPDataStream {
* 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
@@ -447,45 +498,47 @@ public class AFPDataStream {
* the blue value
*/
public void createShading(int x, int y, int w, int h, int red, int green,
int blue) {
int blue) {

_currentPage.createShading(x + _xOffset, y + _xOffset, w, h, red, green, 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();
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) {
if (currentPageGroup == null) {
startPageGroup();
}
_currentPageGroup.createInvokeMediumMap(name);
currentPageGroup.createInvokeMediumMap(name);

}

/**
* Creates an IncludePageSegment on the current page.
*
*
* @param name
* the name of the include page segment
* @param x
@@ -497,31 +550,31 @@ public class AFPDataStream {

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;
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);
currentPage.createIncludePageSegment(name, xOrigin, yOrigin);

}

/**
* Creates a TagLogicalElement on the current page.
*
*
* @param attributes
* the array of key value pairs.
*/
@@ -530,31 +583,31 @@ public class AFPDataStream {
for (int i = 0; i < attributes.length; i++) {
String name = (String) attributes[i].getKey();
String value = (String) attributes[i].getValue();
_currentPage.createTagLogicalElement(name, value);
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) {
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);
currentPageGroup.createTagLogicalElement(name, value);
}

}

/**
* Creates a TagLogicalElement on the current page or page group
*
*
* @param name
* The tag name
* @param value
@@ -562,10 +615,10 @@ public class AFPDataStream {
*/
public void createTagLogicalElement(String name, String value) {

if (_currentPageGroup != null) {
_currentPageGroup.createTagLogicalElement(name, value);
if (currentPageGroup != null) {
currentPageGroup.createTagLogicalElement(name, value);
} else {
_currentPage.createTagLogicalElement(name, value);
currentPage.createTagLogicalElement(name, value);
}

}
@@ -573,10 +626,11 @@ public class AFPDataStream {
/**
* Creates a NoOperation item
*
* @param content byte data
* @param content
* byte data
*/
public void createNoOperation(String content) {
_currentPage.createNoOperation(content);
currentPage.createNoOperation(content);
}

/**
@@ -587,40 +641,40 @@ public class AFPDataStream {
public void startPageGroup() {

String pageGroupName = "PGP"
+ StringUtils.lpad(String.valueOf(_pageCount++), '0', 5);
+ StringUtils.lpad(String.valueOf(pageCount++), '0', 5);

_currentPageGroup = new PageGroup(pageGroupName);
currentPageGroup = new PageGroup(pageGroupName);

}

/**
* Helper method to mark the end of the page group.
* @throws IOException thrown if an I/O exception of some sort has occurred
*/
public void endPageGroup()
throws IOException {
public void endPageGroup() throws IOException {

_currentPageGroup.endPageGroup();
_document.addPageGroup(_currentPageGroup);
_document.writeDataStream(_outputStream);
_currentPageGroup = null;
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
*
* @param pageRotation
* The rotation in degrees.
*/
public void setPortraitRotation(int rotation) {
public void setPortraitRotation(int pageRotation) {

if (rotation == 0 || rotation == 90 || rotation == 180
|| rotation == 270) {
_portraitRotation = rotation;
if (pageRotation == 0 || pageRotation == 90 || pageRotation == 180
|| pageRotation == 270) {
this.portraitRotation = pageRotation;
} else {
throw new IllegalArgumentException(
"The portrait rotation must be one of the values 0, 90, 180, 270");
"The portrait rotation must be one of the values 0, 90, 180, 270");
}

}
@@ -628,18 +682,18 @@ public class AFPDataStream {
/**
* Sets the rotation to be used for landscape pages, valid values are 0, 90,
* 180, 270 (default).
*
* @param rotation
*
* @param pageRotation
* The rotation in degrees.
*/
public void setLandscapeRotation(int rotation) {
public void setLandscapeRotation(int pageRotation) {

if (rotation == 0 || rotation == 90 || rotation == 180
|| rotation == 270) {
_landscapeRotation = rotation;
if (pageRotation == 0 || pageRotation == 90 || pageRotation == 180
|| pageRotation == 270) {
this.landscapeRotation = pageRotation;
} else {
throw new IllegalArgumentException(
"The landscape rotation must be one of the values 0, 90, 180, 270");
"The landscape rotation must be one of the values 0, 90, 180, 270");
}

}

+ 49
- 0
src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java Прегледај датотеку

@@ -0,0 +1,49 @@
/*
* 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.modca;

/**
* Base class for AFP descriptor objects
*/
public abstract class AbstractDescriptor extends AbstractAFPObject {
/** width of this descriptor */
protected int width = 0;
/** height of this descriptor */
protected int height = 0;
/** width resolution of this descriptor */
protected int widthResolution = 0;
/** height resolution of this descriptor */
protected int heightResolution = 0;

/**
* Constructor a PresentationTextDescriptor for the specified
* width and height.
* @param width The width of the page.
* @param height The height of the page.
* @param widthResolution The width resolution of the page.
* @param heightResolution The height resolution of the page.
*/
public AbstractDescriptor(int width, int height, int widthResolution, int heightResolution) {
this.width = width;
this.height = height;
this.widthResolution = widthResolution;
this.heightResolution = heightResolution;
}
}

+ 7
- 7
src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java Прегледај датотеку

@@ -23,19 +23,18 @@ import java.io.UnsupportedEncodingException;
/**
* This is the base class for all named data stream objects.
* A named data stream object has an 8 byte EBCIDIC name.
*
*/
public abstract class AbstractNamedAFPObject extends AbstractAFPObject{
public abstract class AbstractNamedAFPObject extends AbstractAFPObject {
/**
* The actual name of the object
*/
protected String _name = null;
protected String name = null;
/**
* The name of the object in EBCIDIC bytes
*/
protected byte[] _nameBytes;
protected byte[] nameBytes;
/**
* Constructor for the ActiveEnvironmentGroup, this takes a
@@ -44,20 +43,21 @@ public abstract class AbstractNamedAFPObject extends AbstractAFPObject{
*/
public AbstractNamedAFPObject(String name) {
this.name = name;
if (name.length() < 8) {
name = (name + " ").substring(0, 8);
} else if (name.length() > 8) {
log.warn("Constructor:: name truncated to 8 chars"+ name);
log.warn("Constructor:: name truncated to 8 chars" + name);
name = name.substring(0, 8);
}
try {
_nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
} catch (UnsupportedEncodingException usee) {
_nameBytes = name.getBytes();
nameBytes = name.getBytes();
log.warn(
"Constructor:: UnsupportedEncodingException translating the name "
+ name);

+ 84
- 74
src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java Прегледај датотеку

@@ -20,7 +20,6 @@
package org.apache.fop.render.afp.modca;

import java.awt.Color;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

@@ -52,47 +51,47 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
/**
* The active environment group for the page
*/
protected ActiveEnvironmentGroup _activeEnvironmentGroup = null;
protected ActiveEnvironmentGroup activeEnvironmentGroup = null;

/**
* The presentation text object, we only have one per page
*/
private PresentationTextObject _presentationTextObject = null;
private PresentationTextObject presentationTextObject = null;

/**
* The list of objects within the page
*/
protected List _objects = new ArrayList();
protected List objects = new ArrayList();

/**
* The list of tag logical elements
*/
protected ArrayList _tagLogicalElements = new ArrayList();
protected ArrayList tagLogicalElements = new ArrayList();

/**
* The list of the include page segments
*/
protected ArrayList _segments = new ArrayList();
protected ArrayList segments = new ArrayList();

/**
* The page width
*/
private int _width;
private int width;

/**
* The page height
*/
private int _height;
private int height;

/**
* The page rotation
*/
private int _rotation = 0;
private int rotation = 0;

/**
* The page state
*/
private boolean _complete = false;
private boolean complete = false;

/**
* Construct a new page object for the specified name argument, the page
@@ -106,41 +105,45 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* the height of the page.
* @param rotation
* the rotation of the page.
* @param widthResolution
* the width resolution of the page.
* @param heightResolution
* the height resolution of the page.
*/
public AbstractPageObject(String name, int width, int height, int rotation) {
public AbstractPageObject(String name, int width, int height, int rotation,
int widthResolution, int heightResolution) {

super(name);

_name = name;

_rotation = rotation;
_width = width;
_height = height;
this.width = width;
this.height = height;
this.rotation = rotation;

/**
* Every page object must have an ActiveEnvironmentGroup
*/
_activeEnvironmentGroup = new ActiveEnvironmentGroup(_width, _height);
activeEnvironmentGroup = new ActiveEnvironmentGroup(width, height,
widthResolution, heightResolution);

if (_rotation != 0) {
switch (_rotation) {
if (rotation != 0) {
switch (rotation) {
case 90:
_activeEnvironmentGroup.setPosition(_width, 0, _rotation);
activeEnvironmentGroup.setPosition(width, 0, rotation);
break;
case 180:
_activeEnvironmentGroup.setPosition(_width, _height, _rotation);
activeEnvironmentGroup.setPosition(width, height, rotation);
break;
case 270:
_activeEnvironmentGroup.setPosition(0, _height, _rotation);
activeEnvironmentGroup.setPosition(0, height, rotation);
break;
default:
}
}

/**
* We have a presentation text object per page
*/
_presentationTextObject = new PresentationTextObject();
_objects.add(_presentationTextObject);
presentationTextObject = new PresentationTextObject();
objects.add(presentationTextObject);

}

@@ -158,7 +161,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
*/
public void createFont(byte fontReference, AFPFont font, int size) {

_activeEnvironmentGroup.createFont(fontReference, font, size, 0);
activeEnvironmentGroup.createFont(fontReference, font, size, 0);

}

@@ -176,18 +179,19 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* the second y coordinate of the line
* @param thickness
* the thickness of the line
* @param rotation
* @param lineRotation
* 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, Color col) {
public void createLine(int x1, int y1, int x2, int y2, int thickness,
int lineRotation, Color col) {

if (_presentationTextObject == null) {
_presentationTextObject = new PresentationTextObject();
_objects.add(_presentationTextObject);
if (presentationTextObject == null) {
presentationTextObject = new PresentationTextObject();
objects.add(presentationTextObject);
}
_presentationTextObject.createLineData(x1, y1, x2, y2, thickness, rotation, col);
presentationTextObject.createLineData(x1, y1, x2, y2, thickness, lineRotation, col);

}

@@ -201,7 +205,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* the x coordinate of the text data
* @param y
* the y coordinate of the text data
* @param rotation
* @param textRotation
* the rotation of the text data
* @param col
* the text color
@@ -212,13 +216,14 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* @param data
* the text data to create
*/
public void createText(int fontNumber, int x, int y, int rotation, Color col, int vsci, int ica, byte[] data) {
public void createText(int fontNumber, int x, int y, int textRotation, Color col,
int vsci, int ica, byte[] data) {

if (_presentationTextObject == null) {
_presentationTextObject = new PresentationTextObject();
_objects.add(_presentationTextObject);
if (presentationTextObject == null) {
presentationTextObject = new PresentationTextObject();
objects.add(presentationTextObject);
}
_presentationTextObject.createTextData(fontNumber, x, y, rotation, col, vsci, ica, data);
presentationTextObject.createTextData(fontNumber, x, y, textRotation, col, vsci, ica, data);

}

@@ -228,11 +233,11 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
*/
public void endPage() {

if (_presentationTextObject != null) {
_presentationTextObject.endControlSequence();
if (presentationTextObject != null) {
presentationTextObject.endControlSequence();
}

_complete = true;
complete = true;

}

@@ -261,33 +266,33 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {

int xCoord = 0;
int yCoord = 0;
int width = 0;
int height = 0;
int areaWidth = 0;
int areaHeight = 0;

switch (_rotation) {
switch (rotation) {
case 90:
xCoord = _width - y - h;
xCoord = areaWidth - y - h;
yCoord = x;
width = h;
height = w;
areaWidth = h;
areaHeight = w;
break;
case 180:
xCoord = _width - x - w;
yCoord = _height - y - h;
width = w;
height = h;
xCoord = areaWidth - x - w;
yCoord = areaHeight - y - h;
areaWidth = w;
areaHeight = h;
break;
case 270:
xCoord = y;
yCoord = _height - x - w;
width = h;
height = w;
yCoord = areaHeight - x - w;
areaWidth = h;
areaHeight = w;
break;
default:
xCoord = x;
yCoord = y;
width = w;
height = h;
areaWidth = w;
areaHeight = h;
break;
}

@@ -297,19 +302,19 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
int greyscale = Math.round((shade / 255) * 16);

String imageName = "IMG"
+ StringUtils.lpad(String.valueOf(_objects.size() + 1),
+ 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.setXFillSize(areaWidth);
icp.setYFillSize(areaHeight);
icp.setXSize(64);
icp.setYSize(8);

//defing this as a resource
//defining this as a resource
ImageRasterData ird = new ImageRasterData(ImageRasterPattern
.getRasterData(greyscale));

@@ -317,27 +322,28 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
io.setImageInputDescriptor(iid);
io.setImageCellPosition(icp);
io.setImageRasterData(ird);
_objects.add(io);
objects.add(io);

}

/**
* Helper method to create an image on the current page and to return
* the object.
* @return the image object
*/
public ImageObject getImageObject() {

if (_presentationTextObject != null) {
_presentationTextObject.endControlSequence();
if (presentationTextObject != null) {
presentationTextObject.endControlSequence();
}
_presentationTextObject = null;
presentationTextObject = null;

String imageName = "IMG"
+ StringUtils.lpad(String.valueOf(_objects.size() + 1),
+ StringUtils.lpad(String.valueOf(objects.size() + 1),
'0', 5);

ImageObject io = new ImageObject(imageName);
_objects.add(io);
objects.add(io);
return io;
}

@@ -352,7 +358,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
public void createTagLogicalElement(String name, String value) {

TagLogicalElement tle = new TagLogicalElement(name, value);
_tagLogicalElements.add(tle);
tagLogicalElements.add(tle);

}

@@ -364,7 +370,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
public void createNoOperation(String content) {

NoOperation noOp = new NoOperation(content);
_objects.add(noOp);
objects.add(noOp);

}

@@ -381,7 +387,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
public void createIncludePageSegment(String name, int xCoor, int yCoor) {

IncludePageSegment ips = new IncludePageSegment(name, xCoor, yCoor);
_segments.add(ips);
segments.add(ips);

}

@@ -391,35 +397,39 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* @return the ActiveEnvironmentGroup object
*/
public ActiveEnvironmentGroup getActiveEnvironmentGroup() {
return _activeEnvironmentGroup;
return activeEnvironmentGroup;
}

/**
* Returns an indication if the page is complete
* @return whether this page is complete
*/
public boolean isComplete() {
return _complete;
return complete;
}

/**
* Returns the height of the page
* @return the height of the page
*/
public int getHeight() {
return _height;
return height;
}

/**
* Returns the width of the page
* @return the width of the page
*/
public int getWidth() {
return _width;
return width;
}

/**
* Returns the rotation of the page
* @return the rotation of the page
*/
public int getRotation() {
return _rotation;
return rotation;
}

}

+ 45
- 38
src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java Прегледај датотеку

@@ -20,8 +20,8 @@
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;

/**
@@ -47,41 +47,44 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
/**
* The collection of MapCodedFont objects
*/
private ArrayList _mapCodedFonts = new ArrayList();
private ArrayList mapCodedFonts = new ArrayList();

/**
* The Object Area Descriptor for the active environment group
*/
private ObjectAreaDescriptor _objectAreaDescriptor = null;
private ObjectAreaDescriptor objectAreaDescriptor = null;

/**
* The Object Area Position for the active environment group
*/
private ObjectAreaPosition _objectAreaPosition = null;
private ObjectAreaPosition objectAreaPosition = null;

/**
* The PresentationTextDescriptor for the active environment group
*/
private PresentationTextDescriptor _presentationTextDataDescriptor = null;
private PresentationTextDescriptor presentationTextDataDescriptor = null;

/**
* The PageDescriptor for the active environment group
*/
private PageDescriptor _pageDescriptor = null;
private PageDescriptor pageDescriptor = null;

/**
* The collection of MapPageOverlay objects
*/
private ArrayList _mapPageOverlays = new ArrayList();
private ArrayList mapPageOverlays = new ArrayList();

/**
* Default constructor for the ActiveEnvironmentGroup.
* @param width the page width
* @param height the page height
* @param widthResolution the page width resolution
* @param heightResolution the page height resolution
*/
public ActiveEnvironmentGroup(int width, int height) {
public ActiveEnvironmentGroup(int width, int height,
int widthResolution, int heightResolution) {

this(DEFAULT_NAME, width, height);
this(DEFAULT_NAME, width, height, widthResolution, heightResolution);

}

@@ -91,20 +94,24 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
* @param name the active environment group name
* @param width the page width
* @param height the page height
* @param widthResolution the page width resolution
* @param heightResolution the page height resolution
*/
public ActiveEnvironmentGroup(String name, int width, int height) {
public ActiveEnvironmentGroup(String name, int width, int height,
int widthResolution, int heightResolution) {

super(name);

// Create PageDescriptor
_pageDescriptor = new PageDescriptor(width, height);
pageDescriptor = new PageDescriptor(width, height, widthResolution, heightResolution);

// Create ObjectAreaDescriptor
_objectAreaDescriptor = new ObjectAreaDescriptor(width, height);
objectAreaDescriptor = new ObjectAreaDescriptor(width, height,
widthResolution, heightResolution);

// Create PresentationTextDataDescriptor
_presentationTextDataDescriptor =
new PresentationTextDescriptor(width, height);
presentationTextDataDescriptor = new PresentationTextDescriptor(width, height,
widthResolution, heightResolution);

}

@@ -117,7 +124,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
public void setPosition(int x, int y, int rotation) {

// Create ObjectAreaPosition
_objectAreaPosition = new ObjectAreaPosition(x, y, rotation);
objectAreaPosition = new ObjectAreaPosition(x, y, rotation);

}

@@ -128,7 +135,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
*/
public PageDescriptor getPageDescriptor() {

return _pageDescriptor;
return pageDescriptor;

}

@@ -139,32 +146,32 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
*/
public PresentationTextDescriptor getPresentationTextDataDescriptor() {

return _presentationTextDataDescriptor;
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
* @throws java.io.IOException throws if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

writeObjectList(_mapCodedFonts, os);
writeObjectList(mapCodedFonts, os);

writeObjectList(_mapPageOverlays, os);
writeObjectList(mapPageOverlays, os);

_pageDescriptor.writeDataStream(os);
pageDescriptor.writeDataStream(os);

if (_objectAreaDescriptor != null && _objectAreaPosition != null) {
_objectAreaDescriptor.writeDataStream(os);
_objectAreaPosition.writeDataStream(os);
if (objectAreaDescriptor != null && objectAreaPosition != null) {
objectAreaDescriptor.writeDataStream(os);
objectAreaPosition.writeDataStream(os);
}

_presentationTextDataDescriptor.writeDataStream(os);
presentationTextDataDescriptor.writeDataStream(os);

writeEnd(os);

@@ -189,9 +196,9 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -218,9 +225,9 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -245,7 +252,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {

if (mcf == null) {
mcf = new MapCodedFont();
_mapCodedFonts.add(mcf);
mapCodedFonts.add(mcf);
}

try {
@@ -259,7 +266,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
} catch (MaximumSizeExceededException msee) {

mcf = new MapCodedFont();
_mapCodedFonts.add(mcf);
mapCodedFonts.add(mcf);

try {

@@ -291,7 +298,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {

if (mpo == null) {
mpo = new MapPageOverlay();
_mapPageOverlays.add(mpo);
mapPageOverlays.add(mpo);
}

try {
@@ -300,7 +307,7 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {

} catch (MaximumSizeExceededException msee) {
mpo = new MapPageOverlay();
_mapPageOverlays.add(mpo);
mapPageOverlays.add(mpo);
try {
mpo.addOverlay(name);
} catch (MaximumSizeExceededException ex) {
@@ -317,9 +324,9 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
*/
private MapCodedFont getCurrentMapCodedFont() {

int size = _mapCodedFonts.size();
int size = mapCodedFonts.size();
if (size > 0) {
return (MapCodedFont) _mapCodedFonts.get(_mapCodedFonts.size() - 1);
return (MapCodedFont) mapCodedFonts.get(mapCodedFonts.size() - 1);
} else {
return null;
}
@@ -333,10 +340,10 @@ public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
*/
private MapPageOverlay getCurrentMapPageOverlay() {

int size = _mapPageOverlays.size();
int size = mapPageOverlays.size();
if (size > 0) {
return (MapPageOverlay) _mapPageOverlays.get(
_mapPageOverlays.size() - 1);
return (MapPageOverlay) mapPageOverlays.get(
mapPageOverlays.size() - 1);
} else {
return null;
}

+ 20
- 21
src/java/org/apache/fop/render/afp/modca/Document.java Прегледај датотеку

@@ -20,10 +20,8 @@
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;
import java.util.List;

/**
* The document is the highest level of the MO:DCA data-stream document
@@ -55,22 +53,22 @@ public final class Document extends AbstractNamedAFPObject {
/**
* Ststic default name reference
*/
private final static String DEFAULT_NAME = "DOC00001";
private static final String DEFAULT_NAME = "DOC00001";

/**
* A list of the objects in the document
*/
private ArrayList _objects = new ArrayList();
private List objects = new java.util.ArrayList();

/**
* The document started state
*/
private boolean _started = false;
private boolean started = false;

/**
* The document completion state
*/
private boolean _complete = false;
private boolean complete = false;

/**
* Default constructor for the document object.
@@ -94,8 +92,8 @@ public final class Document extends AbstractNamedAFPObject {
* @param page - the Page object
*/
public void addPage(PageObject page) {
if (!_objects.contains(page)) {
_objects.add(page);
if (!objects.contains(page)) {
objects.add(page);
}
}

@@ -104,7 +102,7 @@ public final class Document extends AbstractNamedAFPObject {
* @param pageGroup the PageGroup object
*/
public void addPageGroup(PageGroup pageGroup) {
_objects.add(pageGroup);
objects.add(pageGroup);
}

/**
@@ -112,31 +110,32 @@ public final class Document extends AbstractNamedAFPObject {
*/
public void endDocument() {

_complete = true;
complete = true;

}

/**
* Returns an indication if the page group is complete
* @return whether or not this page group is complete
*/
public boolean isComplete() {
return _complete;
return complete;
}

/**
* Accessor method to write the AFP datastream for document.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

if (!_started) {
if (!started) {
writeStart(os);
_started = true;
started = true;
}

for (Iterator it = _objects.iterator(); it.hasNext(); ) {
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()) {
@@ -147,7 +146,7 @@ public final class Document extends AbstractNamedAFPObject {
}
}

if (_complete) {
if (complete) {
writeEnd(os);
}

@@ -172,9 +171,9 @@ public final class Document extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -201,9 +200,9 @@ public final class Document extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 10
- 6
src/java/org/apache/fop/render/afp/modca/EndPageGroup.java Прегледај датотеку

@@ -21,7 +21,6 @@ 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
@@ -36,18 +35,23 @@ import java.io.UnsupportedEncodingException;
*/
public class EndPageGroup extends AbstractNamedAFPObject {

/**
* Main constructor
* @param groupId the group id
*/
public EndPageGroup(String groupId) {

super(groupId);

log.debug("A ENG is being created for group: " + groupId);

if (log.isDebugEnabled()) {
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
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -63,9 +67,9 @@ public class EndPageGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 24
- 24
src/java/org/apache/fop/render/afp/modca/IMImageObject.java Прегледај датотеку

@@ -18,9 +18,9 @@
/* $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
@@ -40,22 +40,22 @@ public class IMImageObject extends AbstractNamedAFPObject {
/**
* The image output control
*/
private ImageOutputControl _imageOutputControl = null;
private ImageOutputControl imageOutputControl = null;

/**
* The image input descriptor
*/
private ImageInputDescriptor _imageInputDescriptor = null;
private ImageInputDescriptor imageInputDescriptor = null;

/**
* The image cell position
*/
private ImageCellPosition _imageCellPosition = null;
private ImageCellPosition imageCellPosition = null;

/**
* The image rastor data
*/
private ImageRasterData _imageRastorData = null;
private ImageRasterData imageRasterData = null;

/**
* Constructor for the image object with the specified name,
@@ -73,7 +73,7 @@ public class IMImageObject extends AbstractNamedAFPObject {
* @param imageOutputControl The imageOutputControl to set
*/
public void setImageOutputControl(ImageOutputControl imageOutputControl) {
_imageOutputControl = imageOutputControl;
this.imageOutputControl = imageOutputControl;
}

/**
@@ -81,7 +81,7 @@ public class IMImageObject extends AbstractNamedAFPObject {
* @param imageCellPosition The imageCellPosition to set
*/
public void setImageCellPosition(ImageCellPosition imageCellPosition) {
_imageCellPosition = imageCellPosition;
this.imageCellPosition = imageCellPosition;
}

/**
@@ -89,41 +89,41 @@ public class IMImageObject extends AbstractNamedAFPObject {
* @param imageInputDescriptor The imageInputDescriptor to set
*/
public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) {
_imageInputDescriptor = imageInputDescriptor;
this.imageInputDescriptor = imageInputDescriptor;
}

/**
* Sets the ImageRastorData.
* @param imageRastorData The imageRastorData to set
* @param imageRasterData The imageRasterData to set
*/
public void setImageRasterData(ImageRasterData imageRastorData) {
_imageRastorData = imageRastorData;
public void setImageRasterData(ImageRasterData imageRasterData) {
this.imageRasterData = imageRasterData;
}

/**
* Accessor method to write the AFP datastream for the IM Image Objetc
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

if (_imageOutputControl != null) {
_imageOutputControl.writeDataStream(os);
if (imageOutputControl != null) {
imageOutputControl.writeDataStream(os);
}

if (_imageInputDescriptor != null) {
_imageInputDescriptor.writeDataStream(os);
if (imageInputDescriptor != null) {
imageInputDescriptor.writeDataStream(os);
}

if (_imageCellPosition != null) {
_imageCellPosition.writeDataStream(os);
if (imageCellPosition != null) {
imageCellPosition.writeDataStream(os);
}

if (_imageRastorData != null) {
_imageRastorData.writeDataStream(os);
if (imageRasterData != null) {
imageRasterData.writeDataStream(os);
}

writeEnd(os);
@@ -149,9 +149,9 @@ public class IMImageObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -178,9 +178,9 @@ public class IMImageObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 43
- 40
src/java/org/apache/fop/render/afp/modca/ImageObject.java Прегледај датотеку

@@ -22,7 +22,6 @@ package org.apache.fop.render.afp.modca;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import org.apache.fop.render.afp.tools.BinaryUtils;

/**
@@ -33,12 +32,12 @@ public class ImageObject extends AbstractNamedAFPObject {
/**
* The object environment group
*/
private ObjectEnvironmentGroup _objectEnvironmentGroup = null;
private ObjectEnvironmentGroup objectEnvironmentGroup = null;

/**
* The image segment
*/
private ImageSegment _imageSegment = null;
private ImageSegment imageSegment = null;

/**
* Constructor for the image object with the specified name,
@@ -64,12 +63,16 @@ public class ImageObject extends AbstractNamedAFPObject {
* the height of the image
* @param r
* the rotation of the image
* @param wr
* the width resolution of the image
* @param hr
* the height resolution of the image
*/
public void setImageViewport(int x, int y, int w, int h, int r) {
if (_objectEnvironmentGroup == null) {
_objectEnvironmentGroup = new ObjectEnvironmentGroup();
public void setImageViewport(int x, int y, int w, int h, int r, int wr, int hr) {
if (objectEnvironmentGroup == null) {
objectEnvironmentGroup = new ObjectEnvironmentGroup();
}
_objectEnvironmentGroup.setObjectArea(x, y, w, h, r);
objectEnvironmentGroup.setObjectArea(x, y, w, h, r, wr, hr);
}

/**
@@ -80,14 +83,14 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param height the image height
*/
public void setImageParameters(int xresol, int yresol, int width, int height) {
if (_objectEnvironmentGroup == null) {
_objectEnvironmentGroup = new ObjectEnvironmentGroup();
if (objectEnvironmentGroup == null) {
objectEnvironmentGroup = new ObjectEnvironmentGroup();
}
_objectEnvironmentGroup.setImageData(xresol, yresol, width, height);
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
objectEnvironmentGroup.setImageData(xresol, yresol, width, height);
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageSize(xresol, yresol, width, height);
imageSegment.setImageSize(xresol, yresol, width, height);
}

/**
@@ -95,10 +98,10 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param encoding The image encoding.
*/
public void setImageEncoding(byte encoding) {
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageEncoding(encoding);
imageSegment.setImageEncoding(encoding);
}

/**
@@ -106,10 +109,10 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param compression The image compression.
*/
public void setImageCompression(byte compression) {
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageCompression(compression);
imageSegment.setImageCompression(compression);
}

/**
@@ -117,10 +120,10 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param size The IDE size.
*/
public void setImageIDESize(byte size) {
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageIDESize(size);
imageSegment.setImageIDESize(size);
}

/**
@@ -128,21 +131,21 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param colorModel the IDE color model.
*/
public void setImageIDEColorModel(byte colorModel) {
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageIDEColorModel(colorModel);
imageSegment.setImageIDEColorModel(colorModel);
}

/**
* Set the data of the image.
* @param data The image data
*/
public void setImageData(byte data[]) {
if (_imageSegment == null) {
_imageSegment = new ImageSegment();
public void setImageData(byte[] data) {
if (imageSegment == null) {
imageSegment = new ImageSegment();
}
_imageSegment.setImageData(data);
imageSegment.setImageData(data);
}

/**
@@ -150,7 +153,7 @@ public class ImageObject extends AbstractNamedAFPObject {
* @param objectEnvironmentGroup The objectEnvironmentGroup to set
*/
public void setObjectEnvironmentGroup(ObjectEnvironmentGroup objectEnvironmentGroup) {
_objectEnvironmentGroup = objectEnvironmentGroup;
this.objectEnvironmentGroup = objectEnvironmentGroup;
}

/**
@@ -183,21 +186,21 @@ public class ImageObject extends AbstractNamedAFPObject {
/**
* Accessor method to write the AFP datastream for the Image Object
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

if (_objectEnvironmentGroup != null) {
_objectEnvironmentGroup.writeDataStream(os);
if (objectEnvironmentGroup != null) {
objectEnvironmentGroup.writeDataStream(os);
}

if (_imageSegment != null) {
if (imageSegment != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
_imageSegment.writeDataStream(baos);
byte b[] = baos.toByteArray();
imageSegment.writeDataStream(baos);
byte[] b = baos.toByteArray();
int off = 0;
while (off < b.length) {
int len = Math.min(30000, b.length - off);
@@ -230,9 +233,9 @@ public class ImageObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -259,9 +262,9 @@ public class ImageObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 10
- 11
src/java/org/apache/fop/render/afp/modca/IncludeObject.java Прегледај датотеку

@@ -21,7 +21,6 @@ package org.apache.fop.render.afp.modca;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import org.apache.fop.render.afp.tools.BinaryUtils;

@@ -43,12 +42,12 @@ public class IncludeObject extends AbstractNamedAFPObject {
/**
* The object type
*/
private byte _objectType = (byte) 0x92;
private byte objectType = (byte) 0x92;

/**
* The orientation on the include object
*/
private int _orientation = 0;
private int orientation = 0;

/**
* Constructor for the include object with the specified name, the name must
@@ -61,12 +60,12 @@ public class IncludeObject extends AbstractNamedAFPObject {
public IncludeObject(String name) {

super(name);
_objectType = (byte) 0xFB;
objectType = (byte) 0xFB;

}

/**
* Sets the orienation to use for the Include Object.
* Sets the orientation to use for the Include Object.
*
* @param orientation
* The orientation (0,90, 180, 270)
@@ -75,7 +74,7 @@ public class IncludeObject extends AbstractNamedAFPObject {

if (orientation == 0 || orientation == 90 || orientation == 180
|| orientation == 270) {
_orientation = orientation;
this.orientation = orientation;
} else {
throw new IllegalArgumentException(
"The orientation must be one of the values 0, 90, 180, 270");
@@ -86,7 +85,7 @@ public class IncludeObject extends AbstractNamedAFPObject {
/**
* Accessor method to write the AFP datastream for the Include Object
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -109,12 +108,12 @@ public class IncludeObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
data[9 + i] = _nameBytes[i];
for (int i = 0; i < nameBytes.length; i++) {
data[9 + i] = nameBytes[i];
}

data[17] = 0x00;
data[18] = _objectType;
data[18] = objectType;

// XoaOset
data[20] = (byte) 0xFF;
@@ -126,7 +125,7 @@ public class IncludeObject extends AbstractNamedAFPObject {
data[24] = (byte) 0xFF;
data[25] = (byte) 0xFF;

switch (_orientation) {
switch (orientation) {
case 90:
data[26] = 0x2D;
data[27] = 0x00;

+ 12
- 13
src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java Прегледај датотеку

@@ -21,7 +21,6 @@ package org.apache.fop.render.afp.modca;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import org.apache.fop.render.afp.tools.BinaryUtils;

@@ -43,17 +42,17 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {
/**
* The x coordinate
*/
private int _xCoor = 0;
private int xCoor = 0;

/**
* The y coordinate
*/
private int _yCoor = 0;
private int yCoor = 0;

/**
* The orientation
*/
private int _orientation = 0;
private int orientation = 0;

/**
* Constructor for the Include Page Overlay
@@ -66,8 +65,8 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {

super(overlayName);

_xCoor = x;
_yCoor = y;
xCoor = x;
yCoor = y;
setOrientation(orientation);
}

@@ -81,7 +80,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {

if (orientation == 0 || orientation == 90 || orientation == 180
|| orientation == 270) {
_orientation = orientation;
this.orientation = orientation;
} else {
throw new IllegalArgumentException(
"The orientation must be one of the values 0, 90, 180, 270");
@@ -92,7 +91,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {
/**
* Accessor method to write the AFP datastream for the Include Page Overlay
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -115,23 +114,23 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

byte[] r2 = BinaryUtils.convert(_xCoor, 3);
byte[] r2 = BinaryUtils.convert(xCoor, 3);
data[17] = r2[0]; // x coordinate
data[18] = r2[1];
data[19] = r2[2];

byte[] r3 = BinaryUtils.convert(_yCoor, 3);
byte[] r3 = BinaryUtils.convert(yCoor, 3);
data[20] = r3[0]; // y coordinate
data[21] = r3[1];
data[22] = r3[2];

switch (_orientation) {
switch (orientation) {
case 90:
data[23] = 0x2D;
data[24] = 0x00;

+ 15
- 16
src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java Прегледај датотеку

@@ -21,7 +21,6 @@ package org.apache.fop.render.afp.modca;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import org.apache.fop.render.afp.tools.BinaryUtils;

@@ -41,17 +40,17 @@ import org.apache.fop.render.afp.tools.BinaryUtils;
* that may have to be placed at different positions on a document.
*
*/
public class IncludePageSegment extends AbstractNamedAFPObject{
public class IncludePageSegment extends AbstractNamedAFPObject {

/**
* The x position where we need to put this object on the page
*/
private byte [] _xCoor;
private byte[] xCoor;

/**
* The y position where we need to put this object on the page
*/
private byte [] _yCoor;
private byte[] yCoor;

/**
* Constructor for the Include Page Segment
@@ -59,18 +58,18 @@ public class IncludePageSegment extends AbstractNamedAFPObject{
* @param xVal The x position
* @param yVal The y position
*/
public IncludePageSegment(String name, int xVal, int yVal){
public IncludePageSegment(String name, int xVal, int yVal) {

super(name);
_xCoor = BinaryUtils.convert(xVal, 3);
_yCoor = BinaryUtils.convert(yVal, 3);
this.xCoor = BinaryUtils.convert(xVal, 3);
this.yCoor = BinaryUtils.convert(yVal, 3);

}

/**
* Accessor method to write the AFP datastream for the Include Page Segment
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -93,19 +92,19 @@ public class IncludePageSegment extends AbstractNamedAFPObject{
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

data[17] = _xCoor[0]; // x coordinate
data[18] = _xCoor[1];
data[19] = _xCoor[2];
data[17] = xCoor[0]; // x coordinate
data[18] = xCoor[1];
data[19] = xCoor[2];

data[20] = _yCoor[0]; // y coordinate
data[21] = _yCoor[1];
data[22] = _yCoor[2];
data[20] = yCoor[0]; // y coordinate
data[21] = yCoor[1];
data[22] = yCoor[2];

os.write(data);


+ 3
- 4
src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java Прегледај датотеку

@@ -21,7 +21,6 @@ package org.apache.fop.render.afp.modca;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import org.apache.fop.render.afp.tools.BinaryUtils;

@@ -46,7 +45,7 @@ public class InvokeMediumMap extends AbstractNamedAFPObject {
/**
* Accessor method to write the AFP datastream for the Invoke Medium Map
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -69,9 +68,9 @@ public class InvokeMediumMap extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 43
- 48
src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java Прегледај датотеку

@@ -28,74 +28,69 @@ import org.apache.fop.render.afp.tools.BinaryUtils;
* of an object area presentation space.
*
*/
public class ObjectAreaDescriptor extends AbstractAFPObject {

private int _width = 0;
private int _height = 0;
public class ObjectAreaDescriptor extends AbstractDescriptor {

/**
* Construct an object area descriptor for the specified object width
* and object height.
* @param width The page width.
* @param height The page height.
* @param widthResolution The page width resolution.
* @param heightResolution The page height resolution.
*/
public ObjectAreaDescriptor(int width, int height) {

_width = width;
_height = height;

public ObjectAreaDescriptor(int width, int height, int widthResolution, int heightResolution) {
super(width, height, widthResolution, heightResolution);
}

/**
* Accessor method to write the AFP datastream for the Object Area Descriptor
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

byte[] data = new byte[] {
0x5A,
0x00, // Length
0x1C, // Length
(byte) 0xD3,
(byte) 0xA6,
(byte) 0x6B,
0x00, // Flags
0x00, // Reserved
0x00, // Reserved
0x03, // Triplet length
0x43, // tid = Descriptor Position Triplet
0x01, // DesPosId = 1
0x08, // Triplet length
0x4B, // tid = Measurement Units Triplet
0x00, // XaoBase = 10 inches
0x00, // YaoBase = 10 inches
0x09, // XaoUnits = 2400
0x60, // XaoUnits =
0x09, // YaoUnits = 2400
0x60, // YaoUnits =
0x09, // Triplet length
0x4C, // tid = Object Area Size
0x02, // Size Type
0x00, // XoaSize
0x00,
0x00,
0x00, // YoaSize
0x00,
0x00,
};

byte[] l = BinaryUtils.convert(data.length - 1, 2);
data[1] = l[0];
data[2] = l[1];

byte[] x = BinaryUtils.convert(_width, 3);
byte[] data = new byte[29];
data[0] = 0x5A;

byte[] len = BinaryUtils.convert(data.length - 1, 2);
data[1] = len[0]; // Length
data[2] = len[1];

data[3] = (byte) 0xD3;
data[4] = (byte) 0xA6;
data[5] = (byte) 0x6B;
data[6] = 0x00; // Flags
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved
data[9] = 0x03; // Triplet length
data[10] = 0x43; // tid = Descriptor Position Triplet
data[11] = 0x01; // DesPosId = 1
data[12] = 0x08; // Triplet length
data[13] = 0x4B; // tid = Measurement Units Triplet
data[14] = 0x00; // XaoBase = 10 inches
data[15] = 0x00; // YaoBase = 10 inches
// XaoUnits
byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2);
data[16] = xdpi[0];
data[17] = xdpi[1];

// YaoUnits
byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2);
data[18] = ydpi[0];
data[19] = ydpi[1];
data[20] = 0x09; // Triplet length
data[21] = 0x4C; // tid = Object Area Size
data[22] = 0x02; // Size Type

byte[] x = BinaryUtils.convert(width, 3);
data[23] = x[0];
data[24] = x[1];
data[25] = x[2];

byte[] y = BinaryUtils.convert(_height, 3);
byte[] y = BinaryUtils.convert(height, 3);
data[26] = y[0];
data[27] = y[1];
data[28] = y[2];

+ 20
- 17
src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java Прегледај датотеку

@@ -20,7 +20,6 @@
package org.apache.fop.render.afp.modca;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;


/**
@@ -44,17 +43,17 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
/**
* The ObjectAreaDescriptor for the object environment group
*/
private ObjectAreaDescriptor _objectAreaDescriptor = null;
private ObjectAreaDescriptor objectAreaDescriptor = null;

/**
* The ObjectAreaPosition for the object environment group
*/
private ObjectAreaPosition _objectAreaPosition = null;
private ObjectAreaPosition objectAreaPosition = null;

/**
* The ImageDataDescriptor for the object environment group
*/
private ImageDataDescriptor _imageDataDescriptor = null;
private ImageDataDescriptor imageDataDescriptor = null;

/**
* Default constructor for the ObjectEnvironmentGroup.
@@ -83,11 +82,15 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
* @param width the object width
* @param height the object height
* @param rotation the object orientation
* @param widthResolution the object resolution width
* @param heightResolution the object resolution height
*/
public void setObjectArea(int x, int y, int width, int height, int rotation) {
public void setObjectArea(int x, int y, int width, int height, int rotation,
int widthResolution, int heightResolution) {

_objectAreaDescriptor = new ObjectAreaDescriptor(width, height);
_objectAreaPosition = new ObjectAreaPosition(x, y, rotation);
objectAreaDescriptor = new ObjectAreaDescriptor(width, height,
widthResolution, heightResolution);
objectAreaPosition = new ObjectAreaPosition(x, y, rotation);

}

@@ -99,14 +102,14 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
* @param height the image height
*/
public void setImageData(int xresol, int yresol, int width, int height) {
_imageDataDescriptor = new ImageDataDescriptor(xresol, yresol, width, height);
imageDataDescriptor = new ImageDataDescriptor(xresol, yresol, width, height);
}

/**
* Accessor method to obtain write the AFP datastream for
* the object environment group.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException throw if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -114,12 +117,12 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {

writeStart(os);

_objectAreaDescriptor.writeDataStream(os);
objectAreaDescriptor.writeDataStream(os);

_objectAreaPosition.writeDataStream(os);
objectAreaPosition.writeDataStream(os);

if (_imageDataDescriptor != null) {
_imageDataDescriptor.writeDataStream(os);
if (imageDataDescriptor != null) {
imageDataDescriptor.writeDataStream(os);
}

writeEnd(os);
@@ -153,9 +156,9 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
0x00, //
};

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -182,9 +185,9 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 22
- 14
src/java/org/apache/fop/render/afp/modca/Overlay.java Прегледај датотеку

@@ -19,14 +19,17 @@

package org.apache.fop.render.afp.modca;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;

/**
* An overlay is a MO:DCA-P resource object.
*
* It may be stored in an external resource library or it may be
* carried in a resource group. An overlay is similar to a page in
* that it defines its own environment and carries the same data objects.
*/
public class Overlay extends AbstractPageObject{
public class Overlay extends AbstractPageObject {

/**
* Construct a new overlay object for the specified name argument, the overlay
@@ -40,10 +43,15 @@ public class Overlay extends AbstractPageObject{
* the height of the page.
* @param rotation
* the rotation of the page.
* @param widthResolution
* the width resolution of the page.
* @param heightResolution
* the height resolution of the page.
*/
public Overlay(String name, int width, int height, int rotation) {
public Overlay(String name, int width, int height, int rotation,
int widthResolution, int heightResolution) {

super(name, width, height, rotation);
super(name, width, height, rotation, widthResolution, heightResolution);

}

@@ -51,20 +59,20 @@ public class Overlay extends AbstractPageObject{
* Accessor method to write the AFP datastream for the overlay.
*
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

_activeEnvironmentGroup.writeDataStream(os);
activeEnvironmentGroup.writeDataStream(os);

writeObjectList(_segments, os);
writeObjectList(segments, os);

writeObjectList(_tagLogicalElements, os);
writeObjectList(tagLogicalElements, os);

writeObjectList(_objects, os);
writeObjectList(objects, os);

writeEnd(os);

@@ -89,9 +97,9 @@ public class Overlay extends AbstractPageObject{
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -118,9 +126,9 @@ public class Overlay extends AbstractPageObject{
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 40
- 39
src/java/org/apache/fop/render/afp/modca/PageDescriptor.java Прегледај датотеку

@@ -28,71 +28,72 @@ import org.apache.fop.render.afp.tools.BinaryUtils;
* a page or overlay presentation space.
*
*/
public class PageDescriptor extends AbstractAFPObject {

private int _width = 0;
private int _height = 0;
public class PageDescriptor extends AbstractDescriptor {

/**
* Construct a page descriptor for the specified page width
* and page height.
* @param width The page width.
* @param height The page height.
* @param widthResolution The page width resolution
* @param heightResolution The page height resolution
*/
public PageDescriptor(int width, int height) {

_width = width;
_height = height;

public PageDescriptor(int width, int height, int widthResolution, int heightResolution) {
super(width, height, widthResolution, heightResolution);
}

/**
* Accessor method to write the AFP datastream for the Page Descriptor
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException in the event that an I/O Exception occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

byte[] data = new byte[] {
0x5A,
0x00,
0x17,
(byte) 0xD3,
(byte) 0xA6,
(byte) 0xAF,
0x00,
0x00,
0x00,
0x00,
0x00,
0x09,
0x60,
0x09,
0x60,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
log.debug("width=" + width);
log.debug("height=" + height);
byte[] data = new byte[24];
data[0] = 0x5A;
data[1] = 0x00;
data[2] = 0x17;
data[3] = (byte) 0xD3;
data[4] = (byte) 0xA6;
data[5] = (byte) 0xAF;
data[6] = 0x00; // Flags
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved
data[9] = 0x00; // XpgBase = 10 inches
data[10] = 0x00; // YpgBase = 10 inches
// XpgUnits
byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2);
data[11] = xdpi[0];
data[12] = xdpi[1];

byte[] x = BinaryUtils.convert(_width, 3);
// YpgUnits
byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2);
data[13] = ydpi[0];
data[14] = ydpi[1];
// XpgSize
byte[] x = BinaryUtils.convert(width, 3);
data[15] = x[0];
data[16] = x[1];
data[17] = x[2];

byte[] y = BinaryUtils.convert(_height, 3);
// YpgSize
byte[] y = BinaryUtils.convert(height, 3);
data[18] = y[0];
data[19] = y[1];
data[20] = y[2];

os.write(data);
data[21] = 0x00; // Reserved
data[22] = 0x00; // Reserved
data[23] = 0x00; // Reserved

os.write(data);
}

}

+ 18
- 18
src/java/org/apache/fop/render/afp/modca/PageGroup.java Прегледај датотеку

@@ -20,7 +20,6 @@
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.List;

@@ -40,17 +39,17 @@ public class PageGroup extends AbstractNamedAFPObject {
/**
* The pages contained within this group
*/
private List _objects = new ArrayList();
private List objects = new ArrayList();

/**
* The tag logical elements contained within this group
*/
private List _tagLogicalElements = new ArrayList();
private List tagLogicalElements = new ArrayList();

/**
* The page state
*/
private boolean _complete = false;
private boolean complete = false;

/**
* Constructor for the PageGroup.
@@ -72,8 +71,8 @@ public class PageGroup extends AbstractNamedAFPObject {
*/
public void addPage(PageObject page) {

if (!_objects.contains(page)) {
_objects.add(page);
if (!objects.contains(page)) {
objects.add(page);
}

}
@@ -82,7 +81,7 @@ public class PageGroup extends AbstractNamedAFPObject {
* @return the name of the page group
*/
public String getName() {
return _name;
return name;
}

/**
@@ -96,7 +95,7 @@ public class PageGroup extends AbstractNamedAFPObject {
public void createTagLogicalElement(String name, String value) {

TagLogicalElement tle = new TagLogicalElement(name, value);
_tagLogicalElements.add(tle);
tagLogicalElements.add(tle);

}

@@ -109,7 +108,7 @@ public class PageGroup extends AbstractNamedAFPObject {
public void createInvokeMediumMap(String name) {

InvokeMediumMap imm = new InvokeMediumMap(name);
_objects.add(imm);
objects.add(imm);

}

@@ -118,30 +117,31 @@ public class PageGroup extends AbstractNamedAFPObject {
*/
public void endPageGroup() {

_complete = true;
complete = true;

}

/**
* Returns an indication if the page group is complete
* @return whether or not this page group is complete or not
*/
public boolean isComplete() {
return _complete;
return complete;
}

/**
* Accessor method to write the AFP datastream for the page group.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

writeObjectList(_tagLogicalElements, os);
writeObjectList(tagLogicalElements, os);

writeObjectList(_objects, os);
writeObjectList(objects, os);

writeEnd(os);

@@ -166,9 +166,9 @@ public class PageGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -195,9 +195,9 @@ public class PageGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 23
- 18
src/java/org/apache/fop/render/afp/modca/PageObject.java Прегледај датотеку

@@ -48,7 +48,7 @@ public class PageObject extends AbstractPageObject {
/**
* The resource group object
*/
private ResourceGroup _resourceGroup = null;
private ResourceGroup resourceGroup = null;

/**
* Construct a new page object for the specified name argument, the page
@@ -62,10 +62,15 @@ public class PageObject extends AbstractPageObject {
* the height of the page.
* @param rotation
* the rotation of the page.
* @param widthResolution
* the width resolution of the page.
* @param heightResolution
* the height resolution of the page.
*/
public PageObject(String name, int width, int height, int rotation) {
public PageObject(String name, int width, int height, int rotation,
int widthResolution, int heightResolution) {

super(name, width, height, rotation);
super(name, width, height, rotation, widthResolution, heightResolution);

}

@@ -74,10 +79,10 @@ public class PageObject extends AbstractPageObject {
* @param overlay the overlay to add
*/
public void addOverlay(Overlay overlay) {
if (_resourceGroup == null) {
_resourceGroup = new ResourceGroup();
if (resourceGroup == null) {
resourceGroup = new ResourceGroup();
}
_resourceGroup.addOverlay(overlay);
resourceGroup.addOverlay(overlay);
}

/**
@@ -95,31 +100,31 @@ public class PageObject extends AbstractPageObject {
public void createIncludePageOverlay(String name, int x, int y, int orientation) {

IncludePageOverlay ipo = new IncludePageOverlay(name, x, y, orientation);
_objects.add(ipo);
objects.add(ipo);

}

/**
* Accessor method to write the AFP datastream for the page.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

if (_resourceGroup != null) {
_resourceGroup.writeDataStream(os);
if (resourceGroup != null) {
resourceGroup.writeDataStream(os);
}

_activeEnvironmentGroup.writeDataStream(os);
activeEnvironmentGroup.writeDataStream(os);

writeObjectList(_segments, os);
writeObjectList(segments, os);

writeObjectList(_tagLogicalElements, os);
writeObjectList(tagLogicalElements, os);

writeObjectList(_objects, os);
writeObjectList(objects, os);

writeEnd(os);

@@ -144,9 +149,9 @@ public class PageObject extends AbstractPageObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -173,9 +178,9 @@ public class PageObject extends AbstractPageObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 32
- 37
src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java Прегледај датотеку

@@ -45,68 +45,63 @@ import org.apache.fop.render.afp.tools.BinaryUtils;
* in their semantic descriptions.
*
*/
public class PresentationTextDescriptor extends AbstractAFPObject {

private int _width = 0;
private int _height = 0;
public class PresentationTextDescriptor extends AbstractDescriptor {

/**
* Constructor a PresentationTextDescriptor for the specified
* width and height.
* @param width The width of the page.
* @param height The height of the page.
* @param widthResolution The width resolution of the page.
* @param heightResolution The height resolution of the page.
*/
public PresentationTextDescriptor(int width, int height) {

_width = width;
_height = height;

public PresentationTextDescriptor(int width, int height,
int widthResolution, int heightResolution) {
super(width, height, widthResolution, heightResolution);
}

/**
* Accessor method to write the AFP datastream for the Presentation Text Descriptor
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

byte[] data = new byte[] {
0x5A,
0x00,
0x16,
(byte) 0xD3,
(byte) 0xB1,
(byte) 0x9B,
0x00,
0x00,
0x00,
0x00,
0x00,
0x09,
0x60,
0x09,
0x60,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
byte[] data = new byte[23];
data[0] = 0x5A;
data[1] = 0x00;
data[2] = 0x16;
data[3] = (byte) 0xD3;
data[4] = (byte) 0xB1;
data[5] = (byte) 0x9B;
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;

byte[] x = BinaryUtils.convert(_width, 3);
byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2);
data[11] = xdpi[0]; // xdpi
data[12] = xdpi[1];

byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2);
data[13] = ydpi[0]; // ydpi
data[14] = ydpi[1];

byte[] x = BinaryUtils.convert(width, 3);
data[15] = x[0];
data[16] = x[1];
data[17] = x[2];

byte[] y = BinaryUtils.convert(_height, 3);
byte[] y = BinaryUtils.convert(height, 3);
data[18] = y[0];
data[19] = y[1];
data[20] = y[2];

data[21] = 0x00;
data[22] = 0x00;

os.write(data);

}

+ 13
- 8
src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java Прегледај датотеку

@@ -22,7 +22,6 @@ package org.apache.fop.render.afp.modca;
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

/**
@@ -64,6 +63,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
/**
* Construct a new PresentationTextObject for the specified name argument,
* the name should be an 8 character identifier.
* @param name the name of this presentation object
*/
public PresentationTextObject(String name) {

@@ -89,7 +89,8 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
* @param data
* The text data to be created.
*/
public void createTextData(int fontNumber, int x, int y, Color col, int vsci, int ica, byte[] data) {
public void createTextData(int fontNumber, int x, int y, Color col,
int vsci, int ica, byte[] data) {

// Use a default orientation of zero
createTextData(fontNumber, x, y, 0, col, vsci, ica, data);
@@ -225,7 +226,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
/**
* Accessor method to write the AFP datastream for the PresentationTextObject.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException thrown if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {
@@ -238,9 +239,13 @@ public class PresentationTextObject extends AbstractNamedAFPObject {

}

/**
* Returns the name of this presentation text object
* @return the name of this presentation text object
*/
public String getName() {

return _name;
return name;

}

@@ -263,9 +268,9 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -293,9 +298,9 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 12
- 10
src/java/org/apache/fop/render/afp/modca/ResourceGroup.java Прегледај датотеку

@@ -21,7 +21,6 @@ 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.List;

@@ -39,8 +38,11 @@ public final class ResourceGroup extends AbstractNamedAFPObject {
/**
* The overlays contained in this resource group
*/
private List _overlays = new ArrayList();
private List overlays = new ArrayList();

/**
* Default constructor
*/
public ResourceGroup() {

this(DEFAULT_NAME);
@@ -63,7 +65,7 @@ public final class ResourceGroup extends AbstractNamedAFPObject {
* @param overlay the overlay to add
*/
public void addOverlay(Overlay overlay) {
_overlays.add(overlay);
overlays.add(overlay);
}

/**
@@ -71,21 +73,21 @@ public final class ResourceGroup extends AbstractNamedAFPObject {
* @return the list of overlays
*/
public List getOverlays() {
return _overlays;
return overlays;
}

/**
* Accessor method to obtain write the AFP datastream for
* the resource group.
* @param os The stream to write to
* @throws java.io.IOException
* @throws java.io.IOException if an I/O exception of some sort has occurred
*/
public void writeDataStream(OutputStream os)
throws IOException {

writeStart(os);

writeObjectList(_overlays, os);
writeObjectList(overlays, os);

writeEnd(os);

@@ -110,9 +112,9 @@ public final class ResourceGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}

@@ -139,9 +141,9 @@ public final class ResourceGroup extends AbstractNamedAFPObject {
data[7] = 0x00; // Reserved
data[8] = 0x00; // Reserved

for (int i = 0; i < _nameBytes.length; i++) {
for (int i = 0; i < nameBytes.length; i++) {

data[9 + i] = _nameBytes[i];
data[9 + i] = nameBytes[i];

}


+ 9
- 4
src/java/org/apache/fop/render/ps/PSTextPainter.java Прегледај датотеку

@@ -40,6 +40,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.java2d.ps.TextHandler;

import org.apache.batik.dom.svg.SVGOMTextElement;
import org.apache.batik.gvt.text.Mark;
@@ -74,7 +75,7 @@ public class PSTextPainter implements TextPainter {
protected Log log = LogFactory.getLog(PSTextPainter.class);
private NativeTextHandler nativeTextHandler;
//private FontInfo fontInfo;
private FontInfo fontInfo;

/**
* Use the stroking text painter to get the bounds and shape.
@@ -89,6 +90,7 @@ public class PSTextPainter implements TextPainter {
*/
public PSTextPainter(NativeTextHandler nativeTextHandler) {
this.nativeTextHandler = nativeTextHandler;
this.fontInfo = nativeTextHandler.getFontInfo();
}

/**
@@ -314,6 +316,12 @@ public class PSTextPainter implements TextPainter {
}
}
drawPrimitiveString(g2d, loc, font, txt, tx);
loc.setLocation(loc.getX() + (double)advance, loc.getY());
return loc;
}

protected void drawPrimitiveString(Graphics2D g2d, Point2D loc, Font font, String txt, float tx) {
//Finally draw text
nativeTextHandler.setOverrideFont(font);
try {
@@ -327,8 +335,6 @@ public class PSTextPainter implements TextPainter {
} finally {
nativeTextHandler.setOverrideFont(null);
}
loc.setLocation(loc.getX() + (double)advance, loc.getY());
return loc;
}

private void updateLocationFromACI(
@@ -380,7 +386,6 @@ public class PSTextPainter implements TextPainter {
int weight = getWeight(aci);

boolean found = false;
FontInfo fontInfo = nativeTextHandler.getFontInfo();
String fontFamily = null;
List gvtFonts = (List) aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES);

+ 3
- 0
status.xml Прегледај датотеку

@@ -28,6 +28,9 @@

<changes>
<release version="FOP Trunk">
<action context="Code" dev="JM" type="add" fixes-bug="43041" due-to="Adrian Cumiskey">
Added a configuration setting for the renderer/device resolution to the AFP renderer.
</action>
<action context="code" dev="AD" type="update">
Facilitate the implementation for font-selection-strategy:
* Changed FontInfo.fontLookup to always return an array of FontTriplet

Loading…
Откажи
Сачувај