public void actionPerformed(ActionEvent e) { // dump ActionEvent information Object src = e.getSource(); String msg = e.getActionCommand(); if (src == start_stop) { // tell all threads to continue/resume operation for (ProcessSimulator ps : species) if (ps.toggleRunning()) synchronized (ps) { ps.notify(); } System.out.println("Started/Stopped Simulator..."); } else if (src == reset) { for (ProcessSimulator ps : species) { if (!ps.isRunning()) { ps.reset(); synchronized (ps) { ps.notify(); } } } // clear the Elite Agent data cur_elite_genome.setText(""); cur_elite_total.setText(""); System.out.println("Simulation Reset..."); } else if (src == reconfigure) { // create a new environment with the new parameters Environment environment = new Environment(); // override existing values environment.setHQSale(Integer.parseInt(high_sale.getText())); environment.setHQRate(Integer.parseInt(high_rate.getText())); environment.setMQRate(Integer.parseInt(med_rate.getText())); environment.setMQSale(Integer.parseInt(med_sale.getText())); environment.setLQRate(Integer.parseInt(low_rate.getText())); environment.setLQSale(Integer.parseInt(low_sale.getText())); environment.setIncomeRatioThreshold(Double.parseDouble(agent_performance.getText())); for (ProcessSimulator ps : species) { if (!ps.isRunning()) { ps.replaceEnvironment(environment); // replace simulation values ps.setAgentCount(Integer.parseInt(agent_count.getText())); ps.setDayCount(Integer.parseInt(day_count.getText())); ps.setElitePercent(Double.parseDouble(elite_percent.getText())); ps.setGenerationCount(Integer.parseInt(generation_count.getText())); ps.setParentPercent(Double.parseDouble(parent_percent.getText())); } } System.out.println("Species Reconfigured..."); } else if (msg == "elite_total") { // one of the threads has a new elite // TODO: Later, we are going to want to differentiate between the // TODO: different threads current_elite = ((ProcessSimulator) src).getCurrentElite(); // update our GUI cur_elite_total.setText("$" + current_elite.getMoney()); cur_elite_genome.setText(current_elite.toString()); } }