package pathfinder;
/**
 * Deprecated class
 */
import java.awt.Color;
import java.awt.Graphics2D;
//import java.awt.Image;
//import java.awt.Polygon;
import java.awt.ScrollPane;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Display {
    

   // static private int scaleRatio=6000;
    static private int maxx=0;
    static private int maxy=0;
    static private int miny=0;
    static private Wall pom;
    static private int mierka=50;
     
    public Display(){
        
    }
     
    
    public void displayGraph(LinkedList ll,ArrayList points)
    {
        
        for (Iterator iter = ll.iterator(); iter.hasNext(); ){
      pom=(Wall)iter.next();
      if (pom.getX() > maxx) maxx=pom.getX();
      if (pom.getY1() > maxy) maxy=pom.getY1();
      if (pom.getY2() < miny) miny=pom.getY2();
        } 
        //find();	
	int width =mierka*maxx+2*mierka; 
	int height = mierka*(maxy-miny)+2*mierka;
	BufferedImage img = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
	Graphics2D g = img.createGraphics();
	g.setColor(Color.WHITE);
	g.fillRect(0, 0, width, height);
	
	// nejaky for
		    Line2D shape = new Line2D.Float(20,0,20,height);
                    g.setColor(Color.BLACK);
		    g.draw(shape);
                    shape = new Line2D.Float(0,height/2,width,height/2);
                    g.draw(shape);
           for (Iterator iter = ll.iterator(); iter.hasNext(); ){
               pom=(Wall)iter.next();      
               float x=mierka*pom.getX()+20;
               float y1=height/2 - mierka*pom.getY1();
               float y2=height/2 - mierka*pom.getY2();
               
               shape = new Line2D.Float(x,y1,x,y2); 
               g.draw(shape);
               g.drawString((new Point(pom.getX(),pom.getY1())).retString(),x+21,y1+1);
               g.drawString((new Point(pom.getX(),pom.getY2())).retString(),x+21,y2+1);
           }     
                System.out.print(points.size());
            for (int t=0; t<(points.size()-1);t++){
               PathPoint pom1=(PathPoint)points.get(t); 
               PathPoint pom2=(PathPoint)points.get(t+1);
               float x1=mierka*pom1.x+20;
               float x2=mierka*pom2.x+20;
               float y1=height/2 - mierka*pom1.y;
               float y2=height/2 - mierka*pom2.y;
               shape = new Line2D.Float(x1,y1,x2,y2); 
               g.setColor(Color.RED);
               g.draw(shape);
               
                   
            }          
				
	JFrame f=new JFrame();
	f.setSize(800,600);
	f.setTitle("graf");
	f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	ScrollPane p=new ScrollPane();
	p.add(new JLabel(new ImageIcon(img)));
	f.getContentPane().add(p);
	f.setVisible(true);
    }
    
}