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


Java Graphics.drawPolygon方法代码示例

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


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

示例1: doDrawBorder

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void doDrawBorder(ResizablePolygonAttribute polygonAttr, Graphics graphics, Rectangle bounds) throws IllegalActionException {
  PointList pList = getPolygonPoints(polygonAttr);
  
  Dimension dim = bounds.getSize();
  Point tlp = bounds.getTopLeft();
  Dimension rawDim = getRawBounds(pList).getSize();
  
  // Ptolemy scales x and y potentially differently, depending on the ratios
  // of dim width & height and rawDim width & height respectively.
  double scaleWidth = dim.preciseWidth() / rawDim.preciseWidth();
  double scaleHeight = dim.preciseHeight() / rawDim.preciseHeight();
  Transform transform = new Transform();
  transform.setScale(scaleWidth, scaleHeight);
  pList = getTransformedPolygon(transform, pList);
  pList.translate(tlp);
  graphics.drawPolygon(pList);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:19,代码来源:ResizablePolygonDrawingStrategy.java

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

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

示例4: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Paints this Figure's primary representation, or background. Changes made
 *to the graphics to the graphics current state will not affect the
 * @param graphics
 * 					The Graphics used to paint
 */
protected void paintFigure(Graphics graphics) {
	Rectangle rect = getBounds().getCopy();

	graphics.translate(getLocation());

	// fill the note
	PointList outline = new PointList();
	
	outline.addPoint(0, 0);
	outline.addPoint(rect.width - cornerSize, 0);
	outline.addPoint(rect.width - 1, cornerSize);
	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 - cornerSize - 1, 0);
	innerLine.addPoint(rect.width - cornerSize - 1, cornerSize);
	innerLine.addPoint(rect.width - 1, cornerSize);
	innerLine.addPoint(rect.width - cornerSize - 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, cornerSize);
	
	graphics.drawPolygon(innerLine);
	
	graphics.translate(getLocation().getNegated());
 }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:39,代码来源:BentCornerFigure.java

示例5: outlineShape

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * @see nexcore.tool.uml.ui.core.diagram.figure.ShadowShape#outlineShape(org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Rectangle)
 */
protected void outlineShape(Graphics graphics, Rectangle bounds) {
    PointList pl = setupPoints(bounds);
    graphics.setAntialias(SWT.ON);
    graphics.drawPolygon(pl);
    int add = graphics.getLineWidth() / 2;
    graphics.drawOval(new Rectangle(ovalX, ovalY, ovalD + add, ovalD + add));
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:11,代码来源:StickMan.java

示例6: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
 */
@Override
protected void paintFigure(Graphics graphics) {

    // Rectangle r = new Rectangle();
    r.setBounds(getBounds());
    r.crop(getInsets());

    int pixelWidth = 2;
    PointList diamond = new PointList(4);
    // 4 points of the diamond.
    Point top, right, bottom, left;
    top = new Point(r.x + r.width / 2, r.y);
    right = new Point((r.x + r.width - pixelWidth), r.y + r.height / 2);
    bottom = new Point((r.x + r.width / 2 - pixelWidth), r.y + r.height - 1); // The
                                                                              // -1
                                                                              // fixes
                                                                              // the
                                                                              // look
    left = new Point(r.x, r.y + r.height / 2);

    diamond.removeAllPoints();
    diamond.addPoint(top);
    diamond.addPoint(right);
    diamond.addPoint(bottom);
    diamond.addPoint(left);

    // graphics.setBackgroundColor(ColorConstants.lightGray);
    graphics.setAntialias(SWT.ON);

    graphics.fillPolygon(diamond);
    graphics.drawPolygon(diamond);
    super.paintFigure(graphics);
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:37,代码来源:DecisionNodeFigure.java

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

示例8: drawPoint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Draw point with the pointStyle and size of the trace;
 * 
 * @param graphics
 * @param pos
 */
public void drawPoint(Graphics graphics, Point pos) {
	// Shortcut when no point requested
	if (pointStyle == PointStyle.NONE)
		return;
	graphics.pushState();
	graphics.setBackgroundColor(traceColor);
	// graphics.setForegroundColor(traceColor);
	graphics.setLineWidth(1);
	graphics.setLineStyle(SWTConstants.LINE_SOLID);
	switch (pointStyle) {
	case POINT:
		graphics.fillOval(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case CIRCLE:
		graphics.drawOval(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case TRIANGLE:
		graphics.drawPolygon(new int[] { pos.x - pointSize / 2,
				pos.y + pointSize / 2, pos.x, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2 });
		break;
	case FILLED_TRIANGLE:
		graphics.fillPolygon(new int[] { pos.x - pointSize / 2,
				pos.y + pointSize / 2, pos.x, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2 });
		break;
	case SQUARE:
		graphics.drawRectangle(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case FILLED_SQUARE:
		graphics.fillRectangle(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case BAR:
		graphics.drawLine(pos.x, pos.y - pointSize / 2, pos.x, pos.y
				+ pointSize / 2);
		break;
	case CROSS:
		graphics.drawLine(pos.x, pos.y - pointSize / 2, pos.x, pos.y
				+ pointSize / 2);
		graphics.drawLine(pos.x - pointSize / 2, pos.y, pos.x + pointSize
				/ 2, pos.y);
		break;
	case XCROSS:
		graphics.drawLine(pos.x - pointSize / 2, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2);
		graphics.drawLine(pos.x + pointSize / 2, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y + pointSize / 2);
		break;
	case DIAMOND:
		graphics.drawPolyline(new int[] { pos.x, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y, pos.x, pos.y + pointSize / 2,
				pos.x + pointSize / 2, pos.y, pos.x, pos.y - pointSize / 2 });
		break;
	case FILLED_DIAMOND:
		graphics.fillPolygon(new int[] { pos.x, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y, pos.x, pos.y + pointSize / 2,
				pos.x + pointSize / 2, pos.y });
		break;
	default:
		break;
	}
	graphics.popState();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:74,代码来源:Trace.java


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