/*
* Copyright (C) 2011 Alasdair C. Hamilton
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package ket.math.purpose.symbolicFunctions;
import java.awt.*;
import java.util.*;
import ket.display.*;
import ket.display.box.Box;
import ket.display.box.BoxList;
import ket.math.*;
import ket.math.purpose.SymbolicState;
public class SymbolicFunctionSubscript extends SymbolicFunctionForm {
@Override
public Box toBox(Argument argument, Vector<Box> boxArgs, long settings, ColourScheme colourScheme) {
if (boxArgs.size()==2) {
for (Box b : boxArgs) {
if (b.getArgument()==null) {
b.setArgument(argument);
}
}
// DRY principle; is this still the best place for that code?
Box subject = boxArgs.firstElement();
Box subscript = boxArgs.lastElement();
BoxList box = new BoxList(argument, 0L);
box.nextHorizontalPath(new Box[]{subject, subscript});
box.nextVerticalPath(new Box[]{subject});
box.nextVerticalPath(new Box[]{subscript});
subject.setProperty(Box.RIGHT_ALIGN|Box.Y_CENTRE_ALIGN);
subscript.setProperty(Box.LEFT_ALIGN|Box.BOTTOM_ALIGN|Box.SMALL_FONT);
box.setProperty(settings);
return box;
} else {
return super.toBox(argument, boxArgs, settings, colourScheme);
}
}
}