/*
* 18:40:36
* vjanssen
*/
package a0902d_f_Philosophen_VORLAGE;

import java.awt.Color;
import java.awt.Graphics;

public class AF_Dreieck extends AbsForm
{
	public AF_Dreieck()
	{
		this(1, 1, 1, Color.BLACK);
	}
	
	public AF_Dreieck(int x, int y, int laenge, Color farbe)
	{
		super(x, y, laenge, farbe);
	}
	
	private double hoehe()
	{
		double l = (double) this.getLaenge();
		return Math.sqrt(l * l - l/2.0d * l/2.0d);
	}

	public void drawObjekt(Graphics g, int xVer, int yVer)
	{
		double h 	= this.hoehe();					// Höhe
		double hh	= h / 2.0d;						// halbe Höhe
		double l 	= (double) this.getLaenge();	// Seitenlänge
		double hl	= l / 2.0d;						// halbe Seitenlänge				
		
		int x1 = this.getX() + xVer - (int) hl;
		int y1 = this.getY() + yVer + (int) hh;
		int x2 = this.getX() + xVer + (int) hl;
		int y2 = y1;
		int x3 = this.getX() + xVer;
		int y3 = this.getY() + yVer - (int) hh;
		
		int[] xWerte = {x1, x2, x3};
		int[] yWerte = {y1, y2, y3};
			
		g.setColor(this.getFarbe());
		g.fillPolygon(xWerte, yWerte, 3);
		
		if (TESTMODUS)
		{
			g.setColor(Color.BLACK);
			g.drawString("x: " + this.getX(), x1, y1+11);
			g.drawString("y: " + this.getY(), x1, y1+21);
		}
	}
}
