-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElevatorFrame.java
77 lines (61 loc) · 2.04 KB
/
ElevatorFrame.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package elevator_gui;
import java.util.HashMap;
import elevator_gui.ElevatorDisplay.Direction;
/**
*
* @author hieldc
*/
public class ElevatorFrame extends javax.swing.JFrame {
private final HashMap<Integer, ElevatorPanel> elevatorPanels = new HashMap<>();
private final int maxFloors;
public ElevatorFrame(int max) {
initComponents();
maxFloors = max;
setTitle("Elevator Display");
}
public void addElevator(int id, int initValue) {
ElevatorPanel ep = new ElevatorPanel(id);
ep.setMax(maxFloors);
ep.setFloor(initValue);
this.getContentPane().add(ep);
elevatorPanels.put(id, ep);
pack();
setVisible(true);
}
public ElevatorPanel getPanel(int i) {
return elevatorPanels.get(i);
}
public void setDirection(int elev, Direction dir) {
getPanel(elev).setDirection(dir);
}
public void setFloor(int elev, int value) {
getPanel(elev).setFloor(value);
}
public void setNumRiders(int elev, int value) {
getPanel(elev).setNumRiders(value);
}
public void openDoors(int id) {
getPanel(id).openDoors();
}
public void closeDoors(int id) {
getPanel(id).closeDoors();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.FlowLayout());
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}