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

📄 parameter.java

📁 多线程活动球java 程序,便于理解Multi-Threaded 的功能.
💻 JAVA
字号:
import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;


public class Parameter
{
	public static final int nWidth = 900;			// Canvas Width
	public static final int nHeight = 600;			// Canvas Height
	public static final long frameDuration = 20;	// Frame Duration
	public static final int nDeltaDistance = 20;	// Incremental Distance
	public static final int nDeltaRadius = 2;		// Incremental Radius
	public static final int iniRadius = 2;			// Initial Radius of ball
	public static final int endRadius = 40;			// Initial Radius of ball
	public static final Color bgColor= Color.white;      // background canvas color
	public static final Color fgColor= Color.blue;      // background canvas color
	public static final Color ballColor = Color.green;    // ball object color   
	public static final double[] angles = { 10,15,20,25,30,40,45,50,55,60};	
    
    private Properties expProps;                
    
    public Parameter(File inFile)
    {
        loadProperties(inFile);
        listProperties(inFile);
       

    } // end of LifeProperties

    public int getCanvasWidth()
    {
        return Integer.parseInt(expProps.getProperty("nWidth"));
    }// End getCanvasWidth
    
    public int getCanvasHeight()
    {
        return Integer.parseInt(expProps.getProperty("nHeight"));
    }// End getCanvasWidth
    
    public int getFrameDuration()
    {
        return Integer.parseInt(expProps.getProperty("frameDuration"));
    
    }// End getFrameDuration
    
    public int getNumOfLeftShots()
    {
        return Integer.parseInt(expProps.getProperty("NumberOfLeftTrials"));
    }// End getNumOfLeftShots
    
    public int getNumOfRightShots()
    {
        return Integer.parseInt(expProps.getProperty("NumberOfRightTrials"));
    }// End getNumOfRightShots
    
    
    public int getIncrementalDis()
    {
        return Integer.parseInt(expProps.getProperty("nDeltaDistance"));
    }// End getIncrementalDis
    
    public int getIncrementalRadius()
    {
        return Integer.parseInt(expProps.getProperty("nDeltaRadius"));
    }// End getIncrementalRadius
    
    public int getStartRadius()
    {
        return Integer.parseInt(expProps.getProperty("iniRadius"));
    }// End getStartRadius
    
    public int getEndRadius()
    {
        return Integer.parseInt(expProps.getProperty("endRadius"));
    }// End getEndRadius
    
    public int[] getAngels()
    {
        return  parseStringIntoIntArray(expProps.getProperty("angles")); 
    }// End getAngels
    
    public Color getBgColor()
    {
        return getColor(expProps.getProperty("bgColor"));
    }// End getBgColor
    
    public Color getFgColor()
    {
        return getColor(expProps.getProperty("fgColor"));
    }// End getFgColor
    
    public Color getBallColor()
    {
        return getColor(expProps.getProperty("ballColor"));
    }// End getBallColor
    
    // Return a Color
    private Color getColor(String strColorDes)
    {
        Color
            c = Color.white;
        
        int[]
            nValues = parseStringIntoIntArray(strColorDes);
            
        c = new Color(nValues[0],nValues[1],nValues[2]);
               
        return c;
    }//End getColor
    
    private void loadProperties(File inFile)
    // load the properties from the PROP_FNM file
    {
        expProps = new Properties();
        try
        {
            FileInputStream in = new FileInputStream(inFile);
            expProps.load(in);
            in.close();
            System.out.println("Loaded properties from " + inFile.getName());
        } catch (IOException e)
        {
            System.out.println("Could not load properties from " + inFile.getName());
        }
    } // end of loadProperties()

    private void listProperties(File inFile)
    {
        if (expProps.isEmpty())
            System.out.println("No properties in " + inFile.getName());
        else
        {
            System.out.println("Properties in " + inFile.getName());
            expProps.list(System.out);
        }
    } // end of listProperties()
   
    private int[] parseStringIntoIntArray(String str)
    {
        String[] strInfos = str.split(" ");
       
        int[] numInfos = new int[strInfos.length];

        for (int i = 0; i < numInfos.length; i++)
        {
            
            numInfos[i] = Integer.parseInt(strInfos[i]);
            
        }// End for
         
        return numInfos;

    }// End setTrialInfo Method

    
   
}//End Class Defintion

⌨️ 快捷键说明

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