public class TMFFAlignColumn extends TMFFMethod
TMFFAlignColumn renders a parsed sub-expression and if the expression exceeds the input length or tree depth parameters, the sub-expression is broken up across multiple lines. Either Variables, Constants or just plain Symbols can be aligned into a single column.
The idea here is to enable use of multiple instances of TMFFAlignColumn -- and others -- customized for specific formatting schemes. TMFFAlignColumn instances vary according to 3 parameters which designate the type of symbol objects to be aligned and the starting point within a syntax axiom formula for alignment.
Example: alignAtNbr = 3 alignAtValue = Sym alignByValue = Var render "( a -> b )" as follows: "( a -> b )" where "a" and "b" are metavariables that may be replaced by sub-expressions of arbitrary length and depth. Example: alignAtNbr = 1 alignAtValue = Sym alignByValue = Cnst render "( a -> b )" as follows: "( a -> b )"
Modifier and Type | Field and Description |
---|---|
protected int |
alignAtNbr |
protected TMFFConstants.AlignType |
alignAtValue |
protected TMFFConstants.AlignType |
alignByValue |
maxDepth
Constructor and Description |
---|
TMFFAlignColumn()
Default constructor.
|
TMFFAlignColumn(int maxDepth,
java.lang.String byValue,
int atNbr,
java.lang.String atValue)
Standard constructor for TMFFAlignColumn.
|
TMFFAlignColumn(java.lang.String maxDepthString,
java.lang.String byValueString,
java.lang.String atNbrString,
java.lang.String atValueString)
Constructor for TMFFAlignColumn from user parameters.
|
Modifier and Type | Method and Description |
---|---|
org.json.JSONArray |
asArray()
Output the array form of this method's parameters.
|
static TMFFConstants.AlignType |
getAlignTypeValue(Sym sym)
Helper to calculate the arbitrary code number signifying Cnst or Var
within TMFF.
|
protected int |
renderSubExprWithBreaks(TMFFStateParams tmffSP,
ParseNode currNode,
int leftmostColNbr) |
boolean |
updateMaxDepth(int maxDepth)
Updates maxDepth for a TMFFMethod if the Method allows updates.
|
static int |
validateAtNbr(int atNbr)
Validates an alignment number.
|
static int |
validateAtNbr(java.lang.String atNbrString)
Validates an alignment number.
|
static TMFFConstants.AlignType |
validateAtValue(java.lang.String atValue)
Validates an alignment type string and converts it into the numeric
equivalent used internally by the program (sym = 1, etc.)
|
static TMFFConstants.AlignType |
validateByValue(java.lang.String byValue)
Validates an alignment type string and converts it into the enum
equivalent used internally by the program
|
constructMethodWithUserParams, renderFormula, renderSubExpr, validateMaxDepth, validateMaxDepth
protected int alignAtNbr
protected TMFFConstants.AlignType alignAtValue
protected TMFFConstants.AlignType alignByValue
public TMFFAlignColumn()
public TMFFAlignColumn(int maxDepth, java.lang.String byValue, int atNbr, java.lang.String atValue)
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.byValue
- Text indicating the alignment type when a Syntax Axiom is
split across multiple lines: 'Var', 'Cnst' or 'Sym'.atNbr
- The nth occurrence of the atValue type is where an alignment
column is positioned. Should be 1, 2, or 3.atValue
- Text indicating the type the atNbr parm refers to for
start of alignment: 'Var', 'Cnst' or 'Sym'.public TMFFAlignColumn(java.lang.String maxDepthString, java.lang.String byValueString, java.lang.String atNbrString, java.lang.String atValueString)
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.byValueString
- Text indicating the alignment type when a Syntax
Axiom is split across multiple lines: 'Var', 'Cnst' or 'Sym'.atNbrString
- The nth occurrence of the atValue type is where an
alignment column is positioned. Should be 1, 2, or 3.atValueString
- Text indicating the type the atNbr parm refers to
for start of alignment: 'Var', 'Cnst' or 'Sym'.public static TMFFConstants.AlignType getAlignTypeValue(Sym sym)
sym
- to interrogate.public static TMFFConstants.AlignType validateByValue(java.lang.String byValue)
byValue
- string: sym, var, cnst, etc.public static TMFFConstants.AlignType validateAtValue(java.lang.String atValue)
atValue
- string: sym, var, cnst, etc.public static int validateAtNbr(java.lang.String atNbrString)
atNbrString
- ought to be 1, 2, or 3 (any higher than 3 has no
apparent use.)public static int validateAtNbr(int atNbr)
atNbr
- ought to be 1, 2, or 3 (any higher than 3 has no apparent
use.)public org.json.JSONArray asArray()
TMFFMethod
asArray
in class TMFFMethod
public boolean updateMaxDepth(int maxDepth)
updateMaxDepth
in class TMFFMethod
maxDepth
- parameter.protected int renderSubExprWithBreaks(TMFFStateParams tmffSP, ParseNode currNode, int leftmostColNbr)
renderSubExprWithBreaks
in class TMFFMethod