Package org.apache.batik.gvt.text

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


        int begin = aci.getBeginIndex();
        for (int idx=0; idx<gvs.length; idx++) {
            GVTGlyphVector gv = gvs[idx];
            int end = gv.getCharacterCount(0, gv.getNumGlyphs())+1;
            Rectangle2D b = gvs[idx].getBounds2D
                (new AttributedCharacterSpanIterator(aci, begin, end));
            if (ret == null) ret = b;
            else ret = ret.createUnion(b);
            begin = end;
        }
        return ret;
View Full Code Here


              AttributedCharacterIterator aci) {
        int begin = aci.getBeginIndex();
        for (int idx=0; idx<gvs.length; idx++) {
            GVTGlyphVector gv = gvs[idx];
            int end = gv.getCharacterCount(0, gv.getNumGlyphs())+1;
            gv.draw(g2d, new AttributedCharacterSpanIterator(aci, begin, end));
            begin = end;
        }
    }
View Full Code Here

                    } else {
                        Float runX = (Float) aci.getAttribute(XPOS);
                        if ((runX == null) || runX.isNaN())
                            break;
                    }
                    aciList.add(new AttributedCharacterSpanIterator
                        (aci, i-1, i));
                    chunkStartIndex = i;
                }
            }
           
            // found the end of a text chunck
            int chunkEndIndex = aci.getIndex();
            // System.out.println("Bounds: " + chunkStartIndex +
            //                    "," + chunkEndIndex);
            aciList.add(new AttributedCharacterSpanIterator
                (aci, chunkStartIndex, chunkEndIndex));

            chunkStartIndex = chunkEndIndex;
        }
View Full Code Here

        do {
            int start = aci.getRunStart(extendedAtts);
            int end   = aci.getRunLimit(extendedAtts);

            AttributedCharacterIterator runaci;
            runaci = new AttributedCharacterSpanIterator(aci, start, end);

            int [] subCharMap = new int[end-start];
            for (int i=0; i<subCharMap.length; i++) {
                subCharMap[i] = charMap[i+start-begin];
            }
View Full Code Here

            if (ranges[0] > ranges[1]) {
                int temp = ranges[1];
                ranges[1] = ranges[0];
                ranges[0] = temp;
            }
            o = new AttributedCharacterSpanIterator
                (aci, ranges[0], ranges[1]+1);
        }
        return o;
    }
View Full Code Here

                    } else {
                        Float runX = (Float) aci.getAttribute(XPOS);
                        if ((runX == null) || runX.isNaN())
                            break;
                    }
                    aciList.add(new AttributedCharacterSpanIterator
                        (aci, i-1, i));
                    chunkStartIndex = i;
                }
            }

            // found the end of a text chunck
            int chunkEndIndex = aci.getIndex();
            // System.out.println("Bounds: " + chunkStartIndex +
            //                    "," + chunkEndIndex);
            aciList.add(new AttributedCharacterSpanIterator
                (aci, chunkStartIndex, chunkEndIndex));

            chunkStartIndex = chunkEndIndex;
        }
View Full Code Here

        do {
            int start = aci.getRunStart(extendedAtts);
            int end   = aci.getRunLimit(extendedAtts);

            AttributedCharacterIterator runaci;
            runaci = new AttributedCharacterSpanIterator(aci, start, end);

            int [] subCharMap = new int[end-start];
            System.arraycopy( charMap, start - begin, subCharMap, 0, subCharMap.length );

            FontRenderContext frc = fontRenderContext;
View Full Code Here

            // for now use this as the signal for select all
            o = aci;
        } else {
            if ((ranges != null) && (ranges.length > 1)
                && (ranges[1] > ranges[0])) {
                o = new AttributedCharacterSpanIterator(
                                           aci, ranges[0], ranges[1]);
            }
        }
        // TODO: later we will replace with
        // AttributedCharacterMultiSpanIterator(aci, ranges);
