Package ket

Examples of ket.RangeSelection


  private boolean insertFromCharacter(Chord chord, KeyPress keyPress, char character, boolean addIntermediate) {
    chord.setComplete(true);
    boolean multiple = mathCollection.isRangeSelectionSet();
   
    if (character=='"' && multiple) {
      RangeSelection range = (RangeSelection) getSelection();
      Vector<Argument> roots = range.getSubbranchRoots();
      String string = "";
      for (Argument a : roots) {
        Purpose p = getCurrent().getPurpose();
        if (p instanceof Value) {
          string += ((Value) p).getValue(); // i.e. unquoted
        } else {
          string += p.toString();
        }
      }
      Token replacement = new Token(new Text(string));
      if (range.areMultipleEquationsSelected()) {
        // Remove all but one equation and replace it.
        Vector<Equation> selectedEquations = range.getSelectedEquations();
        range.setOnly(selectedEquations.firstElement().getRoot());
        for (int i=1; i<selectedEquations.size(); i++) {
          selectedEquations.get(i).removeEquation();
        }
      } else {
        // Remove all but one roots and replace it with:
        Vector<Argument> subbranchRoots = range.getSubbranchRoots();
        range.setOnly(subbranchRoots.firstElement());
        for (int i=1; i<subbranchRoots.size(); i++) {
          subbranchRoots.get(i).remove();
        }
      }
      getSelection().replace(replacement); // Now a cursor selection.
View Full Code Here


  // Identify an original function for future reference.
  private Function getReferenceFunction(boolean addIntermediate, boolean multiple) {
    if (multiple) {
      // TODO: Move this part to multiple selection model?
      RangeSelection msm = mathCollection.getRangeSelection();
      ArgumentRange argumentRange = msm.getArgumentRange();
      Vector<Argument> roots = argumentRange.getSubbranchRoots();
      if (roots!=null && roots.size()>=1) {
        Argument first = roots.firstElement();
        Parent parent = first.getParent();
        if (parent instanceof Branch) {
View Full Code Here

TOP

Related Classes of ket.RangeSelection

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.