package fsim_panels1;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;
import com.fazecast.jSerialComm.*;
public class Fsim_Panels1 extends JFrame{
/**
* @param args the command line arguments
*/
public static JPanel ptop = null; //-Panel fuer diverse Einstellungen (Flughoehe,Std.Geschwindigkeit usw
public static JPanel phv = null; //-Panel fuer Geschwindigkeitsanzeige
public static JPanel phh = null; //-Panel fuer Horizontanzeige
public static JPanel pha = null; //-Panel fuer Hoehenanzeige
public static JPanel pk = null; //-Panel fuer Kompassanzeige
public static JPanel pm = null; //-Panel fuer Maschinenanzeige
public static JPanel pt = null; //-Panel fuer Zeitanzeige
public static JPanel pbottom = null; //-Panel fuer diverse Einstellungen (Flughoehe,Std.Geschwindigkeit usw
public static PolygonGenerator pg = null; //- erzeugt Hintergrund und Trapez fuer den Vordergrund
public static int y_high_parts = 0; //- die hohen Panes fuer Horizont usw
public static int h_high_parts = 490; //- dito
public static int y_startline_high_parts = 35; //- dito
public static void main(String[] args) {
JFrame fMain_frame = new JFrame("Main-Panel");
fMain_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fMain_frame.setBounds(100, 100, 1000, 600);
fMain_frame.setTitle("Boeing-Cockpit");
fMain_frame.setBackground(Color.yellow);
//fMain_frame.setLayout(new GridLayout(1,6));
fMain_frame.setLayout(new BorderLayout());
panel_top();
fMain_frame.getContentPane().add(ptop,BorderLayout.NORTH);
panel_velocity();
fMain_frame.getContentPane().add(phv);
panel_artific_horizon();
fMain_frame.getContentPane().add(phh);
panel_altitude();
fMain_frame.getContentPane().add(pha);
panel_kompass();
fMain_frame.getContentPane().add(pk);
panel_machine();
fMain_frame.getContentPane().add(pm);
panel_time();
fMain_frame.getContentPane().add(pt);
panel_bottom();
fMain_frame.getContentPane().add(pbottom,BorderLayout.SOUTH);
fMain_frame.revalidate();
fMain_frame.setVisible(true);
simulate_horizon_gliding(Graphics g);
}
public static void panel_top() {
ptop = new JPanel();
ptop.setBackground(Color.PINK);
ptop.setBounds(0, 0, 0, 50);
ptop.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("several items");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_top"));
ptop.add(lblFirst);
ptop.revalidate();
ptop.setVisible(true);
}
public static void panel_velocity() {
phv = new JPanel();
phv.setBackground(Color.red);
phv.setBounds(0, y_startline_high_parts+y_high_parts, 100, h_high_parts);
phv.setPreferredSize(new Dimension(100, h_high_parts));
phv.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("kt/h");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_velocity"));
phv.add(lblFirst);
phv.revalidate();
phv.setVisible(true);
}
public static void panel_artific_horizon() {
phh = new JPanel();
phh.setBackground(Color.BLACK);
phh.setBounds(100, y_startline_high_parts+y_high_parts, 300, h_high_parts);
phh.setPreferredSize(new Dimension(300, h_high_parts));
phh.setLayout(new BorderLayout());
/*
JLabel lblFirst = new JLabel("alt.position");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_horizon"));
phh.add(lblFirst);
*/
PolygonGenerator pg = new PolygonGenerator();
phh.add(pg);
phh.revalidate();
phh.setVisible(true);
}
public static void panel_altitude() {
pha = new JPanel();
pha.setBackground(Color.BLUE);
pha.setBounds(400, y_startline_high_parts+y_high_parts, 100, h_high_parts);
pha.setPreferredSize(new Dimension(100, h_high_parts));
pha.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("feet");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("altitude"));
pha.add(lblFirst);
pha.revalidate();
pha.setVisible(true);
}
public static void panel_kompass() {
pk = new JPanel();
pk.setBackground(Color.CYAN);
pk.setBounds(500, y_startline_high_parts+y_high_parts, 300, h_high_parts);
pk.setPreferredSize(new Dimension(300, h_high_parts));
pk.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("direction");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_kompass"));
pk.add(lblFirst);
pk.revalidate();
pk.setVisible(true);
}
public static void panel_machine() {
pm = new JPanel();
pm.setBackground(Color.ORANGE);
pm.setBounds(800, y_startline_high_parts+y_high_parts, 100, h_high_parts);
pm.setPreferredSize(new Dimension(100, h_high_parts));
pm.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("machine");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_machine"));
pm.add(lblFirst);
pm.revalidate();
pm.setVisible(true);
}
public static void panel_time() {
pt = new JPanel();
pt.setBackground(Color.GREEN);
pt.setBounds(900, y_startline_high_parts+y_high_parts, 100, h_high_parts);
pt.setPreferredSize(new Dimension(100, h_high_parts));
pt.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("flyer-time");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_time"));
pt.add(lblFirst,BorderLayout.EAST);
pt.revalidate();
pt.setVisible(true);
}
public static void panel_bottom() {
pbottom = new JPanel();
pbottom.setBackground(Color.MAGENTA);
pbottom.setBounds(0, 0, 0, 50);
pbottom.setLayout(new BorderLayout());
JLabel lblFirst = new JLabel("several items");
lblFirst.setHorizontalTextPosition(JLabel.CENTER);
lblFirst.setVerticalTextPosition(JLabel.TOP);
lblFirst.setBorder(new TitledBorder("panel_bottom"));
pbottom.add(lblFirst);
pbottom.revalidate();
pbottom.setVisible(true);
}
public static void simulate_horizon_gliding(Graphics g){
Color c_brown = new Color(128,128,110);
Color c_blue_light = new Color(176,224,250);
int y_baseline = 5;
int win_width = 400;
int numberofpoints = 4;
int border_point_left = 5;
int[] border_points_y = {0,60,80};
// x coordinates of vertices
int x[] = { border_point_left, border_point_left, win_width, win_width};
int y[] = { border_points_y[0]+y_baseline, border_points_y[1]+y_baseline, border_points_y[2]+y_baseline, border_points_y[0]+y_baseline };
int i = 0;
for(i=0;i < 10;i++)
{
y[1] = border_points_y[1]+y_baseline+i;
y[2] = border_points_y[2]+y_baseline-i;
pg.neu_zeichnen(g,5,400,c_brown,4,x,y);
try{
TimeUnit.SECONDS.sleep(1000);
}catch(InterruptedException e){}
}
}