本文整理汇总了Java中org.eclipse.swt.graphics.TextStyle类的典型用法代码示例。如果您正苦于以下问题:Java TextStyle类的具体用法?Java TextStyle怎么用?Java TextStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextStyle类属于org.eclipse.swt.graphics包,在下文中一共展示了TextStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PluginsSWT
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
public PluginsSWT(Shell shell, List<String> lines) {
super(shell);
this.pluginsBean = new PluginsBean(lines);
target = pluginsBean.getPlugins();
source = Stream.of(Plugin.values())
.filter(p -> ! target.contains(p))
.collect(Collectors.toList());
targetOriginal = target.stream().collect(Collectors.toList());
rowColorTitle = new Color(display, 70, 130, 180);
int color = myOS == OS.Mac ? 249 : 239;
rowColorBack = new Color(display, color, color, color);
rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
fontAwesome = loadCustomFont(getFontAwesomeSize());
fontGap = new Font(display, fontName, 4, SWT.NORMAL);
rowTitleFont = new Font(display, fontName, getTopFontSize(), SWT.BOLD);
rowTextFont = new Font(display, fontName, getTopFontSize() - 2, SWT.NORMAL);
styleTitle = new TextStyle(rowTitleFont, rowColorTitle, null);
styleGap = new TextStyle(fontGap, display.getSystemColor(SWT.COLOR_BLACK), null);
styleRow = new TextStyle(rowTextFont, display.getSystemColor(SWT.COLOR_BLACK), null);
styleTitleSelected = new TextStyle(rowTitleFont, rowColorSelection, null);
styleRowSelected = new TextStyle(rowTextFont, rowColorSelection, null);
}
示例2: createTextLayout
import org.eclipse.swt.graphics.TextStyle; //导入依赖的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("");
}
示例3: setFont
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
/***************************************************************************
* Set the font to use
*
* @param font
**************************************************************************/
@Override
public void setFont(Font font)
{
String face = font.getFontData()[0].getName();
int size = font.getFontData()[0].getHeight();
int style = font.getFontData()[0].getStyle() | SWT.NORMAL;
FontData newData = new FontData(face, size, style);
Font newFont = new Font(Display.getDefault(), newData);
if (m_codeFont != null)
{
m_codeFont.dispose();
}
m_codeFont = newFont;
m_defaultStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_BLACK), null);
m_selectedStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_WHITE), null);
m_highlightedStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_BLACK), null);
}
示例4: createTextLayout
import org.eclipse.swt.graphics.TextStyle; //导入依赖的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$
}
示例5: highlightedTerms
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
public void highlightedTerms(List<String> terms) {
if (!isValid()) {
return;
}
StyledText styledText = cellEditor.viewer.getTextWidget();
String text = styledText.getText();
char[] source = text.toCharArray();
List<StyleRange> ranges = new ArrayList<StyleRange>();
TextStyle style = new TextStyle(cellEditor.getSegmentViewer().getTextWidget().getFont(), null,
ColorConfigBean.getInstance().getHighlightedTermColor());
for (String term : terms) {
if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
term = term.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
term = term.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
term = term.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
}
ranges.addAll(calculateTermsStyleRange(source, term.toCharArray(), style));
}
for (StyleRange range : ranges) {
styledText.setStyleRange(range);
}
}
示例6: configure
import org.eclipse.swt.graphics.TextStyle; //导入依赖的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);
}
}
}
示例7: configure
import org.eclipse.swt.graphics.TextStyle; //导入依赖的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;
}
示例8: ConcordanceSearchDialog
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
/**
* 构造方法
* @param parentShell
* @param file
* 当前文件
* @param strSrcLang
* 当前文件的源语言
* @param strTgtLang
* 当前文件的目标语言
* @param strSearchText
* 搜索文本
*/
public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang,
String strSearchText) {
super(parentShell);
FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
fontData.setStyle(fontData.getStyle() | SWT.BOLD);
font = new Font(Display.getDefault(), fontData);
style = new TextStyle(font, null, null);
this.strSrcLang = strSrcLang;
this.strTgtLang = strTgtLang;
this.strSearchText = strSearchText;
ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
lstDatabase = projectConfig.getAllTmDbs();
filterUnAvaliableDatabase();
setHelpAvailable(true);
setBlockOnOpen(false);
lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1);
lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1);
if (!Util.isLinux()) {
totalWidth = 910;
}
}
示例9: getStyledText
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
if(element instanceof IExplorerNode){
IExplorerNode node = (IExplorerNode)element;
return new StyledString(node.getName(), new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.foreground = ColorResources.COLOR_CS_BLUE_DARK;
}
});
}
return null;
}
示例10: highlightedTerms
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
public void highlightedTerms(List<String> terms) {
if (!isValid()) {
return;
}
StyledText styledText = cellEditor.viewer.getTextWidget();
String text = styledText.getText();
char[] source = text.toCharArray();
List<StyleRange> ranges = new ArrayList<StyleRange>();
TextStyle style = new TextStyle(cellEditor.getSegmentViewer().getTextWidget().getFont(), null,
ColorConfigBean.getInstance().getHighlightedTermColor());
for (String term : terms) {
ranges.addAll(calculateTermsStyleRange(source, term.toCharArray(), style));
}
for (StyleRange range : ranges) {
styledText.setStyleRange(range);
}
}
示例11: BlockControlImage
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
public BlockControlImage ( final ControlImage controlImage, final int style, final RegistrationManager registrationManager )
{
super ( controlImage.getClientSpace (), style );
this.controlImage = controlImage;
this.registrationManager = registrationManager;
setLayout ( new FillLayout () );
this.icon = new Label ( this, SWT.NONE );
this.icon.setImage ( getEmptyImage () );
this.icon.addMouseListener ( new MouseAdapter () {
@Override
public void mouseUp ( final MouseEvent e )
{
toggleBlock ();
}
} );
this.registrationManager.addListener ( this );
final LocalResourceManager resources = new LocalResourceManager ( JFaceResources.getResources (), this.icon );
this.boldFont = resources.createFont ( JFaceResources.getDefaultFontDescriptor ().withStyle ( SWT.BOLD ) );
this.boldStyler = new Styler () {
@Override
public void applyStyles ( final TextStyle textStyle )
{
textStyle.font = BlockControlImage.this.boldFont;
}
};
}
示例12: provideTreeCellLabelDecorations
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
private void provideTreeCellLabelDecorations(ViewerCell cell) {
TreeElement el = (TreeElement) cell.getElement();
List<StyleRange> styles = new ArrayList<>();
Image icon = Activator.getDbObjImage(el.getType());
String name = el.getName();
if(btnDebugView.getSelection()) {
cell.setText(String.format("%s:%s:%s", //$NON-NLS-1$
el.getType(), name, el.getSide()));
} else {
StringBuilder label = new StringBuilder(name);
if(el.getType() == DbObjType.DATABASE
|| el.getType() == DbObjType.SCHEMA
|| el.getType() == DbObjType.TABLE) {
label.append(" (") //$NON-NLS-1$
.append(el.countChildren())
.append(") [") //$NON-NLS-1$
.append(el.countDescendants())
.append(']');
TextStyle styleGray = new TextStyle();
styleGray.foreground = getDisplay().getSystemColor(
SWT.COLOR_GRAY);
StyleRange styleCount = new StyleRange(styleGray);
styleCount.start = name.length();
styleCount.length = label.length() - name.length();
styles.add(styleCount);
}
cell.setText(label.toString());
}
cell.setStyleRanges(styles.toArray(new StyleRange[styles.size()]));
cell.setImage(icon);
}
示例13: getStylesFromProperties
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
/**
* �������ļ���ԭ������ʽ��text
*
* @param p����������ʽ�������ļ�
* @param text
* ҪӦ��������ʽ��StyledText���
*/
public void getStylesFromProperties(Properties p, StyledText text) {
String start, length, font, fontstyle, strikeout, underline, fontheight;
for (int i = 0; i > -1; i++) {
start = p.getProperty(i + "start");
if (start != null) {
length = p.getProperty(i + "length");
font = p.getProperty(i + "font");
fontheight = p.getProperty(i + "fontheight");
fontstyle = p.getProperty(i + "fontstyle");
strikeout = p.getProperty(i + "strikeout");
underline = p.getProperty(i + "underline");
if (Integer.valueOf(fontheight) >= 0) {
Font f = SWTResourceManager.getFont(font, b.getZoomedFontSize(Integer.valueOf(fontheight)),
Integer.valueOf(fontstyle));
TextStyle ts = new TextStyle(f, null, null);
ts.strikeout = Boolean.valueOf(strikeout);
ts.underline = Boolean.valueOf(underline);
StyleRange sr = new StyleRange(ts);
sr.start = Integer.valueOf(start);
sr.length = Integer.valueOf(length);
if (sr.start >= 0 && sr.length + sr.start <= text.getCharCount())
text.setStyleRange(sr);
} else
getMessageBox("��ȡ�ļ�ʱ����", "black�ļ��е���ʽ��������������߶Ȳ���Ϊ��ֵ��");
} else
break;
}
for (int a = 0; a > -1; ++a) {
String startline = p.getProperty(a + "alignmentstartline");
if (startline != null) {
text.setLineAlignment(Integer.valueOf(startline), 1, Integer.valueOf(p.getProperty(a + "alignment")));
} else
break;
}
}
示例14: applyStyles
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
@Override
public void applyStyles(TextStyle textStyle) {
if (stylerDescriptor.font != null) {
textStyle.font = stylerDescriptor.font;
}
if (stylerDescriptor.foreground != null) {
textStyle.foreground = stylerDescriptor.foreground;
}
if (stylerDescriptor.backGround != null) {
textStyle.background = stylerDescriptor.backGround;
}
}
示例15: applyStyles
import org.eclipse.swt.graphics.TextStyle; //导入依赖的package包/类
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.strikeout = (xtextTextStyle.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
textStyle.underline = (xtextTextStyle.getStyle() & TextAttribute.UNDERLINE) != 0;
if (xtextTextStyle.getFontData() == null
&& xtextTextStyle.getStyle() != org.eclipse.xtext.ui.editor.utils.TextStyle.DEFAULT_FONT_STYLE) {
FontData fontData = new FontData();
fontData.setStyle(xtextTextStyle.getStyle());
xtextTextStyle.setFontData(fontData);
}
textStyle.font = fontFromFontData(xtextTextStyle.getFontData());
if (xtextTextStyle.getBackgroundColor() != null)
textStyle.background = colorFromRGB(xtextTextStyle.getBackgroundColor());
textStyle.foreground = colorFromRGB(xtextTextStyle.getColor());
}