blackears / svgSalamander

158 stars 57 forks source link

On Windows the clip region messes up render but not Linux #16

Closed lessthanoptimal closed 7 years ago

lessthanoptimal commented 7 years ago

I'm rendering to a JPanel and on Linux it behaves as expected but on Windows the rendering is offset to the location of the clip region. So if you do repaint() on the JPanel it works just fine but if you do repaint(50,60,200,200) it will be translated by (50,60) pixels. You also need to specify a transform as is shown in the code below. It's also intermittent.

I'm using this version on Gradle: compile group: 'com.metsci.ext.com.kitfox.svg', name: 'svg-salamander', version: '0.1.19'

The code looks something like:

In Constructor

svg = new SVGUniverse();
uri = svg.loadSVG(classloader.getResource( "image.svg"));
diagram = svg.getDiagram(uri);

In paintComponent()

transform.setTransform(0.1,0,0, 0.1,20,10);
g2.setTransform(transform);
diagram .render(g2);
lessthanoptimal commented 7 years ago

And I found the problem. Have absolutely no idea why this was working in Linux. Maybe I didn't stumble into this situation? The transform should have been concated on top of the original one.

Sorry for the noise!