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

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

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

GC.drawImage介绍

[英]Draws the given image in the receiver at the specified coordinates.
[中]在指定坐标处绘制接收器中的给定图像。

代码示例

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

public void paintControl( PaintEvent event ) {
  if ( image != null ) {
   event.gc.drawImage( image, 0, 0 );
  }
 }
} );

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

public void paintControl( PaintEvent event ) {
  if ( image != null && !image.isDisposed() ) {
   event.gc.drawImage( image, 0, 0 );
  }
 }
} );

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

public void drawImage( String location, ClassLoader classLoader, int x, int y ) {
 Image img = SwtSvgImageUtil.getImage( PropsUI.getDisplay(), classLoader, location,
  Math.round( small_icon_size * currentMagnification ),
  Math.round( small_icon_size * currentMagnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, small_icon_size, small_icon_size );
 }
}

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

public void drawImage( String location, ClassLoader classLoader, int x, int y ) {
 Image img = SwtSvgImageUtil.getImage( PropsUI.getDisplay(), classLoader, location,
  Math.round( small_icon_size * currentMagnification ),
  Math.round( small_icon_size * currentMagnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, small_icon_size, small_icon_size );
 }
}

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

public void drawImage( EImage image, int x, int y, float magnification, double angle ) {
 Image img =
   getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( small_icon_size * magnification ),
     Math.round( small_icon_size * magnification ), angle );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  int hx = Math.round( bounds.width / magnification );
  int hy = Math.round( bounds.height / magnification );
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x - hx / 2, y - hy / 2, hx, hy );
 }
}

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

@Override
public void drawImage( EImage image, int x, int y, float magnification, double angle ) {
 Image img =
   getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( small_icon_size * magnification ),
     Math.round( small_icon_size * magnification ), angle );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  int hx = Math.round( bounds.width / magnification );
  int hy = Math.round( bounds.height / magnification );
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x - hx / 2, y - hy / 2, hx, hy );
 }
}

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

public void drawStepIcon( int x, int y, StepMeta stepMeta, float magnification ) {
 String steptype = stepMeta.getStepID();
 Image im =
   images.get( steptype ).getAsBitmapForSize( gc.getDevice(), Math.round( iconsize * magnification ),
     Math.round( iconsize * magnification ) );
 if ( im != null ) { // Draw the icon!
  org.eclipse.swt.graphics.Rectangle bounds = im.getBounds();
  gc.drawImage( im, 0, 0, bounds.width, bounds.height, x, y, iconsize, iconsize );
 }
}

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

public void drawImage( EImage image, int x, int y, int width, int height, float magnification ) {
 Image img = getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( width * magnification ),
   Math.round( height * magnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, width, height );
 }
}

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

public void drawImage( EImage image, int x, int y, int width, int height, float magnification ) {
 Image img =
   getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( width * magnification ),
     Math.round( height * magnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, width, height );
 }
}

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

public void drawImage( EImage image, int x, int y, float magnification ) {
 Image img = getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( small_icon_size * magnification ),
   Math.round( small_icon_size * magnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, small_icon_size, small_icon_size );
 }
}

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

public void drawImage( EImage image, int x, int y, float magnification ) {
 Image img =
   getNativeImage( image ).getAsBitmapForSize( gc.getDevice(), Math.round( small_icon_size * magnification ),
     Math.round( small_icon_size * magnification ) );
 if ( img != null ) {
  Rectangle bounds = img.getBounds();
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x, y, small_icon_size, small_icon_size );
 }
}

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

@Override
 public void drawImage( BufferedImage image, int x, int y ) {
  ImageData imageData = ImageUtil.convertToSWT( image );
  Image swtImage = new Image( gc.getDevice(), imageData );
  gc.drawImage( swtImage, x, y );
  swtImage.dispose();
 }
}

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

@Override
 public void drawImage( BufferedImage image, int x, int y ) {
  ImageData imageData = ImageUtil.convertToSWT( image );
  Image swtImage = new Image( gc.getDevice(), imageData );
  gc.drawImage( swtImage, x, y );
  swtImage.dispose();
 }
}

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

public void drawStepIcon( int x, int y, StepMeta stepMeta, float magnification ) {
 String steptype = stepMeta.getStepID();
 Image im = null;
 if ( stepMeta.isMissing() ) {
  im = GUIResource.getInstance().getImageMissing();
 } else if ( stepMeta.isDeprecated() ) {
  im = GUIResource.getInstance().getImageDeprecated();
 } else {
  im =
    images.get( steptype ).getAsBitmapForSize( gc.getDevice(), Math.round( iconsize * magnification ),
      Math.round( iconsize * magnification ) );
 }
 if ( im != null ) { // Draw the icon!
  org.eclipse.swt.graphics.Rectangle bounds = im.getBounds();
  gc.drawImage( im, 0, 0, bounds.width, bounds.height, x, y, iconsize, iconsize );
 }
}

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

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getTransformationImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( transMeta.nrSteps() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageTransCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
 // spoon.setShellText();
}

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

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getJobImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( jobMeta.nrJobEntries() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setBackground( GUIResource.getInstance().getColorBackground() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageJobCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
}

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

相关文章

GC类方法