Package org.waveprotocol.wave.client.paging.Traverser

Examples of org.waveprotocol.wave.client.paging.Traverser.Point


   * against a trivial brute-force implementation.
   */
  private void testStartWithin(double start, double end, double count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);
      Point expected = locateStartWithin(root, position);
      Point actual = Traverser.locateStartWithin(root, position);
      assertEquals(expected, actual);
    }
  }
View Full Code Here


   * against a trivial brute-force implementation.
   */
  private void testEndWithin(double start, double end, int count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);
      Point expected = locateEndWithin(root, position);
      Point actual = Traverser.locateEndWithin(root, position);
      assertEquals(expected, actual);
    }
  }
View Full Code Here

   * brute-force implementation.
   */
  private void testStartAfter(double start, double end, int count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);
      Point reference = locateEndWithin(root, position);
      if (reference != null) {
        testStartAfter(reference, start, end, count);
      }
    }
  }
View Full Code Here

   * brute-force implementation.
   */
  private void testEndBefore(double start, double end, int count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);
      Point reference = locateStartWithin(root, position);
      if (reference != null) {
        testEndBefore(reference, start, end, count);
      }
    }
  }
View Full Code Here

  private void testStartAfter(Point ref, double start, double end, double count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);

      // expected = null means exception expected.
      Point expected = ref.absoluteLocation() < position ? locateStartWithin(root, position) : null;
      Point actual;
      try {
        actual = Traverser.locateStartAfter(ref, position);
        assertNotNull(actual);
      } catch (IllegalArgumentException e) {
        actual = null;
View Full Code Here

  private void testEndBefore(Point ref, double start, double end, double count) {
    for (int i = 0; i < count; i++) {
      double position = start + i * (end - start) / (count - 1);

      // expected = null means exception expected.
      Point expected = ref.absoluteLocation() > position ? locateEndWithin(root, position) : null;
      Point actual;
      try {
        actual = Traverser.locateEndBefore(ref, position);
        assertNotNull(actual);
      } catch (IllegalArgumentException e) {
        actual = null;
View Full Code Here

   */
  public double activate(Region viewport) {
    PagingDebugHelper.maybeCheckBlocks(root);
    PagingDebugHelper.enterActivate();

    Point toPreserve;  // A point whose location should be preserved through paging.
    Region active = getActiveRegion();
    if (active == null) {
      // Initialize
      Point init = Traverser.locateStartWithin(root, viewport.getStart());
      if (init == null) {
        init = Traverser.locateEndWithin(root, viewport.getStart());
      }
      init(init);
      expandTo(viewport);
      // Preserve the start of the viewport. No particular reason.
      toPreserve = start;
    } else {
      // Adjust from previous state.
      switch (OverlapKind.compare(viewport, active)) {
        case FULLY_AFTER:
          Point newStart = Traverser.locateStartAfter(end, viewport.getStart());
          shrinkToEnd();
          moveActivePoint(newStart);
          expandTo(viewport);
          toPreserve = start;
          break;
        case FULLY_BEFORE:
          Point newEnd = Traverser.locateEndBefore(start, viewport.getEnd());
          shrinkToStart();
          moveActivePoint(newEnd);
          expandTo(viewport);
          toPreserve = end;
          break;
View Full Code Here

   */
  public double activate(Region viewport) {
    PagingDebugHelper.maybeCheckBlocks(root);
    PagingDebugHelper.enterActivate();

    Point toPreserve;  // A point whose location should be preserved through paging.
    Region active = getActiveRegion();
    if (active == null) {
      // Initialize
      Point init = Traverser.locateStartWithin(root, viewport.getStart());
      if (init == null) {
        init = Traverser.locateEndWithin(root, viewport.getStart());
      }
      init(init);
      expandTo(viewport);
      // Preserve the start of the viewport. No particular reason.
      toPreserve = start;
    } else {
      // Adjust from previous state.
      switch (OverlapKind.compare(viewport, active)) {
        case FULLY_AFTER:
          Point newStart = Traverser.locateStartAfter(end, viewport.getStart());
          shrinkToEnd();
          moveActivePoint(newStart);
          expandTo(viewport);
          toPreserve = start;
          break;
        case FULLY_BEFORE:
          Point newEnd = Traverser.locateEndBefore(start, viewport.getEnd());
          shrinkToStart();
          moveActivePoint(newEnd);
          expandTo(viewport);
          toPreserve = end;
          break;
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.paging.Traverser.Point

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.