import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.Timer;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import processing.core.*;
/*Matt Kuhn
* 6-28-13
*
*
* this is a Jungle Timer for League of Legends
*/
public class timerWindow1 extends JFrame implements ActionListener {
// clock
Timer clock = new Timer(1000, this);
processing shapes = new processing();
//button variables
JButton Baron, Dragon, theirRed, ourRed, theirBlue, ourBlue, theirWraiths, ourWraiths, theirGolems, ourGolems, theirWolves, ourWolves, theirWight, ourWight;
JLabel bname, dname, trname, orname, tbname, obname, twname, owname, tgname, ogname, twoname, owoname, twiname, owiname;
//Seconds
Integer baronTimer = 60, dragonTimer = 60, trTimer = 60, orTimer = 60, tbTimer = 60, obTimer = 60, twTimer = 50, owTimer = 50, tgTimer = 0, ogTimer = 0, twoTimer = 50, owoTimer = 50, twiTimer = 50, owiTimer = 50;
//Minutes
Integer baronMTimer = 6, dragonMTimer = 5, trMTimer = 4, orMTimer = 4, tbMTimer = 4, obMTimer = 4, twMTimer = 0, owMTimer = 0, tgMTimer = 1, ogMTimer = 1, twoMTimer = 0, owoMTimer = 0, twiMTimer = 0, owiMTimer = 0;
boolean dragonRunning, baronRunning, tredRunning, oredRunning, tblueRunning, oblueRunning, twraithsRunning, owraithsRunning, tgolemsRunning, ogolemsRunning, twolvesRunning, owolvesRunning, twightRunning, owightRunning;
//key actions
KeyEvent button1;
KeyListener all;
//the window constructor
timerWindow1 (String title){
super (title);
this.init();
this.setSize(900, 600);
this.setVisible(true);
shapes.setup();
shapes.draw();
}
void init(){
//the timers
bname = new JLabel("7:00");//Baron
dname = new JLabel("6:00");//Dragon
trname = new JLabel("5:00");//their red
orname = new JLabel("5:00");//our red
tbname = new JLabel("5:00");//their blue
obname = new JLabel("5:00");//our blue
twname = new JLabel("0:50");//their wraiths
owname = new JLabel("0:50");//our wraiths
tgname = new JLabel("1:00");//their golems
ogname = new JLabel("1:00");//our golems
twoname = new JLabel("0:50");//their wolves
owoname = new JLabel("0:50");//our wolves
twiname = new JLabel("0:50");//their wight
owiname = new JLabel("0:50");//our wight
//button setup
Baron = new JButton("Baron");
Dragon = new JButton("Dragon");
theirRed = new JButton("Their red");
ourRed= new JButton("Our red");
theirBlue = new JButton("Their blue");
ourBlue = new JButton("Our blue");
theirWraiths = new JButton("Their wraiths");
ourWraiths = new JButton("Our wraiths");
theirGolems = new JButton("Their golems");
ourGolems = new JButton("Our golems");
theirWolves = new JButton("Their wolves");
ourWolves = new JButton("Our wolves");
theirWight = new JButton("Their wight");
ourWight = new JButton("Our wight");
//button colors
Color coolOrange = new Color(242, 161, 33);
Color coolAqua = new Color(8, 196, 138);
Baron.setBackground(Color.MAGENTA);
Dragon.setBackground(coolOrange);
theirRed.setBackground(Color.RED);
ourRed.setBackground(Color.RED);
theirBlue.setBackground(Color.BLUE);
ourBlue.setBackground(Color.BLUE);
theirWraiths.setBackground(Color.GRAY);
ourWraiths.setBackground(Color.GRAY);
theirGolems.setBackground(Color.GREEN);
ourGolems.setBackground(Color.GREEN);
theirWolves.setBackground(Color.LIGHT_GRAY);
ourWolves.setBackground(Color.LIGHT_GRAY);
theirWight.setBackground(coolAqua);
ourWight.setBackground(coolAqua);
//button listeners
Baron.addActionListener(this);
Dragon.addActionListener(this);
theirRed.addActionListener(this);
ourRed.addActionListener(this);
theirBlue.addActionListener(this);
ourBlue.addActionListener(this);
theirWraiths.addActionListener(this);
ourWraiths.addActionListener(this);
theirGolems.addActionListener(this);
ourGolems.addActionListener(this);
theirWolves.addActionListener(this);
ourWolves.addActionListener(this);
theirWight.addActionListener(this);
ourWight.addActionListener(this);
//key listeners
//((Component) all).addKeyListener((KeyListener) this);
// Dragon.addKeyListener(this);
// theirRed.addKeyListener(this);
// ourRed.addKeyListener(this);
// theirBlue.addKeyListener(this);
// ourBlue.addKeyListener(this);
// theirWraiths.addKeyListener(this);
// ourWraiths.addKeyListener(this);
// theirGolems.addKeyListener(this);
// ourGolems.addKeyListener(this);
// theirWolves.addKeyListener(this);
// ourWolves.addKeyListener(this);
//timer and button panels
JPanel panel = new JPanel(new GridLayout(7,2));
panel.add(Baron);
panel.add(bname);
panel.add(Dragon);
panel.add(dname);
panel.add(theirRed);
panel.add(trname);
panel.add(ourRed);
panel.add(orname);
panel.add(theirBlue);
panel.add(tbname);
panel.add(ourBlue);
panel.add(obname);
panel.add(theirWraiths);
panel.add(twname);
panel.add(ourWraiths);
panel.add(owname);
panel.add(theirGolems);
panel.add(tgname);
panel.add(ourGolems);
panel.add(ogname);
panel.add(theirWolves);
panel.add(twoname);
panel.add(ourWolves);
panel.add(owoname);
panel.add(theirWight);
panel.add(twiname);
panel.add(ourWight);
panel.add(owiname);
Toolkit.getDefaultToolkit().beep();
//checks for timers
clock.start();
//adds it all
this.add(panel);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//if button is pushed start clock
if (e.getSource() == Baron )
{
baronRunning = true;
}
if (e.getSource() == Dragon ){
dragonRunning = true;
}
if (e.getSource() == theirRed){
tredRunning = true;
}
if (e.getSource() == ourRed){
oredRunning = true;
}
if (e.getSource() == theirBlue){
tblueRunning = true;
}
if (e.getSource() == ourBlue){
oblueRunning = true;
}
if (e.getSource() == theirWraiths){
twraithsRunning = true;
}
if (e.getSource() == ourWraiths){
owraithsRunning = true;
}
if (e.getSource() == theirGolems ){
tgolemsRunning = true;
}
if (e.getSource() == ourGolems){
ogolemsRunning = true;
}
if (e.getSource() == theirWolves){
twolvesRunning = true;
}
if (e.getSource() == ourWolves){
owolvesRunning = true;
}
if (e.getSource() == theirWight){
twightRunning = true;
}
if (e.getSource() == ourWight){
owightRunning = true;
}
//clock running mechanics
if(baronRunning && e.getSource()==clock){
if(baronMTimer == 0 && baronTimer == 0)
{
baronRunning = false;
baronTimer = 00;
baronMTimer = 7;
Toolkit.getDefaultToolkit().beep();
}
if(baronTimer == 0)
{
baronMTimer--;
baronTimer = 60;
}
baronTimer--;
if(baronTimer < 10)
{
bname.setText(baronMTimer.toString() + ":0" + baronTimer.toString());
}
else
{
bname.setText(baronMTimer.toString() + ":" + baronTimer.toString());
}
}
if(dragonRunning && e.getSource()==clock){
if(dragonMTimer == 0 && dragonTimer == 0)
{
dragonRunning = false;
dragonTimer = 01;
dragonMTimer = 6;
Toolkit.getDefaultToolkit().beep();
}
if(dragonTimer == 0)
{
dragonMTimer--;
dragonTimer = 60;
}
dragonTimer--;
if(dragonTimer < 10)
{
dname.setText(dragonMTimer.toString() + ":0" + dragonTimer.toString());
}
else
{
dname.setText(dragonMTimer.toString() + ":" + dragonTimer.toString());
}
}
if(tredRunning && e.getSource()==clock){
if(trMTimer == 0 && trTimer == 0)
{
tredRunning = false;
trTimer = 01;
trMTimer = 5;
Toolkit.getDefaultToolkit().beep();
}
if(trTimer==0)
{
trMTimer--;
trTimer = 60;
}
trTimer--;
if(trTimer < 10)
{
trname.setText(trMTimer.toString() + ":0" + trTimer.toString());
}
else
{
trname.setText(trMTimer.toString() + ":" + trTimer.toString());
}
}
if(oredRunning && e.getSource()==clock){
if(orTimer == 0 && orMTimer == 0)
{
oredRunning = false;
orTimer = 01;
orMTimer = 5;
Toolkit.getDefaultToolkit().beep();
}
if(orTimer == 0)
{
orMTimer--;
orTimer = 60;
}
orTimer--;
if(orTimer < 10)
{
orname.setText(orMTimer.toString() + ":0" + orTimer.toString());
}
else
{
orname.setText(orMTimer.toString() + ":" + orTimer.toString());
}
}
if(tblueRunning && e.getSource()==clock){
if(tbTimer== 0 && tbMTimer ==0)
{
tblueRunning = false;
tbTimer = 01;
tbMTimer = 5;
Toolkit.getDefaultToolkit().beep();
}
if(tbTimer== 0)
{
tbMTimer--;
tbTimer = 60;
}
tbTimer--;
if (tbTimer < 10)
{
tbname.setText(tbMTimer.toString() + ":0" + tbTimer.toString());
}
else
{
tbname.setText(tbMTimer.toString() + ":" + tbTimer.toString());
}
}
if(oblueRunning && e.getSource()==clock){
if (obTimer == 0 && obMTimer == 0)
{
oblueRunning = false;
obTimer = 01;
obMTimer = 5;
Toolkit.getDefaultToolkit().beep();
}
if(obTimer == 0)
{
obMTimer--;
obTimer = 60;
}
obTimer--;
if (obTimer < 10)
{
obname.setText(obMTimer.toString() + ":0" + obTimer.toString());
}
else
{
obname.setText(obMTimer.toString() + ":" + obTimer.toString());
}
}
if(twraithsRunning && e.getSource()==clock){
if(twTimer == 0 && twMTimer == 0)
{
twraithsRunning = false;
twTimer = 51;
twMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
twTimer--;
if(twTimer < 10)
{
twname.setText(twMTimer.toString() + ":0" + twTimer.toString());
}
else
{
twname.setText(twMTimer.toString() + ":" + twTimer.toString());
}
}
if(owraithsRunning && e.getSource()==clock){
if(owMTimer == 0 && owTimer == 0)
{
owraithsRunning = false;
owTimer = 51;
owMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
owTimer--;
if (owTimer < 10)
{
owname.setText(owMTimer.toString() + ":0" + owTimer.toString());
}
else
{
owname.setText(owMTimer.toString() + ":" + owTimer.toString());
}
}
if(tgolemsRunning && e.getSource()==clock){
if(tgMTimer== 0 && tgTimer == 0)
{
tgolemsRunning = false;
tgTimer = 1;
tgMTimer = 1;
Toolkit.getDefaultToolkit().beep();
}
if(tgTimer==0)
{
tgMTimer--;
tgTimer = 60;
}
tgTimer--;
if(tgTimer < 10)
{
tgname.setText(tgMTimer.toString() + ":0" + tgTimer.toString());
}
else
{
tgname.setText(tgMTimer.toString() + ":" + tgTimer.toString());
}
}
if(ogolemsRunning && e.getSource()==clock){
if(ogMTimer==0 && ogTimer == 0)
{
ogolemsRunning = false;
ogTimer = 1;
ogMTimer = 1
;
Toolkit.getDefaultToolkit().beep();
}
if(ogTimer == 0)
{
ogMTimer--;
ogTimer = 60;
}
ogTimer--;
if (ogTimer < 10)
{
ogname.setText(ogMTimer.toString() + ":0" + ogTimer.toString());
}
else
{
ogname.setText(ogMTimer.toString() + ":" + ogTimer.toString());
}
}
if(twolvesRunning && e.getSource()==clock){
if(twoMTimer == 0 && twoTimer == 0)
{
twolvesRunning = false;
twoTimer = 51;
twoMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
if (twoTimer == 0)
{
twoMTimer--;
twoTimer = 60;
}
twoTimer--;
if(twoTimer < 10)
{
twoname.setText(twoMTimer.toString() + ":0" + twoTimer.toString());
}
else
{
twoname.setText(twoMTimer.toString() + ":" + twoTimer.toString());
}
}
if(owolvesRunning && e.getSource()==clock){
if(owoTimer == 0 && owoMTimer == 0)
{
owolvesRunning = false;
owoTimer = 51;
owoMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
if(owoTimer == 0)
{
owoMTimer--;
owoTimer = 60;
}
owoTimer--;
if(owoTimer < 10)
{
owoname.setText(owoMTimer.toString() + ":0" + owoTimer.toString());
}
else
{
owoname.setText(owoMTimer.toString() + ":" + owoTimer.toString());
}
}
if(twightRunning && e.getSource()==clock){
if(twiTimer == 0 && twMTimer == 0)
{
twightRunning = false;
twiTimer = 51;
twiMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
twiTimer--;
if(twiTimer < 10)
{
twiname.setText(twiMTimer.toString() + ":0" + twiTimer.toString());
}
else
{
twiname.setText(twiMTimer.toString() + ":" + twiTimer.toString());
}
}
if(owightRunning && e.getSource()==clock){
if(owiMTimer == 0 && owiTimer == 0)
{
owightRunning = false;
owiTimer = 51;
owiMTimer = 0;
Toolkit.getDefaultToolkit().beep();
}
if (owiTimer == 0)
{
owiMTimer--;
owiTimer = 60;
}
owiTimer--;
if(owiTimer < 10)
{
owiname.setText(owiMTimer.toString() + ":0" + owiTimer.toString());
}
else
{
owiname.setText(owiMTimer.toString() + ":" + owiTimer.toString());
}
}
}
// @Override
// public void keyTyped(KeyEvent e) {
// // TODO Auto-generated method stub
// button1 = e;
// if (e.getSource() == button1){
// baronRunning = true;
//
// }
// }
// @Override
// public void keyPressed(KeyEvent e) {
// // TODO Auto-generated method stub
// button1 = e;
// if (e.getSource() == button1){
// baronRunning = true;
//
// }
// }
// @Override
// public void keyReleased(KeyEvent e) {
// // TODO Auto-generated method stub
// button1 = e;
// if (e.getSource() == button1){
// baronRunning = true;
//
// }
}