| 1 | package tmcsim.client; |
|---|
| 2 | |
|---|
| 3 | import java.awt.Color; |
|---|
| 4 | import java.awt.Dimension; |
|---|
| 5 | import java.awt.Font; |
|---|
| 6 | import java.awt.event.KeyEvent; |
|---|
| 7 | import java.awt.event.KeyListener; |
|---|
| 8 | import java.util.Observable; |
|---|
| 9 | import java.util.Observer; |
|---|
| 10 | import java.util.logging.Logger; |
|---|
| 11 | |
|---|
| 12 | import javax.swing.BorderFactory; |
|---|
| 13 | import javax.swing.Box; |
|---|
| 14 | import javax.swing.BoxLayout; |
|---|
| 15 | import javax.swing.JFrame; |
|---|
| 16 | import javax.swing.JLabel; |
|---|
| 17 | import javax.swing.JOptionPane; |
|---|
| 18 | import javax.swing.JPanel; |
|---|
| 19 | import javax.swing.WindowConstants; |
|---|
| 20 | import tmcsim.common.ObserverMessage; |
|---|
| 21 | import tmcsim.common.CADEnums.CADScreenNum; |
|---|
| 22 | import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * The CADClientView class is the view component to the CAD Client application. |
|---|
| 26 | * |
|---|
| 27 | * This view class observers the CADClientModel, listening for updates from the |
|---|
| 28 | * CAD Simulator. Updates includes the current CAD time |
|---|
| 29 | */ |
|---|
| 30 | @SuppressWarnings("serial") |
|---|
| 31 | public class CADClockView extends JFrame |
|---|
| 32 | { |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * Error Logger. |
|---|
| 36 | */ |
|---|
| 37 | private static Logger cadLogger = Logger.getLogger("tmcsim.client"); |
|---|
| 38 | private JPanel mainPane; |
|---|
| 39 | private JLabel currentTime; |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | * Constructor. Build panes, add key listeners, and set up observer |
|---|
| 43 | * relationship between the footer and main panes. |
|---|
| 44 | * |
|---|
| 45 | * @param position The CAD position for this client terminal. |
|---|
| 46 | */ |
|---|
| 47 | public CADClockView() |
|---|
| 48 | { |
|---|
| 49 | super("CAD Client"); |
|---|
| 50 | this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|---|
| 51 | currentTime = new JLabel("0:00:00"); |
|---|
| 52 | CADSimulatorStatus status = new CADSimulatorStatus(); |
|---|
| 53 | String simtime = status.getCurrentTime(); |
|---|
| 54 | currentTime.setText(simtime); |
|---|
| 55 | currentTime.setAlignmentX(Box.CENTER_ALIGNMENT); |
|---|
| 56 | currentTime.setFont(new Font("Geneva", Font.BOLD, 70)); |
|---|
| 57 | mainPane = new JPanel(); |
|---|
| 58 | setSize(new Dimension(730, 455)); |
|---|
| 59 | setMaximumSize(new Dimension(730, 455)); |
|---|
| 60 | setMinimumSize(new Dimension(730, 455)); |
|---|
| 61 | mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
|---|
| 62 | mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); |
|---|
| 63 | mainPane.setBackground(Color.LIGHT_GRAY); |
|---|
| 64 | mainPane.add(currentTime); |
|---|
| 65 | add(mainPane); |
|---|
| 66 | pack(); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | public void updateTime(String msg) |
|---|
| 70 | { |
|---|
| 71 | currentTime.setText(msg); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|