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

📄 continent.java

📁 利用JAVA实现的利用进化算法对人口增长进行仿真的源码
💻 JAVA
字号:
/*
 * Continent.java
 *
 * Created on 12 October 2006, 08:09
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package wpc.data;
import java.awt.Graphics;

/**
 *
 * @author User
 */
public class Continent extends DataObject{
    /** Creates a new instance of Continent 
     * A continent contains all of the countrys with it.  It can either be created
     * with a random amount of countrys, when no int is passed, or a specific amount of 
     * countries, using the int.     
     */
    Country[] data;
    
    public Continent(wpc.MainFrame mainFrame) {
        super(mainFrame);
        createData(mainFrame.getRandom(mainFrame.getMaxRandomCountries())+1);
    }
    
    public Continent(int number, wpc.MainFrame mainFrame){
        super(mainFrame);
        createData(number);
        
    }
    
    public void createData(int number){
         if(number<=0){
            number=1;
        }
        if(mainFrame.getMaxWorldTraversal() >= 1) { 
        data = new Country[number];        
        mainFrame.setPartProgressMax((mainFrame.getMaxRandomCountries()*mainFrame.getMaxRandomCountries())*number);
        int n = 0;
        for(int i = 0;i<number;i++){
           if(mainFrame.getDelayCountry()){
             try {
                Thread.sleep(mainFrame.getDelayCountryValue());
                //System.out.println("Checking");
             } catch (InterruptedException e){
                // the VM doesn't want us to sleep anymore,
                // so get back to work
             }
           }
            n = mainFrame.getPartProgressValue();
            if(mainFrame.getMediumDebugLevel()){ 
                mainFrame.addMessageDateStringDebug("\t\tStarting County("+i+") @ ");
            }
            data[i]=new Country(mainFrame);
            if(mainFrame.getMediumDebugLevel()){ 
                mainFrame.addMessageDateStringDebug("\t\tFinished County("+i+") @ ");
            }
            mainFrame.setPartProgressValue(n+(mainFrame.getMaxRandomTowns()*mainFrame.getMaxRandomCounties()));
        }
       super.setData(data);
       //super.splitWorld();
        }
    }
    
    public void draw(Graphics g){
        g.setColor(color);
        g.drawRect(startX, startY, endX-startX, endY-startY);
        if(data!=null){
        for(int i = 0; i<data.length; i++){
            if (data[i]!=null){
            data[i].draw(g);
            }
        }
        }
    }    
}

⌨️ 快捷键说明

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