Examples of GraphicsNode


Examples of org.apache.batik.gvt.GraphicsNode

        AffineTransform at = g2d.getTransform();

        double scx = Math.sqrt(at.getShearX()*at.getShearX()+
                               at.getScaleX()*at.getScaleX());

        GraphicsNode gn = null;
        int idx =-1;
        double w = bounds.getWidth()*scx;
        for (int i=1; i<sizes.length; i++) {
            if (w > sizes[i].width) {
                idx = i-1;
                break;
            }
        }
        if (idx == -1)
            idx = srcURLs.length-1;
        gn = getGraphicsNode(idx);

        if (gn == null) return;

        Rectangle2D gnBounds = gn.getBounds();
        double sx = bounds.getWidth()/sizes[idx].getWidth();
        double sy = bounds.getHeight()/sizes[idx].getHeight();
       
        // System.out.println("Scale: [" + sx + ", " + sy + "]");
        // g2d.scale(sx, sy);
        gn.paint(g2d);
    }
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

       
        try {
            SVGDocument svgDoc = (SVGDocument)loader.loadDocument
                (srcURLs[idx].toString());

            GraphicsNode gn;
            gn = createSVGImageNode(ctx, multiImgElem,
                                    bounds, svgDoc);
            srcs[idx] = new SoftReference(gn);
            return gn;
        } catch (Exception ex) { /* ex.printStackTrace(); */ }

        try {
            GraphicsNode gn;
            gn = createRasterImageNode(ctx, multiImgElem,
                                       bounds, srcURLs[idx]);
            srcs[idx] = new SoftReference(gn);
            return gn;
        } catch (Exception ex) { /* ex.printStackTrace(); */ }
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

            result.setBackgroundEnable(r);
        }

        SVGSVGElement svgElement = imgDocument.getRootElement();
        GVTBuilder builder = new GVTBuilder();
        GraphicsNode node = builder.build(ctx, 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);
        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
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

            int numClonedChildren = clonedGlyphChildren.getLength();
            for (int i = 0; i < numClonedChildren; i++) {
                Node childNode = clonedGlyphChildren.item(i);
                if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element childElement = (Element)childNode;
                    GraphicsNode childGraphicsNode =
                         builder.build(ctx, childElement);
                    glyphChildrenNode.add(childGraphicsNode);
                }
            }
            glyphContentNode.add(glyphChildrenNode);
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

            // Only draw directly into sRGB destinations...
            return false;
        }

        // System.out.println("drawImage GNR: " + g2dCS);
        GraphicsNode gn = getGraphicsNode();
        if (getUsePrimitivePaint()){
            gn.primitivePaint(g2d);
        }
        else{
            gn.paint(g2d);
        }

        // Paint did the work...
        return true;
    }
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

        ImageNode imageNode = (ImageNode)super.createGraphicsNode(ctx, e);
        if (imageNode == null) {
            return null;
        }

        GraphicsNode node = buildImageGraphicsNode(ctx,e);

        if (node == null) {
            String uriStr = XLinkSupport.getXLinkHref(e);
            throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
                                      new Object[] {uriStr});
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

        if (uriStr.indexOf('#') != -1) {
            throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {"xlink:href", uriStr});
        }

        GraphicsNode node = null;
        // try to load the image as an svg document
        SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();

        // try to load an SVG document
        DocumentLoader loader = ctx.getDocumentLoader();
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

            attrName.equals(SVG_HEIGHT_ATTRIBUTE) ||
      attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)){

            //retrieve the new bounds of the image tag
      Rectangle2D  bounds = getImageBounds(ctx, e);
      GraphicsNode imageNode = ((ImageNode)node).getImage();
      float [] vb = null;
      if (imageNode instanceof RasterImageNode) {
                //Raster image
    Rectangle2D imgBounds =
                    ((RasterImageNode)imageNode).getImageBounds();
    // create the implicit viewBox for the raster
    // image. The viewBox for a raster image is the size
    // of the image
    vb = new float[4];
    vb[0] = 0; // x
    vb[1] = 0; // y
    vb[2] = (float)imgBounds.getWidth(); // width
    vb[3] = (float)imgBounds.getHeight(); // height
      } else {
    if (imgDocument != null) {
        Element svgElement = imgDocument.getRootElement();
        String viewBox = svgElement.getAttributeNS
                        (null, SVG_VIEW_BOX_ATTRIBUTE);
        vb = ViewBox.parseViewBoxAttribute(e, viewBox);
                }
            }
            if (imageNode != null) {
                // handles the 'preserveAspectRatio', 'overflow' and
                // 'clip' and sets the appropriate AffineTransform to
                // the image node
                initializeViewport(ctx, e, imageNode, vb, bounds);
            }
           
        } else if (( XLinkSupport.XLINK_NAMESPACE_URI.equals
                     (evtNode.getNamespaceURI()) )
                   && SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()) ){
            //reference copy of the imgDocument
            SVGDocument oldSVGDoc = imgDocument;

            //update of the reference of the image.
            GraphicsNode inode = buildImageGraphicsNode(ctx,e);

            if (inode == null) {
                String uriStr = XLinkSupport.getXLinkHref(e);
                throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
                                          new Object[] {uriStr});
View Full Code Here

Examples of org.apache.batik.gvt.GraphicsNode

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

        SVGSVGElement svgElement = imgDocument.getRootElement();
        GraphicsNode node = ctx.getGVTBuilder().build(ctx, svgElement);
        ctx.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);
        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.batik.gvt.GraphicsNode

        GraphicsNodeMouseEvent mevt = null;
        if (evt instanceof GraphicsNodeMouseEvent) {
            mevt = (GraphicsNodeMouseEvent) evt;
        }

        GraphicsNode source = evt.getGraphicsNode();

        if ((source instanceof Selectable) && (mevt != null)) {

            Point2D p = new Point2D.Double(mevt.getX(), mevt.getY());
            AffineTransform t = source.getGlobalTransform();
            if (t == null) {
                t = new AffineTransform();
            }
            else {
                 try {
                     t = (AffineTransform) t.createInverse();
                 } catch (NoninvertibleTransformException ni) {
                 }
            }
            p = t.transform(p, null);

            if (isDeselectGesture(evt)) {
                if (selectionNode != null)
                    selectionNode.getRoot()
                        .removeTreeGraphicsNodeChangeListener(this);

                dispatchSelectionEvent(
                        new SelectionEvent(null,
                                SelectionEvent.SELECTION_CLEARED,
                                null));
                copyToClipboard(null);
                selectionNode = null;
            } else if (isSelectStartGesture(evt)) {
                if (selectionNode != source) {
                    if (selectionNode != null)
                        selectionNode.getRoot()
                            .removeTreeGraphicsNodeChangeListener(this);
                    if (source != null)
                        source.getRoot()
                            .addTreeGraphicsNodeChangeListener(this);
                }

                selectionNode = source;
                ((Selectable) source).selectAt(p.getX(), p.getY());
                dispatchSelectionEvent(
                        new SelectionEvent(null,
                                SelectionEvent.SELECTION_STARTED,
                                null));

            } else if (isSelectEndGesture(evt)) {
                if (selectionNode != source) {
                    if (selectionNode != null)
                        selectionNode.getRoot()
                            .removeTreeGraphicsNodeChangeListener(this);
                    if (source != null)
                        source.getRoot()
                            .addTreeGraphicsNodeChangeListener(this);
                }
                selectionNode = source;

                ((Selectable) source).selectTo(p.getX(), p.getY());

                Object oldSelection = getSelection();
                Shape newShape =
                    ((Selectable) source).getHighlightShape();
                dispatchSelectionEvent(
                        new SelectionEvent(oldSelection,
                                SelectionEvent.SELECTION_DONE,
                                newShape));
                copyToClipboard(oldSelection);
            } else

            if (isSelectContinueGesture(evt)) {

                if (selectionNode == source) {
                    boolean result = ((Selectable) source).selectTo(p.getX(),
                                                                    p.getY());
                    if (result) {
                        Shape newShape =
                        ((Selectable) source).getHighlightShape();

                        dispatchSelectionEvent(
                            new SelectionEvent(null,
                                SelectionEvent.SELECTION_CHANGED,
                                newShape));
                    }
                }
            } else if (isSelectAllGesture(evt)) {
                if (selectionNode != source) {
                    if (selectionNode != null)
                        selectionNode.getRoot()
                            .removeTreeGraphicsNodeChangeListener(this);
                    if (source != null)
                        source.getRoot()
                            .addTreeGraphicsNodeChangeListener(this);
                }
                selectionNode = source;
               
                ((Selectable) source).selectAll(p.getX(), p.getY());
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.