xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Toussaint <and...@onemileup.com>
Subject Duplicate image references in SVG
Date Thu, 02 Oct 2003 13:14:40 GMT
Hi All,

When I add two instances of the same image to my document via the  
<image> , and add a actionListener to the group, only the first  
instance of the <image> reacts to the actionEvents.

How can I have duplicate references to the same image inside my SVG,  
but that behave as individual instances to the EventListener? (I am  
using a JSVGCanvas to represent the document)

For instance, i want tyhis image  
xlink:href="../equipment/aircraftSpruce/M07TACH.svg" uid="OMU_93", and  
the same one, with uid="OMU_93_2" to be placed on different loations on  
the canvas, and to react individually to the MouseEvents. Each is  
placed in its own Element.

I am aware that perhaps this is an SVG related issue, but any head  
start would be truly appreciated,

Andres.

Abstract of the Element constructor:
String svgNS = "http://www.w3.org/2000/svg";
        String xlinkNS = "http://www.w3.org/1999/xlink";
        Element img = document.createElementNS(svgNS, "image");
        img.setAttributeNS(null, "x", x.toString());
        img.setAttributeNS(null, "y", y.toString());
        img.setAttributeNS(null, "width", width.toString());
        img.setAttributeNS(null, "height", hgt.toString());
        img.setAttributeNS(xlinkNS,"xlink:href", image);
        img.setAttribute("uid", uid);
imgGroup.add(img);

Sample of my SVG Document (extracted from the dynamic document via  
DOMUtilities.writeDocument(doc, writer)).

  <g style="none" id="imgGroup">
    <rect x="0.0" y="0.0" width="3314"  
style="fill-rule:nonzero;clip- 
rule:nonzero;fill:none;stroke:none;stroke-width:0;stroke- 
linecap:round;stroke-linejoin:round;stroke-miterlimit:4;" uid="buffer"  
height="1574" pointer-events="fill"/><image x="1576.0" y="694.0"  
width="162.0" xmlns:xlink="http://www.w3.org/1999/xlink"  
xlink:href="../equipment/aircraftSpruce/M04TACH.svg"  
xlink:type="simple" uid="OMU_92" xlink:actuate="onRequest"  
height="162.0" preserveAspectRatio="xMidYMid meet"  
xlink:show="replace"/>

    <image x="1578.0" y="883.0" width="162.0"  
xmlns:xlink="http://www.w3.org/1999/xlink"  
xlink:href="../equipment/aircraftSpruce/M07TACH.svg"  
xlink:type="simple" uid="OMU_93" xlink:actuate="onRequest"  
height="162.0" preserveAspectRatio="xMidYMid meet"  
xlink:show="replace"/>

    <image x="1578.0" y="883.0" width="162.0"  
xmlns:xlink="http://www.w3.org/1999/xlink"  
xlink:href="../equipment/aircraftSpruce/M07TACH.svg"  
xlink:type="simple" uid="OMU_93_2" xlink:actuate="onRequest"  
height="162.0" preserveAspectRatio="xMidYMid meet"  
xlink:show="replace"/>

    <image x="1541.0" y="444.0" width="225.0"  
xmlns:xlink="http://www.w3.org/1999/xlink"  
xlink:href="../equipment/aircraftSpruce/20KSALT.svg"  
xlink:type="simple" uid="OMU_75" xlink:actuate="onRequest"  
height="225.0" preserveAspectRatio="xMidYMid meet"  
xlink:show="replace"/>
    </g>
Mime
View raw message