protected void paintFigure(Graphics graphics) { int alpha = 0x60; graphics.setAntialias(SWT.ON); if (control != null && !control.isDisposed() && control.isEnabled()) { graphics.setAlpha(0xff); } else { graphics.setAlpha(0x90); } Rectangle r = getBounds(); Path shape = new Path(Display.getCurrent()); float corner = Math.max(2, (vertical ? r.width : r.height) / 2); SWTUtils.addRoundedRectangle(shape, r.x, r.y, r.width - 1, r.height - 1, corner); Pattern pattern = new Pattern( Display.getCurrent(), // r.x, r.y, // vertical ? r.right() - 1 : r.x, // vertical ? r.y : r.bottom() - 1, // ColorConstants.gray, alpha, // ColorConstants.lightGray, alpha); graphics.setBackgroundPattern(pattern); graphics.fillPath(shape); graphics.setBackgroundPattern(null); pattern.dispose(); graphics.setAlpha(alpha); graphics.setForegroundColor(ColorConstants.gray); graphics.drawPath(shape); shape.dispose(); }
/** 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(); }
/** * Sets the clip region. * * @param clip the clip. */ @Override public void setClip(Shape clip) { if (clip == null) { return; } Path clipPath = toSwtPath(clip); this.gc.setClipping(clipPath); clipPath.dispose(); }
/** * Fills the specified shape using the current paint. * * @param shape the shape ({@code null} not permitted). * @see #getPaint() * @see #draw(Shape) */ @Override public void fill(Shape shape) { Path path = toSwtPath(shape); // Note that for consistency with the AWT implementation, it is // necessary to switch temporarily the foreground and background // colors switchColors(); this.gc.fillPath(path); switchColors(); path.dispose(); }
public void setClip(Shape s) { Path path = convertToPath(s); if (path == null) { _gc.setClipping((Rectangle) null); } else { _gc.setClipping(path); } if (_clippingPath != null) { _clippingPath.dispose(); } _clippingPath = path; _clippingArea = (s == null ? null : new Area(s)); }
/** 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(); }
/** Clean used resources. */ public void clean() { if (_clippingPath != null) { _gc.setClipping((Rectangle) null); _clippingPath.dispose(); _clippingPath = null; _clippingArea = null; } if (_color != null) { _color.dispose(); _color = null; } if (_transform != null) { _gc.setTransform(null); _transform.dispose(); } }
@Override protected void outlineShape(Graphics graphics) { graphics.setAntialias(SWT.ON); final int lineWidth = getLineWidth(); int oldLineWidth = graphics.getLineWidth(); graphics.setLineWidth(lineWidth); // get Path Rectangle pathbounds = getBounds(); Path path = createPath(pathbounds, graphics); graphics.drawPath(path); // reset Graphics path.dispose(); graphics.setLineWidth(oldLineWidth); }
/** * Draws the outline of the specified shape using the current stroke and paint settings. * * @param shape the shape ({@code null} not permitted). * @see #getPaint() * @see #getStroke() * @see #fill(Shape) */ @Override public void draw(Shape shape) { Path path = toSwtPath(shape); this.gc.drawPath(path); path.dispose(); }
/** * Applies the specified clip. * * @param s the shape for the clip. */ @Override public void clip(Shape s) { Path path = toSwtPath(s); this.gc.setClipping(path); path.dispose(); }
public void fill(Shape s) { Path p = convertToPath(s); _gc.fillPath(p); p.dispose(); }