View Full Code Here

             */
            int start = aci.getRunStart(extendedAtts);
            int end = aci.getRunLimit(extendedAtts);

            AttributedCharacterIterator runaci =
                    new AttributedCharacterSpanIterator(aci, start, end);

            TextLayout layout = new TextLayout(runaci, frc);

            if (layout.isVertical()) {
                AttributedString as = new AttributedString(runaci);
                if (runaci.getAttribute(GVTAttributedCharacterIterator.
                                        TextAttribute.UNDERLINE) != null) {
                    as.addAttribute(TextAttribute.UNDERLINE,
                                    TextAttribute.UNDERLINE_ON);
                }
                if (runaci.getAttribute(GVTAttributedCharacterIterator.
                                        TextAttribute.STRIKETHROUGH) != null) {
                    as.addAttribute(TextAttribute.STRIKETHROUGH,
                                    TextAttribute.STRIKETHROUGH_ON);
                }
                runaci = as.getIterator();
            }

            TextRun run = new TextRun(layout, runaci);

            textRuns.add(run);

            advance += (double) layout.getAdvance();

            // FIXME: not BIDI compliant yet!

            aci.setIndex(end);
        }

        double x = 0d;

        switch(anchor.getType()){
        case TextNode.Anchor.ANCHOR_MIDDLE:
            x = -advance/2d;
            break;
        case TextNode.Anchor.ANCHOR_END:
            x = -advance;
        }

        /*
         * Adjust for Anchor (above), then
         * we render each of the TextLayout glyphsets
         * in turn.
         */
        for (int i=0; i<textRuns.size(); ++i) {
            TextRun textRun = (TextRun) textRuns.get(i);
            AttributedCharacterIterator runaci = textRun.getACI();
            TextLayout layout = textRun.getLayout();
            runaci.first();
            //System.out.print("Painting text: ");
            //for (int j=runaci.getBeginIndex(); j<runaci.getEndIndex(); ++j) {
            //    System.out.print(runaci.setIndex(j));
            //}
            //System.out.println("");
            runaci.first();

            Composite opacity = (Composite)
                      runaci.getAttribute(GVTAttributedCharacterIterator.
                                                  TextAttribute.OPACITY);
            if (opacity != null) {
                g2d.setComposite(opacity);
            }

            boolean underline =
                (runaci.getAttribute(GVTAttributedCharacterIterator.
                                     TextAttribute.UNDERLINE) != null);

            // paint over-and-underlines first, then layer glyphs over them

            float thickness = getDecorationThickness(runaci, layout);

            if (underline && !layout.isVertical()) {
                paintUnderline(textRun, location, x, thickness, g2d);
            }
            boolean overline =
                (runaci.getAttribute(GVTAttributedCharacterIterator.
                                     TextAttribute.OVERLINE) != null);

            if (overline && !layout.isVertical()) {
                paintOverline(textRun, location, x, thickness, g2d);
            }


            AffineTransform tx = AffineTransform.getTranslateInstance(
                                        location.getX() + x, location.getY());
            Shape outline = layout.getOutline(tx);

            // check if we need to fill this glyph
            Paint paint = (Paint)
                              runaci.getAttribute(TextAttribute.FOREGROUND);
            if (paint != null) {
                g2d.setPaint(paint);
                g2d.fill(outline);
            }

            // check if we need to draw the outline of this glyph
            Stroke stroke = (Stroke) runaci.getAttribute(
                    GVTAttributedCharacterIterator.TextAttribute.STROKE);
            paint = (Paint) runaci.getAttribute(
                    GVTAttributedCharacterIterator.TextAttribute.STROKE_PAINT);
            if (stroke != null && paint != null) {
                g2d.setStroke(stroke);
                g2d.setPaint(paint);
                g2d.draw(outline);
            }
            boolean strikethrough =
                (runaci.getAttribute(GVTAttributedCharacterIterator.
                    TextAttribute.STRIKETHROUGH) ==
                        GVTAttributedCharacterIterator.
                            TextAttribute.STRIKETHROUGH_ON);
            // paint strikethrough last
            if (strikethrough && !layout.isVertical()) {
View Full Code Here

            if (ranges[0] > ranges[1]) {
                int temp = ranges[1];
                ranges[1] = ranges[0];
                ranges[0] = temp;
            }
            o = new AttributedCharacterSpanIterator
    (aci, ranges[0], ranges[1]+1);
        }
        return o;
    }
View Full Code Here

TOP

Related Classes of org.apache.batik.gvt.text.AttributedCharacterSpanIterator

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.