import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.geom.Ellipse2D;
import java.awt.Font;
public class PAPIComponent extends JComponent
{
private int runway;
private Color light1;
private Color light2;
private Color light3;
private Color light4;
public PAPIComponent(int runway)
{
light1 = Color.WHITE;
light2 = Color.WHITE;
light3 = Color.RED;
light4 = Color.RED;
}
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
String rw = String.valueOf(runway);
g2.setColor(Color.WHITE);
g2.setFont(new Font("TimesRoman", Font.PLAIN, 72));
g2.drawString(rw, 70, 300);
g2.setColor(Color.BLACK);
Rectangle background = new Rectangle(0, 0, 400, 650);
g2.fill(background);
g2.setColor(Color.WHITE);
Rectangle median = new Rectangle(190, 0, 8, 100);
g2.fill(median);
median.translate(0,150);
g2.fill(median);
median.translate(0,150);
g2.fill(median);
median.translate(0,150);
g2.fill(median);
Rectangle threshold = new Rectangle(20, 550, 35, 80);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
threshold.translate(72, 0);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
threshold.translate(40, 0);
g2.fill(threshold);
Rectangle bottom = new Rectangle(0, 650, 400, 150);
g2.fill(bottom);
Ellipse2D.Double circle1 = new Ellipse2D.Double(50, 665, 50, 50);
g2.setColor(light1);
g2.fill(circle1);
g2.setColor(Color.BLACK);
g2.draw(circle1);
Ellipse2D.Double circle2 = new Ellipse2D.Double(125, 665, 50, 50);
g2.setColor(light2);
g2.fill(circle2);
g2.setColor(Color.BLACK);
g2.draw(circle2);
Ellipse2D.Double circle3 = new Ellipse2D.Double(200, 665, 50, 50);
g2.setColor(light3);
g2.fill(circle3);
g2.setColor(Color.BLACK);
g2.draw(circle3);
Ellipse2D.Double circle4 = new Ellipse2D.Double(275, 665, 50, 50);
g2.setColor(light4);
g2.fill(circle4);
g2.setColor(Color.BLACK);
g2.draw(circle4);
}
public void glidePathOn()
{
light1 = Color.WHITE;
light2 = Color.WHITE;
light3 = Color.RED;
light4 = Color.RED;
}
public void glidePathSlightlyHigh()
{
light1 = Color.WHITE;
light2 = Color.WHITE;
light3 = Color.WHITE;
light4 = Color.RED;
}
public void glidePathTooHigh()
{
light1 = Color.WHITE;
light2 = Color.WHITE;
light3 = Color.WHITE;
light4 = Color.WHITE;
}
public void glidePathSlightlyLow()
{
light1 = Color.WHITE;
light2 = Color.RED;
light3 = Color.RED;
light4 = Color.RED;
}
public void glidePathTooLow()
{
light1 = Color.RED;
light2 = Color.RED;
light3 = Color.RED;
light4 = Color.RED;
}
}