When I try to link in an Image, I add the x, y, width, height, and xlink:href attribute.  When I place the Element on the JSVGCanvas, I get an error telling me that xlink:href is required.  I do have it as I can verify by viewing the source of my document:

 

<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="">

           id="59FAB452-F82B-9202-6A5C-226937440F88"

           transform="translate(0, 0) scale(1, 1)" width="130"

           xlink:show="embed" xlink:type="simple"

           preserveAspectRatio="xMidYMid meet" height="100" x="21" y="312"

           xlink:actuate="onLoad"/>

 

The odd thing is, I did NOT add the “xmlns:xlink” attribute, the “xlink:show”, “xlink:type”, or “xlink:actuate” attributes.  The xlink:href is clearly there so maybe I’m doing something wrong.  Here’s the code snippet:

 

element = SVGDocumentManager.createElement(SVGConstants.SVG_IMAGE_TAG);

 

        String xCoordinate = String.valueOf(Status.getXCurrent());

        String yCoordinate = String.valueOf(Status.getYCurrent());

        String width = String.valueOf(ImageStatus.getWidth());

        String height = String.valueOf(ImageStatus.getHeight());

        String imageName = ImageStatus.getImageFile().getName();

        element.setAttribute(SVGConstants.SVG_X_ATTRIBUTE, xCoordinate);

        element.setAttribute(SVGConstants.SVG_Y_ATTRIBUTE, yCoordinate);

        element.setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, width);

        element.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, height);

        element.setAttribute("xlink:href", imageName);

 

Michael Bishop

Reply via email to