Exemplo n.º 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);
  }
Exemplo n.º 2
0
  private void saveGizmo(IGizmo gizmo, String type) {
    String name = giveName(gizmo, type);
    fileOutput.format(GIZMO_FORMAT, type, name, gizmo.getX(), gizmo.getY());

    int orientation = gizmo.getOrientation();

    // right flippers are stored as left flippers rotated by one,
    // need to get rid of this before saving
    if (type.equals("RightFlipper")) orientation -= 1;

    for (int i = 0; i < orientation; i++) {
      fileOutput.format(ROTATE_FORMAT, name);
    }
  }