Changeset 61 in tmcsimulator for trunk/src/tmcsim/client/CADClockView.java


Ignore:
Timestamp:
03/15/2017 02:25:16 PM (9 years ago)
Author:
jdalbey
Message:

CADClock development.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/CADClockView.java

    r58 r61  
    11package tmcsim.client; 
    22 
    3 import java.awt.BorderLayout; 
    43import java.awt.Color; 
    54import java.awt.Dimension; 
     
    98import java.util.Observable; 
    109import java.util.Observer; 
    11 import java.util.TreeMap; 
    12 import java.util.logging.Level; 
    1310import java.util.logging.Logger; 
    1411 
     
    2017import javax.swing.JOptionPane; 
    2118import javax.swing.JPanel; 
    22 import javax.swing.JTextPane; 
    2319import 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; 
    4220import tmcsim.common.ObserverMessage; 
    43 import tmcsim.common.CADEnums.ARROW; 
    4421import 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;         
     22import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 
    4923 
    5024/** 
    5125 * The CADClientView class is the view component to the CAD Client application. 
    5226 * 
    53  * This view class observers the CADClientModel, listening for updates 
    54  * from the CAD Simulator.  Updates includes the current  
    55  * CAD time  */ 
     27 * This view class observers the CADClientModel, listening for updates from the 
     28 * CAD Simulator. Updates includes the current CAD time 
     29 */ 
    5630@SuppressWarnings("serial") 
    57 public class CADClockView extends JFrame implements KeyListener, Observer { 
    58      
    59     /** Error Logger. */ 
     31public class CADClockView extends JFrame 
     32{ 
     33 
     34    /** 
     35     * Error Logger. 
     36     */ 
    6037    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; 
    6738    private JPanel mainPane; 
    6839    private JLabel currentTime; 
    69      
     40 
    7041    /** 
    7142     * Constructor. Build panes, add key listeners, and set up observer 
    7243     * 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. 
    7646     */ 
    77     public CADClockView(CADClientModel mod) { 
     47    public CADClockView() 
     48    { 
    7849        super("CAD Client"); 
    7950        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
    80         theModel = mod; 
    8151        currentTime = new JLabel("0:00:00"); 
    8252        CADSimulatorStatus status = new CADSimulatorStatus(); 
     
    8454        currentTime.setText(simtime); 
    8555        currentTime.setAlignmentX(Box.CENTER_ALIGNMENT); 
    86         currentTime.setFont(new Font("Geneva", Font.BOLD, 70));         
     56        currentTime.setFont(new Font("Geneva", Font.BOLD, 70)); 
    8757        mainPane = new JPanel(); 
    8858        setSize(new Dimension(730, 455)); 
     
    9060        setMinimumSize(new Dimension(730, 455)); 
    9161        mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); 
    92         mainPane.setBorder(BorderFactory.createLineBorder(Color.black));    
     62        mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); 
    9363        mainPane.setBackground(Color.LIGHT_GRAY); 
    9464        mainPane.add(currentTime); 
    95         add(mainPane);  
     65        add(mainPane); 
    9666        pack(); 
    9767    } 
    9868 
    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); 
    14272    } 
    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.