Ignore:
Timestamp:
06/23/2016 06:30:20 PM (10 years ago)
Author:
jdalbey
Message:

MultiFile? commit: Add CADViewer Interface and change CADSimulator to Observer Pattern.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/cadsimulator/viewer/DVDInfoPanel.java

    r2 r44  
    22 
    33import java.awt.Dimension; 
    4  
    54import javax.swing.BorderFactory; 
    65import javax.swing.Box; 
     
    109import javax.swing.JTable; 
    1110import javax.swing.JTextField; 
    12  
    1311import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 
    1412import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; 
     
    1715 
    1816/** 
    19  * DVDInfoPanel is a GUI component used in the CADSimulatorViewer.  The panel 
    20  * displays information regarding the DVD player's connection information. 
    21  * One table on the panel shows all DVD title that have been played or  
    22  * repeated.  A second table shows all DVD status updates that have been 
    23  * received from the controller.  
    24  *  
     17 * DVDInfoPanel is a GUI component used in the CADSimulatorViewer. The panel 
     18 * displays information regarding the DVD player's connection information. One 
     19 * table on the panel shows all DVD title that have been played or repeated. A 
     20 * second table shows all DVD status updates that have been received from the 
     21 * controller. 
     22 * 
    2523 * @author Matthew Cechini 
    26  * @version  
     24 * @version 
    2725 */ 
    2826@SuppressWarnings("serial") 
    29 public class DVDInfoPanel extends JPanel { 
     27public class DVDInfoPanel extends JPanel 
     28{ 
    3029 
    31     /** DVD player connection info. */ 
    32     private String connInfo = null; 
    33      
    34     /** Table model for the title table. */ 
     30    /** 
     31     * DVD player connection info. 
     32     */ 
     33    public final String connInfo; 
     34    /** 
     35     * Table model for the title table. 
     36     */ 
    3537    private DVDTitleTableModel titleTableModel; 
     38    /** 
     39     * Table to display DVD title plays and repeats. 
     40     */ 
     41    private JTable titleTable; 
     42    /** 
     43     * Table model for the Status table. 
     44     */ 
     45    private DVDStatusTableModel statusTableModel; 
     46    /** 
     47     * Table to display DVD status updates. 
     48     */ 
     49    private JTable statusTable; 
    3650 
    37     /** Table to display DVD title plays and repeats. */ 
    38     private JTable titleTable; 
    39      
    40     /** Table model for the Status table. */ 
    41     private DVDStatusTableModel statusTableModel; 
    42      
    43     /** Table to display DVD status updates. */ 
    44     private JTable statusTable; 
    45      
    46      
    4751    /** 
    48      * Constructor.  Initialize the panel GUI components. 
    49      *  
     52     * Constructor. Initialize the panel GUI components. 
     53     * 
    5054     * @param connectionInfo DVD player connection info. 
    5155     */ 
    52     public DVDInfoPanel(String connectionInfo) { 
     56    public DVDInfoPanel(String connectionInfo) 
     57    { 
    5358        connInfo = connectionInfo; 
    54          
     59 
    5560        initComponents(); 
    56     }    
    57      
     61    } 
     62 
    5863    /** 
    5964     * This method updates the DVD status table with the new update object. 
     65     * 
    6066     * @param update Update DVD Status update. 
    6167     */ 
    62     public void updateDVDStatus(DVDStatusUpdate update) { 
     68    public void updateDVDStatus(DVDStatusUpdate update) 
     69    { 
    6370        statusTableModel.addStatusUpdate(update); 
    6471    } 
     
    6673    /** 
    6774     * This method updates the DVD title table with the new update object. 
     75     * 
    6876     * @param update Update DVD Status update. 
    6977     */ 
    70     public void updateDVDTitle(DVDTitleUpdate update) { 
     78    public void updateDVDTitle(DVDTitleUpdate update) 
     79    { 
    7180        titleTableModel.addTitleUpdate(update); 
    7281    } 
    73      
     82 
    7483    /** 
    7584     * Initialize the GUI components. 
    7685     */ 
    77     private void initComponents() { 
     86    private void initComponents() 
     87    { 
    7888 
    7989        connInfoLbl = new JLabel("Connection Info:"); 
    8090        connInfoLbl.setAlignmentX(Box.LEFT_ALIGNMENT); 
    81         connInfoTF  = new JTextField(connInfo); 
     91        connInfoTF = new JTextField(connInfo); 
    8292        connInfoTF.setColumns(30); 
    8393        connInfoTF.setAlignmentX(Box.LEFT_ALIGNMENT); 
    8494        connInfoTF.setEditable(false); 
    85          
     95 
    8696        Box connInfoBox = Box.createVerticalBox(); 
    8797        connInfoBox.add(connInfoLbl); 
    8898        connInfoBox.add(connInfoTF); 
    8999        connInfoBox.setAlignmentX(Box.CENTER_ALIGNMENT); 
    90          
     100 
    91101        titleTableModel = new DVDTitleTableModel(); 
    92         titleTable      = new JTable(titleTableModel); 
    93         titleTable.getTableHeader().setReorderingAllowed(false);   
    94          
    95         for(int c = 0; c < titleTable.getColumnCount(); c++) { 
     102        titleTable = new JTable(titleTableModel); 
     103        titleTable.getTableHeader().setReorderingAllowed(false); 
     104 
     105        for (int c = 0; c < titleTable.getColumnCount(); c++) 
     106        { 
    96107            titleTable.getColumnModel().getColumn(c).setMinWidth( 
    97108                    titleTableModel.getColumnMinWidth(c)); 
     
    102113            titleTable.getColumnModel().getColumn(c).setResizable(true); 
    103114        } 
    104          
    105         titlePane       = new JScrollPane(); 
     115 
     116        titlePane = new JScrollPane(); 
    106117        titlePane.setAlignmentX(Box.CENTER_ALIGNMENT); 
    107118        //titlePane.setMinimumSize(new Dimension(,)); 
    108         titlePane.setPreferredSize(new Dimension(425, 225));         
     119        titlePane.setPreferredSize(new Dimension(425, 225)); 
    109120        titlePane.setViewportView(titleTable); 
    110121        titlePane.setBorder(BorderFactory.createTitledBorder( 
    111                     BorderFactory.createRaisedBevelBorder(), "Title Updates")); 
     122                BorderFactory.createRaisedBevelBorder(), "Title Updates")); 
    112123 
    113124        statusTableModel = new DVDStatusTableModel(); 
    114         statusTable      = new JTable(statusTableModel); 
    115         statusTable.getTableHeader().setReorderingAllowed(false);   
    116          
    117         for(int c = 0; c < statusTable.getColumnCount(); c++) { 
     125        statusTable = new JTable(statusTableModel); 
     126        statusTable.getTableHeader().setReorderingAllowed(false); 
     127 
     128        for (int c = 0; c < statusTable.getColumnCount(); c++) 
     129        { 
    118130            statusTable.getColumnModel().getColumn(c).setMinWidth( 
    119131                    statusTableModel.getColumnMinWidth(c)); 
     
    124136            statusTable.getColumnModel().getColumn(c).setResizable(true); 
    125137        } 
    126          
    127         statusPane       = new JScrollPane(); 
     138 
     139        statusPane = new JScrollPane(); 
    128140        statusPane.setAlignmentX(Box.CENTER_ALIGNMENT); 
    129141        //statusPane.setMinimumSize(new Dimension(,)); 
    130         statusPane.setPreferredSize(new Dimension(425, 150));        
     142        statusPane.setPreferredSize(new Dimension(425, 150)); 
    131143        statusPane.setViewportView(statusTable); 
    132144        statusPane.setBorder(BorderFactory.createTitledBorder( 
    133145                BorderFactory.createRaisedBevelBorder(), "Status Updates")); 
    134          
     146 
    135147        Box panelBox = Box.createVerticalBox(); 
    136148        panelBox.add(connInfoBox); 
     
    139151        panelBox.add(Box.createVerticalStrut(10)); 
    140152        panelBox.add(statusPane); 
    141         panelBox.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
    142          
     153        panelBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 
     154 
    143155        add(panelBox); 
    144156    } 
    145      
    146157    private JScrollPane titlePane; 
    147158    private JScrollPane statusPane; 
    148      
    149159    private JLabel connInfoLbl; 
    150      
    151160    private JTextField connInfoTF; 
    152161} 
Note: See TracChangeset for help on using the changeset viewer.