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

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

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

GC.dispose介绍

暂无

代码示例

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

@Override
protected Image renderSimple( Device device, int width, int height ) {
 int xsize = bitmap.getBounds().width;
 int ysize = bitmap.getBounds().height;
 Image result = new Image( device, width, height );
 GC gc = new GC( result );
 gc.drawImage( bitmap, 0, 0, xsize, ysize, 0, 0, width, height );
 gc.dispose();
 return result;
}

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

String leftText = newText.substring( 0, e.start );
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 );
editor.horizontalAlignment = SWT.LEFT;

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

String leftText = newText.substring( 0, e.start );
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 );
editor.horizontalAlignment = SWT.LEFT;

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

String leftText = newText.substring( 0, e.start );
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 );
editor.horizontalAlignment = SWT.LEFT;

代码示例来源:origin: caoxinyu/RedisClient

/**
 * @return the small {@link Image} that can be used as placeholder for missing image.
 */
private static Image getMissingImage() {
  Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
  //
  GC gc = new GC(image);
  gc.setBackground(getColor(SWT.COLOR_RED));
  gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
  gc.dispose();
  //
  return image;
}
/**

代码示例来源:origin: caoxinyu/RedisClient

GC gc = new GC(result);
gc.drawImage(baseImage, 0, 0);
if (corner == TOP_LEFT) {
  gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
gc.dispose();

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

@Override
 protected Image renderRotated( Device device, int width, int height, double angleRadians ) {
  Image result = new Image( device, width * 2, height * 2 );

  GC gc = new GC( result );

  int bw = bitmap.getBounds().width;
  int bh = bitmap.getBounds().height;
  Transform affineTransform = new Transform( device );
  affineTransform.translate( width, height );
  affineTransform.rotate( (float) Math.toDegrees( angleRadians ) );
  affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh );
  gc.setTransform( affineTransform );

  gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh );

  gc.dispose();

  return result;
 }
}

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

void layout() {
 Composite parent = canvas.getParent();
 Rectangle rect = parent.getClientArea();
 int width = 0;
 String[] items = list.getItems();
 GC gc = new GC( list );
 for ( int i = 0; i < objects.length; i++ ) {
  width = Math.max( width, gc.stringExtent( items[i] ).x );
 }
 gc.dispose();
 Point size1 = start.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size2 = stop.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size3 = check.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size4 = label.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 width = Math.max( size1.x, Math.max( size2.x, Math.max( size3.x, width ) ) );
 width = Math.max( 64, Math.max( size4.x, list.computeSize( width, SWT.DEFAULT ).x ) );
 start.setBounds( 0, 0, width, size1.y );
 stop.setBounds( 0, size1.y, width, size2.y );
 check.setBounds( 0, size1.y + size2.y, width, size3.y );
 label.setBounds( 0, rect.height - size4.y, width, size4.y );
 int height = size1.y + size2.y + size3.y;
 list.setBounds( 0, height, width, rect.height - height - size4.y );
 text.setBounds( width, 0, rect.width - width, rect.height );
 canvas.setBounds( width, 0, rect.width - width, rect.height );
}

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

/**
 * Get the image for when all other fallbacks have failed.  This is an image
 * drawn on the canvas, a square with a red X.
 *
 * @param display the device to render the image to
 * @return the missing image
 */
public static SwtUniversalImage getMissingImage( Display display ) {
 Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE );
 GC gc = new GC( img );
 gc.setForeground( new Color( display, 0, 0, 0 ) );
 gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 );
 gc.setForeground( new Color( display, 255, 0, 0 ) );
 gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 );
 gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 );
 gc.dispose();
 return new SwtUniversalImageBitmap( img );
}

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

GC gc_printer = new GC( printer );
gc_printer.dispose();

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

GC gc = new GC( cache_image );
 gc.dispose();
GC gc = new GC( image );
gc.dispose();
image.dispose();

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

GC gc = new GC( cache_image );
 gc.dispose();
GC gc = new GC( image );
gc.dispose();
image.dispose();

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

GC gc = new GC( text );
FontMetrics fm = gc.getFontMetrics();
int charWidth = fm.getAverageCharWidth();
int fieldWidth = text.computeSize( charWidth * 20, SWT.DEFAULT ).x;
gc.dispose();

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

Point getExtent() {
  GC gc = new GC(hoverShell);
  Point e = gc.textExtent(text);
  gc.dispose();
  e.x += hm * 2;
  e.y += hm * 2;
  return e;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

int getBandHeight () {
  if (font == null) return ExpandItem.CHEVRON_SIZE;
  GC gc = new GC (this);
  FontMetrics metrics = gc.getFontMetrics ();
  gc.dispose ();
  return Math.max (ExpandItem.CHEVRON_SIZE, metrics.getHeight ());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

int getBandHeight () {
  if (font == null) return ExpandItem.CHEVRON_SIZE;
  GC gc = new GC (this);
  FontMetrics metrics = gc.getFontMetrics ();
  gc.dispose ();
  return Math.max (ExpandItem.CHEVRON_SIZE, metrics.getHeight ());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

@Override
  public void run () {
    if (!active) return;
    GC gc = new GC(AnimatedProgress.this);
    paintStripes(gc);
    gc.dispose();
    display.timerExec (SLEEP, timer [0]);
  }
};

代码示例来源:origin: BiglySoftware/BiglyBT

public static int getFontHeightInPX(Font font) {
  GC gc = new GC(font.getDevice());
  try {
    gc.setFont(font);
    return gc.textExtent(Utils.GOOD_STRING).y;
  } finally {
    gc.dispose();
  }
}

相关文章

GC类方法