Package org.jmol.script
Class ScriptEval
java.lang.Object
org.jmol.script.ScriptError
org.jmol.script.ScriptParam
org.jmol.script.ScriptEval
- All Implemented Interfaces:
JmolScriptEvaluator
-
Field Summary
FieldsModifier and TypeFieldDescriptionT[][]static intstatic final Stringstatic final Stringbooleanbooleanbooleanbooleanbooleanintintprotected Map<String, ScriptFunction> intprotected T[]booleanFields inherited from class org.jmol.script.ScriptParam
contextFunctions, contextVariables, coordinatesAreFractional, fractionalPoint, isBondSet, iToken, MODE_P_ALLOW_FRACTIONAL, MODE_P_CONVERT_TO_CARTESIAN, MODE_P_IMPLICIT_FRACTIONAL, MODE_P_INT_ONLY, MODE_P_NULL_ON_ERROR, MODE_P3, MODE_P34, MODE_P4, slen, st, theTok, theToken, thisContextFields inherited from class org.jmol.script.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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidatomExpression(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) atomExpressionAt(int index) checkFileExists(String prefix, boolean isAsync, String filename, int i, boolean doClear) checkScriptSilent(String script) a method for just checking a scriptbooleancheckSelect(Map<String, SV> h, T[] where) Check a map for a WHERE phrasevoidvoidcmdLoad()voidcmdRotate(boolean isSpin, boolean isSelected) voidvoidcmdUndoRedo(int tok) protected booleancompareFloat(int tokOperator, float a, float b) protected BScompareFloatData(int tokWhat, float[] data, int tokOperator, float comparisonFloat) booleancompileScript(String filename, String strScript, boolean debugCompiler) booleancompileScriptString(String script, boolean tQuiet) voiddelayScript(int millis) voiddeleteAtomsInVariables(BS bsDeleted) booleandispatchCommands(boolean isSpt, boolean fromFunc, boolean isTry) booleandoReport()encodeRadiusParameter(int index, boolean isOnly, boolean allowAbsolute) floatevalFunctionFloat(Object func, Object params, float[] values) booleanevalParallel(ScriptContext context, ShapeManager shapeManager) voidevaluateCompiledScript(Object[] params, boolean isCmdLine_c_or_C_Option, boolean isCmdLine_C_Option, boolean historyDisabled, boolean listCommands, SB outputBuffer, boolean allowThreads) evaluateExpression(Object expr, boolean asVariable, boolean compileOnly) a general-use method to evaluate a "SET" type expression.expandFloatArray(float[] a, int min, boolean asBS) Accepts a float array and expands [1 -3] to [1 2 3], for example.booleangetAssocArray(int i) protected BSgetAtomBits(int tokType, Object specInfo) getAtomBitSet(Object atomExpression) A general method to evaluate a string representing an atom set.getBitsetProperty(BS bs, Lst<SV> pts, int tok, P3 ptRef, P4 planeRef, Object tokenValue, Object opValue, boolean useAtomMap, int index, boolean asVectorIfAll) float[]getBitsetPropertyFloat(BS bs, int tok, String property, float min, float max) getColorRange(int i) getFullPathName(boolean withType) protected ScriptFunctiongetFunction(String sf) intwhen paused, indicates what statement will be nextP3[]protected P3getObjectCenter(String axisID, int index, int modelIndex) voidgetPartialCharges(BS bs) protected P4getPlaneForObject(String id, V3 vAB) Quat[]getQuaternionArray(Object quaternionOrSVData, int itype) getScriptContext(String why) protected static intgetSeqCode(T instruction) intgetSetAxesTypeMad10(int index) getShapeProperty(int shapeType, String propertyName) booleangetShapePropertyData(int shapeType, String propertyName, Object[] data) floatgetTranslucentLevel(int i) getUserFunctionResult(String name, Lst<SV> params, SV tokenAtom) voidbooleanisAtomExpression(int i) booleanprotected booleanisFunction(String sf) booleanisPaused()booleanbooleanbooleanloadFileAsync(String prefix, String filename, int i, boolean doClear) Allows asynchronous file loading from the LOAD or SCRIPT command.voidloadFileResourceAsync(String fileName) load a static file asynchronouslylookupIdentifierValue(String identifier) protected booleannoCopy(int i, int dir) voidprotected booleanparameterExpressionBoolean(int pt, int ptMax) parameterExpressionList(int pt, int ptAtom, boolean isArrayItem) protected booleanparameterExpressionSelect(Map<String, SV> h, T[] where) protected StringparameterExpressionString(int pt, int ptMax) protected SVparameterExpressionToken(int pt) voidpauseExecution(boolean withDelay) voidpushContextDown(String why) voidrefresh(boolean doDelay) Refresh the display NOWvoidvoidrestoreScriptContext(ScriptContext context, boolean isPopContext, boolean isFlowCommand, boolean statementOnly) voidrestrictSelected(boolean isBond, boolean doInvert) voidresumeEval(Object sco) From dispatchCommands and JmolThread resumeEval.voidvoidrunBufferedSafely(String script, SB outputBuffer) voidvoidrunScriptBuffer(String script, SB outputBuffer, boolean isFuncReturn) runs a script immediately and sends selected output to a provided SBstatic SVrunUserAction(String functionName, Object[] params, Viewer vwr) voidsetAllowJSThreads(boolean b) protected voidsetAtomProp(String prop, Object value, BS bs) voidvoidvoidsetException(ScriptException sx, String msg, String untranslated) booleansetMeshDisplayProperty(int shape, int i, int tok) voidsetObjectMad10(int iShape, String name, int mad10) setObjectPropSafe(String id, int tokCommand) called by Viewer in setting up a PyMOL scene.setShapeNameParameter(int i) voidsetShapeProperty(int shapeType, String propertyName, Object propertyValue) voidsetShapePropertyBs(int iShape, String propertyName, Object propertyValue, BS bs) voidsetShapeSizeBs(int shapeType, int size, BS bs) voidsetShapeTranslucency(int shapeType, String prefix, String translucency, float translucentLevel, BS bs) protected booleansetStatement(T[] st0, int pt0) provides support for @x and @{....} in statements.intsetStatic(int tok, int ival) set a static variable, with checking for rangesetVariable(int pt, int ptMax, String key, boolean isSet) voidshowString(String str) voidshowStringPrint(String s, boolean mustDo) static StringstatementAsString(Viewer vwr, T[] statement, int iTok, boolean doLogMessages) voidvoidtoString()booleanuseThreads(boolean allowWaitFor) Methods inherited from class org.jmol.script.ScriptParam
atomCenterOrCoordinateParameter, centerParameter, centerParameterForModel, checkHKL, checkLast, checkLength, checkLength23, checkLength34, checkLengthErrorPt, checkToken, floatParameter, floatParameterRange, floatParameterSet, getArgbParam, getArgbParamLast, getArgbParamOrNone, getAtomsStartingAt, getCallbackParameter, getContextVariableAsVariable, getFractionalPoint, getHklPlane, getMadParameter, getMatrixParam, getParameter, getPoint3f, getPoint4f, getPoint4fNoError, getPointArray, getPointOrCenterVector, getPointOrPlane, getPointVector, getQuaternionParameter, getToken, getTransformMatrix4, getVarParameter, hklParameter, intParameter, intParameterRange, isArrayParameter, isCenterParameter, isColorParam, isFloatParameter, isPoint3f, listParameter, listParameter4, modelNumberParameter, objectNameParameter, optParameterAsString, paramAsStr, planeParameter, planeValue, setBooleanProperty, setFloatProperty, setIntProperty, setScriptArguments, setStringProperty, stringParameter, stringParameterSet, tickParamAsStr, tokAt, transformPoints, xypParameter, xyzpParameterMethods inherited from class org.jmol.script.ScriptError
bad, error, errorStr, errorStr2, evalError, getErrorLineMessage, getErrorMessage, getErrorMessageUntranslated, integerOutOfRange, invArg, invArgStr, numberOutOfRange, setCursorWait, setErrorMessage, warning
-
Field Details
-
sm
-
isJS
public boolean isJS -
isFuncReturn
public boolean isFuncReturn -
historyDisabled
public boolean historyDisabled -
tQuiet
public boolean tQuiet -
compiler
-
outputBuffer
-
scriptFileName
-
functionName
-
isStateScript
public boolean isStateScript -
scriptLevel
public int scriptLevel -
CONTEXT_HOLD_QUEUE
- See Also:
-
CONTEXT_DELAY
- See Also:
-
commandHistoryLevelMax
public static int commandHistoryLevelMax -
aatoken
-
pc
public int pc -
thisCommand
-
fullCommand
-
pcResume
public int pcResume -
debugHigh
public boolean debugHigh -
privateFuncs
-
tempStatement
-
-
Constructor Details
-
ScriptEval
public ScriptEval()
-
-
Method Details
-
getAllowJSThreads
public boolean getAllowJSThreads() -
setAllowJSThreads
public void setAllowJSThreads(boolean b) -
doReport
public boolean doReport() -
isStateScript
public boolean isStateScript() -
setStatic
public int setStatic(int tok, int ival) set a static variable, with checking for range -
getScript
-
setViewer
-
setCompiler
public void setCompiler() -
compileScriptString
-
evaluateCompiledScript
-
useThreads
public boolean useThreads(boolean allowWaitFor) -
resumeEval
From dispatchCommands and JmolThread resumeEval. After throwing a ScriptInterruption, all statements following the current one are lost. When a JavaScript timeout returns from a DELAY, MOVE, MOVETO, or other sleep-requiring command, it is the ScriptContext that contains all have to worry about this, because the current thread is just put to sleep, not stopped, but in JavaScript, where we only have one thread, we need to manage this more carefully. We re-enter the halted script here, using a saved script context. The program counter is incremented to skip the initiating statement, and all parent contexts up the line are set with mustResumeEval = true.- Parameters:
sco-
-
runScript
- Throws:
ScriptException
-
runScriptBuffer
public void runScriptBuffer(String script, SB outputBuffer, boolean isFuncReturn) throws ScriptException runs a script immediately and sends selected output to a provided SB- Parameters:
script-outputBuffer-- Throws:
ScriptException
-
checkScriptSilent
a method for just checking a script- Parameters:
script-- Returns:
- a ScriptContext that indicates errors and provides a tokenized version of the script that has passed all syntax checking, both in the compiler and the evaluator
-
setDebugging
public void setDebugging() -
haltExecution
public void haltExecution() -
pauseExecution
public void pauseExecution(boolean withDelay) -
stepPausedExecution
public void stepPausedExecution() -
resumePausedExecution
public void resumePausedExecution() -
isExecuting
public boolean isExecuting() -
isPaused
public boolean isPaused() -
isStepping
public boolean isStepping() -
isStopped
public boolean isStopped() -
getNextStatement
when paused, indicates what statement will be next- Returns:
- a string indicating the statement
-
evaluateExpression
a general-use method to evaluate a "SET" type expression.- Parameters:
expr-asVariable-- Returns:
- an object of one of the following types: Boolean, Integer, Float, String, Point3f, BitSet
-
runBufferedSafely
-
runUserAction
-
checkSelect
Check a map for a WHERE phrase -
getAtomBitSet
A general method to evaluate a string representing an atom set. Excepts one atom expression or one per line as "OR". Excepts "()" as "none".- Parameters:
atomExpression-- Returns:
- is a bitset indicating the selected atoms
-
compileScript
-
evalFunctionFloat
-
getUserFunctionResult
- Throws:
ScriptException
-
clearDefinedVariableAtomSets
public void clearDefinedVariableAtomSets() -
lookupIdentifierValue
- Throws:
ScriptException
-
deleteAtomsInVariables
-
getThisContext
-
pushContextDown
-
getScriptContext
-
restoreScriptContext
public void restoreScriptContext(ScriptContext context, boolean isPopContext, boolean isFlowCommand, boolean statementOnly) -
setException
-
statementAsString
-
setObjectPropSafe
called by Viewer in setting up a PyMOL scene. -
setAtomProp
-
restrictSelected
public void restrictSelected(boolean isBond, boolean doInvert) -
showString
-
showStringPrint
- Specified by:
showStringPrintin classScriptError
-
report
-
delayScript
public void delayScript(int millis) -
evalParallel
-
loadFileResourceAsync
load a static file asynchronously- Throws:
ScriptException
-
loadFileAsync
public String loadFileAsync(String prefix, String filename, int i, boolean doClear) throws ScriptException Allows asynchronous file loading from the LOAD or SCRIPT command. Saves the context, initiates a FileLoadThread instance. When the file loading completes, the file data (sans filename) is saved in the FileManager cache under cache://localLoad_xxxxx. Context is resumed at this command in the script, and the file is then retrieved from the cache. Only run from JSmol/HTML5 when vwr.isJS; Incompatibilities: LOAD and SCRIPT commands, load() function only; only one "?" per LOAD command- Parameters:
prefix-filename- or null if end of LOAD command and now just clearing out cachei-doClear- ensures only one file is in the cache for a given type- Returns:
- cached file name if it exists
- Throws:
ScriptException
-
notifyResumeStatus
public void notifyResumeStatus() -
refresh
Refresh the display NOW- Parameters:
doDelay-- Throws:
ScriptException
-
stopScriptThreads
public void stopScriptThreads() -
getErrorLineMessage2
-
getLinenumber
-
dispatchCommands
public boolean dispatchCommands(boolean isSpt, boolean fromFunc, boolean isTry) throws ScriptException - Parameters:
isSpt-fromFunc-isTry-- Returns:
- false only when still working through resumeEval
- Throws:
ScriptException
-
cmdLoad
- Throws:
ScriptException
-
checkFileExists
public String checkFileExists(String prefix, boolean isAsync, String filename, int i, boolean doClear) throws ScriptException - Throws:
ScriptException
-
isAtomExpression
public boolean isAtomExpression(int i) -
cmdRotate
- Throws:
ScriptException
-
cmdScript
public void cmdScript(int tok, String filename, String theScript, Lst<SV> params) throws ScriptException - Throws:
ScriptException
-
cmdUndoRedo
- Throws:
ScriptException
-
getPartialCharges
- Throws:
ScriptException
-
encodeRadiusParameter
public RadiusData encodeRadiusParameter(int index, boolean isOnly, boolean allowAbsolute) throws ScriptException - Throws:
ScriptException
-
expandFloatArray
Accepts a float array and expands [1 -3] to [1 2 3], for example.- Parameters:
a-min-asBS-- Returns:
- float[] or BS
- Throws:
ScriptException
-
getColorRange
- Throws:
ScriptException
-
getFullPathName
- Throws:
ScriptException
-
getObjectBoundingBox
-
getObjectCenter
-
getPlaneForObject
-
getQuaternionArray
-
getSetAxesTypeMad10
- Throws:
ScriptException
-
getShapeProperty
-
getShapePropertyData
-
getTranslucentLevel
- Throws:
ScriptException
-
setMeshDisplayProperty
- Parameters:
shape-i-tok-- Returns:
- true if successful
- Throws:
ScriptException
-
setObjectMad10
-
setObjectProperty
- Throws:
ScriptException
-
setShapeNameParameter
- Throws:
ScriptException
-
setShapeProperty
-
setShapePropertyBs
-
setShapeSizeBs
-
setShapeTranslucency
-
toString
-
getCurrentModelFileAsString
-
getCmdExt
-
getIsoExt
-
getMathExt
-
getSmilesExt
-
parameterExpressionList
protected Lst<SV> parameterExpressionList(int pt, int ptAtom, boolean isArrayItem) throws ScriptException - Throws:
ScriptException
-
parameterExpressionString
- Throws:
ScriptException
-
parameterExpressionBoolean
- Throws:
ScriptException
-
parameterExpressionToken
- Throws:
ScriptException
-
parameterExpressionSelect
- Throws:
ScriptException
-
atomExpressionAt
- Throws:
ScriptException
-
atomExpression
public BS atomExpression(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) throws ScriptException - Parameters:
code-pcStart-pcStop-allowRefresh-allowUnderflow-ret- -- true return value; may not be a BSandNotDeleted- IGNORED- Returns:
- atom bitset
- Throws:
ScriptException
-
noCopy
protected boolean noCopy(int i, int dir) -
getAssocArray
- Throws:
ScriptException
-
listBS
-
compareFloatData
- Parameters:
tokWhat-data-tokOperator-comparisonFloat-- Returns:
- BitSet
-
compareFloat
protected boolean compareFloat(int tokOperator, float a, float b) -
getBitsetPropertyFloat
public float[] getBitsetPropertyFloat(BS bs, int tok, String property, float min, float max) throws ScriptException - Throws:
ScriptException
-
getBitsetProperty
public Object getBitsetProperty(BS bs, Lst<SV> pts, int tok, P3 ptRef, P4 planeRef, Object tokenValue, Object opValue, boolean useAtomMap, int index, boolean asVectorIfAll) throws ScriptException - Throws:
ScriptException
-
getAtomBits
-
getSeqCode
-
setVariable
- Parameters:
pt- starting point in command token sequenceptMax- ending point in command token sequenec, possibly -1 for "all"key- the variable name to save the result in. This must be a standard user variable, either local or globalisSet- from Set ... or Var .... or just xxx ....- Returns:
- a variable or null
- Throws:
ScriptException
-
setStatement
provides support for @x and @{....} in statements. The compiler passes on these, because they must be integrated with the statement dynamically.- Parameters:
st0- aaToken[i]pt0-- Returns:
- a fixed token set -- with possible overrun of unused null tokens
- Throws:
ScriptException
-
isFunction
-
addFunction
-
getFunction
-