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


Java TextLayout.setOrientation方法代码示例

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


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

示例1: getTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
public TextLayout getTextLayout(GC gc, GridItem item, int columnIndex, boolean innerTagStyled, boolean drawInnerTag) {
	TextLayout layout = new TextLayout(gc.getDevice());
	layout.setFont(font);
	layout.setTabs(new int[]{tabWidth});
	innerTagFactory.reset();
	
	String displayStr = "";
	try{
		displayStr = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag(item.getText(columnIndex)));
	}catch (NullPointerException e) {
		return null;
	}
	layout.setText(displayStr);
	int width = getBounds().width - leftMargin - rightMargin;
	layout.setWidth(width < 1 ? 1 : width);
	layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
	layout.setAlignment(SWT.LEFT);
	layout.setOrientation(item.getParent().getOrientation());
	if (displayStr.length() != 0 && innerTagStyled) {
		attachInnertTagStyle(gc, layout, drawInnerTag);
	}
	return layout;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:24,代码来源:XGridCellRenderer.java

示例2: 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

示例3: getCellTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
private TextLayout getCellTextLayout(LayerCell cell) {
	int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
	TextLayout layout = new TextLayout(editor.getTable().getDisplay());
	layout.setOrientation(orientation);
	layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
	layout.setFont(font);
	layout.setAscent(ascent);
	layout.setDescent(descent); // 和 StyledTextEditor 同步
	layout.setTabs(new int[] { tabWidth });

	Rectangle rectangle = cell.getBounds();
	int width = rectangle.width - leftPadding - rightPadding;
	width -= 1;
	if (wrapText && width > 0) {
		layout.setWidth(width);
	}

	String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue()));
	if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
		displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
		displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
		displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
	}
	layout.setText(displayText);
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayText.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}
		TextStyle style = new TextStyle();
		Point rect = tagRender.calculateTagSize(innerTagBean);
		style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
		layout.setStyle(style, start, start + placeHolder.length() - 1);
	}

	return layout;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:40,代码来源:TextPainterWithPadding.java

示例4: paintText

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
protected void paintText(Graphics g, String draw, int x, int y,
		int bidiLevel) {
	if (bidiLevel == -1) {
		g.drawText(draw, x, y);
	} else {
		TextLayout tl = FlowUtilities.getTextLayout();
		if (isMirrored())
			tl.setOrientation(SWT.RIGHT_TO_LEFT);
		tl.setFont(g.getFont());
		tl.setText(draw);
		g.drawTextLayout(tl, x, y);
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:14,代码来源:TextFlow.java

示例5: getCellTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
private TextLayout getCellTextLayout(LayerCell cell) {
	int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
	TextLayout layout = new TextLayout(editor.getTable().getDisplay());
	layout.setOrientation(orientation);
	layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
	layout.setFont(font);
	layout.setAscent(ascent);
	layout.setDescent(descent); // 和 StyledTextEditor 同步
	layout.setTabs(new int[] { tabWidth });

	Rectangle rectangle = cell.getBounds();
	int width = rectangle.width - leftPadding - rightPadding;
	width -= 1;
	if (wrapText && width > 0) {
		layout.setWidth(width);
	}

	String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue()));
	if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
		displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
		displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "");
		displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "");
	}
	layout.setText(displayText);
	List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
	for (InnerTagBean innerTagBean : innerTagBeans) {
		String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
		int start = displayText.indexOf(placeHolder);
		if (start == -1) {
			continue;
		}
		TextStyle style = new TextStyle();
		Point rect = tagRender.calculateTagSize(innerTagBean);
		style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
		layout.setStyle(style, start, start + placeHolder.length() - 1);
	}

	return layout;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:40,代码来源:TextPainterWithPadding.java

示例6: zoomTextLayout

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
private TextLayout zoomTextLayout(TextLayout layout) {
	TextLayout zoomed = new TextLayout(Display.getCurrent());
	zoomed.setText(layout.getText());

	int zoomWidth = -1;

	if (layout.getWidth() != -1)
		zoomWidth = ((int) (layout.getWidth() * zoom));

	if (zoomWidth < -1 || zoomWidth == 0)
		return null;

	zoomed.setFont(zoomFont(layout.getFont()));
	zoomed.setAlignment(layout.getAlignment());
	zoomed.setAscent(layout.getAscent());
	zoomed.setDescent(layout.getDescent());
	zoomed.setOrientation(layout.getOrientation());
	zoomed.setSegments(layout.getSegments());
	zoomed.setSpacing(layout.getSpacing());
	zoomed.setTabs(layout.getTabs());

	zoomed.setWidth(zoomWidth);
	int length = layout.getText().length();
	if (length > 0) {
		int start = 0, offset = 1;
		TextStyle style = null, lastStyle = layout.getStyle(0);
		for (; offset <= length; offset++) {
			if (offset != length
					&& (style = layout.getStyle(offset)) == lastStyle)
				continue;
			int end = offset - 1;

			if (lastStyle != null) {
				TextStyle zoomedStyle = new TextStyle(
						zoomFont(lastStyle.font), lastStyle.foreground,
						lastStyle.background);
				zoomedStyle.metrics = lastStyle.metrics;
				zoomedStyle.rise = lastStyle.rise;
				zoomedStyle.strikeout = lastStyle.strikeout;
				zoomedStyle.underline = lastStyle.underline;
				zoomed.setStyle(zoomedStyle, start, end);
			}
			lastStyle = style;
			start = offset;
		}
	}
	return zoomed;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:49,代码来源:ScaledGraphics.java

示例7: process

import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
 * Processes the contributed text, determines the Bidi levels, and assigns
 * them to the FlowFigures that made thet contributions. This class is for
 * INTERNAL use only. Shaping of visually contiguous Arabic characters that
 * are split in different figures is also handled. This method will do
 * nothing if the contributed text does not require Bidi evaluation. All
 * contributions are discarded at the end of this method.
 */
public void process() {
	try {
		if (bidiText.length() == 0)
			return;
		char[] chars = new char[bidiText.length()];
		bidiText.getChars(0, bidiText.length(), chars, 0);

		// TODO: GEFGWT commented out
		// if (orientation != SWT.RIGHT_TO_LEFT
		// && !Bidi.requiresBidi(chars, 0, chars.length - 1))
		// return;
		// GEFGWT commented out

		int[] levels = new int[15];
		TextLayout layout = FlowUtilities.getTextLayout();

		layout.setOrientation(orientation);
		layout.setText(bidiText.toString());
		int j = 0, offset, prevLevel = -1;
		for (offset = 0; offset < chars.length; offset++) {
			int newLevel = layout.getLevel(offset);
			if (newLevel != prevLevel) {
				if (j + 3 > levels.length) {
					int temp[] = levels;
					levels = new int[levels.length * 2 + 1];
					System.arraycopy(temp, 0, levels, 0, temp.length);
				}
				levels[j++] = offset;
				levels[j++] = newLevel;
				prevLevel = newLevel;
			}
		}
		levels[j++] = offset;

		if (j != levels.length) {
			int[] newLevels = new int[j];
			System.arraycopy(levels, 0, newLevels, 0, j);
			levels = newLevels;
		}
		assignResults(levels);

		// reset the orientation of the layout, in case it was set to RTL
		layout.setOrientation(SWT.LEFT_TO_RIGHT);
	} finally {
		// will cause the fields to be reset for the next string to be
		// processed
		bidiText = null;
		list.clear();
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:59,代码来源:BidiProcessor.java


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