Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Device


  }

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

    Pattern pattern = null;
    if (background.getBgColor1() != null)
      gc.setBackground(background.getBgColor1());
    else if (background.getBgImage() != null) {
View Full Code Here


  public String getText() {
    return GraphicsExample.getResourceString("LineStyles"); //$NON-NLS-1$
  }

  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());

    // draw lines with caps
    gc.drawLine(3 * width / 16, 1 * height / 6, 13 * width / 16, 1 * height / 6);
    gc.setLineStyle(SWT.LINE_DASH);
    gc.drawLine(3 * width / 16, 2 * height / 6, 13 * width / 16, 2 * height / 6);
    gc.setLineStyle(SWT.LINE_DOT);
    gc.drawLine(3 * width / 16, 3 * height / 6, 13 * width / 16, 3 * height / 6);
    gc.setLineStyle(SWT.LINE_DASHDOT);
    gc.drawLine(3 * width / 16, 4 * height / 6, 13 * width / 16, 4 * height / 6);
    gc.setLineStyle(SWT.LINE_DASHDOTDOT);
    gc.drawLine(3 * width / 16, 5 * height / 6, 13 * width / 16, 5 * height / 6);

    // draw labels
    Font font = new Font(device, LineStyleTab.getPlatformFont(), 20, SWT.NORMAL);
    gc.setFont(font);

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

    String text = GraphicsExample.getResourceString("Solid"); //$NON-NLS-1$
    Point size = gc.stringExtent(text);
    gc.drawString(text, (width - size.x) / 2, 1 * height / 12, true);
    text = GraphicsExample.getResourceString("Dash"); //$NON-NLS-1$
View Full Code Here

   * @see org.eclipse.swt.examples.graphics.GraphicsTab#paint(org.eclipse.swt.graphics.GC, int, int)
   */
  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    // diameter of the circle in pixels
    int diameter = width < height ? width - 25 : height - 25;

    if (!getAnimation() && nextNumber == 0) {
      Font font = new Font(device, CountDownTab.getPlatformFontFace(1), diameter / 2, SWT.NONE);
      gc.setFont(font);

      // display "SWT"
      gc.setForeground(device.getSystemColor(SWT.COLOR_DARK_BLUE));
      gc.setTextAntialias(SWT.ON);

      // determine the dimensions of the word
      String text = GraphicsExample.getResourceString("SWT");
      Point point = gc.stringExtent(text);
      int textWidth = point.x;
      int textHeight = point.y;
      gc.drawString(text, (width - textWidth) / 2, (height - textHeight) / 2, true);
      font.dispose();

    } else {

      Font font = new Font(device, CountDownTab.getPlatformFontFace(0), 6 * diameter / 10, SWT.NONE);
      gc.setFont(font);

      // set attributes from controls
      gc.setLineWidth(lineWidthSpinner.getSelection());
      gc.setLineCap(lineCap); // round line ends
      gc.setAntialias(antialias); // smooth jagged edges
      gc.setTextAntialias(antialias); // smooth jagged edges

      // draw the circles
      Path path = new Path(device);
      path.addArc((width - diameter) / 2, (height - diameter) / 2, diameter, diameter, 0, 360);
      path
          .addArc((width - diameter + 50) / 2, (height - diameter + 50) / 2, diameter - 50, diameter - 50, 0,
              360);
      gc.drawPath(path);
      gc.setBackground(device.getSystemColor(SWT.COLOR_RED));
      gc.fillPath(path);
      path.dispose();

      Point point = gc.stringExtent(new Integer(nextNumber).toString());
      int textWidth = point.x;
      int textHeight = point.y;

      // draw the number
      gc.drawString(new Integer(nextNumber).toString(), (width - textWidth) / 2, (height - textHeight) / 2, true);

      // draw the rotating arm
      Transform transform = new Transform(device);
      transform.translate(width / 2, height / 2);
      transform.rotate(angle);
      gc.setTransform(transform);
      gc.setForeground(device.getSystemColor(SWT.COLOR_RED));
      gc.drawLine(0, 0, diameter / 2, 0);
      transform.dispose();

      font.dispose();
    }
