Package java.text

Examples of java.text.AttributedString.addAttribute()


    // we do _not_ want to use the direction of the first character
    // in this text.
    Graphics2D g2 = (Graphics2D) g;

    AttributedString as  = new AttributedString(paintText);
    as.addAttribute(TextAttribute.FONT, g2.getFont());

    Object direction;
    if (context.getReadingDirection() == LocaleUtils.DIRECTION_LEFTTORIGHT)
      direction = TextAttribute.RUN_DIRECTION_LTR;
    else
View Full Code Here


    if (context.getReadingDirection() == LocaleUtils.DIRECTION_LEFTTORIGHT)
      direction = TextAttribute.RUN_DIRECTION_LTR;
    else
      direction = TextAttribute.RUN_DIRECTION_RTL;

    as.addAttribute(TextAttribute.RUN_DIRECTION, direction);

    g2.drawString(as.getIterator(), x, y);

    //
    // paint the mnemonic if necessary
View Full Code Here

                Iterator kit = m.keySet().iterator();
                Iterator vit = m.values().iterator();
                while (kit.hasNext()) {
                    Attribute attr = (Attribute)kit.next();
                    Object val = vit.next();
                    result.addAttribute(attr, val, idx, nidx);
                }
                idx = nidx;
            }

            return result;
View Full Code Here

  private TextLayout getTextLayout(AttributedCharacterIterator text, int committed_count) {
    AttributedString composed = new AttributedString(text, committed_count, text.getEndIndex());
    Font font = textArea.getPainter().getFont();
    FontRenderContext context = ((Graphics2D) (textArea.getPainter().getGraphics())).getFontRenderContext();
    composed.addAttribute(TextAttribute.FONT, font);
    TextLayout layout = new TextLayout(composed.getIterator(), context);
    return layout;
  }

  private Point getCaretLocation() {
View Full Code Here

                        int runStart = -1;
                        for (int j = currentIndex; j < displayUpToIndex; j++) {
                            if (fontAssigned[j - start]) {
                                if (runStart != -1) {
            // System.out.println("Font 1: " + font);
                                    as.addAttribute(GVT_FONT, font,
                                                    runStart-begin, j-begin);
                                    runStart=-1;
                                }
                            } else {
                                if (runStart == -1)
View Full Code Here

                            fontAssigned[j - start] = true;
                            numSet++;
                        }
                        if (runStart != -1) {
          // System.out.println("Font 2: " + font);
                            as.addAttribute(GVT_FONT, font,
                                            runStart-begin,
                                            displayUpToIndex-begin);
                        }

                        // set currentIndex to be one after the char
View Full Code Here

            GVTFont       prevF    = defaultFont;
            for (int i = 0; i < aciLength; i++) {
                if (fontAssigned[i]) {
                    if (runStart != -1) {
      // System.out.println("Font 3: " + prevF);
                        as.addAttribute(GVT_FONT, prevF,
                                        runStart+asOff, i+asOff);
                        runStart = -1;
                        prevF  = null;
                        prevFF = null;
                    }
View Full Code Here

                    }
                }
            }
            if (runStart != -1) {
    // System.out.println("Font 5: " + prevF);
                as.addAttribute(GVT_FONT, prevF,
                                runStart+asOff, aciLength+asOff);
      }

            asOff += aciLength;
            if (aci.setIndex(end) == aci.DONE) {
View Full Code Here

            int newBiDi = tl.getCharacterLevel(i);
            charIndices[i] = i;
            charLevels [i] = newBiDi;

            if (newBiDi != currBiDi) {
                as.addAttribute
                    (GVTAttributedCharacterIterator.TextAttribute.BIDI_LEVEL,
                     new Integer(currBiDi), runStart, i);
                runStart = i;
                currBiDi  = newBiDi;
                if (newBiDi > maxBiDi) maxBiDi = newBiDi;
View Full Code Here

            for (int i=0; i<numChars; i++)
                newCharOrder[i] = chunkStart+i;
            return;
        }

        as.addAttribute
            (GVTAttributedCharacterIterator.TextAttribute.BIDI_LEVEL,
             new Integer(currBiDi), runStart, numChars);

        this.aci = as.getIterator();
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.