Java 类org.eclipse.swt.graphics.Font 实例源码

项目:bdf2    文件:TableFigure.java   
public TableFigure() {
    ToolbarLayout layout = new ToolbarLayout();
    setLayoutManager(layout);
    LineBorder lineBorder = new LineBorder(ColorConstants.lightGray, 2);
    setBorder(lineBorder);
    setOpaque(true);
    setBackgroundColor(ColorConstants.white);

    Font font = new Font(null, "宋体", 11, SWT.NORMAL);
    label.setFont(font);
    label.setBorder(new LineBorder(ColorConstants.lightGray));
    label.setIcon(Activator.getImage(Activator.IMAGE_TABLE_16));
    label.setOpaque(true);
    label.setBackgroundColor(ColorConstants.lightBlue);
    label.setForegroundColor(ColorConstants.black);
    add(label);
    add(columnFigure);
}
项目:ide-plugins    文件:PluginsSWT.java   
public PluginsSWT(Shell shell, List<String> lines) {
    super(shell);
    this.pluginsBean = new PluginsBean(lines);

    target = pluginsBean.getPlugins();
    source = Stream.of(Plugin.values())
            .filter(p -> ! target.contains(p))
            .collect(Collectors.toList());
    targetOriginal = target.stream().collect(Collectors.toList());

    rowColorTitle = new Color(display, 70, 130, 180);
    int color = myOS == OS.Mac ? 249 : 239;
    rowColorBack = new Color(display, color, color, color);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);

    fontAwesome = loadCustomFont(getFontAwesomeSize());
    fontGap = new Font(display, fontName, 4, SWT.NORMAL);
    rowTitleFont = new Font(display, fontName, getTopFontSize(), SWT.BOLD);
    rowTextFont = new Font(display, fontName, getTopFontSize() - 2, SWT.NORMAL);
    styleTitle = new TextStyle(rowTitleFont, rowColorTitle, null);
    styleGap = new TextStyle(fontGap, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleRow = new TextStyle(rowTextFont, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleTitleSelected = new TextStyle(rowTitleFont, rowColorSelection, null);
    styleRowSelected = new TextStyle(rowTextFont, rowColorSelection, null);
}
项目:ide-plugins    文件:PluginDialog.java   
protected void createTopContent(String title, InputStream imageName) {
    Composite top = new Composite(composite, SWT.NONE);

    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    top.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    final Image image = new Image(top.getDisplay(), imageName);
    Image resized = resizeImage(image, 48, 48);
    Label labelImage = new Label(top, SWT.CENTER);
    labelImage.setImage(resized);

    Label label = new Label(top, SWT.NONE);
    label.setText(title);
    final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    label.setFont(newFont);
    label.setBackground(rowColorSelection);

    createLineContent();

    top.addDisposeListener(e -> {
        newFont.dispose();
        resized.dispose();
    });
}
项目:neoscada    文件:TitleRenderer.java   
private Font createFont ( final ResourceManager resourceManager )
{
    final Font defaultFont = resourceManager.getDevice ().getSystemFont ();

    if ( defaultFont == null )
    {
        return null;
    }

    final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
    if ( fd == null )
    {
        return null;
    }

    for ( final FontData f : fd )
    {
        if ( this.fontSize > 0 )
        {
            f.setHeight ( this.fontSize );
        }
    }
    return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
项目:convertigo-eclipse    文件:TextEditorComposite.java   
private void initialize() {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    GridData gridData = new org.eclipse.swt.layout.GridData();
    gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;

    //minimum size (when dialog open)
    gridData.minimumHeight = 200;
    gridData.minimumWidth = 300;

    this.setLayout(gridLayout);
    textArea = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    textArea.setFont(new Font(null,"Tahoma",10,0));
    textArea.setLayoutData(gridData);
}
项目:convertigo-eclipse    文件:SqlQueryEditorComposite.java   
private void initialize() {
    labelSyntaxe = new Label(this, SWT.NONE);

    labelSyntaxe.setText("SQL query syntax examples :\n");
    labelSyntaxe.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
    labelSQLQuery = new Label(this, SWT.NONE);
    labelSQLQuery.setFont(new Font(null,"Tahoma",8,1));
    labelSQLQuery.setText("SELECT * FROM EMPLOYEES WHERE (NAME='{parameter_name}')\n"
                            + "{? = CALL STORED_FUNCTION({parameter_name})}\n"
                            + "{CALL STORED_PROCEDURE({parameter_name})}\n\n");
    labelSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
    textAreaSQLQuery = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    textAreaSQLQuery.setFont(new Font(null,"Tahoma",10,0));
    textAreaSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
    GridLayout gridLayout = new GridLayout();
    this.setLayout(gridLayout);
    setSize(new org.eclipse.swt.graphics.Point(402,289));
}
项目:convertigo-eclipse    文件:ViewLabelProvider.java   
public ViewLabelProvider() {
    Device device = Display.getCurrent();

    fontSystem = device.getSystemFont();

    FontData fontData = fontSystem.getFontData()[0];

    fontDetectedDatabaseObject = new Font(device, fontData);

    FontData fontDataModified = fontSystem.getFontData()[0];
    fontDataModified.setStyle(SWT.BOLD);
    fontModifiedDatabaseObject = new Font(device, fontDataModified);

    colorUnloadedProject = new Color(device, 12, 116, 176);
    colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
    colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
    colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
    colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
项目:convertigo-eclipse    文件:StatisticsDialog.java   
private void addStats() {

        for (String key : statsProject.keySet()) {
            if (key != project.getName()) {
                CLabel title = new CLabel(descriptifRight, SWT.BOLD);
                title.setText(key);
                title.setImage(new Image(display, getClass()
                        .getResourceAsStream(
                                "images/stats_"
                                        + key.replaceAll(" ", "_")
                                                .toLowerCase() + "_16x16.png")));
                title.setBackground(new Color(display, 255, 255, 255));
                title.setMargins(10, 10, 0, 0);

                FontData[] fd = title.getFont().getFontData();
                fd[0].setStyle(SWT.BOLD);
                title.setFont(new Font(title.getFont().getDevice(), fd));

                CLabel subText = new CLabel(descriptifRight, SWT.NONE);
                subText.setText(statsProject.get(key)
                        .replaceAll("<br/>", "\r\n").replaceAll("&nbsp;", " "));
                subText.setBackground(new Color(display, 255, 255, 255));
                subText.setMargins(30, 0, 0, 0);
            }
        }
    }
项目:avoCADo    文件:MELabel.java   
@Override
void paintElement(PaintEvent e) {
    GC g = e.gc;
    g.setBackground(this.getBackground());
    int width  = this.getBounds().width;
    int height = this.getBounds().height;

    // clear entire canvas where button will be painted
    g.fillRectangle(0, 0, width, height);

    // draw text
    g.setForeground(this.meColorForeground);
    FontData fd = new FontData();
    fd.setHeight(8);
    if(textIsBold){
        fd.setStyle(SWT.BOLD);
    }else{
        fd.setStyle(SWT.NORMAL);
    }
    g.setFont(new Font(this.getDisplay(), fd));
    Point textPt = g.textExtent(this.meLabel);          
    g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
项目:openaudible    文件:FontShop.java   
public FontShop(Display display) {
    if (display == null) {
        Application.report("font display null");
    }

    regFonts = new Font[kNumFonts];
    boldFonts = new Font[kNumFonts];
    italicFonts = new Font[kNumFonts];
    for (int x = 0; x < kNumFonts; x++) {
        regFonts[x] = newDefaultFont(x);
        newStyledFont(x);
    }

    if (curFonts == null)
        curFonts = this;

}
项目:eclipse-plugin-commander    文件:KaviListColumns.java   
@SuppressWarnings("unchecked")
private RankedItem<T> applyCellDefaultStyles(final ColumnOptions<T> options, ViewerCell cell) {
    final RankedItem<T> rankedItem = (RankedItem<T>) cell.getElement();
    cell.setForeground(fromRegistry(options.getFontColor()));
    int rowState = rowStateResolver.apply(rankedItem);

    if ((rowState & RowState.SELECTED.value) != 0 && options.isEnableBackgroundSelection()) {
        cell.setBackground(fromRegistry(new RGB(225,226,206)));
    } else {
        cell.setBackground(fromRegistry(options.getBackgroundColor()));
    }
    if ((rowState & RowState.CURSOR.value) != 0 && options.isEnableBackgroundSelection()) {
        cell.setBackground(fromRegistry(ColorUtil.blend(cell.getBackground().getRGB(), new RGB(200,200,200))));
    }
    Font font = createColumnFont(options, cell);
    cell.setFont(font);
    return rankedItem;
}
项目:SWET    文件:ScrolledTextEx.java   
private StyledText createStyledText() {
    styledText = new StyledText(shell,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // SWT.WRAP
    GridData gridData = new GridData();
    styledText.setFont(
            new Font(shell.getDisplay(), "Source Code Pro Light", 10, SWT.NORMAL));
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    styledText.setLayoutData(gridData);
    styledText.addLineStyleListener(lineStyler);
    styledText.setEditable(false);
    styledText
            .setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
    return styledText;
}
项目:Hydrograph    文件:SourceViewer.java   
private void initializeViewer(IDocument document) {
    fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    setDocument(document);
    installViewerConfiguration();
    setEditable(true);
    Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
    getTextWidget().setFont(font);
    getTextWidget().setData("document",document);
    Control control = getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(data);
    prependVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            handleVerifyKeyPressed(event);
        }
    });
    addDocumentListener(document);
}
项目:Hydrograph    文件:CommentBoxFigure.java   
/**
 * Creates a new CommentBoxFigure with a MarginBorder that is the given size and a FlowPage containing a TextFlow
 * with the style WORD_WRAP_SOFT.
 * 
 * @param borderSize
 *            the size of the MarginBorder
 */
public CommentBoxFigure(int borderSize) {
    setBorder(new MarginBorder(5));
    FlowPage flowPage = new FlowPage();

    textFlow = new TextFlow();

    textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, ParagraphTextLayout.WORD_WRAP_SOFT));

    flowPage.add(textFlow);

    setLayoutManager(new StackLayout());
    add(flowPage);
    font = new Font(Display.getDefault(), "Arial", 9, SWT.NORMAL);
    setFont(font);
    setForegroundColor(ColorConstants.black);
    setOpaque(false);

}
项目:Hydrograph    文件:CommentBoxLabelEditManager.java   
/**
 * update scaledFonts
 * @param zoom
 *              at zoom 
 */
