Package wprover
Class CTextValue
- java.lang.Object
-
- wprover.CTextValue
-
public class CTextValue extends java.lang.ObjectCTextValue is a class that represents a mathematical expression in a tree structure. It can parse a string representation of the expression, evaluate it, and perform various mathematical functions.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]sfunction
-
Constructor Summary
Constructors Constructor Description CTextValue()Default constructor for CTextValue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static doublecal_func(int n, double v)Calculates the result of a mathematical function on a given value.voidcalculate(DrawProcess dp)Calculates the value of this CTextValue object using the specified DrawProcess.static doublecalvalue(CTextValue ct, DrawProcess dp)Calculates the value of the specified CTextValue object using the specified DrawProcess.static intgetFunction(java.lang.String s)Gets the function index for a given function name.static CTextValueparse(byte[] src, TMono index)Parses a byte array representation of a mathematical expression into a CTextValue object.static java.lang.StringparseFunction(char[] src, TMono index)Parses a function name from the source character array.static CTextValueparseString(java.lang.String str)Parses a string representation of a mathematical expression into a CTextValue object.static doubleroud3(double r)Rounds a double value to three decimal places.
-
-
-
Method Detail
-
parseString
public static CTextValue parseString(java.lang.String str)
Parses a string representation of a mathematical expression into a CTextValue object.- Parameters:
str- the string representation of the expression- Returns:
- the parsed CTextValue object
-
parse
public static CTextValue parse(byte[] src, TMono index)
Parses a byte array representation of a mathematical expression into a CTextValue object.- Parameters:
src- the byte array representation of the expressionindex- the index used for parsing- Returns:
- the parsed CTextValue object
-
getFunction
public static int getFunction(java.lang.String s)
Gets the function index for a given function name.- Parameters:
s- the function name- Returns:
- the index of the function, or -1 if not found
-
parseFunction
public static java.lang.String parseFunction(char[] src, TMono index)Parses a function name from the source character array.- Parameters:
src- the source character arrayindex- the index used for parsing- Returns:
- the parsed function name
-
roud3
public static double roud3(double r)
Rounds a double value to three decimal places.- Parameters:
r- the double value to round- Returns:
- the rounded double value
-
calculate
public void calculate(DrawProcess dp)
Calculates the value of this CTextValue object using the specified DrawProcess.- Parameters:
dp- the DrawProcess used for calculation
-
calvalue
public static double calvalue(CTextValue ct, DrawProcess dp)
Calculates the value of the specified CTextValue object using the specified DrawProcess.- Parameters:
ct- the CTextValue object to calculatedp- the DrawProcess used for calculation- Returns:
- the calculated double value
-
cal_func
public static double cal_func(int n, double v)Calculates the result of a mathematical function on a given value.- Parameters:
n- the function indexv- the value to apply the function to- Returns:
- the result of the function
-
-