本文整理汇总了Java中org.eclipse.swt.graphics.TextLayout.setTabs方法的典型用法代码示例。如果您正苦于以下问题:Java TextLayout.setTabs方法的具体用法?Java TextLayout.setTabs怎么用?Java TextLayout.setTabs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.TextLayout
的用法示例。
在下文中一共展示了TextLayout.setTabs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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("");
}
示例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$
}
示例3: 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;
}
示例4: 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;
}
示例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;
}
示例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;
}