Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.GC.stringExtent()


            String text = item.getName();
            String info = getInfo();

            GC gc = new GC(this);
            Point extentText = gc.stringExtent(text);
            Point extentInfo = gc.stringExtent(info);
            gc.dispose();

            return new Point(Math.max(extentText.x, extentInfo.x) + 4, extentText.y + extentInfo.y + 4);
        }
View Full Code Here


                    double angleRad = (startAngle + arcAngle / 2) * Math.PI / 180.0d;
                    int x = (size.x / 2) + (int) (radius / 1.2 * Math.cos(-angleRad));
                    int y = (size.y / 2) + (int) (radius / 1.2 * Math.sin(-angleRad));

                    String label = String.format("%,.2f%%", (double) slice.getValue() / total * 100); //$NON-NLS-1$
                    Point extend = gc.stringExtent(label);
                    gc.setForeground(Colors.getTextColor(slice.getColor()));
                    gc.drawString(label, x - extend.x / 2, y - extend.y / 2, true);

                    // label
                    x = (size.x / 2) + (int) ((radius + 10) * Math.cos(-angleRad));
 
View Full Code Here

                    // label
                    x = (size.x / 2) + (int) ((radius + 10) * Math.cos(-angleRad));
                    y = (size.y / 2) + (int) ((radius + 10) * Math.sin(-angleRad));

                    extend = gc.stringExtent(slice.getLabel());
                    if (x < centerX)
                        x -= extend.x;

                    gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
                    gc.drawString(slice.getLabel(), x, y - extend.y / 2, true);
View Full Code Here

        {
            int width = 0, height = 0;
            if (text != null)
            {
                GC gc = new GC(this);
                Point extent = gc.stringExtent(text);
                gc.dispose();
                width += extent.x;
                height = Math.max(height, extent.y);
            }
            if (image != null)
View Full Code Here

            data.left = new FormAttachment(50, 5);
            data.right = new FormAttachment(100);
            valueLatestPrices.setLayoutData(data);

            GC gc = new GC(composite);
            Point extentText = gc.stringExtent("YYYY-MM-DD"); //$NON-NLS-1$
            gc.dispose();
            below(valueLatestPrices, labelLatestTrade, valueLatestTrade, extentText.x);

            below(valueLatestTrade, labelDaysHigh, valueDaysHigh, SWT.DEFAULT);
            below(valueDaysHigh, labelDaysLow, valueDaysLow, SWT.DEFAULT);
View Full Code Here

    public int getWidth(FontContext context, FSFont font, String string) {
        GC gc = ((SWTFontContext) context).getGC();
        Font previous = gc.getFont();
        gc.setFont(((SWTFSFont) font).getSWTFont());
        int width = gc.stringExtent(string).x;
        gc.setFont(previous);
        return width;
    }

    public float getFontScale() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.