|
@@ -14,6 +14,8 @@ import java.util.GregorianCalendar;
|
|
|
|
|
|
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JDialog;
|
|
|
|
|
|
|
|
|
|
+import agenda.Agenda;
|
|
|
|
|
+
|
|
|
public class Topbar implements MouseListener {
|
|
public class Topbar implements MouseListener {
|
|
|
private int oldwidth;
|
|
private int oldwidth;
|
|
|
private GeneralPath background;
|
|
private GeneralPath background;
|
|
@@ -22,14 +24,17 @@ public class Topbar implements MouseListener {
|
|
|
private boolean[] buttonsState;
|
|
private boolean[] buttonsState;
|
|
|
private Terrain terrain;
|
|
private Terrain terrain;
|
|
|
private SimulatorPane simulator;
|
|
private SimulatorPane simulator;
|
|
|
|
|
+ private Agenda agenda;
|
|
|
|
|
|
|
|
- public Topbar(Terrain terrain, SimulatorPane simulator){
|
|
|
|
|
|
|
+ public Topbar(Terrain terrain, SimulatorPane simulator, Agenda agenda){
|
|
|
background = new GeneralPath();
|
|
background = new GeneralPath();
|
|
|
time = new GregorianCalendar();
|
|
time = new GregorianCalendar();
|
|
|
|
|
+ time.setTimeInMillis(agenda.firstActTime().getBeginTime().getTimeInMillis()-60*60*1000);
|
|
|
buttons = new Rectangle[5];
|
|
buttons = new Rectangle[5];
|
|
|
buttonsState = new boolean[5];
|
|
buttonsState = new boolean[5];
|
|
|
this.terrain = terrain;
|
|
this.terrain = terrain;
|
|
|
this.simulator = simulator;
|
|
this.simulator = simulator;
|
|
|
|
|
+ this.agenda = agenda;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -60,19 +65,20 @@ public class Topbar implements MouseListener {
|
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarStopButton), screenwidth/4 + 40, 7, null );
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarStopButton), screenwidth/4 + 40, 7, null );
|
|
|
g2.drawImage(Images.getImage((!buttonsState[1]) ? Images.ImageType.TopbarPlayButton : Images.ImageType.TopbarPauzeButton), screenwidth/4 + 90, 7, null );
|
|
g2.drawImage(Images.getImage((!buttonsState[1]) ? Images.ImageType.TopbarPlayButton : Images.ImageType.TopbarPauzeButton), screenwidth/4 + 90, 7, null );
|
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarFasterButton), screenwidth/4 + 130, 7, null );
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarFasterButton), screenwidth/4 + 130, 7, null );
|
|
|
-
|
|
|
|
|
g2.setFont(new Font("Sans-serif", Font.BOLD, 22));
|
|
g2.setFont(new Font("Sans-serif", Font.BOLD, 22));
|
|
|
g2.drawString(time.get(Calendar.HOUR_OF_DAY) + ":" + getMins(), screenwidth/2-10 , 28);
|
|
g2.drawString(time.get(Calendar.HOUR_OF_DAY) + ":" + getMins(), screenwidth/2-10 , 28);
|
|
|
-
|
|
|
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarGridButton), screenwidth/4*3 -60, 7, null );
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarGridButton), screenwidth/4*3 -60, 7, null );
|
|
|
-
|
|
|
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarPeopleButton), screenwidth/4*3 -150, 7, null );
|
|
g2.drawImage(Images.getImage(Images.ImageType.TopbarPeopleButton), screenwidth/4*3 -150, 7, null );
|
|
|
g2.setFont(new Font("Sans-serif", Font.PLAIN, 18));
|
|
g2.setFont(new Font("Sans-serif", Font.PLAIN, 18));
|
|
|
g2.drawString(terrain.getMaxVisitors() + "", screenwidth/4*3 - 120, 27);
|
|
g2.drawString(terrain.getMaxVisitors() + "", screenwidth/4*3 - 120, 27);
|
|
|
}
|
|
}
|
|
|
- public void setTime(GregorianCalendar t){
|
|
|
|
|
- time = t;
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public GregorianCalendar getTime() {
|
|
|
|
|
+ return time;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public Rectangle[] getButtons(){
|
|
public Rectangle[] getButtons(){
|
|
|
return buttons;
|
|
return buttons;
|
|
|
}
|
|
}
|
|
@@ -95,7 +101,7 @@ public class Topbar implements MouseListener {
|
|
|
terrain.toggleGrid();
|
|
terrain.toggleGrid();
|
|
|
}else if(button == 0){
|
|
}else if(button == 0){
|
|
|
simulator.changeSpeed(SimulatorPane.Time.STOP);
|
|
simulator.changeSpeed(SimulatorPane.Time.STOP);
|
|
|
- time.setTimeInMillis(System.currentTimeMillis());
|
|
|
|
|
|
|
+ time.setTimeInMillis(agenda.firstActTime().getBeginTime().getTimeInMillis()-60*60*1000);
|
|
|
buttonsState[1] = false;
|
|
buttonsState[1] = false;
|
|
|
}else if(button == 1) {
|
|
}else if(button == 1) {
|
|
|
simulator.changeSpeed((!buttonsState[1] ? SimulatorPane.Time.PLAY : SimulatorPane.Time.PAUZE));
|
|
simulator.changeSpeed((!buttonsState[1] ? SimulatorPane.Time.PLAY : SimulatorPane.Time.PAUZE));
|
|
@@ -141,4 +147,4 @@ public class Topbar implements MouseListener {
|
|
|
public void recalculate(){
|
|
public void recalculate(){
|
|
|
time.setTimeInMillis(time.getTimeInMillis()+10000);
|
|
time.setTimeInMillis(time.getTimeInMillis()+10000);
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|