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 Stephan Zuiderwijk <st...@technolution.nl> on 2005/12/01 15:03:49 UTC

Scaling in batik extension

Hi,
 
I'm quite new to batik, I've got a question about scaling in batik. In a
Java application I am showing map of europe in a JSVGCanvas. The cities are
shown as little red circles. When a user clicks on a circle, a tooltip is
presenting the name of the city to the user. The map and circles are
scripted in a svg file, the event handling is done in my JSVGCanvas. Till
now everything works but what I want to achieve is the following. When a
user zooms in at the map, the circles should resize so that they stay at the
same size for the user's point of view. Can anybody help me out with this?
 
Kind regards,
 
Steef
 

RE: Scaling in batik extension

Posted by th...@kodak.com.
Hi Stephan,

"Stephan Zuiderwijk" <st...@technolution.nl> wrote on 
12/05/2005 02:04:16 AM:

> thank you for your fast reply. I've been playing around with your
> sugestions. It works fine. Because of the large amount of items (app. 
5500)
> I cached the circle elements when my JSVGCanvas is first opened. 

   If the update is slow (and I suspect it might be as our CSS engine has
some O(N^2) behavior when modifying all the children of a group), and you
are not afraid of a small 'hack' you might consider using the stroke to
adjust the 'size' of the circles:

        <g stroke-width="2" fill="red" stroke="red">
           <circle r="0.0000001"  cx="..." .../>
           <circle r="0.0000001" ..../>
        </g>

   To update the 'radius' of the circles you now only need to update
the 'stroke-width' on the surrounding 'g' element.  The CSS engine will
quickly cascade this to all of the children in one step.  The other 
advantage is that I think this will only update the shape painter instead
of essentially rebuilding the circle from scratch.

   But it is a hack (in the best sense of the word) and will basically 
only work for circles.


> 
> Kind regards,
> 
> Stephan Zuiderwijk 
> 
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
> Sent: Friday, December 02, 2005 11:46 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: Scaling in batik extension
> 
> Hi Stephan,
> 
> "Stephan Zuiderwijk" <st...@technolution.nl> wrote on
> 12/01/2005 09:03:49 AM:
> 
> > I'm quite new to batik, I've got a question about scaling in batik. In 

> > a
> Java 
> > application I am showing map of europe in a JSVGCanvas. The cities are
> shown 
> > as little red circles. [...] what I want to achieve is the following. 
> When a 
> > user zooms in at the map, the circles should resize so that they stay 
> > at
> the 
> > same size for the user's point of view. Can anybody help me out with
> this?
> 
>   You want to capture 'onzoom' events.  You can then query the 
> currentScale on
> the root SVG element.  You can then use this to update the 'r' attribute 

> on
> your circle elements (this is mostly easily done if all the circles are 
> the
> child of a 'cities' layer or something, then you can just iterate 
through
> all the element children of the group and update the 'r' attribute).
> 
>   All of this can be done in either script or Java.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scaling in batik extension

Posted by Stephan Zuiderwijk <st...@technolution.nl>.
Hi thomas,

thank you for your fast reply. I've been playing around with your
sugestions. It works fine. Because of the large amount of items (app. 5500)
I cached the circle elements when my JSVGCanvas is first opened. 

Kind regards,

Stephan Zuiderwijk 

-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: Friday, December 02, 2005 11:46 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Scaling in batik extension

Hi Stephan,

"Stephan Zuiderwijk" <st...@technolution.nl> wrote on
12/01/2005 09:03:49 AM:

> I'm quite new to batik, I've got a question about scaling in batik. In 
> a
Java 
> application I am showing map of europe in a JSVGCanvas. The cities are
shown 
> as little red circles. [...] what I want to achieve is the following. 
When a 
> user zooms in at the map, the circles should resize so that they stay 
> at
the 
> same size for the user's point of view. Can anybody help me out with
this?

  You want to capture 'onzoom' events.  You can then query the 
currentScale on
the root SVG element.  You can then use this to update the 'r' attribute 
on
your circle elements (this is mostly easily done if all the circles are 
the
child of a 'cities' layer or something, then you can just iterate through
all the element children of the group and update the 'r' attribute).

  All of this can be done in either script or Java.
 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Scaling in batik extension

Posted by th...@kodak.com.
Hi Stephan,

"Stephan Zuiderwijk" <st...@technolution.nl> wrote on 
12/01/2005 09:03:49 AM:

> I'm quite new to batik, I've got a question about scaling in batik. In a 
Java 
> application I am showing map of europe in a JSVGCanvas. The cities are 
shown 
> as little red circles. [...] what I want to achieve is the following. 
When a 
> user zooms in at the map, the circles should resize so that they stay at 
the 
> same size for the user's point of view. Can anybody help me out with 
this?

  You want to capture 'onzoom' events.  You can then query the 
currentScale on
the root SVG element.  You can then use this to update the 'r' attribute 
on
your circle elements (this is mostly easily done if all the circles are 
the
child of a 'cities' layer or something, then you can just iterate through
all the element children of the group and update the 'r' attribute).

  All of this can be done in either script or Java.
 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org