本文整理汇总了Java中org.eclipse.draw2d.Graphics.fillPolygon方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.fillPolygon方法的具体用法?Java Graphics.fillPolygon怎么用?Java Graphics.fillPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.fillPolygon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void fillShape(final Graphics graphics) {
graphics.setAlpha(200);
final Rectangle bounds = getBounds();
final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
final PointList pointList = new PointList();
pointList.addPoint(bounds.getTopLeft());
pointList.addPoint(bounds.getBottomLeft());
pointList.addPoint(bounds.getBottomRight());
pointList.addPoint(topRight1);
pointList.addPoint(topRight2);
pointList.addPoint(bounds.getTopLeft());
graphics.fillPolygon(pointList);
}
示例2: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void fillShape(Graphics graphics) {
graphics.setAlpha(200);
Rectangle bounds = this.getBounds();
Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
PointList pointList = new PointList();
pointList.addPoint(bounds.getTopLeft());
pointList.addPoint(bounds.getBottomLeft());
pointList.addPoint(bounds.getBottomRight());
pointList.addPoint(topRight1);
pointList.addPoint(topRight2);
pointList.addPoint(bounds.getTopLeft());
graphics.fillPolygon(pointList);
}
示例3: doFillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void doFillShape(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.fillPolygon(pList);
}
示例4: 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());
}
示例5: 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());
}
示例6: 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);
}
}
示例7: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.figure.ShadowShape#fillShape(org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Rectangle)
*/
protected void fillShape(Graphics graphics, Rectangle bounds) {
PointList pl = setupPoints(bounds);
graphics.setAntialias(SWT.ON);
graphics.fillPolygon(pl);
int add = graphics.getLineWidth() / 2;
graphics.fillOval(new Rectangle(ovalX, ovalY, ovalD + add, ovalD + add));
}
示例8: 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);
}
示例9: 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);
}
示例10: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics)
*/
@Override
protected void fillShape(Graphics graphics) {
graphics.pushState();
graphics.setForegroundColor(getForegroundColor());
graphics.setBackgroundColor(getBackgroundColor());
PointList pl = new PointList();
pl.addPoint(getBounds().getTop());
pl.addPoint(getBounds().getRight());
pl.addPoint(getBounds().getBottom());
pl.addPoint(getBounds().getLeft());
graphics.fillPolygon(pl);
graphics.popState();
}
示例11: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics)
{
super.paintFigure(graphics);
Rectangle clientArea = getClientArea();
Point top = clientArea.getTop();
Point right = clientArea.getRight();
final int oldWid = graphics.getLineWidth();
graphics.setLineWidth(3);
PointList points = new PointList();
if (isHorizontal())
{
graphics.drawLine(clientArea.getLeft(), right);
points.addPoint(right);
points.addPoint(right.getCopy().translate(-ARROW_HEAD_LENGTH,
-ARROW_HEAD_HALF_WIDTH));
points.addPoint(right.getCopy().translate(-ARROW_HEAD_LENGTH,
ARROW_HEAD_HALF_WIDTH));
}
else
{
graphics.drawLine(clientArea.getBottom(), top);
points.addPoint(top);
points.addPoint(top.getCopy().translate(ARROW_HEAD_HALF_WIDTH,
ARROW_HEAD_LENGTH));
points.addPoint(top.getCopy().translate(-ARROW_HEAD_HALF_WIDTH,
ARROW_HEAD_LENGTH));
}
graphics.fillPolygon(points);
graphics.setLineWidth(oldWid);
}
示例12: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void fillShape(Graphics graphics) {
graphics.setAlpha(200);
final Rectangle bounds = getBounds();
final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
final PointList pointList = new PointList();
pointList.addPoint(bounds.getTopLeft());
pointList.addPoint(bounds.getBottomLeft());
pointList.addPoint(bounds.getBottomRight());
pointList.addPoint(topRight1);
pointList.addPoint(topRight2);
pointList.addPoint(bounds.getTopLeft());
graphics.fillPolygon(pointList);
}
示例13: drawYErrorArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawYErrorArea(final Graphics graphics, final ISample predp,
final ISample dp, final Point predpPos, final Point dpPos) {
// Shortcut if there is no error area
if (predp.getYPlusError() == 0.0 && predp.getYMinusError() == 0.0
&& dp.getYPlusError() == 0.0 && dp.getYMinusError() == 0.0)
return;
graphics.pushState();
Color lighter = null;
if (use_advanced_graphics) {
graphics.setBackgroundColor(errorBarColor);
graphics.setAlpha(areaAlpha);
} else {
final float[] hsb = errorBarColor.getRGB().getHSB();
lighter = new Color(Display.getCurrent(), new RGB(hsb[0], hsb[1]
* areaAlpha / 255, 1.0f));
graphics.setBackgroundColor(lighter);
}
final int predp_xpos = xAxis.getValuePosition(predp.getXValue(), false);
final int dp_xpos = xAxis.getValuePosition(dp.getXValue(), false);
Point preEp, ep;
switch (yErrorBarType) {
case BOTH:
case PLUS:
preEp = new Point(predp_xpos, yAxis.getValuePosition(
predp.getYValue() + predp.getYPlusError(), false));
ep = new Point(dp_xpos, yAxis.getValuePosition(
dp.getYValue() + dp.getYPlusError(), false));
graphics.fillPolygon(new int[] { predpPos.x, predpPos.y, preEp.x,
preEp.y, ep.x, ep.y, dpPos.x, dpPos.y });
if (yErrorBarType != ErrorBarType.BOTH)
break;
case MINUS:
preEp = new Point(predp_xpos, yAxis.getValuePosition(
predp.getYValue() - predp.getYMinusError(), false));
ep = new Point(dp_xpos, yAxis.getValuePosition(
dp.getYValue() - dp.getYMinusError(), false));
graphics.fillPolygon(new int[] { predpPos.x, predpPos.y, preEp.x,
preEp.y, ep.x, ep.y, dpPos.x, dpPos.y });
break;
default:
break;
}
graphics.popState();
if (lighter != null)
lighter.dispose();
}
示例14: 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();
}
示例15: drawLine
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Draw line with the line style and line width of the trace.
*
* @param graphics
* @param p1
* @param p2
*/
public void drawLine(Graphics graphics, Point p1, Point p2) {
graphics.pushState();
graphics.setLineWidth(lineWidth);
switch (traceType) {
case SOLID_LINE:
graphics.setLineStyle(SWTConstants.LINE_SOLID);
graphics.drawLine(p1, p2);
break;
case BAR:
if (use_advanced_graphics)
graphics.setAlpha(areaAlpha);
graphics.setLineStyle(SWTConstants.LINE_SOLID);
graphics.drawLine(p1, p2);
break;
case DASH_LINE:
graphics.setLineStyle(SWTConstants.LINE_DASH);
graphics.drawLine(p1, p2);
break;
case AREA:
int basey;
switch (baseLine) {
case NEGATIVE_INFINITY:
basey = yAxis.getValuePosition(yAxis.getRange().getLower(),
false);
break;
case POSITIVE_INFINITY:
basey = yAxis.getValuePosition(yAxis.getRange().getUpper(),
false);
break;
default:
basey = yAxis.getValuePosition(0, false);
break;
}
if (use_advanced_graphics)
graphics.setAlpha(areaAlpha);
graphics.setBackgroundColor(traceColor);
graphics.fillPolygon(new int[] { p1.x, p1.y, p1.x, basey, p2.x,
basey, p2.x, p2.y });
break;
case STEP_HORIZONTALLY:
graphics.setLineStyle(SWTConstants.LINE_SOLID);
graphics.drawLine(p1.x, p1.y, p2.x, p1.y);
graphics.drawLine(p2.x, p1.y, p2.x, p2.y);
break;
case STEP_VERTICALLY:
graphics.setLineStyle(SWTConstants.LINE_SOLID);
graphics.drawLine(p1.x, p1.y, p1.x, p2.y);
graphics.drawLine(p1.x, p2.y, p2.x, p2.y);
break;
default:
break;
}
graphics.popState();
}