[FOray-commit] SF.net SVN: foray: [9774] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-13 18:55:55
|
Revision: 9774
http://svn.sourceforge.net/foray/?rev=9774&view=rev
Author: victormote
Date: 2007-06-13 11:55:56 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
1. Use the bare color where possible instead of the PDF wrapper.
2. Move some variables to the PDF graphics state.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-13 17:39:26 UTC (rev 9773)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-13 18:55:56 UTC (rev 9774)
@@ -29,6 +29,7 @@
import org.foray.common.ColorSpaceCMYK;
import org.foray.common.WKConstants;
+import org.foray.pdf.PDFGraphicsState;
import org.foray.pdf.object.PDFAnnotList;
import org.foray.pdf.object.PDFColor;
import org.foray.pdf.object.PDFDocument;
@@ -116,12 +117,6 @@
/** The PDF Document being created. */
private PDFDocument pdfDoc;
- /** The current (internal) font. */
- private org.axsl.fontR.FontUse currentFont;
-
- /** The current font size in millipoints. */
- private float currentFontSize;
-
/** The current stream to add PDF commands to. */
private StringWriter currentStream = new StringWriter();
@@ -152,6 +147,9 @@
/** The PDF context. */
private GraphicPdfContext pdfContext;
+ /** The graphics state. */
+ private PDFGraphicsState graphicsState;
+
/**
* Create a new PDFGraphics2D with the given pdf document info.
* This is used to create a Graphics object for use inside an already
@@ -177,7 +175,7 @@
this.logger = logger;
this.fontConsumer = fontConsumer;
this.pdfContext = pdfContext;
- currentFontSize = this.pdfDoc.getCurrentGraphicsState().getFontSize();
+ this.graphicsState = new PDFGraphicsState();
initGraphicalEnvironment();
transformCoordinates(contentRectangle, svgDocument);
}
@@ -447,7 +445,6 @@
public void dispose() {
pdfDoc = null;
currentStream = null;
- currentFont = null;
currentColour = null;
}
@@ -749,9 +746,10 @@
overrideFont = null;
}
- if (font != this.currentFont || (size != this.currentFontSize)) {
- this.currentFont = font;
- this.currentFontSize = size;
+ if (font != this.graphicsState.getFont()
+ || (size != this.graphicsState.getFontSize())) {
+ this.graphicsState.setFont(font);
+ this.graphicsState.setFontSize(size);
final String fontName = this.pdfContext.getFontName(font);
currentStream.write("/" + fontName + " " + size + " Tf\n");
}
@@ -808,9 +806,7 @@
fontWeight = org.axsl.fontR.Font.Weight.BOLD;
}
try {
- final FontConsumer fontConsumer =
- this.currentFont.getFontConsumer();
- return fontConsumer.selectFontXSL(
+ return this.fontConsumer.selectFontXSL(
org.axsl.fontR.Font.SelectionStrategy.AUTO,
FontUtility.foFontFamily(fontFamily),
fontStyle, fontWeight,
@@ -867,10 +863,10 @@
continue;
}
final float size = fontSize.floatValue();
- if ((font != this.currentFont)
- || (size != this.currentFontSize)) {
- this.currentFont = font;
- this.currentFontSize = size;
+ if ((font != this.graphicsState.getFont())
+ || (size != this.graphicsState.getFontSize())) {
+ this.graphicsState.setFont(font);
+ this.graphicsState.setFontSize(size);
final String fontName = this.pdfContext.getFontName(font);
currentStream.write("/" + fontName + " " + size + " Tf\n");
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 17:39:26 UTC (rev 9773)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 18:55:56 UTC (rev 9774)
@@ -28,8 +28,6 @@
package org.foray.pdf;
-import org.foray.pdf.object.PDFColor;
-
import org.axsl.fontR.FontUse;
import org.axsl.pdfW.PDFLineCapStyle;
@@ -45,10 +43,10 @@
public class PDFGraphicsState {
/** The stroke color. */
- private PDFColor strokeColor;
+ private Color strokeColor;
/** The "non-stroke" or "other" color. */
- private PDFColor fillColor;
+ private Color fillColor;
/** The character spacing, in points. */
private float characterSpacing;
@@ -84,8 +82,8 @@
* PDF Reference, 3rd Edition, Section 4.3.
*/
public void reset() {
- this.strokeColor = new org.foray.pdf.object.PDFColor(Color.BLACK);
- this.fillColor = new org.foray.pdf.object.PDFColor(Color.BLACK);
+ this.strokeColor = Color.BLACK;
+ this.fillColor = Color.BLACK;
this.characterSpacing = 0;
this.wordSpacing = 0;
this.font = null;
@@ -97,11 +95,11 @@
/**
* Sets the stroke color (Graphics State holds two colors, one for stroke
- * operations and one for all other operations.
+ * operations and one for all other operations).
* @param newStrokeColor The color that stroke operations should now use.
* @return True if the Graphics State was changed by this operation.
*/
- public boolean setStrokeColor(final PDFColor newStrokeColor) {
+ public boolean setStrokeColor(final Color newStrokeColor) {
boolean anyChange = false;
if (! newStrokeColor.equals(this.strokeColor)) {
this.strokeColor = newStrokeColor;
@@ -112,13 +110,13 @@
/**
* Sets the "non-stroke" or "other" color (Graphics State holds two colors,
- * one for stroke operations and one for all other operations. This is the
+ * one for stroke operations and one for all other operations). This is the
* one for all other operations. The name "fill" was chosen because that is
* the common use for this color.
* @param newFillColor The color that non-stroke operations should now use.
* @return True if the Graphics State was changed by this operation.
*/
- public boolean setFillColor(final PDFColor newFillColor) {
+ public boolean setFillColor(final Color newFillColor) {
boolean anyChange = false;
if (! newFillColor.equals(this.fillColor)) {
this.fillColor = newFillColor;
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-13 17:39:26 UTC (rev 9773)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-13 18:55:56 UTC (rev 9774)
@@ -147,7 +147,7 @@
public void setStrokeColor(final Color newStrokeColor) {
final PDFColor newPDFColor = this.getPDFDocument().createPDFColor(
newStrokeColor);
- if (! this.getGS().setStrokeColor(newPDFColor)) {
+ if (! this.getGS().setStrokeColor(newStrokeColor)) {
// Nothing needs to change.
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|