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

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

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

GC.textExtent介绍

[英]Returns the extent of the given string. Tab expansion and carriage return processing are performed.

The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font (in this case, the current font in the receiver).
[中]返回给定字符串的范围。执行选项卡展开和回车处理。
字符串的范围是以特定字体绘制时将覆盖的矩形区域的宽度和高度(在本例中为接收器中的当前字体)。

代码示例

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

private boolean willLicenseTextFit( String licenseText, GC gc ) {
 Point splashSize = splash.getSize();
 Point licenseDrawLocation = new Point( 290, 290 );
 Point requiredSize = gc.textExtent( licenseText );
 int width = splashSize.x - licenseDrawLocation.x;
 int height = splashSize.y - licenseDrawLocation.y;
 boolean fitsVertically = width >= requiredSize.x;
 boolean fitsHorizontally = height >= requiredSize.y;
 return ( fitsVertically && fitsHorizontally );
}

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

private Rectangle getAndNotSize( GC gc ) {
 Point p = gc.textExtent( Condition.operators[Condition.OPERATOR_AND_NOT] );
 return new Rectangle( 0, 0, p.x, p.y );
}

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

public Point textExtent( String text ) {
 org.eclipse.swt.graphics.Point p = gc.textExtent( text );
 return new Point( p.x, p.y );
}

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

private Rectangle getUpSize( GC gc ) {
 Point p = gc.textExtent( STRING_UP );
 return new Rectangle( size_not.x + size_not.width + 40, size_not.y, p.x + 20, size_not.height );
}

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

public Point textExtent( String text ) {
 org.eclipse.swt.graphics.Point p = gc.textExtent( text );
 return new Point( p.x, p.y );
}

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

private Rectangle getNotSize( GC gc ) {
 Point p = gc.textExtent( STRING_NOT );
 return new Rectangle( 0, 0, p.x + 10, p.y + 4 );
}

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

private String truncateName( String name ) {
  GC gc = new GC( toolBar );
  Point size = gc.textExtent( name );
  if ( size.x <= MAX_REPO_NAME_PIXEL_LENGTH ) { // repository name is small enough to fit just return it.
   gc.dispose();
   return name;
  }
  String originalName = name;
  while ( gc.textExtent( name + "..." ).x > MAX_REPO_NAME_PIXEL_LENGTH ) {
   name = name.substring( 0, name.length() - 1 );
  }
  gc.dispose();
  name = name + "...";
  return name;
 }
}

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

private static final void getMaxWidths( TreeItem[] items, int[] max, GC gc ) {
 for ( int i = 0; i < items.length; i++ ) {
  for ( int c = 0; c < max.length; c++ ) {
   String string = items[i].getText( c );
   Point point = gc.textExtent( string );
   if ( point.x > max[c] ) {
    max[c] = point.x;
   }
  }
  getMaxWidths( items[i].getItems(), max, gc );
 }
}

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

String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );

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

String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );

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

String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );

代码示例来源: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

org.eclipse.swt.graphics.Point textExtent = canvasGc.textExtent( "AagKkiw" );
int height = textExtent.y + 8;

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

public static final void setOptimalWidthOnColumns( Tree tree ) {
 int nrCols = tree.getColumnCount();
 int[] max = new int[nrCols];
 Image image = new Image( tree.getDisplay(), 10, 10 );
 GC gc = new GC( image );
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  Point point = gc.textExtent( treeColumn.getText() );
  max[i] = point.x;
 }
 getMaxWidths( tree.getItems(), max, gc );
 gc.dispose();
 image.dispose();
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  treeColumn.setWidth( max[i] + 30 );
 }
}

代码示例来源: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: pentaho/pentaho-kettle

int strmax = TableView.dummyGC.textExtent( str, SWT.DRAW_TAB | SWT.DRAW_DELIMITER ).x + 20;
int colmax = tablecolumn[colnr].getWidth();
if ( strmax > colmax ) {

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

Point p = gc.textExtent( str );

相关文章

GC类方法