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


Java GC.stringExtent方法代码示例

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


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

示例1: drawString

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawString(GC gc, String str, float x, float y, float width, float height, int bgAlpha) {
	if (str == null)
		return;

	org.eclipse.swt.graphics.Point size = gc.stringExtent(str);
	int posX = Math.round(x + width / 2 - size.x / 2);
	int posY = Math.round(y + height / 2 - size.y / 2);

	if (bgAlpha >= 255) {
		gc.drawString(str, posX, posY);
	} else {
		gc.drawString(str, posX, posY, true);
		if (bgAlpha > 0) {
			gc.setAlpha(bgAlpha);
			gc.fillRectangle(posX, posY, size.x, size.y);
			gc.setAlpha(255);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:GraphUtils.java

示例2: drawTemporaryLabels

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * draw temporary labels for external nodes (and save their bounds for later)
 */
private List<Rectangle> drawTemporaryLabels(GC gc) {
	final List<Rectangle> nodesExternalBounds = new ArrayList<>();
	final Rectangle clip = GraphUtils.getClip(gc);
	float px = clip.x + clip.width;
	float py = clip.y + clip.height;
	for (String currNE : endNodesExternal) {
		final org.eclipse.swt.graphics.Point size = gc.stringExtent(currNE);
		py -= size.y + 4;
		final float rx = px - (size.x + 4);
		final Rectangle b = new Rectangle(rx, py, size.x, size.y);
		nodesExternalBounds.add(b);
		// TODO string extent will be computed twice :(
		GraphUtils.drawString(gc, currNE, b.x + b.width / 2, b.y + b.height / 2);
	}
	return nodesExternalBounds;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:Edge.java

示例3: drawLabel

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/** Draws the label between jumping control flow elements. */
void drawLabel(GC gc, Point p) {
	label = "";
	for (ControlFlowType cfType : cfTypes) {
		switch (cfType) {
		case Break:
		case Continue:
		case Return:
		case Throw:
		case LoopEnter:
		case LoopReenter:
		case LoopInfinite:
			if (!label.isEmpty())
				label += "|";
			label += cfType.name();
			break;
		default:
		}
	}

	org.eclipse.swt.graphics.Point size = gc.stringExtent(label);
	float x = p.x - size.x / 2;
	float y = p.y - size.y / 2;
	GraphUtils.drawString(gc, label, x, y);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:CFEdge.java

示例4: computeColumnWidths

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * Pre-compute column widths for the file tab.
 * These can and are over-ridden by user sizing.
 */
protected void computeColumnWidths(int format) {
	List headers = disks[0].getFileColumnHeaders(format);
	int[] headerWidths = new int[headers.size()];
	GC gc = new GC(shell);
	for (int i=0; i<headers.size(); i++) {
		FileColumnHeader header = (FileColumnHeader) headers.get(i);
		if (header.getTitle().length() >= header.getMaximumWidth()) {
			headerWidths[i] = gc.stringExtent(header.getTitle()).x + 
				2 * gc.stringExtent(textBundle.get("WidestCharacter")).x;  //$NON-NLS-1$
		} else {
			headerWidths[i] = gc.stringExtent(
					textBundle.get("WidestCharacter")).x  //$NON-NLS-1$
					* header.getMaximumWidth();
		}
	}
	gc.dispose();
	gc = null;
	columnWidths.put(new Integer(format), headerWidths);
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:24,代码来源:DiskExplorerTab.java

示例5: computeSizeOfTextAndImages

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private Point computeSizeOfTextAndImages() {
	int width = 0, height = 0;
	final boolean textISNotEmpty = getText() != null && !getText().equals("");

	if (textISNotEmpty) {
		final GC gc = new GC(this.parentBreadcrumb);
		gc.setFont(this.parentBreadcrumb.getFont());
		final Point extent = gc.stringExtent(getText());
		gc.dispose();
		width += extent.x;
		height = extent.y;
	}

	final Point imageSize = computeMaxWidthAndHeightForImages(getImage(),
			this.selectionImage, this.disabledImage);

	if (imageSize.x != -1) {
		width += imageSize.x;
		height = Math.max(imageSize.y, height);
		if (textISNotEmpty) {
			width += MARGIN * 2;
		}
	}
	width += MARGIN;
	return new Point(width, height);
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:27,代码来源:BreadcrumbItem.java

示例6: trim

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * Change size of receiving Node to its preferred size.
 */
public void trim(GC gc) {
	if (title != null) {
		final org.eclipse.swt.graphics.Point size = gc.stringExtent(title);
		this.width = size.x + BORDER * 2;
		this.height = size.y + BORDER * 2;
	} else {
		this.width = DEFAULT_WIDTH;
		this.height = DEFAULT_HEIGHT;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:Node.java

示例7: getCachedStringExtent

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private static synchronized Point getCachedStringExtent(GC gc, String text) {
  if (m_LastGCFromExtend != gc) {
    m_StringExtentCache.clear();
    m_LastGCFromExtend = gc;
  }
  Point p = m_StringExtentCache.get(text);
  if (p == null) {
    if (text == null)
      return new Point(0, 0);
    p = gc.stringExtent(text);
    m_StringExtentCache.put(text, p);
  }
  return new Point(p.x, p.y);
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:15,代码来源:SWTX.java

示例8: getOptimalWidth

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * Returns the optimal width of the given cell (used by column resizing)
 * 
 * @param col
 * @param row
 * @param content
 * @param fixed
 * @return int
 */
public int getOptimalWidth(GC gc, int col, int row, Object content,
    boolean fixed) {
  return gc.stringExtent(content.toString()).x + 8;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:14,代码来源:KTableCellRenderer.java


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