本文整理汇总了Java中org.eclipse.draw2d.Graphics.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setBackgroundColor方法的具体用法?Java Graphics.setBackgroundColor怎么用?Java Graphics.setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintCancel
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintCancel(Graphics graphics){
Rectangle barBounds = getBounds().getCopy();
barBounds.crop(new Insets(getMargin()));
if (barBounds.height > getMaxHeight()){
int dy = (barBounds.height - getMaxHeight())/2;
barBounds.crop(new Insets(dy,0,dy,0));
}
Rectangle cancelBounds = barBounds.getCopy();
cancelBounds.x = cancelBounds.right() - getCancelButtonWidth();
cancelBounds.width = getCancelButtonWidth();
Color cancelColor = new Color(null,
ColorUtils.darker(
ColorUtils.darker(
graphics.getBackgroundColor().getRGB())));
graphics.setBackgroundColor(cancelColor);
int radius = Math.min(15, cancelBounds.height);
graphics.fillRoundRectangle(cancelBounds, radius, radius);
graphics.drawRoundRectangle(cancelBounds, radius, radius);
graphics.setForegroundColor(ColorConstants.white);
paintString(graphics, "Cancel", cancelBounds);
cancelColor.dispose();
}
示例2: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
Rectangle r = getBounds();
Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2));
center = new Point(square.x + square.width/2, square.y + square.height/2);
g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX);
g.fillRectangle(square);
g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black);
g.drawRectangle(square);
g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
g.fillOval(center.x-3, center.y-3, 7, 7);
if(isnull) {
g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
Point dest = center.getTranslated(20, 0);
g.drawLine(center, dest);
g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5));
}
}
示例3: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void paintFigure(final Graphics graphics) {
final ERDiagramConnection connection = (ERDiagramConnection) getParent();
graphics.setAntialias(SWT.ON);
final Color color = connection.getColor();
if (color != null) {
graphics.setForegroundColor(color);
graphics.setBackgroundColor(color);
}
super.paintFigure(graphics);
}
示例4: drawShadowLayer
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawShadowLayer(Rectangle rectangle, Graphics graphics,
int offset, Color color) {
// Save the state of the graphics object
graphics.pushState();
graphics.setLineWidth(0);
graphics.setBackgroundColor(color);
Rectangle shadowLayer = new Rectangle(rectangle);
shadowLayer.x += offset;
shadowLayer.y += offset;
Dimension cornerDimensions = getCornerDimensions();
graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width,
cornerDimensions.height);
// Restore the start of the graphics object
graphics.popState();
}
示例5: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void paintFigure(Graphics graphics) {
ERDiagramConnection connection = (ERDiagramConnection) this.getParent();
graphics.setAntialias(SWT.ON);
Color color = connection.getColor();
if (color != null) {
graphics.setForegroundColor(color);
graphics.setBackgroundColor(color);
}
super.paintFigure(graphics);
}
示例6: drawTitleBar
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* rect는 타이틀 바를 그릴 사각형이다. 여기서는 이 사각형에 타이틀 바를 그린다.
*
* @param figure
* @param g
* @param rect
* void
*/
private void drawTitleBar(IFigure figure, Graphics g, Rectangle rect) {
g.setBackgroundColor(getBackgroundColor());
g.fillRectangle(rect);
Insets padding = getPadding();
int x = rect.x + padding.left;
int y = rect.y + padding.top + (rect.height - getTextExtents(figure).height) / 2;
int textWidth = getTextExtents(figure).width;
int freeSpace = rect.width - padding.getWidth() - textWidth;
if (getTextAlignment() == PositionConstants.CENTER)
freeSpace /= 2;
if (getTextAlignment() != PositionConstants.LEFT)
x += freeSpace;
Font f = getFont(figure);
FontData fData = f.getFontData()[0];
fData.setName(this.getFontName());
fData.setStyle(this.getTextStyle());
fData.setHeight(this.getFontSize());
g.setFont(f);
g.setForegroundColor(this.getTextColor());
g.drawString(getLabel(), x, y);
}
示例7: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics)
*/
@Override
protected void outlineShape(Graphics graphics) {
graphics.pushState();
graphics.setForegroundColor(getForegroundColor());
graphics.setBackgroundColor(getBackgroundColor());
Rectangle f = Rectangle.SINGLETON;
Rectangle r = getBounds();
f.x = r.x + getLineWidth() / 2;
f.y = r.y + getLineWidth() / 2;
f.width = r.width - getLineWidth() - 1;
f.height = r.height - getLineWidth() - 1;
PointList pl = new PointList();
pl.addPoint(f.getTop());
pl.addPoint(f.getRight());
pl.addPoint(f.getBottom());
pl.addPoint(f.getLeft());
graphics.drawPolygon(pl);
graphics.popState();
}
示例8: paintBorder
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see org.eclipse.draw2d.Figure#paintBorder(org.eclipse.draw2d.Graphics)
*/
protected void paintBorder(Graphics graphics) {
super.paintBorder(graphics);
if (this.getContents() != null && ((JDRulerFigure) this.getContents()).getDrawFocus()) {
Rectangle focusBounds = getBounds().getCopy();
if (((JDRulerFigure) this.getContents()).isHorizontal()) {
focusBounds.resize(-2, -4);
focusBounds.x++;
} else {
focusBounds.resize(-4, -2);
focusBounds.y++;
}
graphics.setForegroundColor(ColorConstants.black);
graphics.setBackgroundColor(ColorConstants.white);
// graphics.drawFocus(focusBounds);
}
}
示例9: drawDeviceButton
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void drawDeviceButton(Graphics graphics, int deviceHeight,
int deviceWidth) {
int beginBlackButtonX = (deviceWidth / 2) - 25;
int beginBlackButtonY = deviceHeight - 35 - 25;
int beginCremeButtonX = (deviceWidth / 2) - 20;
int beginCremeButtonY = deviceHeight - 35 - 20;
int beginWhiteButtonX = (deviceWidth / 2) - 18;
int beginWhiteButtonY = deviceHeight - 35 - 18;
graphics.setForegroundColor(black);
graphics.setLineWidth(6);
graphics.drawArc(beginBlackButtonX, beginBlackButtonY, 50, 50, 0, 360);
graphics.setForegroundColor(creameColor);
graphics.setLineWidth(6);
graphics.drawArc(beginCremeButtonX, beginCremeButtonY, 40, 40, 0, 360);
graphics.setBackgroundColor(whiteColor);
graphics.fillArc(beginWhiteButtonX, beginWhiteButtonY, 36, 36, 0, 360);
}
示例10: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Paints this Figure's primary representation, or background
*
* @param graphics
* The Graphics used to paint
*/
protected void paintFigure(Graphics graphics) {
Rectangle rect = getBounds().getCopy();
graphics.setXORMode(true);
graphics.setForegroundColor(ColorConstants.white);
graphics.setBackgroundColor(CustomColorRegistry.INSTANCE.getColorFromRegistry( 31, 31, 31));
graphics.translate(getLocation());
PointList outline = new PointList();
outline.addPoint(0, 0);
outline.addPoint(rect.width - getCornerSize(), 0);
outline.addPoint(rect.width - 1, getCornerSize());
outline.addPoint(rect.width - 1, rect.height - 1);
outline.addPoint(0, rect.height - 1);
graphics.fillPolygon(outline);
// draw the inner outline
PointList innerLine = new PointList();
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(rect.width - getCornerSize() - 1, getCornerSize());
innerLine.addPoint(rect.width - 1, getCornerSize());
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(0, 0);
innerLine.addPoint(0, rect.height - 1);
innerLine.addPoint(rect.width - 1, rect.height - 1);
innerLine.addPoint(rect.width - 1, getCornerSize());
graphics.drawPolygon(innerLine);
graphics.drawLine(rect.width - getCornerSize() - 1, 0, rect.width - 1, getCornerSize());
graphics.translate(getLocation().getNegated());
}
示例11: drawHistory
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawHistory(Graphics g, IArrayIndexModel v, Color color) {
g.setBackgroundColor(color);
List<String> history = v.getHistory();
for (int j = 0; j < history.size()-1; j++) {
Integer i = Integer.parseInt(history.get(j));
Point p = getIndexLocation(i);
if(horizontal)
p = p.translate(0, EXTRA);
g.fillOval(p.x, p.y, PandionJConstants.ILLUSTRATION_LINE_WIDTH+1, PandionJConstants.ILLUSTRATION_LINE_WIDTH+1);
}
}
示例12: drawShadowLayer
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawShadowLayer(final Rectangle rectangle, final Graphics graphics, final int offset, final Color color) {
// Save the state of the graphics object
graphics.pushState();
graphics.setLineWidth(0);
graphics.setBackgroundColor(color);
final Rectangle shadowLayer = new Rectangle(rectangle);
shadowLayer.x += offset;
shadowLayer.y += offset;
final Dimension cornerDimensions = getCornerDimensions();
graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width, cornerDimensions.height);
// Restore the start of the graphics object
graphics.popState();
}
示例13: setupPrinterGraphicsFor
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void setupPrinterGraphicsFor(final Graphics graphics, final IFigure figure) {
final ERDiagram diagram = getDiagram();
final PageSetting pageSetting = diagram.getPageSetting();
final double dpiScale = (double) getPrinter().getDPI().x / Display.getCurrent().getDPI().x * pageSetting.getScale() / 100;
final Rectangle printRegion = getPrintRegion();
// put the print region in display coordinates
printRegion.width /= dpiScale;
printRegion.height /= dpiScale;
final Rectangle bounds = figure.getBounds();
final double xScale = (double) printRegion.width / bounds.width;
final double yScale = (double) printRegion.height / bounds.height;
switch (getPrintMode()) {
case FIT_PAGE:
graphics.scale(Math.min(xScale, yScale) * dpiScale);
break;
case FIT_WIDTH:
graphics.scale(xScale * dpiScale);
break;
case FIT_HEIGHT:
graphics.scale(yScale * dpiScale);
break;
default:
graphics.scale(dpiScale);
}
graphics.setForegroundColor(figure.getForegroundColor());
graphics.setBackgroundColor(figure.getBackgroundColor());
graphics.setFont(figure.getFont());
}
示例14: setupPrinterGraphicsFor
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void setupPrinterGraphicsFor(Graphics graphics, IFigure figure) {
ERDiagram diagram = this.getDiagram();
PageSetting pageSetting = diagram.getPageSetting();
double dpiScale = (double) getPrinter().getDPI().x
/ Display.getCurrent().getDPI().x * pageSetting.getScale()
/ 100;
Rectangle printRegion = getPrintRegion();
// put the print region in display coordinates
printRegion.width /= dpiScale;
printRegion.height /= dpiScale;
Rectangle bounds = figure.getBounds();
double xScale = (double) printRegion.width / bounds.width;
double yScale = (double) printRegion.height / bounds.height;
switch (getPrintMode()) {
case FIT_PAGE:
graphics.scale(Math.min(xScale, yScale) * dpiScale);
break;
case FIT_WIDTH:
graphics.scale(xScale * dpiScale);
break;
case FIT_HEIGHT:
graphics.scale(yScale * dpiScale);
break;
default:
graphics.scale(dpiScale);
}
graphics.setForegroundColor(figure.getForegroundColor());
graphics.setBackgroundColor(figure.getBackgroundColor());
graphics.setFont(figure.getFont());
}
示例15: paintTitle
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paintTitle(Graphics graphics) {
if (Utils.isNotEmpty(getText())){
graphics.pushState();
Color bgColor = graphics.getBackgroundColor();
graphics.setBackgroundColor(ColorConstants.white);
int titleHeight = FigureUtilities.getStringExtents(getText(), titleFont).height;
Rectangle titleRect = getTextHolderRectangle();
Rectangle imRect = new Rectangle(titleRect.x + getMargin(),
titleRect.y + getMargin(), titleHeight, titleHeight);
graphics.fillArc(imRect, 0, 360);
graphics.setBackgroundColor(bgColor);
imRect.shrink(4, 4);
graphics.fillArc(imRect, 0, 360);
graphics.setBackgroundColor(ColorConstants.white);
graphics.fillPolygon(new int[]{imRect.x + imRect.width / 6,
imRect.y + imRect.width / 3,
imRect.x + imRect.width - imRect.width/ 6,
imRect.y + imRect.width / 3,
imRect.x + imRect.width/ 2,
imRect.y + imRect.width});
graphics.setBackgroundColor(ColorConstants.gray);
graphics.drawLine(titleRect.x + 50, titleRect.y + titleHeight + getMargin() + 1,
titleRect.right() - 50, titleRect.y + titleHeight + getMargin() + 1);
graphics.popState();
titleRect.x += titleHeight + getMargin()*2;
titleRect.width -= titleHeight + getMargin()*3;
paintString(graphics, getText(), titleRect);
}
}