예제 #1
0
 /** Close the pipe */
 public void close() {
   // clean up collections
   if (consumers != null) {
     consumers.clear();
     consumers = null;
   }
   if (providers != null) {
     providers.clear();
     providers = null;
   }
   if (listeners != null) {
     listeners.clear();
     listeners = null;
   }
 }
예제 #2
0
 public void reset() {
   inputEvents.clear();
   inputEventSignatures.clear();
   inputEventRegistrationsValid.clear();
   outputEvents.clear();
   listeners.clear();
 }
 public void setClients(Collection<IMailClient> clients) {
   synchronized (_mutex) {
     _clients.clear();
     _clients.addAll(clients);
     _iter = newIterator();
   }
 }
예제 #4
0
  public void setData(int width, int height, byte[] data) {
    entities.clear();
    projectiles.clear();
    animations.clear();

    chunks = new Chunk[width][height];
    for (int i = 0; i < width; i++) {
      for (int j = 0; j < height; j++) {
        chunks[i][j] = new Chunk(i, j);

        int len = Chunk.SIZE * Chunk.SIZE;
        int start = (i * height + j) * len;
        chunks[i][j].setData(Arrays.copyOfRange(data, start, start + len));
        chunks[i][j].image = null;
      }
    }
  }
예제 #5
0
  public void dispose() {
    stop();

    mListeners.clear();
    mQueue.clear();
    mWindow = null;
    mCurrentBuffer = null;
  }
예제 #6
0
  /** @param channelTopics the channelTopics to set */
  public void setChannelTopics(List<String> channelTopics) {

    m_channelTopics.clear();

    for (String topic : channelTopics) {
      m_channelTopics.add(topic);
    }
  }
 @Override
 public void reset() {
   saveData();
   if (dataSet != null) dataSet.clear();
   dataSet = null;
   header = null;
   if (headerList != null) headerList.clear();
   headerList = null;
 }
예제 #8
0
  public void init(int width, int height) {
    entities.clear();
    animations.clear();
    projectiles.clear();

    this.width = width;
    this.height = height;
    x = -(width - Game.getWidth()) / 2;
    y = -(height - Game.getHeight()) / 2;

    chunks =
        new Chunk[(int) Math.ceil(width / (float) (Chunk.SIZE * Tile.SIZE))]
            [(int) Math.ceil(height / (float) (Chunk.SIZE * Tile.SIZE))];
    for (int i = 0; i < chunks.length; i++)
      for (int j = 0; j < chunks[0].length; j++) chunks[i][j] = new Chunk(i, j);

    generate();
    render();
  }
 public void close() {
   if (!isClosed.compareAndSet(false, true)) {
     return;
   }
   for (Future f : loadAllTasks) {
     try {
       f.get(TIMEOUT, TimeUnit.SECONDS);
     } catch (Exception e) {
       throw new CacheException(e);
     }
   }
   loadAllTasks.clear();
   delegate.destroy();
   // close the configured CacheLoader
   closeCacheLoader();
   deregisterCompletionListener();
 }
 @Override
 public void clear() {
   copyOnWriteArrayList.clear();
 }
예제 #11
0
 /**
  * Setter for pipe connection events listeners
  *
  * @param newListeners Listeners
  */
 public void setListeners(List<IPipeConnectionListener> newListeners) {
   listeners.clear();
   listeners.addAll(newListeners);
 }
예제 #12
0
  public ArrayList<Band> getBands() {
    ArrayList<Band> out = new ArrayList<Band>();
    CopyOnWriteArrayList<Challenger> out2 = new CopyOnWriteArrayList<Challenger>();

    int imageWidth = this.image.getWidth();
    /** ideal - 25 minimum - 20 maximum - 30 */
    int step = 25;

    /** ideal - 4 minimum - 3 maximum - 5 */
    int countPlates = 3;
    float stickyCoef = 0.2f; // Value in percents, show coincidence between two challenger-images

    int imageWidthIteration = imageWidth / step;
    int imageLength = imageWidthIteration * step;

    // Bitmap dest = NativeGraphics.convert565to8888(image); //Preprocessing for source image
    Bitmap dest = verticalEdgeBi(image);
    // Intelligence.console.consoleBitmap(image);
    dest = NativeGraphics.treshold(dest, 80);

    /** Render processing - console */
    // ConsoleGraph cGraph = Intelligence.console.createConsoleGraph(dest, step);

    for (int i = 0; i < imageLength - step; i += step) {

      Bitmap bi = Bitmap.createBitmap(dest, i, 0, step, dest.getHeight());
      ChallengerGraph graphHandle = this.createChallengerGraph(bi);
      graphHandle.rankFilter(carsnapshot_graphrankfilter);
      graphHandle.applyProbabilityDistributor(distributor);

      for (Peak p : graphHandle.findPeaks(numberOfCandidates, 6, .55f)) {

        // cGraph.drawLine(i, p.center);

        boolean isValidPeak = false;
        for (Challenger elm : out2) {
          if (elm.addPeak(p, i)) {
            isValidPeak = true;
          } else if ((elm.getStep() < (i - step)) && elm.elems.size() < countPlates) {
            out2.remove(elm);
          }
        }
        if (!isValidPeak) {
          Challenger chlgr = new Challenger(p, i, step);
          out2.add(chlgr);
        }
      }
    }

    /** Join equal images */
    LinkedList<Challenger> out3 = new LinkedList<Challenger>();
    for (Challenger elm : out2) {
      float elmSizeX = elm.maxX - elm.minX;
      float elmSizeY = elm.maxY - elm.minY;

      if (elm.elems.size() < countPlates) continue;
      if ((elm.maxX <= elm.minX) || (elm.maxY <= elm.minY)) continue;
      if (elmSizeX / elmSizeY < 1) continue;

      boolean isOk = false;
      for (Challenger elm2 : out3) {
        float elm2SizeX = elm2.maxX - elm2.minX;
        float elm2SizeY = elm2.maxY - elm2.minY;
        float diffX = 0;
        float diffY = 0;
        if (elm2.maxY > elm.maxY) {
          diffY = elm.maxY - elm2.minY;
        } else {
          diffY = elm2.maxY - elm.minY;
        }
        if (elm2.maxX > elm.maxX) {
          diffX = elm.maxX - elm2.minX;
        } else {
          diffX = elm2.maxX - elm.minX;
        }
        if (diffY > 0
            && diffX > 0
            && (((diffY / elm2SizeY) > stickyCoef) || ((diffY / elmSizeY) > stickyCoef))
            && (((diffX / elm2SizeX) > stickyCoef) || ((diffX / elmSizeX) > stickyCoef))) {

          elm2.maxX = Math.max(elm.maxX, elm2.maxX);
          elm2.minX = Math.min(elm.minX, elm2.minX);
          elm2.maxY = Math.max(elm.maxY, elm2.maxY);
          elm2.minY = Math.min(elm.minY, elm2.minY);
          isOk = true;
        }
      }
      if (isOk == false) {
        out3.add(elm);
      }
    }
    int amplify = 3;
    /**
     * We find original picture with original dimensions and then we project work image to original
     * picture
     */
    for (Challenger elm : out3) {
      Bitmap bi = null;
      int x = 0, y = 0, w = 0, h = 0;
      float power = 1.04f;
      if (originalImage != null) {
        float coefWidth = (float) originalImage.getWidth() / (float) dest.getWidth();
        float coefHeight = (float) originalImage.getHeight() / (float) dest.getHeight();

        x = (int) (Math.max(0, elm.minX - amplify) * coefWidth);
        y = (int) (Math.max(0, elm.minY - amplify) * coefHeight);
        w = (int) (Math.max(1, elm.maxX - elm.minX + amplify) * coefWidth * power);
        h = (int) (Math.max(1, elm.maxY - elm.minY + amplify) * coefHeight * power);
      } else {
        originalImage = image;
        x = Math.max(0, elm.minX - amplify);
        y = Math.max(0, elm.minY - amplify);
        w = (int) (Math.max(1, elm.maxX - elm.minX + amplify) * power);
        h = (int) (Math.max(1, elm.maxY - elm.minY + amplify) * power);
      }

      if (x + w >= originalImage.getWidth()) continue;
      if (y + h >= originalImage.getHeight()) continue;
      bi = Bitmap.createBitmap(originalImage, x, y, w, h);

      for (Graph.Peak p : computeGraph(bi)) {
        Bitmap bi2 = Bitmap.createBitmap(bi, 0, p.getLeft(), bi.getWidth(), p.getDiff());
        out.add(new Band(bi2));
      }
    }
    out2.clear();
    out3.clear();
    Intelligence.console.clear();
    return out;
  }
