Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Path


    int lw = ((int) (getPositionedContextButton().getLineWidth() * getZoomLevel()));
    graphics.setLineWidth(lw);
    graphics.setAntialias(SWT.ON);
    graphics.setAlpha((int) (getAdjustedOpacity() * 255));

    Path pathOuterLine = createPath(1);
    Path pathMiddleLine = createPath(2);
    Path pathFill = createPath(3);

    graphics.setBackgroundColor(getAdjustedColor(getPositionedContextButton().getFillColor()));
    graphics.fillPath(pathFill);
    graphics.setForegroundColor(getAdjustedColor(getPositionedContextButton().getMiddleLineColor()));
    graphics.drawPath(pathMiddleLine);
    graphics.setForegroundColor(getAdjustedColor(getPositionedContextButton().getOuterLineColor()));
    graphics.drawPath(pathOuterLine);

    pathOuterLine.dispose();
    pathMiddleLine.dispose();
    pathFill.dispose();
    pathOuterLine = null;
    pathMiddleLine = null;
    pathFill = null;

    // change opacity for image (never transparent)
View Full Code Here


    // adjust corner for the inner path (formula found by experimenting)
    double zoomedCorner = (getPositionedContextButton().getCornerRadius() * zoom);
    int corner = (int) Math.max(1, zoomedCorner - (((shrinkLines - 1) * lw) + zoomedCorner / 64));

    Path path = new Path(null);
    path.moveTo(r.x, r.y);
    path.addArc(r.x, r.y, corner, corner, 90, 90);
    path.addArc(r.x, r.y + r.height - corner, corner, corner, 180, 90);
    path.addArc(r.x + r.width - corner, r.y + r.height - corner, corner, corner, 270, 90);
    path.addArc(r.x + r.width - corner, r.y, corner, corner, 0, 90);
    path.close();

    return path;
  }
