java.awt.font.TextLayout#toString ( )源码实例Demo

下面列出了java.awt.font.TextLayout#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: TextLayoutUtils.java
public static String toString(TextLayout textLayout) {
    return toStringShort(textLayout) + "; " + // NOI18N
            textLayout.toString();
}
 
源代码2 项目: pentaho-reporting   文件: TextDocumentWriter.java
protected void drawComplexText( final RenderNode node ) {
  final RenderableComplexText renderableComplexText = (RenderableComplexText) node;

  // The text node that is printed will overlap with the ellipse we need to print.
  if ( renderableComplexText.isNodeVisible( drawArea ) == false ) {
    return;
  }
  if ( renderableComplexText.getRawText().length() == 0 ) {
    // This text is empty.
    return;
  }

  final String text;
  TextLayout textLayout = renderableComplexText.getTextLayout();
  String debugInfo = textLayout.toString();
  String startPos =
      debugInfo.substring( debugInfo.indexOf( "[start:" ), debugInfo.indexOf( ", len:" ) ).replace( "[start:", "" );
  int startPosIntValue = -1;

  try {
    startPosIntValue = Integer.parseInt( startPos );
  } catch ( NumberFormatException e ) {
    // do nothing
  }

  // workaround for line breaking (since the text cannot be extracted directly from textLayout as stream or String)
  // in order to avoid duplicates of same source raw text on multiple lines
  if ( ( renderableComplexText.getRawText().length() > textLayout.getCharacterCount() ) && startPosIntValue >= 0 ) {
    text =
        renderableComplexText.getRawText().substring( startPosIntValue,
            textLayout.getCharacterCount() + startPosIntValue );
  } else {
    text = renderableComplexText.getRawText();
  }

  final int x =
      PlainTextPage.correctedDivisionFloor( ( renderableComplexText.getX() - drawArea.getX() ),
          characterWidthInMicroPoint );
  final int y =
      PlainTextPage.correctedDivisionFloor( ( renderableComplexText.getY() - drawArea.getY() ),
          characterHeightInMicroPoint );
  int w = text.length();

  // filter out results that do not belong to the current physical page
  if ( x + w > plainTextPage.getWidth() ) {
    w = Math.max( 0, plainTextPage.getWidth() - x );
  }
  if ( w == 0 ) {
    return;
  }
  if ( y < 0 ) {
    return;
  }
  if ( y >= plainTextPage.getHeight() ) {
    return;
  }

  plainTextPage.addTextChunk( x, y, w, text, renderableComplexText.getStyleSheet() );
}