Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Device


  @Override
  protected void addSelectionHandles() {
    super.addSelectionHandles();
    PolylineConnection connection = getConnectionFigure();
    color = connection.getForegroundColor();
    Device device = color.getDevice();
    int red = (255 - color.getRed()) / 2;
    int green = (255 - color.getGreen()) / 2;
    int blue = (255 - color.getBlue()) / 2;
    connection.setForegroundColor(new Color(device, red, green, blue));
  }
View Full Code Here


     *
     * @since 3.1
     */
    public ImageRegistry(ResourceManager manager) {
        Assert.isNotNull(manager);
        Device dev = manager.getDevice();
        if (dev instanceof Display) {
            this.display = (Display)dev;
        }
        this.manager = manager;
        manager.disposeExec(disposeRunnable);
View Full Code Here

                    // update the plugin list that's in the base path
                    pluginManager.updatePluginList (localRepoPath.getText(), metadata);
                }
                catch (Exception e) {
                    pluginCreatedStatus.setText(CommonMessages.bind(CommonMessages.failedToSave, createPluginCombo.getItem(createPluginCombo.getSelectionIndex())));
                    Device device = pluginCreatedStatus.getForeground().getDevice();
                    Color color = new Color (device, 255, 0, 0);
                    pluginCreatedStatus.setForeground(color);
                    success = false;
                }
                if (success == true) {
                    pluginCreatedStatus.setText(CommonMessages.bind (CommonMessages.savedSuccess, createPluginCombo.getItem(createPluginCombo.getSelectionIndex())));
                    Device device = pluginCreatedStatus.getForeground().getDevice();
                    Color color = new Color (device, 0, 0, 0);
                    pluginCreatedStatus.setForeground(color);
                }
                pageVisible = 0;
                break;
View Full Code Here

  }

  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    int size = 100;

    gc.setLineWidth(2);

    // ----- cube -----

    Transform transform = new Transform(device);
    transform.translate(width / 4 - size, height / 4 + -upDownValue);
    gc.setTransform(transform);

    gc.setLineStyle(SWT.LINE_DOT);

    // fill in left face
    gc.setBackground(device.getSystemColor(SWT.COLOR_RED));
    gc.fillPolygon(new int[] { 0, 0, size / 3, -size / 2, size / 3, size / 2, 0, size });

    gc.setLineStyle(SWT.LINE_SOLID);

    // square
    gc.drawRectangle(0, 0, size, size);

    // next 3 solid lines
    gc.drawLine(0, 0, size / 3, -size / 2); // left
    gc.drawLine(size, 0, 4 * size / 3, -size / 2); // middle
    gc.drawLine(size, size, 4 * size / 3, size / 2); // right

    // 2 furthest solid lines
    gc.drawLine(size / 3, -size / 2, 4 * size / 3, -size / 2); // horizontal
    gc.drawLine(4 * size / 3, size / 2, 4 * size / 3, -size / 2); // vertical

    // 3 dotted lines
    gc.setLineStyle(SWT.LINE_DOT);
    gc.drawLine(0, size, size / 3, size / 2);
    gc.drawLine(size / 3, -size / 2, size / 3, size / 2);
    gc.drawLine(4 * size / 3, size / 2, size / 3, size / 2);

    // fill right side of cube
    gc.setBackground(device.getSystemColor(SWT.COLOR_GRAY));
    gc.fillPolygon(new int[] { size, 0, 4 * size / 3, -size / 2, 4 * size / 3, size / 2, size, size });

    transform.dispose();

    // ----- pyramid -----

    transform = new Transform(device);
    transform.translate(width / 2 + size / 2, height / 4 + size + upDownValue);
    gc.setTransform(transform);

    // fill back of pyramid
    gc.fillPolygon(new int[] { size / 3, -size / 2, 6 * size / 10, -5 * size / 4, 4 * size / 3, -size / 2 });

    // fill left side of pyramid
    gc.setBackground(device.getSystemColor(SWT.COLOR_GREEN));
    gc.fillPolygon(new int[] { 0, 0, 6 * size / 10, -5 * size / 4, size / 3, -size / 2 });

    // select solid line style
    gc.setLineStyle(SWT.LINE_SOLID);

    // 2 solid lines of base
    gc.drawLine(0, 0, size, 0);
    gc.drawLine(size, 0, 4 * size / 3, -size / 2);

    // 3 solid lines of pyramid
    gc.drawLine(0, 0, 6 * size / 10, -5 * size / 4);
    gc.drawLine(size, 0, 6 * size / 10, -5 * size / 4);
    gc.drawLine(4 * size / 3, -size / 2, 6 * size / 10, -5 * size / 4);

    // select dot line style
    gc.setLineStyle(SWT.LINE_DOT);

    // 3 dotted lines
    gc.drawLine(0, 0, size / 3, -size / 2); // left
    gc.drawLine(size / 3, -size / 2, 6 * size / 10, -5 * size / 4); // to top of pyramid
    gc.drawLine(4 * size / 3, -size / 2, size / 3, -size / 2); // right

    transform.dispose();

    // ----- rectangular prism -----

    transform = new Transform(device);
    transform.translate(width / 2 + upDownValue, height / 2 + size);
    gc.setTransform(transform);

    // fill bottom
    gc.setBackground(device.getSystemColor(SWT.COLOR_BLUE));
    gc.fillPolygon(new int[] { 0, size, size / 3, size / 2, 7 * size / 3, size / 2, 2 * size, size });

    // select solid line style
    gc.setLineStyle(SWT.LINE_SOLID);

    gc.drawRectangle(0, 0, 2 * size, size);

    // next 3 solid lines
    gc.drawLine(0, 0, size / 3, -size / 2); // left
    gc.drawLine(2 * size, 0, 7 * size / 3, -size / 2); // middle
    gc.drawLine(2 * size, size, 7 * size / 3, size / 2); // right

    // 2 furthest solid lines
    gc.drawLine(size / 3, -size / 2, 7 * size / 3, -size / 2); // horizontal
    gc.drawLine(7 * size / 3, size / 2, 7 * size / 3, -size / 2); // vertical

    // 3 dotted lines
    gc.setLineStyle(SWT.LINE_DASHDOTDOT);
    gc.drawLine(0, size, size / 3, size / 2);
    gc.drawLine(size / 3, -size / 2, size / 3, size / 2);
    gc.drawLine(7 * size / 3, size / 2, size / 3, size / 2);

    // fill top
    gc.setBackground(device.getSystemColor(SWT.COLOR_GRAY));
    gc.fillPolygon(new int[] { 0, 0, size / 3, -size / 2, 7 * size / 3, -size / 2, 2 * size, 0 });

    transform.dispose();

    // ----- triangular shape -----
    transform = new Transform(device);
    transform.translate(width / 4 - size - upDownValue, height / 2 + size + upDownValue);
    gc.setTransform(transform);

    // fill back of shape (top left)
    gc.setBackground(device.getSystemColor(SWT.COLOR_YELLOW));
    gc.fillPolygon(new int[] { 0, 0, size / 2, -size, size / 2, -size / 3 });

    // fill back of shape (bottom right)
    gc.fillPolygon(new int[] { size, 0, size / 2, size, size / 2, -size / 3 });