View Full Code Here

      pattern = new Pattern(device, shapeColor.getBgImage());
      gc.setForegroundPattern(pattern);
    }

    // draw the shape
    Path path = new Path(device);
    path.moveTo(width / 2, 25);
    path.lineTo(2 * width / 3, height / 3);
    path.lineTo(width - 25, height / 2);
    path.lineTo(2 * width / 3, 2 * height / 3);
    path.lineTo(width / 2, height - 25);
    path.lineTo(width / 3, 2 * height / 3);
    path.lineTo(25, height / 2);
    path.lineTo(width / 3, height / 3);
    path.lineTo(width / 2, 25);
    path.close();
    gc.drawPath(path);
    path.dispose();

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

    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);
    path.dispose();

    gc.setTransform(null);
    gc.drawRectangle(tBottomRect1.x + (int) botTXPos, tBottomRect1.y + (int) botTYPos, tBottomRect1.width,
        tBottomRect1.height);
    gc.drawRectangle(tBottomRect2.x + (int) botTXPos, tBottomRect2.y + (int) botTYPos, tBottomRect2.width,
View Full Code Here

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

    case 0: // circles
      Path path = new Path(device);
      path.addArc((width - width / 5) / 2, (height - height / 5) / 2, width / 5, height / 5, 0, 360);
      path.addArc(5 * (width - width / 8) / 12, 4 * (height - height / 8) / 12, width / 8, height / 8, 0, 360);
      path.addArc(7 * (width - width / 8) / 12, 8 * (height - height / 8) / 12, width / 8, height / 8, 0, 360);
      path
          .addArc(6 * (width - width / 12) / 12, 3 * (height - height / 12) / 12, width / 12, height / 12, 0,
              360);
      path
          .addArc(6 * (width - width / 12) / 12, 9 * (height - height / 12) / 12, width / 12, height / 12, 0,
              360);
      path.addArc(11.5f * (width - width / 18) / 20, 5 * (height - height / 18) / 18, width / 18, height / 18, 0,
          360);
      path.addArc(8.5f * (width - width / 18) / 20, 13 * (height - height / 18) / 18, width / 18, height / 18, 0,
          360);
      gc.setClipping(path);
      path.dispose();
      break;
    case 1: // rectangle
      path = new Path(device);
      path.addRectangle(100, 100, width - 200, height - 200);
      path.addRectangle(120, 120, width - 240, height - 240);
      path.addRectangle(140, 140, width - 280, height - 280);
      gc.setClipping(path);
      path.dispose();
      break;
    case 2: // circle
      path = new Path(device);
      path.addArc(100, 100, width - 200, height - 200, 0, 360);
      path.addArc((width - width / 5) / 2, (height - height / 5) / 2, width / 5, height / 5, 0, 360);
      path.addArc(5 * (width - width / 8) / 12, 4 * (height - height / 8) / 12, width / 8, height / 8, 0, 360);
      path.addArc(7 * (width - width / 8) / 12, 8 * (height - height / 8) / 12, width / 8, height / 8, 0, 360);
      path
          .addArc(6 * (width - width / 12) / 12, 3 * (height - height / 12) / 12, width / 12, height / 12, 0,
              360);
      path
          .addArc(6 * (width - width / 12) / 12, 9 * (height - height / 12) / 12, width / 12, height / 12, 0,
              360);
      path.addArc(11.5f * (width - width / 18) / 20, 5 * (height - height / 18) / 18, width / 18, height / 18, 0,
          360);
      path.addArc(8.5f * (width - width / 18) / 20, 13 * (height - height / 18) / 18, width / 18, height / 18, 0,
          360);
      gc.setClipping(path);
      path.dispose();
      break;
    case 3: // word
      path = new Path(device);
      String text = GraphicsExample.getResourceString("SWT"); //$NON-NLS-1$
      Font font = new Font(device, "Times", 200, SWT.NORMAL);
      gc.setFont(font);
      Point size = gc.stringExtent(text);
      path.addString(text, (width - size.x) / 2, (height - size.y) / 2, font);
      font.dispose();
      gc.setClipping(path);
      path.dispose();
      break;
    case 4: // star
      path = new Path(device);
      path.lineTo(width / 2, 0);
      path.lineTo(5 * width / 8, height / 3);
      path.lineTo(width, height / 3);
      path.lineTo(3 * width / 4, 10 * height / 16);
      path.lineTo(7 * width / 8, height);
      path.lineTo(width / 2, 3 * height / 4);
      path.lineTo(width / 8, height);
      path.lineTo(width / 4, 10 * height / 16);
      path.lineTo(0, height / 3);
      path.lineTo(3 * width / 8, height / 3);
      path.lineTo(width / 2, 0);

      Path ovalPath = new Path(device);
      ovalPath.addArc(90, 90, width - 180, height - 180, 0, 360);

      path.addPath(ovalPath);
      gc.setClipping(path);
      ovalPath.dispose();
      path.dispose();
      break;
    case 5: // triangles
      path = new Path(device);
      path.addRectangle(0, 0, width, height);
      path.lineTo(width / 4, 0);
      path.lineTo(width / 4, height / 2);
      path.lineTo(0, height / 2);
      path.lineTo(width / 4, 0);

      Path path2 = new Path(device);
      path2.lineTo(width / 2, 0);
      path2.lineTo(width / 4, height / 2);
      path2.lineTo(3 * width / 4, height / 2);
      path2.lineTo(width / 2, 0);

      Path path3 = new Path(device);
      path3.lineTo(3 * width / 4, 0);
      path3.lineTo(3 * width / 4, height / 2);
      path3.lineTo(width, height / 2);
      path3.lineTo(3 * width / 4, 0);

      Path path4 = new Path(device);
      path4.lineTo(0, height);
      path4.lineTo(width / 4, height / 2);
      path4.lineTo(width / 2, height);
      path4.lineTo(0, height);

      Path path5 = new Path(device);
      path5.lineTo(width / 2, height);
      path5.lineTo(3 * width / 4, height / 2);
      path5.lineTo(width, height);
      path5.lineTo(width / 2, height);

      path.addPath(path2);
      path.addPath(path3);
      path.addPath(path4);
      path.addPath(path5);
      gc.setClipping(path);

      path5.dispose();
      path4.dispose();
      path3.dispose();
      path2.dispose();
      path.dispose();
      break;
View Full Code Here

    if (GraphicsExample.advanceGraphicsInit)
      return GraphicsExample.advanceGraphics;
    GraphicsExample.advanceGraphicsInit = true;
    Display display = parent.getDisplay();
    try {
      Path path = new Path(display);
      path.dispose();
    } catch (SWTException e) {
      Shell shell = display.getActiveShell(), newShell = null;
      if (shell == null)
        shell = newShell = new Shell(display);
      MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
View Full Code Here

      gc.setFont(font);
      Point size = gc.stringExtent(text);
      textWidth = size.x;
      textHeight = size.y;
    }
    Path path = new Path(device);
    path.addString(text, x, y, font);
    gc.setClipping(path);
    Rectangle rect = image.getBounds();
    gc.drawImage(image, 0, 0, rect.width, rect.height, 0, 0, width, height);
    gc.setClipping((Rectangle) null);
    gc.setForeground(device.getSystemColor(SWT.COLOR_BLUE));
    gc.drawPath(path);
    path.dispose();
  }
