Examples of CanvasGraphicsNode


Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

                        (s, SVG_Y_ATTRIBUTE, uctx);
                }

                AffineTransform positionTransform =
                    AffineTransform.getTranslateInstance(x, y);
                CanvasGraphicsNode cgn;
                cgn = (CanvasGraphicsNode)node;

                cgn.setPositionTransform(positionTransform);
            }
        } else if (attrName.equals(SVG_VIEW_BOX_ATTRIBUTE) ||
                   attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
            boolean isOutermost = (doc.getRootElement() == e);

            String s;
            UnitProcessor.Context uctx;
            uctx = UnitProcessor.createContext(ctx, e);
            // X & Y are ignored on outermost SVG.
            float x = 0;
            float y = 0;
            if (!isOutermost) {
                // 'x' attribute - default is 0
                s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
                if (s.length() != 0) {
                    x = UnitProcessor.svgHorizontalCoordinateToUserSpace
                        (s, SVG_X_ATTRIBUTE, uctx);
                }
                // 'y' attribute - default is 0
                s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
                if (s.length() != 0) {
                    y = UnitProcessor.svgVerticalCoordinateToUserSpace
                        (s, SVG_Y_ATTRIBUTE, uctx);
                }
            }
           
            // 'width' attribute - default is 100%
            s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
            if (s.length() == 0) {
                s = SVG_SVG_WIDTH_DEFAULT_VALUE;
            }
            float w = UnitProcessor.svgHorizontalLengthToUserSpace
                (s, SVG_WIDTH_ATTRIBUTE, uctx);
           
            // 'height' attribute - default is 100%
            s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
            if (s.length() == 0) {
                s = SVG_SVG_HEIGHT_DEFAULT_VALUE;
            }
            float h = UnitProcessor.svgVerticalLengthToUserSpace
                (s, SVG_HEIGHT_ATTRIBUTE, uctx);
           
            CanvasGraphicsNode cgn;
            cgn = (CanvasGraphicsNode)node;
           
            // 'viewBox' and "preserveAspectRatio' attributes
            AffineTransform newVT =
                ViewBox.getPreserveAspectRatioTransform(e, w, h);
            AffineTransform oldVT = cgn.getViewingTransform();
            if ((newVT.getScaleX() != oldVT.getScaleX()) ||
                (newVT.getScaleY() != oldVT.getScaleY()) ||
                (newVT.getShearX() != oldVT.getShearX()) ||
                (newVT.getShearY() != oldVT.getShearY()))
                rebuild = true;
            else {
                // Only differs in translate.
                cgn.setViewingTransform(newVT);
               
                // 'overflow' and 'clip'
                Shape clip = null;
                if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
                    float [] offsets = CSSUtilities.convertClip(e);
                    if (offsets == null) { // clip:auto
                        clip = new Rectangle2D.Float(x, y, w, h);
                    } else { // clip:rect(<x> <y> <w> <h>)
                        // offsets[0] = top
                        // offsets[1] = right
                        // offsets[2] = bottom
                        // offsets[3] = left
                        clip = new Rectangle2D.Float(x+offsets[3],
                                                     y+offsets[0],
                                                     w-offsets[1]-offsets[3],
                                                     h-offsets[2]-offsets[0]);
                    }
                }
               
                if (clip != null) {
                    try {
                        AffineTransform at;
                        at = cgn.getPositionTransform();
                        at = new AffineTransform(at);
                        at.concatenate(newVT);
                        at = at.createInverse(); // clip in user space
                        clip = at.createTransformedShape(clip);
                        Filter filter = cgn.getGraphicsNodeRable(true);
                        cgn.setClip(new ClipRable8Bit(filter, clip));
                    } catch (NoninvertibleTransformException ex) {}
                }
            }
        }
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

                double s = Math.min(sx, sy);
                Tx = AffineTransform.getScaleInstance(s, s);
            }

            GraphicsNode gn = svgCanvas.getGraphicsNode();
            CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
            if (cgn != null) {
                AffineTransform vTx = cgn.getViewingTransform();
                if ((vTx != null) && !vTx.isIdentity()) {
                    try {
                        AffineTransform invVTx = vTx.createInverse();
                        Tx.concatenate(invVTx);
                    } catch (NoninvertibleTransformException nite) {
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

            }

            curAOI = new Rectangle2D.Float(0, 0, width, height);
        }

        CanvasGraphicsNode cgn = getCanvasGraphicsNode(gvtRoot);
        if (cgn != null) {
            cgn.setViewingTransform(Px);
            curTxf = new AffineTransform();
        } else {
            curTxf = Px;
        }
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

        if (r != null) {
            result.setBackgroundEnable(r);
        }

        SVGSVGElement svgElement = imgDocument.getRootElement();
        CanvasGraphicsNode node;
        node = (CanvasGraphicsNode)subCtx.getGVTBuilder().build
            (subCtx, svgElement);

        if (eng == null) // If we "created" this document then add listerns.
            subCtx.addUIEventListeners(imgDocument);

        // HACK: remove the clip set by the SVGSVGElement as the overflow
        // and clip properties must be ignored. The clip will be set later
        // using the overflow and clip of the <image> element.
        node.setClip(null);
        // HACK: remove the viewingTransform set by the SVGSVGElement
        // as the viewBox must be ignored. The viewingTransform will
        // be set later using the width/height of the image element.
        node.setViewingTransform(new AffineTransform());
        result.getChildren().add(node);

        // create the implicit viewBox for the SVG image. The viewBox for a
        // SVG image is the viewBox of the outermost SVG element of the SVG file
        String viewBox =
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

        JSVGComponent.this.setMySize(mySz);
        SVGSVGElement elt = svgDocument.getRootElement();
        prevComponentSize = getSize();
        AffineTransform at = calculateViewingTransform
            (fragmentIdentifier, elt);
        CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
        cgn.setViewingTransform(at);
        viewingTransform = null;
        initialTransform = new AffineTransform();
        setRenderingTransform(initialTransform, false);
        jsvgComponentListener.updateMatrix(initialTransform);
        addJGVTComponentListener(jsvgComponentListener);
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

    public AffineTransform getViewingTransform() {
        AffineTransform vt;
        synchronized (this) {
            vt = viewingTransform;
            if (vt == null) {
                CanvasGraphicsNode cgn = getCanvasGraphicsNode();
                if (cgn != null)
                    vt = cgn.getViewingTransform();
            }
        }
        return vt;
    }
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

            }

            curAOI = new Rectangle2D.Float(0, 0, width, height);
        }

        CanvasGraphicsNode cgn = getCanvasGraphicsNode(gvtRoot);
        if (cgn != null) {
            cgn.setViewingTransform(Px);
            curTxf = new AffineTransform();
        } else {
            curTxf = Px;
        }
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

        if (r != null) {
            result.setBackgroundEnable(r);
        }

        SVGSVGElement svgElement = imgDocument.getRootElement();
        CanvasGraphicsNode node;
        node = (CanvasGraphicsNode)subCtx.getGVTBuilder().build
            (subCtx, svgElement);

        if ((eng == null) && ctx.isInteractive()) {
            // If we "created" this document then add listerns.
            subCtx.addUIEventListeners(imgDocument);
        }

        // HACK: remove the clip set by the SVGSVGElement as the overflow
        // and clip properties must be ignored. The clip will be set later
        // using the overflow and clip of the <image> element.
        node.setClip(null);
        // HACK: remove the viewingTransform set by the SVGSVGElement
        // as the viewBox must be ignored. The viewingTransform will
        // be set later using the width/height of the image element.
        node.setViewingTransform(new AffineTransform());
        result.getChildren().add(node);

        // create the implicit viewBox for the SVG image. The viewBox for a
        // SVG image is the viewBox of the outermost SVG element of the SVG file
        // XXX Use animated value of 'viewBox' here?
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

    /**
     * Creates a <tt>CompositeGraphicsNode</tt>.
     */
    protected GraphicsNode instantiateGraphicsNode() {
        return new CanvasGraphicsNode();
    }
