📄 mainpanel.java.svn-base
字号:
package gui;import interfaces.*;import java.awt.*;import java.awt.event.KeyEvent;import java.util.*;import javax.swing.*;import agents.*;import base.*;import world.*;import world.*;public class MainPanel extends JPanel { JTabbedPane tabbedPane; HashMap<String, Integer> tabs = new HashMap<String, Integer>(); StartGuiNoRMI gui; public MainPanel(StartGuiNoRMI gui) { this.gui = gui; tabs.put("Airplane Manager", 0); tabs.put("Agent Controller", 1); tabs.put("Clearance Delivery", 2); tabs.put("Pilot", 3); tabs.put("CoPilot", 4); tabs.put("Ground Control", 5); tabs.put("Local Control", 6); tabbedPane = new JTabbedPane(); gui.messageGUI = new MessageGUI(); Tower tower1 = gui.airport.towers.get(0); tower1.setAirport(gui.airport); gui.airplaneManagerGui = new AirplaneManagerGUI(gui); tabbedPane.addTab("Airplane Manager", null, gui.airplaneManagerGui, null); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); gui.agentControllerGui = new AgentControllerGUI(gui); tabbedPane.addTab("Agent Controller", null, gui.agentControllerGui, null); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); tabbedPane.addTab("Messages", null,gui. messageGUI, null); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); String cdName, gcName, lcName; if(gui.userControlled) { //instantiate "GUI" agents if(gui.cdControlled) { } else { cdName = "ClearanceDeliveryGUI"; gui.clearanceDelivery = new ClearanceDeliveryHelper(cdName, gui.airport, new WorldObjectState(), new GuiObject(), new Animation(gui.messageGUI, cdName)); tabbedPane.addTab("Clearance Delivery", null, ((ClearanceDeliveryHelper) gui.clearanceDelivery).getClearancePanel(), null); // tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); } gui.pilotGui = new PilotGUI(); tabbedPane.addTab("Pilot", null, gui.pilotGui, null); // tabbedPane.setMnemonicAt(4, KeyEvent.VK_5); gui.coPilotGui = new CoPilotGUI(); tabbedPane.addTab("CoPilot", null, gui.coPilotGui, null); // tabbedPane.setMnemonicAt(5, KeyEvent.VK_6); gui.pilotGui.setCoPilot(gui.coPilotGui); if(gui.gcControlled) { } else { gcName = "GroundControlGUI"; gui.groundControl = new GroundControlHelperGUI(gcName, tower1, new WorldObjectState(), new GuiObject(), new Animation(gui.messageGUI, gcName)); tabbedPane.addTab("Ground Control", null, ((GroundControlHelperGUI) gui.groundControl).getGroundPanel(), null); // tabbedPane.setMnemonicAt(6, KeyEvent.VK_7); } if(gui.lcControlled) { } else { lcName = "LocalControlGUI"; gui.localControl = new LocalControlHelperGUI(lcName, tower1, new WorldObjectState(), new GuiObject(), new Animation(gui.messageGUI, lcName)); tabbedPane.addTab("Local Control", null, ((LocalControlHelperGUI) gui.localControl).getLocalPanel(), null); // tabbedPane.setMnemonicAt(7, KeyEvent.VK_8); } } else { //instantiate 201 agents System.out.println("Adding agents"); cdName = "ClearanceDeliveryAgent"; gui.clearanceDelivery = new ClearanceDeliveryAgent(cdName, tower1); gui.agentControllerGui.addClearanceDelivery(cdName); ((Agent) (gui.clearanceDelivery)).startThread(); gcName = "GroundControlAgent"; gui.groundControl = new GroundControllerAgent(gcName, tower1); gui.agentControllerGui.addGroundControl(gcName); ((Agent) (gui.groundControl)).startThread(); lcName = "LocalControlAgent"; gui.localControl = new LocalControllerAgent(lcName, tower1); gui.agentControllerGui.addLocalControl(lcName); ((Agent) (gui.localControl)).startThread(); } addDestinations(); //World.setAnimation(new Animation(gui.messageGUI)); add(tabbedPane); } public void addDestinations() { String[] destinations = { "San Francisco (SFO)", "Oakland (OAK)", "Seattle (SEA)" }; gui.airplaneManagerGui.setDestinations(destinations); if(gui.cdControlled) { } else { // ((ClearanceDeliveryHelper) gui.clearanceDelivery).setDestinations(destinations); } } public void addArrivingFlight(String callNumber) { } public void addDepartingFlight(String callNumber, Runway runway) { if(gui.gcControlled) { ((GroundControlHelperGUI) gui.groundControl).addRunway(runway); } else { // ((GroundControllerAgent)gui.groundControl). } } public void addPilot(String name) { gui.agentControllerGui.addPilot(name); } public void addCoPilot(String name) { gui.agentControllerGui.addCoPilot(name); } public void setFocus(String tabName) { try { tabbedPane.setSelectedIndex(tabs.get(tabName)); } catch(Exception e) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -