⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groundcontrolhelpergui.java.svn-base

📁 這是一個JAVA語言寫的多代理人程式用來模擬飛機起飛或是降落的程式
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
		}
	}
	/**
	 *  Adds a runway to alRunways
	 *  
	 *  @param runway  a Runway object
	 *  @return void
 	 */	
	public void addRunway(Runway runway)
	{
		((ArrayList)alRunways).add(runway);
		gGUI.cbRunway.addItem(runway.toString());

	}
	/**
	 *  Adds taxiways to alTaxiways
	 *  
	 *  @param taxiways list of taxiways
	 *  @return void
 	 */	
	public void addTaxiways(ArrayList <Taxiway> taxiways)
	{
		alTaxiways = taxiways;
		for (int i = 0; i<alTaxiways.size(); i++)
		{
			gGUI.cbTaxiway.addItem(taxiways.get(i).toString());
			gGUI.cbTaxiwayArriv.addItem(taxiways.get(i).toString());
		}
	}
	/**
	 *  Adds a taxiway to alTaxiways
	 *  
	 *  @param runway  a Taxiway object
	 *  @return void
 	 */	
    public void addTaxiway(Taxiway taxiway)
	{
	    ((ArrayList)alTaxiways).add(taxiway);
		gGUI.cbTaxiway.addItem(taxiway.toString());
		gGUI.cbTaxiwayArriv.addItem(taxiway.toString());
	}
	
	 //** Arrival **\\
    /**
	 *  Returns status of the bPath boolean object
	 *  
	 *  @return boolean
 	 */	
	public boolean isPath()
	{
		return alAirplaneInfoArriv.get((String)gGUI.cbCallNumArriv.getSelectedItem()).isBPath();
	}
	/**
	 *  Returns the taxiways needed for arrival
	 *  
	 *  @return Collection<Taxiway> 
 	 */	
	public List<Taxiway> getTaxiwaysArriv()
	{
		return colTaxiwaysArriv;
	}
	/**
	 *  Returns the currently selected plane number
	 *  
	 *  @return String
 	 */	
	public String getCallNumArriv()
	{
		return (String)gGUI.cbCallNumArriv.getSelectedItem();
	}
	/**
	 *  Removes the plane from the Arrival panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
    public void removeArriv(String callNum)
    {
	    gGUI.tfRunwayArriv.setText("");
            gGUI.tfGateNumArriv.setText("");
            gGUI.cbCallNumArriv.removeItem(callNum);
            gGUI.taTaxiwayArriv.setText("");
            alAirplaneInfoArriv.remove(callNum);
    }	
    /**
	 *  Updates images in Arrival panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
	public void updateImagesArriv(String callNum)
	{
		try
		{
			GroundHelperArriv temp = alAirplaneInfoArriv.get(callNum);
			if (temp.isBPath())
			{
				gGUI.lPathImage.setIcon(gGUI.iConfirmation[1]);
			}
			else
			{
				gGUI.lPathImage.setIcon(gGUI.iConfirmation[0]);
			}		
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	//** Departure **\\
	/**
	 *  Returns status of the bPush boolean object
	 *  
	 *  @return boolean
 	 */	 
	public boolean isPush()
	{
		return alAirplaneInfoDep.get((String)gGUI.cbCallNum.getSelectedItem()).isBPush();
	}
	/**
	 *  Returns status of the bTaxiReady boolean object
	 *  
	 *  @return boolean
 	 */	
	public boolean isReady()
	{
		return alAirplaneInfoDep.get((String)gGUI.cbCallNum.getSelectedItem()).isBTaxiReady();
	}
	/**
	 *  Returns status of the bTaxiConfirm boolean object
	 *  
	 *  @return boolean
 	 */	
	public boolean isConfirm()
	{
		return alAirplaneInfoDep.get((String)gGUI.cbCallNum.getSelectedItem()).isBTaxiConfirm();
	}
	/**
	 *  Returns runway associated with Departure
	 *  
	 *  @return Runway
 	 */	
	public Runway getRunwayDep()
	{
		return alAirplaneInfoDep.get((String)gGUI.cbCallNum.getSelectedItem()).getSStrip().runway;
	}	
	/**
	 *  Returns gate associated with Departure
	 *  
	 *  @return Gate
 	 */	
	public Gate getGateDep()
	{
		return alAirplaneInfoDep.get((String)gGUI.cbCallNum.getSelectedItem()).getSStrip().gate;
	}
	/**
	 *  Returns a collection of Taxiways associated with Departure
	 *  
	 *  @return Collection<Taxiway> 
 	 */
	public List<Taxiway> getPathDep()
	{
		return colTaxiwaysDep;
	}
	/**
	 *  Returns a currently selected plane number associated with Departure
	 *  
	 *  @return String
 	 */
	public String getCallNumDep()
	{
		return (String)gGUI.cbCallNum.getSelectedItem();
	}
	/**
	 *  Removes the plane from the Departure panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
    public void removeDep(String callNum)
    {
	    gGUI.tfGateNum.setText("");
            gGUI.cbCallNum.removeItem(callNum);
            gGUI.taTaxiway.setText("");
            alAirplaneInfoDep.remove(callNum);
    }
    /**
	 *  Updates images in Departure panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	    
	public void updateImagesDep(String callNum)
	{
		try
		{
			GroundHelperDep temp = alAirplaneInfoDep.get(callNum);
			if (temp.isBPush())
			{
				gGUI.lPushImage.setIcon(gGUI.iConfirmation[1]);
			}
			else
			{
				gGUI.lPushImage.setIcon(gGUI.iConfirmation[0]);
			}
			if (temp.isBTaxiConfirm())
			{
				gGUI.lTaxiPathImage.setIcon(gGUI.iConfirmation[1]);
			}
			else
			{
				gGUI.lTaxiPathImage.setIcon(gGUI.iConfirmation[0]);
			}
			if (temp.isBTaxiReady())
			{
				gGUI.lTaxiReadyImage.setIcon(gGUI.iConfirmation[1]);
			}
			else
			{
				gGUI.lTaxiReadyImage.setIcon(gGUI.iConfirmation[0]);
			}
			
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	/** Log a message call */
	protected void logMessage(String msg, Object ... objects) {
		String from = Thread.currentThread().getName();
		String str = timeStamp() + from + " -> " + name + " . " + msg + "()\n";
		/*
		for(Object object : objects) {
			str += " \n\t" + shortName(object.getClass().toString()) + ": " + object.toString();
		}
		
		System.out.print(str + "\n \n");
		
		/*if(guiObject != null) {
			guiObject.logMessage(from, name, str);
		}
		animation.logMessage(from, name, str);
		*/
	}
	
	/**
	 *  Returns the Ground Control Panel
	 *  
	 *  @return JPanel
 	 */	
	public JPanel getGroundPanel()
	{
		return gGUI;
	}
	
	/**
	 * Action Listeners
	 */
	//** Arrival **\\
	class ComboArriv implements ActionListener {
    	//@Override
	    public void actionPerformed(ActionEvent ae) {
	        
	        if (ae.getSource() == gGUI.bTaxiwayArriv)
	        {
	        	gGUI.taTaxiwayArriv.append(gGUI.cbTaxiwayArriv.getSelectedItem().toString() + "\n");
	        	colTaxiwaysArriv.add(new Taxiway(gGUI.cbTaxiwayArriv.getSelectedItem().toString()));
	        }
	        else if (ae.getSource() == gGUI.bTaxiwaySubmitArriv)
	        {
	        	if (getCallNumArriv()!= null &&!isPath())
				{
	        		GiveTaxiLandingPathToPilot(getCallNumArriv());
				}
	        }
	        else 
	        {
		        JComboBox cb = (JComboBox)ae.getSource();
		        String callNum = (String)cb.getSelectedItem();
		        if (alAirplaneInfoArriv.get(callNum)!= null)
		        {
		        	colTaxiwaysArriv.clear();
		        	updateImagesArriv(callNum);
		        	gGUI.tfGateNumArriv.setText(alAirplaneInfoArriv.get(callNum).getSStrip().gate.toString());
		        	gGUI.tfRunwayArriv.setText(alAirplaneInfoArriv.get(callNum).getSStrip().runway.toString());
		        	if (alAirplaneInfoArriv.get(callNum).getAlTaxiways()!=null)
		        	{
		        		Iterator <Taxiway> it = alAirplaneInfoArriv.get(callNum).getAlTaxiways().iterator();
		        		String text = ""; 
		        		while (it.hasNext())
		        		{
		        			text += it.next().toString() + "\n";
		        		}
		        		colTaxiwaysArriv = alAirplaneInfoArriv.get(callNum).getAlTaxiways();
		        		gGUI.taTaxiwayArriv.setText(text);
		        	}	        	
		        }
	        }
	    }
    }
	
	//** Departure **\\
	class ComboDep implements ActionListener {
    	//@Override
	    public void actionPerformed(ActionEvent ae) {
	    	
	    	if (ae.getSource() == gGUI.bTaxiway)
	    	{
	    		gGUI.taTaxiway.append(gGUI.cbTaxiway.getSelectedItem().toString()+ "\n");
	    		colTaxiwaysDep.add(new Taxiway(gGUI.cbTaxiway.getSelectedItem().toString()));
	    	}
	    	else if (ae.getSource() == gGUI.bPush)
			{
				if (getCallNumDep()!= null &&!isPush()&& !isReady()&&!isConfirm())
				{
					GivePushBackToPilot(getCallNumDep());
				}
			}
			else if (ae.getSource() == gGUI.bTaxiwaySubmit)
			{
				if (getCallNumDep()!= null && isPush()&& isReady()&&!isConfirm())
				{
					GiveTaxiTakeoffPathToPilot(getCallNumDep());
				}
			}
	    	else
	    	{
	    		JComboBox cb = (JComboBox)ae.getSource();
		        String callNum = (String)cb.getSelectedItem();
		        if (alAirplaneInfoDep.get(callNum)!= null)
		        {
		        	colTaxiwaysDep.clear();
		        	updateImagesDep(callNum);
		        	try
		        	{
		        		gGUI.tfGateNum.setText(alAirplaneInfoDep.get(callNum).getSStrip().gate.toString());
		        	}
		        	catch(Exception e)
		        	{
		        		System.out.println(e.getMessage());
		        	}
		        	if (alAirplaneInfoDep.get(callNum).getSStrip().runway != null)
		        	{
		        		//gGUI.cbRunway.setSelectedItem(alAirplaneInfoDep.get(callNum).getSStrip().runway.toString());
		        	}
		        	if (alAirplaneInfoDep.get(callNum).getAlTaxiways()!=null)
		        	{
		        		Iterator <Taxiway> it = alAirplaneInfoDep.get(callNum).getAlTaxiways().iterator();
		        		String text = ""; 
		        		while (it.hasNext())
		        		{
		        			text += it.next().toString() + "\n";
		        		}
		        		colTaxiwaysDep = alAirplaneInfoDep.get(callNum).getAlTaxiways();
		        		gGUI.taTaxiway.setText(text);
		        	}	        	
		        }
	    	}
	    }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -