Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.GC


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

        final GC gc = new GC(drawable);
        try {

            final StringBuffer buffer = new StringBuffer();
            int maxNumberOfLines = Math.round((float) maxHeight
                    / (float) gc.getFontMetrics().getHeight());

            fCounter = 0;
            final LineBreakingReader reader = new LineBreakingReader(createReader(
                    hoverInfo, presentation), gc, maxWidth);

            boolean lastLineFormatted = false;
            String lastLineIndent = null;

            String line = reader.readLine();
            boolean lineFormatted = reader.isFormattedLine();
            boolean firstLineProcessed = false;

            while (line != null) {

                if (fEnforceUpperLineLimit && maxNumberOfLines <= 0) {
                    break;
                }

                if (firstLineProcessed) {
                    if (!lastLineFormatted) {
                        append(buffer, LINE_DELIM, null);
                    } else {
                        append(buffer, LINE_DELIM, presentation);
                        if (lastLineIndent != null) {
                            append(buffer, lastLineIndent, presentation);
                        }
                    }
                }

                append(buffer, line, null);
                firstLineProcessed = true;

                lastLineFormatted = lineFormatted;
                if (!lineFormatted) {
                    lastLineIndent = null;
                } else if (lastLineIndent == null) {
                    lastLineIndent = getIndent(line);
                }

                line = reader.readLine();
                lineFormatted = reader.isFormattedLine();

                maxNumberOfLines--;
            }

            if (line != null) {
                append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
            }
            return trim(buffer, presentation);

        } catch (final IOException e) {
            // ignore TODO do something else?
            return null;
        } finally {
            gc.dispose();
        }
    }
View Full Code Here


     */
    private void createUIWidgetFilterText(final Composite parent) {
        // Create the widget
        fFilterText = new Text(parent, SWT.NONE);
        // Set the font
        final GC gc = new GC(parent);
        gc.setFont(parent.getFont());
        final FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();
        // Create the layout
        final GridData data = new GridData(GridData.FILL_HORIZONTAL);
        data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.CENTER;
View Full Code Here

    public Point computeSizeConstraints(final int widthInChars, final int heightInChars) {
        if (fSymbolicFontName == null) {
            return null;
        }

        final GC gc = new GC(fBrowser);
        final Font font = fSymbolicFontName == null ? JFaceResources.getDialogFont()
                : JFaceResources.getFont(fSymbolicFontName);
        gc.setFont(font);
        final int width = gc.getFontMetrics().getAverageCharWidth();
        final int height = gc.getFontMetrics().getHeight();
        gc.dispose();

        return new Point(widthInChars * width, heightInChars * height);
    }
View Full Code Here

     */
    private static Image getMissingImage() {
        final Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE,
                MISSING_IMAGE_SIZE);
        //
        final GC gc = new GC(image);
        gc.setBackground(getColor(SWT.COLOR_RED));
        gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
        gc.dispose();
        //
        return image;
    }
View Full Code Here

            final Rectangle bib = baseImage.getBounds();
            final Rectangle dib = decorator.getBounds();
            //
            result = new Image(Display.getCurrent(), bib.width, bib.height);
            //
            final GC gc = new GC(result);
            gc.drawImage(baseImage, 0, 0);
            if (corner == TOP_LEFT) {
                gc.drawImage(decorator, 0, 0);
            } else if (corner == TOP_RIGHT) {
                gc.drawImage(decorator, bib.width - dib.width, 0);
            } else if (corner == BOTTOM_LEFT) {
                gc.drawImage(decorator, 0, bib.height - dib.height);
            } else if (corner == BOTTOM_RIGHT) {
                gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
            }
            gc.dispose();
            //
            decoratedMap.put(decorator, result);
        }
        return result;
    }
View Full Code Here

            if (screenImage != null) {
                screenImage.dispose();
            }
            screenImage = new Image(getDisplay(), clientRect.width, clientRect.height);
            final GC newGC = new GC(screenImage);
            newGC.setClipping(clientRect);
            newGC.drawImage(sourceImage, imageRect.x, imageRect.y, imageRect.width,
                    imageRect.height, destRect.x, destRect.y, destRect.width,
                    destRect.height);
            newGC.dispose();

            gc.drawImage(screenImage, 0, 0);
        } else {
            gc.setClipping(clientRect);
            gc.fillRectangle(clientRect);
View Full Code Here

        int columnWidth = -1;

        for (int i = 0; i < names.length; ++i) {
            if (i == 0) {
                // Compute and store a font metric
                final GC gc = new GC(tree);
                gc.setFont(tree.getFont());
                final FontMetrics fontMetrics = gc.getFontMetrics();
                gc.dispose();
                columnWidth = Math.max(100, fontMetrics.getAverageCharWidth() * 20);
            }

            // if (columnWidths != null) {
            // final Integer value = columnWidths.getInteger(getFieldId(column
View Full Code Here

        textField = getTextControl(parent);
        GridData gd = new GridData();
        gd.horizontalSpan = numColumns - 1;
        if (widthInChars != UNLIMITED) {
            GC gc = new GC(textField);
            try {
                Point extent = gc.textExtent("X");//$NON-NLS-1$
                gd.widthHint = widthInChars * extent.x;
            } finally {
                gc.dispose();
            }
        } else {
            gd.horizontalAlignment = GridData.FILL;
            gd.grabExcessHorizontalSpace = true;
        }
View Full Code Here

     * @param control the control being sized
     * @param dlus the number of horizontal dialog units
     * @return the number of pixels
     */
    protected int convertHorizontalDLUsToPixels(Control control, int dlus) {
        GC gc = new GC(control);
        gc.setFont(control.getFont());
        int averageWidth = gc.getFontMetrics().getAverageCharWidth();
        gc.dispose();

        double horizontalDialogUnitSize = averageWidth * 0.25;

        return (int) Math.round(dlus * horizontalDialogUnitSize);
    }
View Full Code Here

     * @param control the control being sized
     * @param dlus the number of vertical dialog units
     * @return the number of pixels
     */
    protected int convertVerticalDLUsToPixels(Control control, int dlus) {
        GC gc = new GC(control);
        gc.setFont(control.getFont());
        int height = gc.getFontMetrics().getHeight();
        gc.dispose();

        double verticalDialogUnitSize = height * 0.125;

        return (int) Math.round(dlus * verticalDialogUnitSize);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.GC

Copyright © 2018 www.massapicom. 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.