View Full Code Here

  }

  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    gc.setLineWidth(20);
    gc.setLineJoin(joinValues[joinCb.getSelectionIndex()]);

    // set the foreground color or pattern
View Full Code Here

  }

  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    Font font = new Font(device, CurvesSWTTab.getPlatformFont(), 16, SWT.ITALIC);
    gc.setFont(font);
    gc.setLineWidth(2);

    Transform transform;

    // ----- letter s -----
    sXPos = 4 * width / 16;
    sYPos = (height - 150) / 2;

    transform = new Transform(device);
    transform.translate(sXPos, sYPos);
    gc.setTransform(transform);
    transform.dispose();

    gc.setForeground(device.getSystemColor(SWT.COLOR_DARK_BLUE));
    gc.drawString(GraphicsExample.getResourceString("Cubic"), 0, 175, true);

    Path path = new Path(device);
    path.cubicTo(-200 + sDiffX1, 50 + sDiffY1, 200 + sDiffX2, 100 + sDiffY2, 0, 150);
    gc.drawPath(path);
    path.dispose();

    // draw the spline points
    gc.setTransform(null);
    gc.drawRectangle(sRect1.x + (int) sXPos, sRect1.y + (int) sYPos, sRect1.width, sRect1.height);
    gc.drawRectangle(sRect2.x + (int) sXPos, sRect2.y + (int) sYPos, sRect2.width, sRect2.height);

    // ----- letter w -----
    wXPos = 6 * width / 16;
    wYPos = (height - 150) / 2;

    transform = new Transform(device);
    transform.translate(wXPos, wYPos);
    gc.setTransform(transform);
    transform.dispose();

    gc.setForeground(device.getSystemColor(SWT.COLOR_GRAY));
    gc.drawString(GraphicsExample.getResourceString("Quadratic"), 0, -50, true);
    gc.drawString(GraphicsExample.getResourceString("Quadratic"), 110, -50, true);

    path = new Path(device);
    path.quadTo(100 + wDiffX1, 300 + wDiffY1, 100, 0);
    path.quadTo(100 + wDiffX2, 300 + wDiffY2, 200, 0);
    gc.drawPath(path);
    path.dispose();

    gc.setTransform(null);
    gc.drawRectangle(wRect1.x + (int) wXPos, wRect1.y + (int) wYPos, wRect1.width, wRect1.height);
    gc.drawRectangle(wRect2.x + (int) wXPos, wRect2.y + (int) wYPos, wRect2.width, wRect2.height);

    // ----- top of letter t -----
    topTXPos = 11 * width / 16;
    topTYPos = (height - 150) / 2;

    transform = new Transform(device);
    transform.translate(topTXPos, topTYPos);
    gc.setTransform(transform);
    transform.dispose();

    gc.setForeground(device.getSystemColor(SWT.COLOR_YELLOW));
    gc.drawString(GraphicsExample.getResourceString("Cubic"), 25, -50, true);

    path = new Path(device);
    path.cubicTo(33 + tTopDiffX1, -20 + tTopDiffY1, 66 + tTopDiffX2, 20 + tTopDiffY2, 100, 0);
    gc.drawPath(path);
    path.dispose();

    gc.setTransform(null);
    gc.drawRectangle(tTopRect1.x + (int) topTXPos, tTopRect1.y + (int) topTYPos, tTopRect1.width, tTopRect1.height);
    gc.drawRectangle(tTopRect2.x + (int) topTXPos, tTopRect2.y + (int) topTYPos, tTopRect2.width, tTopRect2.height);

    // ----- vertical bar of letter t -----
    botTXPos = 12 * width / 16;
    botTYPos = (height - 150) / 2;

    transform = new Transform(device);
    transform.translate(botTXPos, botTYPos);
    gc.setTransform(transform);
    transform.dispose();

    gc.setForeground(device.getSystemColor(SWT.COLOR_RED));
    gc.drawString(GraphicsExample.getResourceString("Cubic"), 0, 175, true);

    path = new Path(device);
    path.cubicTo(-33 + tBotDiffX1, 50 + tBotDiffY1, 33 + tBotDiffX2, 100 + tBotDiffY2, 0, 150);
    gc.drawPath(path);
