protected void outlineShape(Graphics graphics) { graphics.pushState(); try { if (mode == NORMAL) { // TODO: common up and organize colors.... graphics.setForegroundColor(ReferenceConnection.inactiveConnection); } else if (mode == SELECTED) { graphics.setForegroundColor(ColorConstants.black); } super.outlineShape(graphics); } finally { graphics.popState(); } }
g.setLineWidth(lineWidth); g.setForegroundColor(ColorConstants.buttonDarker); g.drawArc(centerX - cycleWidth / 2, centerY - cycleWidth + 1, cycleWidth, cycleWidth, 45, 180); g.setForegroundColor(ColorConstants.button); g.drawArc(centerX - cycleWidth / 2, centerY - cycleWidth + 1, cycleWidth, cycleWidth, 225, 180); g.setForegroundColor(ColorConstants.buttonDarkest); g.drawArc(centerX - cycleWidth / 2, centerY - cycleWidth + 1, cycleWidth, cycleWidth, 45, 180);
private static void drawHorizontalPart(Graphics g, int arrawLength, int borderThick, Rectangle rect) { int left = rect.x; int top = rect.y; int width = Math.min(arrawLength, rect.width / 2); int height = Math.min(arrawLength, rect.height); Rectangle borderRect = new Rectangle(left, top, width, height); BorderUtil.drawBorder(g, borderRect, borderThick, false); g.setForegroundColor(ColorConstants.black); int decoratorHeight = (height - borderThick * 2) / 2; int length = decoratorHeight / 2 + 1; int leftX = rect.x + (width + length) / 2 - 1; int bottomY = rect.y + (height - length) / 2 - 1; for (int i = 0; i < length; i++) { g.drawLine(leftX - i, bottomY + i, leftX - i, bottomY - i + decoratorHeight); } left = rect.x + rect.width - width; borderRect = new Rectangle(left, top, width, height); BorderUtil.drawBorder(g, borderRect, borderThick, false); leftX = left + (width - length) / 2; g.setForegroundColor(ColorConstants.black); for (int i = 0; i < length; i++) { g.drawLine(leftX + i, bottomY + i, leftX + i, bottomY - i + decoratorHeight); } }
private static void drawVerticalPart(Graphics g, int arrawLength, int borderThick, Rectangle rect) { int left = rect.x; int top = rect.y; int width = Math.min(arrawLength, rect.width); int height = Math.min(arrawLength, rect.height / 2); Rectangle borderRect = new Rectangle(left, top, width, height); BorderUtil.drawBorder(g, borderRect, borderThick, false); g.setForegroundColor(ColorConstants.black); int decoratorWidth = (width - borderThick * 2) / 2; int length = decoratorWidth / 2 + 1; int leftX = rect.x + (width - decoratorWidth) / 2 - 1; int bottomY = rect.y + (height + length) / 2 - 1; for (int i = 0; i < length; i++) { g.drawLine(leftX + i, bottomY - i, leftX - i + decoratorWidth, bottomY - i); } top = rect.y + rect.height - height; borderRect = new Rectangle(left, top, width, height); BorderUtil.drawBorder(g, borderRect, borderThick, false); int topY = top + (height - length) / 2; g.setForegroundColor(ColorConstants.black); for (int i = 0; i < length; i++) { g.drawLine(leftX + i, topY + i, leftX - i + decoratorWidth, topY + i); } }
/** * draw a mask to a rectangle * * @param Graphics * @param Rectangle * @param Color */ public static void maskRectangle(Graphics g, Rectangle rect, Color color) { // set default if one not provided if (color == null) { color = ColorConstants.blue; } // get old information and keep them int lineStyle = g.getLineStyle(); Color foregroundColor = g.getForegroundColor(); g.setLineStyle(SWT.LINE_SOLID); g.setForegroundColor(color); for (int i = 0, n = rect.height; i < n; i++, i++) { for (int j = 0, m = rect.width; j < m; j++, j++) { g.drawLine(rect.x + j, rect.y + i, rect.x + j, rect.y + i); } } // restore to the old state g.setLineStyle(lineStyle); g.setForegroundColor(foregroundColor); }
public void paint(Graphics graphics) { super.paint(graphics); try { graphics.pushState(); graphics.setForegroundColor(ColorConstants.blue); graphics.setFont(DesignViewerGraphicConstants.smallFont); List children = getChildren(); for (Iterator i = children.iterator(); i.hasNext(); ) { Figure object = (Figure)i.next(); traverse(object, graphics); } } finally { graphics.popState(); } }
/** * @param figure * @param graphics */ public static void drawBorderDecorator(CSSFigure figure, Graphics graphics) { graphics.setLineWidth(1); graphics.setLineStyle(Graphics.LINE_DASH); graphics.setForegroundColor(ColorConstants.lightGray); List fragments = figure.getFragmentsForRead(); for (int i = 0, size = fragments.size(); i < size; i++) { FlowBox box = (FlowBox) fragments.get(i); // XXX: why -1? graphics.drawRectangle(box._x, box._y, box.getWidth() - 1, box .getHeight() - 1); } graphics.restoreState(); }
/** * Debug code. * * @param g * @param box */ public static void drawBox(Graphics g, FlowBox box) { Color color = null; if (box instanceof BlockBox) { // color = ColorConstants.red; } else if (box instanceof LineBox) { color = ColorConstants.blue; } else if (box instanceof TextFragmentBox) { color = ColorConstants.green; } else { color = ColorConstants.darkGreen; } if (color != null) { g.setForegroundColor(color); g.setLineStyle(Graphics.LINE_DASH); g.setLineWidth(1); g.drawRectangle(box._x, box._y, box.getWidth(), box.getHeight()); } }
public void paint(Graphics graphics) { super.paint(graphics); graphics.pushState(); try { // Fill for the header section // Rectangle r = getBounds().getCopy(); graphics.setBackgroundColor(ColorConstants.lightGray); Color gradient1 = isReadOnly ? gradientColor[1] : headerColor; if (isSelected && isReadOnly) gradient1 = gradientColor[3]; else if (isSelected && !isReadOnly) gradient1 = gradientColor[2]; Color gradient2 = gradientColor[0]; graphics.setForegroundColor(gradient1); graphics.setBackgroundColor(gradient2); Rectangle labelBounds = label.getBounds(); graphics.fillGradient(r.x+1, r.y+1, r.width-2, labelBounds.height - 2, true); graphics.setForegroundColor(ColorConstants.darkGray); label.paint(graphics); } finally { graphics.popState(); } }
public void paintFigure(Graphics g, org.eclipse.draw2d.geometry.Rectangle rect) { g.fillRectangle(rect); g.setClip(rect); int imageAreaWidth = Math.min(rect.width, _imageWidth); int imageAreaHeight = Math.min(rect.height, _imageHeight); if (_image != null && !_image.isDisposed()) { g.drawImage(_image, 0, 0, _imageWidth, _imageHeight, rect.x, rect.y + (rect.height - imageAreaHeight) / 2, imageAreaWidth, imageAreaHeight); } if (_label != null && _labelVisible) { int leading = 0; if (_fontMetrics != null) { leading = _fontMetrics.getLeading(); } // TODO: adapt to bg: go lighter on colors that darker() would make black // TODO: color registry Color fg = FigureUtilities.darker(g.getBackgroundColor()); g.setForegroundColor(fg); g.drawString(_label, imageAreaWidth + GAP, rect.y + (rect.height - getLabelHeight()) / 2 + leading); fg.dispose(); } }
public void paintFigure(Graphics g) { ICSSStyle style = this.getCSSStyle(); if (style != null) { ITagEditInfo info = (ITagEditInfo) style .getAdapter(ITagEditInfo.class); if (info != null && info.needTableDecorator()) { List cells = _tableInfo.getCells(); for (int i = 0, size = cells.size(); i < size; i++) { TableCellInfo cellInfo = (TableCellInfo) cells.get(i); IFigure cellfigure = cellInfo.getFigure(); Rectangle rect = cellfigure.getBounds().getCopy(); rect = rect.expand(1, 1); g.setLineStyle(Graphics.LINE_SOLID); g.setLineWidth(1); g.setForegroundColor(ColorConstants.lightGray); g.drawRectangle(rect); } } } }
private void paintLeftEdge(Graphics graphics, RGB[] rgbs, String style, Rectangle rect, Rectangle innerRect) { int x = rect.x; int topY = rect.y; int bottomY = rect.bottom() - 1; int width = innerRect.x - rect.x; if (ICSSPropertyID.VAL_DOTTED.equals(style)) { drawDottedBorder(graphics, rgbs, ICSSStyle.LEFT, rect, width); } else if (ICSSPropertyID.VAL_DASHED.equals(style)) { drawDashedBorder(graphics, rgbs, ICSSStyle.LEFT, rect, width); } else { double yTopRate = ((double) (innerRect.y - rect.y)) / width; double yBottomRate = ((double) (rect.bottom() - innerRect.bottom())) / width; graphics.pushState(); for (int i = 0; i < width; i++) { Color color = new Color(Display.getCurrent(), rgbs[rgbs.length * i / width]); graphics.setForegroundColor(color); graphics.drawLine(x + i, topY + (int) (i * yTopRate), x + i, bottomY - (int) (i * yBottomRate)); color.dispose(); } graphics.popState(); } }
private void paintTopEdge(Graphics graphics, RGB[] rgbs, String style, Rectangle rect, Rectangle innerRect) { int leftX = rect.x; int rightX = rect.right() - 1; int y = rect.y; int width = innerRect.y - rect.y; if (ICSSPropertyID.VAL_DOTTED.equals(style)) { drawDottedBorder(graphics, rgbs, ICSSStyle.TOP, rect, width); } else if (ICSSPropertyID.VAL_DASHED.equals(style)) { drawDashedBorder(graphics, rgbs, ICSSStyle.TOP, rect, width); } else { double xLeftRate = ((double) (innerRect.x - rect.x)) / width; double xRightRate = ((double) (rect.right() - innerRect.right())) / width; graphics.pushState(); for (int i = 0; i < width; i++) { Color color = new Color(Display.getCurrent(), rgbs[rgbs.length * i / width]); graphics.setForegroundColor(color); graphics.drawLine((int) (leftX + i * xLeftRate), y + i, (int) (rightX - i * xRightRate), y + i); color.dispose(); } graphics.popState(); } }
Object color = style.getColor(); if (color instanceof Color) { g.setForegroundColor((Color) color); } else if (color instanceof RGB) { newColor = new Color(Display.getCurrent(), (RGB) color); g.setForegroundColor(newColor); } else { g.setForegroundColor(ColorConstants.black);
public void paintFigure(Graphics g, Rectangle rect) { int centerX = rect.x + rect.width / 2; int centerY = rect.y + rect.height / 2; // we always draw it as a square. int width = Math.min(rect.width, rect.height); int innerWidth = width * 4 / 5; int left = centerX - innerWidth / 2; int top = centerY - innerWidth / 2; BorderUtil.drawBorder(g, left, top, innerWidth, innerWidth, 2, true); if (isChecked()) { g.pushState(); Display display = Display.getCurrent(); g.setForegroundColor(display.getSystemColor(SWT.COLOR_BLACK)); g.drawLine(left + 3, top + 2, left + innerWidth - 3, top + innerWidth - 4); g.drawLine(left + 2, top + 2, left + innerWidth - 3, top + innerWidth - 3); g.drawLine(left + innerWidth - 4, top + 2, left + 2, top + innerWidth - 4); g.drawLine(left + innerWidth - 3, top + 2, left + 2, top + innerWidth - 3); g.popState(); } }
public void paint(IFigure figure, Graphics graphics, Insets insets) { int rlbWidth = getWidth(); tempRect.setBounds(getPaintRectangle(figure, insets)); if (rlbWidth%2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(rlbWidth/2,rlbWidth/2); graphics.setLineWidth(rlbWidth); graphics.setLineStyle(lineStyle); if (getColor() != null) graphics.setForegroundColor(getColor()); graphics.drawRoundRectangle(tempRect, arcLength, arcLength); } }
private void paintBottomEdge(Graphics graphics, RGB[] rgbs, String style, Rectangle rect, Rectangle innerRect) { int leftX = rect.x; int rightX = rect.right() - 1; int y = rect.bottom() - 1; int width = rect.bottom() - innerRect.bottom(); if (ICSSPropertyID.VAL_DOTTED.equals(style)) { drawDottedBorder(graphics, rgbs, ICSSStyle.BOTTOM, rect, width); } else if (ICSSPropertyID.VAL_DASHED.equals(style)) { drawDashedBorder(graphics, rgbs, ICSSStyle.BOTTOM, rect, width); } else { double xLeftRate = ((double) (innerRect.x - rect.x)) / width; double xRightRate = ((double) (rect.right() - innerRect.right())) / width; graphics.pushState(); for (int i = 0; i < width; i++) { Color color = new Color(Display.getCurrent(), rgbs[rgbs.length * i / width]); graphics.setForegroundColor(color); graphics.drawLine(leftX + (int) (i * xLeftRate), y - i, rightX - (int) (i * xRightRate), y - i); color.dispose(); } graphics.popState(); } }
private void paintRightEdge(Graphics graphics, RGB[] rgbs, String style, Rectangle rect, Rectangle innerRect) { int x = rect.right() - 1; int topY = rect.y; int bottomY = rect.bottom() - 1; int width = rect.right() - innerRect.right(); if (ICSSPropertyID.VAL_DOTTED.equals(style)) { drawDottedBorder(graphics, rgbs, ICSSStyle.RIGHT, rect, width); } else if (ICSSPropertyID.VAL_DASHED.equals(style)) { drawDashedBorder(graphics, rgbs, ICSSStyle.RIGHT, rect, width); } else { graphics.pushState(); for (int i = 0; i < width; i++) { double yTopRate = ((double) (innerRect.y - rect.y)) / width; double yBottomRate = ((double) (rect.bottom() - innerRect .bottom())) / width; Color color = new Color(Display.getCurrent(), rgbs[rgbs.length * i / width]); graphics.setForegroundColor(color); graphics.drawLine(x - i, topY + (int) (i * yTopRate), x - i, bottomY - (int) (i * yBottomRate)); color.dispose(); } graphics.popState(); } }
/** * Draws the handle with fill color and outline color dependent * on the primary selection status of the owner editpart. * * @param g The graphics used to paint the figure. */ public void paintFigure(Graphics g) { Rectangle r = getBounds(); r.shrink(1, 1); try { g.setBackgroundColor(getFillColor()); g.setAlpha(getAlpha()); g.fillRectangle(r.x, r.y, r.width, r.height); g.setForegroundColor(getBorderColor()); g.drawRectangle(r.x, r.y, r.width, r.height); } finally { //We don't really own rect 'r', so fix it. r.expand(1, 1); } }
public void paintFigure(Graphics g) { // TODO: could we use an image label toggle button here instead? Image arrowImage = null; if (_stateMachine.isMenuShowing()) { arrowImage = PDPlugin.getDefault().getImage("pin_down.gif"); } else { arrowImage = PDPlugin.getDefault().getImage("pin_up.gif"); } Rectangle r = getBounds(); g.setAlpha(75); g.setBackgroundColor(getFillColor()); g.fillRectangle(r.x, r.y, r.width, r.height); g.setAlpha(getAlpha()); g.drawImage(arrowImage, r.x+1, r.y+1); g.setForegroundColor(getBorderColor()); g.drawRectangle(r.x, r.y, r.width-1, r.height-1); }