Java Code Examples for org.eclipse.swt.graphics.TextStyle

The following examples show how to use org.eclipse.swt.graphics.TextStyle. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: xtext-eclipse   Author: eclipse   File: XbaseInformationControl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates and initializes the text layout used to compute the size hint.
 * 
 * @since 3.2
 */
private void createTextLayout() {
	fTextLayout = new TextLayout(fSashForm.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$
}
 
Example #2
Source Project: APICloud-Studio   Author: apicloudcom   File: CustomBrowserInformationControl.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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$
}
 
Example #3
Source Project: translationstudio8   Author: heartsome   File: HsMultiCellEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
	}
}
 
Example #4
Source Project: translationstudio8   Author: heartsome   File: TagStyleConfigurator.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
		}
	}
}
 
Example #5
Source Project: translationstudio8   Author: heartsome   File: TagStyleConfigurator.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #6
Source Project: translationstudio8   Author: heartsome   File: ConcordanceSearchDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 构造方法
 * @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;
	}
}
 
Example #7
Source Project: tmxeditor8   Author: heartsome   File: TagStyleConfigurator.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
		}
	}
}
 
Example #8
Source Project: tmxeditor8   Author: heartsome   File: TagStyleConfigurator.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
		}
	}
}
 
Example #9
Source Project: tmxeditor8   Author: heartsome   File: TagStyleConfigurator.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #10
Source Project: tmxeditor8   Author: heartsome   File: ConcordanceSearchDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 构造方法
 * @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;
	}
}
 
Example #11
Source Project: goclipse   Author: GoClipse   File: StylerHelpers.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle) {
	if(parentStyler != null) {
		parentStyler.applyStyles(textStyle);
	}
	
	Font font = textStyle.font;
	if(font == null) {
		font = JFaceResources.getDefaultFont(); 
	}
	FontDescriptor fontDescriptor = FontDescriptor.createFrom(font);
	fontDescriptor = getModifiedFontDescriptor(fontDescriptor);
	textStyle.font = fontDescriptor.createFont(Display.getCurrent());
}
 
Example #12
Source Project: bonita-studio   Author: bonitasoft   File: StyledConnectorLabelProvider.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
	if (cell.getElement() instanceof Connector) {
		Connector connector = (Connector) cell.getElement();
		ConnectorDefinition def = connectorDefStore.getDefinition(connector.getDefinitionId(),connector.getDefinitionVersion()) ;
		if(def == null){
			def = connectorDefStore.getDefinition(connector.getDefinitionId(),connector.getDefinitionVersion()) ;
		}
		StyledString styledString = new StyledString();

		styledString.append(getText(connector), null);
		styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
		String connectorType = connector.getDefinitionId() +" ("+connector.getDefinitionVersion()+")";
		styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
		EObject parent = connector.eContainer();
           if (!(parent instanceof Expression)) {
			if(connector.getEvent() != null && !connector.getEvent().isEmpty()){
				styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
				styledString.append(connector.getEvent(), StyledString.COUNTER_STYLER);
			}
		}
		if(def == null){
			styledString.setStyle(0, styledString.length(), new org.eclipse.jface.viewers.StyledString.Styler() {

				@Override
				public void applyStyles(TextStyle textStyle) {
					textStyle.strikeout = true ;
				}
			}) ;
			styledString.append(" ");
			styledString.append(Messages.bind(Messages.connectorDefinitionNotFound,connector.getDefinitionId() + " ("+connector.getDefinitionVersion()+")")) ;
		}

		cell.setText(styledString.getString());
		cell.setImage(getImage(connector)) ;
		cell.setStyleRanges(styledString.getStyleRanges());
	}
}
 
Example #13
Source Project: bonita-studio   Author: bonitasoft   File: StylerBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Styler create() {
    return new Styler() {

        @Override
        public void applyStyles(TextStyle textStyle) {
            color.ifPresent(c -> textStyle.foreground = c);
            font.ifPresent(f -> textStyle.font = f);
        }
    };
}
 
Example #14
Source Project: xtext-eclipse   Author: eclipse   File: StylerFactory.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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());
}
 
Example #15
Source Project: xtext-eclipse   Author: eclipse   File: StylerFactory.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle) {
	ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
	if (fontDescriptor != null) {
		textStyle.font = fontDescriptor.createFont(Display.getCurrent());
	}
	if (foregroundColorName != null) {
		textStyle.foreground = colorRegistry.get(foregroundColorName);
	}
	if (backgroundColorName != null) {
		textStyle.background = colorRegistry.get(backgroundColorName);
	}
}
 
