
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java2d.*;

public class mappoint extends JPanel {
  private Ellipse2D.Double circle =
    new Ellipse2D.Double(10, 10, 350, 350);
  private Rectangle2D.Double square =
    new Rectangle2D.Double(10, 10, 350, 350);

  private GeneralPath gp=new GeneralPath();



  private float scalefactor=1;
  private float autoscalefactor=1;
  private float theta=0;

  private int xshift=0;
  private int yshift=0;
  private Graphics2D g2d;
  private float ixy[][];
  private float x;
  private float y;



  public mappoint(){

    yshift=this.getSize().height/2;
    xshift=this.getSize().width/2;

    ixy=new float[100][2];


  }

  public void paintComponent(Graphics g) {
    clear(g);
    g2d = (Graphics2D)g;
    g2d.scale(scalefactor,scalefactor);
    g2d.translate(xshift,yshift);
    g2d.rotate(2*Math.PI*theta/360);
    //g2d.fill(circle);
    //g2d.draw(square);

    //g2d.translate(100,-100);

    //gp.closePath();

    g2d.draw(gp);


  }

  // super.paintComponent clears offscreen pixmap,
  // since we're using double buffering by default.

  protected void clear(Graphics g) {
    super.paintComponent(g);
  }

  public void zoomin(){

    scalefactor+=0.5;
    this.repaint();

  }

  public void zoomout(){
    scalefactor-=0.5;
    this.repaint();

  }

  public void xshift_right(){
    xshift+=50;
    this.repaint();

  }

  public void xshift_left(){
    xshift-=50;
    this.repaint();

  }
  public void yshift_up(){
    yshift-=50;
    this.repaint();

  }
  public void yshift_down(){
    yshift+=50;
    this.repaint();

  }

  public void rotate_c(){
    this.theta+=5;

    this.repaint();
  }

  public void rotate_cc(){
    this.theta-=5;

    this.repaint();
  }

  public void center(){
    yshift=this.getSize().height/2;
    xshift=this.getSize().width/2;


    this.repaint();

  }

  public void mapthepoints(float[][] ixy){
    int mx=0,my=0;




    this.ixy=ixy;

    gp=new GeneralPath();

    x=0;
    y=0;

    x+=ixy[1][0];
    y+=ixy[1][1];
    gp.moveTo(x,y);

    for(int i=2;i<50;i++){
      x+=ixy[i][0];
      y+=ixy[i][1];
      gp.lineTo(x,-y);

    }

    this.repaint();
  }

  protected Ellipse2D.Double getCircle() {
    return(circle);
  }


}