Changeset 61 in tmcsimulator for trunk/src/tmcsim/client/CADClockView.java
- Timestamp:
- 03/15/2017 02:25:16 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/client/CADClockView.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/CADClockView.java
r58 r61 1 1 package tmcsim.client; 2 2 3 import java.awt.BorderLayout;4 3 import java.awt.Color; 5 4 import java.awt.Dimension; … … 9 8 import java.util.Observable; 10 9 import java.util.Observer; 11 import java.util.TreeMap;12 import java.util.logging.Level;13 10 import java.util.logging.Logger; 14 11 … … 20 17 import javax.swing.JOptionPane; 21 18 import javax.swing.JPanel; 22 import javax.swing.JTextPane;23 19 import javax.swing.WindowConstants; 24 import javax.xml.parsers.DocumentBuilderFactory;25 26 import org.w3c.dom.Document;27 import org.w3c.dom.Element;28 29 import tmcsim.cadmodels.BlankScreenModel;30 import tmcsim.cadmodels.CADScreenModel;31 import tmcsim.cadmodels.IncidentBoardModel;32 import tmcsim.cadmodels.IncidentInquiryModel;33 import tmcsim.cadmodels.IncidentSummaryModel;34 import tmcsim.cadmodels.RoutedMessageModel;35 import tmcsim.client.cadscreens.IB_IncidentBoard;36 import tmcsim.client.cadscreens.II_IncidentInquiry;37 import tmcsim.client.cadscreens.SA_IncidentSummary;38 import tmcsim.client.cadscreens.TO_RoutedMessage;39 import tmcsim.client.cadscreens.view.CADCommandLineView;40 import tmcsim.client.cadscreens.view.CADFooterView;41 import tmcsim.client.cadscreens.view.CADMainView;42 20 import tmcsim.common.ObserverMessage; 43 import tmcsim.common.CADEnums.ARROW;44 21 import tmcsim.common.CADEnums.CADScreenNum; 45 import tmcsim.common.CADEnums.CAD_ERROR; 46 import tmcsim.common.CADEnums.CAD_KEYS; 47 import tmcsim.common.CADProtocol.CAD_CLIENT_CMD; 48 import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 22 import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 49 23 50 24 /** 51 25 * The CADClientView class is the view component to the CAD Client application. 52 26 * 53 * This view class observers the CADClientModel, listening for updates 54 * from the CAD Simulator. Updates includes the current55 * CAD time */27 * This view class observers the CADClientModel, listening for updates from the 28 * CAD Simulator. Updates includes the current CAD time 29 */ 56 30 @SuppressWarnings("serial") 57 public class CADClockView extends JFrame implements KeyListener, Observer { 58 59 /** Error Logger. */ 31 public class CADClockView extends JFrame 32 { 33 34 /** 35 * Error Logger. 36 */ 60 37 private static Logger cadLogger = Logger.getLogger("tmcsim.client"); 61 62 /** Reference to the CADClient model object. */63 private CADClientModel theModel = null;64 65 /** Current CAD Screen number. */66 private CADScreenNum currentScreenNum = null;67 38 private JPanel mainPane; 68 39 private JLabel currentTime; 69 40 70 41 /** 71 42 * Constructor. Build panes, add key listeners, and set up observer 72 43 * relationship between the footer and main panes. 73 * 74 * @param position 75 * The CAD position for this client terminal. 44 * 45 * @param position The CAD position for this client terminal. 76 46 */ 77 public CADClockView(CADClientModel mod) { 47 public CADClockView() 48 { 78 49 super("CAD Client"); 79 50 this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 80 theModel = mod;81 51 currentTime = new JLabel("0:00:00"); 82 52 CADSimulatorStatus status = new CADSimulatorStatus(); … … 84 54 currentTime.setText(simtime); 85 55 currentTime.setAlignmentX(Box.CENTER_ALIGNMENT); 86 currentTime.setFont(new Font("Geneva", Font.BOLD, 70)); 56 currentTime.setFont(new Font("Geneva", Font.BOLD, 70)); 87 57 mainPane = new JPanel(); 88 58 setSize(new Dimension(730, 455)); … … 90 60 setMinimumSize(new Dimension(730, 455)); 91 61 mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); 92 mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); 62 mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); 93 63 mainPane.setBackground(Color.LIGHT_GRAY); 94 64 mainPane.add(currentTime); 95 add(mainPane); 65 add(mainPane); 96 66 pack(); 97 67 } 98 68 99 /** 100 * Observable update method. The CADClientView class is an observer of the 101 * CADClientModel. If the model sends a null object, it is signifying that 102 * it has shut down. In this case, an error message should be shown to prompt 103 * the user to restart the CAD Client. If the update object is an 104 * ObserverMessage object, the following actions are to be taken: 105 * 106 *<table cellpadding="2" cellspacing="2" border="1" 107 * style="text-align: left; width: 250px;"> 108 * <tbody> 109 * <tr> 110 * <th>Message Type</th> 111 * <th>Message Data</th> 112 * <th>Action Taken</th> 113 * </tr> 114 * <tr> 115 * <td>TIME_UPDATE<br></td> 116 * <td>Time String<br></td> 117 * <td>Update the footer pane with the new time.</td> 118 * </tr> 119 * </tbody> 120 *</table> 121 */ 122 public void update(Observable o, Object arg) { 123 124 125 if(arg == null) 126 { 127 JOptionPane.showMessageDialog(this, 128 "Connection to the CAD Simulator has been lost. " + 129 "Restart the CAD Client.", "Connection Error", 130 JOptionPane.ERROR_MESSAGE); 131 return; 132 } 133 134 ObserverMessage oMessage = (ObserverMessage)arg; 135 136 switch(oMessage.type) { 137 // Time updates occur once a minute 138 case TIME_UPDATE: 139 currentTime.setText("" + (String)oMessage.value); 140 break; 141 } 69 public void updateTime(String msg) 70 { 71 currentTime.setText(msg); 142 72 } 143 144 @Override 145 public void keyTyped(KeyEvent e) 146 { 147 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 148 } 149 150 @Override 151 public void keyPressed(KeyEvent e) 152 { 153 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 154 } 155 156 @Override 157 public void keyReleased(KeyEvent e) 158 { 159 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 160 } 161 162 163 164 } 73 }
Note: See TracChangeset
for help on using the changeset viewer.
