Examples of AttributedCharacterIterator


Examples of java.text.AttributedCharacterIterator

  {
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      Map attributes = iterator.getAttributes();
     
      boolean localHyperlink = false;

      if (!startedHyperlink)
      {
        JRPrintHyperlink hyperlink = (JRPrintHyperlink)attributes.get(JRTextAttribute.HYPERLINK);
        if (hyperlink != null)
        {
          localHyperlink = startHyperlink(hyperlink, true);
        }
      }
     
      runHelper.export(
        style,
        iterator.getAttributes(),
        text.substring(iterator.getIndex(), runLimit),
        locale,
        hiddenText
        );
     
      if (localHyperlink)
      {
        endHyperlink(true);
      }

      iterator.setIndex(runLimit);
    }
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

  {
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      runHelper.export(
        style, iterator.getAttributes(),
        text.substring(iterator.getIndex(), runLimit),
        locale
        );

      iterator.setIndex(runLimit);
    }
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

    // add parameters in case of styled text element
    String plainText = styledText.getText();
    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
    while (
      runLimit < styledText.length()
      && (runLimit = iterator.getRunLimit()) <= styledText.length()
      )
    {

      Map styledTextAttributes = iterator.getAttributes();
      JRFont styleFont = new JRBaseFont(styledTextAttributes);
      Color styleForeground = (Color) styledTextAttributes.get(TextAttribute.FOREGROUND);
      Color styleBackground = (Color) styledTextAttributes.get(TextAttribute.BACKGROUND);

      writer.write("\\f");
      writer.write(String.valueOf(getFontIndex(styleFont, getTextLocale(text))));
      writer.write("\\fs");
      writer.write(String.valueOf(2 * styleFont.getFontSize()));

      if (styleFont.isBold())
      {
        writer.write("\\b");
      }
      if (styleFont.isItalic())
      {
        writer.write("\\i");
      }
      if (styleFont.isUnderline())
      {
        writer.write("\\ul");
      }
      if (styleFont.isStrikeThrough())
      {
        writer.write("\\strike");
      }

      if (TextAttribute.SUPERSCRIPT_SUPER.equals(styledTextAttributes.get(TextAttribute.SUPERSCRIPT)))
      {
        writer.write("\\super");
      }
      else if (TextAttribute.SUPERSCRIPT_SUB.equals(styledTextAttributes.get(TextAttribute.SUPERSCRIPT)))
      {
        writer.write("\\sub");
      }

      if(!(null == styleBackground || styleBackground.equals(text.getBackcolor()))){
        writer.write("\\highlight");
        writer.write(String.valueOf(getColorIndex(styleBackground)));
      }
      writer.write("\\cf");
      writer.write(String.valueOf(getColorIndex(styleForeground)));
      writer.write(" ");

      writer.write(
        handleUnicodeText(
          plainText.substring(iterator.getIndex(), runLimit)         
          )
        );

      // reset all styles in the paragraph
      writer.write("\\plain");

      iterator.setIndex(runLimit);
    }
//    if (startedHyperlink)
//    {
//      endHyperlink();
//    }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

  {
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      exportStyledTextRun(
        iterator.getAttributes(),
        text.substring(iterator.getIndex(), runLimit),
        locale,
        startedHyperlink
        );

      iterator.setIndex(runLimit);
    }
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

  protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale)
  {
    String text = styledText.getText();
    HSSFRichTextString richTextStr = new HSSFRichTextString(text);
    int runLimit = 0;
    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      Map attributes = iterator.getAttributes();
      JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
      short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ?
          getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
          forecolor;
      HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
      richTextStr.applyFont(iterator.getIndex(), runLimit, font);
      iterator.setIndex(runLimit);
    }
    return richTextStr;
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

   * @see #write(Map, AttributedCharacterIterator, String)
   */
  public String write(JRStyledText styledText,
      int startIndex, int endIndex)
  {
    AttributedCharacterIterator subIterator = new AttributedString(
        styledText.getAttributedString().getIterator(),
        startIndex, endIndex).getIterator();
    String subText = styledText.getText().substring(startIndex, endIndex);
    return write(styledText.getGlobalAttributes(), subIterator, subText);
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

  {
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      runHelper.export(
        style,
        iterator.getAttributes(),
        text.substring(iterator.getIndex(), runLimit),
        locale
        );

      iterator.setIndex(runLimit);
    }
  }
View Full Code Here

Examples of java.text.AttributedCharacterIterator

                    typedCal.setTime(typedDate);
                    Calendar projectStartCal = CalendarFactory.newCalendar();
                    projectStartCal.setTime(myProject.getTaskManager().getProjectStart());
                    int yearDiff = Math.abs(typedCal.get(Calendar.YEAR) - projectStartCal.get(Calendar.YEAR));
                    if (yearDiff > 1500) {
                      AttributedCharacterIterator iter = formats[i].formatToCharacterIterator(typedDate);
                      int additionalZeroes = -1;
                      StringBuffer result = new StringBuffer();
                      for (char c = iter.first(); c!=iter.DONE; c = iter.next()) {
                        if (iter.getAttribute(DateFormat.Field.YEAR)!=null && additionalZeroes==-1) {
                              additionalZeroes = iter.getRunLimit(DateFormat.Field.YEAR) - iter.getIndex();
                          for (int j=0; j<additionalZeroes; j++) {
                            result.append('0');
                          }
                        }
                        result.append(c);
View Full Code Here

Examples of java.text.AttributedCharacterIterator

    final BreakIterator iter = BreakIterator.getLineInstance();
    iter.setText(text.getIterator());
   
    int previous = iter.first();
   
    AttributedCharacterIterator best = null;
   
    while (iter.next() != BreakIterator.DONE) {
      final AttributedCharacterIterator candidate = text.getIterator(null, previous, iter.current());

      if (getPixelWidth(candidate) <= width) {
        // check for line breaks within the provided text
        // unfortunately, the BreakIterators are too dumb to tell *why* they consider the
        // location a break, so the check needs to be implemented here
View Full Code Here

Examples of java.text.AttributedCharacterIterator

    final int offset = text.getBeginIndex();
    final BreakIterator wordIterator = BreakIterator.getWordInstance();
   
    final AttributedString tmpText = new AttributedString(text);
    // return the original iterator if there are no suitable break points
    AttributedCharacterIterator best = text;
    wordIterator.setText(text);
   
    while (wordIterator.next() != BreakIterator.DONE) {
      final AttributedCharacterIterator candidate = tmpText.getIterator(null, tmpText.getIterator().getBeginIndex(), wordIterator.current() - offset);
     
      if (getPixelWidth(candidate) <= width) {
        best = candidate;
      } else {
        return best;
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.