import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

/**
 * Demo/test: Draws a Triangle in a panel.
 *<p>
 * Creates a triangle and a translated one and displays them.
 * For CSU540 Computer Graphics class, Spring 2005
 * CCIS, Northeastern University
 *
 * @author Bob Futrelle
 * @version 23 January 2005
 * Here's a screen shot from runing this program:
 * <p>
 * <img src="../doc-files/TriDraw-1.gif" alt="" width="350" height="272" />
 */

public class TriDraw extends JPanel {

    /**
     * Sets up JFrame and adds this JPanel, which will draw.
     */
    public static void main(String[] args) {

        JFrame jf = new JFrame("Triangle draw test");
        TriDraw td = new TriDraw();
        td.setPreferredSize(new Dimension(350, 250));
        jf.getContentPane().add(td);
        jf.pack();
        jf.show();
    }

    /**
     * Draws red triangle, upper right then translated and green copy.
     * Important point: Drawing routine is drawTri(g) in the Triangle class.
     * This is possible because Graphics has reference to component on which to draw.
     */
    public void paintComponent(Graphics g) {
            super.paintComponent(g);

	Vec v0 = new Vec(0.0,0.0,0.0);
	Vec v1 = new Vec(100.0,0.0,80.0);
	Vec v2 = new Vec(0.0,100.0,0.0);
	Triangle tri = new Triangle(v0, v1, v2, Color.red);
	Mat mat = Mat.transMat(150.0, 50.0, 0.0);
	Triangle trit = Triangle.transformTriangle(mat,tri);
	trit.color= Color.green;

	tri.drawTri(g);
	trit.drawTri(g);
    }

}


