Programming with colour buttons.
William Overington
Copyright 2001 William Overington
Tuesday 10 July 2001
A Java applet written to run on the world wide web that seeks to simulate, as best I know how at present, a program that uses the colour buttons of the DVB-MHP minimum system.
In this simulation, the upper panel represents the television screen and the lower panel represents the colour buttons of a hand held infra-red control device. In this simulation, activation of the colour buttons is by clicking them with a mouse unit. The simulation simply draws orange and magenta panels in order to produce a visual demonstration.
I have used an area that is 512 pixels wide by 288 pixels high to simulate the screen of a DVB-MHP terminal. These figures have been chosen as they are half scale to a 16 x 9 display of 1024 pixels by 576 pixels. This seems, at my present level of knowledge, a reasonable basis for simulating aspects of the DVB-MHP system on the world wide web.
Here is a link to viewing the web based simulation. A Java enabled browser is required.
The web based simulation of programming with colour buttons.
Here is the source code of the Java applet.
import java.awt.*;
import java.awt.event.*;
public class ast00201 extends java.applet.Applet implements
ActionListener
// Software written by William Overington
// WOverington@ngo.globalnet.co.uk
// 10 July 2001
// Copyright 2001 William Overington
//
{
int obeycode;
Button colourButton1 = new Button("");
Button colourButton2 = new Button("");
Button colourButton3 = new Button("");
Button colourButton4 = new Button("");
public void init()
{
setLayout(null);
setBounds(0,0,512,400);
colourButton1.addActionListener(this);
colourButton1.setLocation(50,350);
colourButton1.setSize(25,25);
colourButton1.setBackground(Color.red);
add(colourButton1);
colourButton2.addActionListener(this);
colourButton2.setLocation(100,350);
colourButton2.setSize(25,25);
colourButton2.setBackground(Color.green);
add(colourButton2);
colourButton3.addActionListener(this);
colourButton3.setLocation(150,350);
colourButton3.setSize(25,25);
colourButton3.setBackground(Color.yellow);
add(colourButton3);
colourButton4.addActionListener(this);
colourButton4.setLocation(200,350);
colourButton4.setSize(25,25);
colourButton4.setBackground(Color.blue);
add(colourButton4);
setBackground(Color.black);
obeycode=1;
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if (source == colourButton1)
{
obeycode=51;
repaint();
}
if (source == colourButton2)
{
obeycode=52;
repaint();
}
if (source == colourButton3)
{
obeycode=53;
repaint();
}
if (source == colourButton4)
{
obeycode=54;
repaint();
}
}
public void paint(Graphics screen)
{
if (obeycode == 1)
{
screen.setColor(Color.white);
screen.fillRect(0,289,512,112);
screen.setColor(Color.gray);
screen.fillRoundRect(0,325,512,75,20,20);
screen.clipRect(0,0,512,288);
}
else if (obeycode == 51)
{
screen.setColor(Color.orange);
screen.fillRect(156,44,100,200);
}
else if (obeycode == 52)
{
screen.setColor(Color.orange);
screen.fillRect(256,44,100,200);
}
else if (obeycode == 53)
{
screen.setColor(Color.magenta);
screen.fillRect(156,44,200,100);
}
else if (obeycode == 54)
{
screen.setColor(Color.magenta);
screen.fillRect(156,144,200,100);
}
obeycode=1;
}
public void update(Graphics screen)
{
paint(screen);
}
}
An interesting exercise is to try to obtain a display of a magenta field with an orange square in the bottom right hand corner by clicking on the buttons.
The question that I now need to resolve is how to write a Java program that produces upon a DVB-MHP system the same graphic demonstration that appears in the upper panel of the simulation.
Astrolabe Channel
Copyright 2001 William Overington
This file is accessible as follows.