Package ket.math.purpose.symbolicFunctions

Source Code of ket.math.purpose.symbolicFunctions.SymbolicFunctionNorm

/*
* 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.BoxGap;
import ket.display.box.BoxGraphic;
import ket.display.box.BoxList;
import ket.display.box.BoxTools;
import ket.math.*;
import ket.math.purpose.SymbolicState;

/**
* A specific mathematical operation that acts on arguments in a case-specific
* way.
*/
public class SymbolicFunctionNorm extends SymbolicFunctionForm {

  @Override
  public String toLatex(Vector<Argument> args) {
    return super.toLatex(args);
  }

  @Override
  public String toHTML(Vector<Argument> args) {
    return super.toHTML(args);
  }

  @Override
  public Box toBox(Argument argument, long settings, ColourScheme colourScheme, Vector<Argument> args) {
    if (args.size()!=1) {
      return super.toBox(argument, settings, colourScheme, args);
    }
    Vector<Box> boxArgs = new Vector<Box>();
    long es = settings|Box.SUPPRESS_BRACKETS;
    Box arg = args.get(0).toBox(es, colourScheme);
    boxArgs.add(arg);
    return toBox(argument, boxArgs, settings, colourScheme);
  }

  @Override
  public Box toBox(Argument argument, Vector<Box> boxArgs, long settings, ColourScheme colourScheme) {
    BoxGraphic left1 = new BoxGraphic(argument, 0L, BoxGraphic.VERTICAL_LINE);
    Box left2 = new BoxGap(argument, 0L, left1, 1.0, 1.0, 0.0, 0.0);
    BoxGraphic left3 = new BoxGraphic(argument, 0L, BoxGraphic.VERTICAL_LINE);
    BoxGraphic right1 = new BoxGraphic(argument, 0L, BoxGraphic.VERTICAL_LINE);
    Box right2 = new BoxGap(argument, 0L, left1, 1.0, 1.0, 0.0, 0.0);
    BoxGraphic right3 = new BoxGraphic(argument, 0L, BoxGraphic.VERTICAL_LINE);
    Vector<Box> list = new Vector<Box>();
    list.add(left1);
    list.add(left2);
    list.add(left3);
    list.add(boxArgs.firstElement());
    list.add(right1);
    list.add(right2);
    list.add(right3);
    Box box = BoxTools.centredHorizontalBoxList(argument, settings, list);
    left1.setProperty(Box.VERTICAL_STRETCH);
    left2.setProperty(Box.VERTICAL_STRETCH);
    left3.setProperty(Box.VERTICAL_STRETCH);
    right1.setProperty(Box.VERTICAL_STRETCH);
    right2.setProperty(Box.VERTICAL_STRETCH);
    right3.setProperty(Box.VERTICAL_STRETCH);
    box.setProperty(settings);
    return box;
  }
}
TOP

Related Classes of ket.math.purpose.symbolicFunctions.SymbolicFunctionNorm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.