예제 #13
0
 /** {@inheritDoc} */
 public void removeAllItems() {
   currentItemIndex = 0;
   items.clear();
 }
예제 #14
0
  @SubscribeEvent
  public void onWorldTick(WorldTickEvent event) {
    if (event.phase == Phase.START) {
      final WorldServer world = (WorldServer) event.world;

      CopyOnWriteArrayList<ScheduledBlockChange> changeList =
          TickHandlerServer.scheduledBlockChanges.get(world.provider.dimensionId);

      if (changeList != null && !changeList.isEmpty()) {
        int blockCount = 0;
        int blockCountMax = Math.max(this.MAX_BLOCKS_PER_TICK, changeList.size() / 4);
        List<ScheduledBlockChange> newList =
            new ArrayList<ScheduledBlockChange>(Math.max(0, changeList.size() - blockCountMax));

        for (ScheduledBlockChange change : changeList) {
          if (++blockCount > blockCountMax) {
            newList.add(change);
          } else {
            if (change != null) {
              BlockVec3 changePosition = change.getChangePosition();
              Block block = world.getBlock(changePosition.x, changePosition.y, changePosition.z);
              // Only replace blocks of type BlockAir or fire - this is to prevent accidents where
              // other mods have moved blocks
              if (changePosition != null && (block instanceof BlockAir || block == Blocks.fire)) {
                world.setBlock(
                    changePosition.x,
                    changePosition.y,
                    changePosition.z,
                    change.getChangeID(),
                    change.getChangeMeta(),
                    change.getChangeUpdateFlag());
              }
            }
          }
        }

        changeList.clear();
        TickHandlerServer.scheduledBlockChanges.remove(world.provider.dimensionId);
        if (newList.size() > 0)
          TickHandlerServer.scheduledBlockChanges.put(
              world.provider.dimensionId, new CopyOnWriteArrayList<ScheduledBlockChange>(newList));
      }

      CopyOnWriteArrayList<BlockVec3> torchList =
          TickHandlerServer.scheduledTorchUpdates.get(world.provider.dimensionId);

      if (torchList != null && !torchList.isEmpty()) {
        for (BlockVec3 torch : torchList) {
          if (torch != null) {
            Block b = world.getBlock(torch.x, torch.y, torch.z);
            if (b instanceof BlockUnlitTorch) {
              world.scheduleBlockUpdateWithPriority(
                  torch.x, torch.y, torch.z, b, 2 + world.rand.nextInt(30), 0);
            }
          }
        }

        torchList.clear();
        TickHandlerServer.scheduledTorchUpdates.remove(world.provider.dimensionId);
      }

      if (world.provider instanceof IOrbitDimension) {
        final Object[] entityList = world.loadedEntityList.toArray();

        for (final Object o : entityList) {
          if (o instanceof Entity) {
            final Entity e = (Entity) o;

            if (e.worldObj.provider instanceof IOrbitDimension) {
              final IOrbitDimension dimension = (IOrbitDimension) e.worldObj.provider;

              if (e.posY <= dimension.getYCoordToTeleportToPlanet()) {
                final Integer dim =
                    WorldUtil.getProviderForName(dimension.getPlanetToOrbit()).dimensionId;

                WorldUtil.transferEntityToDimension(e, dim, world, false, null);
              }
            }
          }
        }
      }
    } else if (event.phase == Phase.END) {
      final WorldServer world = (WorldServer) event.world;

      List<BlockVec3> edgesList = TickHandlerServer.edgeChecks.get(world.provider.dimensionId);
      final HashSet<BlockVec3> checkedThisTick = new HashSet();

      if (edgesList != null && !edgesList.isEmpty()) {
        List<BlockVec3> edgesListCopy = new ArrayList();
        edgesListCopy.addAll(edgesList);
        for (BlockVec3 edgeBlock : edgesListCopy) {
          if (edgeBlock != null && !checkedThisTick.contains(edgeBlock)) {
            if (TickHandlerServer.scheduledForChange(world.provider.dimensionId, edgeBlock)) {
              continue;
            }

            ThreadFindSeal done =
                new ThreadFindSeal(world, edgeBlock, 2000, new ArrayList<TileEntityOxygenSealer>());
            checkedThisTick.addAll(done.checked);
          }
        }

        TickHandlerServer.edgeChecks.remove(world.provider.dimensionId);
      }
    }
  }
