Package ket.math

Examples of ket.math.Argument


    }
  }

  public static Box derivative(Argument argument, Box dBox, int argsUpperLimit, Vector<Argument> args, long settings, ColourScheme colourScheme) {
    int lowestDerivativeIndex = (args.size()<2) ? 0 : 1;
    Argument orderArgument = ArgumentFactory.getOrderArgument(lowestDerivativeIndex, args);
    Box topD = dBox.cloneBox();
    topD.setArgument(argument);
    Vector<Box> boxArgs = BoxTools.padArgs(args, 1, colourScheme);
    Box topRowBox;
    Box orderBox;
    if (orderArgument!=null) {
      orderBox = orderArgument.toBox(settings, colourScheme);
      orderBox.clearArgument();
      if (1<args.size()) { // multiple
        topRowBox = BoxTools.centredHorizontalBoxList(argument, 0L, topD, orderBox, boxArgs.firstElement())// d ^n x
      } else {
        topRowBox = BoxTools.centredHorizontalBoxList(argument, 0L, topD, orderBox);
View Full Code Here


   * exponent], return exponent, and otherwise return null.
   */
  private static Argument getExponent(Argument argument) {
    if (argument.getFunction()==Function.POWER) {
      Branch power = (Branch) argument;
      Argument exponent = power.lastChild();
      if (power.size()==2) {
        return exponent;
      }
    }
    return null;
View Full Code Here

  /**
   * Return the order to which the given derivative is raised to of that
   * order is a function so integers orders over zero are ignored.
   */
  private static Argument getFunctionOrder(Argument derivative) {
    Argument exponent = getExponent(derivative);
    if (exponent==null) {
      return null;
    }
    Integer intExponent = getIntegerValue(exponent);
    if (intExponent==null) {
View Full Code Here

   * non-positive) exponents and return them as in a vector.
   */
  private static Vector<Argument> findFunctionOrder(int index, Vector<Argument> args) {
    Vector<Argument> orderVector = new Vector<Argument>();
    for (int i=index; i<args.size(); i++) {
      Argument order = getFunctionOrder(args.get(i));
      if (order!=null) {
        orderVector.add(order);
      }
    }
    return orderVector;
View Full Code Here

   * Given a variable, possibly raised to an arbitrary order, return
   * either its value or null if the order is non-integer or
   * not positive.
   */
  private static Integer findIntOrder(Argument derivative) {
    Argument order = getExponent(derivative);
    if (order==null) {
      // x
      return 1;
    }
    Integer intExponent = getIntegerValue(order);
View Full Code Here

      if (intOrder>1) {
        orderVector.add(new Token(intOrder));
      }
      Branch orderBranch = new Branch(Function.ADD);
      for (Argument next : orderVector) {
        Argument clone = Argument.cloneArgument(next);
        orderBranch.append(clone);
      }
      if (orderVector.size()==1) {
        return orderBranch.firstChild();
      }
View Full Code Here

      if (getSelection().getCurrent()==target || getSelection().getCurrent()==argument) {
        getSelection().appendEquation(new Equation());
      }
      synchronized (getSelection()) {
        synchronized (target) {
          Argument u = new Token(new Text((titles[i])));
          target.replace(u);
          target = u;
        }
        synchronized (argument) {
          Argument v = parse(acts[i]);
          argument.replace(v);
          argument = v;
        }
        getSelection().replace(new Token(Math.random()));
        modes.getDocument().updateAndRepaint();
View Full Code Here

    DropLocation dl = transferSupport.getDropLocation();
    Point p = dl.getDropPoint();
    Position release = new Position(p.getX(), p.getY());

    Argument finishArgument = ketPanel.findDeepestArgument(release);
    if (finishArgument==null) {
      Equation finishEquation = finishArgument!=null ?
        finishArgument.getEquation() :
        ketPanel.pointToEquation(release);
      if (finishEquation==null) {
        Ket.out.println(" !!! No argument at mouse release location !!! ");
        return false;
      }
      finishArgument = finishEquation.getRoot();
    }
    mathCollection.getSelection().setOnly(finishArgument);

    if ( ! canImport(transferSupport) ) {
      return false;
    }
    Transferable t = transferSupport.getTransferable();
    String string = null;
    try {
      string = (String) t.getTransferData(DataFlavor.stringFlavor);
    } catch (UnsupportedFlavorException e) {
      Ket.out.println(" !!! A string-flavor transfer exception occurred while reading (drag and drop) transfer data !!! ");
      return false;
    } catch (IOException ioe) {
      Ket.out.println(" !!! IO Exception while reading (drag and drop) transfer data !!! ");
      return false;
    }
    String[] lines = string.split("\n");
    // TODO: Re-join wrapped lines, 'text... \'?
    if (lines.length==1) {
      // Single line.
      Argument arg = ArgumentParser.parseArgument(string, knownArguments, clipboard, mathCollection);
      if (arg!=null) {
        Selection selection = mathCollection.getSelection();
        Equation appendedEquation = new Equation(arg);
        selection.appendEquation(appendedEquation);
      }
View Full Code Here

    g2D.drawRect(0, 0, width+2*dx, ascent+decent+2*dy);
    g2D.drawString(label, dx, ascent+dy);
  }

  public static ImageIcon asIcon(String expression, String label) {
    Argument argument = ArgumentParser.parseArgument(expression, knownArguments, null, mathCollection); // null clipboard
    Box box = argument.toBox(Box.X_CENTRE_ALIGN|Box.Y_CENTRE_ALIGN, colourScheme);
    BufferedImage image = ImageTools.boxToBufferedImage(box, 160, 120, colourScheme, false);
    labelImage(image, label);
    ImageIcon imageIcon = new ImageIcon(image);
    return imageIcon;
  }
View Full Code Here

    }
    int size = row.length;
    Argument[][] table = new Argument[args.size()][size];
    table[0] = row;
    for (int i=1; i<args.size(); i++) {
      Argument child = args.get(i);
      row = toRow(child);
      if (row==null || size!=row.length) {
        return null;
      }
      table[i] = row;
View Full Code Here

TOP

Related Classes of ket.math.Argument

Copyright © 2018 www.massapicom. 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.