Exemplo n.º 1
0
  public void updateMonitorPosition(int x, int y) {
    innerCacheArea.setLocation(x, y);
    // Check if we are outside the fullCacheArea
    //		if (!fullCacheArea.contains(innerCacheArea)) {
    service.clearHighPriorityQueue();
    checkOnReloadPrimary();

    //	}
    int cacheDistX =
        Math.min((fullCacheArea.width >> 1), fullCacheArea.width - innerCacheArea.width - 2);
    int cacheDistY =
        Math.min((fullCacheArea.height >> 1), fullCacheArea.height - innerCacheArea.height - 2);
    int fcx = x - cacheDistX;
    int fcy = y - cacheDistY;
    if (fcx < 0) fcx = 0;
    if (fullCacheArea.width >= totalGridArea.width) fcx = 0;
    if (fcy < 0) fcy = 0;
    if (fullCacheArea.height >= totalGridArea.height) fcy = 0;
    Rectangle newFullCacheArea = new Rectangle(fcx, fcy, fullCacheArea.width, fullCacheArea.height);
    if (!fullCacheArea.contains(newFullCacheArea)) {
      service.clearLowPriorityQueue();
      // compute out of cache areas
      Rectangle[] outAreas = subtraction(newFullCacheArea, fullCacheArea);
      // purge old entries from memory
      for (int i = 0; i < outAreas.length; i++) {
        Rectangle purgeArea = outAreas[i];
        for (int ry = 0; ry < purgeArea.height; ry++) {
          for (int rx = 0; rx < purgeArea.width; rx++) {
            int xPos = rx + purgeArea.x;
            int yPos = ry + purgeArea.y;
            AbstractGridEntry entry = grid.getGridEntry(xPos, yPos);
            if (entry != null) entry.deActivate();
          }
        }
      }
      // compute new need to cache areas and load
      // entries
      for (int ry = 0; ry < newFullCacheArea.height; ry++) {
        for (int rx = 0; rx < newFullCacheArea.width; rx++) {
          int xPos = rx + newFullCacheArea.x;
          int yPos = ry + newFullCacheArea.y;
          if (!innerCacheArea.contains(xPos, yPos)) {
            AbstractGridEntry entry = grid.getGridEntry(xPos, yPos);
            if (entry != null && entry.isDeactivated()) {
              service.addLoadJob(entry, false);
            }
          }
        }
      }
    }
    fullCacheArea = newFullCacheArea;
  }
Exemplo n.º 2
0
 public void stopLoading() {
   service.clearLowPriorityQueue();
   service.clearHighPriorityQueue();
 }