java.awt.Polygon.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中java.awt.Polygon.<init>()方法的一些代码示例,展示了Polygon.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.<init>()方法的具体详情如下:
包路径:java.awt.Polygon
类名称:Polygon
方法名:<init>

Polygon.<init>介绍

[英]Creates an empty polygon.
[中]创建一个空多边形。

代码示例

代码示例来源:origin: plantuml/plantuml

private void addSymbolExtendsInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(-25, 7);
  arrow.addPoint(-25, -7);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: plantuml/plantuml

private void addSymbolNavasocInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(13, -8);
  arrow.addPoint(6, 0);
  arrow.addPoint(13, 8);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: plantuml/plantuml

private void addSymbolDiamondInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(10, 6);
  arrow.addPoint(20, 0);
  arrow.addPoint(10, -6);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: plantuml/plantuml

private void addSymbolDiamond(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(-10, 6);
  arrow.addPoint(-20, 0);
  arrow.addPoint(-10, -6);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: plantuml/plantuml

private void addSymbolNavasoc(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(-13, -8);
  arrow.addPoint(-6, 0);
  arrow.addPoint(-13, 8);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: plantuml/plantuml

private void addSymbolExtends(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
  final Polygon arrow = new Polygon();
  arrow.addPoint(0, 0);
  arrow.addPoint(25, 7);
  arrow.addPoint(25, -7);
  appendAndRotate(generalPath, point, seg, arrow);
}

代码示例来源:origin: stackoverflow.com

import java.awt.Polygon;

public class JavaTest {

 public static void main(final String[] args) {

  final Polygon polygon = new Polygon();
  polygon.addPoint(-10, -10);
  polygon.addPoint(-10, 10);
  polygon.addPoint(10, 10);
  polygon.addPoint(10, -10);

  System.out.println(polygon.contains(0, 0));

 }

}

代码示例来源:origin: plantuml/plantuml

@Override
  public void draw(ColorMapper colorMapper, Graphics2D g2d) {
    final Polygon p = new Polygon();
    p.addPoint(size, 0);
    p.addPoint(size * 2, size);
    p.addPoint(size, size * 2);
    p.addPoint(0, size);

    g2d.setColor(colorMapper.getMappedColor(getYellow()));
    g2d.fill(p);
    g2d.setColor(colorMapper.getMappedColor(getRed()));
    g2d.draw(p);
  }
}

代码示例来源:origin: Activiti/Activiti

public void drawGateway(GraphicInfo graphicInfo) {
  Polygon rhombus = new Polygon();
  int x = (int) graphicInfo.getX();
  int y = (int) graphicInfo.getY();
  int width = (int) graphicInfo.getWidth();
  int height = (int) graphicInfo.getHeight();
  rhombus.addPoint(x,
           y + (height / 2));
  rhombus.addPoint(x + (width / 2),
           y + height);
  rhombus.addPoint(x + width,
           y + (height / 2));
  rhombus.addPoint(x + (width / 2),
           y);
  g.draw(rhombus);
}

代码示例来源:origin: Activiti/Activiti

doubleArrowWidth = 2;
Polygon arrowHead = new Polygon();
arrowHead.addPoint(0,
          0);
int arrowHeadPoint = (int) (-ARROW_WIDTH);
  arrowHeadPoint = -1;
arrowHead.addPoint(arrowHeadPoint,
          -doubleArrowWidth);
arrowHeadPoint = (int) (ARROW_WIDTH);
  arrowHeadPoint = 1;
arrowHead.addPoint(arrowHeadPoint,
          -doubleArrowWidth);

代码示例来源:origin: Activiti/Activiti

public void drawConditionalSequenceFlowIndicator(Line2D.Double line) {
  int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
  int halfOfHorizontal = horizontal / 2;
  int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;
  Polygon conditionalIndicator = new Polygon();
  conditionalIndicator.addPoint(0,
                 0);
  conditionalIndicator.addPoint(-halfOfHorizontal,
                 halfOfVertical);
  conditionalIndicator.addPoint(0,
                 CONDITIONAL_INDICATOR_WIDTH);
  conditionalIndicator.addPoint(halfOfHorizontal,
                 halfOfVertical);
  AffineTransform transformation = new AffineTransform();
  transformation.setToIdentity();
  double angle = Math.atan2(line.y2 - line.y1,
               line.x2 - line.x1);
  transformation.translate(line.x1,
               line.y1);
  transformation.rotate((angle - Math.PI / 2d));
  AffineTransform originalTransformation = g.getTransform();
  g.setTransform(transformation);
  g.draw(conditionalIndicator);
  Paint originalPaint = g.getPaint();
  g.setPaint(CONDITIONAL_INDICATOR_COLOR);
  g.fill(conditionalIndicator);
  g.setPaint(originalPaint);
  g.setTransform(originalTransformation);
}

代码示例来源:origin: stackoverflow.com

radii);
Polygon pointer = new Polygon();
  pointer.addPoint(
      strokePad + radii + pointerPad,
      bottomLineY);
  pointer.addPoint(
      strokePad + radii + pointerPad + pointerSize,
      bottomLineY);
  pointer.addPoint(
      strokePad + radii + pointerPad + (pointerSize / 2),
      height - strokePad);

