Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Pattern


  }

  public void paint(GC gc, int width, int height) {
    Device device = gc.getDevice();

    Pattern pattern = null;
    if (lineColor.getBgColor1() != null)
      gc.setForeground(lineColor.getBgColor1());
    else if (lineColor.getBgImage() != null) {
      pattern = new Pattern(device, lineColor.getBgImage());
      gc.setForegroundPattern(pattern);
    }

    // set line width
    gc.setLineWidth(lineWidthSpinner.getSelection());
View Full Code Here


    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    Image image = createImage(device, colorGB1.getBgColor1(), colorGB2.getBgColor1(), width, height);
    Pattern p = new Pattern(device, image);
    gc.setBackgroundPattern(p);
    gc.fillRectangle(0, 0, width, height);

    p.dispose();
    image.dispose();
  }
View Full Code Here

  Image createImage(Device device, Color color1, Color color2, int width, int height) {
    Image image = new Image(device, width / 2, height / 2);
    GC gc = new GC(image);
    Rectangle rect = image.getBounds();

    Pattern pattern1 = new Pattern(device, rect.x, rect.y, rect.width / 2f, rect.height / 2f, color1, color2);
    gc.setBackgroundPattern(pattern1);
    Path path = new Path(device);
    path.addRectangle(0, 0, width / 4f, height / 4f);
    path.addRectangle(width / 4f, height / 4f, width / 4f, height / 4f);
    gc.fillPath(path);
    path.dispose();

    Pattern pattern2 = new Pattern(device, rect.width, 0, rect.width / 2f, rect.height / 2f, color1, color2);
    gc.setBackgroundPattern(pattern2);
    path = new Path(device);
    path.addRectangle(width / 4f, 0, width / 4f, height / 4f);
    path.addRectangle(0, height / 4f, width / 4f, height / 4f);
    gc.fillPath(path);
    path.dispose();

    gc.dispose();
    pattern1.dispose();
    pattern2.dispose();
    return image;
  }
View Full Code Here

    path.addPath(path7);
    path.addPath(path8);
    path.addPath(path9);
    gc.setClipping(path);

    Pattern pattern = null;
    if (background.getBgColor1() != null)
      gc.setBackground(background.getBgColor1());
    else if (background.getBgImage() != null) {
      pattern = new Pattern(device, background.getBgImage());
      gc.setBackgroundPattern(pattern);
    }

    gc.setLineWidth(2);
    gc.fillRectangle((width - rectWidth) / 2, (height - rectHeight) / 2, rectWidth, rectHeight);
    gc.drawPath(path);

    if (pattern != null)
      pattern.dispose();

    path9.dispose();
    path8.dispose();
    path7.dispose();
    path6.dispose();
View Full Code Here

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

    Pattern pattern = null;
    if (fillColor.getBgColor1() != null)
      gc.setBackground(fillColor.getBgColor1());
    else if (fillColor.getBgImage() != null) {
      pattern = new Pattern(device, fillColor.getBgImage());
      gc.setBackgroundPattern(pattern);
    }

    gc.setLineWidth(5);
    gc.setForeground(device.getSystemColor(SWT.COLOR_BLACK));

    // arc
    Path path = new Path(device);
    path.addArc((width - 250) / 2, (height - 400) / 2, 500, 400, 90, 180);
    if (closeButton.getSelection())
      path.close();
    if (fillButton.getSelection())
      gc.fillPath(path);
    if (drawButton.getSelection())
      gc.drawPath(path);
    path.dispose();

    // shape on left
    Transform transform = new Transform(device);
    transform.translate((width - 250) / 4, height / 2 - 150);
    gc.setTransform(transform);
    transform.dispose();
    path = new Path(device);
    path.cubicTo(-150, 100, 150, 200, 0, 300);
    if (closeButton.getSelection())
      path.close();
    if (fillButton.getSelection())
      gc.fillPath(path);
    if (drawButton.getSelection())
      gc.drawPath(path);
    path.dispose();
    gc.setTransform(null);

    // shape on right
    path = new Path(device);
    path.moveTo(3 * (width - 250) / 4 - 25 + 250, height / 2);
    path.lineTo(3 * (width - 250) / 4 + 50 + 250, height / 2 - 200);
    path.lineTo(3 * (width - 250) / 4 + 50 + 250, height / 2 + 50);
    path.lineTo(3 * (width - 250) / 4 - 25 + 250, height / 2 + 150);
    path.lineTo(3 * (width - 250) / 4 + 25 + 250, height / 2 + 50);
    if (closeButton.getSelection())
      path.close();
    if (fillButton.getSelection())
      gc.fillPath(path);
    if (drawButton.getSelection())
      gc.drawPath(path);
    path.dispose();

    if (pattern != null)
      pattern.dispose();
  }
