Java ResourceRow Example

Introduction

The java resourcerow example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: Java

Class/type: ResourceRow

Example#1
File: NetworkTimeLineDetailView.javaProject: skywhat/speedtracer

  public void refreshResource(NetworkResource resource) {
    // Short circuit if it's not in the window
    if (!isResourceInWindow(resource, oldLeft, oldRight)) {
      return;
    }

    // Always display if we haven't displayed anything yet.
    if (displayed == null) {
      displayResource(oldLeft, oldRight, resource);
      return;
    }

    boolean found = false;
    for (int i = 0, l = displayed.size(); i < l; ++i) {
      ResourceRow row = displayed.get(i);
      if (row.getResource().equals(resource)) {
        row.refresh();
        found = true;
        break;
      }
    }

    // It's in the window but not yet displayed, so create it
    if (!found) {
      displayResource(oldLeft, oldRight, resource);
    }
  }

Example#2
File: NetworkTimeLineDetailView.javaProject: skywhat/speedtracer

  /**
   * Display all resources that fall in the given window.
   *
   * @param left the left boundary
   * @param right the right boundary
   */
  protected void displayResourcesInWindow(double left, double right) {
    NetworkVisualizationModel model = getModel();
    // We dont need to update if we
    // have not shifted bounds.
    if ((displayed.size() > 0) && (left == oldLeft) && (right == oldRight)) {
      return;
    } else {
      oldLeft = left;
      oldRight = right;
    }

    // clean up Event Hookups
    for (int i = 0; i < displayed.size(); i++) {
      ResourceRow row = displayed.get(i);
      row.cleanUp();
    }

    // blank the resource Panel
    displayed.clear();
    getContentElement().setInnerHTML("");

    // We do a naive linear search until the kinks can be ironed
    // out of more sophisticated search.
    List<NetworkResource> networkResources = model.getSortedResources();
    for (int i = 0; i < networkResources.size(); i++) {
      NetworkResource resource = networkResources.get(i);
      if (isResourceInWindow(resource, left, right)) {
        displayResource(left, right, resource);
      }

      // Bail once we've hit the right edge
      if (resource.getStartTime() >= right) {
        break;
      }
    }

    if (shouldFlash) {
      CssTransitionFloat.get().transition(getElement(), "opacity", 0, 1, 200);
      shouldFlash = false;
    }
  }