View Full Code Here

    Point size = gc.stringExtent(text);
    textWidth = size.x;
    textHeight = size.y;

    Path path = new Path(device);
    path.addString(text, x, y, font);

    gc.setForeground(device.getSystemColor(foreGrdColor));
    gc.setBackground(device.getSystemColor(fillColor));

    gc.fillPath(path);
    gc.drawPath(path);
    font.dispose();
    path.dispose();
  }
View Full Code Here

    if (ovalColorGB != null && ovalColorGB.getBgColor1() != null)
      gc.setBackground(ovalColorGB.getBgColor1());

    gc.setAntialias(aliasValues[aliasCombo.getSelectionIndex()]);

    Path path = new Path(device);
    float offsetX = 2 * width / 3f, offsetY = height / 3f;
    for (int i = 0; i < 25; i++)
      path.addArc(offsetX - 50 * i, offsetY - 25 * i, 50 + 100 * i, 25 + 50 * i, 0, 360);
    gc.fillPath(path);
    path.dispose();
  }
View Full Code Here

    transform.dispose();

    // choose the smallest between height and width
    int diameter = height < width ? height : width;

    Path path = new Path(device);
    path.addArc((width - diameter / 5) / 2, (height - diameter / 5) / 2, diameter / 5, diameter / 5, 0, 360);
    path.addArc(5 * (width - diameter / 8) / 12, 4 * (height - diameter / 8) / 12, diameter / 8, diameter / 8, 0,
        360);
    path.addArc(7 * (width - diameter / 8) / 12, 8 * (height - diameter / 8) / 12, diameter / 8, diameter / 8, 0,
        360);
    path.addArc(6 * (width - diameter / 12) / 12, 3 * (height - diameter / 12) / 12, diameter / 12, diameter / 12,
        0, 360);
    path.addArc(6 * (width - diameter / 12) / 12, 9 * (height - diameter / 12) / 12, diameter / 12, diameter / 12,
        0, 360);
    path.addArc(11.5f * (width - diameter / 18) / 20, 5 * (height - diameter / 18) / 18, diameter / 18,
        diameter / 18, 0, 360);
    path.addArc(8.5f * (width - diameter / 18) / 20, 13 * (height - diameter / 18) / 18, diameter / 18,
        diameter / 18, 0, 360);
    path.addArc(62f * (width - diameter / 25) / 100, 32 * (height - diameter / 25) / 100, diameter / 25,
        diameter / 25, 0, 360);
    path.addArc(39f * (width - diameter / 25) / 100, 67 * (height - diameter / 25) / 100, diameter / 25,
        diameter / 25, 0, 360);

    gc.fillPath(path);
    path.dispose();

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

TOP

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

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.