/** Draw the icon */
  protected void drawIcon(Graphics graphics) {
    graphics.pushState();

    graphics.setLineWidthFloat(1);
    graphics.setForegroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);

    Point pt = getIconOrigin();

    Path path = new Path(null);

    path.addArc(pt.x, pt.y, 5, 5, 0, 360);
    path.addArc(pt.x + 2, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 10, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 8, pt.y, 5, 5, 0, 360);

    path.moveTo(pt.x + 3, pt.y);
    path.lineTo(pt.x + 4, pt.y - 3);

    path.moveTo(pt.x + 11, pt.y);
    path.lineTo(pt.x + 12, pt.y - 3);

    path.moveTo(pt.x + 5, pt.y + 2.5f);
    path.lineTo(pt.x + 8, pt.y + 2.5f);

    path.moveTo(pt.x + 7, pt.y - 5.5f);
    path.lineTo(pt.x + 10, pt.y - 5.5f);

    graphics.drawPath(path);
    path.dispose();

    graphics.popState();
  }
示例#2
0
 /**
  * Converts an AWT {@code Shape} into a SWT {@code Path}.
  *
  * @param shape the shape ({@code null} not permitted).
  * @return The path.
  */
 private Path toSwtPath(Shape shape) {
   int type;
   float[] coords = new float[6];
   Path path = new Path(this.gc.getDevice());
   PathIterator pit = shape.getPathIterator(null);
   while (!pit.isDone()) {
     type = pit.currentSegment(coords);
     switch (type) {
       case (PathIterator.SEG_MOVETO):
         path.moveTo(coords[0], coords[1]);
         break;
       case (PathIterator.SEG_LINETO):
         path.lineTo(coords[0], coords[1]);
         break;
       case (PathIterator.SEG_QUADTO):
         path.quadTo(coords[0], coords[1], coords[2], coords[3]);
         break;
       case (PathIterator.SEG_CUBICTO):
         path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
         break;
       case (PathIterator.SEG_CLOSE):
         path.close();
         break;
       default:
         break;
     }
     pit.next();
   }
   return path;
 }
示例#3
0
 /**
  * Convert an AWT Shape to an SWT Path.
  *
  * @param shape
  * @return the SWT Path or <code>null</code> if <code>shape == null</code>
  */
 private Path convertToPath(Shape shape) {
   if (shape == null) {
     return null;
   }
   Path path = new Path(_gc.getDevice());
   PathIterator iter = shape.getPathIterator(null);
   float[] coords = new float[6];
   while (!iter.isDone()) {
     int op = iter.currentSegment(coords);
     switch (op) {
       case PathIterator.SEG_MOVETO:
         path.moveTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_LINETO:
         path.lineTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_QUADTO:
         path.quadTo(coords[0], coords[1], coords[2], coords[3]);
         break;
       case PathIterator.SEG_CUBICTO:
         path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
         break;
       case PathIterator.SEG_CLOSE:
         path.close();
         break;
     }
     iter.next();
   }
   return path;
 }
示例#4
0
 void init(PathData data) {
   byte[] types = data.types;
   float[] points = data.points;
   for (int i = 0, j = 0; i < types.length; i++) {
     switch (types[i]) {
       case SWT.PATH_MOVE_TO:
         moveTo(points[j++], points[j++]);
         break;
       case SWT.PATH_LINE_TO:
         lineTo(points[j++], points[j++]);
         break;
       case SWT.PATH_CUBIC_TO:
         cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
         break;
       case SWT.PATH_QUAD_TO:
         quadTo(points[j++], points[j++], points[j++], points[j++]);
         break;
       case SWT.PATH_CLOSE:
         close();
         break;
       default:
         dispose();
         SWT.error(SWT.ERROR_INVALID_ARGUMENT);
     }
   }
 }
示例#5
0
  /**
   * Create horizontal line
   *
   * @param display - active {@link Display}
   * @param g - active {@link ViewportGraphics}
   * @param sx - Square width
   * @param lw - line width
   * @param current - Current square coordinate (corner)
   * @param next - Next square coordinate (corner)
   * @param gap - Gap where label is inserted (pixels)
   * @param bold - flag controlling line width
   * @param lines - already created square lines
   * @return 'next' coordinate
   */
  private Point horz(
      Display display,
      ViewportGraphics g,
      int sx,
      int lw,
      Point current,
      Point next,
      boolean gap,
      boolean bold,
      List<Line> lines) {

    // Initialize
    List<Path> paths = new ArrayList<Path>(2);

    // Create first segment
    Path path = new Path(display);

    // Move to last point
    path.moveTo(current.x, current.y);

    // Insert gap?
    if (gap) {

      // Calculate gap/2
      int offset = Math.max(1, g.getFontHeight());

      // End first segment before mid-point
      Point p = offset(current, next, -offset);
      path.lineTo(p.x, p.y);
      paths.add(path);

      // Create second segment
      path = new Path(display);

      // Move past mid-point
      p = offset(current, next, offset);
      path.moveTo(p.x, p.y);
    }

    // Close path
    path.lineTo(next.x - (bold ? 2 * lw : lw), next.y);
    paths.add(path);
    lines.add(new Line(paths, bold ? 2 * lw : lw));

    // Finished
    return gap ? offset(current, next, 0) : next;
  }
示例#6
0
  /** Draw the icon */
  protected void drawIcon(Graphics graphics) {
    graphics.setLineWidth(1);
    graphics.setForegroundColor(ColorConstants.black);
    graphics.setBackgroundColor(ColorConstants.black);

    Point pt = getIconOrigin();

    Path path = new Path(null);

    graphics.setLineWidthFloat(1.2f);
    path.addArc(pt.x, pt.y, 13, 13, 0, 360);

    graphics.drawPath(path);
    path.dispose();

    graphics.fillOval(pt.x + 5, pt.y + 5, 4, 4);

    graphics.setLineWidth(1);

    path = new Path(null);

    path.moveTo(pt.x - 2, pt.y + 6.5f);
    path.lineTo(pt.x + 15, pt.y + 6.5f);

    path.moveTo(pt.x + 6.5f, pt.y - 2);
    path.lineTo(pt.x + 6.5f, pt.y + 15);

    path.moveTo(pt.x + 0.5f, pt.y + 0.5f);
    path.lineTo(pt.x + 12.5f, pt.y + 12.5f);

    path.moveTo(pt.x + 0.5f, pt.y + 12.5f);
    path.lineTo(pt.x + 12.5f, pt.y + 0.5f);

    graphics.drawPath(path);
    path.dispose();
  }