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

📄 parameter.java

📁 FuncPlotter is a combined Java application and applet for displaying two-dimensional plots of explic
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*====================================================================*\Parameter.javaParameter class.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program.  If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage util;//----------------------------------------------------------------------// IMPORTSimport exception.AppException;import java.awt.Color;import javax.swing.JApplet;import org.w3c.dom.Element;import xml.PropertyFile;//----------------------------------------------------------------------// PARAMETER CLASSpublic abstract class Parameter{//////////////////////////////////////////////////////////////////////////  Constants////////////////////////////////////////////////////////////////////////    public static final String  APP_PREFIX  = "app.";    public enum Order    {        LESS_THAN,        LESS_THAN_OR_EQUAL_TO,        GREATER_THAN,        GREATER_THAN_OR_EQUAL_TO    }//////////////////////////////////////////////////////////////////////////  Enumeration types////////////////////////////////////////////////////////////////////////    // PARAMETER TYPE    public enum Type    {    ////////////////////////////////////////////////////////////////////    //  Constants    ////////////////////////////////////////////////////////////////////        APPLET          ( "Applet parameter" ),        SYSTEM_PROPERTY ( "System property" ),        CONFIG_FILE     ( "Configuration file" ),        PARAM_FILE      ( "Parameter file" ),        PARAM_SET       ( "Parameter set" );    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        private Type( String text )        {            this.text = text;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Class methods    ////////////////////////////////////////////////////////////////////        public static Type get( int index )        {            return ( ((index >= 0) && (index < values( ).length)) ? values( )[index] : null );        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance methods : overriding methods    ////////////////////////////////////////////////////////////////////        public String toString( )        {            return text;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance variables    ////////////////////////////////////////////////////////////////////        private String  text;    }    //==================================================================    // ERROR IDENTIFIERS    public enum ErrorId        implements AppException.Id    {    ////////////////////////////////////////////////////////////////////    //  Constants    ////////////////////////////////////////////////////////////////////        ILLEGAL_PARAMETER_VALUE        ( "The parameter value is illegal." ),        PARAMETER_VALUE_OUT_OF_BOUNDS        ( "The parameter value is out of bounds." ),        PARAMETER_VALUES_OUT_OF_ORDER        ( "The parameter values are out of order." );    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        private ErrorId( String message )        {            this.message = message;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance methods : AppException.Id interface    ////////////////////////////////////////////////////////////////////        public String getMessage( )        {            return message;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance variables    ////////////////////////////////////////////////////////////////////        private String  message;    }    //==================================================================//////////////////////////////////////////////////////////////////////////  Member classes : non-inner classes////////////////////////////////////////////////////////////////////////    // APPLET PARAMETER CLASS    public static class AppletParam        extends Parameter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public AppletParam( JApplet applet,                            String  name )        {            super( Type.APPLET, APP_PREFIX + name,                   (applet == null) ? null : applet.getParameter( APP_PREFIX + name ) );        }        //--------------------------------------------------------------        public AppletParam( JApplet applet,                            String  name,                            int     index )        {            super( Type.APPLET, APP_PREFIX + name + index, index,                   (applet == null) ? null : applet.getParameter( APP_PREFIX + name + index ) );        }        //--------------------------------------------------------------    }    //==================================================================    // SYSTEM-PROPERTY PARAMETER CLASS    public static class PropertyParam        extends Parameter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public PropertyParam( String name )        {            super( Type.SYSTEM_PROPERTY, APP_PREFIX + name, System.getProperty( APP_PREFIX + name ) );        }        //--------------------------------------------------------------        public PropertyParam( String name,                              int    index )        {            super( Type.SYSTEM_PROPERTY, APP_PREFIX + name + index, index,                   System.getProperty( APP_PREFIX + name + index ) );        }        //--------------------------------------------------------------    }    //==================================================================    // CONFIGURATION-FILE PARAMETER CLASS    public static class ConfigFileParam        extends Parameter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public ConfigFileParam( PropertyFile configFile,                                String       name )        {            super( Type.CONFIG_FILE, name, (configFile == null) ? null : configFile.getValue( name ) );        }        //--------------------------------------------------------------        public ConfigFileParam( PropertyFile configFile,                                String       name,                                int          index )        {            super( Type.CONFIG_FILE, name, index,                   (configFile == null) ? null : configFile.getValue( name, index ) );        }        //--------------------------------------------------------------    }    //==================================================================    // PARAMETER-FILE PARAMETER CLASS    public static class ParamFileParam        extends Parameter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public ParamFileParam( PropertyFile paramFile,                               String       name )        {            super( Type.PARAM_FILE, name, (paramFile == null) ? null : paramFile.getValue( name ) );        }        //--------------------------------------------------------------        public ParamFileParam( PropertyFile paramFile,                               String       name,                               int          index )        {            super( Type.PARAM_FILE, name, index,                   (paramFile == null) ? null : paramFile.getValue( name, index ) );        }        //--------------------------------------------------------------    }    //==================================================================    // PARAMETER-SET PARAMETER CLASS    public static class ParamSetParam        extends Parameter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public ParamSetParam( Element element,                              String  name )        {            super( Type.PARAM_SET, name, ParameterSet.getValue( element, name ) );        }        //--------------------------------------------------------------        public ParamSetParam( Element element,                              String  name,                              int     index )        {            super( Type.PARAM_SET, name, index, ParameterSet.getValue( element, name, index ) );        }        //--------------------------------------------------------------    }    //==================================================================    // ILLEGAL VALUE EXCEPTION    public static class IllegalValueException        extends ParameterException    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public IllegalValueException( Parameter param )        {            super( ErrorId.ILLEGAL_PARAMETER_VALUE, param );        }        //--------------------------------------------------------------    }    //==================================================================    // VALUE OUT OF BOUNDS EXCEPTION    public static class ValueOutOfBoundsException        extends ParameterException    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        public ValueOutOfBoundsException( Parameter param )        {            super( ErrorId.PARAMETER_VALUE_OUT_OF_BOUNDS, param );        }

⌨️ 快捷键说明

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