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

📄 radioproperty.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.core.graphics.properties;

import java.util.Set;
import java.util.Collections;
import java.util.HashSet;
import jmathlib.core.graphics.*;

public class RadioProperty extends Property
{
	protected Set    valueSet;
	protected String value;

	public RadioProperty(PropertySet parent, String name, String[] values, String defaultValue)
	{
		super(parent, name);
		valueSet = Collections.synchronizedSet(new HashSet());
        
		for (int i=0; i<values.length; i++)
			valueSet.add(values[i]);
		
        if (valueSet.contains(defaultValue))
			value = defaultValue;
		else
			value = values[0];
	}

	public Object get()
	{
		return getValue();
	}

	public void set(Object newValue) throws PropertyException
	{
		if (newValue instanceof String)
			setValueInternal((String)newValue);
		else
			throw new PropertyException("invalid property value - " + newValue.toString());
	}

	public String getValue()
	{
		return value;
	}

	public boolean is(String val)
	{
		return value.equals(val);
	}

	private void setValueInternal(String newValue) throws PropertyException
	{
		if (valueSet.contains(newValue))
		{
			value = newValue;
			valueChanged();
		}
		else
			throw new PropertyException("invalid property value - " + newValue);
	}

	public String toString()
	{
		return value;
	}
}

⌨️ 快捷键说明

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