Hi, There is a small mispelling in the PSGraphicsDevice constructor comment:
> - * Create a new PDF graphics device. > + * Create a new PostScruot graphics device. It should have been PostScript instead of PostScruot, shouldn't it? Anyway, thanks for your work Jeremias ;-) Regards, Julien 2010/11/12 <[email protected]>: > Author: jeremias > Date: Fri Nov 12 13:04:26 2010 > New Revision: 1034385 > > URL: http://svn.apache.org/viewvc?rev=1034385&view=rev > Log: > Bugzilla #50253: > Added custom GraphicsConfiguration to avoid a HeadlessException. > > Added: > > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > (contents, props changed) > - copied, changed from r1034338, > xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java > > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > (contents, props changed) > - copied, changed from r1034339, > xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsDevice.java > Modified: > > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java > > Modified: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java > URL: > http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=1034385&r1=1034384&r2=1034385&view=diff > ============================================================================== > --- > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java > (original) > +++ > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java > Fri Nov 12 13:04:26 2010 > @@ -28,7 +28,6 @@ import java.awt.GradientPaint; > import java.awt.Graphics; > import java.awt.Graphics2D; > import java.awt.GraphicsConfiguration; > -import java.awt.GraphicsEnvironment; > import java.awt.Image; > import java.awt.Paint; > import java.awt.Rectangle; > @@ -67,6 +66,10 @@ public class PSGraphics2D extends Abstra > > private static final boolean DEBUG = false; > > + /** > + * The G2D instance that represents the root instance > + * (used in context with create()/dispose()). Null if this instance is > the root instance. > + */ > protected PSGraphics2D rootG2D; > > /** the PostScript generator being created */ > @@ -532,8 +535,7 @@ public class PSGraphics2D extends Abstra > gen.write(psTilingPattern.toString()); > gen.writeln("/Pattern " + > gen.mapCommand("setcolorspace")); > gen.writeln(psTilingPattern.getName() + " " + > gen.mapCommand("setcolor")); > - } > - catch (IOException ioe) { > + } catch (IOException ioe) { > handleIOException(ioe); > } > } > @@ -821,8 +823,7 @@ public class PSGraphics2D extends Abstra > * @return the device configuration > */ > public GraphicsConfiguration getDeviceConfiguration() { > - return GraphicsEnvironment.getLocalGraphicsEnvironment(). > - getDefaultScreenDevice().getDefaultConfiguration(); > + return new PSGraphicsConfiguration(); > } > > /** > > Copied: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > (from r1034338, > xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java) > URL: > http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java?p2=xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java&r1=1034338&r2=1034385&rev=1034385&view=diff > ============================================================================== > --- > xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java > (original) > +++ > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > Fri Nov 12 13:04:26 2010 > @@ -17,21 +17,23 @@ > > /* $Id$ */ > > -package org.apache.fop.svg; > +package org.apache.xmlgraphics.java2d.ps; > > +import java.awt.GraphicsConfiguration; > import java.awt.GraphicsDevice; > import java.awt.Rectangle; > import java.awt.Transparency; > import java.awt.geom.AffineTransform; > import java.awt.image.BufferedImage; > import java.awt.image.ColorModel; > - > +import java.awt.image.VolatileImage; > > /** > * Our implementation of the class that returns information about > * roughly what we can handle and want to see (alpha for example). > */ > -class PDFGraphicsConfiguration extends GraphicsConfiguration { > +class PSGraphicsConfiguration extends GraphicsConfiguration { > + > // We use this to get a good colormodel.. > private static final BufferedImage BI_WITH_ALPHA > = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); > @@ -39,15 +41,8 @@ class PDFGraphicsConfiguration extends G > private static final BufferedImage BI_WITHOUT_ALPHA > = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); > > - /** > - * Construct a buffered image with an alpha channel, unless > - * transparencty is OPAQUE (no alpha at all). > - * > - * @param width the width of the image > - * @param height the height of the image > - * @param transparency the alpha value of the image > - * @return the new buffered image > - */ > + /** {...@inheritdoc} */ > + �...@override > public BufferedImage createCompatibleImage(int width, int height, > int transparency) { > if (transparency == Transparency.OPAQUE) { > @@ -59,44 +54,42 @@ class PDFGraphicsConfiguration extends G > } > } > > - /** > - * Construct a buffered image with an alpha channel. > - * > - * @param width the width of the image > - * @param height the height of the image > - * @return the new buffered image > - */ > + /** {...@inheritdoc} */ > + �...@override > public BufferedImage createCompatibleImage(int width, int height) { > return new BufferedImage(width, height, > BufferedImage.TYPE_INT_ARGB); > } > > - /** > - * TODO: This should return the page bounds in Pts, > - * I couldn't figure out how to get this for the current > - * page from the PDFDocument (this still works for now, > - * but it should be fixed...). > - * > - * @return the bounds of the PDF document page > - */ > + /** {...@inheritdoc} */ > + �...@override > + public VolatileImage createCompatibleVolatileImage(int width, int > height) { > + throw new UnsupportedOperationException( > + "Creation of VolatileImage instances is not supported"); > + } > + > + /** {...@inheritdoc} */ > + �...@override > + public VolatileImage createCompatibleVolatileImage(int width, int > height, int transparency) { > + throw new UnsupportedOperationException( > + "Creation of VolatileImage instances is not supported"); > + } > + > + /** {...@inheritdoc} */ > + �...@override > public Rectangle getBounds() { > + //Not applicable to vector graphic devices. Up to date, it works > like this. > return null; > } > > - /** > - * Return a good default color model for this 'device'. > - * @return the colour model for the configuration > - */ > + /** {...@inheritdoc} */ > + �...@override > public ColorModel getColorModel() { > return BI_WITH_ALPHA.getColorModel(); > } > > - /** > - * Return a good color model given <code>transparency</code> > - * > - * @param transparency the alpha value for the colour model > - * @return the colour model for the configuration > - */ > + /** {...@inheritdoc} */ > + �...@override > public ColorModel getColorModel(int transparency) { > if (transparency == Transparency.OPAQUE) { > return BI_WITHOUT_ALPHA.getColorModel(); > @@ -105,34 +98,22 @@ class PDFGraphicsConfiguration extends G > } > } > > - /** > - * The default transform (1:1). > - * > - * @return the default transform for the configuration > - */ > + /** {...@inheritdoc} */ > + �...@override > public AffineTransform getDefaultTransform() { > return new AffineTransform(); > } > > - /** > - * The normalizing transform (1:1) (since we currently > - * render images at 72dpi, which we might want to change > - * in the future). > - * > - * @return the normalizing transform for the configuration > - */ > + /** {...@inheritdoc} */ > + �...@override > public AffineTransform getNormalizingTransform() { > return new AffineTransform(2, 0, 0, 2, 0, 0); > } > > - /** > - * Return our dummy instance of GraphicsDevice > - * > - * @return the PDF graphics device > - */ > + /** {...@inheritdoc} */ > + �...@override > public GraphicsDevice getDevice() { > - return new PDFGraphicsDevice(this); > + return new PSGraphicsDevice(this); > } > > -} > - > +} > \ No newline at end of file > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > ------------------------------------------------------------------------------ > svn:keywords = Id > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java > ------------------------------------------------------------------------------ > --- svn:mergeinfo (added) > +++ svn:mergeinfo Fri Nov 12 13:04:26 2010 > @@ -0,0 +1,3 @@ > +/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java:603620-746655 > +/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java:684572,688085,688696 > +/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java:959975-964707 > > Copied: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > (from r1034339, > xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsDevice.java) > URL: > http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java?p2=xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsDevice.java&r1=1034339&r2=1034385&rev=1034385&view=diff > ============================================================================== > --- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsDevice.java > (original) > +++ > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > Fri Nov 12 13:04:26 2010 > @@ -17,77 +17,52 @@ > > /* $Id$ */ > > -package org.apache.fop.svg; > +package org.apache.xmlgraphics.java2d.ps; > > -import java.awt.GraphicsDevice; > -import java.awt.GraphicsConfiguration; > import java.awt.GraphicsConfigTemplate; > +import java.awt.GraphicsConfiguration; > +import java.awt.GraphicsDevice; > > /** > * This implements the GraphicsDevice interface as appropriate for > - * a PDFGraphics2D. This is quite simple since we only have one > - * GraphicsConfiguration for now (this might change in the future > - * I suppose). > + * a PSGraphics2D. This is quite simple since we only have one > + * GraphicsConfiguration for now. > */ > -class PDFGraphicsDevice extends GraphicsDevice { > +class PSGraphicsDevice extends GraphicsDevice { > > - /** > - * The Graphics Config that created us... > - */ > + /** The Graphics Config that created us... */ > protected GraphicsConfiguration gc; > > /** > - * Create a new PDF graphics device. > + * Create a new PostScruot graphics device. > * > * @param gc The graphics configuration we should reference > */ > - PDFGraphicsDevice(PDFGraphicsConfiguration gc) { > + PSGraphicsDevice(GraphicsConfiguration gc) { > this.gc = gc; > } > > - /** > - * Ignore template and return the only config we have > - * > - * @param gct the template configuration > - * @return the best configuration which is the only one > - */ > - public GraphicsConfiguration getBestConfiguration( > - GraphicsConfigTemplate gct) { > + /** {...@inheritdoc} */ > + public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate > gct) { > return gc; > } > > - /** > - * Return an array of our one GraphicsConfig > - * > - * @return an array containing the one graphics configuration > - */ > + /** {...@inheritdoc} */ > public GraphicsConfiguration[] getConfigurations() { > return new GraphicsConfiguration[] {gc}; > } > > - /** > - * Return out sole GraphicsConfig. > - * > - * @return the graphics configuration that created this object > - */ > + /** {...@inheritdoc} */ > public GraphicsConfiguration getDefaultConfiguration() { > return gc; > } > > - /** > - * Generate an IdString.. > - * > - * @return the ID string for this device, uses toString > - */ > + /** {...@inheritdoc} */ > public String getIDstring() { > return toString(); > } > > - /** > - * Let the caller know that we are "a printer" > - * > - * @return the type which is always printer > - */ > + /** {...@inheritdoc} */ > public int getType() { > return GraphicsDevice.TYPE_PRINTER; > } > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > ------------------------------------------------------------------------------ > svn:keywords = Id > > Propchange: > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java > ------------------------------------------------------------------------------ > --- svn:mergeinfo (added) > +++ svn:mergeinfo Fri Nov 12 13:04:26 2010 > @@ -0,0 +1,3 @@ > +/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFGraphicsDevice.java:603620-746655 > +/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFGraphicsDevice.java:684572,688085,688696 > +/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/svg/PDFGraphicsDevice.java:959975-964707 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
