@Override public void paintFigure(Graphics graphics) { int offsetX; int offsetY; if (ci.getShape() == ComponentShape.CIRCLE) { offsetX = OFFSET_SMALL_CIRCLE_COMPONENT_ICON; offsetY = OFFSET_SMALL_CIRCLE_COMPONENT_ICON; graphics.fillOval(this.getBounds()); graphics.setAntialias(SWT.ON); Rectangle b = this.getBounds().getCopy(); b.width--; b.height--; graphics.drawOval(b); graphics.setAntialias(SWT.OFF); } else { offsetX = OFFSET_SMALL_SQUARE_COMPONENT_ICON_X; offsetY = OFFSET_SMALL_SQUARE_COMPONENT_ICON_Y; graphics.fillRectangle(this.getBounds()); Rectangle b = this.getBounds().getCopy(); b.width--; b.height--; graphics.drawRectangle(b); } graphics.drawImage( icon, new Point(this.getLocation().x + offsetX, this.getLocation().y - 1 + offsetY)); }
/* (non-Javadoc) * @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) */ @Override public void paint(Graphics graphics) { int oldAntialias = graphics.getAntialias(); if (Animation.isAnimating() && Animation.getProgress() < .9) { graphics.setAntialias(SWT.OFF); } else { graphics.setAntialias(antialiasing); } super.paint(graphics); graphics.setAntialias(oldAntialias); }
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(); }
@Override protected void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.ON); Rectangle bounds = getBounds().getCopy(); graphics.setForegroundColor(getFillColor()); graphics.setBackgroundColor(ColorFactory.getLighterColor(getFillColor(), 0.9f)); graphics.fillGradient(bounds, false); // Border if (getBorderColor() != null) { graphics.setForegroundColor(ColorFactory.getLighterColor(getBorderColor(), 0.82f)); graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y); graphics.drawLine( bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); graphics.setForegroundColor(getBorderColor()); graphics.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1); graphics.drawLine( bounds.x, bounds.y + bounds.height - 1, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); } fIconicDelegate.drawIcon(graphics, bounds); }
protected void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.ON); if (control != null && !control.isDisposed() && control.isEnabled()) { graphics.setAlpha(0xff); } else { graphics.setAlpha(0x80); } super.paintFigure(graphics); }
/** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(final Graphics graphics) { super.paintFigure(graphics); Image image = getImage(); if (image != null) { graphics.setAntialias(SWT.ON); if (getAlpha() != IUseTransparency.DONT_USE_ALPHA) graphics.setAlpha(getAlpha()); paintImage(graphics, image); } }
/** * @see * nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics) */ @Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.setAntialias(SWT.ON); Rectangle bounds = getBounds(); if (isDangling()) { graphics.setForegroundColor(ColorConstants.red); graphics.drawOval(bounds.x, bounds.y, 12, 12); graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10); graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10); } }
@Override public void paintFigure(Graphics graphics) { graphics.pushState(); graphics.setAntialias(SWT.ON); if (!isEnabled()) { setDisabledState(graphics); } graphics.setBackgroundColor(getFillColor()); graphics.fillOval(bounds.getCopy()); graphics.popState(); }
@Override public void paint(Graphics g) { // We do not draw unless the target position of the // dummy connection lies outside of the source figure's bounds. // But we have to draw in polyline connections if a connection is // created starting from an existing one. if (rec != null && (!(getHostFigure() instanceof DiagramConnectionFigure)) && rec.contains(getPoints().getLastPoint())) { return; } g.setAntialias(SWT.ON); super.paint(g); }
@Override public void paintFigure(Graphics g) { g.setAntialias(SWT.ON); g.setLineWidth(1); Rectangle r = getBounds(); r.shrink(1, 1); try { g.setForegroundColor(getBorderColor()); g.setBackgroundColor(getFillColor()); g.fillOval(r); g.drawOval(r); } finally { // We don't really own rect 'r', so fix it. r.expand(1, 1); } }
@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); }
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); Pattern pattern = null; graphics.setBackgroundColor(GRAY_COLOR); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3D) { // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); pattern = new Pattern( Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, WHITE_COLOR, BORDER_COLOR); graphics.setBackgroundPattern(pattern); } super.fillShape(graphics); if (effect3D && support3D) pattern.dispose(); }
/* * (non-Javadoc) * * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics) */ public void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.LOW); super.paintFigure(graphics); graphics.pushState(); graphics.setBackgroundColor(ColorConstants.black); /* Creates the cross in the circle */ Rectangle rect1 = getBounds().getCopy(); int scaleFactor_horizontale = rect1.height / 2; int scaleFactor_verticale = rect1.width / 2; Rectangle rect = getBounds().getCopy(); graphics.drawLine( rect1.x, rect1.y + scaleFactor_horizontale, rect1.x + (int) Math.floor(rect1.width * (scaleFactor_horizontale)), rect1.y - (1 - scaleFactor_horizontale)); graphics.drawLine( rect1.x + scaleFactor_verticale, rect1.y, rect1.x - (1 - scaleFactor_verticale), rect1.y + (int) Math.floor(rect1.height * (scaleFactor_verticale))); graphics.popState(); }
@Override protected void fillShape(Graphics graphics) { int fill_corner = DEFAULT_CORNER; // If this is more close to 1/2, more light the tank will be. double intersectFactor = 11d / 20d; if (bounds.width < 2 * DEFAULT_CORNER) intersectFactor = 12d / 20d; int rectWidth = (int) (bounds.width * intersectFactor); if (fill_corner > (2 * rectWidth - (bounds.width - 2 * getLineWidth()))) fill_corner = 2 * rectWidth - bounds.width; corner.height = fill_corner; corner.width = fill_corner; graphics.setAntialias(SWT.ON); int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false); if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3d) { graphics.setBackgroundColor(WHITE_COLOR); super.fillShape(graphics); // fill background Rectangle leftRectangle = new Rectangle(bounds.x, bounds.y, rectWidth, bounds.height); Pattern leftGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), leftRectangle.x, leftRectangle.y, leftRectangle.x + leftRectangle.width + 2, leftRectangle.y, fillBackgroundColor, 255, WHITE_COLOR, 0); graphics.setBackgroundPattern(leftGradientPattern); graphics.fillRoundRectangle(leftRectangle, corner.width, corner.height); Rectangle rightRectangle = new Rectangle(bounds.x + bounds.width - rectWidth, bounds.y, rectWidth, bounds.height); Pattern rightGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), rightRectangle.x - 2, rightRectangle.y, rightRectangle.x + rightRectangle.width, rightRectangle.y, WHITE_COLOR, 0, fillBackgroundColor, 255); graphics.setBackgroundPattern(rightGradientPattern); graphics.fillRoundRectangle(rightRectangle, corner.width, corner.height); leftGradientPattern.dispose(); rightGradientPattern.dispose(); // fill value graphics.setBackgroundColor(WHITE_COLOR); int fillHeight = bounds.height - (valuePosition - bounds.y) - getLineWidth(); if (fillHeight > 0) { graphics.fillRoundRectangle( new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight), fill_corner, fill_corner); leftRectangle = new Rectangle(bounds.x, valuePosition, rectWidth, fillHeight); leftGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), leftRectangle.x, leftRectangle.y, leftRectangle.x + leftRectangle.width + 2, leftRectangle.y, fillColor, 255, WHITE_COLOR, 0); graphics.setBackgroundPattern(leftGradientPattern); graphics.fillRoundRectangle(leftRectangle, fill_corner, fill_corner); rightRectangle = new Rectangle( bounds.x + bounds.width - rectWidth, valuePosition, rectWidth, fillHeight); rightGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), rightRectangle.x - 2, rightRectangle.y, rightRectangle.x + rightRectangle.width, rightRectangle.y, WHITE_COLOR, 0, fillColor, 255); graphics.setBackgroundPattern(rightGradientPattern); graphics.fillRoundRectangle(rightRectangle, fill_corner, fill_corner); leftGradientPattern.dispose(); rightGradientPattern.dispose(); } graphics.setForegroundColor(EFFECT3D_OUTLINE_COLOR); } else { graphics.setBackgroundColor(fillBackgroundColor); super.fillShape(graphics); graphics.setBackgroundColor(fillColor); graphics.fillRoundRectangle( new Rectangle( bounds.x + lineWidth, valuePosition, bounds.width - 2 * lineWidth, bounds.height - (valuePosition - bounds.y)), fill_corner, fill_corner); // graphics.setForegroundColor(outlineColor); } }
@Override protected void fillShape(Graphics g) { g.setAntialias(SWT.ON); super.fillShape(g); }
@Override protected void paintClientArea(Graphics graphics) { graphics.setAntialias(SWT.ON); Rectangle area = getClientArea(); area.width = Math.min(area.width, area.height); area.height = area.width; Pattern pattern = null; graphics.pushState(); graphics.setBackgroundColor(GRAY_COLOR); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3D) { // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); pattern = new Pattern( Display.getCurrent(), area.x, area.y, area.x + area.width, area.y + area.height, BORDER_COLOR, WHITE_COLOR); graphics.setBackgroundPattern(pattern); } graphics.fillOval(area); graphics.popState(); if (effect3D && support3D) { pattern.dispose(); area.shrink(BORDER_WIDTH, BORDER_WIDTH); } else area.shrink(1, 1); graphics.fillOval(area); super.paintClientArea(graphics); // glossy effect if (effect3D && support3D) { graphics.pushState(); graphics.setAntialias(SWT.ON); final double R = area.width / 2.0d; final double UD_FILL_PART = 9.5d / 10d; final double UP_DOWN_RATIO = 1d / 2d; final double LR_FILL_PART = 8.5d / 10d; final double UP_ANGLE = 0d * Math.PI / 180d; final double DOWN_ANGLE = 35d * Math.PI / 180d; // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); Pattern glossyPattern = new Pattern( Display.getCurrent(), area.x + area.width / 2, (float) (area.y + area.height / 2 - R * UD_FILL_PART), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO), WHITE_COLOR, 90, WHITE_COLOR, 0); graphics.setBackgroundPattern(glossyPattern); Rectangle rectangle = new Rectangle( (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.cos(UP_ANGLE)), (int) (area.y + area.height / 2 - R * UD_FILL_PART), (int) (2 * R * LR_FILL_PART * Math.cos(UP_ANGLE)), (int) (R * UD_FILL_PART + R * UP_DOWN_RATIO)); graphics.fillOval(rectangle); glossyPattern.dispose(); glossyPattern = new Pattern( Display.getCurrent(), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO - 1), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UD_FILL_PART + 1), WHITE_COLOR, 0, WHITE_COLOR, 40); graphics.setBackgroundPattern(glossyPattern); rectangle = new Rectangle( (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.sin(DOWN_ANGLE)), (int) Math.ceil(area.y + area.height / 2 + R * UP_DOWN_RATIO), (int) (2 * R * LR_FILL_PART * Math.sin(DOWN_ANGLE)), (int) Math.ceil(R * UD_FILL_PART - R * UP_DOWN_RATIO)); graphics.fillOval(rectangle); glossyPattern.dispose(); graphics.popState(); } }
@Override protected void paintClientArea(Graphics graphics) { updateThresholdPosition(); graphics.setAntialias(SWT.ON); graphics.setLineWidth(rampWidth); graphics.pushState(); int overlap = 0; Pattern pattern = null; boolean support3D = GraphicsUtil.testPatternSupported(graphics); // draw lolo part if (lolo.visible) { graphics.setBackgroundColor(lolo.color); graphics.fillArc(bounds, lolo.absolutePosition, min.relativePosition - lolo.relativePosition); } // draw lo part if (lo.visible) { if (support3D && gradient && lolo.visible) { try { pattern = new Pattern( Display.getCurrent(), lolo.leftPoint.x, lolo.leftPoint.y, lo.rightPoint.x, lo.rightPoint.y, lolo.color, lo.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } catch (Exception e) { support3D = false; pattern.dispose(); graphics.setBackgroundColor(lo.color); overlap = 0; } } else { graphics.setBackgroundColor(lo.color); overlap = 0; } if (lolo.visible) graphics.fillArc( bounds, lo.absolutePosition, lolo.relativePosition - lo.relativePosition + overlap); else graphics.fillArc(bounds, lo.absolutePosition, min.relativePosition - lo.relativePosition); if (gradient && lolo.visible && support3D) pattern.dispose(); } // draw left normal part // get the left marker boolean leftMarkerVisible = false; ThresholdMarker leftMarker = null; if (lo.visible) { leftMarkerVisible = true; leftMarker = lo; } else if (lolo.visible) { leftMarkerVisible = true; leftMarker = lolo; } else leftMarkerVisible = false; if (gradient && leftMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), leftMarker.leftPoint.x, leftMarker.leftPoint.y, normal.rightPoint.x, normal.rightPoint.y, leftMarker.color, normal.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(normal.color); overlap = 0; } if (leftMarkerVisible) graphics.fillArc( bounds, normal.absolutePosition, leftMarker.relativePosition - normal.relativePosition + overlap); else graphics.fillArc( bounds, normal.absolutePosition, min.relativePosition - normal.relativePosition); if (gradient && leftMarkerVisible && support3D) pattern.dispose(); // draw right normal part // get the right marker boolean rightMarkerVisible = false; ThresholdMarker rightMarker = null; if (hi.visible) { rightMarkerVisible = true; rightMarker = hi; } else if (hihi.visible) { rightMarkerVisible = true; rightMarker = hihi; } else rightMarkerVisible = false; if (gradient && rightMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), rightMarker.rightPoint.x, rightMarker.rightPoint.y, normal.leftPoint.x, normal.leftPoint.y, rightMarker.color, normal.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(normal.color); overlap = 0; } if (rightMarkerVisible) graphics.fillArc( bounds, rightMarker.absolutePosition, normal.relativePosition - rightMarker.relativePosition + overlap + 1); else graphics.fillArc( bounds, max.absolutePosition, normal.relativePosition - max.relativePosition + 1); if (gradient && rightMarkerVisible && support3D) pattern.dispose(); // draw hi part if (hi.visible) { if (hihi.visible) { rightMarkerVisible = true; rightMarker = hihi; } else rightMarkerVisible = false; if (gradient && rightMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), rightMarker.rightPoint.x, rightMarker.rightPoint.y, hi.leftPoint.x, hi.leftPoint.y, rightMarker.color, hi.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(hi.color); overlap = 0; } if (rightMarkerVisible) graphics.fillArc( bounds, rightMarker.absolutePosition, hi.relativePosition - rightMarker.relativePosition + overlap); else graphics.fillArc(bounds, max.absolutePosition, hi.relativePosition - max.relativePosition); if (gradient && rightMarkerVisible && support3D) pattern.dispose(); } // draw hihi part if (hihi.visible) { if (gradient && support3D) overlap = OVERLAP_DEGREE / 2; else overlap = 0; graphics.setBackgroundColor(hihi.color); graphics.fillArc( bounds, max.absolutePosition, hihi.relativePosition - max.relativePosition + overlap); } graphics.popState(); graphics.fillOval( bounds.x + rampWidth, bounds.y + rampWidth, bounds.width - 2 * rampWidth, bounds.height - 2 * rampWidth); super.paintClientArea(graphics); }