@Override public SVGGElement initGui(SVGOMDocument svgDocument, IBoundsCalculator boundsCalculator) { this.calculator = boundsCalculator; this.outerGroupElement = (SVGGElement) svgDocument.createElementNS( SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_G_TAG); SVGGElement buttonGroup = button.initGui(svgDocument); outerGroupElement.appendChild(buttonGroup); this.displayElement = display.initGui(svgDocument, calculator); setAttribute( displayElement, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, "translate(0," + SVGIntValueDisplay.getDiameter(nodeWidth) * 1.15 + SVGButton.SHADOW_OFFSET + ")"); //$NON-NLS-1$ //$NON-NLS-2$ outerGroupElement.appendChild(displayElement); this.rootElement = svgDocument.getRootElement(); EventListener removeListener = createRemoveListener(buttonGroup); buttonGroup.addEventListener( SVGConstants.SVG_MOUSEUP_EVENT_TYPE, createDisplayListener(), false); buttonGroup.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, removeListener, false); displayElement.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, removeListener, false); setDisplayVisible(false); return outerGroupElement; }
/** * Creates a <code>GraphicsNode</code> according to the specified parameters. This is called * before children have been added to the returned GraphicsNode (obviously since you construct and * return it). * * @param ctx the bridge context to use * @param doc the document node that describes the graphics node to build * @return a graphics node that represents the specified document node */ public RootGraphicsNode createGraphicsNode(BridgeContext ctx, Document doc) { RootGraphicsNode gn = new RootGraphicsNode(); this.document = doc; this.node = gn; this.ctx = ctx; ((SVGOMDocument) doc).setSVGContext(this); return gn; }
/** Disposes this BridgeUpdateHandler and releases all resources. */ public void dispose() { ((SVGOMDocument) document).setSVGContext(null); ctx.unbind(document); }