예제 #15
0
 public void removeAllMovies() {
   movies.clear();
 }
 @Override
 public void reset() {
   if (terminalPrintedLines != null) terminalPrintedLines.clear();
   terminalPrintedLines = null;
 }
예제 #17
0
 public void close() {
   events.clear();
   listeners.clear();
   dispatchServer.shutdownNow();
 }
  @SubscribeEvent
  public void onWorldTick(WorldTickEvent event) {
    if (event.phase == Phase.START) {
      final WorldServer world = (WorldServer) event.world;

      CopyOnWriteArrayList<ScheduledBlockChange> changeList =
          TickHandlerServer.scheduledBlockChanges.get(world.provider.dimensionId);

      if (changeList != null && !changeList.isEmpty()) {
        for (ScheduledBlockChange change : changeList) {
          if (change != null) {
            BlockVec3 changePosition = change.getChangePosition();
            if (changePosition != null) {
              world.setBlock(
                  changePosition.x,
                  changePosition.y,
                  changePosition.z,
                  change.getChangeID(),
                  change.getChangeMeta(),
                  2);
            }
          }
        }

        changeList.clear();
        TickHandlerServer.scheduledBlockChanges.remove(world.provider.dimensionId);
      }

      CopyOnWriteArrayList<BlockVec3> torchList =
          TickHandlerServer.scheduledTorchUpdates.get(world.provider.dimensionId);

      if (torchList != null && !torchList.isEmpty()) {
        for (BlockVec3 torch : torchList) {
          if (torch != null) {
            if (world.getBlock(torch.x, torch.y, torch.z) == GCBlocks.unlitTorch) {
              world.scheduleBlockUpdateWithPriority(
                  torch.x, torch.y, torch.z, GCBlocks.unlitTorch, 2 + world.rand.nextInt(30), 0);
            } else if (world.getBlock(torch.x, torch.y, torch.z) == GCBlocks.unlitTorchLit) {
              world.scheduleBlockUpdateWithPriority(
                  torch.x, torch.y, torch.z, GCBlocks.unlitTorchLit, 2 + world.rand.nextInt(30), 0);
            }
          }
        }

        torchList.clear();
        TickHandlerServer.scheduledTorchUpdates.remove(world.provider.dimensionId);
      }

      if (world.provider instanceof IOrbitDimension) {
        final Object[] entityList = world.loadedEntityList.toArray();

        for (final Object o : entityList) {
          if (o instanceof Entity) {
            final Entity e = (Entity) o;

            if (e.worldObj.provider instanceof IOrbitDimension) {
              final IOrbitDimension dimension = (IOrbitDimension) e.worldObj.provider;

              if (e.posY <= dimension.getYCoordToTeleportToPlanet()) {
                final Integer dim =
                    WorldUtil.getProviderForName(dimension.getPlanetToOrbit()).dimensionId;

                WorldUtil.transferEntityToDimension(e, dim, world, false, null);
              }
            }
          }
        }
      }
    } else if (event.phase == Phase.END) {
      final WorldServer world = (WorldServer) event.world;

      List<BlockVec3> edgesList = TickHandlerServer.edgeChecks.get(world.provider.dimensionId);
      final HashSet<BlockVec3> checkedThisTick = new HashSet();

      if (edgesList != null && !edgesList.isEmpty()) {
        List<BlockVec3> edgesListCopy = new ArrayList();
        edgesListCopy.addAll(edgesList);
        for (BlockVec3 edgeBlock : edgesListCopy) {
          if (edgeBlock != null && !checkedThisTick.contains(edgeBlock)) {
            if (TickHandlerServer.scheduledForChange(world.provider.dimensionId, edgeBlock)) {
              continue;
            }

            ThreadFindSeal done =
                new ThreadFindSeal(world, edgeBlock, 2000, new ArrayList<TileEntityOxygenSealer>());
            checkedThisTick.addAll(done.checked);
          }
        }

        TickHandlerServer.edgeChecks.remove(world.provider.dimensionId);
      }
    }
  }