private void updateScaledFont(double zoom) {
    if (cachedZoom == zoom)
        return;

    Text text = (Text)getCellEditor().getControl();
    Font font = getEditPart().getFigure().getFont();

    disposeScaledFont();
    cachedZoom = zoom;
    if (zoom == 1.0)
        text.setFont(font);
    else {
        FontData fd = font.getFontData()[0];
        fd.setHeight((int)(fd.getHeight() * zoom));
        text.setFont(scaledFont = new Font(null, fd));
    }
}
项目:n4js    文件:LaunchConfigurationMainTab.java   
@SuppressWarnings("javadoc")
public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) {
    Composite g = new Composite(parent, SWT.NONE);
    g.setLayout(new GridLayout(columns, false));
    g.setFont(font);
    GridData gd = new GridData(fill);
    gd.horizontalSpan = hspan;
    g.setLayoutData(gd);
    return g;
}
项目:n4js    文件:OpenTypeSelectionDialog.java   
@Override
public Font get() {
    final Font font = getDialogArea().getFont();
    final FontData[] data = font.getFontData();
    for (int i = 0; i < data.length; i++) {
        data[i].setStyle(BOLD);
    }
    return new Font(font.getDevice(), data);
}
项目:n4js    文件:OpenTypeSelectionDialog.java   
@Override
public void dispose() {
    super.dispose();
    if (null != boldFontSupplier) {
        final Font font = boldFontSupplier.get();
        if (null != font && !font.isDisposed()) {
            font.dispose();
        }
    }
}
项目:BiglyBT    文件:SubscriptionWizard.java   
private void createFonts() {

        FontData[] fDatas = shell.getFont().getFontData();

        for(int i = 0 ; i < fDatas.length ; i++) {
            fDatas[i].setStyle(SWT.BOLD);
        }
        boldFont = new Font(display,fDatas);


        for(int i = 0 ; i < fDatas.length ; i++) {
            if(com.biglybt.core.util.Constants.isOSX) {
                fDatas[i].setHeight(12);
            } else {
                fDatas[i].setHeight(10);
            }
        }
        subTitleFont = new Font(display,fDatas);

        for(int i = 0 ; i < fDatas.length ; i++) {
            if(com.biglybt.core.util.Constants.isOSX) {
                fDatas[i].setHeight(17);
            } else {
                fDatas[i].setHeight(14);
            }
        }
        titleFont = new Font(display,fDatas);

        // When GTK3 can show a textbox without a border, we can remove the logic
        textInputFont = FontUtils.getFontWithHeight(shell.getFont(), null, Utils.isGTK3 ? 12 : 14);


    }
项目:n4js    文件:ExportSelectionPage.java   
@Override
protected void createOptionsGroupButtons(Group optionsGroup) {
    Font font = optionsGroup.getFont();
    optionsGroup.setLayout(new GridLayout(2, true));

    Composite left = new Composite(optionsGroup, SWT.NONE);
    left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
    left.setLayout(new GridLayout(1, true));

    // compress... checkbox
    compressContentsCheckbox = new Button(left, SWT.CHECK | SWT.LEFT);
    compressContentsCheckbox.setText(DataTransferMessages.ZipExport_compressContents);
    compressContentsCheckbox.setFont(font);

}
项目:n4js    文件:AbstractLaunchConfigurationMainTab.java   
/**
 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createControl(Composite parent) {
    Font font = parent.getFont();
    Composite comp = createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
    createResourceGroup(comp);
    createImplementationIdGroup(comp);
    setControl(comp);
}
项目:ide-plugins    文件:PluginsSWT.java   
private Font loadCustomFont(int fontSize) {
    String fontPath = ProjectUtils.extractResourceToTmp("fontawesome-webfont.ttf");
    boolean isLoaded = display.loadFont(fontPath);
    if (isLoaded) {
        return Stream.of(Display.getDefault().getFontList(null, true))
                .filter(fd -> fd.getName().toLowerCase(Locale.ROOT).contains("fontawesome"))
                .findFirst()
                .map(fd -> {
                    fd.setHeight(fontSize);
                    return new Font(display, fd);
                })
                .orElse(null);
    }
    return null;   
}
项目:ide-plugins    文件:PluginDialog.java   
public PluginDialog(Shell shell) {
    super(shell);
    this.display = Display.getDefault();

    fontName = display.getSystemFont().getFontData()[0].getName();
    backColor = new Color(display, 244, 244, 244);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
    titleFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    topFont = new Font(display, fontName, getTopFontSize(), SWT.NORMAL);
}
项目:gemoc-studio-modeldebugging    文件:LaunchConfigurationMainTab.java   
/***
 * Create the Field where user enters the language used to execute
 * 
 * @param parent container composite
 * @param font used font
 * @return the created composite containing the fields
 */
public Composite createLanguageLayout(Composite parent, Font font) {
    // Language
    createTextLabelLayout(parent, "Melange languages");
    _languageCombo = new Combo(parent, SWT.NONE);
    _languageCombo.setLayoutData(createStandardLayout());

    List<String> languagesNames = MelangeHelper.getAllLanguages();
    String[] empty = {};
    _languageCombo.setItems(languagesNames.toArray(empty));
    _languageCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            //String selection = _languageCombo.getText();
            //List<String> modelTypeNames = MelangeHelper.getModelTypes(selection);
            updateLaunchConfigurationDialog();
        }
    });
    createTextLabelLayout(parent, "");

    createTextLabelLayout(parent, "Melange resource adapter query");
    _melangeQueryText = new Text(parent, SWT.SINGLE | SWT.BORDER);
    _melangeQueryText.setLayoutData(createStandardLayout());
    _melangeQueryText.setFont(font);
    _melangeQueryText.setEditable(false);
    createTextLabelLayout(parent, "");

    return parent;
}
项目:gemoc-studio-modeldebugging    文件:DecoratingColumLabelProvider.java   
@Override
public Font getFont(Object element) {
    final Font res;

    if (fontProvider == null) {
        res = null;
    } else {
        res = fontProvider.getFont(element);
    }

    return res;
}
项目:gemoc-studio-modeldebugging    文件:DecoratingColumLabelProvider.java   
@Override
public Font getToolTipFont(Object element) {
    final Font res;

    if (cellLabelProvider == null) {
        res = null;
    } else {
        res = cellLabelProvider.getToolTipFont(element);
    }

    return res;
}
项目:gemoc-studio-modeldebugging    文件:EnginesStatusView.java   
/**
     * This is a callback that will allow us
     * to create the viewer and initialize it.
     */
    public void createPartControl(Composite parent) {
        _viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        _contentProvider = new ViewContentProvider();
        _viewer.setContentProvider(_contentProvider);
        ColumnViewerToolTipSupport.enableFor(_viewer);
        _viewer.addSelectionChangedListener(
                new ISelectionChangedListener() {
                    public void selectionChanged(SelectionChangedEvent event) {
                        fireEngineSelectionChanged();
                    }
                });

        createColumns();
//      _viewer.setColumnProperties( new String[] {"Status", "Identifier", "Step", "Status"} );
//      _viewer.getTree().setHeaderVisible(true);
        Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT);
        _viewer.getTree().setFont(mono);

        // Create the help context id for the viewer's control
        PlatformUI.getWorkbench().getHelpSystem().setHelp(_viewer.getControl(), "org.eclipse.gemoc.executionframework.ui.views.engine.EngineStatusView");

        // register for changes in the RunningEngineRegistry
        //org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addObserver(this);

        buildMenu();        

        org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addEngineRegistrationListener(this);
    }
