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


Java Graphics.getForegroundColor方法代码示例

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


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

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

示例2: paintString

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintString(Graphics graphics, String text, Rectangle parentRect) {
	Color oldFG = graphics.getForegroundColor(); 
	if(fgColor != null)
		graphics.setForegroundColor(fgColor);
	super.paintString(graphics, text, parentRect);
	graphics.setForegroundColor(oldFG);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:8,代码来源:TabbedBarButtonFigure.java

示例3: paintTitaniumFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintTitaniumFigure(Graphics graphics) {
	setTextHorisontalAlign(Alignments.center);
	Color oldFG = graphics.getForegroundColor();
	graphics.setForegroundColor(new Color(null, 204, 204, 204));
	this.paintString(graphics, getTime(), getBounds());
	setTextHorisontalAlign(Alignments.left);
	this.paintString(graphics, CARRIER, getBounds());
	graphics.setForegroundColor(oldFG);
	this.paintLeftImage(graphics);
	this.paintRightImage(graphics);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:IPadCarrierFigure.java

示例4: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Template method to enforce all standard logic for drawing the shape and its border.
 */
@Override
public final void draw(A shapeAttribute, Graphics graphics, ResourceManager resourceManager) {
  Color stdFgColor = graphics.getForegroundColor();
  Color stdBgColor = graphics.getBackgroundColor();
  float stdLineWidth = graphics.getLineWidthFloat();
  int stdAlpha = graphics.getAlpha();

  try {
    Point tlp = getTopLeftLocation(shapeAttribute);
    Dimension dim = getDimension(shapeAttribute, resourceManager);

    Color lineColor = getSwtColor(shapeAttribute.lineColor, resourceManager);
    Color fillColor = getSwtColor(shapeAttribute.fillColor, resourceManager);
    if (lineColor != null) {
      graphics.setForegroundColor(lineColor);
    }
    if (fillColor != null) {
      graphics.setBackgroundColor(fillColor);
    }

    float lineWidth = (float) ((DoubleToken) shapeAttribute.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);

    Rectangle bounds = new Rectangle(tlp.x, tlp.y, dim.width(), dim.height());
    // do the filling of the shape
    graphics.setAlpha(fillColor.getAlpha());
    doFillShape(shapeAttribute, graphics, bounds);
    // draw the border of the shape
    graphics.setAlpha(lineColor.getAlpha());
    doDrawBorder(shapeAttribute, graphics, bounds);
  } catch (IllegalActionException e) {
    getLogger().error("Error reading properties of " + shapeAttribute.getFullName(), e);
  } finally {
    graphics.setLineWidthFloat(stdLineWidth);
    graphics.setForegroundColor(stdFgColor);
    graphics.setBackgroundColor(stdBgColor);
    graphics.setAlpha(stdAlpha);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:43,代码来源:FilledShapeDrawingStrategy.java

示例5: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(ArrowAttribute arrowAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  Color bgColor = graphics.getBackgroundColor();
  Color rgb = getSwtColor(arrowAttr.lineColor, resourceManager);
  if (rgb != null) {
    graphics.setForegroundColor(rgb);
    graphics.setBackgroundColor(rgb);
  }

  try {
    float lineWidth = (float) ((DoubleToken) arrowAttr.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);
    int x = (int) ((DoubleToken) arrowAttr.x.getToken()).doubleValue();
    int y = (int) ((DoubleToken) arrowAttr.y.getToken()).doubleValue();
    int width = (int) ((DoubleToken) arrowAttr.arrowWidth.getToken()).doubleValue();
    int length = (int) ((DoubleToken) arrowAttr.arrowLength.getToken()).doubleValue();
    int halfWidth = width/2;
    Point tlp = getTopLeftLocation(arrowAttr);
    Transform transform = new Transform();
    transform.setRotation(Math.atan2(y, x));
    PointList pList = new PointList();
    pList.addPoint(0, halfWidth);
    pList.addPoint(length + 3,  0);
    pList.addPoint(length,  halfWidth);
    pList.addPoint((int) Math.sqrt(x*x + y*y),  halfWidth);
    pList.addPoint(length,  halfWidth);
    pList.addPoint(length + 3,  width);
    pList = getTransformedPolygon(transform, pList);
    pList.translate(tlp);
    graphics.fillPolygon(pList);
    graphics.drawPolygon(pList);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + arrowAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
  graphics.setBackgroundColor(bgColor);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:39,代码来源:ArrowDrawingStrategy.java

示例6: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(LineAttribute lineAttr, Graphics graphics, ResourceManager resourceManager) {
  Color stdFgColor = graphics.getForegroundColor();
  int stdLineStyle = graphics.getLineStyle();

  Color lineColor = getSwtColor(lineAttr.lineColor, resourceManager);
  if (lineColor != null) {
    graphics.setForegroundColor(lineColor);
  }

  try {
    float lineWidth = (float) ((DoubleToken) lineAttr.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);
    int x2_step = (int) ((DoubleToken) lineAttr.x.getToken()).doubleValue();
    int y2_step = (int) ((DoubleToken) lineAttr.y.getToken()).doubleValue();

    // TODO may need to move this upwards as other shape types may also have dashed lines in Ptolemy II
    ArrayToken dashArrayToken = (ArrayToken) lineAttr.dashArray.getToken();
    if (dashArrayToken != null && dashArrayToken.length() > 0) {
      graphics.setLineStyle(SWT.LINE_DASH);
      float[] dashPattern = new float[dashArrayToken.length()];
      for (int i = 0; i < dashArrayToken.length(); i++) {
        dashPattern[i] = (float) ((DoubleToken) dashArrayToken.getElement(i)).doubleValue();
      }
      graphics.setLineDash(dashPattern);
    }
    Point tlp = getTopLeftLocation(lineAttr);
    graphics.drawLine(tlp, tlp.getTranslated(x2_step, y2_step));
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + lineAttr.getFullName(), e);
  } finally {
    graphics.setForegroundColor(stdFgColor);
    graphics.setLineStyle(stdLineStyle);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:36,代码来源:LineDrawingStrategy.java

示例7: paintGrid

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void paintGrid(final Graphics g) {
    super.paintGrid(g);

    final Rectangle clip = g.getClip(Rectangle.SINGLETON);

    final PageSetting pageSetting = diagram.getPageSetting();

    final int width = pageSetting.getWidth();
    final int height = pageSetting.getHeight();

    final Rectangle rect = clip;

    final Color color = g.getForegroundColor();
    g.setForegroundColor(ColorConstants.lightGray);

    int startX = rect.x;
    if (startX > 0) {
        startX = 0;
    }
    int startY = rect.y;
    if (startY > 0) {
        startY = 0;
    }

    for (int i = startX; i < rect.x + rect.width; i += width) {
        g.drawLine(i, rect.y, i, rect.y + rect.height);
    }

    for (int i = startY; i < rect.y + rect.height; i += height) {
        g.drawLine(rect.x, i, rect.x + rect.width, i);
    }

    g.setForegroundColor(color);

    i++;
    if (i > 0) {
        i = -1;
        repaint();
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:45,代码来源:PagableFreeformRootEditPart.java

示例8: paintGrid

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void paintGrid(Graphics g) {
	super.paintGrid(g);

	Rectangle clip = g.getClip(Rectangle.SINGLETON);

	PageSetting pageSetting = diagram.getPageSetting();

	int width = pageSetting.getWidth();
	int height = pageSetting.getHeight();

	Rectangle rect = clip;

	Color color = g.getForegroundColor();
	g.setForegroundColor(ColorConstants.lightGray);

	int startX = rect.x;
	if (startX > 0) {
		startX = 0;
	}
	int startY = rect.y;
	if (startY > 0) {
		startY = 0;
	}

	for (int i = startX; i < rect.x + rect.width; i += width) {
		g.drawLine(i, rect.y, i, rect.y + rect.height);
	}

	for (int i = startY; i < rect.y + rect.height; i += height) {
		g.drawLine(rect.x, i, rect.x + rect.width, i);
	}

	g.setForegroundColor(color);

	i++;
	if (i > 0) {
		i = -1;
		repaint();
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:45,代码来源:PagableFreeformRootEditPart.java

示例9: paintGrid

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

    Rectangle clip = g.getClip(Rectangle.SINGLETON);

    PageSettings pageSetting = diagram.getPageSetting();

    int width = pageSetting.getWidth();
    int height = pageSetting.getHeight();

    Rectangle rect = clip;

    Color color = g.getForegroundColor();
    g.setForegroundColor(ColorConstants.lightGray);

    int startX = rect.x;
    if (startX > 0) {
        startX = 0;
    }
    int startY = rect.y;
    if (startY > 0) {
        startY = 0;
    }

    for (int i = startX; i < rect.x + rect.width; i += width) {
        g.drawLine(i, rect.y, i, rect.y + rect.height);
    }

    for (int i = startY; i < rect.y + rect.height; i += height) {
        g.drawLine(rect.x, i, rect.x + rect.width, i);
    }

    g.setForegroundColor(color);

    i++;
    if (i > 0) {
        i = -1;
        repaint();
    }
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:42,代码来源:PagableFreeformRootEditPart.java


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