Example #16
Source Project: bonita-studio   Author: bonitasoft   File: StyledFilterLabelProvider.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof ActorFilter) {
        ActorFilter filter = (ActorFilter) cell.getElement();
        ConnectorDefinition def = defStore.getDefinition(filter.getDefinitionId(),filter.getDefinitionVersion()) ;
        StyledString styledString = new StyledString();

        styledString.append(getText(filter), null);
        styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
        String connectorType = filter.getDefinitionId() +" ("+filter.getDefinitionVersion()+")";
        styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
        if(filter.getEvent() != null && !filter.getEvent().isEmpty()){
            styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
            styledString.append(filter.getEvent(), StyledString.COUNTER_STYLER);
        }
        if(def == null){
            styledString.setStyle(0, styledString.length(), new org.eclipse.jface.viewers.StyledString.Styler() {

                @Override
                public void applyStyles(TextStyle textStyle) {
                    textStyle.strikeout = true ;
                }
            }) ;
            styledString.append(" ");
            styledString.append(Messages.bind(Messages.filterDefinitionNotFound,filter.getDefinitionId() + " ("+filter.getDefinitionVersion()+")")) ;
        }

        cell.setText(styledString.getString());
        cell.setImage(getImage(filter)) ;
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}
 
Example #17
Source Project: xds-ide   Author: excelsior-oss   File: SelectModulaSourceFileDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public StyledDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
    super(provider, decorator);
    boldStyler = new Styler() {
        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.font= getBoldFont();
        }
    };
}
 
Example #18
Source Project: olca-app   Author: GreenDelta   File: ColorStyler.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle) {
	if (background != null) {
		textStyle.background = background;
	}
	if (foreground != null) {
		textStyle.foreground = foreground;
	}
	textStyle.strikeout = strikeout;
	if (italic) {
		textStyle.font = getFont();
	}
}
 
Example #19
Source Project: APICloud-Studio   Author: apicloudcom   File: SnippetsCompletionProcessor.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle)
{
	if (maxHeightTextFont != null)
	{
		// Use font with limited max height
		textStyle.font = maxHeightTextFont;
	}
	else
	{
		textStyle.font = JFaceResources.getTextFont();
	}
}
 
Example #20
private Styler createBoldStyler() {
	return new Styler() {
		@Override
		public void applyStyles(TextStyle textStyle) {
			textStyle.font= getBoldFont();
		}
	};
}
 
Example #21
private Styler createBoldQualifierStyler() {
	return new Styler() {
		@Override
		public void applyStyles(TextStyle textStyle) {
			StyledString.QUALIFIER_STYLER.applyStyles(textStyle);
			textStyle.font= getBoldFont();
		}
	};
}
 
Example #22
Source Project: translationstudio8   Author: heartsome   File: TextPainterWithPadding.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #23
Source Project: translationstudio8   Author: heartsome   File: TextPainterWithPadding.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example #24
Source Project: translationstudio8   Author: heartsome   File: StyleTextCellRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 构造方法
 * @param strStyleText
 *            要加样式的文本
 * @param blnIsCaseSensitive
 *            是否区分大小写
 */
public StyleTextCellRenderer(String strStyleText, boolean blnIsCaseSensitive, boolean blnIsApplyRegular,TextStyle style) {
	super();
	this.strStyleText = strStyleText;
	this.blnIsCaseSensitive = blnIsCaseSensitive;
	this.blnIsApplyRegular = blnIsApplyRegular;	
	this.style = style;
}
 
Example #25
Source Project: translationstudio8   Author: heartsome   File: PresentationRepairer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) {
	Assert.isNotNull(scanner);

	fViewer = viewer;
	fScanner = scanner;
	fDefaultTextStyle = new TextStyle();
}
 
