Пример #1
0
  @Override
  public void paint(Graphics2D g, IGizmo gizmo) {
    int orientation = gizmo.getOrientation();
    int x = gizmo.getX(), y = gizmo.getY();

    Flipper flipper = (Flipper) gizmo;

    Path2D.Double path = new Path2D.Double();
    path.moveTo(x, y + 0.25);
    path.lineTo(x, y + 1.75);
    path.curveTo(x, y + 2, x + 0.5, y + 2, x + 0.5, y + 1.75);
    path.lineTo(x + 0.5, y + 0.25);
    path.curveTo(x + 0.5, y, x, y, x, y + 0.25);

    if (flipper.getAngle() != 0)
      path.transform(AffineTransform.getRotateInstance(flipper.getAngle(), x + 0.25, y + 0.25));

    if (orientation != 0)
      path.transform(AffineTransform.getRotateInstance(Math.PI / 2 * orientation, x + 1, y + 1));

    g.setColor(Color.ORANGE);
    g.fill(path);

    g.setColor(Color.ORANGE.darker());
    g.draw(path);
  }
 private Path2D.Double getPath() {
   double width = getWidth() - 1;
   double height = getHeight();
   Path2D.Double path = new Path2D.Double();
   path.moveTo(0.0, arcwidth);
   path.curveTo(0.0, 0.0, arcwidth, 0.0, arcwidth, 0.0);
   path.lineTo(width - arcwidth, 0.0);
   path.curveTo(width, 0.0, width, arcwidth, width, arcwidth);
   path.lineTo(width, height);
   // path.curveTo(width, height, width - arcwidth, height, width - arcwidth, height);
   path.lineTo(0.0, height);
   // path.curveTo(0.0, height, 0.0, height - arcwidth, 0, height - arcwidth);
   path.closePath();
   return path;
 }