From b0cddf75f0d38c10e9e02edaf860f27a7861adb3 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 16 Sep 2017 22:25:11 -0700 Subject: [PATCH] Write a base Graph class that does some parsing of expressions. --- .../org/nwapw/abacus/fx/graphing/Graph.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 fx/src/main/kotlin/org/nwapw/abacus/fx/graphing/Graph.kt diff --git a/fx/src/main/kotlin/org/nwapw/abacus/fx/graphing/Graph.kt b/fx/src/main/kotlin/org/nwapw/abacus/fx/graphing/Graph.kt new file mode 100644 index 0000000..e7bdde1 --- /dev/null +++ b/fx/src/main/kotlin/org/nwapw/abacus/fx/graphing/Graph.kt @@ -0,0 +1,33 @@ +package org.nwapw.abacus.fx.graphing + +import org.nwapw.abacus.Abacus +import org.nwapw.abacus.config.Configuration +import org.nwapw.abacus.number.NaiveNumber +import org.nwapw.abacus.number.NumberInterface +import org.nwapw.abacus.plugin.StandardPlugin +import org.nwapw.abacus.tree.TreeNode + +class Graph(val abacus: Abacus, + expression: String, pointExpression: String, + var domain: ClosedRange, var range: ClosedRange, + var inputVariable: String = "x", var pointInputVariable: String = "n") { + + private var expressionTree: TreeNode? = null + private var pointExpressionTree: TreeNode? = null + + var expression: String = "" + set(value) { + expressionTree = abacus.parseString(value) + field = value + } + var pointExpression: String = "" + set(value) { + pointExpressionTree = abacus.parseString(value) + field = value + } + + init { + this.expression = expression + this.pointExpression = pointExpression + } +}