View Full Code Here

    gc.setTransform(transform);
    transform.dispose();

    Path path = new Path(device);
    path.addRectangle(0, 0, width, 50);
    Pattern pattern = new Pattern(device, 0, 0, width, 50, device.getSystemColor(SWT.COLOR_BLUE), 0x7f, device
        .getSystemColor(SWT.COLOR_RED), 0x7f);
    gc.setBackgroundPattern(pattern);
    gc.fillPath(path);
    gc.drawPath(path);
    path.dispose();

    // vertical rectangle
    transform = new Transform(device);
    transform.translate(translateX, 0);
    gc.setTransform(transform);
    transform.dispose();

    path = new Path(device);
    path.addRectangle(0, 0, 50, height);
    pattern.dispose();
    pattern = new Pattern(device, 0, 0, 50, height, device.getSystemColor(SWT.COLOR_DARK_CYAN), 0x7f, device
        .getSystemColor(SWT.COLOR_WHITE), 0x7f);
    gc.setBackgroundPattern(pattern);
    gc.fillPath(path);
    gc.drawPath(path);
    path.dispose();

    // diagonal rectangle from bottom right corner
    Rectangle rect = new Rectangle(0, 0, 50, height);
    transform = new Transform(device);
    transform.translate(width - diagTranslateX1, height / 2 - diagTranslateY1);

    // rotate on center of rectangle
    transform.translate(rect.width / 2, rect.height / 2);
    transform.rotate(45);
    transform.translate(-rect.width / 2, -rect.height / 2);
    gc.setTransform(transform);
    transform.dispose();

    path = new Path(device);
    path.addRectangle(rect.x, rect.y, rect.width, rect.height);
    pattern.dispose();
    pattern = new Pattern(device, rect.x, rect.y, rect.width, rect.height, device
        .getSystemColor(SWT.COLOR_DARK_GREEN), 0x7f, device.getSystemColor(SWT.COLOR_DARK_MAGENTA), 0x7f);
    gc.setBackgroundPattern(pattern);
    gc.fillPath(path);
    gc.drawPath(path);
    path.dispose();

    // diagonal rectangle from top right corner
    transform = new Transform(device);
    transform.translate(width - diagTranslateX2, height / 2 - diagTranslateY2);

    // rotate on center of rectangle
    transform.translate(rect.width / 2, rect.height / 2);
    transform.rotate(-45);
    transform.translate(-rect.width / 2, -rect.height / 2);
    gc.setTransform(transform);
    transform.dispose();

    path = new Path(device);
    path.addRectangle(rect.x, rect.y, rect.width, rect.height);
    pattern.dispose();
    pattern = new Pattern(device, rect.x, rect.y, rect.width, rect.height, device
        .getSystemColor(SWT.COLOR_DARK_RED), 0x7f, device.getSystemColor(SWT.COLOR_YELLOW), 0x7f);
    gc.setBackgroundPattern(pattern);
    gc.fillPath(path);
    gc.drawPath(path);
    pattern.dispose();
    path.dispose();
  }
View Full Code Here

TOP

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

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.