Package org.apache.batik.gvt

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


     */
    protected void computeLayoutedText() {
        AttributedString as = buildAttributedString(ctx, e);
        addGlyphPositionAttributes(as, e, ctx);
        layoutedText = new AttributedString(as.getIterator());
        TextNode tn = (TextNode)node;
        tn.setAttributedCharacterIterator(as.getIterator());
        TextDecoration textDecoration =
            getTextDecoration(e, tn, new TextDecoration(), ctx);
        addPaintAttributes(as, e, tn, textDecoration, ctx);
        tn.setAttributedCharacterIterator(as.getIterator());
    }
View Full Code Here


                if (!hasNewACI) {
                    hasNewACI = true;
                    AttributedString as = buildAttributedString(ctx, e);
                    addGlyphPositionAttributes(as, e, ctx);
                    layoutedText = new AttributedString(as.getIterator());
                    TextNode tn = (TextNode)node;
                    tn.setAttributedCharacterIterator(as.getIterator());
                    TextDecoration textDecoration =
                        getTextDecoration(e, tn, new TextDecoration(), ctx);
                    addPaintAttributes(as, e, tn, textDecoration, ctx);
                    tn.setAttributedCharacterIterator(as.getIterator());
                }
                break;
            }
            }
        }
View Full Code Here

        case SVGCSSEngine.STROKE_DASHARRAY_INDEX:
        case SVGCSSEngine.STROKE_DASHOFFSET_INDEX:
        case SVGCSSEngine.TEXT_DECORATION_INDEX: {
            if (!hasNewACI) {
                hasNewACI = true;
                TextNode tn = (TextNode)node;
                AttributedString as;

                TextDecoration parentDecoration;

                if ( cssProceedElement == e ){
                    parentDecoration = new TextDecoration();
                    as = new AttributedString(layoutedText.getIterator());
                }
                else{
                    //if a child CSS property has changed, then
                    //retrieve the parent text decoration
                    //and only update the section of the AtrtibutedString of
                    //the child
                    parentDecoration = getParentTextDecoration
                        (tn.getAttributedCharacterIterator(),
                         cssProceedElement);
                    as = new AttributedString
                        (tn.getAttributedCharacterIterator());
                }
                tn.setAttributedCharacterIterator(as.getIterator());
                TextDecoration textDecoration = getTextDecoration
                    (cssProceedElement, tn, parentDecoration, ctx);
                addPaintAttributes
                    (as, cssProceedElement, tn, textDecoration, ctx);
                tn.setAttributedCharacterIterator(as.getIterator());
            }
            break;
        }
        case SVGCSSEngine.TEXT_RENDERING_INDEX: {
            RenderingHints hints = node.getRenderingHints();
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

     * @param ctx the bridge context to use
     * @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 = (TextNode)super.createGraphicsNode(ctx, e);
        if (node == null)
            return null;

        // specify the text painter to use
        if (ctx.getTextPainter() != null)
            node.setTextPainter(ctx.getTextPainter());

        // 'text-rendering' and 'color-rendering'
        RenderingHints hints = null;
        hints = CSSUtilities.convertColorRendering(e, hints);
        hints = CSSUtilities.convertTextRendering (e, hints);
        if (hints != null)
            node.setRenderingHints(hints);

        node.setLocation(getLocation(ctx, e));

        return node;
    }
View Full Code Here

    /**
     * Creates the GraphicsNode depending on the GraphicsNodeBridge
     * implementation.
     */
    protected GraphicsNode instantiateGraphicsNode() {
        return new TextNode();
    }
View Full Code Here

        AttributedString as = buildAttributedString(ctx, e);
        addGlyphPositionAttributes(as, e, ctx);
        if (ctx.isDynamic()) {
            laidoutText = new AttributedString(as.getIterator());
        }
        TextNode tn = (TextNode)node;
        elemTPI.clear();
        // Add null TPI objects to the text (after we set it on the
        // Text we will swap in the correct values.
        addNullPaintAttributes(as, e, ctx);

        // Install the ACI in the text node.
        tn.setAttributedCharacterIterator(as.getIterator());

        // Now get the real paint into - this needs to
        // wait until the text node is laidout so we can get
        // objectBoundingBox info.
        TextPaintInfo pi = new TextPaintInfo();
        setBaseTextPaintInfo(pi, e, node, ctx);
        // This get's Overline/underline info.
        setDecorationTextPaintInfo(pi, e);
        // Install the attributes.
        addPaintAttributes(as, e, tn, pi, ctx);

        if (usingComplexSVGFont) {
            // Force Complex SVG fonts to be recreated, if we have them.
            tn.setAttributedCharacterIterator(as.getIterator());
        }
    }
View Full Code Here

    protected void rebuildACI() {
        if (hasNewACI)
            return;

        TextNode tn = (TextNode)node;

        TextPaintInfo pi, oldPI;
        if ( cssProceedElement == e ){
            pi = new TextPaintInfo();
            setBaseTextPaintInfo(pi, e, node, ctx);
            setDecorationTextPaintInfo(pi, e);
            oldPI = (TextPaintInfo)elemTPI.get(e);
        } else {
            //if a child CSS property has changed, then
            //retrieve the parent text decoration
            //and only update the section of the AtrtibutedString of
            //the child
            TextPaintInfo parentPI;
            parentPI = getParentTextPaintInfo
                (tn.getAttributedCharacterIterator(), cssProceedElement);
            pi = getTextPaintInfo(cssProceedElement, tn, parentPI, ctx);
            oldPI = (TextPaintInfo)elemTPI.get(cssProceedElement);
        }
        if (oldPI == null) return;

        tn.swapTextPaintInfo(pi, oldPI);
        if (usingComplexSVGFont)
            // Force Complex SVG fonts to be recreated
            tn.setAttributedCharacterIterator
                (tn.getAttributedCharacterIterator());
    }
View Full Code Here

        float length = 0;

        AttributedCharacterIterator aci;
        aci = ((TextNode)node).getAttributedCharacterIterator();
        TextNode textNode = (TextNode)node;

        int firstChar = getElementStartIndex(aci,element);

        if ( firstChar == -1 )
            return -1;
View Full Code Here

     *  manager in JSVGComponent.
     */
    protected void selectSubString(Element element, int charnum, int nchars) {
        AttributedCharacterIterator aci;
        aci = ((TextNode)node).getAttributedCharacterIterator();
        TextNode textNode = (TextNode)node;

        int firstChar = getElementStartIndex(aci,element);

        if ( firstChar == -1 )
            return;

        List list = getTextRuns(textNode);

        int lastChar = getElementEndIndex(aci,element);

        CharacterInformation firstInfo, lastInfo;
        firstInfo = getCharacterInformation(list, firstChar,charnum,aci);
        lastInfo  = getCharacterInformation(list, firstChar,charnum+nchars-1,aci);
       
        Mark firstMark, lastMark;
        firstMark = textNode.getMarkerForChar(firstInfo.characterIndex,true);

        if ( lastInfo != null && lastInfo.characterIndex <= lastChar ){
            lastMark = textNode.getMarkerForChar(lastInfo.characterIndex,false);
        }
        else{
            lastMark = textNode.getMarkerForChar(lastChar,false);
        }

        ctx.getUserAgent().setTextSelection(firstMark,lastMark);
    }
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.