import java.applet.Applet; import java.awt.*; public class hybrid1 extends Applet { public Choice cb; private Button b1, b2, b3, b4, b5; private Canvas c; private Checkbox check1, check2, check3, check4, check5, check6, check7; private Font f; private Label oxLabel, amountLabel, throtLabel; public void init() { // do not use a layout manager setLayout( null ); setBackground(Color.black); setForeground(Color.yellow); cb = new Choice(); cb.addItem( "Fuel Grain Calculations" ); cb.addItem( "Oxidiser Tank Optimisation" ); cb.addItem( "Combustion Chamber Analysis" ); cb.addItem( "Simple Trajectory Analysis" ); check1 = new Checkbox( "Chamber Temperature" ); check2 = new Checkbox( "Nozzle Temperature" ); check3 = new Checkbox( "Oxidiser Flow Rate" ); check4 = new Checkbox( "Burn Duration" ); check5 = new Checkbox( "Throttle Motor Voltage" ); check6 = new Checkbox( "Throttle Motor Current" ); check7 = new Checkbox( "Battery Power" ); // c = new Canvas(); // c.setBackground( Color.black ); // c.resize( 20, 10 ); b1 = new Button( "Throttle Up" ); b2 = new Button( "Throttle Down" ); b3 = new Button( "50% Throttle" ); b4 = new Button( "25% Throttle" ); b5 = new Button( "Ignition" ); add( cb ); add( b1 ); add( b2 ); add( b3 ); add( b4 ); add( b5 ); setForeground(Color.red); add( check1 ); setForeground(Color.orange); add( check2 ); setForeground(Color.yellow); add( check3 ); setForeground(Color.blue); add( check4 ); setForeground(Color.cyan); add( check5 ); setForeground(Color.red); add( check6 ); setForeground(Color.blue); add( check7 ); // add ( c ); b1.reshape( 105, 20, 75, 25 ); b2.reshape( 105, 80, 75, 25 ); b3.reshape( 25, 50, 75, 25); b4.reshape( 185, 50, 75, 25 ); b5.reshape( 105, 50, 75, 25); check1.reshape(20, 255, 125, 25); check2.reshape(150, 255, 115, 25); check3.reshape(20, 285, 115, 25); check4.reshape(150, 285, 115, 25); check5.reshape(300, 250, 125, 25); check6.reshape(300, 270, 125, 25); check7.reshape(300, 290, 90, 25); // c.reshape( 20, 120, 240, 100); cb.reshape( 280, 20, 150, 17); f = new Font( "Arial", Font.BOLD + Font.ITALIC, 15 ); setForeground( Color.green ); oxLabel = new Label(); oxLabel.setText( "OXIDISER" ); oxLabel.setFont( f ); add( oxLabel ); oxLabel.reshape( 15, 360, 80, 15); f = new Font( "Arial", Font.BOLD, 20 ); setForeground( Color.red ); amountLabel = new Label(); amountLabel.setText( "100 %" ); amountLabel.setFont( f ); add( amountLabel ); amountLabel.reshape( 25, 380, 80, 20); f = new Font( "Arial", Font.BOLD + Font.ITALIC, 15 ); setForeground( Color.white ); throtLabel = new Label(); throtLabel.setText( "THROTTLE" ); throtLabel.setFont( f ); add( throtLabel ); throtLabel.reshape( 310, 55, 80, 15); } public void paint ( Graphics g ) { g.setColor( Color.green ); // Left Graph // These lines ---- for (int i = 12; i < 25; i++) { g.drawLine(20, i * 10, 260, i * 10); } // These lines - |||||| for (int i = 2; i < 27; i++) { g.drawLine(i * 10, 120, i * 10, 240); } g.setColor( Color.orange ); // Right Graph // These lines ---- for (int i = 12; i < 25; i++) { g.drawLine(300, i * 10, 430, i * 10); } // These lines - |||||| for (int i = 30; i < 44; i++) { g.drawLine(i * 10, 120, i * 10, 240); } // Valve // x1, y1, x2, y2 g.setColor( Color.yellow ); g.drawRect( 70, 333, 15, 15 ); g.drawLine(70, 333, 85, 348); g.drawLine(85, 333, 70, 348); // Flow Line g.drawLine(86, 338, 125, 338); g.drawLine(86, 343, 125, 343); // Oxidiser Tank g.setColor( Color.yellow ); g.drawArc( 125, 320, 41, 41, 90, 180 ); g.setColor( Color.red ); g.fillArc( 126, 321, 40, 40, 90, 180 ); g.setColor( Color.yellow ); g.drawRect( 148, 320, 30, 40 ); g.setColor( Color.pink ); g.fillRect( 149, 321, 29, 39 ); g.setColor( Color.yellow ); g.drawRect( 181, 320, 30, 40 ); g.setColor( Color.orange ); g.fillRect( 182, 321, 29, 39 ); g.setColor( Color.yellow ); g.drawRect( 214, 320, 30, 40 ); g.setColor( Color.green ); g.fillRect( 215, 321, 29, 39 ); g.setColor( Color.yellow ); g.drawRect( 247, 320, 30, 40 ); g.setColor( Color.green ); g.fillRect( 248, 321, 29, 39 ); g.setColor( Color.yellow ); g.drawRect( 280, 320, 30, 40 ); g.setColor( Color.green ); g.fillRect( 281, 321, 29, 39 ); g.setColor( Color.yellow ); g.drawArc( 291, 320, 41, 41, 270, 180 ); // Scale g.setColor( Color.white); g.drawLine(125, 390, 332, 390); g.drawLine(125, 390, 125, 375); g.drawLine(148, 390, 148, 380); g.drawLine(181, 390, 181, 380); g.drawLine(214, 390, 214, 380); g.drawLine(247, 390, 247, 380); g.drawLine(280, 390, 280, 380); g.drawLine(310, 390, 310, 380); g.drawLine(332, 390, 332, 375); } public boolean action( Event e, Object o ) { if (e.target == b1 ) { showStatus( "Throttle Up " ); // g.setColor( Color.black ); // g.fillRect( 281, 281, 29, 39 ); return true; } if (e.target == b2 ) { showStatus( "Throttle Down" ); // g.setColor( Color.black ); // g.fillRect( 281, 281, 29, 39 ); return true; } if (e.target == b3 ) { showStatus( "50% Throttle " ); // g.setColor( Color.black ); // g.fillRect( 281, 281, 29, 39 ); return true; } if (e.target == b4 ) { showStatus( "25% Throttle " ); // g.setColor( Color.black ); // g.fillRect( 281, 281, 29, 39 ); return true; } if (e.target == b5 ) { showStatus( "Motor Ignition " ); // g.setColor( Color.black ); // g.fillRect( 281, 281, 29, 39 ); return true; } // return true; if ( e.target instanceof Choice ) { cb.getSelectedItem(); cb.countItems(); if (cb.getSelectedIndex() == 0) { showStatus( "This option is not currently available" ); } // return true; if (cb.getSelectedIndex() == 1) { showStatus( "This option is not currently available" ); } if (cb.getSelectedIndex() == 2) { showStatus( "This option is not currently available" ); } if (cb.getSelectedIndex() == 3) { showStatus( "This option is not currently available" ); } } return true; } }