/*
* 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.function;
import java.awt.*;
import java.util.*;
import ket.display.*;
import ket.display.box.Box;
import ket.display.box.BoxGraphic;
import ket.display.box.BoxList;
import ket.display.box.BoxTools;
import ket.display.box.BoxWord;
import ket.math.*;
public class FunctionBra extends FunctionForm {
@Override
public String toLatex(Vector<Argument> args) {
switch (args.size()) {
case 1:
return "\\left< " + args.get(0).toLatex() + " \\right|";
case 2:
return "\\left< " + args.get(0).toLatex() + " | " + args.get(1).toLatex() + " \\right>";
case 3:
return "\\left< " + args.get(0).toLatex() + " | " + args.get(1).toLatex() + " | " + args.get(2).toLatex() + " \\right>";
default:
return super.toLatex(args);
}
}
@Override
public String toHTML(Vector<Argument> args) {
String less = Symbol.LESS_THAN.toHTML();
String pipe = Symbol.PIPE.toHTML();
String greater = Symbol.GREATER_THAN.toHTML();
switch (args.size()) {
case 1:
return less + args.get(0).toHTML() + pipe;
case 2:
return less + args.get(0).toHTML() + pipe + args.get(1).toHTML() + greater;
case 3:
return less + args.get(0).toHTML() + pipe + args.get(1).toHTML() + pipe + args.get(2).toHTML() + greater;
default:
return super.toHTML(args);
}
}
@Override
public Box toBox(Argument argument, Vector<Box> boxArgs, long settings, ColourScheme colourScheme) {
//- Box lt = Symbol.LESS_THAN.toBox(argument, settings, colourScheme);
BoxGraphic lt = new BoxGraphic(argument, settings, BoxGraphic.BRA);
//- Box leftPipe = Symbol.PIPE.toBox(argument, settings, colourScheme);
BoxGraphic leftPipe = new BoxGraphic(argument, settings, BoxGraphic.VERTICAL_LINE);
//- Box rightPipe = Symbol.PIPE.toBox(argument, settings, colourScheme);
BoxGraphic rightPipe = new BoxGraphic(argument, settings, BoxGraphic.VERTICAL_LINE);
//- Box gt = Symbol.GREATER_THAN.toBox(argument, settings, colourScheme);
BoxGraphic gt = new BoxGraphic(argument, settings, BoxGraphic.KET);
Vector<Box> list = new Vector<Box>();
switch (boxArgs.size()) {
case 1:
list.add(lt);
list.add(boxArgs.firstElement());
list.add(leftPipe);
return BoxTools.centredHorizontalBoxList(argument, settings, list);
case 2:
list.add(lt);
list.add(boxArgs.get(0));
list.add(rightPipe);
list.add(boxArgs.get(1));
list.add(gt);
return BoxTools.centredHorizontalBoxList(argument, settings, list);
case 3:
list.add(lt);
list.add(boxArgs.get(0));
list.add(leftPipe);
list.add(boxArgs.get(1));
list.add(rightPipe);
list.add(boxArgs.get(2));
list.add(gt);
return BoxTools.centredHorizontalBoxList(argument, settings, list);
default:
return super.toBox(argument, boxArgs, settings, colourScheme);
}
}
}