/** * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform) */ public void process(Loader loader, Element element, Diagram diagram, Transform transform) throws ParsingException { String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href"); String href = Util.getAsReference(ref); Figure referenced = diagram.getFigureByID(href); if (referenced == null) { throw new ParsingException(element, "Unable to locate referenced element: "+href); } Transform local = Util.getTransform(element); Transform trans = local.concatenate(referenced.getTransform()); NonGeometricData data = Util.getNonGeometricData(element); Shape shape = referenced.getShape().transform(trans); data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL)); data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE)); data.addAttribute(NonGeometricData.OPACITY, referenced.getData().getAttribute(NonGeometricData.OPACITY)); data.addAttribute(NonGeometricData.STROKE_WIDTH, referenced.getData().getAttribute(NonGeometricData.STROKE_WIDTH)); Figure figure = new Figure(referenced.getType(), shape, data, trans); diagram.addFigure(figure); }
/** * Get the non-geometric data information from an XML element * * @param element The element to be processed * @return The non-geometric data (i.e. stroke, fill, etc) */ static NonGeometricData getNonGeometricData(Element element) { String meta = getMetaData(element); NonGeometricData data = new InkscapeNonGeometricData(meta, element); data.addAttribute(NonGeometricData.ID, element.getAttribute("id")); data.addAttribute(NonGeometricData.FILL, getStyle(element, NonGeometricData.FILL)); data.addAttribute(NonGeometricData.STROKE, getStyle(element, NonGeometricData.STROKE)); data.addAttribute(NonGeometricData.OPACITY, getStyle(element, NonGeometricData.OPACITY)); data.addAttribute(NonGeometricData.STROKE_DASHARRAY, getStyle(element, NonGeometricData.STROKE_DASHARRAY)); data.addAttribute(NonGeometricData.STROKE_DASHOFFSET, getStyle(element, NonGeometricData.STROKE_DASHOFFSET)); data.addAttribute(NonGeometricData.STROKE_MITERLIMIT, getStyle(element, NonGeometricData.STROKE_MITERLIMIT)); data.addAttribute(NonGeometricData.STROKE_OPACITY, getStyle(element, NonGeometricData.STROKE_OPACITY)); data.addAttribute(NonGeometricData.STROKE_WIDTH, getStyle(element, NonGeometricData.STROKE_WIDTH)); return data; }