Package org.apache.batik.gvt

Examples of org.apache.batik.gvt.TextNode$Anchor


        ctx.getUserAgent().setTextSelection(firstMark,lastMark);
    }

    protected int getCharNumAtPosition(Element e, float x, float y){
       
        TextNode textNode = (TextNode)node;

        //check if there is an hit
        List list = getTextRuns(textNode);

        //going backward in the list to catch the last character
View Full Code Here


    }


    public Set getTextIntersectionSet(AffineTransform at,
                                       Rectangle2D rect) {
        TextNode tn  = (TextNode)node;
        List list = tn.getTextRuns();
        Set elems = new HashSet();
        for (int i = 0 ; i < list.size(); i++) {
            StrokingTextPainter.TextRun run;
            run = (StrokingTextPainter.TextRun)list.get(i);
            TextSpanLayout layout = run.getLayout();
View Full Code Here

        return elems;
    }

    public Set getTextEnclosureSet(AffineTransform at,
                                    Rectangle2D rect) {
        TextNode tn = (TextNode)node;

        Set elems = new HashSet();
        Set reject = new HashSet();
        List list = tn.getTextRuns();
        for (int i = 0 ; i < list.size(); i++) {
            StrokingTextPainter.TextRun run;
            run = (StrokingTextPainter.TextRun)list.get(i);
            TextSpanLayout layout = run.getLayout();
            AttributedCharacterIterator aci = run.getACI();
View Full Code Here

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

        TextNode tn      = (TextNode)txtBridge.node;
        Element  txtElem = txtBridge.e;

        AffineTransform at = tn.getGlobalTransform();
        at.preConcatenate(ati);

        Rectangle2D tnRect;
        tnRect = tn.getBounds();
        tnRect = at.createTransformedShape(tnRect).getBounds2D();
        if (!rect.intersects(tnRect)) return false;

        List list = tn.getTextRuns();
        for (int i = 0 ; i < list.size(); i++) {
            StrokingTextPainter.TextRun run;
            run = (StrokingTextPainter.TextRun)list.get(i);
            TextSpanLayout layout = run.getLayout();
            AttributedCharacterIterator aci = run.getACI();
View Full Code Here

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

        TextNode tn      = (TextNode)txtBridge.node;
        Element  txtElem = txtBridge.e;

        Rectangle2D ret = null;
        List list = tn.getTextRuns();
        if (list == null) return null;
        for (int i = 0 ; i < list.size(); i++) {
            StrokingTextPainter.TextRun run;
            run = (StrokingTextPainter.TextRun)list.get(i);
            TextSpanLayout layout = run.getLayout();
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

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

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

        int beginIndex = begin.getHit().getCharIndex();
        int endIndex   = end.getHit().getCharIndex();
        if (beginIndex > endIndex) {
            // Swap them...
            BasicTextPainter.BasicMark tmpMark = begin;
            begin = end; end = tmpMark;

            int tmpIndex = beginIndex;
            beginIndex = endIndex; endIndex = tmpIndex;
        }

        // get the list of text runs
        List textRuns = getTextRuns
            (textNode, textNode.getAttributedCharacterIterator());

        GeneralPath highlightedShape = new GeneralPath();

        // for each text run, append any highlight it may contain for
        // the current selection
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;
        Object selection = getSelection();
        Shape  shape     = node.getHighlightShape();
        dispatchSelectionEvent(new SelectionEvent
            (selection, SelectionEvent.SELECTION_DONE, shape));
    }
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

    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

TOP

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

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.