View Full Code Here

Examples of org.apache.flex.forks.batik.gvt.CanvasGraphicsNode

        // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
        if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
            return null;
        }

        CanvasGraphicsNode cgn;
        cgn = (CanvasGraphicsNode)instantiateGraphicsNode();

        associateSVGContext(ctx, e, cgn);

        try {
            // In some cases we converted document fragments which didn't
            // have a parent SVG element, this check makes sure only the
            // real root of the SVG Document tries to do negotiation with
            // the UA.
            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
            SVGOMSVGElement se = (SVGOMSVGElement) e;
            boolean isOutermost = (doc.getRootElement() == e);
            float x = 0;
            float y = 0;
            // x and y have no meaning on the outermost 'svg' element
            if (!isOutermost) {
                // 'x' attribute - default is 0
                AbstractSVGAnimatedLength _x =
                    (AbstractSVGAnimatedLength) se.getX();
                x = _x.getCheckedValue();

                // 'y' attribute - default is 0
                AbstractSVGAnimatedLength _y =
                    (AbstractSVGAnimatedLength) se.getY();
                y = _y.getCheckedValue();
            }

            // 'width' attribute - default is 100%
            AbstractSVGAnimatedLength _width =
                (AbstractSVGAnimatedLength) se.getWidth();
            float w = _width.getCheckedValue();

            // 'height' attribute - default is 100%
            AbstractSVGAnimatedLength _height =
                (AbstractSVGAnimatedLength) se.getHeight();
            float h = _height.getCheckedValue();

            // 'visibility'
            cgn.setVisible(CSSUtilities.convertVisibility(e));

            // 'viewBox' and "preserveAspectRatio' attributes
            SVGOMAnimatedRect vb = (SVGOMAnimatedRect) se.getViewBox();
            SVGAnimatedPreserveAspectRatio par = se.getPreserveAspectRatio();
            AffineTransform viewingTransform =
                ViewBox.getPreserveAspectRatioTransform(e, vb, par, w, h, ctx);

            float actualWidth = w;
            float actualHeight = h;
            try {
                AffineTransform vtInv = viewingTransform.createInverse();
                actualWidth = (float) (w*vtInv.getScaleX());
                actualHeight = (float) (h*vtInv.getScaleY());
            } catch (NoninvertibleTransformException ex) {}

            AffineTransform positionTransform =
                AffineTransform.getTranslateInstance(x, y);
            // The outermost preserveAspectRatio matrix is set by the user
            // agent, so we don't need to set the transform for outermost svg
            if (!isOutermost) {
                // X & Y are ignored on outermost SVG.
                cgn.setPositionTransform(positionTransform);
            } else if (doc == ctx.getDocument()) {
                // <!> FIXME: hack to compute the original document's size
                ctx.setDocumentSize(new Dimension((int) (w + 0.5f),
                                                  (int) (h + 0.5f)));
            }
            // Set the viewing transform, this is often updated when the
            // component prepares for rendering.
            cgn.setViewingTransform(viewingTransform);

            // 'overflow' and 'clip'
            Shape clip = null;
            if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
                float [] offsets = CSSUtilities.convertClip(e);
                if (offsets == null) { // clip:auto
                    clip = new Rectangle2D.Float(x, y, w, h);
                } else { // clip:rect(<x> <y> <w> <h>)
                    // offsets[0] = top
                    // offsets[1] = right
                    // offsets[2] = bottom
                    // offsets[3] = left
                    clip = new Rectangle2D.Float(x+offsets[3],
                                                 y+offsets[0],
                                                 w-offsets[1]-offsets[3],
                                                 h-offsets[2]-offsets[0]);
                }
            }

            if (clip != null) {
                try {
                    AffineTransform at = new AffineTransform(positionTransform);
                    at.concatenate(viewingTransform);
                    at = at.createInverse(); // clip in user space
                    clip = at.createTransformedShape(clip);
                    Filter filter = cgn.getGraphicsNodeRable(true);
                    cgn.setClip(new ClipRable8Bit(filter, clip));
                } catch (NoninvertibleTransformException ex) {}
            }
            RenderingHints hints = null;
            hints = CSSUtilities.convertColorRendering(e, hints);
            if (hints != null)
                cgn.setRenderingHints(hints);

            // 'enable-background'
            Rectangle2D r = CSSUtilities.convertEnableBackground(e);
            if (r != null) {
                cgn.setBackgroundEnable(r);
            }

            if (vb.isSpecified()) {
                SVGRect vbr = vb.getAnimVal();
                actualWidth = vbr.getWidth();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.