Example usage for org.eclipse.swt.graphics FontData toString

List of usage examples for org.eclipse.swt.graphics FontData toString

Introduction

In this page you can find the example usage for org.eclipse.swt.graphics FontData toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the receiver which is suitable for constructing an equivalent instance using the FontData(String) constructor.

Usage

From source file:org.eclipse.swt.snippets.Snippet367.java

private static void paintImage2(GC gc, Point size, int f) {
    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.fillRectangle(0, 0, size.x, size.y);

    // Scale line width, corner roundness, and font size.
    // Caveat: line width expands in all directions, so the origin also has to move.

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
    gc.fillRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.setLineWidth(f);/*from   w  w w.  jav a  2  s  . c  o  m*/
    gc.drawRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);
    FontData fontData = gc.getFont().getFontData()[0];
    fontData.setHeight(fontData.getHeight() * f);
    Font font = new Font(gc.getDevice(), fontData);
    try {
        gc.setFont(font);
        gc.drawText(fontData.toString(), 10 * f, 10 * f, true);
    } finally {
        font.dispose();
    }
}