@Override
public Box toBox(Argument argument, Vector<Box> boxArgs, long settings, ColourScheme colourScheme) {
if (isPrefixOnly() && f.displayBrackets()) {
// Generalization of a simple function, e.g. \alpha:(x,y).
Box boxText = getPrefix().toBox(argument,
Box.PLAIN_FONT|Box.RIGHT_ALIGN|Box.Y_CENTRE_ALIGN,
colourScheme);
Box commaArgs = BoxTools.commaList(argument, boxArgs, settings, colourScheme);
Box brackets = BoxTools.roundBrackets(argument, commaArgs, settings, colourScheme);
brackets.setArgument(argument);
brackets.setProperty(Box.VERTICAL_STRETCH);
boxText.setArgument(argument);
brackets.setArgument(argument);
return BoxTools.centredHorizontalBoxList(argument, settings, boxText, brackets);
} else {
Vector<Box> boxes = new Vector<Box>();
if (isPrefix()) {
Box pre = getPrefix().toBox(argument, Box.PLAIN_FONT, colourScheme);
//- pre.setArgument(argument);
boxes.add(pre);
}
switch ( boxArgs.size() ) {
case 0:
// Infix-only operators act like prefix operators for single arguments.
if (isInfixOnly()) {
Box inf = getInfix().toBox(argument, Box.PLAIN_FONT, colourScheme);
//- inf.setArgument(argument);
boxes.add(inf);
}
break;
case 1:
if (isInfixOnly()) {
Box inf = getInfix().toBox(argument, Box.PLAIN_FONT, colourScheme);
//- inf.setArgument(argument);
boxes.add(inf);
}
boxes.add(boxArgs.lastElement());
break;
default:
SymbolicState infixSymbol = isInfix() ? getInfix() : Symbol.COMMA;
for (int i=0; i<boxArgs.size()-1; i++) {
boxes.add(boxArgs.get(i));
Box inf = infixSymbol.toBox(argument, Box.PLAIN_FONT, colourScheme);
//- inf.setArgument(argument);
boxes.add(inf);
}
boxes.add(boxArgs.lastElement());
}
if (isPostfix()) {
Box post = getPostfix().toBox(argument, Box.PLAIN_FONT, colourScheme);
//- post.setArgument(argument);
boxes.add(post);
}
return BoxTools.centredHorizontalBoxList(argument, settings, boxes);
}