View Full Code Here

  }

  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    int clipping = clippingCb.getSelectionIndex();
    switch (clipping) {

    case 0: // circles
View Full Code Here

  }

  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    Image image = GraphicsExample.loadImage(device, GraphicsExample.class, "houses.png");
    Rectangle bounds = image.getBounds();

    // top
View Full Code Here

    canvas = new Canvas(parent, style);
    canvas.addListener(SWT.Paint, new Listener() {
      public void handleEvent(Event event) {
        GC gc = event.gc;
        Rectangle rect = canvas.getClientArea();
        Device device = gc.getDevice();
        Pattern pattern = null;
        if (background.getBgColor1() != null) {
          if (background.getBgColor2() != null) { // gradient
            pattern = new Pattern(device, 0, 0, rect.width, rect.height, background.getBgColor1(),
                background.getBgColor2());
View Full Code Here

   * (non-Javadoc)
   *
   * @see org.eclipse.swt.examples.graphics.GraphicsTab#paint(org.eclipse.swt.graphics.GC, int, int)
   */
  public void paint(GC gc, int width, int height) {
    Device device = gc.getDevice();

    if (image == null)
      image = example.loadImage(device, "maze.bmp");
    // draw maze
    Rectangle bounds = image.getBounds();
    int x = (width - bounds.width) / 2;
    int y = (height - bounds.height) / 2;
    gc.drawImage(image, x, y);

    // draw correct oval
    gc.setBackground(device.getSystemColor(SWT.COLOR_RED));
    gc.fillOval(x + xcoord, y + ycoord, 16, 16);
    gc.drawOval(x + xcoord, y + ycoord, 15, 15);

    // draw wrong oval 1
    gc.setBackground(device.getSystemColor(SWT.COLOR_BLUE));
    gc.fillOval(x + xcoord2, y + ycoord2, 16, 16);
    gc.drawOval(x + xcoord2, y + ycoord2, 15, 15);

    // draw wrong oval 2
    gc.setBackground(device.getSystemColor(SWT.COLOR_GREEN));
    gc.fillOval(x + xcoord3, y + ycoord3, 16, 16);
    gc.drawOval(x + xcoord3, y + ycoord3, 15, 15);

    if (isDone2) {
      Image helpImg = example.loadImage(device, "help.gif");
View Full Code Here

TOP

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

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.