Alex86fire 0 Newbie Poster

Hey guys, I have a problem I can't seem to figure out properly: I have to implement a mirror in a java applet.
For the mirror I used a second window.
what I don't know:
-how to rotate the second window
-how to make it mirror what's in front of it.
any ideas would be appreciated.
I do this in init():

v = new Vizual2D();
		v.fereastra(-10,-5, 15, 20);
		v.poarta(0, 0, getSize().width - 10, getSize().height - 10);
		v.schimbaTipScalare(true);
oglinda = new Vizual2D();
		oglinda.fereastra(0, 0, 10, 10);
		oglinda.poarta(70, 70, 150, 150,gg);
		oglinda.schimbaTipScalare(true);

where Vizual2D is:

public class Vizual2D{

	float XFm, XFM, YFm, YFM;

	int XPm, XPM, YPm, YPM;

	float sx, sy, tx, ty;

	boolean decupare;

	boolean scalare;

	public Vizual2D(){
		this(0, 0, 0, 0, 0, 0, 0, 0);
	}

	public Vizual2D(float xf1, float yf1, float xf2, float yf2, int xp1, int yp1, int xp2, int yp2){
		XPm = xp1; YPm = yp1;	XPM = xp2; YPM = yp2;
		XFm = xf1; XFM = xf2; YFm = yf1; YFM = yf2;
		scalare = false; decupare = false;
		calcTran();
	}

	public void fereastra(float x1, float y1, float x2, float y2){
		XFm = x1; XFM = x2; YFm = y1; YFM = y2;
		calcTran();
	}

	public void poarta(int x1, int y1, int x2, int y2){
		XPm = x1; XPM = x2; YPm = y1; YPM = y2;
		calcTran();
	}

	public void poarta(int x1, int y1, int x2, int y2, Graphics g){
		XPm = x1; XPM = x2; YPm = y1; YPM = y2;
		calcTran();
		if (decupare)
			g.setClip(x1, y1, x2 - x1, y2 - y1);
	}

	public void schimbaTipScalare(boolean tip) {
		if (tip != scalare){
			scalare = tip;
			calcTran();
		}
	}

	private void calcTran(){
		if (XFM > XFm && YFM > YFm){
			sx = (XPM - XPm) / (XFM - XFm);
			sy = (YPM - YPm) / (YFM - YFm);
			if (scalare) //scalare uniforma
				sx = sy = (sx < sy) ? sx : sy;
			tx = XPm - sx * XFm + (XPM - XPm - sx * (XFM - XFm)) / 2;
			ty = YPm - sy * YFm + (YPM - YPm - sy * (YFM - YFm)) / 2;
		} else
			sx = sy = tx = ty = 0;
	}

	public void cadruFereastra(Graphics g){
		g.drawRect(xDisp(XFm), yDisp(YFM), xDisp(XFM) - xDisp(XFm), yDisp(YFm) - yDisp(YFM));
	}

	public void cadruPoarta(Graphics g){
		//System.out.println("g este" + g);
		g.drawRect(XPm, YPm, XPM - XPm, YPM - YPm);
	}

	public int xDisp(double xf){
		return (int) (xf * sx + tx);
	}

	public int yDisp(double yf){
		/* tinem cont de faptul ca se inverseaza axele Oy */
		return (int) (YPM + YPm - (yf * sy + ty));
	}

	public void decupare(Graphics g, boolean dec) {
		if (dec)
			g.setClip(XPm, YPm, XPM - XPm, YPM - YPm);
		else
			g.setClip(null);
		decupare = dec;
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.