Package org.gudy.azureus2.core3.peer

Examples of org.gudy.azureus2.core3.peer.PEPiece


    int  piece_number = y_block*iNumCols + x_block + first_piece;
   
    if ( piece_number >= first_piece && piece_number < first_piece + num_pieces ){
     
      DiskManagerPiece  dm_piece = dm_pieces[piece_number];
      PEPiece        pe_piece = pe_pieces[piece_number];
     
      String  text =  "Piece " + piece_number + ": " + dm_piece.getString();
     
      if ( pe_piece != null ){
       
        text += ", active: " + pe_piece.getString();

      }else{
       
        if ( dm_piece.isNeeded() && !dm_piece.isDone()){
         
View Full Code Here


      int iCol = 0;
     
      for (int i = first_piece; i < first_piece+num_pieces; i++) {
     
        DiskManagerPiece  dm_piece = dm_pieces[i];
        PEPiece        pe_piece = pe_pieces[i];
       
        int colorIndex;
     
        int iXPos = iCol * BLOCK_SIZE;
        int iYPos = iRow * BLOCK_SIZE;
 
View Full Code Here

    super("type", ALIGN_TRAIL, POSITION_LAST, 80, TableManager.TABLE_TORRENT_PIECES);
    setRefreshInterval(INTERVAL_LIVE);
  }

  public void refresh(TableCell cell) {
    PEPiece piece = (PEPiece)cell.getDataSource();
    long value = (piece == null) ? 0 : piece.getSpeed() >2 ? 1 : 0;
   
    if( !cell.setSortValue( value ) && cell.isValid() ) {
      return;
    }
   
View Full Code Here

  public BlockCountItem() {
    super("numberofblocks", ALIGN_TRAIL, POSITION_LAST, 65, TableManager.TABLE_TORRENT_PIECES);
  }

  public void refresh(TableCell cell) {
    PEPiece piece = (PEPiece)cell.getDataSource();
    long value = (piece == null) ? 0 : piece.getNbBlocks();

    if( !cell.setSortValue( value ) && cell.isValid() ) {
      return;
    }
   
View Full Code Here

      CAT_BYTES,
    });
  }

  public void refresh(TableCell cell) {
    PEPiece piece = (PEPiece)cell.getDataSource();
    long value = (piece == null) ? 0 : piece.getLength();

    if( !cell.setSortValue( value ) && cell.isValid() ) {
      return;
    }
   
View Full Code Here

      CAT_SWARM,
    });
  }

  public void refresh(TableCell cell) {
    PEPiece piece = (PEPiece)cell.getDataSource();
    long value = (piece == null) ? 0 : piece.getAvailability();

    if( !cell.setSortValue( value ) && cell.isValid() ) {
      return;
    }
   
View Full Code Here

      CAT_SWARM,
    });
  }

  public void refresh(TableCell cell) {
    PEPiece piece = (PEPiece)cell.getDataSource();
    String[] core_writers = piece.getWriters();
    String[] my_writers = new String[core_writers.length];
    int writer_count = 0;
    Map map = new HashMap();

    for(int i = 0 ; ; ) {
View Full Code Here

  }
 
  public void refresh(TableCell cell)
  {
    int  value =0;
    final PEPiece piece = (PEPiece)cell.getDataSource();
    if (piece !=null)
    {
      value =piece.getResumePriority();

      if(!cell.setSortValue(value) &&cell.isValid())
      {
        return;
      }
View Full Code Here

    }

    public void refresh(TableCell cell)
    {
        boolean value =false;
        final PEPiece pePiece =(PEPiece) cell.getDataSource();
        if (pePiece !=null)
        {
             value = pePiece.isRequested();
        }
        if (!cell.setSortValue(value ?1 :0) &&cell.isValid())
            return;
        cell.setText(value?"*" :"");
    }
View Full Code Here

    if (img != null && !img.isDisposed())
      img.dispose();
  }

  public void refresh(TableCell cell) {
    PEPiece pePiece = (PEPiece) cell.getDataSource();
    if (pePiece == null) {
      cell.setSortValue(0);
      dispose(cell);
      cell.setGraphic(null);
      return;
    }

    cell.setSortValue(pePiece.getNbWritten());
    long lNumBlocks = pePiece.getNbBlocks();

    int newWidth = cell.getWidth();
    if (newWidth <= 0) {
      dispose(cell);
      cell.setGraphic(null);
      return;
    }
    int newHeight = cell.getHeight();

    int x1 = newWidth - 2;
    int y1 = newHeight - 3;
    if (x1 < 10 || y1 < 3) {
      dispose(cell);
      cell.setGraphic(null);
      return;
    }
    Image image = new Image(SWTThread.getInstance().getDisplay(), newWidth,
        newHeight);
    Color color;
    GC gcImage = new GC(image);
    gcImage.setForeground(Colors.grey);
    gcImage.drawRectangle(0, 0, x1 + 1, y1 + 1);
    int blocksPerPixel = 0;
    int iPixelsPerBlock = 0;
    int pxRes = 0;
    long pxBlockStep = 0;
    int factor = 4;

    while (iPixelsPerBlock <= 0) {
      blocksPerPixel++;
      iPixelsPerBlock = (int) ((x1 + 1) / (lNumBlocks / blocksPerPixel));
    }

    pxRes = (int) (x1 - ((lNumBlocks / blocksPerPixel) * iPixelsPerBlock)); // kolik mi zbyde
    if (pxRes <= 0)
      pxRes = 1;
    pxBlockStep = (lNumBlocks * factor) / pxRes; // kolikaty blok na +1 k sirce
    long addBlocks = (lNumBlocks * factor) / pxBlockStep;
    if ((addBlocks * iPixelsPerBlock) > pxRes)
      pxBlockStep += 1;

    /*      String msg = "iPixelsPerBlock = "+iPixelsPerBlock + ", blocksPerPixel = " + blocksPerPixel;
          msg += ", pxRes = " + pxRes + ", pxBlockStep = " + pxBlockStep + ", addBlocks = " + addBlocks + ", x1 = " + x1;
          Debug.out(msg);*/

    TOTorrent torrent = pePiece.getManager().getDiskManager().getTorrent();

    boolean[] written = pePiece.getDMPiece().getWritten();
    boolean piece_written = pePiece.isWritten();
    int drawnWidth = 0;
    int blockStep = 0;

    int pieceNumber = pePiece.getPieceNumber();
    long[] offsets = new long[(int) lNumBlocks];
    long[] lengths = (long[]) offsets.clone();
    Arrays.fill(offsets,
        (long) pePiece.getManager().getDiskManager().getPieceLength()
            * (long) pieceNumber);
    for (int i = 0; i < lNumBlocks; lengths[i] = pePiece.getBlockSize(i), offsets[i] += DiskManager.BLOCK_SIZE * i, i++)
      ;

    boolean[] isCached = cacheStats == null ? null
        : cacheStats.getBytesInCache(torrent, offsets, lengths);

    for (int i = 0; i < lNumBlocks; i += blocksPerPixel) {
      int nextWidth = iPixelsPerBlock;

      blockStep += blocksPerPixel * factor;
      if (blockStep >= pxBlockStep) { // pokud jsem prelezl dany pocet bloku, zvys tomuhle sirku
        nextWidth += (int) (blockStep / pxBlockStep);
        blockStep -= pxBlockStep;
      }

      if (i >= lNumBlocks - blocksPerPixel) { // pokud je posledni, at zasahuje az na konec
        nextWidth = x1 - drawnWidth;
      }
      color = Colors.white;

      if ((written == null && piece_written) || (written != null && written[i])) {

        color = colors[COLOR_WRITTEN];

      } else if (pePiece.isDownloaded(i)) {

        color = colors[COLOR_DOWNLOADED];

      } else if (pePiece.isRequested(i)) {

        color = colors[COLOR_REQUESTED];
      }

      gcImage.setBackground(color);
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.peer.PEPiece

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.