/** * Returns the transformation matrix to apply to initialize a viewport or * null if the specified viewBox disables the rendering of the element. * * @param e the element with a viewbox * @param aViewBox the viewBox definition * @param aPAR the preserveAspectRatio definition * @param w the width of the effective viewport * @param h the height of the effective viewport * @param ctx the BridgeContext to use for error information */ public static AffineTransform getPreserveAspectRatioTransform (Element e, SVGAnimatedRect aViewBox, SVGAnimatedPreserveAspectRatio aPAR, float w, float h, BridgeContext ctx) { if (!((SVGOMAnimatedRect) aViewBox).isSpecified()) { // no viewBox specified return new AffineTransform(); } SVGRect viewBox = aViewBox.getAnimVal(); float[] vb = new float[] { viewBox.getX(), viewBox.getY(), viewBox.getWidth(), viewBox.getHeight() }; return getPreserveAspectRatioTransform(e, vb, w, h, aPAR, ctx); }
/** * <b>DOM</b>: Implements {@link * SVGSVGElement#getIntersectionList(SVGRect,SVGElement)}. */ public NodeList getIntersectionList(SVGRect rect, SVGElement referenceElement) { SVGSVGContext ctx = (SVGSVGContext)getSVGContext(); List list = ctx.getIntersectionList(rect, referenceElement); return new ListNodeList(list); }
/** * <b>DOM</b>: Implements {@link * SVGSVGElement#getEnclosureList(SVGRect,SVGElement)}. */ public NodeList getEnclosureList(SVGRect rect, SVGElement referenceElement) { SVGSVGContext ctx = (SVGSVGContext)getSVGContext(); List list = ctx.getEnclosureList(rect, referenceElement); return new ListNodeList(list); }
/** * <b>DOM</b>: Implements {@link SVGAnimatedRect#getBaseVal()}. */ public SVGRect getBaseVal() { if (baseVal == null) { baseVal = new BaseSVGRect(); } return baseVal; }
/** * <b>DOM</b>: Implements {@link SVGAnimatedRect#getAnimVal()}. */ public SVGRect getAnimVal() { if (animVal == null) { animVal = new AnimSVGRect(); } return animVal; }
/** * Draws a line on the annotation grouper. * * @param x * @return */ public String drawAnnoteLine(int x) { if (annotemode == AnnoteMode.LINE) { Element annote_g = doc.getElementById("annote_g"); Element annote_canvas = doc.getElementById("annote_canvas"); Element annote_line = doc.createElementNS(svgNS, "line"); SVGRect annote_canvas_rc = SVGLocatableSupport.getBBox(annote_canvas); String id = "annote_line_" + (lineGensym++); annote_line.setAttributeNS(null, "id", id); annote_line.setAttributeNS(null, "x1", Float.toString(x - chartXOffset)); annote_line.setAttributeNS(null, "y1", "0"); annote_line.setAttributeNS(null, "x2", Float.toString(x - chartXOffset)); annote_line.setAttributeNS(null, "y2", Float.toString(annote_canvas_rc.getHeight())); annote_line.setAttributeNS(null, "stroke", "black"); annote_line.setAttributeNS(null, "stroke-width", "3"); annote_line.setAttributeNS(null, "opacity", "0.5"); annote_line.setAttributeNS(null, "onmousedown", "FireChartSVG.getChart(chart_num).deleteAnnoteLine('" + id + "')"); annote_g.appendChild(annote_line); annotemode = AnnoteMode.NONE; return id; } return "wrong_annotemode"; }
protected float[] calculateDefaultViewbox(String fragIdent, SVGSVGElement svgElt) { float[] vb = new float[4]; SVGRect rc = svgElt.getBBox(); vb[0] = rc.getX(); vb[1] = rc.getY(); vb[2] = rc.getWidth(); vb[3] = rc.getHeight(); return vb; }
protected void addGraphicsDragHandles(Element highlightGroupNode, UniqueIdentifier targetIdentifier, SVGRect bbox, int paddingDistance) { Element symbolNode = graphPanel.doc.createElementNS(graphPanel.svgNameSpace, "circle"); symbolNode.setAttribute("cx", Float.toString(bbox.getX() + bbox.getWidth() + paddingDistance)); symbolNode.setAttribute("cy", Float.toString(bbox.getY() + bbox.getHeight() + paddingDistance)); symbolNode.setAttribute("r", "5"); symbolNode.setAttribute("target", targetIdentifier.getAttributeIdentifier()); symbolNode.setAttribute("fill", "blue"); symbolNode.setAttribute("stroke", "none"); ((EventTarget) symbolNode).addEventListener("mousedown", graphPanel.mouseListenerSvg, false); highlightGroupNode.appendChild(symbolNode); }
/** * <b>DOM</b>: Implements {@link SVGSVGElement#getViewport()}. */ public SVGRect getViewport() { SVGContext ctx = getSVGContext(); return new SVGOMRect(0, 0, ctx.getViewportWidth(), ctx.getViewportHeight()); }
/** * <b>DOM</b>: Implements {@link * SVGSVGElement#checkIntersection(SVGElement,SVGRect)}. */ public boolean checkIntersection(SVGElement element, SVGRect rect) { SVGSVGContext ctx = (SVGSVGContext)getSVGContext(); return ctx.checkIntersection(element, rect); }
/** * <b>DOM</b>: Implements {@link * SVGSVGElement#checkEnclosure(SVGElement,SVGRect)}. */ public boolean checkEnclosure(SVGElement element, SVGRect rect) { SVGSVGContext ctx = (SVGSVGContext)getSVGContext(); return ctx.checkEnclosure(element, rect); }
/** * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGRect()}. */ public SVGRect createSVGRect() { return new SVGOMRect(0, 0, 0, 0); }
/** * To implement {@link * org.w3c.dom.svg.SVGTextContentElement#getExtentOfChar(int charnum)}. */ public static SVGRect getExtentOfChar(Element elt, final int charnum ) { final SVGOMElement svgelt = (SVGOMElement)elt; if ( (charnum < 0) || (charnum >= getNumberOfChars(elt)) ){ throw svgelt.createDOMException (DOMException.INDEX_SIZE_ERR, "",null); } final SVGTextContent context = (SVGTextContent)svgelt.getSVGContext(); return new SVGRect() { public float getX() { return (float)SVGTextContentSupport.getExtent (svgelt, context, charnum).getX(); } public void setX(float x) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getY() { return (float)SVGTextContentSupport.getExtent (svgelt, context, charnum).getY(); } public void setY(float y) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getWidth() { return (float)SVGTextContentSupport.getExtent (svgelt, context, charnum).getWidth(); } public void setWidth(float width) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getHeight() { return (float)SVGTextContentSupport.getExtent (svgelt, context, charnum).getHeight(); } public void setHeight(float height) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } }; }
/** * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGLocatable#getBBox()}. */ public SVGRect getBBox() { return SVGLocatableSupport.getBBox(this); }
/** * Returns the base value of the attribute as an {@link AnimatableValue}. */ public AnimatableValue getUnderlyingValue(AnimationTarget target) { SVGRect r = getBaseVal(); return new AnimatableRectValue (target, r.getX(), r.getY(), r.getWidth(), r.getHeight()); }
/** * To implement {@link org.w3c.dom.svg.SVGLocatable#getBBox()}. */ public static SVGRect getBBox(Element elt) { final SVGOMElement svgelt = (SVGOMElement)elt; SVGContext svgctx = svgelt.getSVGContext(); if (svgctx == null) return null; if (svgctx.getBBox() == null) return null; return new SVGRect() { public float getX() { return (float)svgelt.getSVGContext().getBBox().getX(); } public void setX(float x) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getY() { return (float)svgelt.getSVGContext().getBBox().getY(); } public void setY(float y) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getWidth() { return (float)svgelt.getSVGContext().getBBox().getWidth(); } public void setWidth(float width) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } public float getHeight() { return (float)svgelt.getSVGContext().getBBox().getHeight(); } public void setHeight(float height) throws DOMException { throw svgelt.createDOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.rect", null); } }; }