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


Java Graphics.setForegroundColor方法代码示例

本文整理汇总了Java中org.eclipse.draw2d.Graphics.setForegroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setForegroundColor方法的具体用法?Java Graphics.setForegroundColor怎么用?Java Graphics.setForegroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.draw2d.Graphics的用法示例。


在下文中一共展示了Graphics.setForegroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
	super.paintFigure(g);
	final int LEG = 5;
	Rectangle r = getBounds();
	g.setLineWidth(1);
	g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
	
	g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
	g.drawLine(r.x, r.y, r.x+LEG, r.y);
	g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);

	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
	g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);

	if(!valid) {
		g.setForegroundColor(PandionJConstants.Colors.ERROR);
		String text = "Invalid matrix";
		int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
		Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
		g.drawText(text, p);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:MatrixWidget.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: paint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void paint(final IFigure figure, final Graphics graphics, final Insets insets) {
    if (getColor() != null) {
        graphics.setForegroundColor(getColor());
    }

    tempRect.setBounds(getPaintRectangle(figure, insets));
    if (getWidth() % 2 == 1) {
        tempRect.width--;
        tempRect.height--;
    }
    tempRect.shrink(getWidth() / 2, getWidth() / 2);
    graphics.setLineWidth(1);

    int g = 9 * DELTA;
    int b = 9 * DELTA;

    for (int i = 0; i <= 5; i++) {
        final Color color = Resources.getColor(new int[] {b, g, 255});
        paint1(i, color, tempRect, graphics);

        g -= DELTA;
        b -= DELTA;
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:29,代码来源:ERDiagramLineBorder.java

示例4: 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

示例5: paint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	if (getColor() != null) {
		graphics.setForegroundColor(getColor());
	}

	tempRect.setBounds(getPaintRectangle(figure, insets));
	if (getWidth() % 2 == 1) {
		tempRect.width--;
		tempRect.height--;
	}
	tempRect.shrink(getWidth() / 2, getWidth() / 2);
	graphics.setLineWidth(1);

	int g = 9 * DELTA;
	int b = 9 * DELTA;

	for (int i = 0; i <= 5; i++) {
		Color color = Resources.getColor(new int[] { b, g, 255 });
		this.paint1(i, color, tempRect, graphics);

		g -= DELTA;
		b -= DELTA;
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:29,代码来源:ERDiagramLineBorder.java

示例6: 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

示例7: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * @see nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
 */
@Override
protected void paintFigure(Graphics graphics) {
    
    super.paintFigure(graphics);
    graphics.setAntialias(SWT.ON);

    graphics.drawRectangle(getLocation().x, getLocation().y, getSize().width - 1, getSize().height - 1);
    
    Rectangle bounds = getBounds();
    if(isDangling()){
        graphics.setForegroundColor(ColorConstants.red);
        graphics.drawOval(bounds.x, bounds.y, 12, 12);
        graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10);
        graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10);
    }
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:20,代码来源:ArtifactFigure.java

示例8: outlineShape

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void outlineShape(Graphics graphics) {
	graphics.pushState();
	//Outline with foreground
	graphics.setForegroundColor(getBackgroundColor());
	super.outlineShape(graphics);
	// draw the 'H' letter
	graphics.setForegroundColor(getForegroundColor());
	graphics.setBackgroundColor(getBackgroundColor());
	graphics.drawLine(
			bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds
					.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (bounds.height * HEIGHT_RATIO)));
	graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (-bounds.height * HEIGHT_RATIO)),
			bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (bounds.height * HEIGHT_RATIO)));
	graphics.drawLine(bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), 0), bounds.getCenter()
			.getTranslated((int) (bounds.width * OFFSET), 0));

	// draw the '*' character
	graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)),
			bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * OFFSET)));
	graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.20)),
			bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.10)));
	graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.20)),
			bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.10)));
	graphics.popState();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:27,代码来源:DeepHistoryFigure.java

示例9: fillShape

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void fillShape(Graphics graphics) {
	super.fillShape(graphics);

	int h = graphics.getFontMetrics().getHeight();

	Rectangle r = getBounds();
	if (text != null) {
		graphics.setForegroundColor(getForegroundColor());
		int y = r.y + 2;
		int x = r.x + 2;
		for (String txt : text) {
			graphics.drawText(txt, x, y);
			y += h + 3;
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:CalloutFigure.java

示例10: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
public void paintFigure(Graphics g) {
	Rectangle bounds = getBounds().getCopy();

	// Avoid drawing images that are 0 in dimension
	if (bounds.width < 5 || bounds.height < 5)
		return;

	// Don't paint the selector figure if the entire source is visible.
	Dimension thumbnailSize = new Dimension(getThumbnailImage());
	// expand to compensate for rounding errors in calculating bounds
	Dimension size = getSize().getExpanded(1, 1);
	if (size.contains(thumbnailSize))
		return;

	bounds.height--;
	bounds.width--;

	Image image = new Image(Display.getCurrent(), iData);
	g.drawImage(image, iBounds, bounds);
	image.dispose();

	g.setForegroundColor(ColorConstants.menuBackgroundSelected);
	g.drawRectangle(bounds);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:ScrollableThumbnail.java

示例11: 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

示例12: paint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
    if (getColor() != null) {
        graphics.setForegroundColor(getColor());
    }

    tempRect.setBounds(getPaintRectangle(figure, insets));
    if (getWidth() % 2 == 1) {
        tempRect.width--;
        tempRect.height--;
    }
    tempRect.shrink(getWidth() / 2, getWidth() / 2);
    graphics.setLineWidth(1);

    int g = 9 * DELTA;
    int b = 9 * DELTA;

    for (int i = 0; i <= 5; i++) {
        final Color color = DesignResources.getColor(new int[] { b, g, 255 });
        paint1(i, color, tempRect, graphics);

        g -= DELTA;
        b -= DELTA;
    }
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:26,代码来源:ERDiagramLineBorder.java

示例13: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(TextAttribute textAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  java.awt.Color color = textAttr.textColor.asColor();
  if (color != null) {
    Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
    graphics.setForegroundColor(rgb);
  }

  try {
    String text = textAttr.text.getExpression();
    int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue();
    String fontFamily = textAttr.fontFamily.stringValue();
    boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue();
    boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue();
    int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL);
    Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style));
    graphics.setFont(f);

    Point tlp = getTopLeftLocation(textAttr);
    graphics.drawText(text, tlp);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading properties for " + textAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:27,代码来源:TextDrawingStrategy.java

示例14: 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

示例15: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
	super.paintFigure(g);
	g.setForegroundColor(ColorConstants.gray);
	Rectangle r = getBounds();
	g.drawLine(r.getTopLeft(), r.getBottomRight());
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:8,代码来源:ValueFigure.java


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