public abstract class TMFFMethod
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
maxDepth |
Constructor and Description |
---|
TMFFMethod()
Default constructor.
|
TMFFMethod(int maxDepth)
Standard constructor for TMFFMethod.
|
TMFFMethod(java.lang.String maxDepthString)
Constructor for TMFFMethod using user parameters.
|
Modifier and Type | Method and Description |
---|---|
abstract org.json.JSONArray |
asArray()
Output the array form of this method's parameters.
|
static TMFFMethod |
constructMethodWithUserParams(java.lang.String[] param)
A crude TMFFMethod factory used to construct a TMFFMethod using BatchMMJ2
RunParm values from the TMFFDefineScheme command.
|
int |
renderFormula(TMFFStateParams tmffSP,
ParseTree parseTree,
Formula formula)
Formats a formula and outputs it to a StringBuilder using the given
ParseTree root node and initial Constant of the formula.
|
protected int |
renderSubExpr(TMFFStateParams tmffSP,
ParseNode currNode,
int leftmostColNbr)
Renders a sub-expression by first attempting to output on the current
line within the maxDepth restriction; if that is not possible then it
makes a polymorphic call to render the sub-expression using line breaks.
|
protected abstract int |
renderSubExprWithBreaks(TMFFStateParams tmffSP,
ParseNode currNode,
int leftmostColNbr) |
abstract boolean |
updateMaxDepth(int maxDepth)
Updates maxDepth for a TMFFMethod if the Method allows updates.
|
static int |
validateMaxDepth(int maxDepth)
Validates the maxDepth parameter.
|
static int |
validateMaxDepth(java.lang.String maxDepthString)
Validates the maxDepth parameter.
|
public TMFFMethod()
public TMFFMethod(java.lang.String maxDepthString)
maxDepthString
- maximum sub-tree depth for a sub-expression that
will not trigger a line-break, not counting leaf nodes, and
non-Notation Syntax Axioms such as Type Conversions.public TMFFMethod(int maxDepth)
maxDepth
- maximum sub-tree depth for a sub-expression that will not
trigger a line-break, not counting leaf nodes, and
non-Notation Syntax Axioms such as Type Conversions.protected abstract int renderSubExprWithBreaks(TMFFStateParams tmffSP, ParseNode currNode, int leftmostColNbr)
public abstract boolean updateMaxDepth(int maxDepth)
As of the initial release, only TMFFAlignColumn uses maxDepth. The methods TMFFFlat and TMFFUnformatted have maxDepth = Integer.MAX_VALUE which results in no maxDepth line breaks from happening -- therefore, they do not allow updates after initial construction of the method.
maxDepth
- parameter.public abstract org.json.JSONArray asArray()
public static int validateMaxDepth(int maxDepth)
maxDepth
- parameter.public static int validateMaxDepth(java.lang.String maxDepthString)
maxDepthString
- parameter.public static TMFFMethod constructMethodWithUserParams(java.lang.String[] param)
param
- String parameter array corresponding to the BatchMMJ2
RunParm command TMFFDefineScheme.public int renderFormula(TMFFStateParams tmffSP, ParseTree parseTree, Formula formula)
This is the main method *in* TMFFMethod for formatting a formula. I
Note that if the returned number of lines = -1 the formula has not been formatted, BUT the input StringBuilder may have been updated. To deal with this, it is possible to restore the StringBuilder because output is appended to the original input. See TMFFPreverences.renderFormula() for an example.
NOTE: TMFFUnformatted AND TMFFFlat override this method!
tmffSP
- TMFFStateParams initialized, ready for use.parseTree
- for the formula to be formatted. If left null, -1 is
returned.formula
- formula to be formatted.protected int renderSubExpr(TMFFStateParams tmffSP, ParseNode currNode, int leftmostColNbr)
Note that if later we assign TMFFSchemes at the level of individual Syntax Axioms, we could modify this routine to invoke the method instance stored in an array (4 elements) inside mmj.lang.Axiom. In preparation, Format Nbr is stored inside TMFFStateParams so that the array lookup can be done -- the array index would be set at the start of formula rendering and each method would invoke the 'i-th' TMFFMethod in the current node's stmt object (except for VarHyps). Bit of work but not too hard.
tmffSP
- the TMFF state datacurrNode
- the current node of the treeleftmostColNbr
- the indent amount