/* ===================================================================== */
/** A class to draw nationality signs. Static members only. 
*/
/* ===================================================================== */

import java.awt.*;

abstract class DrawHelper {

  // --- Unknown ----------------------------------------------------
  static void drawUnknown(Graphics g, int x, int y, double size) {
    int r1 = (int) Math.round(size / 2.0);
    int r2 = (int) Math.round(size);
    int s1 = r1 / 2;
    int s2 = r2 / 2;
    g.setColor(Color.black);
    g.fillOval(x - s2, y - s2, r2+1, r2+1);
    g.setColor(Color.white);
    g.fillOval(x - s1, y - s1, r1+1, r1+1);
  }

  // --- German cross -----------------------------------------------
  static void drawGermany(Graphics g, int x, int y, double size) {
    int vx[] = new int[12];
    int vy[] = new int[12];
    int a = (int) Math.round(size / 2.0);
    int b = (int) Math.round(size / 8.0);
    vx[ 0] = x-b; vy[ 0] = y+b;   vx[ 6] = x+b; vy[ 6] = y-b;    
    vx[ 1] = x-b; vy[ 1] = y+a;   vx[ 7] = x+b; vy[ 7] = y-a;    
    vx[ 2] = x+b; vy[ 2] = y+a;   vx[ 8] = x-b; vy[ 8] = y-a;    
    vx[ 3] = x+b; vy[ 3] = y+b;   vx[ 9] = x-b; vy[ 9] = y-b;    
    vx[ 4] = x+a; vy[ 4] = y+b;   vx[10] = x-a; vy[10] = y-b;    
    vx[ 5] = x+a; vy[ 5] = y-b;   vx[11] = x-a; vy[11] = y+b;
    g.setColor(Color.black);
    g.fillPolygon(vx, vy, 12);
  }

  // --- Japanese Sun -----------------------------------------------
  static void drawJapan(Graphics g, int x, int y, double size) {
    int r = (int) Math.round(size);
    int s = r / 2;
    g.setColor(Color.white);
    g.fillOval(x-s-1, y-s-1, r+3, r+3);
    g.setColor(Color.red);
    g.fillOval(x-s, y-s, r+1, r+1);
  }

  // --- British marking --------------------------------------------
  static void drawBritain(Graphics g, int x, int y, double size) {
    int r1 = (int) Math.round(size / 2.0);
    int r2 = (int) Math.round(size);
    int s1 = r1 / 2;
    int s2 = r2 / 2;
    g.setColor(Color.blue);
    g.fillOval(x-s2, y-s2, r2+1, r2+1);
    g.setColor(Color.red);
    g.fillOval(x-s1, y-s1, r1+1, r1+1);
  }

  // --- French marking ---------------------------------------------
  static void drawFrance(Graphics g, int x, int y, double size) {
    int r1 = (int) Math.round(size / 3.0);
    int r2 = (int) Math.round(2.0 * size / 3.0);
    int r3 = (int) Math.round(size);
    int s1 = r1 / 2;
    int s2 = r2 / 2;
    int s3 = r3 / 2;
    g.setColor(Color.red);
    g.fillOval(x-s3, y-s3, r3+1, r3+1);
    g.setColor(Color.white);
    g.fillOval(x-s2, y-s2, r2+1, r2+1);
    g.setColor(Color.blue);
    g.fillOval(x-s1, y-s1, r1+1, r1+1);
  }

  // --- Italian marking --------------------------------------------
  static void drawItaly(Graphics g, int x, int y, double size) {
    int r1 = (int) Math.round(size / 3.0);
    int r2 = (int) Math.round(2.0 * size / 3.0);
    int r3 = (int) Math.round(size);
    int s1 = r1 / 2;
    int s2 = r2 / 2;
    int s3 = r3 / 2;
    g.setColor(Color.red);
    g.fillOval(x-s3, y-s3, r3+1, r3+1);
    g.setColor(Color.white);
    g.fillOval(x-s2, y-s2, r2+1, r2+1);
    g.setColor(Color.green);
    g.fillOval(x-s1, y-s1, r1+1, r1+1);
  }

  // --- Polish marking ---------------------------------------------
  static void drawPoland(Graphics g, int x, int y, double size) {
    int r = (int) Math.round(size / 2.0);
    int s = (int) Math.round(size);
    g.setColor(Color.red);
    g.fillRect(x-r, y-r, s, s);
    g.setColor(Color.white);
    g.fillRect(x-r, y, r, r);
    g.fillRect(x, y-r, r, r);
  }

  // --- Red Star --------------------------------------------
  static void drawUSSR(Graphics g, int ox, int oy, double size) {
    double r = 1.5 * size / 2.0;
    double R = r * 0.38196601;
    int ir   = (int) Math.round(r);
    int iR   = (int) Math.round(R);
    int ar   = (int) Math.round( 0.9511 * r);
    int aR   = (int) Math.round( 0.9511 * R);
    int cr   = (int) Math.round( 0.5878 * r);
    int cR   = (int) Math.round( 0.5878 * R);
    int br   = (int) Math.round( 0.3090 * r);
    int bR   = (int) Math.round( 0.3090 * R);
    int dr   = (int) Math.round( 0.8090 * r);
    int dR   = (int) Math.round( 0.8090 * R);
    int x[] = new int[10];
    int y[] = new int[10];
    x[0] = ox + ar;  x[1] = ox + cR;  x[2] = ox;       x[3] = ox - cR;
    x[4] = ox - ar;  x[5] = ox - aR;  x[6] = ox - cr;  x[7] = ox;
    x[8] = ox + cr;  x[9] = ox + aR;  y[0] = oy - br;  y[1] = oy - dR;
    y[2] = oy - ir;  y[3] = oy - dR;  y[4] = oy - br;  y[5] = oy + bR;
    y[6] = oy + dr;  y[7] = oy + iR;  y[8] = oy + dr;  y[9] = oy + bR;
    g.setColor(Color.red);
    g.fillPolygon(x, y, 10);
  }

