Examples of TextSpanLayout


Examples of org.apache.batik.gvt.text.TextSpanLayout

        // for each text run, get its outline and append it to the overall
        // outline

        for (int i = 0; i < textRuns.size(); ++i) {
            TextRun textRun = (TextRun)textRuns.get(i);
            TextSpanLayout textRunLayout = textRun.getLayout();
            GeneralPath textRunOutline =
    new GeneralPath(textRunLayout.getOutline());

            if (outline == null) {
               outline = textRunOutline;
            } else {
                outline.setWindingRule(GeneralPath.WIND_NON_ZERO);
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

            TextRun textRun = (TextRun)textRuns.get(i);
            AttributedCharacterIterator textRunACI = textRun.getACI();
            textRunACI.first();

            TextSpanLayout textRunLayout = textRun.getLayout();

            if (bounds == null)
                bounds = textRunLayout.getBounds2D();
            else
                bounds = bounds.createUnion(textRunLayout.getBounds2D());
        }

        // append any stroked decoration outlines
        Shape underline = getDecorationStrokeOutline
            (textRuns, TextSpanLayout.DECORATION_UNDERLINE);
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

        List textRuns = getTextRuns(node, aci);

        // for each text run, see if its been hit
        for (int i = 0; i < textRuns.size(); ++i) {
            TextRun textRun = (TextRun)textRuns.get(i);
            TextSpanLayout layout = textRun.getLayout();
            TextHit textHit = layout.hitTestChar((float) x, (float) y);
            if (textHit != null && layout.getBounds2D().contains(x,y)) {
                return new BasicTextPainter.BasicMark(node, textHit);
            }
        }

        return null;
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

        // get the list of text runs
        List textRuns = getTextRuns(textNode, aci);
        Iterator trI = textRuns.iterator();
        int startGlyphIndex = -1;
        int endGlyphIndex = -1;
        TextSpanLayout startLayout=null, endLayout=null;
        while (trI.hasNext()) {
            TextRun tr = (TextRun)trI.next();
            TextSpanLayout tsl = tr.getLayout();
            if (startGlyphIndex == -1) {
                startGlyphIndex  = tsl.getGlyphIndex(result[0]);
                if (startGlyphIndex != -1)
                    startLayout = tsl;
            }
               
            if (endGlyphIndex == -1) {
                endGlyphIndex = tsl.getGlyphIndex(result[1]);
                if (endGlyphIndex != -1)
                    endLayout = tsl;
            }
            if ((startGlyphIndex != -1) && (endGlyphIndex != -1))
                break;
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

        // for each text run, append any highlight it may contain for
        // the current selection
        for (int i = 0; i < textRuns.size(); ++i) {
            TextRun textRun = (TextRun)textRuns.get(i);
            TextSpanLayout layout = textRun.getLayout();

            Shape layoutHighlightedShape = layout.getHighlightShape
                (beginIndex, endIndex);

            // append the highlighted shape of this layout to the
            // overall hightlighted shape
            if (( layoutHighlightedShape != null) &&
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

            for( int l = 0 ; l < list.size() ; l++ ){
                StrokingTextPainter.TextRun run =
                    (StrokingTextPainter.TextRun)list.get(l);

                TextSpanLayout layout =  run.getLayout();

                if ( layout.hasCharacterIndex(k) ){
                    if ( layout.isOnATextPath() ){
                       
                        GVTGlyphVector vector = layout.getGlyphVector();

                        //alt glyph ?
                        if ( layout.isAltGlyph() ){
                                //get the number of glyph visible here
                            int glyphs = vector.getNumGlyphs();
                            int visibleGlyphs = 0;
                            for( int h=0 ; h < glyphs ; h++ ){
                                if ( vector.isGlyphVisible(h)){
                                    visibleGlyphs++;
                                }
                            }
                                //get the number of character associated
                                //to this run
                            int charactersInRun = 1;
                            while ( layout.hasCharacterIndex( k+1 )){
                                charactersInRun++;
                                k++;
                            }
                            visible += (int)(charactersInRun*visibleGlyphs/glyphs);
                        }
                        else{
                            int lastGlyphIndexFound = -1;
                            do{
                                int glyphIndex = layout.getGlyphIndex(k);
                                ifglyphIndex == -1 ){
                                    //probable missing glyph
                                    if ( layout.isLeftToRight() ){
                                        glyphIndex = 1 + lastGlyphIndexFound;
                                    }
                                    else{
                                        glyphIndex = ( lastGlyphIndexFound == -1)
                                            ? vector.getNumGlyphs()-1
                                            : lastGlyphIndexFound -1;
                                    }
                                }
                                lastGlyphIndexFound = glyphIndex;
                                if ( vector.isGlyphVisible( glyphIndex ) ){
                                    visible++;
                                }
                           
                                k++;
                            }while (k <= lastChar && layout.hasCharacterIndex(k) );
                            //got one too far;
                            k--;
                        }
                            
                    }
                    else{
                        visible++;
                        while ( k < lastChar && layout.hasCharacterIndex(k+1) ){
                            k++;
                            visible++;
                        }
                    }
                }
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

        for( k = startIndex ; (visible < (charnum+1)) ; k++ ){

            for( int l = 0 ; l < list.size() && (visible < (charnum+1)) ; l++ ){
                run = (StrokingTextPainter.TextRun)list.get(l);

                TextSpanLayout layout = run.getLayout();

                if ( layout.hasCharacterIndex(k) ){
                    if ( layout.isOnATextPath() ){
                       
                        GVTGlyphVector vector = layout.getGlyphVector();

                        //alt glyph ?
                        if ( layout.isAltGlyph() ){
                                //get the number of glyph visible here
                            int glyphs = vector.getNumGlyphs();
                            int visibleGlyphs = 0;
                            for( int h=0 ; h < glyphs ; h++ ){
                                if ( vector.isGlyphVisible(h)){
                                    visibleGlyphs++;
                                }
                            }
                                //get the number of character associated
                                //to this run
                            int charactersInRun = 1;
                            while ( layout.hasCharacterIndex( k+1 )){
                                charactersInRun++;
                                k++;
                            }
                            visible += (int)(charactersInRun*visibleGlyphs/glyphs);
                           
                            if ( visible > charnum +1 ){
                                visible = charnum +1;
                            }

                        }
                        else{
                            int lastGlyphIndexFound = -1;
                            do{
                                int glyphIndex = layout.getGlyphIndex(k);
                                ifglyphIndex == -1 ){
                                    //probable missing glyph
                                    if ( layout.isLeftToRight() ){
                                        glyphIndex = 1 + lastGlyphIndexFound;
                                    }
                                    else{
                                        glyphIndex = ( lastGlyphIndexFound == -1)
                                            ? vector.getNumGlyphs()-1
                                            : lastGlyphIndexFound -1;
                                    }
                                }
                                lastGlyphIndexFound = glyphIndex;
                                if ( vector.isGlyphVisible( glyphIndex ) ){
                                    visible++;
                                }
                                k++;
                            }while ((visible < (charnum+1)) && layout.hasCharacterIndex(k) );
                            //got one too far
                            k--;
                        }
                    }
                    else{
                        visible++;
                        while ( (visible < (charnum+1)) && layout.hasCharacterIndex(k+1) ){
                            k++;
                            visible++;
                        }
                    }
                }
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

        // place coords in text node coordinate system
        for (int i = 0 ; i < list.size(); i++) {
            StrokingTextPainter.TextRun run =
                (StrokingTextPainter.TextRun)list.get(i);
            AttributedCharacterIterator aci = run.getACI();
            TextSpanLayout layout = run.getLayout();
            float x = (float)p.getX();
            float y = (float)p.getY();
            TextHit textHit = layout.hitTestChar(x, y);
            if (textHit != null && contains(p, layout.getBounds2D())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

                if (list != null){
                    for (int i = 0 ; i < list.size(); i++) {
                        StrokingTextPainter.TextRun run =
                            (StrokingTextPainter.TextRun)list.get(i);
                        AttributedCharacterIterator aci = run.getACI();
                        TextSpanLayout layout = run.getLayout();
                        float x = (float)coords.getX();
                        float y = (float)coords.getY();
                        TextHit textHit = layout.hitTestChar(x, y);
                        if (textHit != null && layout.getBounds2D().contains(x, y)) {
                            Object delimiter = aci.getAttribute
                                (GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER);
                            if (delimiter instanceof Element) {
                                return (Element)delimiter;
                            }
View Full Code Here

Examples of org.apache.batik.gvt.text.TextSpanLayout

                   
            int [] subCharMap = new int[end-start];
            for (int i=0; i<subCharMap.length; i++) {
                subCharMap[i] = charMap[i+start-begin];
            }
            TextSpanLayout layout = getTextLayoutFactory().
                createTextLayout(runaci, subCharMap,
                                 offset, fontRenderContext);
            TextRun run = new TextRun(layout, runaci, isChunkStart);
            textRuns.add(run);
            Point2D layoutAdvance = layout.getAdvance2D();
            if (isChunkStart)
                location = layout.getOffset();

            // System.out.println("layoutAdv: " + layoutAdvance);

            advance = new Point2D.Float
                ((float) (advance.getX()+layoutAdvance.getX()),
                 (float) (advance.getY()+layoutAdvance.getY()));
            ++endChunk;
            prevTextPath = textPath;
            prevTextPathAdvance = layout.getTextPathAdvance();
            if (aci.setIndex(end) == CharacterIterator.DONE) break;
            isChunkStart = false;
        } while (true);
        // System.out.println("Adv: " + advance);
        return new TextChunk(beginChunk, endChunk, location, advance);
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.