protected void fillShape(Graphics g) { try { g.pushState(); g.setBackgroundColor(ColorConstants.white); super.fillShape(g); } finally { g.popState(); } }
protected void paintChildren(Graphics graphics) { // force all children to paint with my alpha setting graphics.setAlpha(getAlpha()); //push the current state so it is what the children revert to graphics.pushState(); super.paintChildren(graphics); // pop that state we pushed above graphics.popState(); }
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(); } }
graphics.popState(); color.dispose();
graphics.popState(); color.dispose();
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(); } }
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(); } }
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(); } }
protected void paintClientArea(Graphics graphics) { if (this.getChildren().isEmpty()) return; // boolean optimizeClip = getBorder() == null || getBorder().isOpaque(); if (useLocalCoordinates()) { graphics.translate(getBounds().x + getInsets().left, getBounds().y + getInsets().top); // if (!optimizeClip) // graphics.clipRect(getClientArea(PRIVATE_RECT)); graphics.pushState(); paintChildren(graphics); graphics.popState(); graphics.restoreState(); } else { // if (optimizeClip) paintChildren(graphics); // else { // graphics.clipRect(getClientArea(PRIVATE_RECT)); // graphics.pushState(); // paintChildren(graphics); // graphics.popState(); // graphics.restoreState(); // } } } }
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(); } }
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(); } }
g.setBackgroundColor(ColorConstants.button); g.fillRectangle(innerRect2); g.popState();