Class ScriptParam

  • All Implemented Interfaces:
    JmolScriptEvaluator
    Direct Known Subclasses:
    ScriptExpr

    public abstract class ScriptParam
    extends ScriptError
    The ScriptParam class holds methods used to parse parameters in Jmol scripts.
    • Field Detail

      • contextVariables

        public java.util.Map<java.lang.String,​SV> contextVariables
      • contextFunctions

        public java.util.Map<java.lang.String,​ScriptFunction> contextFunctions
      • iToken

        public int iToken
      • theTok

        public int theTok
      • theToken

        public T theToken
      • st

        public T[] st
      • slen

        public int slen
      • fractionalPoint

        public javajs.util.P3 fractionalPoint
      • coordinatesAreFractional

        public boolean coordinatesAreFractional
      • isBondSet

        public boolean isBondSet
      • pt1

        public javajs.util.P3 pt1
      • pt2

        public javajs.util.P3 pt2
      • pt3

        public javajs.util.P3 pt3
    • Constructor Detail

      • ScriptParam

        public ScriptParam()
    • Method Detail

      • tokAt

        public int tokAt​(int i)
      • checkToken

        protected boolean checkToken​(int i)
      • getParameter

        public java.lang.Object getParameter​(java.lang.String key,
                                             int tokType,
                                             boolean nullAsString)
      • getVarParameter

        protected java.lang.Object getVarParameter​(java.lang.String var,
                                                   boolean orReturnName)
      • getContextVariableAsVariable

        public SV getContextVariableAsVariable​(java.lang.String var,
                                               boolean isLocal)
      • atomCenterOrCoordinateParameter

        public javajs.util.P3 atomCenterOrCoordinateParameter​(int i,
                                                              java.lang.Object[] ret)
                                                       throws ScriptException
        Parameters:
        i -
        ret - return P3 or BS to ret[0]; on input, passing a BS as ret[1] indicates that it should be ANDED with this BS prior to calculation (SHOW/DRAW SYMOP)
        Returns:
        point -- ORIGINAL, non-copied atom, if a single atom
        Throws:
        ScriptException
      • isCenterParameter

        public boolean isCenterParameter​(int i)
      • centerParameterForModel

        protected javajs.util.P3 centerParameterForModel​(int i,
                                                         int modelIndex,
                                                         java.lang.Object[] ret)
                                                  throws ScriptException
        Throws:
        ScriptException
      • getHklPlane

        public javajs.util.P4 getHklPlane​(javajs.util.P3 pt,
                                          float offset,
                                          boolean getPts)
      • getPointOrPlane

        public java.lang.Object getPointOrPlane​(int index,
                                                boolean integerOnly,
                                                boolean allowFractional,
                                                boolean doConvert,
                                                boolean implicitFractional,
                                                int minDim,
                                                int maxDim,
                                                boolean throwE)
                                         throws ScriptException
        Throws:
        ScriptException
      • isPoint3f

        public boolean isPoint3f​(int i)
      • isFloatParameter

        public boolean isFloatParameter​(int index)
      • getPointArray

        public javajs.util.P3[] getPointArray​(int i,
                                              int nPoints,
                                              boolean allowNull)
                                       throws ScriptException
        may return null values in some cases
        Parameters:
        i -
        nPoints - -1 for unspecified number of points
        allowNull - if allowing null values (as in setting atom properties such as vxyz or xyz)
        Returns:
        array of P3, with possible null values
        Throws:
        ScriptException
      • listParameter

        public javajs.util.Lst<java.lang.Object> listParameter​(int i,
                                                               int nMin,
                                                               int nMax)
                                                        throws ScriptException
        Throws:
        ScriptException
      • listParameter4

        public javajs.util.Lst<java.lang.Object> listParameter4​(int i,
                                                                int nMin,
                                                                int nMax,
                                                                boolean allowString)
                                                         throws ScriptException
        Throws:
        ScriptException
      • floatParameterSet

        public float[] floatParameterSet​(int i,
                                         int nMin,
                                         int nMax)
                                  throws ScriptException
        process a general string or set of parameters as an array of floats, allowing for relatively free form input
        Parameters:
        i -
        nMin -
        nMax -
        Returns:
        array of floats
        Throws:
        ScriptException
      • isArrayParameter

        public boolean isArrayParameter​(int i)
      • getQuaternionParameter

        public javajs.util.Quat getQuaternionParameter​(int i,
                                                       javajs.util.BS bsAtoms,
                                                       boolean divideByCurrent)
                                                throws ScriptException
        Throws:
        ScriptException
      • getFloatEncodedInt

        static int getFloatEncodedInt​(java.lang.String strDecimal)
        Encodes a string such as "2.10" as an integer instead of a float so as to distinguish "2.1" from "2.10" used for model numbers and partial bond orders. 2147483647 is maxvalue, so this allows loading simultaneously up to 2147 files, each with 999999 models (or trajectories)
        Parameters:
        strDecimal -
        Returns:
        float encoded as an integer
      • getPartialBondOrderFromFloatEncodedInt

        public static int getPartialBondOrderFromFloatEncodedInt​(int bondOrderInteger)
        reads standard n.m float-as-integer n*1000000 + m and returns (n % 7) << 5 + (m % 0x1F)
        Parameters:
        bondOrderInteger -
        Returns:
        Bond order partial mask
      • getBondOrderFromString

        public static int getBondOrderFromString​(java.lang.String s)
      • getPartialBondOrderFromString

        private static int getPartialBondOrderFromString​(java.lang.String s)
      • isColorParam

        public boolean isColorParam​(int i)
      • tickParamAsStr

        public TickInfo tickParamAsStr​(int index,
                                       boolean allowUnitCell,
                                       boolean allowScale,
                                       boolean allowFirst)
                                throws ScriptException
        Parameters:
        index -
        allowUnitCell - IGNORED
        allowScale -
        allowFirst -
        Returns:
        TickInfo
        Throws:
        ScriptException
      • setBooleanProperty

        public void setBooleanProperty​(java.lang.String key,
                                       boolean value)
      • setIntProperty

        protected boolean setIntProperty​(java.lang.String key,
                                         int value)
      • setFloatProperty

        protected boolean setFloatProperty​(java.lang.String key,
                                           float value)
      • setStringProperty

        protected void setStringProperty​(java.lang.String key,
                                         java.lang.String value)