Closed mudgen closed 8 years ago
Which Java Virtual Machine and which version of it are you using? Are you running it in Jython or something along those lines?
Yes, I am using Jython. I am using Oracle Java 8. I am also using the Alloy Look and Feel: http://lookandfeel.incors.com
Best,
On Tue, Dec 29, 2015 at 2:02 PM, Michael Seifert notifications@github.com wrote:
Which Java Virtual Machine and which version of it are you using? Are you running it in Jython or something along those lines?
— Reply to this email directly or view it on GitHub https://github.com/eseifert/vectorgraphics2d/issues/34#issuecomment-167887171 .
I don't see any VectorGraphics2D code involved in your stack trace. To make sure the problem is caused by SVGGraphics2D could you please try to use a Graphics
instance from an image object in g
instead of SVGGraphics2D like this
BufferedImage img = new BufferedImage(320, 240, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) img.getGraphics();
and report back?
Using the Graphics instance from a BufferedImage works without a problem. Here is the code that works without an exception. My code is in Jython:
from java.awt.image import BufferedImage
from de.erichseifert.vectorgraphics2d import SVGGraphics2D
button = event.source.parent.getComponent("Button 1")
img = BufferedImage(320, 240, BufferedImage.TYPE_INT_RGB)
g = img.getGraphics()
button.paint(g)
This is the exact code that is throwing the exception:
from de.erichseifert.vectorgraphics2d import SVGGraphics2D
button = event.source.parent.getComponent("Button 1")
g = SVGGraphics2D(0,0,200,200)
button.paint(g)
The problems seems to be related to the Alloy look and feel.
I was told by someone that the Alloy look and feel is getting a null value from the Graphics2D object when it needs a GraphicsConfiguration object. Is the getDeviceConfiguration() method returning null?
Indeed, this is the case. I'll have a look at it.
Could you please clone and test the 0.9 branch from git? If it solves the issue I can do a new VectorGraphics2D release. Thanks.
Thanks. I tested it out and it solved the null exception error. But the generated svg file is not good. I tried converted a swing container with various swing components in it to SVG. Only the button displays in the SVG file and it does not display well. I attached an image that shows this. The left side is what the container with components look like, and the right side shows what the generated SVG file looks like .
Here is the exact code I am using in Jython. Am I doing something wrong? This script is on the mouseClicked event of the container.
from de.erichseifert.vectorgraphics2d import SVGGraphics2D path = system.file.saveFile("window.svg",".svg","SVG") if path == None: sys.exit() comp = event.source g = SVGGraphics2D(0,0,comp.width,comp.height) comp.paint(g) system.file.writeFile(path, g.toString())
Why does it not print all the components in the container?
I cannot speak for the Alloy L&F specifically, but as far as I remember we had problems with Swing in general. Swing makes extensive use of Graphics.create()
and Graphics.dispose()
, which wasn't handled properly in the past. However, this has been addressed quite some time ago and should work in the current master branch.
We are trying to get out a new release of VG2D with all the new code, but a few issues are left. If you don't want to wait or cannot wait, you test the version in master. The tests for Swing work fine in commit b23b003c62c8a5c71a557fc3ca58510105fe9e36 (at least for EPS and PDF, haven't checked SVG recently).
No response from reporter. Please reopen if necessary.
I am getting the following exception when I run: comp.paint(g). And "g" is an SVGGraphics2D. Can something be done to fix this?