Loading ...
Sorry, an error occurred while loading the content.

Re: Big svg

Expand Messages
  • Peruzzi Alessandro
    My problem isn t to generate svg dom but in my applet the ploblem is to popolate a swing canvas (org.apache.batik.swing.JSVGCanvas) including svg creation.
    Message 1 of 7 , Jul 1 12:08 AM
    • 0 Attachment
      My problem isn't to generate svg dom but in my applet the ploblem is
      to popolate a swing canvas (org.apache.batik.swing.JSVGCanvas)
      including svg creation. Therefore the problem is to conversion
      SVGDocument into swing component.

      Code to do it is:
      // generate SVGDocument with org.apache.batik
      // and then the conversion in a swing component

      JSVGCanvas canvas = new JSVGCanvas();
      canvas.setSVGDocument(svgDocument);

      Up to 100000-150000 elements is ok but over this number of elements
      the conversion is more slow. (I need 300000-500000 elements)

      How do I do it?
      There is another best methods for do it?

      Thanks a lot.
      Alessandro Peruzzi (sorry for my English)


      --- In svg-developers@yahoogroups.com, Peter Thompson
      <plthompson2004@y...> wrote:
      > There are too many elements, making it unable to display, or very
      slow.
      >
      > I was able to display 365,000 rects in batik and deer park (mozilla
      nightly build with SVG enabled). It takes a long time to display,
      and screen updates were very slow. It would no be usable.
      >
      > What are you really trying to do? You probably aren't planning on
      looking at all 365,000 rectangles at the same time. If you are, then
      you should probably should be be using a raster image. Is there
      another way to solve the problem, like displaying only the rectangles
      that can be seen, and updating the DOM (via interactions with a web
      server) as the user pans? Or if continguous rectanges are the same
      color, draw them as a single rectangle?
      >
      > I also tried 1000 text elements, each with 365 characters (thinking
      that you could use a character that looks like a square) and that was
      also too slow.
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Tired of spam? Yahoo! Mail has the best spam protection around
      > http://mail.yahoo.com
      >
      > [Non-text portions of this message have been removed]
    • Thomas DeWeese
      ... The thing is that the way you are creating the document (lots and lots of rects) is causing your problem when you try to display it. Can you provide some
      Message 2 of 7 , Jul 1 5:02 AM
      • 0 Attachment
        Peruzzi Alessandro wrote:
        > My problem isn't to generate svg dom but in my applet the ploblem is
        > to popolate a swing canvas (org.apache.batik.swing.JSVGCanvas)
        > including svg creation. Therefore the problem is to conversion
        > SVGDocument into swing component.

        The thing is that the way you are creating the document
        (lots and lots of rects) is causing your problem when you
        try to display it. Can you provide some description of
        how these 100's of thousands of rects are laid out?

        If they are in a regular grid I would look at combining
        rects that have the same fill. Also if the rects are
        stroked you are much better off having grid lines that run the
        full height/width of the table rather than stroking each rect
        separately (much less geometry and you aren't double
        stroking everything). Also you may find that path elements
        are better than rects (and they are easier to use to combine
        elements).

        > Code to do it is:
        > // generate SVGDocument with org.apache.batik
        > // and then the conversion in a swing component
        >
        > JSVGCanvas canvas = new JSVGCanvas();
        > canvas.setSVGDocument(svgDocument);
        >
        > Up to 100000-150000 elements is ok but over this number of elements
        > the conversion is more slow. (I need 300000-500000 elements)
        >
        > How do I do it?
        > There is another best methods for do it?

        Can you generate the rects 'as needed'? So if the document
        is generally larger than the display (you can even force this)
        then you only generate the rects for the currently visible portion.

        Performance might also be slightly better if you introduce
        grouping (for example put all the rects for a row in a group)
        rather than having one parent with 500K children.

        Hope these ideas help. You might also want to check out
        the Batik-users mail-list (although most of my comments above
        apply to any SVG renderer).
      Your message has been successfully submitted and would be delivered to recipients shortly.