Java Code Examples for javafx.collections.ListChangeListener.Change#getFrom()

The following examples show how to use javafx.collections.ListChangeListener.Change#getFrom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuasiListModification.java    From ReactFX with BSD 2-Clause "Simplified" License 6 votes vote down vote up
static <E, F extends E> QuasiListModification<E> fromCurrentStateOf(
        Change<F> ch) {
    List<F> list = ch.getList();
    int from = ch.getFrom();
    int addedSize = ch.getTo() - from; // use (to - from), because
                                       // ch.getAddedSize() is 0 on permutation

    List<F> removed;
    if(ch.wasPermutated()) {
        removed = new ArrayList<>(addedSize);
        for(int i = 0; i < addedSize; ++i) {
            int pi = ch.getPermutation(from + i);
            removed.add(list.get(pi));
        }
    } else {
        removed = ch.getRemoved();
    }
    return new QuasiListModificationImpl<>(from, removed, addedSize);
}
 
Example 2
Source File: ListChange.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
public ListChange(ObservableList<ObjectTag> property, Change<? extends ObjectTag> change) {
   this.property = property;
   if (change.next()) {
      if (change.wasRemoved()) {
         target = change.getRemoved().get(0);
         added = false;
      }
      else if (change.wasAdded()) {
         target = change.getAddedSubList().get(0);
         added = true;
      }
      index = change.getFrom();
   }
}
 
Example 3
Source File: Java9.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void sourceChanged(Change<? extends F> c) {
    beginChange();
    while (c.next()) {
        if (c.wasPermutated()) {
            int from = c.getFrom();
            int to = c.getTo();
            int[] perm = new int[to - from];
            for (int i = from; i < to; i++) {
                perm[i] = c.getPermutation(i);
            }
            nextPermutation(from, to, perm);
        } else if (c.wasUpdated()) {
            for (int pos = c.getFrom(); pos < c.getTo(); pos++)
                nextUpdate(pos);
        } else {
            if (c.wasAdded())
                nextAdd(c.getFrom(), c.getTo());
            if (c.wasRemoved()) {
                nextRemove(c.getFrom(), c.getRemoved().stream().map((f) -> {
                    return (E) f;
                }).collect(Collectors.toList()));
            }
        }
    }
    endChange();
}