# Class ScriptParam

java.lang.Object
org.jmol.script.ScriptError
org.jmol.script.ScriptParam

All Implemented Interfaces:
  `JmolScriptEvaluator`

Direct Known Subclasses:
  `ScriptEval`

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

## Field Summary

Fields
Modifier and Type
Field
Description
`Map<String, ScriptFunction>`
`contextFunctions`
`Map<String,SV>`
`contextVariables`
`boolean`
`coordinatesAreFractional`
set in getPointOrPlane
`P3`
`fractionalPoint`
set in getPointOrPlane
`boolean`
`isBondSet`
`int`
`iToken`
`static final int`
`MODE_P_ALLOW_FRACTIONAL`
`protected static final int`
`MODE_P_CONVERT_TO_CARTESIAN`
`protected static final int`
`MODE_P_IMPLICIT_FRACTIONAL`
`protected static final int`
`MODE_P_INT_ONLY`
`protected static final int`
`MODE_P_NULL_ON_ERROR`
`static final int`
`MODE_P3`
`static final int`
`MODE_P34`
`protected static final int`
`MODE_P4`
`int`
`slen`
`T[]`
`st`
`int`
`theTok`
`T`
`theToken`
`ScriptContext`
`thisContext`

### Fields inherited from class ScriptError

`chk, error, ERROR_badArgumentCount, ERROR_badRGBColor, ERROR_cannotSet, ERROR_endOfStatementUnexpected, ERROR_expressionExpected, ERROR_expressionOrIntegerExpected, ERROR_fileNotFoundException, ERROR_incompatibleArguments, ERROR_insufficientArguments, ERROR_invalidArgument, ERROR_invalidParameterOrder, ERROR_keywordExpected, ERROR_moCoefficients, ERROR_moIndex, ERROR_moModelError, ERROR_moOccupancy, ERROR_moOnlyOne, ERROR_multipleModelsDisplayedNotOK, ERROR_noData, ERROR_noPartialCharges, ERROR_numberExpected, ERROR_operationCanceled, ERROR_what, ERROR_writeWhat, errorMessage, errorMessageUntranslated, errorType, iCommandError, ignoreError, vwr`

## Constructor Summary

Constructors
Constructor
Description
`ScriptParam()`

## Method Summary

