Example usage for org.eclipse.jface.resource FontRegistry FontRegistry

List of usage examples for org.eclipse.jface.resource FontRegistry FontRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource FontRegistry FontRegistry.

Prototype

public FontRegistry(Display display, boolean cleanOnDisplayDisposal) 

Source Link

Document

Creates an empty font registry.

Usage

From source file:org.mwc.cmap.core.property_support.FontHelper.java

License:Open Source License

/**
 * create an swt font that looks like this java awt one
 * /* w  w w  . j  a v  a2  s .co  m*/
 * @param javaFont
 * @return
 */
public static org.eclipse.swt.graphics.Font convertFontFromAWT(final java.awt.Font javaFont) {

    // check we have our registry
    if (_fontRegistry == null)
        _fontRegistry = new FontRegistry(Display.getCurrent(), true);

    if (_myFontList == null)
        _myFontList = new HashMap<java.awt.Font, Font>();

    // see if we've got the font in our local list
    org.eclipse.swt.graphics.Font thisFont = (Font) _myFontList.get(javaFont);

    // did we find it?
    if (thisFont == null) {
        // nope, better go and get it then

        // get the font as a string - we use that as an index
        final String fontName = javaFont.toString();

        // do we have a font for this style?
        if (!_fontRegistry.hasValueFor(fontName)) {
            // bugger, we'll have to create it

            final int size = javaFont.getSize();
            final int style = javaFont.getStyle();
            String name = javaFont.getName();

            // WORKAROUND
            // - on windows, our 'sans serif' recorded in the xml file doesn't get
            // translated to Arial. So, we do it by hand
            if (name.equals("Sans Serif"))
                name = "Arial";

            // create an SWT font data entity to describe this font
            final FontData newF = new FontData(name, size, style);

            // and store the font in the registry
            _fontRegistry.put(fontName, new FontData[] { newF });
        }

        // ok, we can now try to retrieve this font (if the font data wasn't there before,
        // it will be now. If we really don't have it,  we'll just get a default one any
        // way. cool.
        thisFont = _fontRegistry.get(fontName);

        // and store the Java font against the SWT one
        _myFontList.put(javaFont, thisFont);
    }

    return thisFont;
}

From source file:org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.MBeanOperationEditor.java

License:Apache License

/**
 * @see org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.IMBeanNodeEditor#decorateContentsAsSelected()
 *//*from   w w  w .j av a  2  s .c o  m*/
public boolean decorateContentsAsSelected() {
    FontRegistry fontRegistry = new FontRegistry(Display.getCurrent(), true);
    operationButton.setFont(fontRegistry.getBold(fontRegistry.defaultFont().toString()));
    return true;
}

From source file:org.soyatec.tooling.gef.resources.ResourcesFactory.java

License:Open Source License

public static FontRegistry getFontRegistry() {
    if (fontRegistry == null) {
        fontRegistry = new FontRegistry(getDisplay(), true);
    }/* w w  w  .ja va2s.c  o m*/
    return fontRegistry;
}