M Winda/src/winda/animation/ElevatorMovement.java Ustawiono prędkość zjeżdżania windy
M Winda/src/winda/gui/WindaView.java Poprawiono ustawianie trasy dla animacji
This commit is contained in:
parent
cc007d41d4
commit
e3e2d4d75e
2 changed files with 31 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
||||||
package winda.animation;
|
package winda.animation;
|
||||||
|
|
||||||
import java.awt.ScrollPane;
|
import java.awt.ScrollPane;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import winda.gui.WindaApp;
|
import winda.gui.WindaApp;
|
||||||
|
@ -21,11 +22,14 @@ public class ElevatorMovement extends Thread{
|
||||||
private double speed;
|
private double speed;
|
||||||
private int enter_exit_time;
|
private int enter_exit_time;
|
||||||
|
|
||||||
private Pietro pietro;
|
private ArrayList<Pietro> pietro;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
this.goToFloor(this.pietro);
|
for(int i=0;i<this.pietro.size();i++){
|
||||||
|
this.goToFloor(this.pietro.get(i));
|
||||||
|
System.out.println("goto:"+this.pietro.get(i).numerPietra+" in:"+this.pietro.get(i).pasazerowieWsiadający.size()+" out:"+this.pietro.get(i).pasazerowieWysiadajacy.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElevatorMovement(int floor_count){
|
public ElevatorMovement(int floor_count){
|
||||||
|
@ -45,12 +49,11 @@ public class ElevatorMovement extends Thread{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goUp(int number){
|
private void goUp(int number){
|
||||||
System.out.println(""+(this.jump_time*this.speed));
|
|
||||||
while(this.ea.shift>(this.floor_size*(this.floor_count-(number+1)))){
|
while(this.ea.shift>(this.floor_size*(this.floor_count-(number+1)))){
|
||||||
try {
|
try {
|
||||||
this.ea.shift--;
|
this.ea.shift--;
|
||||||
this.ea.repaint();
|
this.ea.repaint();
|
||||||
Thread.sleep((long) (this.jump_time*this.speed));
|
this.sleep((long) (this.jump_time*this.speed));
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +65,7 @@ public class ElevatorMovement extends Thread{
|
||||||
try {
|
try {
|
||||||
this.ea.shift++;
|
this.ea.shift++;
|
||||||
this.ea.repaint();
|
this.ea.repaint();
|
||||||
Thread.sleep((long) (this.jump_time));
|
this.sleep((long) (this.jump_time*this.speed));
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
@ -70,25 +73,34 @@ public class ElevatorMovement extends Thread{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitElevator(int number){
|
private void exitElevator(int number){
|
||||||
|
if(number<=0)
|
||||||
|
return;
|
||||||
|
System.out.println("exitElevator("+number+") elevator_passangers "+this.ea.elevator_passangers);
|
||||||
for(int i=0;i<number;i++){
|
for(int i=0;i<number;i++){
|
||||||
try {
|
try {
|
||||||
Thread.sleep((long) (this.enter_exit_time*this.speed));
|
this.ea.elevator_passangers--;
|
||||||
|
this.ea.repaint();
|
||||||
|
this.sleep((long) (this.enter_exit_time*this.speed));
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
this.ea.elevator_passangers--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterElevator(int number, int floor){
|
private void enterElevator(int number, int floor){
|
||||||
|
if(number<=0)
|
||||||
|
return;
|
||||||
|
System.out.println("enterElevator("+number+") elevator_passangers "+this.ea.elevator_passangers);
|
||||||
|
System.out.println("enterElevator("+number+") floor_passangers["+floor+"] "+this.ea.floor_passangers[floor]);
|
||||||
for(int i=0;i<number;i++){
|
for(int i=0;i<number;i++){
|
||||||
try {
|
try {
|
||||||
Thread.sleep((long) (this.enter_exit_time*this.speed));
|
this.ea.elevator_passangers++;
|
||||||
|
this.ea.floor_passangers[floor]--;
|
||||||
|
this.ea.repaint();
|
||||||
|
this.sleep((long) (this.enter_exit_time*this.speed));
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ElevatorMovement.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
this.ea.elevator_passangers++;
|
|
||||||
this.ea.floor_passangers[floor]--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +121,7 @@ public class ElevatorMovement extends Thread{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassangersInElevator(int passangers){
|
public void setPassangersInElevator(int passangers){
|
||||||
|
System.out.println("setPassangersInElevator("+passangers+")");
|
||||||
this.ea.elevator_passangers = passangers;
|
this.ea.elevator_passangers = passangers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +170,7 @@ public class ElevatorMovement extends Thread{
|
||||||
this.speed = 1;
|
this.speed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPietro(Pietro pietro){
|
public void setPietro(ArrayList pietro){
|
||||||
this.pietro = pietro;
|
this.pietro = pietro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package winda.gui;
|
package winda.gui;
|
||||||
|
|
||||||
import java.awt.ScrollPane;
|
import java.awt.ScrollPane;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.jdesktop.application.Action;
|
import org.jdesktop.application.Action;
|
||||||
|
@ -110,11 +111,15 @@ public class WindaView extends FrameView{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToPieto(){
|
private void goToPieto(){
|
||||||
for(int i=0;i<this.w.GetTrasa().size();i++){
|
this.em.setPietro((ArrayList) this.w.GetTrasa());
|
||||||
|
this.em.setEnterExitTime(czasWeWy);
|
||||||
|
Thread t = new Thread(em);
|
||||||
|
t.start();
|
||||||
|
/*for(int i=0;i<this.w.GetTrasa().size();i++){
|
||||||
this.em.setPietro(this.w.GetTrasa().get(i));
|
this.em.setPietro(this.w.GetTrasa().get(i));
|
||||||
Thread t = new Thread(em);
|
Thread t = new Thread(em);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawAnimation(){
|
private void drawAnimation(){
|
||||||
|
|
Loading…
Reference in a new issue