當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.getClientArea方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.Canvas.getClientArea方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.getClientArea方法的具體用法?Java Canvas.getClientArea怎麽用?Java Canvas.getClientArea使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.Canvas的用法示例。


在下文中一共展示了Canvas.getClientArea方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paintVerticalRuler

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
	// FIXME - not i18n safe!!
	String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
	if (disk.getBitmapLabels().length == 2) {
		label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
	}
	StringBuffer buf = new StringBuffer();
	for (int i=0; i<label.length(); i++) {
		if (i>0) buf.append("\n"); //$NON-NLS-1$
		buf.append(label.charAt(i));
	}
	label = buf.toString();
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();
	event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
	Point size = event.gc.textExtent(label);
	event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:22,代碼來源:DiskMapTab.java

示例2: paintBlockMap

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Paint a block map.
 */	
private void paintBlockMap(PaintEvent event) {
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();

	double blocks = disk.getBitmapLength();
	double width = area.width;
	double height = area.height;
	double factor = Math.sqrt(blocks / (width * height));
	int xdim = (int) (width * factor + 0.5);
	int ydim = (int) (height * factor + 0.5);
	if (xdim * ydim < blocks) {
		xdim++;
	}
	if (xdim * ydim < blocks) {
		ydim++;
	}
	
	paintDiskMap(xdim, ydim, event);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:23,代碼來源:DiskMapTab.java

示例3: calculateEditorTrim

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Calculates the proper trim. Includes scrollbars' sizes only if they're
 * visible.
 * 
 * @param canvas
 *            The canvas.
 * @since 3.6
 */
public static Rectangle calculateEditorTrim(Canvas canvas) {
	/*
	 * Workaround for Bug# 87712 Calculating the trim using the clientArea.
	 */
	Rectangle bounds = canvas.getBounds();
	Rectangle clientArea = canvas.getClientArea();
	Rectangle result = new Rectangle(0, 0, bounds.width - clientArea.width,
			bounds.height - clientArea.height);
	if (result.width != 0 || result.height != 0) {
		Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
		result.x = result.height == 0 ? 0 : trim.x;
		result.y = result.width == 0 ? 0 : trim.y;
	}
	return result;
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:24,代碼來源:RulerComposite.java

示例4: paintHorizontalRuler

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Handle paint requests for horizontal ruler.
 */
protected void paintHorizontalRuler(PaintEvent event) {
	// FIXME - not i18n safe!!
	String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();
	event.gc.drawLine(area.x, area.y + area.height/2, area.x + area.width, area.y + area.height/2);
	Point size = event.gc.textExtent(label);
	event.gc.drawString(label, area.x + area.width/2 - size.x, area.y + area.height/2 - size.y/2);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:13,代碼來源:DiskMapTab.java

示例5: paintDiskMap

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
/**
 * Paint a map with the given dimensions.
 */
private void paintDiskMap(int xdim, int ydim, PaintEvent event) {
	Canvas canvas = (Canvas) event.widget;
	Rectangle area = canvas.getClientArea();
	area.width-= 2;
	area.height-= 2;

	int[] ypos = new int[ydim + 1];
	for (int i=0; i<ydim; i++) {
		ypos[i] = (i * area.height) / ydim + 1;
	}
	ypos[ydim] = area.height;
	int[] xpos = new int[xdim + 1];
	for (int i=0; i<xdim; i++) {
		xpos[i] = (i * area.width) / xdim + 1;
	}
	xpos[xdim] = area.width;
	
	Image image = new Image(canvas.getDisplay(), area);
	GC gc = new GC(image);
	int x = 0;
	int y = 0;
	DiskUsage usage = disk.getDiskUsage();
	for (x=0; x<xdim && usage.hasNext(); x++) {
		for (y=0; y<ydim && usage.hasNext(); y++) {
			usage.next();
			boolean free = usage.isFree();
			Rectangle box = new Rectangle(xpos[x], ypos[y], 
					xpos[x+1]-xpos[x], ypos[y+1]-ypos[y]);
			drawBox(box, gc, free ? freeFill : usedFill, black, gray);
		}
	}
	event.gc.drawImage(image, 0, 0);
	gc.dispose();
	image.dispose();
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:39,代碼來源:DiskMapTab.java

示例6: calculateEditorTrim

import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private static Rectangle calculateEditorTrim(Canvas canvas) {
	/*
	 * Workaround for Bug# 87712 Calculating the trim using the clientArea.
	 */
	Rectangle bounds = canvas.getBounds();
	Rectangle clientArea = canvas.getClientArea();
	Rectangle result = new Rectangle(0, 0, bounds.width - clientArea.width, bounds.height - clientArea.height);
	if (result.width != 0 || result.height != 0) {
		Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
		result.x = result.height == 0 ? 0 : trim.x;
		result.y = result.width == 0 ? 0 : trim.y;
	}
	return result;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:15,代碼來源:JDRulerComposite.java


注:本文中的org.eclipse.swt.widgets.Canvas.getClientArea方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。