Index: src/java/org/apache/xmlgraphics/ps/PSState.java =================================================================== --- src/java/org/apache/xmlgraphics/ps/PSState.java (revision 541229) +++ src/java/org/apache/xmlgraphics/ps/PSState.java (working copy) @@ -43,7 +43,7 @@ private int linecap = 0; private double linewidth = 1.0f; private String dashpattern = DEFAULT_DASH; - private Color rgbColor = DEFAULT_RGB_COLOR; + private Color color = DEFAULT_RGB_COLOR; //Font state private String fontname; @@ -69,7 +69,7 @@ this.linecap = org.linecap; this.linewidth = org.linewidth; this.dashpattern = org.dashpattern; - this.rgbColor = org.rgbColor; + this.color = org.color; this.fontname = org.fontname; this.fontsize = org.fontsize; } @@ -152,8 +152,8 @@ * @return true if the color changed compared to the previous setting */ public boolean useColor(Color value) { - if (!rgbColor.equals(value)) { - rgbColor = value; + if (!color.equals(value)) { + color = value; return true; } else { return false; @@ -192,7 +192,7 @@ gen.useLineCap(linecap); gen.useLineWidth(linewidth); gen.useDash(dashpattern); - gen.useRGBColor(rgbColor); + gen.useColor(color); if (fontname != null) { gen.useFont(fontname, fontsize); } Index: src/java/org/apache/xmlgraphics/ps/PSGenerator.java =================================================================== --- src/java/org/apache/xmlgraphics/ps/PSGenerator.java (revision 541229) +++ src/java/org/apache/xmlgraphics/ps/PSGenerator.java (working copy) @@ -32,6 +32,7 @@ import javax.xml.transform.Source; +import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.dsc.ResourceTracker; /** @@ -41,6 +42,9 @@ */ public class PSGenerator { + /** + * Default postscript language level + */ public static final int DEFAULT_LANGUAGE_LEVEL = 3; /** @@ -495,22 +499,27 @@ writeln(pattern + " setdash"); } } - + /** * Establishes the specified color (RGB). * @param col the color as defined by the setrgbcolor command. * @exception IOException In case of an I/O problem + * @deprecated use useColor method instead */ public void useRGBColor(Color col) throws IOException { - if (col == null) { - col = PSState.DEFAULT_RGB_COLOR; - } + useColor(col); + } + + /** + * Establishes the specified color. + * @param col the color. + * @exception IOException In case of an I/O problem + */ + public void useColor(Color col) throws IOException { if (getCurrentState().useColor(col)) { - float[] comps = col.getColorComponents(null); - writeln(formatDouble(comps[0]) - + " " + formatDouble(comps[1]) - + " " + formatDouble(comps[2]) - + " setrgbcolor"); + final boolean textAsShapes = false; + PSGraphics2D graphics = new PSGraphics2D(textAsShapes, this); + graphics.establishColor(col); } }