當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。