代码示例来源:origin: jenkinsci/jenkins

Polygon p = new Polygon();
p.addPoint((int) xx0, (int) yy0);
p.addPoint((int) (xx0+xx1)/2, (int) (yy0+yy1)/2);
p.addPoint((int) (xx0+xx1)/2, (int) (previousHeightxx0+previousHeightxx1)/2);
p.addPoint((int) xx0, (int) previousHeightxx0);
p = new Polygon();
p.addPoint((int) xx1, (int) yy1);
p.addPoint((int) (xx0+xx1)/2, (int) (yy0+yy1)/2);

代码示例来源:origin: stackoverflow.com

int fila = runCount;
    for (int i = 0; i < lines.length - 1; i++, fila--) {
      Polygon carp = new Polygon();
      carp.addPoint(0, lines[i]);
      carp.addPoint(tabPane.getWidth() - 2 * fila - 2, lines[i]);
      carp.addPoint(tabPane.getWidth() - 2 * fila, lines[i] + 3);
      if (i < lines.length - 2) {
        carp.addPoint(tabPane.getWidth() - 2 * fila, lines[i + 1]);
    int fila = 0;
    for (int i = 0; i < lines.length - 1; i++, fila++) {
      Polygon carp = new Polygon();
      carp.addPoint(0, lines[i]);
      carp.addPoint(tabPane.getWidth() - 2 * fila - 1, lines[i]);
shape = new Polygon(xp, yp, xp.length);
if (isSelected) {
  g2D.setColor(selectColor);

代码示例来源:origin: runelite/runelite

Polygon p = new Polygon();
for (Point point : points)
  p.addPoint(point.getX(), point.getY());

代码示例来源:origin: runelite/runelite

Polygon hull = new Polygon();
for (Point p : points)
    hull.addPoint(p.getX(), p.getY());

代码示例来源:origin: runelite/runelite

Polygon poly = new Polygon();
poly.addPoint(p1.getX(), p1.getY());
poly.addPoint(p2.getX(), p2.getY());
poly.addPoint(p3.getX(), p3.getY());
poly.addPoint(p4.getX(), p4.getY());

代码示例来源:origin: geotools/geotools

/** Converts the rectangle into a java.awt.Polygon. */
public static java.awt.Polygon rectangleToPolygon(Rectangle rect) {
  java.awt.Polygon result = new java.awt.Polygon();
  result.addPoint(rect.x, rect.y);
  result.addPoint(rect.x + rect.width, rect.y);
  result.addPoint(rect.x + rect.width, rect.y + rect.height);
  result.addPoint(rect.x, rect.y + rect.height);
  return result;
}

代码示例来源:origin: knowm/XChart

@Override
 public void paint(Graphics2D g, double xOffset, double yOffset, int markerSize) {
  g.setStroke(stroke);
  double halfSize = (double) markerSize / 2;
  Polygon polygon = new Polygon();

  for (int i = 1; i <= 4; i++) {
   polygon.addPoint(
     (int) ((xOffset) + (markerSize * 0.75) * Math.sin(i * 2 * Math.PI / 5)),
     (int)
       ((yOffset + (markerSize * 0.25))
         + (markerSize * 0.75) * Math.cos(i * 2 * Math.PI / 5)));
  }

  g.fillPolygon(polygon);
 }
}

代码示例来源:origin: stackoverflow.com

public static Shape createArrowShape(Point fromPt, Point toPt) {
  Polygon arrowPolygon = new Polygon();
  arrowPolygon.addPoint(-6,1);
  arrowPolygon.addPoint(3,1);
  arrowPolygon.addPoint(3,3);
  arrowPolygon.addPoint(6,0);
  arrowPolygon.addPoint(3,-3);
  arrowPolygon.addPoint(3,-1);
  arrowPolygon.addPoint(-6,-1);

  Point midPoint = midpoint(fromPt, toPt);

  double rotate = Math.atan2(toPt.y - fromPt.y, toPt.x - fromPt.x);

  AffineTransform transform = new AffineTransform();
  transform.translate(midPoint.x, midPoint.y);
  double ptDistance = fromPt.distance(toPt);
  double scale = ptDistance / 12.0; // 12 because it's the length of the arrow polygon.
  transform.scale(scale, scale);
  transform.rotate(rotate);

  return transform.createTransformedShape(arrowPolygon);
}

private static Point midpoint(Point p1, Point p2) {
  return new Point((int)((p1.x + p2.x)/2.0), 
           (int)((p1.y + p2.y)/2.0));
}

相关文章