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


Java TextLayout.getBounds方法代码示例

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


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

示例1: createTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
	fTextLayout= new TextLayout(fBrowser.getDisplay());
	
	// Initialize fonts
	String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
	Font font = JFaceResources.getFont(symbolicFontName);
	fTextLayout.setFont(font);
	fTextLayout.setWidth(-1);
	font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
	fBoldStyle = new TextStyle(font, null, null);
	
	// Compute and set tab width
	fTextLayout.setText("    ");
	int tabWidth = fTextLayout.getBounds().width;
	fTextLayout.setTabs(new int[] {tabWidth});
	
	fTextLayout.setText("");
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:26,代码来源:DwprofileBrowserInformationControl.java

示例2: createTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * Creates and initializes the text layout used to compute the size hint.
 * 
 * @since 3.2
 */
private void createTextLayout()
{
	fTextLayout = new TextLayout(fBrowser.getDisplay());

	// Initialize fonts
	String symbolicFontName = fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
	Font font = JFaceResources.getFont(symbolicFontName);
	fTextLayout.setFont(font);
	fTextLayout.setWidth(-1);
	font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
	fBoldStyle = new TextStyle(font, null, null);

	// Compute and set tab width
	fTextLayout.setText("    "); //$NON-NLS-1$
	int tabWidth = fTextLayout.getBounds().width;
	fTextLayout.setTabs(new int[] { tabWidth });
	fTextLayout.setText(""); //$NON-NLS-1$
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:CustomBrowserInformationControl.java

示例3: drawBlankString

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
protected void drawBlankString( Graphics g, String s )
{
	TextLayout tl = new TextLayout( Display.getCurrent( ) );

	// bidi_hcg: Apply text direction
	tl.setOrientation( this.rtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT );
	
	tl.setText( s );
	Rectangle rc = tl.getBounds( );

	int left = ( getClientArea( ).width - rc.width ) / 2;
	int top = ( getClientArea( ).height - rc.height ) / 2;

	g.drawText( s, getClientArea( ).x + left, getClientArea( ).y + top );
	tl.dispose();
}
 
开发者ID:eclipse,项目名称:birt,代码行数:17,代码来源:CellFigure.java

示例4: setFont

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * 设置字体
 * @param font
 *            ;
 */
public void setFont(Font font) {
	TextLayout layout = new TextLayout(Display.getDefault());
	layout.setFont(font);
	StringBuffer tabBuffer = new StringBuffer(tabSize);
	for (int i = 0; i < tabSize; i++) {
		tabBuffer.append(' ');
	}
	layout.setText(tabBuffer.toString());
	tabWidth = layout.getBounds().width;
	layout.dispose();
	this.font = font;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:XGridCellRenderer.java

示例5: getTextLayoutBounds

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * @see TextLayout#getBounds()
 */
protected Rectangle getTextLayoutBounds(String s, Font f, int start, int end) {
	TextLayout textLayout = getTextLayout();
	textLayout.setFont(f);
	textLayout.setText(s);
	return textLayout.getBounds(start, end);
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:10,代码来源:FlowUtilities.java

示例6: addLeadingWordWidth

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * Calculates the width taken up by the given text before a line-break is
 * encountered.
 * 
 * @param text
 *            the text in which the break is to be found
 * @param width
 *            the width before the next line-break (if one's found; the
 *            width of all the given text, otherwise) will be added on to
 *            the first int in the given array
 * @return <code>true</code> if a line-break was found
 * @since 3.1
 */
boolean addLeadingWordWidth(String text, int[] width) {
	if (text.length() == 0)
		return false;
	// if (Character.isWhitespace(text.charAt(0)))
	// return true;

	text = 'a' + text + 'a';
	// TODO: GEFGWT commented out
	// FlowUtilities.LINE_BREAK.setText(text);
	// int index = FlowUtilities.LINE_BREAK.next() - 1;
	int index = 0;
	// GEFGWT commented out

	if (index == 0)
		return true;
	// while (Character.isWhitespace(text.charAt(index)))
	// index--;
	// boolean result = index < text.length() - 1;
	// index should point to the end of the actual text (not including the
	// 'a' that was
	// appended), if there were no breaks
	if (index == text.length() - 1)
		index--;
	text = text.substring(1, index + 1);

	if (bidiInfo == null)
		width[0] += getTextUtilities().getTextExtents(text, getFont()).width;
	else {
		TextLayout textLayout = FlowUtilities.getTextLayout();
		textLayout.setFont(getFont());
		textLayout.setText(text);
		width[0] += textLayout.getBounds().width;
	}
	return true;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:49,代码来源:TextFlow.java

示例7: updateTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * @param layout
 * @param cell
 * @param applyColors
 * @return the text width delta (0 if the text layout contains no other font)
 */
private int updateTextLayout(TextLayout layout, ViewerCell cell,
		boolean applyColors) {
	layout.setStyle(null, 0, Integer.MAX_VALUE); // clear old styles

	layout.setText(cell.getText());
	layout.setFont(cell.getFont()); // set also if null to clear previous usages
	
	int originalTextWidth = layout.getBounds().width; // text width without any styles
	boolean containsOtherFont= false;
	
	StyleRange[] styleRanges = cell.getStyleRanges();
	if (styleRanges != null) { // user didn't fill styled ranges
		for (int i = 0; i < styleRanges.length; i++) {
			StyleRange curr = prepareStyleRange(styleRanges[i], applyColors);
			layout.setStyle(curr, curr.start, curr.start + curr.length - 1);
			if (curr.font != null) {
				containsOtherFont= true;
			}
		}
	}
	int textWidthDelta = 0;
	if (containsOtherFont) {
		textWidthDelta = layout.getBounds().width - originalTextWidth;
	}
	return textWidthDelta;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:33,代码来源:StyledCellLabelProvider.java

示例8: getPreferredHeight

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
@Override
public int getPreferredHeight(LayerCell cell, GC gc, IConfigRegistry configRegistry) {
	TextLayout layout = getCellTextLayout(cell);
	int contentHeight = layout.getBounds().height;
	layout.dispose();
	contentHeight += topPadding;
	contentHeight += bottomPadding;
	contentHeight += 4;// 加上编辑模式下,StyledTextCellEditor的边框
	return contentHeight;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:11,代码来源:AttributePainter.java

示例9: getPreferredHeight

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
@Override
public int getPreferredHeight(LayerCell cell, GC gc, IConfigRegistry configRegistry) {
	TextLayout layout = getCellTextLayout(cell);
	int contentHeight = layout.getBounds().height;
	layout.dispose();
	tuv = null;
	contentHeight += topPadding;
	contentHeight += bottomPadding;
	contentHeight += 4;// 加上编辑模式下,StyledTextCellEditor的边框
	return contentHeight;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:12,代码来源:TmxEditorTextPainter.java


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