Package net.sf.jasperreports.engine.util

Examples of net.sf.jasperreports.engine.util.JRStyledText$Run


  public void exportText(JRPrintText text, JRExporterGridCell gridCell, int col, int row) throws JRException
  {
    addMergeRegion(gridCell, col, row);

    JRStyledText styledText = getStyledText(text);

    if (styledText != null)
    {
      Colour forecolor = getWorkbookColour(text.getForecolor());
      WritableFont cellFont = this.getLoadedFont(text, forecolor.getValue(), getTextLocale(text));

      TextAlignHolder alignment = getTextAlignHolder(text);
      int horizontalAlignment = getHorizontalAlignment(alignment);
      int verticalAlignment = getVerticalAlignment(alignment);
      int rotation = getRotation(alignment);

      Pattern mode = this.backgroundMode;
      Colour backcolor = WHITE;

      if (!isIgnoreCellBackground && gridCell.getCellBackcolor() != null)
      {
        mode = Pattern.SOLID;
        backcolor = getWorkbookColour(gridCell.getCellBackcolor(), true);
      }

      StyleInfo baseStyle =
        new StyleInfo(
          mode,
          backcolor,
          horizontalAlignment,
          verticalAlignment,
          rotation,
          cellFont,
          gridCell,
          isWrapText(text),
          isCellLocked(text)
          );

      String textStr = styledText.getText();

      String href = null;
      JRHyperlinkProducer customHandler = getCustomHandler(text);
      if (customHandler == null)
      {
View Full Code Here


   */
  public void exportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell)
  {
    tableHelper.getCellHelper().exportHeader(text, gridCell);

    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null)
    {
      textLength = styledText.length();
    }

//    if (styleBuffer.length() > 0)
//    {
//      writer.write(" style=\"");
View Full Code Here

    JRExporterGridCell gridCell,
    int colIndex,
    int rowIndex
    ) throws JRException
  {
    final JRStyledText styledText = getStyledText(text);

    final int textLength = styledText == null ? 0 : styledText.length();

    final String textStr = styledText.getText();

    TextValue textValue = null;
    if (isDetectCellType)
    {
      textValue = getTextValue(text, textStr);
View Full Code Here

   */
  public void draw(Graphics2D grx, JRPrintText text, int offsetX, int offsetY)
  {
    textRenderer.initialize(grx, text, offsetX, offsetY);
   
    JRStyledText styledText = textRenderer.getStyledText();
   
    if (styledText == null)
    {
      return;
    }
View Full Code Here

   */
  public void exportText(JRPrintText text) throws IOException, JRException {


    // use styled text
    JRStyledText styledText = getStyledText(text);
    if (styledText == null)
    {
      return;
    }

    int width = text.getWidth();
    int height = text.getHeight();

    int textHeight = (int)text.getTextHeight();

    if(textHeight <= 0) {
      if(height <= 0 ){
        throw new JRException("Invalid text height");
      }
      textHeight = height;
    }

    /*   */
    startElement(text);

    // padding for the text
    int topPadding = text.getLineBox().getTopPadding().intValue();
    int leftPadding = text.getLineBox().getLeftPadding().intValue();
    int bottomPadding = text.getLineBox().getBottomPadding().intValue();
    int rightPadding = text.getLineBox().getRightPadding().intValue();

    String rotation = null;

    switch (text.getRotationValue())
    {
      case LEFT :
      {
        switch (text.getVerticalAlignmentValue())
        {
          case TOP:
          {
            break;
          }
          case MIDDLE:
          {
            leftPadding = Math.max(leftPadding, (width - rightPadding - textHeight) / 2);
            break;
          }
          case BOTTOM:
          {
            leftPadding = Math.max(leftPadding, width - rightPadding - textHeight);
            break;
          }
        }
        rotation = "{\\sp{\\sn txflTextFlow}{\\sv 2}}";
        break;
      }
      case RIGHT :
      {
        switch (text.getVerticalAlignmentValue())
        {
          case TOP:
          {
            break;
          }
          case MIDDLE:
          {
            rightPadding = Math.max(rightPadding, (width - leftPadding - textHeight) / 2);
            break;
          }
          case BOTTOM:
          {
            rightPadding = Math.max(rightPadding, width - leftPadding - textHeight);
            break;
          }
        }
        rotation = "{\\sp{\\sn txflTextFlow}{\\sv 3}}";
        break;
      }
      case UPSIDE_DOWN :
      {
        switch (text.getVerticalAlignmentValue())
        {
          case TOP:
          {
            topPadding = Math.max(topPadding, height - bottomPadding - textHeight);
            break;
          }
          case MIDDLE:
          {
            topPadding = Math.max(topPadding, (height - bottomPadding - textHeight) / 2);
            break;
          }
          case BOTTOM:
          {
            break;
          }
        }
        rotation = "";
        break;
      }
      case NONE :
      default :
      {
        switch (text.getVerticalAlignmentValue())
        {
          case TOP:
          {
            break;
          }
          case MIDDLE:
          {
            topPadding = Math.max(topPadding, (height - bottomPadding - textHeight) / 2);
            break;
          }
          case BOTTOM:
          {
            topPadding = Math.max(topPadding, height - bottomPadding - textHeight);
            break;
          }
        }
        rotation = "";
      }
    }

    writer.write(rotation);
    writer.write("{\\sp{\\sn dyTextTop}{\\sv ");
    writer.write(String.valueOf(LengthUtil.emu(topPadding)));
    writer.write("}}");
    writer.write("{\\sp{\\sn dxTextLeft}{\\sv ");
    writer.write(String.valueOf(LengthUtil.emu(leftPadding)));
    writer.write("}}");
    writer.write("{\\sp{\\sn dyTextBottom}{\\sv ");
    writer.write(String.valueOf(LengthUtil.emu(bottomPadding)));
    writer.write("}}");
    writer.write("{\\sp{\\sn dxTextRight}{\\sv ");
    writer.write(String.valueOf(LengthUtil.emu(rightPadding)));
    writer.write("}}");
    writer.write("{\\sp{\\sn fLine}{\\sv 0}}");
    writer.write("{\\shptxt{\\pard ");

    writer.write("\\fi" + LengthUtil.twip(text.getParagraph().getFirstLineIndent().intValue()) + " ");
    writer.write("\\li" + LengthUtil.twip(text.getParagraph().getLeftIndent().intValue()) + " ");
    writer.write("\\ri" + LengthUtil.twip(text.getParagraph().getRightIndent().intValue()) + " ");
    writer.write("\\sb" + LengthUtil.twip(text.getParagraph().getSpacingBefore().intValue()) + " ");
    writer.write("\\sa" + LengthUtil.twip(text.getParagraph().getSpacingAfter().intValue()) + " ");

    TabStop[] tabStops = text.getParagraph().getTabStops();
    if (tabStops != null && tabStops.length > 0)
    {
      for (int i = 0; i < tabStops.length; i++)
      {
        TabStop tabStop = tabStops[i];

        String tabStopAlign = "";
       
        switch (tabStop.getAlignment())
        {
          case CENTER:
            tabStopAlign = "\\tqc";
            break;
          case RIGHT:
            tabStopAlign = "\\tqr";
            break;
          case LEFT:
          default:
            tabStopAlign = "";
            break;
        }

        writer.write(tabStopAlign + "\\tx" + LengthUtil.twip(tabStop.getPosition()) + " ");
      }
    }

    JRFont font = text;
    if (text.getRunDirectionValue() == RunDirectionEnum.RTL)
    {
      writer.write("\\rtlch");
    }
//    writer.write("\\f");
//    writer.write(String.valueOf(getFontIndex(font)));
//    writer.write("\\cf");
//    writer.write(String.valueOf(getColorIndex(text.getForecolor())));
    writer.write("\\cb");
    writer.write(String.valueOf(getColorIndex(text.getBackcolor())));
    writer.write(" ");

//    if (font.isBold())
//      writer.write("\\b");
//    if (font.isItalic())
//      writer.write("\\i");
//    if (font.isStrikeThrough())
//      writer.write("\\strike");
//    if (font.isUnderline())
//      writer.write("\\ul");
//    writer.write("\\fs");
//    writer.write(String.valueOf(font.getFontSize() * 2));

    switch (text.getHorizontalAlignmentValue())
    {
      case LEFT:
        writer.write("\\ql");
        break;
      case CENTER:
        writer.write("\\qc");
        break;
      case RIGHT:
        writer.write("\\qr");
        break;
      case JUSTIFIED:
        writer.write("\\qj");
        break;
      default:
        writer.write("\\ql");
        break;
    }

    switch (text.getParagraph().getLineSpacing())
    {
      case AT_LEAST:
      {
        writer.write("\\sl" + LengthUtil.twip(text.getParagraph().getLineSpacingSize().floatValue()));
        writer.write(" \\slmult0 ");
        break;
      }
      case FIXED:
      {
        writer.write("\\sl-" + LengthUtil.twip(text.getParagraph().getLineSpacingSize().floatValue()));
        writer.write(" \\slmult0 ");
        break;
      }
      case PROPORTIONAL:
      {
        writer.write("\\sl" + (int)(text.getParagraph().getLineSpacingSize().floatValue() * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case DOUBLE:
      {
        writer.write("\\sl" + (int)(2f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case ONE_AND_HALF:
      {
        writer.write("\\sl" + (int)(1.5f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case SINGLE:
      default:
      {
        writer.write("\\sl" + (int)(1f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
    }

    if (text.getAnchorName() != null)
    {
      writeAnchor(text.getAnchorName());
    }

    exportHyperlink(text);

    // 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);
View Full Code Here

   */
  public void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell) throws IOException
  {
    tableBuilder.buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null)
    {
      textLength = styledText.length();
    }

    tempBodyWriter.write("<text:p text:style-name=\"");
    tempBodyWriter.write(styleCache.getParagraphStyle(text));
    tempBodyWriter.write("\">");
View Full Code Here



  public void exportText(JRPrintText textElement, JRExporterGridCell gridCell, int colIndex, int rowIndex) throws JRException
  {
    JRStyledText styledText = getStyledText(textElement);

    if (styledText == null)
    {
      return;
    }
View Full Code Here

  /**
   *
   */
  protected void exportText(JRPrintText text, JRExporterGridCell gridCell) throws IOException
  {
    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null)
    {
      textLength = styledText.length();
    }

    writeCellStart(gridCell);//FIXME why dealing with cell style if no text to print (textLength == 0)?

    if (text.getRunDirectionValue() == RunDirectionEnum.RTL)
View Full Code Here


  protected JRStyledText getStyledText(JRPrintText textElement,
      boolean setBackcolor)
  {
    JRStyledText styledText = super.getStyledText(textElement, setBackcolor);
   
    if (styledText != null)
    {
      short[] lineBreakOffsets = textElement.getLineBreakOffsets();
      if (lineBreakOffsets != null && lineBreakOffsets.length > 0)
      {
        //insert new lines at the line break positions saved at fill time
        //cloning the text first
        styledText = styledText.cloneText();
        styledText.insert("\n", lineBreakOffsets);
      }
    }
   
    return styledText;
  }
View Full Code Here

  /**
   *
   */
  public void exportText(JRPrintText text)
  {
    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null)
    {
      textLength = styledText.length();
    }
 
    int x = 0;
    int y = 0;
    int width = 0;
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.util.JRStyledText$Run

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.