org.eclipse.swt.graphics.GC.drawText()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(207)

本文整理了Java中org.eclipse.swt.graphics.GC.drawText()方法的一些代码示例,展示了GC.drawText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.drawText()方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:drawText

GC.drawText介绍

[英]Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return processing are performed. The background of the rectangular area where the text is being drawn will be filled with the receiver's background color.
[中]使用接收者的当前字体和前景色绘制给定字符串。执行选项卡展开和回车处理。正在绘制文本的矩形区域的背景将用接收者的背景色填充。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void drawText( String text, int x, int y ) {
 gc.drawText( text, x, y );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawText( String text, int x, int y, boolean transparent ) {
 gc.drawText( text, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawText( String text, int x, int y ) {
 gc.drawText( text, x, y );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawText( String text, int x, int y, boolean transparent ) {
 gc.drawText( text, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT );
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawMessage( GC gc ) {
 gc.setForeground( blue );
 gc.drawText(
  getMessageString(), size_up.x + size_up.width + offsetx + 40, size_up.y + 1 + offsety,
  SWT.DRAW_TRANSPARENT );
 // widget.setToolTipText(getMessageString());
}

代码示例来源:origin: pentaho/pentaho-kettle

private void repaint( GC gc, int width, int height ) {
 ImageData imd = image.getImageData();
 double sizeOnPaperX = imd.width * factorx;
 double sizeOnPaperY = imd.height * factory;
 double actualSizeX = sizeOnPaperX * scale / 100;
 double actualSizeY = sizeOnPaperY * scale / 100;
 // What % of the screen is filled?
 // The canvas is nrcols * nrrows nr of pages large.
 double percentScreenX = actualSizeX / ( page.x * nrcols );
 double percentScreenY = actualSizeY / ( page.y * nrrows );
 gc.drawImage(
  image, 0, 0, imd.width, imd.height, 0, 0, (int) ( width * percentScreenX ),
  (int) ( height * percentScreenY ) );
 StringBuilder text = new StringBuilder();
 text.append( nrcols ).append( "x" ).append( nrrows ).append( " @ " ).append( scale ).append( "%" );
 gc.drawText( text.toString(), 0, 0 );
 for ( int c = 1; c < nrcols; c++ ) {
  gc.drawLine( c * ( width / nrcols ), 0, c * ( width / nrcols ), height );
 }
 for ( int r = 1; r < nrrows; r++ ) {
  gc.drawLine( 0, r * ( height / nrrows ), width, r * ( height / nrrows ) );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void drawUp( GC gc ) {
 if ( hover_up ) {
  gc.setBackground( gray );
  gc.fillRectangle( size_up );
 }
 gc.drawRectangle( size_up );
 gc.drawText( STRING_UP, size_up.x + 1 + offsetx, size_up.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
}

代码示例来源:origin: pentaho/pentaho-kettle

private void drawNegated( GC gc, int x, int y, Condition condition ) {
 Color color = gc.getForeground();
 if ( hover_not ) {
  gc.setBackground( gray );
 }
 gc.fillRectangle( Real2Screen( size_not ) );
 gc.drawRectangle( Real2Screen( size_not ) );
 if ( condition.isNegated() ) {
  if ( hover_not ) {
   gc.setForeground( green );
  }
  gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
  gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
  if ( hover_not ) {
   gc.setForeground( color );
  }
 } else {
  if ( hover_not ) {
   gc.setForeground( red );
   gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
   gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT );
   gc.setForeground( color );
  }
 }
 if ( hover_not ) {
  gc.setBackground( bg );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( fixedFont );
  Rectangle max = wFFont.getBounds();
  String name = fixedFontData.getName() + " - " + fixedFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( graphFont );
  Rectangle max = wGFont.getBounds();
  String name = graphFontData.getName() + " - " + graphFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( noteFont );
  Rectangle max = wNFont.getBounds();
  String name = noteFontData.getName() + " - " + noteFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

private void drawVersionWarning( GC gc, Display display ) {
 gc.setBackground( versionWarningBackgroundColor );
 gc.setForeground( new Color( display, 65, 65, 65 ) );
 // gc.fillRectangle(290, 231, 367, 49);
 // gc.drawRectangle(290, 231, 367, 49);
 gc.drawImage( exclamation_image, 304, 243 );
 gc.setFont( devWarningFont );
 gc.drawText( BaseMessages.getString( PKG, "SplashDialog.DevelopmentWarning" ), 335, 241, true );
}

代码示例来源:origin: pentaho/pentaho-kettle

e.gc.drawText( fullVersionText, 290, 205, true );
e.gc.drawText( licenseText, 290, 275, true );
e.gc.drawText( version, 290, 235, true );
e.gc.drawText( buildDate, 290, 250, true );

代码示例来源:origin: pentaho/pentaho-kettle

gc.drawText( left, size_left.x + 1 + offsetx, size_left.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
} else {
 gc.setForeground( gray );
 gc.drawText( "<field>", size_left.x + 1 + offsetx, size_left.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
 gc.setForeground( black );
gc.drawText( fn, size_fn.x + 1 + offsetx, size_fn.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
  gc.drawText( rightval, size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
 } else {
  String nothing = rightex == null ? "<field>" : "";
  gc.setForeground( gray );
  gc.drawText( nothing, size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
  if ( condition.getRightValuename() == null ) {
   gc.setForeground( black );
  gc.drawText( re, size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
 } else {
  String nothing = condition.getRightValuename() == null ? "<value>" : "";
  gc.setForeground( gray );
  gc.drawText( nothing, size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
  gc.setForeground( black );
 gc.drawText(
  stype, size_rightex.x + 1 + size_rightex.width + 10 + offsetx, size_rightex.y + 1 + offsety,
  SWT.DRAW_TRANSPARENT );
} else {
 gc.drawText( "-", size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
 gc.drawText( "-", size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT );

代码示例来源:origin: pentaho/pentaho-kettle

String str = rows.get( i );
for ( int p = fromx; p < str.length() && p < tox; p++ ) {
 gc.drawText( "" + str.charAt( p ), LEFT + MARGIN + p * fontwidth + offset.x, TOP
  + i * ( fontheight + 2 ) + offset.y, true );
 gc.drawText(
  "" + i, LEFT + MARGIN + i * fontwidth - numsize / 2 + offset.x, linepos - 10 - fontheight, true );
String number = "" + ( i + 1 );
int numsize = number.length() * fontwidth;
gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true );
gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP
 + ( i + 1 ) * ( fontheight + 2 ) + offset.y );

代码示例来源:origin: pentaho/pentaho-kettle

String str = rows.get( i );
for ( int p = fromx; p < str.length() && p < tox; p++ ) {
 gc.drawText( "" + str.charAt( p ), LEFT + MARGIN + p * fontwidth + offset.x, TOP
  + i * ( fontheight + 2 ) + offset.y, true );
 gc.drawText(
  "" + i, LEFT + MARGIN + i * fontwidth - numsize / 2 + offset.x, linepos - 10 - fontheight, true );
String number = "" + ( i + 1 );
int numsize = number.length() * fontwidth;
gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true );
gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP
 + ( i + 1 ) * ( fontheight + 2 ) + offset.y );

代码示例来源:origin: pentaho/pentaho-kettle

gc.setBackground( bg );
 gc.drawText( operator, size_oper[nr].x + 2 + offsetx, size_oper[nr].y + 2 + offsety, SWT.DRAW_TRANSPARENT );
 gc.setBackground( bg );
gc.drawText( str, size_cond[nr].x + 2 + offsetx, size_cond[nr].y + 5 + offsety, SWT.DRAW_DELIMITER
 | SWT.DRAW_TRANSPARENT | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( final PaintEvent event ) {
  if ( transGraph.trans != null && transGraph.trans.isFinished() ) {
   refreshImage( event.gc );
   if ( image != null && !image.isDisposed() ) {
    event.gc.drawImage( image, 0, 0 );
   }
  } else {
   Rectangle bounds = canvas.getBounds();
   if ( bounds.width <= 0 || bounds.height <= 0 ) {
    return;
   }
   event.gc.setForeground( GUIResource.getInstance().getColorWhite() );
   event.gc.setBackground( GUIResource.getInstance().getColorWhite() );
   event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) );
   event.gc.setForeground( GUIResource.getInstance().getColorBlack() );
   String metricsMessage =
    BaseMessages.getString( PKG, "TransMetricsDelegate.TransformationIsNotRunning.Message" );
   org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage );
   event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent event ) {
  if ( jobGraph.job != null && ( jobGraph.job.isFinished() || jobGraph.job.isStopped() ) ) {
   refreshImage( event.gc );
   if ( image != null && !image.isDisposed() ) {
    event.gc.drawImage( image, 0, 0 );
   }
  } else {
   Rectangle bounds = canvas.getBounds();
   if ( bounds.width <= 0 || bounds.height <= 0 ) {
    return;
   }
   event.gc.setForeground( GUIResource.getInstance().getColorWhite() );
   event.gc.setBackground( GUIResource.getInstance().getColorWhite() );
   event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) );
   event.gc.setForeground( GUIResource.getInstance().getColorBlack() );
   String metricsMessage = BaseMessages.getString( PKG, "JobMetricsDelegate.JobIsNotRunning.Message" );
   org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage );
   event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 );
  }
 }
} );

代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer

public void drawString(OutputDevice outputDevice, String string, float x,
    float y) {
  GC gc = ((SWTOutputDevice) outputDevice).getGC();
  FontMetrics metrics = gc.getFontMetrics();
  y -= (metrics.getAscent() + metrics.getLeading());
  gc.drawText(string, (int) x, (int) y, SWT.DRAW_TRANSPARENT);
}

相关文章

GC类方法