  // --- US Marking ------------------------------------------
  static void drawUSA(Graphics g, int ox, int oy, double size) {
    double r  = 1.2 * size / 2.0;
    double R  = r * 0.38196601;
    int x[] = new int[10];
    int y[] = new int[10];
    // --- bar ---
    int r3 = (int) Math.round(2.0 * r);
    int s3 = (int) Math.round(0.40 * r);
    int t3 = 2 * s3 / 5;
    g.setColor(Color.blue);
    g.fillRect(ox-r3,    oy-s3,      2*r3+1,      2*s3+1);
    g.setColor(Color.white);
    g.fillRect(ox-r3+t3, oy-s3+t3,   2*r3-2*t3+1, 2*s3-2*t3+1);
    g.setColor(Color.red);
    g.fillRect(ox-r3+t3, oy-s3+2*t3, 2*r3-2*t3+1, 2*s3-4*t3+1);
    // -- circle ---
    int r2 = (int) Math.round(r);
    g.setColor(Color.blue);
    g.fillOval(ox-r2, oy-r2, 2*r2+1, 2*r2+1);
    // star
    int ir   = (int) Math.round(r);
    int iR   = (int) Math.round(R);
    int ar   = (int) Math.round( 0.9511 * r);
    int aR   = (int) Math.round( 0.9511 * R);
    int cr   = (int) Math.round( 0.5878 * r);
    int cR   = (int) Math.round( 0.5878 * R);
    int br   = (int) Math.round( 0.3090 * r);
    int bR   = (int) Math.round( 0.3090 * R);
    int dr   = (int) Math.round( 0.8090 * r);
    int dR   = (int) Math.round( 0.8090 * R);
    x[0] = ox + ar;  x[1] = ox + cR;  x[2] = ox;       x[3] = ox - cR;
    x[4] = ox - ar;  x[5] = ox - aR;  x[6] = ox - cr;  x[7] = ox;
    x[8] = ox + cr;  x[9] = ox + aR;  y[0] = oy - br;  y[1] = oy - dR;
    y[2] = oy - ir;  y[3] = oy - dR;  y[4] = oy - br;  y[5] = oy + bR;
    y[6] = oy + dr;  y[7] = oy + iR;  y[8] = oy + dr;  y[9] = oy + bR;
    g.setColor(Color.white);
    g.fillPolygon(x, y, 10);
  }

  // --- Dutch Marking ---------------------------------------
  static void drawNetherlands(Graphics g, int x, int y, double size) {
    int r3 = (int) Math.round(size);
    int s3 = r3 / 2;
    int r2 = r3 / 4;
    int s2 = r2 / 2;
    g.setColor(Color.blue);
    g.fillArc(x-s3, y-s3, r3+1, r3+1,  90, 120);
    g.setColor(Color.white);
    g.fillArc(x-s3, y-s3, r3+1, r3+1, 210, 120);
    g.setColor(Color.red);
    g.fillArc(x-s3, y-s3, r3+1, r3+1, 330, 120);
    g.setColor(Color.red);
    g.fillOval(x-s2, y-s2, r2+1, r2+1);
  }

  // --- Dutch Marking ---------------------------------------
  static void drawCzech(Graphics g, int x, int y, double size) {
    int r3 = (int) Math.round(size);
    int s3 = r3 / 2;
    g.setColor(Color.white);
    g.fillArc(x-s3, y-s3, r3+1, r3+1, 0, 120);
    g.setColor(Color.blue);
    g.fillArc(x-s3, y-s3, r3+1, r3+1, 120, 120);
    g.setColor(Color.red);
    g.fillArc(x-s3, y-s3, r3+1, r3+1, 240, 120);
  }

  // --- Swedish Marking -------------------------------------
  // Squares instead of little crowns...
  static void drawSweden(Graphics g, int x, int y, double size) {
    int r = (int) Math.round(size);
    int s = r / 2;
    int p = r / 4;
    int q = r / 6;
    // circles
    g.setColor(Color.yellow);
    g.fillOval(x-s-2, y-s-2, r+5, r+5);
    g.setColor(Color.blue);
    g.fillOval(x-s, y-s, r+1, r+1);
    //crowns
    g.setColor(Color.yellow);
    g.fillRect(x-p-q, y-q, p, q);
    g.fillRect(x+q, y-q, p, q);
    g.fillRect(x - p / 2, y+2*q, p, q);
  }

  // --- Austrian Marking -------------------------------------------
  static void drawAustria(Graphics g, int x, int y, double size) {
    int r = (int) Math.round(size);
    int s = r / 2;
    int q = (int) Math.round(0.866025 * r);
    int vx[] = new int[3];
    int vy[] = new int[3];
    // circle 
    g.setColor(Color.red);
    g.fillOval(x-s, y-s, r+1, r+1);
    // triangle
    vx[0] = x+q;   vy[0] = y-s;
    vx[1] = x-q;   vy[1] = y-s;
    vx[2] = x;     vy[2] = y+r;
    g.fillPolygon(vx,vy,3);
  }

}

