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 William Huang <sh...@xperient.net> on 2003/01/09 23:41:47 UTC

How to disable JSVGCanvas automatic resizing?

The JSVGCanvas by default automatically adapts its size to the size of
the document. I want to disable this behavior. That is, if the SVG size
can't fit into the browser window, it will just display a part that can
be accommodated in this window and show scrollbar. I also don't want
this displayed image being clipped to window size. Which program should
I modify? 
 
And for the scrolling to work, I need to know information about the
actual SVG size. For example, when I load an SVG file with
width="10.278in" and height="9.167in" using image tag, specify size
800,600 for the image node, then I get 800 when I call getWidth of this
image node. How can I deal with this problem? Thanks a lot.
Best regards,
William    
 
 

Re: Question about SVG and Batik usage - voting system

Posted by Vincent Hardy <vi...@sun.com>.
Hello Stefan,

I think SVG can definitely help in your scenario. Here are a few 
examples of things which help:

a. <use>
=========

    In SVG, you can define a template content (typically in a <defs> 
section) and later refer to it in a <use>. For example:

    <defs>
       <g id="chairTemplate">
           <rect x="0" y="0" width="20" height="40" fill="green" />
       </g>
    </defs>

    <use xlink:href="#chairTemplate" x="30" y="30" />
    <use xlink:href="#chairTemplate" x="20" y="130" />
    ...

   Of course, you can make the chair a lot nicer than a green rectangle :-)

b. Support for mixed namespaces.
=================================

    In XML and in SVG in particular, you can mix namespaces. That means 
that you can mix content from different grammars in the same document. 
So, using your example, you could embed the floor definition information 
the way you have expressed it:

<svg onload="init()">
 > <floorplan id="myFloorPlan" xmlns="myNameSpace">
 >     <chair id="1">
 >         <location>...</location>
 >     </char>
 >     <chair id="2">
 >         <location>...</location>
 >     </char>
 >     <wall>
 >         ....
 >     </wall>
 > </floorplan>
</svg>

and then, by script, you can access that <floorplan> information and 
build the graphical content. Something like:

   <script>
function init() {
     var floorplan = document.getElementById("myFloorPlan");
     var chairs = floorplan.getElementsByTagNameNS("myNameSpace", "chair");
     var nChairs = chairs.getLength();
     for (var i=0; i<nChairs; i++) {
        var chair = document.createElementNS(svgNS, "use");
        chair.setAttributeNS(xlinkNS, "xlink:href", "#chairTemplate");
        chair.setAttributeNS(null, "x", ....);
        .....
     }
}

   </script>

Note how the 'onload' attribute on the root <svg> invokes the init() 
function.

This is not quite cut-and-paste code and the use of mixed namespace may 
or may not be a good idea depending on your architecture, but this is 
food for thoughts.

I hope this helps.

In terms of resources, Randy pointed out some very interesting examples 
from Adobe. You'll find a lot of pointers to SVG resources at:

http://www.w3.org/Graphics/SVG.

Vincent.

