You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Nicolas VEYSSIERE <ni...@thalesgroup.com> on 2008/06/27 13:28:08 UTC

CPU to 100% when JSVGCanvas is under a jframe

Hello, I am new to Batik, but it is really a great API, and like it.

But I have a little problem, I am using batik in a JFrame application
that is using JDesktopPane, so I have many little 'frames' that can be
moved in the main frame, and one is displaying a JSVGCanvas (in the
future there will be an other JSVGCanvas).

Here is the problem : if the canvas is displayed entirely (we can see
all the SVG document on the screen) no problem occurs, and CPU is low,
because I am using this init code :

svgCanvas = new JSVGCanvas(null, false, false);
svgCanvas.setURI(getClass().getResource("alarmes.svg").toString());
svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.setBackground(Color.BLACK);
svgCanvas.setDoubleBuffered(true);
svgCanvas.setDoubleBufferedRendering(true);
svgCanvas.setProgressivePaint(true); // ????
svgCanvas.setRecenterOnResize(true);
svgCanvas.setOpaque(true);
svgCanvas.setAnimationLimitingFPS(1);
svgCanvas.setAnimationLimitingCPU((float) 0.01);



But there is a big problem : if the user move a frame over the
JSVGCanvas, the CPU is burning (90% or more).

I think it is because that the canvas have to refresh only the visible
part, but it is really anoying, why does the LimitingFPS don't seems to
work when a frame is over the canvas ?


DEV Environment : JDK 1.6u10b - Netbeans 6.1 - OS running the
application : Windows / Linux

Thanks.

-- 
iXĂ´


Re: CPU to 100% when JSVGCanvas is under a jframe

Posted by Nicolas VEYSSIERE <ni...@thalesgroup.com>.
Ok, problem solved !

For information :

in the JPanel that as the JSVGCanvas, I have overried the paint method
like that :

public void paint()
{
    if(initDone)
    {
      
svgCanvas.setRenderingTransform(AffineTransform.getScaleInstance(getWidth()
/ svgWidth, (getHeight() ) / svgHeight));
    }

    super.paint();
}

So now I have put the setRenderingTransform in the "public void
gvtBuildCompleted(GVTTreeBuilderEvent e)" method


Thanks.
> Hello, I am new to Batik, but it is really a great API, and like it.
>
> But I have a little problem, I am using batik in a JFrame application
> that is using JDesktopPane, so I have many little 'frames' that can be
> moved in the main frame, and one is displaying a JSVGCanvas (in the
> future there will be an other JSVGCanvas).
>
> Here is the problem : if the canvas is displayed entirely (we can see
> all the SVG document on the screen) no problem occurs, and CPU is low,
> because I am using this init code :
>
> svgCanvas = new JSVGCanvas(null, false, false);
> svgCanvas.setURI(getClass().getResource("alarmes.svg").toString());
> svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> svgCanvas.setBackground(Color.BLACK);
> svgCanvas.setDoubleBuffered(true);
> svgCanvas.setDoubleBufferedRendering(true);
> svgCanvas.setProgressivePaint(true); // ????
> svgCanvas.setRecenterOnResize(true);
> svgCanvas.setOpaque(true);
> svgCanvas.setAnimationLimitingFPS(1);
> svgCanvas.setAnimationLimitingCPU((float) 0.01);
>
>
>
> But there is a big problem : if the user move a frame over the
> JSVGCanvas, the CPU is burning (90% or more).
>
> I think it is because that the canvas have to refresh only the visible
> part, but it is really anoying, why does the LimitingFPS don't seems to
> work when a frame is over the canvas ?
>
>
> DEV Environment : JDK 1.6u10b - Netbeans 6.1 - OS running the
> application : Windows / Linux
>
> Thanks.
>
>