import java.awt.*;
import java.awt.event.*;
public class ast00901 extends java.applet.Applet implements
ActionListener,MouseListener
// Software written by William Overington
// WOverington@ngo.globalnet.co.uk
// 26 July 2001
// Copyright 2001 William Overington
//
{
int obeycode;
int storedobeycode;
int pressx,pressy;
boolean SIMULATION_DVB_MHP_MOUSE_ATTACHED=false;
// this is what the simulation management environment knows
boolean mouseattached;
// this is what the simulated program knows
Button colourButton1 = new Button("");
Button colourButton2 = new Button("");
Button colourButton3 = new Button("");
Button colourButton4 = new Button("");
Button digitButton0 = new Button("0");
Button digitButton1 = new Button("1");
Button digitButton2 = new Button("2");
Button digitButton3 = new Button("3");
Button digitButton4 = new Button("4");
Button digitButton5 = new Button("5");
Button digitButton6 = new Button("6");
Button digitButton7 = new Button("7");
Button digitButton8 = new Button("8");
Button digitButton9 = new Button("9");
Button upButton = new Button("^");
Button downButton = new Button("v");
Button leftButton = new Button("<");
Button rightButton = new Button(">");
Button enterButton = new Button("E");
Button teletextButton = new Button("T");
Font buttonsfont,displayfont;
// items needed from Print1456.java and not already in here starts
Engine1456 firefly = new Engine1456();
String software,software01,software02,software03,software04,
software05,software06,software07,software08,software09;
int length,length01,length02,length03,length04,length05,length06,
length07,length08,length09;
char resultchar;
String string00,string01,string02,string03,string04,
string05,string06,string07,string08,string09;
// items needed from Print1456.java and not already in here finishes
// polyglot compatibility section starts
// There are no strings to be translated for this program.
// polyglot compatibility section finishes
public void init()
{
setLayout(null);
setBounds(0,0,512,400);
buttonsfont = new Font("SansSerif", Font.PLAIN, 18);
displayfont = new Font("SansSerif", Font.PLAIN, 24);
setFont(buttonsfont);
colourButton1.addActionListener(this);
colourButton1.setLocation(16,327);
colourButton1.setSize(25,25);
colourButton1.setBackground(Color.red);
add(colourButton1);
colourButton2.addActionListener(this);
colourButton2.setLocation(48,327);
colourButton2.setSize(25,25);
colourButton2.setBackground(Color.green);
add(colourButton2);
colourButton3.addActionListener(this);
colourButton3.setLocation(80,327);
colourButton3.setSize(25,25);
colourButton3.setBackground(Color.yellow);
add(colourButton3);
colourButton4.addActionListener(this);
colourButton4.setLocation(112,327);
colourButton4.setSize(25,25);
colourButton4.setBackground(Color.blue);
add(colourButton4);
digitButton0.addActionListener(this);
digitButton0.setLocation(16,359);
digitButton0.setSize(25,25);
digitButton0.setBackground(Color.lightGray);
add(digitButton0);
digitButton1.addActionListener(this);
digitButton1.setLocation(48,359);
digitButton1.setSize(25,25);
digitButton1.setBackground(Color.lightGray);
add(digitButton1);
digitButton2.addActionListener(this);
digitButton2.setLocation(80,359);
digitButton2.setSize(25,25);
digitButton2.setBackground(Color.lightGray);
add(digitButton2);
digitButton3.addActionListener(this);
digitButton3.setLocation(112,359);
digitButton3.setSize(25,25);
digitButton3.setBackground(Color.lightGray);
add(digitButton3);
digitButton4.addActionListener(this);
digitButton4.setLocation(144,359);
digitButton4.setSize(25,25);
digitButton4.setBackground(Color.lightGray);
add(digitButton4);
digitButton5.addActionListener(this);
digitButton5.setLocation(176,359);
digitButton5.setSize(25,25);
digitButton5.setBackground(Color.lightGray);
add(digitButton5);
digitButton6.addActionListener(this);
digitButton6.setLocation(208,359);
digitButton6.setSize(25,25);
digitButton6.setBackground(Color.lightGray);
add(digitButton6);
digitButton7.addActionListener(this);
digitButton7.setLocation(240,359);
digitButton7.setSize(25,25);
digitButton7.setBackground(Color.lightGray);
add(digitButton7);
digitButton8.addActionListener(this);
digitButton8.setLocation(272,359);
digitButton8.setSize(25,25);
digitButton8.setBackground(Color.lightGray);
add(digitButton8);
digitButton9.addActionListener(this);
digitButton9.setLocation(304,359);
digitButton9.setSize(25,25);
digitButton9.setBackground(Color.lightGray);
add(digitButton9);
upButton.addActionListener(this);
upButton.setLocation(372,327);
upButton.setSize(25,25);
upButton.setBackground(Color.lightGray);
add(upButton);
downButton.addActionListener(this);
downButton.setLocation(372,359);
downButton.setSize(25,25);
downButton.setBackground(Color.lightGray);
add(downButton);
leftButton.addActionListener(this);
leftButton.setLocation(340,343);
leftButton.setSize(25,25);
leftButton.setBackground(Color.lightGray);
add(leftButton);
rightButton.addActionListener(this);
rightButton.setLocation(404,343);
rightButton.setSize(25,25);
rightButton.setBackground(Color.lightGray);
add(rightButton);
enterButton.addActionListener(this);
enterButton.setLocation(439,359);
enterButton.setSize(25,25);
enterButton.setBackground(Color.lightGray);
add(enterButton);
teletextButton.addActionListener(this);
teletextButton.setLocation(471,359);
teletextButton.setSize(25,25);
teletextButton.setBackground(Color.lightGray);
add(teletextButton);
addMouseListener(this);
// items needed from Print1456.java and not already in here starts
software="";
software01 = getParameter("SOFTWARE01");
if (software01 != null)
{
length01=software01.length();
if (length01 > 0)
{
software=software+software01;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software02 = getParameter("SOFTWARE02");
if (software02 != null)
{
length02=software02.length();
if (length02 > 0)
{
software=software+software02;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software03 = getParameter("SOFTWARE03");
if (software03 != null)
{
length03=software03.length();
if (length03 > 0)
{
software=software+software03;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software04 = getParameter("SOFTWARE04");
if (software04 != null)
{
length04=software04.length();
if (length04 > 0)
{
software=software+software04;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software05 = getParameter("SOFTWARE05");
if (software05 != null)
{
length05=software05.length();
if (length05 > 0)
{
software=software+software05;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software06 = getParameter("SOFTWARE06");
if (software06 != null)
{
length06=software06.length();
if (length06 > 0)
{
software=software+software06;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software07 = getParameter("SOFTWARE07");
if (software07 != null)
{
length07=software07.length();
if (length07 > 0)
{
software=software+software07;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software08 = getParameter("SOFTWARE08");
if (software08 != null)
{
length08=software08.length();
if (length08 > 0)
{
software=software+software08;
firefly.loadSoftwareFromAppletParameters(software);
}
}
software="";
software09 = getParameter("SOFTWARE09");
if (software09 != null)
{
length09=software09.length();
if (length09 > 0)
{
software=software+software09;
firefly.loadSoftwareFromAppletParameters(software);
}
}
string01 = getParameter("STRING01");
if (string01 != null)
{
firefly.loadStringFromString(1,string01);
}
string02 = getParameter("STRING02");
if (string02 != null)
{
firefly.loadStringFromString(2,string02);
}
string03 = getParameter("STRING03");
if (string03 != null)
{
firefly.loadStringFromString(3,string03);
}
string04 = getParameter("STRING04");
if (string04 != null)
{
firefly.loadStringFromString(4,string04);
}
string05 = getParameter("STRING05");
if (string05 != null)
{
firefly.loadStringFromString(5,string05);
}
string06 = getParameter("STRING06");
if (string06 != null)
{
firefly.loadStringFromString(6,string06);
}
string07 = getParameter("STRING07");
if (string07 != null)
{
firefly.loadStringFromString(7,string07);
}
string08 = getParameter("STRING08");
if (string08 != null)
{
firefly.loadStringFromString(8,string08);
}
string09 = getParameter("STRING09");
if (string09 != null)
{
firefly.loadStringFromString(9,string09);
}
firefly.landscapeAuthorIs("William Overington" +
" " +
"WOverington@ngo.globalnet.co.uk");
// items needed from Print1456.java and not already in here finishes
setBackground(Color.black);
obeycode=1;
storedobeycode=1;
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if (source == colourButton1)
{
obeycode=51;
repaint();
}
else
if (source == colourButton2)
{
obeycode=52;
repaint();
}
else
if (source == colourButton3)
{
obeycode=53;
repaint();
}
else
if (source == colourButton4)
{
obeycode=54;
repaint();
}
else
if (source == digitButton0)
{
obeycode=20;
repaint();
}
else
if (source == digitButton1)
{
obeycode=21;
repaint();
}
else
if (source == digitButton2)
{
obeycode=22;
repaint();
}
else
if (source == digitButton3)
{
obeycode=23;
repaint();
}
else
if (source == digitButton4)
{
obeycode=24;
repaint();
}
else
if (source == digitButton5)
{
obeycode=25;
repaint();
}
else
if (source == digitButton6)
{
obeycode=26;
repaint();
}
else
if (source == digitButton7)
{
obeycode=27;
repaint();
}
else
if (source == digitButton8)
{
obeycode=28;
repaint();
}
else
if (source == digitButton9)
{
obeycode=29;
repaint();
}
else
if (source == upButton)
{
obeycode=61;
repaint();
}
else
if (source == downButton)
{
obeycode=62;
repaint();
}
else
if (source == leftButton)
{
obeycode=63;
repaint();
}
else
if (source == rightButton)
{
obeycode=64;
repaint();
}
else
if (source == enterButton)
{
obeycode=91;
repaint();
}
else
if (source == teletextButton)
{
obeycode=92;
repaint();
}
}
public void mousePressed(MouseEvent e)
{
pressx=e.getX();
pressy=e.getY();
if ((pressy > 300) & (pressy < 311))
// then a command to the simulation environment management is intended
//
// the 300 is used in the test rather than 288 so as to give a blank area below
// the simulated display screen just in case a click intended for the bottom
// of the simulated display screen is clicked a few pixels low in error
{
if (pressx < 256) // simulated no DVB-MHP mouse
{
SIMULATION_DVB_MHP_MOUSE_ATTACHED=false;
}
else // simulated DVB-MHP mouse present
{
SIMULATION_DVB_MHP_MOUSE_ATTACHED=true;
}
obeycode=1;
repaint();
}
else if (pressy <= 287)
// then a click within the simulation on the simulated display screen is intended
{
if(SIMULATION_DVB_MHP_MOUSE_ATTACHED)
{
// items needed from Print1456.java and not already in here starts
firefly.integer1456Set(5,pressx);
firefly.integer1456Set(6,pressy);
// items needed from Print1456.java and not already in here finishes
obeycode=41;
repaint();
}
else
{
donothing();
}
}
else
// the mouse press is on the simulated hand held infra-red control device
// or the upper part of the white area and is disregarded
{
donothing();
}
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void paint(Graphics screen)
{
storedobeycode=obeycode;
screen.setFont(displayfont);
if(obeycode == 1)
{
// start up for the simulation management
screen.setColor(Color.black);
screen.fillRect(0,0,512,288);
screen.setColor(Color.white);
screen.fillRect(0,288,512,112);
screen.setColor(Color.gray);
screen.fillRoundRect(0,311,512,89,20,20);
screen.clipRect(0,0,512,288);
// start up for the program that is being simulated
mouseattached=SIMULATION_FOR_MOUSE_getInputDeviceSupported();
}
// items needed from Print1456.java and not already in here starts
resultchar =
firefly.obeySoftwareAtLabel(screen,obeycode);
if (resultchar == '?')
{
do
{
int functionchoice=
firefly.softwareinterruptparameterGet();
if (functionchoice == 41)
{
if(mouseattached)
{
firefly.ai1456Set(1);
}
else
{
firefly.ai1456Set(0);
}
}
resultchar =
firefly.obeySoftwareAfterSoftwareInterrupt(screen);
} while (resultchar == '?');
// items needed from Print1456.java and not already in here finishes
}
obeycode=1;
}
public void update(Graphics screen)
{
paint(screen);
}
private void donothing()
{
// does nothing
}
private boolean SIMULATION_FOR_MOUSE_getInputDeviceSupported()
{
return SIMULATION_DVB_MHP_MOUSE_ATTACHED;
}
}