Modifier and Type
Method
Description
`P3`
`atomCenterOrCoordinateParameter(int i, Object[] ret)`
`P3`
`centerParameter(int i, Object[] ret)`
`protected P3`
`centerParameterForModel(int i, int modelIndex, Object[] ret)`
`T3`
`checkHKL(T3 pt)`
Note - this check does not allow a 0 for h, k, or l.
`int`
`checkLast(int i)`
`int`
`checkLength(int length)`
`int`
`checkLength23()`
`protected int`
`checkLength34()`
`int`
`checkLengthErrorPt(int length, int errorPt)`
`protected boolean`
`checkToken(int i)`
`float`
`floatParameter(int index)`
`protected float`
`floatParameterRange(int i, float min, float max)`
`float[]`
`floatParameterSet(int i, int nMin, int nMax)`
process a general string or set of parameters as an array of floats, allowing for relatively free form input
`int`
`getArgbParam(int index)`
`protected int`
`getArgbParamLast(int index, boolean allowNone)`
`int`
`getArgbParamOrNone(int index, boolean allowNone)`
`BS`
`getAtomsStartingAt(int i)`
`SV`
`getCallbackParameter(int n)`
`SV`
`getContextVariableAsVariable(String var, boolean isLocal)`
`T3`
`getFractionalPoint(int i)`
Could return a P4 for large 1100100100 type indicators
`P4`
`getHklPlane(T3 pt, float offset, Lst<P3> pts)`
`int`
`getMadParameter()`
`protected M34`
`getMatrixParam(int i, int dim, boolean throwError)`
`Object`
`getParameter(String key, int tokType, boolean nullAsString)`
`P3`
`getPoint3f(int i, boolean allowFractional, boolean throwE)`
Get an {x,y,z} value, possibly fractional, with option to throw an error.
`P4`
`getPoint4f(int i)`
`P4`
`getPoint4fNoError(int i)`
`P3[]`
`getPointArray(int i, int nPoints, boolean allowNull, boolean throwException)`
may return null values in some cases
`Lst<P3>`
`getPointOrCenterVector(T t)`
`T3`
`getPointOrPlane(int index, int mode)`
Get the point or plane at an index
`Lst<P3>`
`getPointVector(T t, int i)`
`Quat`
`getQuaternionParameter(int i, BS bsAtoms, boolean divideByCurrent)`
`T`
`getToken(int i)`
`static double`
`getTransformMatrix4(Lst<P3> ptsA, Lst<P3> ptsB, M4 m, P3 centerA)`
Fills a 4x4 matrix with rotation-translation of mapped points A to B.
`protected Object`
`getVarParameter(String var, boolean orReturnName)`
`P4`
`hklParameter(int i, Lst<P3> pts, boolean allowOffset)`
`int`
`intParameter(int index)`
`int`
`intParameterRange(int i, int min, int max)`
`boolean`
`isArrayParameter(int i)`
`boolean`
`isCenterParameter(int i)`
`boolean`
`isColorParam(int i)`
`boolean`
`isFloatParameter(int index)`
`boolean`
`isPoint3f(int i)`
`Lst<Object>`
`listParameter(int i, int nMin, int nMax)`
`Lst<Object>`
`listParameter4(int i, int nMin, int nMax, boolean allowString)`
`int`
`modelNumberParameter(int index)`
`String`
`objectNameParameter(int index)`
`String`
`optParameterAsString(int i)`
`String`
`paramAsStr(int i)`
`P4`
`planeParameter(int i, boolean isBest)`
`P4`
`planeValue(T x)`
`void`
`setBooleanProperty(String key, boolean value)`
///////////////// setting global parameters ////////////////////////
`protected boolean`
`setFloatProperty(String key, float value)`
`protected boolean`
`setIntProperty(String key, int value)`
`protected void`
`setScriptArguments(Object params, boolean isCallback)`
`protected void`
`setStringProperty(String key, String value)`
`String`
`stringParameter(int index)`
`String[]`
`stringParameterSet(int i)`
`TickInfo`
`tickParamAsStr(int index, boolean allowUnitCell, boolean allowScale, boolean allowFirst)`
`int`
`tokAt(int i)`
`static Lst<P3>`
`transformPoints(Lst<P3> vPts, M4 m4, P3 center)`
`P3`
`xypParameter(int index)`
`P4`
`xyzpParameter(int index)`

### Methods inherited from class ScriptError

`bad, error, errorStr, errorStr2, evalError, getErrorLineMessage, getErrorMessage, getErrorMessageUntranslated, integerOutOfRange, invArg, invArgStr, numberOutOfRange, setCursorWait, setErrorMessage, showStringPrint, warning`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface JmolScriptEvaluator

`checkScriptSilent, checkSelect, compileScriptString, deleteAtomsInVariables, evalFunctionFloat, evalParallel, evaluateCompiledScript, evaluateExpression, getAllowJSThreads, getAtomBitSet, getNextStatement, getScript, getScriptContext, getThisContext, haltExecution, isExecuting, isPaused, isStateScript, isStepping, isStopped, loadFileResourceAsync, notifyResumeStatus, pauseExecution, pushContextDown, resumeEval, resumePausedExecution, runScript, runScriptBuffer, setCompiler, setDebugging, setObjectPropSafe, setStatic, setViewer, stepPausedExecution, stopScriptThreads`

## Field Details

### contextVariables

public Map<String,SV> contextVariables

### contextFunctions

public Map<String, ScriptFunction> contextFunctions

### thisContext

public ScriptContext thisContext

### iToken

public int iToken

### theTok

public int theTok

### theToken

public T theToken

### st

public T[] st

### slen

public int slen

### fractionalPoint

public P3 fractionalPoint
set in getPointOrPlane

### coordinatesAreFractional

public boolean coordinatesAreFractional
set in getPointOrPlane

### isBondSet

public boolean isBondSet

### MODE_P3

public static final int MODE_P3

