当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.setBackgroundColor方法代码示例

本文整理汇总了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();
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:25,代码来源:SearchBarFigure.java

示例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));
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:ReferenceLabel.java

示例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);
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:19,代码来源:ERDecoration.java

示例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();
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:18,代码来源:DropShadowRectangle.java

示例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);
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:19,代码来源:ERDecoration.java

示例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);
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:34,代码来源:TitleBarBorder.java

示例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();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:25,代码来源:ChoiceFigure.java

示例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);
			}
		}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:JDRulerRootEditPart.java

示例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);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:25,代码来源:AndroidMobileScreenFigure.java

示例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());
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:44,代码来源:CommentBoxFeedbackFigure.java

示例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);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:14,代码来源:IllustrationBorder.java

示例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();
    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:16,代码来源:DropShadowRectangle.java

示例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());
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:36,代码来源:PrintERDiagramOperation.java

示例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());
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:38,代码来源:PrintERDiagramOperation.java

示例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);
		
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:35,代码来源:AndroidAlertDialogFigure.java


注:本文中的org.eclipse.draw2d.Graphics.setBackgroundColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。