Example #26
Source Project: translationstudio8   Author: heartsome   File: PresentationRepairer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void createPresentation(TextPresentation presentation, ITypedRegion region) {
	if (fScanner == null) {
		// will be removed if deprecated constructor will be removed
		addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextStyle);
		return;
	}

	int lastStart = region.getOffset();
	int length = 0;
	boolean firstToken = true;
	IToken lastToken = Token.UNDEFINED;
	TextStyle lastTextStyle = getTokenTextStyle(lastToken);

	fScanner.setRange(fDocument, lastStart, region.getLength());

	while (true) {
		IToken token = fScanner.nextToken();
		if (token.isEOF())
			break;

		TextStyle textStyle = getTokenTextStyle(token);
		if (lastTextStyle != null && lastTextStyle.equals(textStyle)) {
			length += fScanner.getTokenLength();
			firstToken = false;
		} else {
			if (!firstToken)
				addRange(presentation, lastStart, length, lastTextStyle);
			firstToken = false;
			lastToken = token;
			lastTextStyle = textStyle;
			lastStart = fScanner.getTokenOffset();
			length = fScanner.getTokenLength();
		}
	}

	addRange(presentation, lastStart, length, lastTextStyle);
}
 
Example #27
Source Project: translationstudio8   Author: heartsome   File: PresentationRepairer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds style information to the given text presentation.
 * @param presentation
 *            the text presentation to be extended
 * @param offset
 *            the offset of the range to be styled
 * @param length
 *            the length of the range to be styled
 * @param textStyle
 *            the style of the range to be styled
 */
protected void addRange(TextPresentation presentation, int offset, int length, TextStyle textStyle) {
	if (textStyle != null) {

		if (textStyle.metrics != null && length >= 1) {
			for (int i = offset; i < offset + length; i++) {
				try {
					StyleRange styleRange = new StyleRange(textStyle);
					String placeHolder = fDocument.get(i, 1);
					InnerTag innerTag = InnerTagUtil.getInnerTag(fViewer.getInnerTagCacheList(), placeHolder);
					if (innerTag != null) {
						Point rect = innerTag.computeSize(SWT.DEFAULT, SWT.DEFAULT);
						// int ascent = 4 * rect.height / 5 + SEGMENT_LINE_SPACING / 2;
						// int descent = rect.height - ascent + SEGMENT_LINE_SPACING;
						styleRange.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
					}
					styleRange.start = i;
					styleRange.length = 1;
					presentation.addStyleRange(styleRange);
				} catch (BadLocationException e) {
					e.printStackTrace();
				}
			}
		} /*
		 * else { StyleRange styleRange = new StyleRange(textStyle); styleRange.start = offset; styleRange.length =
		 * length; presentation.addStyleRange(styleRange); }
		 */
	}
}
 
Example #28
Source Project: translationstudio8   Author: heartsome   File: ConcordanceSearchDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
private TextStyle createResultsStyle() {
	background = new Color(Display.getCurrent(), 0x19, 0x19, 0x70);
	foreground = new Color(Display.getCurrent(), 0xff, 0xff, 0xff);
	FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
	fontData.setStyle(fontData.getStyle());
	rsFont = new Font(Display.getDefault(), fontData);
	TextStyle style = new TextStyle(rsFont, foreground, background);
	return style;
}
 
Example #29
Source Project: JDeodorant   Author: tsantalis   File: StyledStringStyler.java    License: MIT License 5 votes vote down vote up
public StyledStringStyler(TextStyle textStyle){
	textStyleAttributeStyle.font = textStyle.font;
	textStyleAttributeStyle.background = textStyle.background;
	textStyleAttributeStyle.borderColor = textStyle.borderColor;
	textStyleAttributeStyle.borderStyle = textStyle.borderStyle;
	textStyleAttributeStyle.foreground = textStyle.foreground;
	textStyleAttributeStyle.metrics = textStyle.metrics;
	textStyleAttributeStyle.rise = textStyle.rise;
	textStyleAttributeStyle.strikeout = textStyle.strikeout;
	textStyleAttributeStyle.strikeoutColor = textStyle.strikeoutColor;
	textStyleAttributeStyle.underline = textStyle.underline;
	textStyleAttributeStyle.underlineColor = textStyle.underlineColor;
	textStyleAttributeStyle.underlineStyle = textStyle.underlineStyle;
}
 
Example #30
Source Project: bonita-studio   Author: bonitasoft   File: DataStyledTreeLabelProvider.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void initStyle() {
	imageProvider = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)) ;
	italicGrey = new StyledString.Styler() {
		@Override
		public void applyStyles(TextStyle textStyle) {
			textStyle.font = BonitaStudioFontRegistry.getTransientDataFont();
			textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
		}
	};
}