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

📄 options.java

📁 利用JAVA实现的利用进化算法对人口增长进行仿真的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:

        jPanel6.setPreferredSize(new java.awt.Dimension(100, 50));
        Save.setText("Save");

        Close.setText("Close");

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .add(149, 149, 149)
                .add(Save)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Close)
                .addContainerGap(234, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Close)
                    .add(Save))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void toTownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toTownActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_toTownActionPerformed

    private void toCountyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toCountyActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_toCountyActionPerformed

    private void patternNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patternNoActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_patternNoActionPerformed

    private void diamondSquareActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_diamondSquareActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_diamondSquareActionPerformed

    private void maxCountiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxCountiesActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_maxCountiesActionPerformed

    private void maxContinentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxContinentsActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_maxContinentsActionPerformed

    private void personDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personDelayActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_personDelayActionPerformed

    private void highDebugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_highDebugActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_highDebugActionPerformed
    
    /**
     * @param args the command line arguments
     */
    private void secondInit(){
        Save.addActionListener(this);
        Close.addActionListener(this);
        Save.setActionCommand("Save");
        Close.setActionCommand("Close");
    }
    
    private void populateOptions(){
        //Populate General
        xSize.setText(Integer.toString(mainFrame.getWorldX()));
        ySize.setText(Integer.toString(mainFrame.getWorldY()));
        //Populate Debug
        highDebug.setSelected(mainFrame.getHighDebugLevel());
        mediumDebug.setSelected(mainFrame.getMediumDebugLevel());
        lowDebug.setSelected(mainFrame.getLowDebugLevel());
        
        personDelay.setSelected(mainFrame.getDelayPerson());
        personDelayValue.setValue(mainFrame.getDelayPersonValue());
        personDelayValue.setEnabled(mainFrame.getDelayPerson());
        
        houseDelay.setSelected(mainFrame.getDelayHouse());
        houseDelayValue.setValue(mainFrame.getDelayHouseValue());
        houseDelayValue.setEnabled(mainFrame.getDelayHouse());
        
        townDelay.setSelected(mainFrame.getDelayTown());
        townDelayValue.setValue(mainFrame.getDelayTownValue());
        townDelayValue.setEnabled(mainFrame.getDelayTown());
        
        countyDelay.setSelected(mainFrame.getDelayCounty());
        countyDelayValue.setValue(mainFrame.getDelayCountyValue());
        countyDelayValue.setEnabled(mainFrame.getDelayCounty());
        
        countryDelay.setSelected(mainFrame.getDelayCountry());
        countryDelayValue.setValue(mainFrame.getDelayCountryValue());
        countryDelayValue.setEnabled(mainFrame.getDelayCountry());
        
        continentDelay.setSelected(mainFrame.getDelayContinent());
        ContinentDelayValue.setValue(mainFrame.getDelayContinentValue());
        ContinentDelayValue.setEnabled(mainFrame.getDelayContinent());
        //Populate Generator
        maxContinents.setText(Integer.toString(mainFrame.getMaxRandomContinents()));
        maxCountries.setText(Integer.toString(mainFrame.getMaxRandomCountries()));
        maxCounties.setText(Integer.toString(mainFrame.getMaxRandomCounties()));
        maxTowns.setText(Integer.toString(mainFrame.getMaxRandomTowns()));
        maxHouses.setText(Integer.toString(mainFrame.getMaxRandomHouses()));
        maxPeople.setText(Integer.toString(mainFrame.getMaxRandomPeople()));
        
        switch(mainFrame.getMaxWorldTraversal()){
            case 0:
                toWorld.setSelected(true);
                break;
            case 1:
                toContinent.setSelected(true);
                break;
            case 2:
                toCountry.setSelected(true);
                break;
            case 3:
                toCounty.setSelected(true);
                break;
            case 4:
                toTown.setSelected(true);
                break;
            case 5:
                toHouse.setSelected(true);
                break;
            case 6:
                toPerson.setSelected(true);
                break;
            default:
                toWorld.setSelected(true);
                break;
        }
        //Populate Algorithm
        maxWorldHeight.setText(Integer.toString(mainFrame.getMaxWorldHeight()));
        minWorldHeight.setText(Integer.toString(mainFrame.getMinWorldHeight()));
        seaLevel.setText(Integer.toString(mainFrame.getSeaLevel()));
        mountainLevel.setText(Integer.toString(mainFrame.getMountainLevel()));
        switch (mainFrame.getAlgorithm()){
            case 0:
                diamondSquare.setSelected(true);
                perlinNoiseOptions.setEnabled(false);
                diamondSquareOptions.setEnabled(true);
                break;
            case 1:
                perlinNoise.setSelected(true);
                perlinNoiseOptions.setEnabled(true);
                diamondSquareOptions.setEnabled(false);
                break;
            default:
                diamondSquare.setSelected(true);
                perlinNoiseOptions.setEnabled(false);
                diamondSquareOptions.setEnabled(true);
                break;
        }
        smoothness.setText(Double.toString(mainFrame.getSmoothness()));
        randomStart.setSelected(mainFrame.getRandomStartDiamondSquare());
        patternNo.setText(Integer.toString(mainFrame.getDiamondSquarePattern()));
        maxStartHeight.setText(Integer.toString(mainFrame.getMaxStartHeight()));
        minStartHeight.setText(Integer.toString(mainFrame.getMinStartHeight()));
        if(mainFrame.getRandomStartDiamondSquare()){
            patternNo.setEnabled(false);
        }else{
            maxStartHeight.setEnabled(false);
            minStartHeight.setEnabled(false);
        }
    }
    
    private boolean errorCheckValues(){
        //errorcheck general
        //errorcheck debug
        //errorcheck generator
        //errorcheck algorithm
        
        return true;
    }
    
    private void saveValues(){
        /*Assumtions:
         *values are correct
         */
        //save general
        mainFrame.setWorldX(Integer.parseInt(xSize.getText()));
        mainFrame.setWorldY(Integer.parseInt(ySize.getText()));
        //save debug
        
        mainFrame.setHighDebugLevel(highDebug.isSelected());
        mainFrame.setMediumDebugLevel(mediumDebug.isSelected());
        mainFrame.setLowDebugLevel(lowDebug.isSelected());
        
        mainFrame.setDelayPerson(personDelay.isSelected());
        mainFrame.setDelayHouse(houseDelay.isSelected());
        mainFrame.setDelayTown(townDelay.isSelected());
        mainFrame.setDelayCounty(countyDelay.isSelected());
        mainFrame.setDelayCountry(countryDelay.isSelected());
        mainFrame.setDelayContinent(continentDelay.isSelected());
        SpinnerNumberModel temp;
        temp = (SpinnerNumberModel)personDelayValue.getModel();
        mainFrame.setDelayPersonValue(temp.getNumber().intValue());
        temp = (SpinnerNumberModel)houseDelayValue.getModel();
        mainFrame.setDelayHouseValue(temp.getNumber().intValue());
        temp = (SpinnerNumberModel)townDelayValue.getModel();
        mainFrame.setDelayTownValue(temp.getNumber().intValue());
        temp = (SpinnerNumberModel)countyDelayValue.getModel();
        mainFrame.setDelayCountyValue(temp.getNumber().intValue());
        temp = (SpinnerNumberModel)countryDelayValue.getModel();
        mainFrame.setDelayCountryValue(temp.getNumber().intValue());
        temp = (SpinnerNumberModel)ContinentDelayValue.getModel();
        mainFrame.setDelayContinentValue(temp.getNumber().intValue());
        
        //save generator
        mainFrame.setMaxRandomContinents(Integer.parseInt(maxContinents.getText()));
        mainFrame.setMaxRandomCountries(Integer.parseInt(maxCountries.getText()));
        mainFrame.setMaxRandomCounties(Integer.parseInt(maxCounties.getText()));
        mainFrame.setMaxRandomTowns(Integer.parseInt(maxTowns.getText()));
        mainFrame.setMaxRandomHouses(Integer.parseInt(maxHouses.getText()));
        mainFrame.setMaxRandomPeople(Integer.parseInt(maxPeople.getText()));
        
        if(toWorld.isSelected()){
            mainFrame.setMaxWorldTraversal(0);
        }else

⌨️ 快捷键说明

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