use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.
the class FontProviderMapper method releaseFont.
public static void releaseFont(FontInfo fontInfo) {
Font font = fontsCache.get(fontInfo);
if (!font.isDisposed()) {
font.dispose();
}
fontsCache.remove(fontInfo);
}
use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.
the class SWTResourceManager method getFont.
/**
* Returns a font based on its name, height and style
*
* @param name String The name of the font
* @param height int The height of the font
* @param style int The style of the font
* @return Font The font matching the name, height and style
*/
public static Font getFont(String name, int height, int style) {
String fontName = name + '|' + height + '|' + style;
Font font = m_FontMap.get(fontName);
if (font == null) {
FontData fontData = new FontData(name, height, style);
font = new Font(Display.getCurrent(), fontData);
m_FontMap.put(fontName, font);
}
return font;
}
use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.
the class SWTResourceManager method getSystemFont.
public static Font getSystemFont(int style) {
Font font = m_systemFontMap.get(style);
if (font == null) {
systemFontData[0].setStyle(style);
font = new Font(Display.getCurrent(), systemFontData);
m_systemFontMap.put(style, font);
}
return font;
}
use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.
the class AbstractLanguageMemoController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
if (!estimateInitialized) {
IControlCreator txtCtrl = new IControlCreator() {
@Override
public Control createControl(final Composite parent, final int style) {
final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
display.syncExec(new Runnable() {
@Override
public void run() {
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
FontData fontData = new FontData(fontType);
Font font = new Font(parent.getDisplay(), fontData);
addResourceDisposeListener(colorText, font);
colorText.setFont(font);
}
});
}
return colorText;
}
};
DecoratedField dField = null;
if (param.getNbLines() != 1) {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
} else {
dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
}
StyledText text = (StyledText) dField.getControl();
FormData d = (FormData) text.getLayoutData();
d.height = text.getLineHeight();
text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
rowSizeByLine = text.getLineHeight();
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dField.getLayoutControl().dispose();
rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
estimateInitialized = true;
}
return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.
the class FontProviderMapper method getFont.
public static Font getFont(FontInfo fontInfo) {
Font fontFromCache = fontsCache.get(fontInfo);
if (fontFromCache != null) {
return fontFromCache;
}
Font font = new Font(Display.getCurrent(), fontInfo.getFontDatas());
fontsCache.put(fontInfo, font);
return font;
}
Aggregations