Package ket.math

Examples of ket.math.Equation


    public Presentation() {
      i = 0;
      loop = true;
      target = new Token(new Text("goal:"));
      argument = parse("integral(ln:x, x)");
      getSelection().getCurrent().getEquation().addBefore(new Equation(target));
      getSelection().getCurrent().getEquation().addBefore(new Equation(argument));
    }
View Full Code Here


      }
    }
    public synchronized void update() {
      // BUG: What if you've selected this?
      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);
View Full Code Here

    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);
      }
    } else {
      // Multiple lines.
      for (String next : lines) {
        Equation e = mathCollection.processLine(next);
        if (e!=null) {
          Selection selection = mathCollection.getSelection();
          Equation appendedEquation = new Equation(e.getRoot());
          selection.appendEquation(appendedEquation);
        }
      }
    }
    ketPanel.updateAndRepaint();
View Full Code Here

    ColourScheme colourScheme = getColourScheme();

    n = equations.size();
    Vector<Integer> visible = findVisibleEquationIndices();
    for (int i=0; i<n; i++) {
      Equation e = equations.get(i);
      if (e.isText()) {
        if (e.isBlankLine()) {
          sizes.add(BLANK);
        } else {
          invisibleText.add(i);
          text.add(i);
          sizes.add(TEXT);
        }
        figs.add(null);
      } else {
        args.add(i);
        invisibleArgs.add(i);
        sizes.add(e.getVisibleRoot().recursiveSize());

        // TODO: Expensive: Only evaluate for small numbers of equations.
        //> if (equations.size()<MAX_DRAW_SIZE) {
        //- figs.add(e.toBox(colourScheme).toBufferedImage(width, height, colourScheme));
        figs.add(e.toBox(colourScheme).toBufferedImage(ICON_WIDTH, ICON_HEIGHT, colourScheme, false));
        //> }
      }
    }
    invisibleArgs.removeAll(visible);
    invisibleText.removeAll(visible);
    args.retainAll(visible);
    text.retainAll(visible);
    for (Equation e : getSelectedEquations()) {
      if (e==null) continue; //?
      int v = e.getEquationIndex();
      selected.add(v);
    }
    invisibleArgs.removeAll(selected);
    invisibleText.removeAll(selected);
    args.removeAll(selected);
View Full Code Here

    toolBar.add(function);
    toolBar.add(symbolicFunctions);
  }

  private Argument cloneCurrentRoot() { // TODO: Use this here and in normal responder.
    Equation currentEquation = document.getCursor().getEquation();
    Argument root = currentEquation.getRoot();
    return Argument.cloneArgument(root);
  }
View Full Code Here

      getMathCollection().undo();
    } else if (source==mOut) {
      getDeleteMode().deleteParent();
    } else if (source==mClone) {
      Argument clone = Argument.cloneArgument(getCurrent());
      getSelection().appendEquation(new Equation(clone));
    } else if (source==mCut) {
      getDeleteMode().remove();
    } else if (source==mCompositon) {
      getAddMode().appendPurpose(chord);
    } else if (source==mState) {
View Full Code Here

TOP

Related Classes of ket.math.Equation

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.