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


Java TextLayout.getText方法代码示例

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


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

示例1: drawInnerTag

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
protected void drawInnerTag(GC gc, TextLayout layout) {
	String displayStr = layout.getText();
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	Rectangle bounds = getBounds();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayStr.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}			
		if (gc != null) {
			Point p = layout.getLocation(start, false);
			int x = bounds.x + p.x + leftMargin;
			x += SEGMENT_LINE_SPACING;

			Point tagSize = tagRender.calculateTagSize(innerTagBean);
			int lineIdx = layout.getLineIndex(start);
			Rectangle r = layout.getLineBounds(lineIdx);
			int y = bounds.y + p.y + topMargin + r.height / 2 - tagSize.y /2;				
			tagRender.draw(gc, innerTagBean, x, y - layout.getAscent());
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:24,代码来源:XGridCellRenderer.java

示例2: configure

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
public static void configure(TextLayout textLayout) {
	String text = textLayout.getText();
	Document doc = new Document(text);
	ITokenScanner scanner = getRecipeScanner(doc);
	scanner.setRange(doc, 0, doc.getLength());
	IToken token;
	while ((token = scanner.nextToken()) != Token.EOF) {
		int offset = scanner.getTokenOffset();
		int length = scanner.getTokenLength();
		Object data = token.getData();
		if (data != null && data instanceof TextStyle) {
			TextStyle textStyle = (TextStyle) data;
			textLayout.setStyle(textStyle, offset, offset + length - 1);
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:17,代码来源:TagStyleConfigurator.java

示例3: configure

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
public static void configure(TextLayout textLayout) {
	String text = textLayout.getText();
	Document doc = new Document(text);
	ITokenScanner scanner = getRecipeScanner(doc);
	scanner.setRange(doc, 0, doc.getLength());
	IToken token;
	while ((token = scanner.nextToken()) != Token.EOF) {
		int offset = scanner.getTokenOffset();
		int length = scanner.getTokenLength();
		Object data = token.getData();
		if (data != null && data instanceof TextStyle) {
			TextStyle textStyle = (TextStyle) data;
			textLayout.setStyle(textStyle, offset, offset + length - 1);
		}
	}
	scanner = null;
	doc = null;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:19,代码来源:TagStyleConfigurator.java

示例4: appendNonprintingStyle

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
private void appendNonprintingStyle(TextLayout layout) {
	TextStyle style = new TextStyle(font, GUIHelper.getColor(new RGB(100, 100, 100)), null);
	String s = layout.getText();
	Matcher matcher = Constants.NONPRINTING_PATTERN.matcher(s);
	while (matcher.find()) {
		int start = matcher.start();
		int end = matcher.end();
		// style.metrics = new GlyphMetrics(10, 0, 1);
		layout.setStyle(style, start, end - 1);
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:12,代码来源:TextPainterWithPadding.java

示例5: parseSyntax

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
@Override
public void parseSyntax(TextLayout layout, int rowIndex, boolean selected, boolean highlighted )
{
	// Obtain the text to parse
	String text = layout.getText();
	// Do not process null or blank text
	if (text == null || text.length() == 0)
		return;
	// Default style
	
	if (selected)
	{
		layout.setStyle(m_scheme.getSelectedStyle(), 0, text.length());
		return;
	}
	else if (highlighted)
	{
		layout.setStyle(m_scheme.getHighlightedStyle(), 0, text.length());
		return;
	}
	else
	{
		layout.setStyle(m_scheme.getDefaultStyle(), 0, text.length());
	}

	// Create a source for the tokenizer with the text
	StringSource source = new StringSource(text);
	// Create the tokenizer using the current configuration
	StandardTokenizer tokenizer = new StandardTokenizer(m_properties);
	// Assign the source
	tokenizer.setSource(source);
	try
	{
		// For each token recognised in the text
		while (tokenizer.hasMoreToken())
		{
			Token token = tokenizer.nextToken();
			int type = token.getType();
			// This is the token text
			String word = tokenizer.currentImage();
			// When the image is null, we are processing EOL
			if (word == null)
				break;
			boolean isDocStringTag1 = (type == Token.SPECIAL_SEQUENCE && word.equals("\"\"\""));
			boolean isDocStringTag2 = (type == Token.SPECIAL_SEQUENCE && word.equals("'''"));
			boolean isDocString = false;
			if (m_currentCodeId != null)
			{
				ISyntaxAreas areas = m_syntaxAreas.get(m_currentCodeId);
				if (areas != null)
				{
					isDocString = areas.isInCommentBlock(rowIndex);
				}
			}
			// Find the applicable style, depending on the token type
			TextStyle toApply = null;
			if (isDocString || isDocStringTag1 || isDocStringTag2)
			{
				toApply = m_scheme.getStyle(TokenTypes.COMMENT);
			}
			else
			{
				toApply = getApplicableStyle(word, type);
			}
			// If no style is returned, continue to next token
			if (toApply == null)
				continue;
			// Get the applicable range (find token position)
			Range range = getApplicableRange(text, word, token);
			// Apply the style to the layout
			layout.setStyle(toApply, range.start, range.end);
		}
		// Close tokenizer
		tokenizer.close();
		tokenizer = null;
	}
	catch (TokenizerException e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:Spacecraft-Code,项目名称:SPELL,代码行数:82,代码来源:SyntaxParser.java


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