示例#1
0
  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);
  }
示例#2
0
 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");
 }
示例#3
0
 public void simulationStopped(int realSimID) {
   setStatusMessage("Game " + realSimID + " has finished");
   statusPanel.simulationStopped(realSimID);
   viewer.simulationStopped(realSimID);
 }
示例#4
0
 public void interaction(int fromAgent, int toAgent, int type) {
   viewer.interaction(fromAgent, toAgent, type);
 }
示例#5
0
 public void interactionWithRole(int fromAgent, int role, int type) {
   viewer.interactionWithRole(fromAgent, role, type);
 }
示例#6
0
 public void dataUpdated(int type, Transportable value) {
   viewer.dataUpdated(type, value);
 }
示例#7
0
 public void dataUpdated(int agent, int type, String value) {
   viewer.dataUpdated(agent, type, value);
 }
示例#8
0
 public void dataUpdated(int agent, int type, double value) {
   viewer.dataUpdated(agent, type, value);
 }
示例#9
0
 public void participant(int index, int role, String name, int participantID) {
   viewer.participant(index, role, name, participantID);
 }
示例#10
0
 /**
  * ******************************************************************* ViewerConnection API
  * ********************************************************************
  */
 public void nextTimeUnit(int timeUnit) {
   statusPanel.nextTimeUnit(timeUnit);
   viewer.nextTimeUnit(timeUnit);
 }