View Full Code Here

   * @see org.eclipse.swt.examples.graphics.GraphicsTab#paint(org.eclipse.swt.graphics.GC, int, int)
   */
  public void paint(GC gc, int width, int height) {
    if (!example.checkAdvancedGraphics())
      return;
    Device device = gc.getDevice();

    if (ace_club == null) {
      ace_club = GraphicsExample.loadImage(device, GraphicsExample.class, "ace_club.jpg");
      ace_spade = GraphicsExample.loadImage(device, GraphicsExample.class, "ace_spade.jpg");
      ace_diamond = GraphicsExample.loadImage(device, GraphicsExample.class, "ace_diamond.jpg");
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, CurvesTab.getPlatformFont(), 16, SWT.ITALIC);
    gc.setFont(font);
    gc.setLineWidth(5);

    Transform transform;

    // ----- cubic curve -----
    cubXPos = width / 5;
    cubYPos = height / 3;

    transform = new Transform(device);
    transform.translate(cubXPos, cubYPos);
    gc.setTransform(transform);
    transform.dispose();

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

    Path path = new Path(device);
    path.cubicTo(133 + cubDiffX1, -60 + cubDiffY1, 266 + cubDiffX2, 60 + cubDiffY2, 400 + cubEndDiffX,
        0 + cubEndDiffY);
    gc.drawPath(path);
    path.dispose();

    gc.setTransform(null);
    gc.setForeground(device.getSystemColor(SWT.COLOR_DARK_BLUE));
    gc.drawRectangle(cubHndl1.x + (int) cubXPos, cubHndl1.y + (int) cubYPos, cubHndl1.width, cubHndl1.height);
    gc.drawRectangle(cubHndl2.x + (int) cubXPos, cubHndl2.y + (int) cubYPos, cubHndl2.width, cubHndl2.height);
    gc.drawRectangle(cubEndHndl.x + (int) cubXPos, cubEndHndl.y + (int) cubYPos, cubEndHndl.width,
        cubEndHndl.height);

    // ----- quadratic curve -----
    quadXPos = width / 5;
    quadYPos = 2 * height / 3;

    transform = new Transform(device);
    transform.translate(quadXPos, quadYPos);
    gc.setTransform(transform);
    transform.dispose();

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

    path = new Path(device);
    path.quadTo(200 + quadDiffX, 150 + quadDiffY, 400 + quadEndDiffX, 0 + quadEndDiffY);
    gc.drawPath(path);
    path.dispose();

    gc.setTransform(null);
    gc.setForeground(device.getSystemColor(SWT.COLOR_GRAY));
    gc.drawRectangle(quadHndl.x + (int) quadXPos, quadHndl.y + (int) quadYPos, quadHndl.width, quadHndl.height);
    gc.drawRectangle(quadEndHndl.x + (int) quadXPos, quadEndHndl.y + (int) quadYPos, quadEndHndl.width,
        quadEndHndl.height);

    font.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())
View Full Code Here

   * 4 gradient patterns (total of 16).
   */
  public void paint(GC gc, int width, int height) {
    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);
View Full Code Here

  }

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

    float scaleX = 10f;
    float scaleY = 10f;
    Image image = null;
    switch (imageCb.getSelectionIndex()) {
View Full Code Here

  }

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

    if (bc[0] == null) {
      bc[0] = new BallCollection(0, 0, 5, 5, 20, 20, new Color[] { device.getSystemColor(SWT.COLOR_GREEN) });
      bc[1] = new BallCollection(50, 300, 10, -5, 50, 10, new Color[] { device.getSystemColor(SWT.COLOR_BLUE) });
      bc[2] = new BallCollection(250, 100, -5, 8, 25, 12, new Color[] { device.getSystemColor(SWT.COLOR_RED) });
      bc[3] = new BallCollection(150, 400, 5, 8, 35, 14, new Color[] { device.getSystemColor(SWT.COLOR_BLACK) });
      bc[4] = new BallCollection(100, 250, -5, -18, 100, 5, new Color[] { device
          .getSystemColor(SWT.COLOR_MAGENTA) });
    }

    for (int j = 0; j < bc.length; j++)
      for (int i = 0; i < bc[j].prevx.size(); i++) {
View Full Code Here

  }

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

    // top triangle
    Path path = new Path(device);
    path.moveTo(width / 2, 0);
    path.lineTo(width / 2 + 100, 173);
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.