本文整理汇总了Java中org.eclipse.jface.resource.FontRegistry.put方法的典型用法代码示例。如果您正苦于以下问题:Java FontRegistry.put方法的具体用法?Java FontRegistry.put怎么用?Java FontRegistry.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.resource.FontRegistry
的用法示例。
在下文中一共展示了FontRegistry.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private void init() {
shell.setLayout(new GridLayout(2, false));
fontRegistry = new FontRegistry(display);
fontRegistry.put("button-text", new FontData[]{new FontData("Arial", 9, SWT.BOLD)} );
fontRegistry.put("code", new FontData[]{new FontData("Courier New", 10, SWT.NORMAL)});
Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP);
text.setFont(fontRegistry.get("code"));
text.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
text.setText("public static void main() {\n\tSystem.out.println(\"Hello\"); \n}");
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
Button executeButton = new Button(shell, SWT.PUSH);
executeButton.setText("Execute");
executeButton.setFont(fontRegistry.get("button-text"));
Button cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setFont(fontRegistry.get("button-text"));
}
示例2: start
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
public void start(BundleContext context) throws Exception
{
super.start(context);
plugin = this;
fontReg = new FontRegistry(Display.getCurrent());
// initialise some fonts
fontReg.put(FONT_8, new FontData[]
{new FontData("Arial", 8, SWT.None)});
fontReg.put(FONT_10, new FontData[]
{new FontData("Arial", 10, SWT.None)});
fontReg.put(FONT_12, new FontData[]
{new FontData("Arial", 12, SWT.None)});
}
示例3: deriveFontSize
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private static Font deriveFontSize(Font font, String preferenceKey) {
int pixelHeight = TIMELINE_PREFERENCES.getInt(preferenceKey);
if (font == null) {
font = Display.getDefault().getSystemFont();
}
Device device = font.getDevice();
if (device == null) {
device = WidgetUtils.getDisplay();
}
int pixelsPerInch = device.getDPI().y;
int pointHeight;
if (pixelsPerInch == 0) {
pointHeight = pixelHeight;
} else {
pointHeight = POINTS_PER_INCH * pixelHeight / pixelsPerInch;
}
FontData[] fontData = font.getFontData();
for (int i=0; i<fontData.length; i++) {
fontData[i].setHeight(pointHeight);
}
String symbolicFontName = font.toString() + "_" + pointHeight;
FontRegistry fontRegistry = FontUtils.FONT_REGISTRY_INSTANCE;
boolean fontExists = fontRegistry.getKeySet().contains(symbolicFontName);
Font desiredFont = null;
if(!fontExists) {
desiredFont = FontUtils.getStyledFont(font.getDevice(), fontData);
fontRegistry.put(symbolicFontName, fontData);
} else {
desiredFont = fontRegistry.get(symbolicFontName);
}
return desiredFont;
}
示例4: getBoldFont
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private Font getBoldFont() {
Font systemFont = FontUtils.getSystemFont();
int desiredFontHeight = 10;
String symbolicFontName = systemFont.toString() + "_" + desiredFontHeight;
FontRegistry fontRegistry = FontUtils.FONT_REGISTRY_INSTANCE;
boolean fontExists = fontRegistry.getKeySet().contains(symbolicFontName);
Font font = null;
if(!fontExists) {
font = FontUtils.getStyledFont(desiredFontHeight, SWT.NONE);
fontRegistry.put(symbolicFontName, font.getFontData());
} else {
font = fontRegistry.get(symbolicFontName);
}
return font;
}
示例5: initFonts
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
/**
* Inits the fonts for the dialog.
*
* @param fontRegistry
* fontRegistry
*/
public static void initFonts(FontRegistry fontRegistry) {
FontData[] fontData = JFaceResources.getDialogFontDescriptor().getFontData();
if (fontData.length > 0) {
fontData[0].setStyle(SWT.ITALIC);
fontData[0].setHeight(fontData[0].getHeight() - 1);
}
fontRegistry.put("titleLabel", fontData);
fontRegistry.put("content", JFaceResources.getDialogFontDescriptor().getFontData());
}
示例6: updateFontEntry
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private static void updateFontEntry( Display display, FontRegistry fontRegistry, String symbolicName ) {
Font textFont = fontRegistry.get( symbolicName );
fontRegistry.put( symbolicName, display.getSystemFont().getFontData() );
display.readAndDispatch();
fontRegistry.put( symbolicName, textFont.getFontData() );
display.readAndDispatch();
}
示例7: updateFont
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
public static void updateFont(String cfgName){
FontRegistry fr = JFaceResources.getFontRegistry();
FontData[] fd =
PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
cfgName);
fr.put(cfgName, fd);
}
示例8: getFont
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
public static Font getFont(String cfgName){
FontRegistry fr = JFaceResources.getFontRegistry();
if (!fr.hasValueFor(cfgName)) {
FontData[] fd =
PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
cfgName);
fr.put(cfgName, fd);
}
return fr.get(cfgName);
}
示例9: registerFont
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private void registerFont(final Control control) {
final FontRegistry fontRegistry = JFaceResources.getFontRegistry();
if (!fontRegistry.hasValueFor(symbolicName)) {
fontRegistry.put(symbolicName, control.getFont().getFontData());
}
}
示例10: setElementBackgroundColor
import org.eclipse.jface.resource.FontRegistry; //导入方法依赖的package包/类
private void setElementBackgroundColor(TableView wQueryElement, String text) {
FontRegistry fontRegistry= new FontRegistry(Display.getCurrent());
fontRegistry.put("font", new FontData[]{new FontData("Sans Serif", 9, SWT.BOLD|SWT.ITALIC)} );
FontRegistry defaultFontRegistry= new FontRegistry(Display.getCurrent());
defaultFontRegistry.put("font", new FontData[]{new FontData("Sans Serif", 9, SWT.NORMAL)} );
wQueryElement.table.setFont(defaultFontRegistry.get("font"));
if (text.equalsIgnoreCase("CSW_RECORD")&& wQueryElement.table.getItemCount()>=15){
wQueryElement.table.getItem(0).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(1).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(6).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(7).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(10).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(13).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(14).setFont(fontRegistry.get("font"));
//wQueryElement.table.getItem(17).setFont(fontRegistry.get("font"));
//set foreground color
wQueryElement.table.getItem(0).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(6).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(7).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(10).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(13).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(14).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
}else{
if (text.equalsIgnoreCase("MD_METADATA")&& wQueryElement.table.getItemCount()>=51){
wQueryElement.table.getItem(0).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(1).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(4).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(5).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(12).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(17).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(18).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(25).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(43).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(46).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(47).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(48).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(49).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(50).setFont(fontRegistry.get("font"));
wQueryElement.table.getItem(51).setFont(fontRegistry.get("font"));
//set foreground color
wQueryElement.table.getItem(0).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(4).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(5).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(12).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(17).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(18).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(25).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(43).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(46).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(47).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(48).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(49).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(50).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
wQueryElement.table.getItem(51).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
}
}
}