public void paint(Graphics g) { if (lblCnnName.getBorder() != null) { g.setLineWidth(2); } else { g.setLineWidth(1); } super.paint(g); }
/* * (non-Javadoc) * * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics) */ @Override public void paintFigure(Graphics graphics) { graphics.setLineWidth(2); Rectangle r = getBounds(); // Define the points of a diamond Point p1 = new Point(r.x, r.y + r.height / 2); Point p2 = new Point(r.x + r.width / 2, r.y); Point p3 = new Point(r.x + r.width, r.y + r.height / 2); Point p4 = new Point(r.x + r.width / 2, r.y + r.height - 1); PointList pointList = new PointList(); pointList.addPoint(p1); pointList.addPoint(p2); pointList.addPoint(p3); pointList.addPoint(p4); // Fill the shape graphics.fillPolygon(pointList); // Draw the outline graphics.drawLine(p1, p2); graphics.drawLine(p2, p3); graphics.drawLine(p3, p4); graphics.drawLine(p4, p1); }
private void drawDarkerSide( Graphics graphics, Color[] br, int top, int left, int bottom, int right) { graphics.setLineWidth(1); graphics.setAlpha(200); Color color; for (int i = 0; i < br.length; i++) { color = br[i]; graphics.setForegroundColor(color); graphics.drawArc( right - i - corner.width, bottom - i - corner.height, corner.width, corner.height, 270, 90); Point rightButtomRight = new Point(right - i, bottom - i - corner.height / 2); Point rightTopRight = new Point(right - i, top + i + corner.height / 2); graphics.drawLine(rightButtomRight, rightTopRight); graphics.drawArc(right - i - corner.width, top - i, corner.width, corner.height, 0, 45); Point rightButtomButtom = new Point(right - i - corner.width / 2, bottom - i); Point leftBottomLeft = new Point(left + i + corner.width / 2, bottom - i); graphics.drawLine(rightButtomButtom, leftBottomLeft); graphics.drawArc( left - i, bottom - i - corner.height, corner.width, corner.height, 180 + 45, 45); } }
@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 paintClientArea(Graphics graphics) { if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics); Rectangle clientArea = getClientArea(); Rectangle square = new Rectangle( clientArea.x, clientArea.y + clientArea.height / 2 - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE); graphics.pushState(); if (support3d) graphics.setBackgroundPattern( GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), square.x, square.y + 1, square.x, square.y + square.height, ColorConstants.white, graphics.getBackgroundColor())); graphics.fillRoundRectangle(square, 4, 4); graphics.setForegroundColor(CustomMediaFactory.getInstance().getColor(130, 130, 130)); graphics.drawRoundRectangle(square, 4, 4); if (boolValue) { graphics.translate(square.x, square.y); graphics.setLineWidth(3); graphics.setForegroundColor(selectedColor); graphics.drawPolyline( new int[] { 3, (int) (BOX_SIZE * 0.45), (int) (BOX_SIZE * 0.45), BOX_SIZE * 3 / 4 - 1, BOX_SIZE - 2, 3 }); } graphics.popState(); Dimension textSize = FigureUtilities.getTextExtents(text, graphics.getFont()); if (!isEnabled()) { graphics.translate(1, 1); graphics.setForegroundColor(ColorConstants.buttonLightest); graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2)); graphics.translate(-1, -1); graphics.setForegroundColor(ColorConstants.buttonDarker); } graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2)); super.paintClientArea(graphics); }
@Override protected void paintClientArea(Graphics graphics) { super.paintClientArea(graphics); graphics.setForegroundColor(GRAY_COLOR); graphics.setLineWidth(1); graphics.drawLine( bounds.x + bounds.width / 2, bounds.y, bounds.x + bounds.width / 2, bounds.y + bounds.height); }
/** 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(); }
@Override protected void outlineShape(Graphics graphics) { Rectangle a = start(graphics); try { graphics.setLineWidth(2); graphics.setLineStyle(SWT.LINE_SOLID); if (shape instanceof Ellipse) { graphics.drawOval(1, 1, a.width - 2, a.height - 2); } else if (shape instanceof PointList) { graphics.drawPolygon((PointList) shape); } } finally { stop(graphics); } }
@Override public void paintFigure(final Graphics g) { // super.paintFigure(g); g.pushState(); // DEBUG // g.setLineDash(new int[] { 1, 5 }); // g.drawRectangle(this.bounds.x, this.bounds.y, this.bounds.width - 1, this.bounds.height - 1); // g.setLineDash(new int[] {}); // END DEBUG // final int y = this.bounds.y; final int x = this.bounds.x; final int w = this.bounds.width; final int y = this.posY; g.setLineWidth(1); g.drawLine(x, y, x + w, y); g.popState(); }
@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); } }
/** * The stop is a cross * * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics) */ @Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.pushState(); int width = bounds.width; int height = bounds.height; if (width > height) { width = height; } else if (width < height) { height = width; } int x = bounds.x + bounds.width / 2 - width / 2; int y = bounds.y + bounds.height / 2 - height / 2; graphics.setLineWidth(lineWidth); graphics.drawLine(x, y, x + width, y + height); graphics.drawLine(x + width, y, x, y + height); graphics.popState(); }
public void drawIcon(Graphics graphics, Point origin) { graphics.pushState(); graphics.setLineWidth(1); // fills graphics.setForegroundColor(blue3); graphics.setBackgroundColor(blue4); graphics.fillGradient(origin.x, origin.y, 5, 5, true); graphics.fillGradient(origin.x, origin.y + 9, 5, 5, true); graphics.setForegroundColor(blue1); // squares graphics.drawRectangle(origin.x, origin.y, 5, 5); graphics.drawRectangle(origin.x, origin.y + 9, 5, 5); graphics.drawRectangle(origin.x + 8, origin.y + 6, 2, 2); // little square // lines graphics.translate(7, 2); graphics.setForegroundColor(blue2); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 1); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 8); graphics.setForegroundColor(blue2); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 1); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); // small line graphics.translate(4, -5); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 2, origin.y); graphics.popState(); }
private void drawLighterSide( Graphics graphics, Color[] tl, int top, int left, int bottom, int right) { graphics.setAlpha(255); right--; bottom--; Color color; graphics.setLineWidth(1); for (int i = 0; i < tl.length; i++) { color = tl[i]; graphics.setForegroundColor(color); graphics.drawArc(left - i, top - i, corner.width, corner.height, 90, 90); Point leftTopLeft = new Point(left - i, top - i + corner.height / 2); Point leftBottomLeft = new Point(left - i, bottom + i - corner.height / 2); graphics.drawLine(leftTopLeft, leftBottomLeft); graphics.drawArc(left - i, bottom - i - corner.height, corner.width, corner.height, 180, 45); Point rightTopTop = new Point(right - i - corner.width / 2, top - i); Point leftTopTop = new Point(left + i + corner.width / 2, top - i); graphics.drawLine(rightTopTop, leftTopTop); graphics.drawArc(right - i - corner.width, top - i, corner.width, corner.height, 0 + 45, 45); } }
@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); }
public void paintFigure(Graphics graphics) { graphics.setLineWidth(lineWidth); super.paintFigure(graphics); }
@Override protected void drawSymbol(Graphics g) { PointList points = null; super.drawSymbol(g); int centerPointX = (int) Math.ceil((H_EXTENT / 2.0f)); // Center point of odd #. switch (this.featureCategory) { case BUS_ACCESS: case DATA_ACCESS: // Configure GC. g.setForegroundColor(this.getForegroundColor()); g.setBackgroundColor(ColorConstants.white); g.setLineWidth(2); // Create point list that defines the symbol. points = new PointList(); /* Populate point list. */ points.addPoint(centerPointX, 0); points.addPoint(0, V_EXTENT - 8); points.addPoint(0, V_EXTENT); points.addPoint(centerPointX, V_EXTENT - 2); points.addPoint(H_EXTENT, V_EXTENT); points.addPoint(H_EXTENT, V_EXTENT - 8); // Fill symbol. g.fillPolygon(points); // Draw symbol. g.drawPolygon(points); break; case SUBPROGRAM_ACCESS: case SUBPROGRAM_GROUP_ACCESS: // Configure GC if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) { g.setBackgroundColor(ColorConstants.white); g.setForegroundColor(ColorConstants.black); } else { g.setBackgroundColor(ColorConstants.black); g.setForegroundColor(ColorConstants.white); } g.setLineCap(SWT.CAP_ROUND); g.setLineWidth(2); int ovalWidth = H_EXTENT; int ovalHeight = V_EXTENT; // Draw oval. Rectangle ovalRect = new Rectangle( (int) (0.5f * (H_EXTENT - ovalWidth)), (int) (0.5f * (V_EXTENT - ovalHeight)), ovalWidth, ovalHeight); g.fillOval(ovalRect); if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) g.drawOval(ovalRect); int triangleWidth = 7; int triangleHeight = 5; int triangleStartX = (int) Math.ceil((0.5f * (H_EXTENT - triangleWidth))); int triangleStartY = (int) Math.ceil((0.5f * (V_EXTENT - triangleHeight))); // Draw triangle. g.drawLine(triangleStartX, triangleStartY, centerPointX, triangleStartY + triangleHeight); g.drawLine( triangleStartX + triangleWidth, triangleStartY, centerPointX, triangleStartY + triangleHeight); break; } }
public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); BorderComponent borderDef = this.rectPresentation.getTopBorder(); if (this.hasUniformBorders && borderDef.getWeight().getContent() > 0) { int w = borderDef.getWeight().getContent(); int inset = Math.max(1, w >> 1); tempRect.x += inset; tempRect.y += inset; tempRect.width -= inset + inset; tempRect.height -= inset + inset; int cornerRadius = this.rectPresentation.getCornerRadius(); float cornerWidth = cornerRadius; float cornerHeight = cornerRadius; // adjust corner for the inner path (formula found by experimenting) cornerHeight = Math.max(1, cornerHeight - (w + cornerHeight / 64)); cornerWidth = Math.max(1, cornerWidth - (w + cornerWidth / 64)); graphics.setLineWidth(borderDef.getWeight().getContent()); graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent())); graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent())); graphics.drawRoundRectangle( tempRect, Math.max(0, (int) cornerWidth), Math.max(0, (int) cornerHeight)); } else { if (borderDef.getWeight().getContent() > 0) { int w = borderDef.getWeight().getContent(); graphics.setLineWidth(w); graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent())); graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent())); int inset = Math.max(1, w >> 1); int x = tempRect.x; int y = tempRect.y + inset; int x2 = tempRect.x + tempRect.width; graphics.drawLine(x, y, x2, y); } borderDef = this.rectPresentation.getBottomBorder(); if (borderDef.getWeight().getContent() > 0) { int w = borderDef.getWeight().getContent(); graphics.setLineWidth(w); graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent())); graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent())); int inset = Math.max(1, w >> 1); int x = tempRect.x; int y = tempRect.y + tempRect.height - inset; int x2 = tempRect.x + tempRect.width; graphics.drawLine(x, y, x2, y); } borderDef = this.rectPresentation.getLeftBorder(); if (borderDef.getWeight().getContent() > 0) { int w = borderDef.getWeight().getContent(); graphics.setLineWidth(w); graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent())); graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent())); int inset = Math.max(1, w >> 1); int x = tempRect.x + inset; int y = tempRect.y; int y2 = tempRect.y + tempRect.height; graphics.drawLine(x, y, x, y2); } borderDef = this.rectPresentation.getRightBorder(); if (borderDef.getWeight().getContent() > 0) { int w = borderDef.getWeight().getContent(); graphics.setLineWidth(w); graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent())); graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent())); int inset = Math.max(1, w >> 1); int x = tempRect.x + tempRect.width - inset; int y = tempRect.y; int y2 = tempRect.y + tempRect.height; graphics.drawLine(x, y, x, y2); } } }