CanvasGraphics2D setTransform

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Locked
hanafey
Posts: 2
Joined: Wed Apr 30, 2014 4:43 pm
antibot: No, of course not.

CanvasGraphics2D setTransform

Post by hanafey » Wed Apr 30, 2014 4:57 pm

The script produced by CanvasGraphics2D uses "setTransform". This seems to make it impossible to use the "ctx.scale()" method to easily dynamically scale a graphic. If you try this, only a some of the graphic is scaled, but after the absolute "setTranform()" method call , "scale()" gets reset.

In general it would be nice if a script could be produced that could be easily manipulated by some other externally provided java script.

(yes, I did get my employer to buy the docs!)

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: CanvasGraphics2D setTransform

Post by david.gilbert » Mon May 05, 2014 4:14 pm

Can you clarify exactly how you want to apply the scaling? We are using a test suite to ensure that the transformations on our Graphics2D implementations are giving the same results as the reference implementation, so I'd like to understand whether we have a bug for a particular combination of transforms or if the scaling you want to perform on the CanvasGraphics2D would break the behavior expected for Graphics2D.

Earlier I considered having the script generated by CanvasGraphics2D use width ('w') and height ('h') variables and do all drawing relative to these values - this would at least give the possibility to resize the chart nicely. I didn't do that yet, since if you need to be able to scale the chart then the SVGGraphics2D class is probably a better solution.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

hanafey
Posts: 2
Joined: Wed Apr 30, 2014 4:43 pm
antibot: No, of course not.

Re: CanvasGraphics2D setTransform

Post by hanafey » Mon Jun 16, 2014 5:08 pm

What I was hoping to do was to generate one SVG script, and then draw the graphic twice, once as a thumbnail, and then if this thumbnail was clicked to draw a full scale plot. The SVG files are quite large, and so creating two size versions would be inefficient.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: CanvasGraphics2D setTransform

Post by david.gilbert » Wed Jun 25, 2014 7:59 am

You mean JavaScript rather than SVG, right? Anyway, I think you are correct that the script being output should preserve the incoming transform, so I will work on that.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked