Example usage for org.eclipse.jface.resource FontDescriptor destroyFont

List of usage examples for org.eclipse.jface.resource FontDescriptor destroyFont

Introduction

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

Prototype

public abstract void destroyFont(Font previouslyCreatedFont);

Source Link

Document

Deallocates anything that was allocated by createFont, given a font that was allocated by an equal FontDescriptor.

Usage

From source file:com.synflow.cx.ui.annotations.CxImageProvider.java

License:Open Source License

@Override
public Image getManagedImage(Annotation annotation) {
    IMarker marker = ((MarkerAnnotation) annotation).getMarker();

    Device device = Display.getCurrent();
    int index = marker.getAttribute("index", 0);
    Image image = images.get(index);
    if (image == null) {
        image = new Image(device, 16, 16);
        images.put(index, image);//  w w  w. j av a 2  s  .  com

        Color color = new Color(device, 248, 248, 248);
        GC gc = new GC(image);
        gc.setBackground(color);
        gc.fillRectangle(0, 0, 16, 15);
        color.dispose();

        FontDescriptor fd = FontDescriptor.createFrom(gc.getFont()).setHeight(7);

        Font font = fd.createFont(device);
        gc.setFont(font);
        gc.setForeground(ViewsConstants.SELECTION_COLOR);
        gc.drawText(String.valueOf(index + 1), 2, 0);
        fd.destroyFont(font);

        gc.dispose();
    }

    return image;
}

From source file:org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.handler.AddAnalysisDialog.java

License:Open Source License

private static void createSubtitleLabel(Composite parent, String text) {
    final Label label = new Label(parent, SWT.WRAP);
    label.setText(text + ':');
    final FontDescriptor boldDescriptor = FontDescriptor.createFrom(parent.getFont()).setStyle(SWT.BOLD);
    final Font boldFont = boldDescriptor.createFont(parent.getDisplay());
    label.setFont(boldFont);//w w  w  . j  ava2s .  c  o m
    label.addDisposeListener(event -> boldDescriptor.destroyFont(boldFont));
}

From source file:org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.handler.AddAnalysisDialog.java

License:Open Source License

private static Label createErrorLabel(Composite parent) {
    final Label label = new Label(parent, SWT.WRAP);
    Color color = new Color(parent.getDisplay(), 0xe7, 0x4c, 0x3c);
    label.setForeground(color);//w w w.  ja v  a2s .  com
    final FontDescriptor fd = FontDescriptor.createFrom(parent.getFont());
    Font font = fd.createFont(parent.getDisplay());
    label.setFont(font);

    label.addDisposeListener(e -> {
        color.dispose();
        fd.destroyFont(font);
    });

    return label;
}