import java.awt.*;
import java.applet.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Vector;
import java.awt.geom.*;
import java.lang.Math;
import java.lang.*;
 
public class Lin extends Applet implements ActionListener {
 	Rise rise;
	Kontrola kontrola;

	int izbira;

	public void actionPerformed(ActionEvent ev) {
		rise.OK();	
	}

	public void init() {
		setLayout(new BorderLayout());

		rise = new Rise();
		add(rise, BorderLayout.CENTER);
		
		Button b = new Button("Ok");
		b.addActionListener(this);
		add(b, BorderLayout.SOUTH);

	    kontrola = new Kontrola(rise);
		add("West",kontrola);


	}

}


/* Risemo poljuben veckotnik, pri cemer tocke zajemamo s "clik"-om miske.
   Risanje prekinemo s pritiskom na "OK" in nato veckotnik premikamo
   z misko.
*/
class Rise extends Panel implements MouseListener, 
									MouseMotionListener {
	
	Kontrola kontrola;

	Vector tocke = new Vector();
	Vector tocke2 = new Vector();
	Vector tocka = new Vector();
	Vector radij = new Vector();
	Vector tockaZ = new Vector();
	Vector tockaZ1 = new Vector();
	Vector tockaZ2 = new Vector();
	Vector tockaZ11 = new Vector();
	Vector tockaZ12 = new Vector();
	Vector tockaZ21 = new Vector();
	Vector tockaZ22 = new Vector();
	Vector Lin1 = new Vector();	
	Vector Lin2 = new Vector();
	Vector Lin11 = new Vector();	
	Vector Lin12 = new Vector();	
	int x1, y1, xp, yp, xp2, yp2;
	int x0, y0, xs, ys, dX, dY, deltaX, deltaY;
	int xmax = 0, ymax = 0;
	int xmin = 10000, ymin = 10000;
	int xv, yv;
	int izbira, ok, ok2;
	int sl = -1; 
	int thetaxx, thetayy;
	int ax, ay, bx, by, cx, cy;
	double xn, yn, zn = 0;
	double xn2, yn2, zn2 = 0;
	double xn11, yn11, zn11 = 0;
	double xn12, yn12, zn12 = 0;
	double xn21, yn21, zn21 = 0;
	double xn22, yn22, zn22 = 0;
	float a, b;

	public Rise() {
		addMouseListener(this);
		addMouseMotionListener(this);
	}

	public void premikanje() {
		izbira = 50;
	}

	public void rotiranje() {
		izbira = 51;
	}
	
	public void mousePressed(MouseEvent e) {
		if (ok == 1) {
			dX = 0;
			dY = 0;
			x0 = e.getX();
			y0 = e.getY();
		}
		
		if (ok != 1 ) {
			tocke.addElement(new Point(e.getX(), e.getY()));
		}
		tocka.addElement(new Point(e.getX(), e.getY()));
		
		repaint();

	}

	public void mouseDragged(MouseEvent e) {
//Premikanje lika
		if (izbira != 51) {
			sl = sl * (-1);
		if (ok == 1) {
			deltaX = e.getX() - x0 - dX;
			deltaY = e.getY() - y0 - dY;
			dX = dX + deltaX;
			dY = dY + deltaY;

			if (sl < 0)	{
				tocke.clear();
				int np2 = tocke2.size();
				for (int i=0; i < np2; i++) {
					Point p2 = (Point)tocke2.elementAt(i);
					tocke.addElement(new Point(p2.x + deltaX, p2.y + deltaY));			
				}
				tocke2.clear();
				if (np2 <= 4 ){
				ok2 = 3;
				Lin1.clear();					
				Lin2.clear();					
					for (int il=0; il<4; il++) {
						Rectangle r1 = (Rectangle)Lin11.elementAt(il);						 
						Rectangle r2 = (Rectangle)Lin12.elementAt(il);						 
						Lin1.addElement(new Rectangle(r1.x+deltaX, r1.y+deltaY, r1.width+deltaX, r1.height+deltaY));
						Lin2.addElement(new Rectangle(r2.x+deltaX, r2.y+deltaY, r2.width+deltaX, r2.height+deltaY));
					}
				}
				repaint();
			} else if (sl > 0)	{
				tocke2.clear();
				int np = tocke.size();
				for (int i=0; i < np; i++) {
					Point p = (Point)tocke.elementAt(i);
					tocke2.addElement(new Point(p.x + deltaX, p.y + deltaY));			
				}
				tocke.clear();
				if (np <= 4 ){
				ok2 = 3;
				Lin11.clear();					
				Lin12.clear();					
					for (int il=0; il<4; il++) {
						Rectangle r1 = (Rectangle)Lin1.elementAt(il);						 
						Rectangle r2 = (Rectangle)Lin2.elementAt(il);						 
						Lin11.addElement(new Rectangle(r1.x+deltaX, r1.y+deltaY, r1.width+deltaX, r1.height+deltaY));
						Lin12.addElement(new Rectangle(r2.x+deltaX, r2.y+deltaY, r2.width+deltaX, r2.height+deltaY));
					}
				}
				repaint();
			}
		}
//Rotiranje lika
		} else if (izbira != 50) {
		if (ok == 1) {

			thetaxx = e.getX() - x0;
			thetayy = e.getY() - y0;

			if (sl < 0)	{
				int np = tocke.size();
				xmax = 0;
				xmin = 10000;
				ymax = 0;
				ymin = 10000;
				for (int i=0; i < np; i++) {
					Point p2 = (Point)tocke.elementAt(i);
						xs = p2.x;
						ys = p2.y;
						if (xs >= xmax)	{
							xmax = xs;
						}
						if (xs <= xmin)	{
							xmin = xs;
						}
						if (ys >= ymax)	{
							ymax = ys;
						}
						if (ys <= ymin)	{
							ymin = ys;
						}
						xv = ((xmax - xmin) / 2) + xmin;
						yv = ((ymax - ymin) / 2) + ymin;			
				}

				tocke2.clear();
				int np2 = tocke.size();
				for (int i=0; i < np2; i++) {
					Point p2 = (Point)tocke.elementAt(i);
					Point z = (Point)tockaZ.elementAt(i);
						xn = (p2.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn = (p2.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (p2.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn = (p2.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (p2.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z.x * Math.cos(thetayy * 3.1415926 / 180);	
						tocke2.addElement(new Point((int) xn + xv, yv + (int) yn));
						tockaZ.addElement(new Point((int) zn, 0));
				}
				if (np2 <= 4 ){
				ok2 = 3;
				Lin11.clear();					
				Lin12.clear();					
					for (int il=0; il<4; il++) {
						Point z11 = (Point)tockaZ11.elementAt(il);
						Point z12 = (Point)tockaZ12.elementAt(il);
						Point z21 = (Point)tockaZ21.elementAt(il);
						Point z22 = (Point)tockaZ22.elementAt(il);
						Rectangle r1 = (Rectangle)Lin1.elementAt(il);						 
						Rectangle r2 = (Rectangle)Lin2.elementAt(il);						 
						xn11 = (r1.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z11.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn11 = (r1.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r1.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z11.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn11 = (r1.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r1.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z11.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn12 = (r1.width - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z12.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn12 = (r1.width - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r1.height - yv) * Math.cos(thetayy* 3.1415926 / 180) + z12.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn12 = (r1.width - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r1.height - yv) * Math.sin(thetayy * 3.1415926 / 180) + z12.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn21 = (r2.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z21.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn21 = (r2.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r2.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z21.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn21 = (r2.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r2.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z21.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn22 = (r2.width - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z22.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn22 = (r2.width - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r2.height - yv) * Math.cos(thetayy* 3.1415926 / 180) + z22.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn22 = (r2.width - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r2.height - yv) * Math.sin(thetayy * 3.1415926 / 180) + z22.x * Math.cos(thetayy * 3.1415926 / 180);	
						Lin11.addElement(new Rectangle((int) xn11 + xv, yv + (int) yn11, (int) xn12 + xv, yv + (int) yn12));
						Lin12.addElement(new Rectangle((int) xn21 + xv, yv + (int) yn21, (int) xn22 + xv, yv + (int) yn22));
						tockaZ11.addElement(new Point((int) zn11, 0));
						tockaZ12.addElement(new Point((int) zn12, 0));
						tockaZ21.addElement(new Point((int) zn21, 0));
						tockaZ22.addElement(new Point((int) zn22, 0));
					}
				}
				repaint();
			} else if (sl > 0)	{
				int np = tocke2.size();
				xmax = 0;
				xmin = 10000;
				ymax = 0;
				ymin = 10000;
				for (int i=0; i < np; i++) {
					Point p2 = (Point)tocke2.elementAt(i);
					xs = p2.x;
					ys = p2.y;
					if (xs >= xmax)	{
						xmax = xs;
					}
					if (xs <= xmin)	{
						xmin = xs;
					}
					if (ys >= ymax)	{
						ymax = ys;
					}
					if (ys <= ymin)	{
						ymin = ys;
					}
					xv = ((xmax - xmin) / 2) + xmin;
					yv = ((ymax - ymin) / 2) + ymin;			
				}
				tocke.clear();
				int np2 = tocke2.size();
				for (int i=0; i < np2; i++) {
					Point p2 = (Point)tocke2.elementAt(i);
					Point z = (Point)tockaZ.elementAt(i);
						xn = (p2.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn = (p2.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (p2.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn = (p2.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (p2.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z.x * Math.cos(thetayy * 3.1415926 / 180);	
						tocke.addElement(new Point((int) xn + xv, yv + (int) yn));
						tockaZ.addElement(new Point((int) zn, 0));
				}
				if (np2 <= 4 ){
				ok2 = 3;
				Lin1.clear();					
				Lin2.clear();					
					for (int il=0; il<4; il++) {
						Point z11 = (Point)tockaZ11.elementAt(il);
						Point z12 = (Point)tockaZ12.elementAt(il);
						Point z21 = (Point)tockaZ21.elementAt(il);
						Point z22 = (Point)tockaZ22.elementAt(il);
						Rectangle r1 = (Rectangle)Lin11.elementAt(il);						 
						Rectangle r2 = (Rectangle)Lin12.elementAt(il);						 
						xn11 = (r1.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z11.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn11 = (r1.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r1.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z11.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn11 = (r1.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r1.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z11.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn12 = (r1.width - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z12.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn12 = (r1.width - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r1.height - yv) * Math.cos(thetayy* 3.1415926 / 180) + z12.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn12 = (r1.width - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r1.height - yv) * Math.sin(thetayy * 3.1415926 / 180) + z12.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn21 = (r2.x - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z21.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn21 = (r2.x - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r2.y - yv) * Math.cos(thetayy* 3.1415926 / 180) + z21.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn21 = (r2.x - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r2.y - yv) * Math.sin(thetayy * 3.1415926 / 180) + z21.x * Math.cos(thetayy * 3.1415926 / 180);	
						xn22 = (r2.width - xv) * Math.cos(thetaxx* 3.1415926 / 180) - z22.x * Math.sin(thetaxx * 3.1415926 / 180);
						yn22 = (r2.width - xv) * Math.sin(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) + (r2.height - yv) * Math.cos(thetayy* 3.1415926 / 180) + z22.x * Math.sin(thetayy * 3.1415926 / 180) * Math.cos(thetaxx * 3.1415926 / 180);
						zn22 = (r2.width - xv) * Math.cos(thetayy * 3.1415926 / 180) * Math.sin(thetaxx * 3.1415926 / 180) - (r2.height - yv) * Math.sin(thetayy * 3.1415926 / 180) + z22.x * Math.cos(thetayy * 3.1415926 / 180);	
						Lin1.addElement(new Rectangle((int) xn11 + xv, yv + (int) yn11, (int) xn12 + xv, yv + (int) yn12));
						Lin2.addElement(new Rectangle((int) xn21 + xv, yv + (int) yn21, (int) xn22 + xv, yv + (int) yn22));
						tockaZ11.addElement(new Point((int) zn11, 0));
						tockaZ12.addElement(new Point((int) zn12, 0));
						tockaZ21.addElement(new Point((int) zn21, 0));
						tockaZ22.addElement(new Point((int) zn22, 0));
					}
				}
				repaint();
			}
		}
	}
	}

	public void mouseMoved(MouseEvent e) {}

	public void mouseReleased(MouseEvent e) {}

	public void mouseEntered(MouseEvent e) {}

	public void mouseExited(MouseEvent e) {}

	public void mouseClicked(MouseEvent e) {}

	public void paint(Graphics g) {
		setForeground(Color.blue);
		setBackground(Color.white);
		if (ok2 == 2) {
			for (int i=0;i<4 ;i++ )	{
				Rectangle r1 = (Rectangle)Lin1.elementAt(i);
				g.drawLine(r1.x, r1.y, r1.width, r1.height);
				Rectangle r2 = (Rectangle)Lin2.elementAt(i);
				g.drawLine(r2.x, r2.y, r2.width, r2.height);
			}
		}
		if (ok != 1) {
			int np = tocka.size();
			for (int i=0; i < np; i++) {
				Point t = (Point)tocka.elementAt(i);
				g.drawOval(t.x, t.y, 3, 3);
			}
		}
// Risanje premikanja
		if (ok == 1) {
			if (izbira != 51) {
				if (sl < 0)	{
					int np = tocke.size();
					for (int i=0; i < np; i++) {
						Point p = (Point)tocke.elementAt(i);
						if ( i == 0) {
							xp = p.x;
							yp = p.y;
						} else if ( i > 0 & i <= np - 1) {
							g.drawLine(x1, y1, p.x, p.y);
							if ( i == np - 1) {
								g.drawLine(p.x, p.y, xp, yp);
							}	
						}
						x1 = p.x;
						y1 = p.y;
					}
					if (ok2 == 3) {
						for (int il=0;il<4 ;il++ )	{
							Rectangle r1 = (Rectangle)Lin1.elementAt(il);
							g.drawLine(r1.x, r1.y, r1.width, r1.height);
							Rectangle r2 = (Rectangle)Lin2.elementAt(il);
							g.drawLine(r2.x, r2.y, r2.width, r2.height);
						}
					}
				} else if (sl > 0) {
					int np2 = tocke2.size();
					for (int i=0; i < np2; i++) {
						Point p2 = (Point)tocke2.elementAt(i);
						if ( i == 0) {
							xp2 = p2.x;
							yp2 = p2.y;
						} else if ( i > 0 & i <= np2 - 1)	{
							g.drawLine(x1, y1, p2.x, p2.y);
							if ( i == np2 - 1) {
								g.drawLine(p2.x, p2.y, xp2, yp2);
							}	
						}
						x1 = p2.x;
						y1 = p2.y;
					}
					if (ok2 == 3) {
							for (int il=0;il<4 ;il++ )	{
								Rectangle r1 = (Rectangle)Lin11.elementAt(il);
								g.drawLine(r1.x, r1.y, r1.width, r1.height);
								Rectangle r2 = (Rectangle)Lin12.elementAt(il);
								g.drawLine(r2.x, r2.y, r2.width, r2.height);
							}
					}
				}
// Risanje rotacije
			} else if (izbira != 50) {
				if (sl < 0)	{
					int np = tocke2.size();
					for (int i=0; i < np; i++) {
						Point p = (Point)tocke2.elementAt(i);
						if ( i == 0) {
							xp = p.x;
							yp = p.y;
						} else if ( i > 0 & i <= np - 1)	{
							g.drawLine(x1, y1, p.x, p.y);
							if ( i == np - 1) {
								g.drawLine(p.x, p.y, xp, yp);
							}	
						}
						x1 = p.x;
						y1 = p.y;
					}
					if (ok2 == 3) {
						for (int il=0;il<4 ;il++ )	{
							Rectangle r1 = (Rectangle)Lin11.elementAt(il);
							g.drawLine(r1.x, r1.y, r1.width, r1.height);
							Rectangle r2 = (Rectangle)Lin12.elementAt(il);
							g.drawLine(r2.x, r2.y, r2.width, r2.height);
						}

					}
				} else if (sl > 0) {
					int np2 = tocke.size();
					for (int i=0; i < np2; i++) {
					    Point p2 = (Point)tocke.elementAt(i);
						if ( i == 0) {
							xp2 = p2.x;
							yp2 = p2.y;
						} else if ( i > 0 & i <= np2 - 1)	{
							g.drawLine(x1, y1, p2.x, p2.y);
							if ( i == np2 - 1) {
								g.drawLine(p2.x, p2.y, xp2, yp2);
							}	
						}
						x1 = p2.x;
						y1 = p2.y;
					}
					if (ok2 == 3) {
						for (int il=0;il<4 ;il++ )	{
							Rectangle r1 = (Rectangle)Lin1.elementAt(il);
							g.drawLine(r1.x, r1.y, r1.width, r1.height);
							Rectangle r2 = (Rectangle)Lin2.elementAt(il);
							g.drawLine(r2.x, r2.y, r2.width, r2.height);
						}
					}
				}
			}
		}
	}
		
// Funkcoja OK
	public void OK() {
	ok = 1;
	sl = -1;
	ok2 = ok2 + 1;
	if (ok2 == 1) {
		int np = tocke.size();
		for (int i=0; i < np; i++) {
			Point p = (Point)tocke.elementAt(i);
			tockaZ.addElement(new Point(0, 0));
		}
		repaint();
	}
	if (ok2 == 2) {
		tockaZ11.addElement(new Point(0, 0));
		tockaZ12.addElement(new Point(0, 0));
		tockaZ21.addElement(new Point(0, 0));		
		tockaZ22.addElement(new Point(0, 0));
		int np = tocke.size();
		int i = 0;
		Point p1 = (Point)tocke.elementAt(i);
		ax = p1.x;
		ay = p1.y;
		i = 1;
		Point p2 = (Point)tocke.elementAt(i);
		bx = p2.x;
		by = p2.y;
		i = 2;
		Point p3 = (Point)tocke.elementAt(i);
		cx = p3.x;
		cy = p3.y;
		float xda = ((float)bx-(float)ax)/5.0f;
		float yda = ((float)by-(float)ay)/5.0f;
		float xla = ((float)cx-(float)ax)/5.0f;
		float yla = ((float)cy-(float)ay)/5.0f;
		float xlc = ((float)bx-(float)cx)/5.0f;
		float ylc = ((float)by-(float)cy)/5.0f;
		if (np==3) {
			for (int il=1; il<5; il++) {
				Lin1.addElement(new Rectangle(ax+il*(int)xda,ay+il*(int)yda, cx+il*(int)xlc,cy+il*(int)ylc));
				Lin2.addElement(new Rectangle(ax+il*(int)xla,ay+il*(int)yla, bx-il*(int)xlc,by-il*(int)ylc));
			}
			repaint();			
		}
		if (np==4) {
			i = 3;
			Point p4 = (Point)tocke.elementAt(i);
			int dx = p4.x;
			int dy = p4.y;
			for (int il=1; il<5; il++) {
				xla = ((float)dx-(float)ax)/5.0f;
				yla = ((float)dy-(float)ay)/5.0f;
				float xdb = ((float)cx-(float)bx)/5.0f;
				float ydb = ((float)cy-(float)by)/5.0f;
				float xdd = ((float)cx-(float)dx)/5.0f;
				float ydd = ((float)cy-(float)dy)/5.0f;
				Lin1.addElement(new Rectangle(ax+il*(int)xda,ay+il*(int)yda, dx+il*(int)xdd,dy+il*(int)ydd));
				Lin2.addElement(new Rectangle(ax+il*(int)xla,ay+il*(int)yla, bx+il*(int)xdb,by+il*(int)ydb));
			}	
			repaint();			
		}
	}
}
}

/*Tu prekljapljamo med moznostjo premikanja ali rotiranja veckotnika
z misko.
*/
class Kontrola extends Panel implements ItemListener {
    Rise rise;

	int izbira;

    public Kontrola(Rise rise) {
	this.rise = rise;
	setLayout(new GridLayout(2, 1));
	CheckboxGroup group = new CheckboxGroup();
	Checkbox b;
	add(b = new Checkbox("Premikanje", group, true));
	b.addItemListener(this);
	add(b = new Checkbox("Rotiranje", group, false));
	b.addItemListener(this);
    }

	public void itemStateChanged(ItemEvent e) {
  
	String arg = (String)(e.getItem());

	if ("Premikanje".equals(arg)) {
		rise.premikanje();

	} else if ("Rotiranje".equals(arg)) {
		rise.rotiranje();
	} 
  }
}


