/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jgrow;
import java.awt.Label;
import java.awt.GridLayout;
import java.awt.Color;
import javax.swing.JPanel;
/**
*
* @author maryam
*/
public class PanelInformation extends JPanel {
public Label population, time, cycle, rate;
InfoTiles tiles;
InfoBonds bonds;
public PanelInformation(InfoTiles ts, InfoBonds bs) {
tiles = ts;
bonds = bs;
setForeground(Color.black);
setLayout(new GridLayout(2,2));
population = new Label("population: 0");
add(population);
time = new Label("time: 0.0 sec");
add(time);
cycle = new Label("cycles: 0");
add(cycle);
rate = new Label("rate: 0");
add(rate);
}
public void setStats(int n_population, double n_time, int n_cycle, double n_rate) {
population.setText(String.format("population: %,d" , n_population));
int seconds = (int) (n_time % 60);
int minutes = (int) ((n_time / 60) % 60);
int hours = (int) ((n_time / 60 / 60) % 24);
int days = (int) (n_time / 60 / 60 / 24);
time.setText(String.format("%d days, %02d hrs, %02d min, %02d sec", days, hours, minutes, seconds));
cycle.setText(String.format("cycles: %,d", n_cycle));
rate.setText("rate (per 1 ms): " + n_rate);
}
}
# |
Change |
User |
Description |
Committed |
|
#2
|
7857 |
renat_bekbolatov |
sync |
|
|
#1
|
7851 |
renat_bekbolatov |
new files |
|
|