📄 integerpropertyinfo.java
字号:
/*
* 08/10/2005
*
* IntegerPropertyInfo.java - Information about an int property.
* Copyright (C) 2005 Robert Futrell
* email@address.com
* www.website.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.fife.ui.propertysheet.infos;
import org.fife.ui.propertysheet.InvalidPropertyValueException;
public class IntegerPropertyInfo extends PropertyInfo {
/*****************************************************************************/
/**
* Creates information about an integer property.
*
* @param name The name of the property.
* @param value The initial and default value of the property.
*/
public IntegerPropertyInfo(String name, int value) {
this(name, value, value);
}
/*****************************************************************************/
/**
* Creates information about an integer property.
*
* @param name The name of the property.
* @param value The initial value of the property.
* @param defaultValue The default value of the property.
*/
public IntegerPropertyInfo(String name, int value, int defaultValue) {
super(name, new Integer(value), new Integer(defaultValue));
}
/*****************************************************************************/
/**
* Returns the bounds set for this int property, if any.
*
* @return The property bounds. If <code>null</code> is returned, then
* no bounds have been explicitly set; this means any int value
* is valid.
* @see #setBounds
* @see #setMinimumBound
*/
public IntegerBounds getBounds() {
Object data = getData();
// Check in case they call setData() with some other object...
if (data instanceof IntegerBounds)
return (IntegerBounds)data;
return null;
}
/*****************************************************************************/
public Class getType() {
return int.class;
}
/*****************************************************************************/
public void setBounds(int min, int max) {
setData(new IntegerBounds(min, max));
}
/*****************************************************************************/
public void setMinimumBound(int min) {
setData(new IntegerBounds(min));
}
/*****************************************************************************/
protected void validateValue(Object value)
throws InvalidPropertyValueException {
if (!(value instanceof Integer))
throw new InvalidPropertyValueException("Expected an Integer, " +
"but received a " + (value==null ? "null" :
value.getClass().toString()));
}
/*****************************************************************************/
/******************** INNER CLASSES ******************************************/
/*****************************************************************************/
/**
* Object representing bounds for an integer.
*/
public static class IntegerBounds {
private int min;
private int max;
public IntegerBounds(int min) {
this(min, Integer.MAX_VALUE);
}
public IntegerBounds(int min, int max) {
this.min = min;
this.max = max;
}
public int getMaxValue() {
return max;
}
public int getMinValue() {
return min;
}
}
/*****************************************************************************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -