Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-509

Documentation and Interface on SVGGraphics2D is cryptic



    • Type: Improvement
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.5
    • Fix Version/s: None
    • Component/s: SVGGraphics2D
    • Labels:
    • Environment:
      Operating System: other
      Platform: Other


      A component we want to output as SVG (a TouchGraph graph panel) needs to have
      the offset set, as well as the drawing bounds, otherwise the SVG will draw
      outside the bounds of the page (and some tools clip out the graphics which are
      outside the page.)

      As there is a setSVGCanvasSize method but no setSVGCanvasOffset method, we had
      to improvise.


      if (g instanceof SVGGraphics2D)

      { TGPoint2D topLeft = getTGPanel().getTopLeftDraw(); TGPoint2D bottomRight = getTGPanel().getBottomRightDraw(); Element svgRoot = ((SVGGraphics2D) g).getRoot(); svgRoot.setAttribute("x", Double.toString(topLeft.x)); svgRoot.setAttribute("y", Double.toString(topLeft.y)); svgRoot.setAttribute("width", Double.toString(bottomRight.x - topLeft.x)); svgRoot.setAttribute("height", Double.toString(bottomRight.y - topLeft.y)); }

      The problem is that after doing this, there is nothing in the SVG file at all
      (not the graphics, nor even the attributes I just tried to set!) If I remove
      the whole block, the drawing works but has no x, y, width and height attributes
      are there.

      I would expect this to set the attributes on the SVG root element. I didn't ask
      it to remove the element from the tree, so it shouldn't remove the element from
      the tree. And setting attributes on an XML element should result in the
      attributes being set.




            • Assignee:
              batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
              trejkaz@xaoza.net Trejkaz Xaoza
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: