在未触发的JavaFX WebView onclick事件上呈现SVG PATH元素

时间:2016-06-13 10:06:11

标签: svg javafx inkscape javafx-webengine

我有一个带有嵌入式webView组件的javafx应用程序(jdk1.8.0_72)。

我有这个由inkscape工具创建的svg:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   id="svg2"
   version="1.1"
   inkscape:version="0.91 r13725"
   width="1920"
   height="600"
   viewBox="0 0 1920 600"
   sodipodi:docname="prova_link.svg">
  <metadata
     id="metadata8">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <defs
     id="defs6">
    <linearGradient
       id="linearGradient4288"
       osb:paint="solid">
      <stop
         style="stop-color:#ff0000;stop-opacity:1;"
         offset="0"
         id="stop4290" />
    </linearGradient>
    <linearGradient
       inkscape:collect="always"
       id="linearGradient4210">
      <stop
         style="stop-color:#00ff00;stop-opacity:1;"
         offset="0"
         id="stop4212" />
      <stop
         style="stop-color:#00ff00;stop-opacity:0;"
         offset="1"
         id="stop4214" />
    </linearGradient>
    <inkscape:perspective
       sodipodi:type="inkscape:persp3d"
       inkscape:vp_x="78.642594 : 273.36913 : 1"
       inkscape:vp_y="0 : 967.24275 : 0"
       inkscape:vp_z="837.94953 : 273.36913 : 1"
       inkscape:persp3d-origin="458.29604 : 176.64486 : 1"
       id="perspective4153" />
    <linearGradient
       inkscape:collect="always"
       xlink:href="#linearGradient4210"
       id="linearGradient4216"
       x1="166.32027"
       y1="80.578522"
       x2="526.18355"
       y2="80.578522"
       gradientUnits="userSpaceOnUse" />
  </defs>
  <sodipodi:namedview
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1"
     objecttolerance="10"
     gridtolerance="10"
     guidetolerance="10"
     inkscape:pageopacity="0"
     inkscape:pageshadow="2"
     inkscape:window-width="1920"
     inkscape:window-height="1018"
     id="namedview4"
     showgrid="false"
     inkscape:zoom="0.80666667"
     inkscape:cx="67.403168"
     inkscape:cy="460.14918"
     inkscape:window-x="1358"
     inkscape:window-y="-8"
     inkscape:window-maximized="1"
     inkscape:current-layer="svg2" />
  <path
     sodipodi:type="star"
     style="opacity:1;fill:#fa0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:82.125;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
     id="path4143"
     sodipodi:sides="5"
     sodipodi:cx="75.619835"
     sodipodi:cy="203.30579"
     sodipodi:r1="50.034138"
     sodipodi:r2="31.917227"
     sodipodi:arg1="0.7328151"
     sodipodi:arg2="1.3611336"
     inkscape:flatsided="false"
     inkscape:rounded="0"
     inkscape:randomized="0"
     d="M 112.80992,236.77686 82.262768,234.52406 55.27932,249.01879 47.982269,219.27057 25.858623,198.0869 51.895946,181.95429 65.20623,154.36734 l 23.389002,19.77771 30.349848,4.134 -11.58212,28.35591 z"
     inkscape:transform-center-x="3.2179809"
     inkscape:transform-center-y="-1.6127244"
     onclick="javascript:alert(&quot;HELLO&quot;);" />
  <rect
     style="opacity:1;fill:#de8787;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:82.125;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
     id="rect4161"
     width="92.975204"
     height="50.826447"
     x="226.8595"
     y="74.380165" />
  <rect
     style="opacity:1;fill:#de8787;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:82.125;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
     id="rect4163"
     width="140.08264"
     height="90.495865"
     x="388.01654"
     y="259.09091" />
  <path
     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:5px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
     d="M 296.29601,125.20661 417.1976,259.09091"
     id="path4165"
     inkscape:connector-type="polyline"
     inkscape:connector-curvature="100"
     inkscape:connection-start="#rect4161"
     inkscape:connection-end="#rect4163"
     onclick="javascript:alert(&quot;HELLO&quot;);" />
</svg>

id为#34; path4143&#34;代表一个明星&#34 ;;

ID为&#34; path4165&#34;的路径代表一个&#34;链接&#34;通过使用&#34;连接器实用程序&#34;;

创建

在chrome,explorer和firefox上加载此svg,可以在两个svg元素上正确触发onclick事件。

在javafx应用程序的webEngine组件上加载相同的svg,&#34;链接上的onclick事件&#34;没有触发。

这似乎是javafx webEngine上的一个错误。 有人可以帮帮我吗? 感谢

0 个答案:

没有答案