See Also:
  - Constant Field Values

### MODE_P4

protected static final int MODE_P4

See Also:
  - Constant Field Values

### MODE_P34

public static final int MODE_P34

See Also:
  - Constant Field Values

### MODE_P_INT_ONLY

protected static final int MODE_P_INT_ONLY

See Also:
  - Constant Field Values

### MODE_P_ALLOW_FRACTIONAL

public static final int MODE_P_ALLOW_FRACTIONAL

See Also:
  - Constant Field Values

### MODE_P_CONVERT_TO_CARTESIAN

protected static final int MODE_P_CONVERT_TO_CARTESIAN

See Also:
  - Constant Field Values

### MODE_P_IMPLICIT_FRACTIONAL

protected static final int MODE_P_IMPLICIT_FRACTIONAL

See Also:
  - Constant Field Values

### MODE_P_NULL_ON_ERROR

protected static final int MODE_P_NULL_ON_ERROR

See Also:
  - Constant Field Values

## Constructor Details

### ScriptParam

public ScriptParam()

## Method Details

### getToken

public T getToken(int i) throws ScriptException

Throws:
  `ScriptException`

### tokAt

public int tokAt(int i)

### checkToken

protected boolean checkToken(int i)

### getParameter

public Object getParameter(String key, int tokType, boolean nullAsString)

### getVarParameter

protected Object getVarParameter(String var, boolean orReturnName)

### getContextVariableAsVariable

public SV getContextVariableAsVariable(String var, boolean isLocal)

### paramAsStr

public String paramAsStr(int i) throws ScriptException

Throws:
  `ScriptException`

### stringParameter

public String stringParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### stringParameterSet

public String[] stringParameterSet(int i) throws ScriptException

Throws:
  `ScriptException`

### objectNameParameter

public String objectNameParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### atomCenterOrCoordinateParameter

public P3 atomCenterOrCoordinateParameter(int i, 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)

### centerParameter

public P3 centerParameter(int i, Object[] ret) throws ScriptException

Throws:
  `ScriptException`

### centerParameterForModel

protected P3 centerParameterForModel(int i, int modelIndex, Object[] ret) throws ScriptException

Throws:
  `ScriptException`

### planeParameter

public P4 planeParameter(int i, boolean isBest) throws ScriptException

Throws:
  `ScriptException`

### getAtomsStartingAt

public BS getAtomsStartingAt(int i) throws ScriptException

Throws:
  `ScriptException`

### getPointOrCenterVector

public Lst<P3> getPointOrCenterVector(T t) throws ScriptException

Throws:
  `ScriptException`

### hklParameter

public P4 hklParameter(int i, Lst<P3> pts, boolean allowOffset) throws ScriptException

Throws:
  `ScriptException`

### getHklPlane

public P4 getHklPlane(T3 pt, float offset, Lst<P3> pts)

### getPointOrPlane

public T3 getPointOrPlane(int index, int mode) throws ScriptException
Get the point or plane at an index

Parameters:
  `index` -
  `mode` - some combination of MODE_P options
Returns:
  P3 or P4 or null
Throws:
  `ScriptException`

### isPoint3f

public boolean isPoint3f(int i)

### getPoint3f

public P3 getPoint3f(int i, boolean allowFractional, boolean throwE) throws ScriptException
Get an {x,y,z} value, possibly fractional, with option to throw an error. Will set fractionalCoords and coordinatesAreFractional

Parameters:
  `i` -
  `allowFractional` -
  `throwE` -
Returns:
  P3
Throws:
  `ScriptException`

### getFractionalPoint

public T3 getFractionalPoint(int i) throws ScriptException
Could return a P4 for large 1100100100 type indicators

Parameters:
  `i` -
Returns:
  P3 or P4
Throws:
  `ScriptException`

### getPoint4f

public P4 getPoint4f(int i) throws ScriptException

Throws:
  `ScriptException`

### getPoint4fNoError

public P4 getPoint4fNoError(int i) throws ScriptException

Throws:
  `ScriptException`

### xypParameter

public P3 xypParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### xyzpParameter

public P4 xyzpParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### optParameterAsString

