本文整理汇总了Java中org.eclipse.swt.graphics.GC.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Java GC.drawImage方法的具体用法?Java GC.drawImage怎么用?Java GC.drawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.GC
的用法示例。
在下文中一共展示了GC.drawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawShadowImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawShadowImage(GC gc, Image image, int x, int y,
int alpha) {
Display display = Display.getCurrent();
Point imageSize = new Point(image.getBounds().width,
image.getBounds().height);
//
ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24,
new PaletteData(255, 255, 255));
imgData.alpha = alpha;
Image img = new Image(display, imgData);
GC imgGC = new GC(img);
imgGC.drawImage(image, 0, 0);
gc.drawImage(img, x, y);
imgGC.dispose();
img.dispose();
}
示例2: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
if(showImage && meIcon != null){
Rectangle b = meIcon.getBounds();
int imageX = Math.max((width-b.width)/2, 1);
int imageY = Math.max((height-b.height)/2, 1);
g.drawImage(meIcon, imageX, imageY);
}
}
示例3: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
Rectangle bounds = cell.getBounds();
ImageLoader imageLoader = ImageLoader.getInstance();
Image viewImage = imageLoader.getImage("ic_view");
if(imageWidth == -1 || imageHeight == -1) {
imageWidth = viewImage.getBounds().width;
imageHeight = viewImage.getBounds().height;
}
bounds.width -= (imageWidth + 5);
GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds,true,false,SWT.LEFT);
Subscription sub = (Subscription) cell.getDataSource();
if ( sub != null && !sub.isSearchTemplate()){
gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
}
imageLoader.releaseImage("ic_view");
//gc.drawText(cell.getText(), bounds.x,bounds.y);
}
示例4: paint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
void paint(GC gc) {
if (fImage != null) {
Rectangle bounds = fImage.getBounds();
Rectangle clientArea = getClientArea();
int x;
if (bounds.width < clientArea.width)
x = (clientArea.width - bounds.width) / 2;
else
x = -getHorizontalBar().getSelection();
int y;
if (bounds.height < clientArea.height)
y = (clientArea.height - bounds.height) / 2;
else
y = -getVerticalBar().getSelection();
gc.drawImage(fImage, x, y);
}
}
示例5: resizeImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private Image resizeImage(Image image, int width, int height) {
Image scaled = new Image(Display.getDefault(), width, height);
GC gc = new GC(scaled);
gc.setAntialias(SWT.ON);
gc.setInterpolation(SWT.HIGH);
gc.drawImage(image, 0, 0,image.getBounds().width, image.getBounds().height, 0, 0, width, height);
gc.dispose();
image.dispose();
return scaled;
}
示例6: drawTransparentImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawTransparentImage(GC gc, Image image, int x, int y) {
if (image == null)
return;
Point imageSize = new Point(image.getBounds().width,
image.getBounds().height);
Image img = new Image(Display.getCurrent(), imageSize.x, imageSize.y);
GC gc2 = new GC(img);
gc2.setBackground(gc.getBackground());
gc2.fillRectangle(0, 0, imageSize.x, imageSize.y);
gc2.drawImage(image, 0, 0);
gc.drawImage(img, x, y);
gc2.dispose();
img.dispose();
}
示例7: paintControl
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
* Handle paint events.
*/
public void paintControl(PaintEvent event) {
GC gc = event.gc;
gc.drawImage (image, 0, 0);
Rectangle rect = image.getBounds ();
Rectangle client = getClientArea();
int marginWidth = client.width - rect.width;
if (marginWidth > 0) {
gc.fillRectangle (rect.width, 0, marginWidth, client.height);
}
int marginHeight = client.height - rect.height;
if (marginHeight > 0) {
gc.fillRectangle (0, rect.height, client.width, marginHeight);
}
}
示例8: resize
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private Image resize(Image image, int width, int height) {
Image scaled = new Image(display, width, height);
GC gc = new GC(scaled);
gc.setAntialias(SWT.ON);
gc.setInterpolation(SWT.HIGH);
gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height,
0, 0, width, height);
gc.dispose();
image.dispose();
return scaled;
}
示例9: draw
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private void draw(GC gc,float x,float y,float h,DHTControlContact contact,int distance,float error) {
if(x == 0 && y == 0) return;
if(error > 1) error = 1;
int errDisplay = (int) (100 * error);
int x0 = scale.getX(x,y);
int y0 = scale.getY(x,y);
Image img = ImageRepository.getCountryFlag( contact.getTransportContact().getTransportAddress().getAddress(), true );
if ( img != null ){
Rectangle bounds = img.getBounds();
int old = gc.getAlpha();
gc.setAlpha( 150 );
gc.drawImage( img, x0-bounds.width/2, y0-bounds.height);
gc.setAlpha( old );
}
gc.fillRectangle(x0-1,y0-1,3,3);
//int elevation =(int) ( 200*h/(scale.maxY-scale.minY));
//gc.drawLine(x0,y0,x0,y0-elevation);
//String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms \nerr:"+errDisplay+"%";
String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms "+errDisplay+"%";
int lineReturn = text.indexOf("\n");
int xOffset = gc.getFontMetrics().getAverageCharWidth() * (lineReturn != -1 ? lineReturn:text.length()) / 2;
gc.drawText(text,x0-xOffset,y0,true);
currentPositions.add( new Object[]{ x0, y0, h, contact, x, y, distance });
}
示例10: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
SBC_SearchResult entry = (SBC_SearchResult) cell.getDataSource();
Rectangle cellBounds = cell.getBounds();
Image img = entry.getIcon();
if (img != null && !img.isDisposed()) {
Rectangle imgBounds = img.getBounds();
if (cellBounds.width < imgBounds.width || cellBounds.height < imgBounds.height) {
float dx = (float) cellBounds.width / imgBounds.width;
float dy = (float) cellBounds.height / imgBounds.height;
float d = Math.min(dx, dy);
int newWidth = (int) (imgBounds.width * d);
int newHeight = (int) (imgBounds.height * d);
gc.drawImage(img, 0, 0, imgBounds.width, imgBounds.height,
cellBounds.x + (cellBounds.width - newWidth) / 2,
cellBounds.y + (cellBounds.height - newHeight) / 2, newWidth,
newHeight);
} else {
gc.drawImage(img, cellBounds.x
+ ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
+ ((cellBounds.height - imgBounds.height) / 2));
}
}
}
示例11: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
SBC_SubscriptionResult entry = (SBC_SubscriptionResult) cell.getDataSource();
Rectangle cellBounds = cell.getBounds();
Image img = entry== null || entry.getRead() ? imgOld: imgNew;
if (img != null && !img.isDisposed()) {
Rectangle imgBounds = img.getBounds();
gc.drawImage(img, cellBounds.x
+ ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
+ ((cellBounds.height - imgBounds.height) / 2));
}
}
示例12: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
Subscription sub = (Subscription) cell.getDataSource();
if (sub.getHistory().getNumUnread() > 0) {
Rectangle cellBounds = cell.getBounds();
gc.drawImage(imgNew, cellBounds.x
+ ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
+ ((cellBounds.height - imgBounds.height) / 2));
}
}
示例13: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, final TableCellSWT cell) {
ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
Image imgIcon;
String iconID = entry.getIconID();
if (iconID != null) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (iconID.startsWith("http")) {
imgIcon = imageLoader.getUrlImage(iconID,
new ImageDownloaderListener() {
@Override
public void imageDownloaded(Image image,
boolean returnedImmediately) {
if (returnedImmediately) {
return;
}
cell.invalidate();
}
});
if (imgIcon == null) {
return;
}
} else {
imgIcon = imageLoader.getImage(iconID);
}
if (ImageLoader.isRealImage(imgIcon)) {
Rectangle cellBounds = cell.getBounds();
Rectangle imgBounds = imgIcon.getBounds();
gc.drawImage(imgIcon, cellBounds.x
+ ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
+ ((cellBounds.height - imgBounds.height) / 2));
}
imageLoader.releaseImage(iconID);
}
}
示例14: cellPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
Rectangle cellBounds = cell.getBounds();
Image img = entry.getReadOn() <= 0 ? imgNew : imgOld;
if (img != null && !img.isDisposed()) {
Rectangle imgBounds = img.getBounds();
gc.drawImage(img, cellBounds.x
+ ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
+ ((cellBounds.height - imgBounds.height) / 2));
}
}
示例15: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
// draw button background
int selShift = 0;
if(mouseIsOver && !isSelected){
g.setBackground(this.meColorMouseOver);
}else{
g.setBackground(this.meColorUnselected);
}
if(isSelected){
selShift = MEB_SIDE_SPACE-1;
g.setBackground(this.meColorSelected);
}
g.fillRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
// draw button outline
g.setLineWidth(1);
if(mouseIsOver){ // || isFocused, but not currently used
g.setForeground(this.meColorFocused);
}else{
g.setForeground(this.meColorOutline2);
}
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1), height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-1, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-2, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.setForeground(this.meColorOutline);
g.setLineWidth(1);
g.drawRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
//
// handle position of Text/Icon within MEButton
//
int usableHeight = height-4;
// draw button text
g.setForeground(this.meColorForeground);
FontData fd = new FontData();
fd.setHeight(8);
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
switch(this.meDispOptions){
case(MenuetElement.ME_ICON_ONLY): {
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
break;
}
case(MenuetElement.ME_TEXT_ONLY): {
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
case(MenuetElement.ME_TRY_ICON): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
}
break;
}
case(MenuetElement.ME_TRY_TEXT): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
}
break;
}
default:{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
}
}