public ViewerPanel(String userName, String serverName) { this.serverName = serverName; this.userName = userName; // TODO: use the tasim_viewer.conf file // NOTE: this should actually be the tac09aa_viewer.conf file String configFile = "tasim_viewer.conf"; // String configFile = "tac13adx_viewer.conf"; URL configURL = ViewerPanel.class.getResource("/config/" + configFile); config = new ConfigManager(); try { if (configURL != null) { config.loadConfiguration(configURL); } else if (!config.loadConfiguration("config" + File.separatorChar + configFile)) { // Failed to load the configuration. log.severe("could not find config " + configFile); } } catch (Exception e) { log.severe("could not find config " + configFile); } // Should not be hardcoded but setup depending on simulation type. FIX // THIS!!! 0 \TODO viewer = null; try { String simulationViewerClass = config.getProperty("simulationViewer"); viewer = (SimulationViewer) Class.forName(simulationViewerClass).newInstance(); } catch (InstantiationException e) { log.severe("Could not instantiate the simulation viewer"); } catch (IllegalAccessException e) { log.severe("Could not instantiate the simulation viewer"); } catch (ClassNotFoundException e) { log.severe("Could not find the simulation viewer class"); } viewer.init(this); viewerPanel = viewer.getComponent(); mainPanel = new JPanel(new BorderLayout()); mainPanel.setForeground(foregroundColor); mainPanel.setBackground(backgroundColor); mainPanel.add(viewerPanel, BorderLayout.CENTER); statusLabel = new JLabel("Status:"); statusLabel.setOpaque(true); statusLabel.setForeground(foregroundColor); statusLabel.setBackground(backgroundColor); chatPanel = new ChatPanel(this); // Hack to avoid using another panel chatPanel.setStatusLabel(statusLabel); mainPanel.add(chatPanel, BorderLayout.SOUTH); statusPanel = new StatusPanel(this, foregroundColor, backgroundColor); mainPanel.add(statusPanel, BorderLayout.NORTH); }
public void simulationStarted( int realSimID, String type, long startTime, long endTime, String timeUnitName, int timeUnitCount) { // Close any old open dialog closeDialog(); statusPanel.simulationStarted(realSimID, type, startTime, endTime, timeUnitName, timeUnitCount); viewer.simulationStarted(realSimID, type, startTime, endTime, timeUnitName, timeUnitCount); setStatusMessage("Game " + realSimID + " is running"); }
public void simulationStopped(int realSimID) { setStatusMessage("Game " + realSimID + " has finished"); statusPanel.simulationStopped(realSimID); viewer.simulationStopped(realSimID); }
public void interaction(int fromAgent, int toAgent, int type) { viewer.interaction(fromAgent, toAgent, type); }
public void interactionWithRole(int fromAgent, int role, int type) { viewer.interactionWithRole(fromAgent, role, type); }
public void dataUpdated(int type, Transportable value) { viewer.dataUpdated(type, value); }
public void dataUpdated(int agent, int type, String value) { viewer.dataUpdated(agent, type, value); }
public void dataUpdated(int agent, int type, double value) { viewer.dataUpdated(agent, type, value); }
public void participant(int index, int role, String name, int participantID) { viewer.participant(index, role, name, participantID); }
/** * ******************************************************************* ViewerConnection API * ******************************************************************** */ public void nextTimeUnit(int timeUnit) { statusPanel.nextTimeUnit(timeUnit); viewer.nextTimeUnit(timeUnit); }