public String optParameterAsString(int i) throws ScriptException

Throws:
  `ScriptException`

### intParameter

public int intParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### isFloatParameter

public boolean isFloatParameter(int index)

### floatParameter

public float floatParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### getPointArray

public P3[] getPointArray(int i, int nPoints, boolean allowNull, boolean throwException) 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)
  `throwException` -
Returns:
  array of P3, with possible null values
Throws:
  `ScriptException`

### listParameter

public Lst<Object> listParameter(int i, int nMin, int nMax) throws ScriptException

Throws:
  `ScriptException`

### listParameter4

public Lst<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 Quat getQuaternionParameter(int i, BS bsAtoms, boolean divideByCurrent) throws ScriptException

Throws:
  `ScriptException`

### checkLast

public int checkLast(int i) throws ScriptException

Throws:
  `ScriptException`

### checkLength

public int checkLength(int length) throws ScriptException

Throws:
  `ScriptException`

### checkLengthErrorPt

public int checkLengthErrorPt(int length, int errorPt) throws ScriptException

Throws:
  `ScriptException`

### checkLength23

public int checkLength23() throws ScriptException

Throws:
  `ScriptException`

### checkLength34

protected int checkLength34() throws ScriptException

Throws:
  `ScriptException`

### modelNumberParameter

public int modelNumberParameter(int index) throws ScriptException

Throws:
  `ScriptException`

### getMadParameter

public int getMadParameter() throws ScriptException

Throws:
  `ScriptException`

### intParameterRange

public int intParameterRange(int i, int min, int max) throws ScriptException

Throws:
  `ScriptException`

### floatParameterRange

protected float floatParameterRange(int i, float min, float max) throws ScriptException

Throws:
  `ScriptException`

### getPointVector

public Lst<P3> getPointVector(T t, int i) throws ScriptException

Throws:
  `ScriptException`

### isColorParam

public boolean isColorParam(int i)

### getArgbParam

public int getArgbParam(int index) throws ScriptException

Throws:
  `ScriptException`

### getArgbParamLast

protected int getArgbParamLast(int index, boolean allowNone) throws ScriptException

Throws:
  `ScriptException`

### getArgbParamOrNone

public int getArgbParamOrNone(int index, boolean allowNone) throws ScriptException

Throws:
  `ScriptException`

### 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(String key, boolean value)
///////////////// setting global parameters ////////////////////////

### setIntProperty

protected boolean setIntProperty(String key, int value)

### setFloatProperty

protected boolean setFloatProperty(String key, float value)

### setStringProperty

protected void setStringProperty(String key, String value)

### checkHKL

public T3 checkHKL(T3 pt) throws ScriptException
Note - this check does not allow a 0 for h, k, or l.

Parameters:
  `pt` -
Returns:
  pt or throw invArg
Throws:
  `ScriptException`

### planeValue

public P4 planeValue(T x)

### transformPoints

public static Lst<P3> transformPoints(Lst<P3> vPts, M4 m4, P3 center)

### getTransformMatrix4

public static double getTransformMatrix4(Lst<P3> ptsA, Lst<P3> ptsB, M4 m, P3 centerA)
Fills a 4x4 matrix with rotation-translation of mapped points A to B. If centerA is null, this is a standard 4x4 rotation-translation matrix; otherwise, this 4x4 matrix is a rotation around a vector through the center of ptsA, and centerA is filled with that center; Prior to Jmol 14.3.12_2014.02.14, when used from the JmolScript compare() function, this method returned the second of these options instead of the first.

Parameters:
  `ptsA` -
  `ptsB` -
  `m` - 4x4 matrix to be returned
  `centerA` - return center of rotation; if null, then standard 4x4 matrix is returned
Returns:
  stdDev

### setScriptArguments

protected void setScriptArguments(Object params, boolean isCallback)

Parameters:
  `params` -
  `isCallback` - unused to date

### getCallbackParameter

public SV getCallbackParameter(int n)

### getMatrixParam

protected M34 getMatrixParam(int i, int dim, boolean throwError) throws ScriptException

Throws:
  `ScriptException`