Package org.apache.batik.gvt

Examples of org.apache.batik.gvt.TextNode


            childCtx = (AbstractTextChildSVGContext)svgCtx;
            txtBridge = childCtx.getTextBridge();
        }
        if (txtBridge == null) return null;

        TextNode tn = txtBridge.getTextNode();
        List list = tn.getTextRuns();
        if (list == null)
            return null;

        Element  txtElem = txtBridge.e;
        Rectangle2D ret = null;
View Full Code Here


            Element target = context.getElement(node);
            // Lookup inside the text element children to see if the target
            // is a tspan or textPath

            if (target != null && node instanceof TextNode) {
                TextNode textNode = (TextNode)node;
                List list = textNode.getTextRuns();
                Point2D pt = (Point2D)coords.clone();
                // place coords in text node coordinate system
                try {
                    node.getGlobalTransform().createInverse().transform(pt, pt);
                } catch (NoninvertibleTransformException ex) {
View Full Code Here

                                SelectionEvent.SELECTION_CHANGED,
                                newShape));
    }

    public void setSelection(Mark begin, Mark end) {
        TextNode node = begin.getTextNode();
        if (node != end.getTextNode()) {
            throw new Error("Markers not from same TextNode");
        }
        node.setSelection(begin, end);
        selectionNode = node;
        selectionNodeRoot = node.getRoot();
        Object selection = getSelection();
        Shape  shape     = node.getHighlightShape();
        dispatchSelectionEvent(new SelectionEvent
            (selection, SelectionEvent.SELECTION_DONE, shape));
    }
View Full Code Here

        } catch (ClassCastException cce) {
            throw new Error
                ("This Mark was not instantiated by this TextPainter class!");
        }

        TextNode textNode = start.getTextNode();
        if (textNode == null)
            return null;
        if (textNode != finish.getTextNode())
            throw new Error("Markers are from different TextNodes!");

        AttributedCharacterIterator aci;
        aci = textNode.getAttributedCharacterIterator();
        if (aci == null)
            return null;

        int[] result = new int[2];
        result[0] = start.getHit().getCharIndex();
View Full Code Here

        } catch (ClassCastException cce) {
            throw new Error
                ("This Mark was not instantiated by this TextPainter class!");
        }

        TextNode textNode = begin.getTextNode();
        if (textNode == null)
            return null;
        if (textNode != end.getTextNode())
            throw new Error("Markers are from different TextNodes!");

        AttributedCharacterIterator aci;
        aci = textNode.getAttributedCharacterIterator();
        if (aci == null)
            return null;

        int beginIndex = begin.getHit().getCharIndex();
        int endIndex   = end.getHit().getCharIndex();
View Full Code Here

    protected void showSelectedGraphicsNode() {
        GraphicsNode gn = walker.getCurrentGraphicsNode();
        if (!(gn instanceof TextNode)) {
            return;
        }
        TextNode textNode = (TextNode)gn;
        // mark the selection of the substring found
        String text    = textNode.getText();
        String pattern = search.getText();
        if (!caseSensitive.isSelected()) {
            text    = text.toLowerCase();
            pattern = pattern.toLowerCase();
        }
        int end = text.indexOf(pattern, currentIndex);

        AttributedCharacterIterator aci =
            textNode.getAttributedCharacterIterator();
        aci.first();
        for (int i=0; i < end; ++i) {
            aci.next();
        }
        Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true);

        for (int i = 0; i < pattern.length()-1; ++i) {
            aci.next();
        }
        Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false);
        svgCanvas.select(startMark, endMark);

        // zoom on the TextNode if needed
        if (highlightButton.isSelected()) {
            return;
        }

        // get the highlight shape in GVT root (global) coordinate sytem
        Shape s = textNode.getHighlightShape();
        AffineTransform at;
        if (highlightCenterZoomButton.isSelected()) {
            at = svgCanvas.getInitialTransform();
        } else {
            at = svgCanvas.getRenderingTransform();
View Full Code Here

                                    lasthit);
        } else {
            // selection must span more than one text layout (run)

            // get the list of text runs
            TextNode textNode = begin.getHit().getTextNode();
            FontRenderContext frc = begin.getHit().getFontRenderContext();
            List textRuns = getTextRuns(textNode, textNode.getAttributedCharacterIterator(), frc);



            // find out whether selection is right to left or not, ie. whether
            // beginLayout is before endLayout or not
View Full Code Here

     * @param e the element that describes the graphics node to build
     * @return a graphics node that represents the specified element
     */
    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {

        TextNode node = new TextNode();
        // 'transform'
        String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
        if (s.length() != 0) {
            node.setTransform
                (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s));
        }
        // 'visibility'
        node.setVisible(CSSUtilities.convertVisibility(e));

        // 'text-rendering' and 'color-rendering'
        Map textHints = CSSUtilities.convertTextRendering(e);
        Map colorHints = CSSUtilities.convertColorRendering(e);
        if (textHints != null || colorHints != null) {
            RenderingHints hints;
            if (textHints == null) {
                hints = new RenderingHints(colorHints);
            } else if (colorHints == null) {
                hints = new RenderingHints(textHints);
            } else {
                hints = new RenderingHints(textHints);
                hints.putAll(colorHints);
            }
            node.setRenderingHints(hints);
        }

        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);

        // 'x' attribute - default is 0
        s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
        float x = 0;
        if (s.length() != 0) {
            x = UnitProcessor.svgHorizontalCoordinateToUserSpace
                (s, SVG_X_ATTRIBUTE, uctx);
        }

        // 'y' attribute - default is 0
        s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
        float y = 0;
        if (s.length() != 0) {
            y = UnitProcessor.svgVerticalCoordinateToUserSpace
                (s, SVG_Y_ATTRIBUTE, uctx);
        }

        node.setLocation(new Point2D.Float(x, y));
        return node;
    }
View Full Code Here

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

        } catch (ClassCastException cce) {
            throw new
            Error("This Mark was not instantiated by this TextPainter class!");
        }

        TextNode textNode = start.getTextNode();
        if (textNode != finish.getTextNode())
            throw new Error("Markers are from different TextNodes!");

        AttributedCharacterIterator aci;
        aci = textNode.getAttributedCharacterIterator();
                            
        int[] result = new int[2];
        result[0] = start.getHit().getCharIndex();
        result[1] = finish.getHit().getCharIndex();
View Full Code Here

TOP

Related Classes of org.apache.batik.gvt.TextNode

Copyright © 2018 www.massapicom. 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.