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

📄 constraint.java

📁 使用java编写的关于通讯及串口编程所必需的类库
💻 JAVA
字号:
/* * Constraint.java * * This is a required part of the com.adaptiveview.ospso package. * * Copyright (C) 2003 AdaptiveView.com *  * This library 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 (at your option) any later version. *  * This library 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 library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *  * You may contact AdaptiveView.com via email at: comments.pso@adaptiveview.com  * */package com.adaptiveview.ospso;/**A Constraint is simply the limits to (the minimum and maximum of) a number range. * Some constraints have special boundary (limit) types that indicate how a value that * exceeds the boundaries is to be modified such that it is again within the boundaries. * There are three such types:  *<blockquote> *<B>STICK</B>: the value is set to the exceeded boundary's value * -- e.g., if the boundaries are 1 and 10 and the value is 12, it is set to 10, * <p><B>WRAP</B>: the value wraps around to the opposite boundary -- e.g., if the boundaries * are 1 and 10 and the value is 12, the value will be set to 2, and  *<p><B>BOUNCE</B> the value, in effect, bounces off the exceeded boundary and is  * applied in the opposite direction -- e.g., if the boundaries are 1 and 10 and the  * value is 12, the value will be set to 8. *</blockquote> * * @author  unknown */public class Constraint implements com.adaptiveview.ospso.dmi.DMI_GPL_License {        public static final byte NONE = 0;    public static final byte WRAP = 125;    public static final byte BOUNCE = 126;    public static final byte STICK = 127;        private double minimum;    private double maximum;    private byte boundaryType;        /** Creates a new instance of Constraint */    public Constraint(double minimum, double maximum, byte boundaryType) throws IllegalArgumentException {        if (!(boundaryType == NONE || boundaryType == WRAP || boundaryType == BOUNCE || boundaryType == STICK))            throw new IllegalArgumentException("Invalid boundary type.");        if (boundaryType == NONE) {          if (minimum > maximum)              throw new IllegalArgumentException("Maximum must be greater than minimum for specified boundary type.");        }        else        if (minimum >= maximum)            throw new IllegalArgumentException("Maximum must be greater than minimum for specified boundary type.");        this.minimum = minimum;        this.maximum = maximum;        this.boundaryType = boundaryType;    }        /** Creates a new instance of Constraint with no boundary type */    public Constraint(double minimum, double maximum) throws IllegalArgumentException {        this(minimum,maximum,NONE);    }        public double getMinimum() {        return this.minimum;    }        public double getMaximum() {        return this.maximum;    }        public byte getBoundaryType() {        return this.boundaryType;    }    }

⌨️ 快捷键说明

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