当前位置: 首页>>代码示例>>Java>>正文


Java Image.getBounds方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.Image.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Image.getBounds方法的具体用法?Java Image.getBounds怎么用?Java Image.getBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.Image的用法示例。


在下文中一共展示了Image.getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawShadowImage

import org.eclipse.swt.graphics.Image; //导入方法依赖的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();
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:17,代码来源:SWTX.java

示例2: drawButtonAtPosition

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
void drawButtonAtPosition(final int x) {

		if (this.selection) {
			drawBackgroundAtPosition(x);
		}
		if (!this.isLastItemOfTheBreadCrumb) {
			drawTrianglesAtPosition(x);
		}

		int xPosition = computeGap();
		final Image drawnedImage = drawImageAtPosition(x + xPosition);
		if (drawnedImage != null) {
			xPosition += drawnedImage.getBounds().width + 2 * MARGIN;
		}
		drawTextAtPosition(x + xPosition);

		this.bounds = new Rectangle(x, 0, getWidth(), this.toolbarHeight);
	}
 
开发者ID:sergueik,项目名称:SWET,代码行数:19,代码来源:BreadcrumbItem.java

示例3: drawImageAtPosition

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
private Image drawImageAtPosition(final int xPosition) {
	Image image;
	if (!isEnabled()) {
		image = this.disabledImage;
	} else if (this.selection) {
		image = this.selectionImage;
	} else {
		image = getImage();
	}

	if (image == null) {
		return null;
	}

	final int yPosition = (this.toolbarHeight - image.getBounds().height) / 2;
	this.gc.drawImage(image, (int) (xPosition + MARGIN * 1.5), yPosition);
	return image;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:19,代码来源:BreadcrumbItem.java

示例4: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的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);
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:27,代码来源:ColumnSubscriptionName.java

示例5: drawTransparentImage

import org.eclipse.swt.graphics.Image; //导入方法依赖的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();
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:15,代码来源:SWTX.java

示例6: drawImageVerticalAlign

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
public static void drawImageVerticalAlign(GC gc, Image image,
      int imageAlign, int x, int y, int h) {
    if (image == null)
      return;
    Point imageSize = new Point(image.getBounds().width,
        image.getBounds().height);
    //
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_TOP) {
  drawTransparentImage(gc, image, x, y);
  gc.fillRectangle(x, y + imageSize.y, imageSize.x, h - imageSize.y);
  return;
}
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_BOTTOM) {
  drawTransparentImage(gc, image, x, y + h - imageSize.y);
  gc.fillRectangle(x, y, imageSize.x, h - imageSize.y);
  return;
}
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_CENTER) {
  int yOffset = (h - imageSize.y) / 2;
  drawTransparentImage(gc, image, x, y + yOffset);
  gc.fillRectangle(x, y, imageSize.x, yOffset);
  gc.fillRectangle(x, y + yOffset + imageSize.y, imageSize.x, h
      - (yOffset + imageSize.y));
  return;
}
throw new SWTException(
    "H: "
            + (imageAlign & ALIGN_VERTICAL_MASK));
  }
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:30,代码来源:SWTX.java

示例7: computeMaxWidthAndHeightForImages

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
private Point computeMaxWidthAndHeightForImages(final Image... images) {
	final Point imageSize = new Point(-1, -1);
	for (final Image image : images) {
		if (image == null) {
			continue;
		}
		final Rectangle imageBounds = image.getBounds();
		imageSize.x = Math.max(imageBounds.width, imageSize.x);
		imageSize.y = Math.max(imageBounds.height, imageSize.y);
	}
	return imageSize;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:13,代码来源:BreadcrumbItem.java

示例8: draw

import org.eclipse.swt.graphics.Image; //导入方法依赖的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 });
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:31,代码来源:VivaldiPanel.java

示例9: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的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));
		}
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:29,代码来源:ColumnSearchResultSite.java

示例10: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的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));
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:15,代码来源:ColumnSubResultNew.java

示例11: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的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);
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:38,代码来源:ColumnActivityType.java

示例12: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的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));
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:15,代码来源:ColumnActivityNew.java

示例13: cellPaint

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
	SearchSubsResultBase entry = (SearchSubsResultBase) cell.getDataSource();

	Rectangle cellBounds = cell.getBounds();
	Image img;
	if ( entry == null ){
		img = imgOther;
	}else{
		int ct = entry.getContentType();
		switch( ct ){
			case 0:{
				img = imgOther;
				break;
			}
			case 1:{
				img = imgVideo;
				break;
			}
			case 2:{
				img = imgAudio;
				break;
			}
			case 3:{
				img = imgGame;
				break;
			}
			default:{
				img = imgOther;
				break;
			}
		}
	}

	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));
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:42,代码来源:ColumnSearchSubResultType.java

示例14: BookTable

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
public BookTable(Composite c) {
    super(c, BookTableColumn.values());
    init();
    setPackMode(PackMode.packNever);
    addSelectAllListener();
    populate();
    BookNotifier.getInstance().addListener(this);

    table.setMenu(AppMenu.instance.getBookTableMenu());

    hasMP3 = PaintShop.getImage("images/green.gif");
    hasAAX = PaintShop.getImage("images/audible.png");
    hasNothing = PaintShop.getImage("images/white.png");
    final Rectangle rect = new Rectangle(0, 0, 12, 12);
    table.getColumn(0).setImage(hasAAX);
    table.getColumn(0).setText("");

    final Listener paintListener = event -> {
        final Image image = hasMP3;

        switch (event.type) {
            case SWT.MeasureItem: {
                event.width += rect.width;
                event.height = Math.max(event.height, rect.height + 2);
                break;
            }
            case SWT.PaintItem: {
                int x = event.x + event.width;
                Rectangle rect1 = image.getBounds();
                int offset = Math.max(0, (event.height - rect1.height) / 2);
                event.gc.drawImage(image, x, event.y + offset);
                break;
            }
        }
    };
    if (false) {
        table.addListener(SWT.MeasureItem, paintListener);
        table.addListener(SWT.PaintItem, paintListener);
    }

}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:42,代码来源:BookTable.java

示例15: OverlayImageDescriptor

import org.eclipse.swt.graphics.Image; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param image
 *            the base {@link Image}
 * @param overlay
 *            the overlay {@link Image}
 */
public OverlayImageDescriptor(Image image, Image overlay) {
	this.image = image;
	final Rectangle bounds = image.getBounds();
	this.size = new Point(bounds.width, bounds.height);
	this.overlay = overlay;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:15,代码来源:OverlayImageDescriptor.java


注:本文中的org.eclipse.swt.graphics.Image.getBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。