项目:openaudible    文件:FontShop.java   
private Font newStyledFont(int index, int style) {

        Font f = regFonts[index];
        if (isset(f)) {
            FontData[] fontData = f.getFontData();
            fontData[0].setStyle(style);
            fontData[0].setLocale(Translate.getLocale().toString());
            return new Font(Display.getDefault(), fontData);
        } else {
            Application.report("newBold failed. f=" + f);
        }
        return null;
    }
项目:neoscada    文件:TreeNodeLabelProvider.java   
public TreeNodeLabelProvider ( final TreeViewer viewer, final IObservableMap... attributeMaps )
{
    super ( attributeMaps );
    this.viewer = viewer;

    this.defaultFont = viewer.getControl ().getFont ();

    final FontData[] fds = this.viewer.getControl ().getFont ().getFontData ();
    for ( final FontData fd : fds )
    {
        fd.setStyle ( SWT.ITALIC );
    }
    this.font = new Font ( this.viewer.getControl ().getDisplay (), fds );
}
项目:neoscada    文件:TreeNodeLabelProvider.java   
@Override
public Font getFont ( final Object element )
{
    final TreeNode node = (TreeNode)element;
    if ( node.isProviderSet () )
    {
        return this.defaultFont;
    }
    else
    {
        return this.font;
    }
}
项目:neoscada    文件:StyleBlinker.java   
public CurrentStyle ( final Image image, final Color foreground, final Color background, final Font font )
{
    this.image = image;
    this.foreground = foreground;
    this.background = background;
    this.font = font;
}
项目:neoscada    文件:StyleHandler.java   
public Style ( final Image[] images, final Color[] foregroundColor, final Color[] backgroundColor, final Font[] font )
{
    this.images = images;
    this.foregroundColor = foregroundColor;
    this.backgroundColor = backgroundColor;
    this.font = font;
}
项目:convertigo-eclipse    文件:ViewLabelProvider.java   
public Font getFont(Object element) {
    if (element instanceof DatabaseObjectTreeObject) {
        DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) element;
        DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
        if (databaseObject.hasChanged) return fontModifiedDatabaseObject;
        if (databaseObjectTreeObject.isDetectedObject) return fontDetectedDatabaseObject;
    }
    return fontSystem;
}
项目:convertigo-eclipse    文件:CicsConnectorComposite.java   
protected void initialize() {
    GridData gridData = new org.eclipse.swt.layout.GridData();
    gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
    cicsData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    cicsData.setEditable(false);
    cicsData.setBackground(new Color(null,253,253,244));
    cicsData.setFont(new Font(null,"Courier New",10,1));
    cicsData.setLayoutData(gridData);
    cicsData.setText("");
    this.setLayout(new GridLayout());
    setSize(new Point(300, 200));
}
项目:codelens-eclipse    文件:DefaultViewZone.java   
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
    StyledText styledText = super.getTextViewer().getTextWidget();
    Rectangle client = styledText.getClientArea();
    gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    styledText.drawBackground(gc, paintX, paintY, client.width, super.getHeightInPx());
    gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));

    Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
    gc.setFont(font);
    gc.drawText(this.getText(), paintX, paintY + 4);
}
项目:codelens-eclipse    文件:StyledTextPatcher.java   
private static Method getSetFontMethod(Object styledTextRenderer) throws NoSuchMethodException {
    // if (SET_FONT_METHOD == null) {
    Method SET_FONT_METHOD = styledTextRenderer.getClass().getDeclaredMethod("setFont",
            new Class[] { Font.class, int.class });
    SET_FONT_METHOD.setAccessible(true);
    // }
    return SET_FONT_METHOD;
}
项目:eclipse-plugin-commander    文件:KaviListColumns.java   
private Font createColumnFont(final ColumnOptions<T> options, ViewerCell cell) {
    Font font = options.getFont();
    if (font == null) {
        FontDescriptor fontDescriptor = FontDescriptor.createFrom(cell.getFont()).setStyle(options.getFontStyle());
        font = fontDescriptor.createFont(cell.getControl().getDisplay());
        options.setFont(font);
    }
    return font;
}
项目:pandionj    文件:ValueLabel.java   
private void setAutoFont(int size, String text, FontStyle ... styles) {
    Font f = FontManager.getFont(size, styles);
    while(FigureUtilities.getTextWidth(text, f) > PandionJConstants.POSITION_WIDTH-4 && size > 8) {
        size--;
        f = FontManager.getFont(size, styles);
    }
    setFont(f);
}
项目:eclipse-plugin-commander    文件:KaviList.java   
private int averageCharacterWidth(Font font) {
    int width;
    GC gc = new GC(Display.getDefault());
    gc.setFont(font);
    FontMetrics fontMetrics = gc.getFontMetrics();
    width = fontMetrics.getAverageCharWidth();
    gc.dispose();
    return width;
}
项目:openaudible    文件:FontShop.java   
private Font swapFont(Font old, Font newFont) {
    if (old == newFont)
        logger.error("font swap error.");

    if (isset(old))
        old.dispose();
    return newFont;
}