Hi Rolland,
The problem is that (ironically) the SVGGraphics2D doesn't support
output of complex
SVG gradients. You should file a bugzilla entry on this, but honestly I
don't know when we
would get to it. You might consider appending the source SVG to the
output document,
rather than depending on the SVGGenerator converting everything perfectly
(SVG is
a complex language and there are some things that don't map well).
Roland Haas <[EMAIL PROTECTED]> wrote on 10/21/2005 02:59:17 AM:
> I have created a programm with draggable and movable graphic elements
> represented as a single jcomponent. In this component I call the
> GraphicsNode.paint() Method for displaying it onto the screen.
> Here's the code snippet:
> This code causes no problem for displaying svg in the gui. When I want
> to create an svg file from the whole panel containing this components I
> call the following code:
>
> //...
> DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
> Document document = domImpl.createDocument(null, "svg", null);
> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
> svgGenerator.getGeneratorContext().setPrecision(12);
> ProjectPanel p =
>
(ProjectPanel)((PIAMainFrame)GraphicsWorkbench.MAINFRAME).getProjectPanel();
> //scaling the graphics
> svgGenerator.setTransform(AffineTransform.getScaleInstance(scale,
scale));
> //setting the final size
> svgGenerator.setSVGCanvasSize(new
> Dimension(getPDFDimension(props).width,(int)(scale*dim.getHeight())));
> //Paint the "static" content of the panel
> p.getGraphPanel().paintComponent(svgGenerator);
> //used to paint the jcomponents within the panel
> p.getGraphPanel().paintComponents(svgGenerator);
> boolean useCSS = false;
> Writer out;
> try {
> out = new OutputStreamWriter(new FileOutputStream(svgFile),
> "ISO-8859-1");
> svgGenerator.stream(out, useCSS);
> out.close();
> } catch (UnsupportedEncodingException e) {
> e.printStackTrace();
> } catch (SVGGraphics2DIOException e) {
> e.printStackTrace();
> }
> //...
>
> The export in the svg-file works perfectly, but there are some
> differences in the graphics in the generated svg-file and the gui
display.
> Take for example this small svg-grahpic:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!-- Created with Inkscape (http://www.inkscape.org/) -->
> <svg
> xmlns:svg="http://www.w3.org/2000/svg"
> xmlns="http://www.w3.org/2000/svg"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> version="1.0"
> x="0.00000000"
> y="0.00000000"
> width="25.000000"
> height="25.000000"
> id="svg2">
> <defs
> id="defs4">
> <linearGradient
> id="linearGradient2038">
> <stop
> style="stop-color:#36c228;stop-opacity:1.0000000"
> offset="0.00000000"
> id="stop2040" />
> <stop
> style="stop-color:#36c228;stop-opacity:0.00000000"
> offset="1.0000000"
> id="stop2042" />
> </linearGradient>
> <linearGradient
> x1="3.5039666"
> y1="5.1757565"
> x2="21.686712"
> y2="23.326935"
> id="linearGradient2044"
> xlink:href="#linearGradient2038"
> gradientUnits="userSpaceOnUse" />
> </defs>
> <g
> id="layer1">
> <rect
> width="24.401497"
> height="24.338364"
> x="0.31567267"
> y="0.34596437"
>
>
style="opacity:1.0000000;fill:url(#linearGradient2044);fill-opacity:1.0000000;
>
stroke:#000000;stroke-width:0.50338471;stroke-miterlimit:4.0000000;stroke-
> dasharray:none;stroke-dashoffset:0.00000000;stroke-opacity:1.0000000"
> id="rect1306" />
> <path
> d="M 1.9256033,2.3031349 C 1.9256033,23.421637
> 22.586380,22.963911 22.586380,22.963911 L 1.9256033,2.3031349 z "
>
>
style="fill:#0000e3;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#ee1620;
>
stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-
> opacity:1.0000000"
> id="path1308" />
> </g>
> </svg>
>
> In this specific case the "linearGradient2038" shows perfectly on the
> screen, but completely disappears in the svg-export-file from the panel.
> Here's the created svg file from the panel.
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
> <svg fill-opacity="1" xmlns:xlink="http://www.w3.org/1999/xlink"
> color-rendering="auto" color-interpolation="auto" text-rendering="auto"
> stroke="black" stroke-linecap="square" width="425"
> stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1"
> fill="black" stroke-dasharray="none" font-weight="normal"
> stroke-width="1" height="256" xmlns="http://www.w3.org/2000/svg"
> font-family="'Dialog'" font-style="normal"
> stroke-linejoin="miter" font-size="12" stroke-dashoffset="0"
> image-rendering="auto">
> <!--Generated by the Batik Graphics2D SVG Generator-->
> <defs id="genericDefs" />
> <g>
> <defs id="defs1">
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
> <path d="M0 -0.0000070010915 L885 -0.0000070010915 L885 45 L0 45
> L0 -0.0000070010915 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath2">
> <path d="M0 -0.0000070010915 L0 45 L885 45 L885 -0.0000070010915
> Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath3">
> <path d="M0 -0.000007539637 L885 -0.000007539637 L885
> 44.9999961853027 L0 44.9999961853027 L0 -0.000007539637 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath4">
> <path d="M0 -0.000007539637 L0 44.9999961853027 L885
> 44.9999961853027 L885 -0.000007539637 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath5">
> <path d="M0 -0.0000080781829 L885 -0.0000080781829 L885
> 44.9999961853027 L0 44.9999961853027 L0 -0.0000080781829 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath6">
> <path d="M0 -0.0000080781829 L0 44.9999961853027 L885
> 44.9999961853027 L885 -0.0000080781829 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath7">
> <path d="M0 -0.0000004039091 L885 -0.0000004039091 L885
> 44.9999961853027 L0 44.9999961853027 L0 -0.0000004039091 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath8">
> <path d="M0 -0.0000004039091 L0 44.9999961853027 L885
> 44.9999961853027 L885 -0.0000004039091 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath9">
> <path d="M0.0000251321235 0.0000011668485 L75.0000152587891
> 0.0000011668485 L75.0000152587891 43.0000038146973 L0.0000251321235
> 43.0000038146973 L0.0000251321235 0.0000011668485 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath10">
> <path d="M0.0000251321235 0.0000011668485 L0.0000251321235
> 43.0000038146973 L75.0000152587891 43.0000038146973 L75.0000152587891
> 0.0000011668485 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath11">
> <path d="M-0.0000139322719 0.000000674106 L-0.0000139322719
> 24.8417491912842 L25.0000133514404 24.8417491912842 L25.0000133514404
> 0.000000674106 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath12">
> <path d="M-0.0000079884248 0.000000628303 L74.9999923706055
> 0.000000628303 L74.9999923706055 43.0000038146973 L-0.0000079884248
> 43.0000038146973 L-0.0000079884248 0.000000628303 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath13">
> <path d="M-0.0000079884248 0.000000628303 L-0.0000079884248
> 43.0000038146973 L74.9999923706055 43.0000038146973 L74.9999923706055
> 0.000000628303 Z" />
> </clipPath>
> <clipPath clipPathUnits="userSpaceOnUse" id="clipPath14">
> <path d="M-0.0000045687552 0.0000003634235 L-0.0000045687552
> 24.872091293335 L24.9999942779541 24.872091293335 L24.9999942779541
> 0.0000003634235 Z" />
> </clipPath>
> </defs>
> <g fill="white"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)"
stroke="white">
> <rect width="915" x="0" height="553" y="0" stroke="none" />
> </g>
> <g transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)">
> <line y2="513" fill="none" x1="100" x2="100" y1="30" />
> </g>
> <g transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)">
> <line y2="513" fill="none" x1="100" x2="885" y1="513" />
> <line y2="508" fill="none" x1="885" x2="880" y1="513" />
> <line y2="518" fill="none" x1="885" x2="880" y1="513" />
> <text xml:space="preserve" x="482" y="545" font-weight="bold"
> stroke="none">Zeit</text>
> <text xml:space="preserve" x="80" y="22" font-weight="bold"
> stroke="none">Umfeld</text>
> <line y2="518" fill="none" x1="110" x2="110" y1="508" />
> <line y2="518" fill="none" x1="875" x2="875" y1="508" />
> <line y2="518" fill="none" x1="150" x2="150" y1="508" />
> <text xml:space="preserve" x="126" font-size="10" y="532"
> stroke="none">3.10.2005</text>
> <line y2="518" fill="none" x1="327" x2="327" y1="508" />
> <text xml:space="preserve" x="300" font-size="10" y="532"
> stroke="none">10.10.2005</text>
> <line y2="518" fill="none" x1="503" x2="503" y1="508" />
> <text xml:space="preserve" x="476" font-size="10" y="532"
> stroke="none">17.10.2005</text>
> <line y2="518" fill="none" x1="679" x2="679" y1="508" />
> <text xml:space="preserve" x="652" font-size="10" y="532"
> stroke="none">24.10.2005</text>
> <text xml:space="preserve" x="71" font-size="10" y="544"
> stroke="none">1.10.2005 09:00</text>
> <text xml:space="preserve" x="833" font-size="10" y="544"
> stroke="none">31.10.2005 17:00</text>
> <line fill="none" x1="613" x2="613" y1="30" y2="513" stroke="blue"
/>
> <line y2="220" fill="none" x1="260" x2="637" y1="133" />
> <polygon points=" 637 220 625 222 628 213" stroke="none" />
> </g>
> <g font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(0,399)">
> <line clip-path="url(#clipPath2)" fill="none" x1="100" x2="895"
> y1="22" y2="22" />
> <text xml:space="preserve" x="45" y="26"
> clip-path="url(#clipPath2)" stroke="none">Informatik</text>
> </g>
> <g font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(0,303)">
> <line clip-path="url(#clipPath4)" fill="none" x1="100" x2="895"
> y1="22" y2="22" />
> <text xml:space="preserve" x="20" y="26"
> clip-path="url(#clipPath4)" stroke="none">IT-Projektleiter</text>
> </g>
> <g font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(0,207)">
> <line clip-path="url(#clipPath6)" fill="none" x1="100" x2="895"
> y1="22" y2="22" />
> <text xml:space="preserve" x="21" y="26"
> clip-path="url(#clipPath6)" stroke="none">Fachabteilung</text>
> </g>
> <g font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(0,111)">
> <line clip-path="url(#clipPath8)" fill="none" x1="100" x2="895"
> y1="22" y2="22" />
> <text xml:space="preserve" x="16" y="26"
> clip-path="url(#clipPath8)" stroke="none">FA-Projektleiter</text>
> </g>
> <g fill="white" font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(637,208)" stroke="white">
> <rect x="0" y="0" clip-path="url(#clipPath10)" width="75"
> height="43" stroke="none" />
> <rect x="0.3156726658344" y="0.3459643721581"
> transform="translate(16,0)
> matrix(1.72656921438,0,0,1.7309571467949,0,0)"
> clip-path="url(#clipPath11)" width="24.401496887207"
> height="24.3383636474609" stroke="none" />
> </g>
> <g stroke-miterlimit="4" stroke-width="0.5033847093582"
> font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(653,208) matrix(1.72656921438,0,0,1.7309571467949,0,0)"
> stroke-linecap="butt">
> <rect x="0.3156726658344" y="0.3459643721581"
> clip-path="url(#clipPath11)" fill="none" width="24.401496887207"
> height="24.3383636474609" />
> </g>
> <g stroke-linecap="butt"
>
transform="matrix(0.8019583782639,0,0,0.8039964889484,303.3060109289618,96.
> 6120218579235)"
> fill="rgb(0,0,227)" font-family="'Arial'"
> stroke="rgb(0,0,227)" stroke-width="0.5033847093582"
stroke-miterlimit="4">
> <path d="M1.9256031513214 2.3031349182129 C1.9256031513214
> 23.4216365814209 22.5863800048828 22.9639110565186 22.5863800048828
> 22.9639110565186 L1.9256031513214 2.3031349182129 Z"
> clip-path="url(#clipPath11)" fill-rule="evenodd" stroke="none" />
> <path clip-path="url(#clipPath11)" fill="none" fill-rule="evenodd"
> d="M1.9256031513214 2.3031349182129 C1.9256031513214 23.4216365814209
> 22.5863800048828 22.9639110565186 22.5863800048828 22.9639110565186
> L1.9256031513214 2.3031349182129 Z" stroke="rgb(238,22,32)"
> stroke-width="1" />
> </g>
> <g stroke-miterlimit="4" font-family="'Arial'"
>
transform="matrix(0.4644808743169,0,0,0.4644808743169,303.3060109289618,96.
> 6120218579235)
> translate(-16,0)" stroke-linecap="butt">
> <text xml:space="preserve" x="19" y="21"
> clip-path="url(#clipPath10)" stroke="none">Sketch</text>
> <text x="0" font-size="10" y="31" clip-path="url(#clipPath10)"
> stroke="none" xml:space="preserve">22.10.05 22:30-</text>
> <text x="1" font-size="10" y="41" clip-path="url(#clipPath10)"
> stroke="none" xml:space="preserve">22.10.05 22:30</text>
> </g>
> <g fill="white" font-family="'Arial'"
> transform="matrix(0.4644808743169,0,0,0.4644808743169,0,0)
> translate(223,112)" stroke="white">
> <rect x="0" y="0" clip-path="url(#clipPath13)" width="75"
> height="43" stroke="none" />
> <path fill="rgb(214,124,53)" d="M24.9302463531494 12.4999952316284
> C24.9302463531494 19.3682327270508 19.3624362945557 24.9360408782959
> 12.494194984436 24.9360408782959 C5.6259517669678 24.9360408782959
> 0.0581420361996 19.3682327270508 0.0581420361996 12.4999952316284
> C0.0581420361996 5.6317582130432 5.6259517669678 0.0639519914985
> 12.494194984436 0.0639519914985 C19.3624362945557 0.0639519914985
> 24.9302463531494 5.6317582130432 24.9302463531494 12.4999952316284 Z"
> clip-path="url(#clipPath14)" transform="translate(16,0)
> matrix(1.728844446987,0,0,1.7288455076166,0,0)" stroke="none" />
> </g>
> <g fill="white" font-family="'Arial'"
>
transform="matrix(0.4644808743169,0,0,0.4644808743169,111.0109289617486,52.
> 0218579234973)
> translate(-16,0)" stroke="white">
> <rect x="0" y="0" clip-path="url(#clipPath13)" width="75"
> height="43" opacity="0.75" stroke="none" />
> <text x="25" y="21" clip-path="url(#clipPath13)" fill="black"
> stroke="none" xml:space="preserve">Test</text>
> <text x="0" font-size="10" y="31" clip-path="url(#clipPath13)"
> fill="black" stroke="none" xml:space="preserve">06.10.05 12:45-</text>
> <text x="1" font-size="10" y="41" clip-path="url(#clipPath13)"
> fill="black" stroke="none" xml:space="preserve">06.10.05 12:45</text>
> </g>
> </g>
> </svg>
>
>
> This issue is tested with the following configurations:
> - windowsXP jre1.4.2_08 with batik-1.5-fop-0.20-5.jar from
> http://www.ibiblio.org/maven/batik/jars/
> - windowwXP jre1.5.0_05 with batik-1.5-fop-0.20-5.jar from
> http://www.ibiblio.org/maven/batik/jars/
>
> I need to use this version of batik because of a later implementation of
> this svg file into a pdf report using fop and xslt.
>
>
> Do you have any idea where these varieties are coming from and how I can
> eliminate them?
>
> Best regards
> Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]