本文整理汇总了Java中org.eclipse.jface.resource.FontRegistry类的典型用法代码示例。如果您正苦于以下问题:Java FontRegistry类的具体用法?Java FontRegistry怎么用?Java FontRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontRegistry类属于org.eclipse.jface.resource包,在下文中一共展示了FontRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: XYGraphMediaFactory
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
/**
* Private constructor to avoid instantiation.
*/
private XYGraphMediaFactory() {
_colorRegistry = new ColorRegistry();
_imageRegistry = new ImageRegistry();
_fontRegistry = new FontRegistry();
_imageCache = new HashMap<ImageDescriptor, Image>();
// dispose all images from the image cache, when the display is disposed
Display.getDefault().addListener(SWT.Dispose, new Listener() {
public void handleEvent(final Event event) {
for (Image img : _imageCache.values()) {
img.dispose();
}
disposeResources();
}
});
}
示例3: createContents
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
/**
* @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
*/
public void createContents(Composite parent) {
FormToolkit toolkit = this.managedForm.getToolkit();
fontRegistry = new FontRegistry(parent.getDisplay());
// Initializes the parent control.
parent.setLayout(new FillLayout());
// Creates the section
this.section = toolkit.createSection(parent, Section.TITLE_BAR);
this.section.marginHeight = 5;
this.section.marginWidth = 10;
// Createst the section content and its layout
this.sectionContent = toolkit.createComposite(section);
this.section.setClient(this.sectionContent);
GridLayout layout = new GridLayout(1, true);
layout.marginWidth = 0;
layout.marginHeight = 0;
this.sectionContent.setLayout(layout);
// Creates the editor content.
this.editorContainer = managedForm.getToolkit().createComposite(sectionContent);
this.editorContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Creates controls displaying the setting note.
this.noteLabel = this.managedForm.getToolkit().createFormText(sectionContent, false);
this.noteLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.noteLabel.setFont(EMPHASIS, fontRegistry.getItalic(""));
this.noteLabel.addHyperlinkListener(new MyHyperlinkListener(this));
}
示例4: initDiffStyleRangeForLineType
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
/**
* Starts a new {@link StyleRange} given a specific line type.
*/
private StyleRange initDiffStyleRangeForLineType(DiffLineType lineType, int startTextOffset) {
ColorRegistry reg =
PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
StyleRange range = new StyleRange();
range.start = startTextOffset;
switch (lineType) {
case ADD:
range.foreground = reg.get(THEME_DiffAddForegroundColor);
range.background = reg.get(THEME_DiffAddBackgroundColor);
break;
case REMOVE:
range.foreground = reg.get(THEME_DiffRemoveForegroundColor);
range.background = reg.get(THEME_DiffRemoveBackgroundColor);
break;
case HUNK:
range.foreground = reg.get(THEME_DiffHunkForegroundColor);
range.background = reg.get(THEME_DiffHunkBackgroundColor);
break;
case HEADLINE:
range.foreground = reg.get(THEME_DiffHeadlineForegroundColor);
range.background = reg.get(THEME_DiffHeadlineBackgroundColor);
FontRegistry fontReg =
PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
range.font = fontReg.get(THEME_DiffHeadlineFont);
break;
default:
break;
}
return range;
}
示例5: 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)});
}
示例6: FontListener
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
/**
* Create the FontListener. Starts listening to the font registry
* provided. It the control already has a FontListener, it is disposed.
* @param control The control who's font this class will update.
* @param fontPref The preference this class will update.
* @param registry The registry to get font preferences from.
*/
private FontListener( Control control, ExternalPreference fontPref,
FontRegistry registry )
{
this.control = control;
this.fontPref = fontPref;
this.registry = registry;
registry.addListener( this );
removeListener( control );
currentListeners.put( control, this );
}
示例7: 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;
}
示例8: 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;
}
示例9: 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());
}
示例10: populateTree
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
protected void populateTree(Map<String, List<UpgradeConflict>> upgradeConflicts) {
TreeSet<String> sortedComponentTypes = new TreeSet<>();
sortedComponentTypes.addAll(upgradeConflicts.keySet());
// loop thru sorted list creating upgrade component tree
for (String componentType : sortedComponentTypes) {
// create root component type node
TreeItem componentTypeTreeItem = new TreeItem(getTreeComponentConflicts(), SWT.NONE);
componentTypeTreeItem.setText(componentType);
FontRegistry registry = new FontRegistry();
Font boldFont = registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
componentTypeTreeItem.setFont(boldFont);
componentTypeTreeItem.setExpanded(true);
// loop thru each component instance and create named node
List<UpgradeConflict> upgradeComponents = upgradeConflicts.get(componentType);
for (UpgradeConflict upgradeConflict : upgradeComponents) {
TreeItem componentTreeItem = new TreeItem(componentTypeTreeItem, SWT.NONE);
componentTreeItem.setText(upgradeConflict.getLocalComponent().getFileName());
componentTreeItem.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
componentTreeItem.setData("local", upgradeConflict.getLocalComponent());
componentTreeItem.setData("remote", upgradeConflict.getRemoteComponent());
componentTreeItem.setExpanded(true);
}
}
}
示例11: updateSummaryLabel
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
public void updateSummaryLabel(int candidateCnt, String orgUserName) {
if (lblSummary != null) {
lblSummary.setText("Found " + candidateCnt + " deployment candidates");
FontRegistry registry = new FontRegistry();
Font boldFont = registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
lblSummary.setFont(boldFont);
lblSummary.update();
}
}
示例12: getPreferenceFont
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
public static Font getPreferenceFont(Display display, String name) {
FontRegistry fontRegistry = JFaceResources.getFontRegistry();
FontData[] fonts = fontRegistry.filterData(getPreferenceFont(name), display);
if (fonts == null)
return fontRegistry.defaultFont();
return new Font(display, fonts);
}
示例13: initFonts
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
private void initFonts()
{
FontData[] fontData = Display.getCurrent().getSystemFont().getFontData();
String fontName = fontData[0].getName();
FontRegistry registry = JFaceResources.getFontRegistry();
boldFont = registry.getBold(fontName);
}
示例14: updateFontEntries
import org.eclipse.jface.resource.FontRegistry; //导入依赖的package包/类
private static void updateFontEntries( Display display ) {
FontRegistry fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
if( fontRegistry.getFontData( "org.eclipse.jface.textfont" )[ 0 ].getName().equals( FONT_FACE ) ) {
updateFontEntry( display, fontRegistry, "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" );
updateFontEntry( display, fontRegistry, "org.eclipse.jface.textfont" );
updateFontEntry( display, fontRegistry, "org.eclipse.jdt.ui.editors.textfont" );
}
}
示例15: 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();
}