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

📄 localcontrolhelpergui.java.svn-base

📁 這是一個JAVA語言寫的多代理人程式用來模擬飛機起飛或是降落的程式
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
	public void addRunways(ArrayList <Runway> runways)
	{
		alRunways = runways;
		for (int i = 0; i<alRunways.size(); i++)
		{
			lGUI.cbRunwayDep.addItem(runways.get(i).toString());
		}
	}		
	/**
	 *  Adds a runway to alRunways
	 *  
	 *  @param runway  a Runway object
	 *  @return void
 	 */	
	public void addRunway(Runway runway)
	{
		((ArrayList)alRunways).add(runway);
		lGUI.cbRunwayDep.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++)
		{
			lGUI.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);
		lGUI.cbTaxiwayArriv.addItem(taxiway.toString());
	}

	// Arrival Methods
	/**
	 *  Returns status of the bClearance boolean object
	 *  
	 *  @return boolean
 	 */	
	public boolean isClearance()
	{
		return alAirplaneInfoArriv.get((String)lGUI.cbCallNumArriv.getSelectedItem()).isBClearance();
	}
	/**
	 *  Returns status of the BConfirmation boolean object
	 *  
	 *  @return boolean
 	 */	
	public boolean isConfirm()
	{
		return alAirplaneInfoArriv.get((String)lGUI.cbCallNumArriv.getSelectedItem()).isBConfirmation();
	}
	/**
	 *  Returns runway associated with Arrival
	 *  
	 *  @return Runway
 	 */	
	public Runway getRunwayArriv()
	{
		return alAirplaneInfoArriv.get((String)lGUI.cbCallNumArriv.getSelectedItem()).getSStrip().runway;
	}
	/**
	 *  Returns the currently selected plane number
	 *  
	 *  @return String
 	 */	
	public String getCallNumArriv()
	{
		return (String)lGUI.cbCallNumArriv.getSelectedItem();
	}
	/**
	 *  Returns the taxiways needed for arrival
	 *  
	 *  @return Collection<Taxiway> 
 	 */
	public List<Taxiway> getPathArriv()
	{
		return colTaxiwaysArriv;
	}
	/**
	 *  Removes the plane from the Arrival panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
    public void removeArriv(String callNum)
    {
	    lGUI.tfRunwayArriv.setText("");
            lGUI.tfGateNumArriv.setText("");
            lGUI.cbCallNumArriv.removeItem(callNum);
            lGUI.taTaxiwayArriv.setText("");
            alAirplaneInfoArriv.remove(callNum);
    }
    /**
	 *  Updates images in Arrival panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
	public void updateImagesArriv(String callNum)
	{
		try
		{
			LocalHelperArriv temp = alAirplaneInfoArriv.get(callNum);
			if (temp.isBClearance())
			{
				lGUI.lLandImageArriv.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lLandImageArriv.setIcon(lGUI.iConfirmation[0]);
			}
			if (temp.isBConfirmation())
			{
				lGUI.lPathImageArriv.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lPathImageArriv.setIcon(lGUI.iConfirmation[0]);
			}
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	// Departure Methods
	/**
	 *  Returns status of the bReady boolean object
	 *  
	 *  @return boolean
 	 */
	public boolean isReady()
	{
		return alAirplaneInfoDep.get((String)lGUI.cbCallNumDep.getSelectedItem()).isBReady();
	}
	/**
	 *  Returns status of the bHold boolean object
	 *  
	 *  @return boolean
 	 */
	public boolean isHold()
	{
		return alAirplaneInfoDep.get((String)lGUI.cbCallNumDep.getSelectedItem()).isBHold();
	}
	/**
	 *  Returns status of the bTakeOff boolean object
	 *  
	 *  @return boolean
 	 */
	public boolean isTakeoff()
	{
		return alAirplaneInfoDep.get((String)lGUI.cbCallNumDep.getSelectedItem()).isBTakeOff();
	}
	/**
	 *  Returns status of the bControl boolean object
	 *  
	 *  @return boolean
 	 */
	public boolean isControl()
	{
		return alAirplaneInfoDep.get((String)lGUI.cbCallNumDep.getSelectedItem()).isBControl(); 
	}
	/**
	 *  Returns runway associated with Departure
	 *  
	 *  @return Runway
 	 */	
	public Runway getRunwayDep()
	{
		return new Runway((String)lGUI.cbRunwayDep.getSelectedItem());
	}
	/**
	 *  Returns a currently selected plane number associated with Departure
	 *  
	 *  @return String
 	 */
	public String getCallNumDep()
	{
		return (String)lGUI.cbCallNumDep.getSelectedItem();
	}
	/**
	 *  Removes the plane from the Departure panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	
    public void removeDep(String callNum)
    {
	    lGUI.tfRunwayDep.setText("");
            lGUI.cbCallNumDep.removeItem(callNum);
            alAirplaneInfoDep.remove(callNum);
    }
    /**
	 *  Updates images in Departure panel
	 *  
	 *  @param callNum plane number 
	 *  @return void
 	 */	        
	public void updateImagesDep(String callNum)
	{
		try
		{
			LocalHelperDep temp = alAirplaneInfoDep.get(callNum);
			if (temp.isBControl() || temp.isBTakeOff())
			{
				lGUI.lConfirmImageDep.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lConfirmImageDep.setIcon(lGUI.iConfirmation[0]);
			}
			if (temp.isBHold())
			{
				lGUI.lHoldImageDep.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lHoldImageDep.setIcon(lGUI.iConfirmation[0]);
			}
			if (temp.isBReady())
			{
				lGUI.lReadyImageDep.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lReadyImageDep.setIcon(lGUI.iConfirmation[0]);
			}
			if (temp.isBTakeOff() || temp.isBControl())
			{
				lGUI.lConfirm2ImageDep.setIcon(lGUI.iConfirmation[1]);
			}
			else
			{
				lGUI.lConfirm2ImageDep.setIcon(lGUI.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 Local Control Panel
	 *  
	 *  @return JPanel
 	 */	
	public JPanel getLocalPanel()
	{
		return lGUI;
	}
	/**
	 * Action Listeners
	 */
	class ComboArriv implements ActionListener {
    	//@Override
	    public void actionPerformed(ActionEvent ae) {
	        
	        if (ae.getSource() == lGUI.bTaxiwayArriv)
	        {
	        	lGUI.taTaxiwayArriv.append(lGUI.cbTaxiwayArriv.getSelectedItem().toString() + "\n");
	        	colTaxiwaysArriv.add(new Taxiway(lGUI.cbTaxiwayArriv.getSelectedItem().toString()));
	        }
	        else if (ae.getSource() == lGUI.bRunwayClearArriv )
	        {
	        	if (getCallNumArriv()!= null && !isClearance() && !isConfirm())
				{
	        		GiveClearanceToLand(getCallNumArriv());
				}
	        }
	        else if (ae.getSource() == lGUI.bTaxiwaySubmitArriv )
	        {
	        	if (getCallNumArriv()!= null && isClearance() && !isConfirm())
				{
					GiveLandingPath(getCallNumArriv());
				}
	        }
	        else
	        {
		        JComboBox cb = (JComboBox)ae.getSource();
		        String callNum = (String)cb.getSelectedItem();
		        if (alAirplaneInfoArriv.get(callNum)!= null)
		        {
		        	colTaxiwaysArriv.clear();
		        	updateImagesArriv(callNum);
		        	lGUI.tfGateNumArriv.setText(alAirplaneInfoArriv.get(callNum).getSStrip().gate.toString());
		        	lGUI.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();
		        		lGUI.taTaxiwayArriv.setText(text);
		        	}	        	
		        }
	        }
	    }
    }
	class ComboDep implements ActionListener {
    	//@Override
	    public void actionPerformed(ActionEvent ae) {

	    	if (ae.getSource() == lGUI.bHoldDep)
	    	{
	    		if (getCallNumDep()!= null && isReady()&& !isHold()&&!isTakeoff()&&!isControl())
				{
	    			GivePositionAndHold(getCallNumDep());
	    			// GiveClearFlightForTakeoff(getCallNumDep());
				}
	    	}
	    	else if (ae.getSource() == lGUI.bClearedDep)
	    	{
	    		System.out.println("clear button clicked");
	    		if (getCallNumDep()!= null && isReady()&& !isTakeoff()&&!isControl())
				{
	    			GiveClearFlightForTakeoff(getCallNumDep());
	    			// GivePositionAndHold(getCallNumDep());
				}					
	    	}
	    	else if (ae.getSource() == lGUI.bContactDep)
	    	{
	    		if (getCallNumDep()!= null && isReady())
				{
	    			GiveDepartureControlContact(getCallNumDep());
				}	
	    	}
	    	else
	    	{
	    		JComboBox cb = (JComboBox)ae.getSource();
		        String callNum = (String)cb.getSelectedItem();
		        if (alAirplaneInfoDep.get(callNum)!= null)
		        {
		        	updateImagesDep(callNum);
		            lGUI.tfRunwayDep.setText(alAirplaneInfoDep.get(callNum).getRRunwayCurrent().toString());
		        	if (alAirplaneInfoDep.get(callNum).getSStrip().runway != null)
		        	{
		        		lGUI.cbRunwayDep.setSelectedItem(alAirplaneInfoDep.get(callNum).getSStrip().runway.toString());
		        	}
		        }
	    	}
	    }
    }
}

⌨️ 快捷键说明

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