Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.GC


    return selectedServicesList;
  }

  protected void initializeDialogUnits(Control testControl) {
    // Compute and store a font metric
    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fontMetrics = gc.getFontMetrics();
    gc.dispose();
  }
View Full Code Here


    }

    private Image resizeImage(Image oldImage, int newWidth, int newHeight) {
      Image newImage = new Image(Display.getDefault(), newWidth, newHeight);
      GC gc = new GC(newImage);
      gc.setAntialias(SWT.ON);
      gc.setInterpolation(SWT.HIGH);
      gc.drawImage(oldImage, 0, 0, oldImage.getBounds().width, oldImage.getBounds().height, 0, 0, newWidth,
          newHeight);
      gc.dispose();
      oldImage.dispose();
      return newImage;
    }
View Full Code Here

      }
    });

    this.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        GC gc = e.gc;
       
        gc.setBackground(success ? green : red);
        gc.fillRectangle(0, 0, getFillWidth(), getBounds().height);
      }
    });
  }
View Full Code Here

 
  private static FontMetrics fontMetrics;

  protected static void initializeDialogUnits(Control testControl) {
    // Compute and store a font metric
    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fontMetrics = gc.getFontMetrics();
    gc.dispose();
  }
View Full Code Here

    private Image drawType(final int type) {

        final Image img = new Image(Display.getCurrent(), new Rectangle(2, 3, 12, 12));

        final GC graphic = new GC(img);

        Color color;
        switch (type) {
        case TestTreeObject.WARN:
            color = new Color(Display.getCurrent(), 255, 255, 100);
            break;
        case TestTreeObject.SUCCESS:
            color = new Color(Display.getCurrent(), 60, 140, 10);
            break;
        case TestTreeObject.FAILOURE:
            color = new Color(Display.getCurrent(), 180, 20, 20);
            break;
        default:
            color = new Color(Display.getCurrent(), 255, 255, 255);
        }

        graphic.setForeground(color);
        graphic.setBackground(color);
        graphic.fillRectangle(0, 0, 12, 12);

        return img;
    }
View Full Code Here

    private Image drawPercentage(final double percentage) {

        final Image img = new Image(Display.getCurrent(), new Rectangle(2, 3, 20, 8));

        final GC graphic = new GC(img);
        graphic.setForeground(new Color(Display.getCurrent(), 60, 140, 10));
        graphic.setBackground(new Color(Display.getCurrent(), 60, 140, 10));
        graphic.drawRectangle(0, 0, 18, 6);
        graphic.fillRectangle(1, 1, (int) (17 * percentage / 100), 5);

        return img;
    }
View Full Code Here

    public ColorEditor(final Composite parent) {
        fButton = new Button(parent, SWT.PUSH);
        fExtent = computeImageSize(parent);
        fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y);

        final GC gc = new GC(fImage);
        gc.setBackground(fButton.getBackground());
        gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
        gc.dispose();

        fButton.setImage(fImage);
        fButton.addSelectionListener(new SelectionAdapter() {

            @Override
View Full Code Here

     */
    protected void updateColorImage() {

        final Display display = fButton.getDisplay();

        final GC gc = new GC(fImage);
        gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
        gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);

        if (fColor != null) {
            fColor.dispose();
        }

        fColor = new Color(display, fColorValue);
        gc.setBackground(fColor);
        gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
        gc.dispose();

        fButton.setImage(fImage);
    }
View Full Code Here

     * @param window
     *            the window on which to render the image
     * @return the point with the image size
     */
    protected Point computeImageSize(final Control window) {
        final GC gc = new GC(window);
        final Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
        gc.setFont(f);
        final int height = gc.getFontMetrics().getHeight();
        gc.dispose();
        final Point p = new Point(height * 3 - 6, height);
        return p;
    }
View Full Code Here

public class PixelConverter {

    private final FontMetrics fFontMetrics;

    public PixelConverter(final Control control) {
        final GC gc = new GC(control);
        gc.setFont(control.getFont());
        fFontMetrics = gc.getFontMetrics();
        gc.dispose();
    }
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.