Changeset 44 in tmcsimulator for trunk/src/tmcsim/cadsimulator/viewer/MediaStatusPanel.java
- Timestamp:
- 06/23/2016 06:30:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/viewer/MediaStatusPanel.java
r2 r44 1 1 package tmcsim.cadsimulator.viewer; 2 2 3 import java.util.Iterator; 4 import java.util.Observable; 3 5 import java.util.TreeMap; 4 5 6 import javax.swing.JPanel; 6 7 import javax.swing.JTabbedPane; 7 8 8 import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 9 9 import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; 10 import tmcsim.cadsimulator.viewer.model.CADMediaStatus; 10 11 11 12 /** 12 * MediaStatusPanel is a GUI object used for displaying information 13 * for DVD connections created by the CAD Simulator. Tabs for each 14 * DVD are created and information is displayed on a DVDInfoPanel. 15 * All status and title updates are sent to the corresponding 16 * DVDInfoPanel. The DVDs are referenced by connection info, which 17 * is unique to each DVD player. 18 * 19 * @author Matthew Cechini 20 * @version 13 * MediaStatusPanel is a GUI object used for displaying information for DVD 14 * connections created by the CAD Simulator. Tabs for each DVD are created and 15 * information is displayed on a DVDInfoPanel. All status and title updates are 16 * sent to the corresponding DVDInfoPanel. The DVDs are referenced by connection 17 * info, which is unique to each DVD player. 18 * 19 * @author jdalbey 21 20 */ 22 21 @SuppressWarnings("serial") 23 public class MediaStatusPanel extends JPanel { 24 25 /** Map of DVDInfoPanels(values) referenced by a DVD's connection info(key). */ 22 public class MediaStatusPanel extends JPanel 23 { 24 25 /** 26 * Map of DVDInfoPanels(values) referenced by a DVD's connection info(key). 27 */ 26 28 private TreeMap<String, DVDInfoPanel> dvdPanels = null; 27 29 28 30 /** 29 * Constructor. Initialize data and GUI components.31 * Constructor. Initialize data and GUI components. 30 32 */ 31 public MediaStatusPanel() { 33 public MediaStatusPanel() 34 { 32 35 33 dvdPanels = new TreeMap<String, DVDInfoPanel>();34 36 dvdPanels = new TreeMap<String, DVDInfoPanel>(); 37 35 38 initComponents(); 36 39 } 37 40 41 public void refresh(Observable obs) 42 { 43 CADMediaStatus status = (CADMediaStatus) obs; 44 Iterator<DVDInfoPanel> iter = status.getDVDlist(); 45 // Remove existing tabs before adding them all back 46 mediaTabs.removeAll(); 47 // add a new tab for each dvd panel 48 while (iter.hasNext()) 49 { 50 DVDInfoPanel item = iter.next(); 51 mediaTabs.addTab( 52 "DVD " + (Integer.parseInt(item.connInfo 53 .substring(item.connInfo 54 .indexOf(":") + 1)) % 3000), 55 dvdPanels.get(item.connInfo)); 56 } 57 // mediaTabs.addTab( 58 // "DVD " + (Integer.parseInt(update.connectionInfo 59 // .substring(update.connectionInfo 60 // .indexOf(":") + 1)) % 3000), 61 // dvdPanels.get(update.connectionInfo)); 62 63 } 64 38 65 /** 39 * Updates the current DVDInfoPanel with the status update. 40 * If a panel does not current exist, create one and add 41 * a new tab. 42 * 66 * Updates the current DVDInfoPanel with the status update. If a panel does 67 * not current exist, create one and add a new tab. 68 * 43 69 * @param update DVD status update. 44 70 */ 45 public void updateDVDStatus(DVDStatusUpdate update) { 46 if(dvdPanels.get(update.connectionInfo) == null) { 71 public void updateDVDStatus(DVDStatusUpdate update) 72 { 73 if (dvdPanels.get(update.connectionInfo) == null) 74 { 47 75 dvdPanels.put(update.connectionInfo, new DVDInfoPanel( 48 76 update.connectionInfo)); … … 50 78 mediaTabs.addTab( 51 79 "DVD " + (Integer.parseInt(update.connectionInfo 52 .substring(update.connectionInfo53 .indexOf(":")+1)) % 3000),80 .substring(update.connectionInfo 81 .indexOf(":") + 1)) % 3000), 54 82 dvdPanels.get(update.connectionInfo)); 55 83 } 56 57 84 85 58 86 dvdPanels.get(update.connectionInfo).updateDVDStatus(update); 59 87 } 60 88 61 89 /** 62 * Updates the current DVDInfoPanel with the title update. 63 * If a panel does not current exist, create one and add 64 * a new tab. 65 * 90 * Updates the current DVDInfoPanel with the title update. If a panel does 91 * not current exist, create one and add a new tab. 92 * 66 93 * @param update DVD title update. 67 94 */ 68 public void updateDVDTitle(DVDTitleUpdate update) { 69 if(dvdPanels.get(update.connectionInfo) == null) { 95 public void updateDVDTitle(DVDTitleUpdate update) 96 { 97 if (dvdPanels.get(update.connectionInfo) == null) 98 { 70 99 dvdPanels.put(update.connectionInfo, new DVDInfoPanel(update.connectionInfo)); 71 72 mediaTabs.addTab("DVD " + dvdPanels.size(), 100 101 mediaTabs.addTab("DVD " + dvdPanels.size(), 73 102 dvdPanels.get(update.connectionInfo)); 74 103 } 75 104 76 105 dvdPanels.get(update.connectionInfo).updateDVDTitle(update); 77 106 } 78 107 79 108 /** 80 109 * Initialize GUI components. 81 110 */ 82 private void initComponents() { 111 private void initComponents() 112 { 83 113 mediaTabs = new JTabbedPane(); 84 114 85 115 add(mediaTabs); 86 116 } 87 88 117 private JTabbedPane mediaTabs; 89 90 118 }
Note: See TracChangeset
for help on using the changeset viewer.