Stefán Freyr Stefánsson wrote:
> Hello.
> 
> I know that this mailing list should be used for questions regarding the Batik 
> software itself and general SVG questions should go to some W3C mailing list 
> as stated on the Batik web page.  However, the mailing list address given on 
> the Batik web page that is supposed to subscribe to the W3C SVG mailing list 
> seems to be broken.  I did eventually find a mailing list that is supposedly 
> about SVG at the W3C but so far I've seen no signs of life on that list so I 
> hope that you forgive me for asking this question here.
> 
> The problem that I'm facing is that I need to create an application that can 
> show a descriptive overview image of a meeting room (it's actually the 
> chamber of the Icelandic parliament).  This application will be hooked up to 
> a voting system and needs to be able to display accurately the status of 
> votes in the chamber.  For that it needs to display an image of the floor and 
> each seat is represented by a color that indicates how the person that sits 
> there voted.  Now, the tricky part about this is that this floor plan needs 
> to be dynamic...  the number of members of parliament can change (the number 
> and layout of chairs would therefore change too) so there needs to be a way 
> of defining the floor plan without having to build the whole system again.
> 
> So my question is: Would SVG be a good candidate to solve my problem?  Does 
> anybody have other ideas about what technique could be used for this?
> 
> My dream is to have the floor plan in an XML document that describes the 
> layout/location of the seats and maybe even more information such as the 
> locations of walls to give a better impression of the room itself.  An 
> example of the XML document defining the floor plan might be something like:
> <floorplan>
>     <chair id="1">
>         <location>...</location>
>     </char>
>     <chair id="2">
>         <location>...</location>
>     </char>
>     <wall>
>         ....
>     </wall>
> </floor>
> 
> I know that this doesn't conform to the SVG document type (and no... this idea 
> hasn't been fully sculpted even) but I'm just describing what I'm thinking... 
> I will then adopt this idea to the SVG documents if SVG is indeed a viable 
> option to solve this problem.
> 
> Optimally there would be just one document describing the layout of the room, 
> the system would therefore be able to draw up the floor plan by using that 
> document.  The voting system would also read this document and parse out the 
> location of all the "chair" elements and it would read the status of each 
> vote for each of the chairs from the voting system.  It could then create a 
> "layer" where, for example, a chair that votes "yes" is displayed as a green 
> area and a vote of "no" is displayed as red and "pass" is displayed as 
> yellow.  There would also have to be other layers for each seat such as 
> displaying the name of the person sitting in the seat, what party that person 
> is associated with and so on.
> 
> If anybody could give me some pointers on whether SVG would be usable for this 
> situation I'd be very grateful.  I want to stress that I'm not a lazy bum 
> trying to get the solution to my problem here but my first impression of SVG 
> is that it's a rather complicated but powerful tool and I'd just like to know 
> if I'm on the right track by throwing myself in the deep end of the SVG-pool.  
> If anybody knows of anything similar to what I've described, I'd really like 
> to know about it of course :o)
> 
> Kind regards and thanks in advance for any answers.
> Stefan Freyr.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> 



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


Question about SVG and Batik usage - voting system

Posted by Stefán Freyr Stefánsson <st...@althingi.is>.
Hello.

I know that this mailing list should be used for questions regarding the Batik 
software itself and general SVG questions should go to some W3C mailing list 
as stated on the Batik web page.  However, the mailing list address given on 
the Batik web page that is supposed to subscribe to the W3C SVG mailing list 
seems to be broken.  I did eventually find a mailing list that is supposedly 
about SVG at the W3C but so far I've seen no signs of life on that list so I 
hope that you forgive me for asking this question here.

The problem that I'm facing is that I need to create an application that can 
show a descriptive overview image of a meeting room (it's actually the 
chamber of the Icelandic parliament).  This application will be hooked up to 
a voting system and needs to be able to display accurately the status of 
votes in the chamber.  For that it needs to display an image of the floor and 
each seat is represented by a color that indicates how the person that sits 
there voted.  Now, the tricky part about this is that this floor plan needs 
to be dynamic...  the number of members of parliament can change (the number 
and layout of chairs would therefore change too) so there needs to be a way 
of defining the floor plan without having to build the whole system again.

So my question is: Would SVG be a good candidate to solve my problem?  Does 
anybody have other ideas about what technique could be used for this?

My dream is to have the floor plan in an XML document that describes the 
layout/location of the seats and maybe even more information such as the 
locations of walls to give a better impression of the room itself.  An 
example of the XML document defining the floor plan might be something like:
<floorplan>
    <chair id="1">
        <location>...</location>
    </char>
    <chair id="2">
        <location>...</location>
    </char>
    <wall>
        ....
    </wall>
</floor>

I know that this doesn't conform to the SVG document type (and no... this idea 
hasn't been fully sculpted even) but I'm just describing what I'm thinking... 
I will then adopt this idea to the SVG documents if SVG is indeed a viable 
option to solve this problem.

Optimally there would be just one document describing the layout of the room, 
the system would therefore be able to draw up the floor plan by using that 
document.  The voting system would also read this document and parse out the 
location of all the "chair" elements and it would read the status of each 
vote for each of the chairs from the voting system.  It could then create a 
"layer" where, for example, a chair that votes "yes" is displayed as a green 
area and a vote of "no" is displayed as red and "pass" is displayed as 
yellow.  There would also have to be other layers for each seat such as 
displaying the name of the person sitting in the seat, what party that person 
is associated with and so on.

If anybody could give me some pointers on whether SVG would be usable for this 
situation I'd be very grateful.  I want to stress that I'm not a lazy bum 
trying to get the solution to my problem here but my first impression of SVG 
is that it's a rather complicated but powerful tool and I'd just like to know 
if I'm on the right track by throwing myself in the deep end of the SVG-pool.  
If anybody knows of anything similar to what I've described, I'd really like 
to know about it of course :o)

Kind regards and thanks in advance for any answers.
Stefan Freyr.

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