Examples of PEPeer


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

      CAT_BYTES,
    });
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    long data_value = 0;
    long prot_value = 0;

    if (peer != null) {
      data_value = peer.getStats().getTotalDataBytesSent();
      prot_value = peer.getStats().getTotalProtocolBytesSent();
    }
    long sort_value;
    if (separate_prot_data_stats) {
      sort_value = (data_value << 24) + prot_value;
    } else if (data_stats_only) {
View Full Code Here

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

    super(COLUMN_ID, ALIGN_CENTER, POSITION_INVISIBLE, 20, table_id);
    setRefreshInterval(INTERVAL_LIVE);
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    long value = (peer == null) ? 0 : (peer.isChokedByMe() ? 1 : 0);

    if (!cell.setSortValue(value) && cell.isValid())
      return;

    cell.setText((value == 1) ? "*" : "");
View Full Code Here

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

    row_count++;
  }
    cell.setFillCell(true);
    Object ds = cell.getDataSource();
    if (ds instanceof PEPeer) {
      PEPeer peer = (PEPeer) ds;
      DiskManager diskmanager = peer.getManager().getDiskManager();
     
      if ( diskmanager.getRemaining() > 0 ){
        if ( !diskmanager.hasListener( this )){
          diskmanager.addListener( this );
        }
View Full Code Here

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

  public void dispose(TableCell cell) {
  synchronized( this ){
    row_count--;
  }
    // Named infoObj so code can be copied easily to the other PiecesItem
    PEPeer infoObj = (PEPeer)cell.getDataSource();
    if (infoObj == null)
      return;

    Image img = (Image)infoObj.getData("PiecesImage");
    if (img != null && !img.isDisposed())
      img.dispose();

    infoObj.setData("PiecesImageBuffer", null);
    infoObj.setData("PiecesImage", null);
  }
View Full Code Here

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

     * We store our image and imageBufer in PEPeer using
     * setData & getData.
     */

    // Named infoObj so code can be copied easily to the other PiecesItem
    PEPeer infoObj = (PEPeer)cell.getDataSource();
    long lCompleted = (infoObj == null) ? 0 : infoObj.getPercentDoneInThousandNotation();

    if( !cell.setSortValue( lCompleted ) && cell.isValid() ) {
      return;
    }
   
    if (infoObj == null)
      return;

    //Compute bounds ...
    int newWidth = cell.getWidth();
    if (newWidth <= 0)
      return;
    int newHeight = cell.getHeight();

    int x0 = borderVerticalSize;
    int x1 = newWidth - 1 - borderVerticalSize;
    int y0 = completionHeight + borderHorizontalSize + borderSplit;
    int y1 = newHeight - 1 - borderHorizontalSize;
    int drawWidth = x1 - x0 + 1;
    if (drawWidth < 10 || y1 < 3)
      return;
    int[] imageBuffer = (int [])infoObj.getData("PiecesImageBuffer");
    boolean bImageBufferValid = imageBuffer != null && imageBuffer.length == drawWidth;

    Image image = (Image)infoObj.getData("PiecesImage");
    GC gcImage;
    boolean bImageChanged;
    Rectangle imageBounds;
    if (image == null || image.isDisposed()) {
      bImageChanged = true;
    } else {
      imageBounds = image.getBounds();
      bImageChanged = imageBounds.width != newWidth ||
                      imageBounds.height != newHeight;
    }
    if (bImageChanged) {
      if (image != null && !image.isDisposed()) {
        image.dispose();
      }
      image = new Image(SWTThread.getInstance().getDisplay(),
                        newWidth, newHeight);
      imageBounds = image.getBounds();
      bImageBufferValid = false;

      // draw border
      gcImage = new GC(image);
      gcImage.setForeground(Colors.grey);
      if (borderHorizontalSize > 0) {
        if (borderVerticalSize > 0) {
          gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1);
        } else {
          gcImage.drawLine(0, 0, newWidth - 1, 0);
          gcImage.drawLine(0, newHeight -1, newWidth - 1, newHeight - 1);
        }
      } else if (borderVerticalSize > 0) {
        gcImage.drawLine(0, 0, 0, newHeight - 1);
        gcImage.drawLine(newWidth - 1, 0, newWidth - 1, newHeight - 1);
      }

      if (borderSplit > 0) {
        gcImage.setForeground(Colors.white);
        gcImage.drawLine(x0, completionHeight + borderHorizontalSize,
                         x1, completionHeight + borderHorizontalSize);
      }
    } else {
      gcImage = new GC(image);
    }

    final BitFlags peerHave = infoObj.getAvailable();
    boolean established = ((PEPeerTransport)infoObj).getConnectionState() == PEPeerTransport.CONNECTION_FULLY_ESTABLISHED;
   
    if (established && peerHave != null && peerHave.flags.length > 0) {
      if (imageBuffer == null || imageBuffer.length != drawWidth) {
        imageBuffer = new int[drawWidth];
      }
        final boolean available[] =peerHave.flags;
    try {
     
      int nbComplete = 0;
      int nbPieces = available.length;
     
      DiskManager disk_manager = infoObj.getManager().getDiskManager();
      DiskManagerPiece[]  pieces = disk_manager==null?null:disk_manager.getPieces();
                     
     
      int a0;
      int a1 = 0;
      for (int i = 0; i < drawWidth; i++) {
        if (i == 0) {
          // always start out with one piece
          a0 = 0;
          a1 = nbPieces / drawWidth;
          if (a1 == 0)
            a1 = 1;
        } else {
          // the last iteration, a1 will be nbPieces
          a0 = a1;
          a1 = ((i + 1) * nbPieces) / (drawWidth);
        }

        int index;
        int nbNeeded = 0;

        if (a1 <= a0) {
          index = imageBuffer[i - 1];
        } else {
          int nbAvailable = 0;
          for (int j = a0; j < a1; j++) {
            if (available[j]) {
              if (pieces==null || !pieces[j].isDone()) {
                nbNeeded++;
              }
              nbAvailable++;
            }
          }
          nbComplete += nbAvailable;
          index = (nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0);
          if (nbNeeded <= nbAvailable / 2)
            index += INDEX_COLOR_FADEDSTARTS;
        }

        if (imageBuffer[i] != index) {
          imageBuffer[i] = index;
          if (bImageBufferValid) {
            bImageChanged = true;
            if (imageBuffer[i] >= INDEX_COLOR_FADEDSTARTS)
              gcImage.setForeground(Colors.faded[index - INDEX_COLOR_FADEDSTARTS]);
            else
              gcImage.setForeground(Colors.blues[index]);
            gcImage.drawLine(i + x0, y0, i + x0, y1);
          }
        }
      }
      if (!bImageBufferValid) {
        if(established) {
          int iLastIndex = imageBuffer[0];
          int iWidth = 1;
          for (int i = 1; i < drawWidth; i++) {
            if (iLastIndex == imageBuffer[i]) {
              iWidth++;
            } else {
              if (iLastIndex >= INDEX_COLOR_FADEDSTARTS) {
                gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
              } else
                gcImage.setBackground(Colors.blues[iLastIndex]);
              gcImage.fillRectangle(i - iWidth + x0, y0, iWidth, y1 - y0 + 1);
              iWidth = 1;
              iLastIndex = imageBuffer[i];
            }
          }
          if (iLastIndex >= INDEX_COLOR_FADEDSTARTS)
            gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
          else
            gcImage.setBackground(Colors.blues[iLastIndex]);
          gcImage.fillRectangle(x1 - iWidth + 1, y0, iWidth, y1 - y0 + 1);
          bImageChanged = true;
        }
      }

      int limit = (drawWidth * nbComplete) / nbPieces;
      if (limit < drawWidth) {
        gcImage.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
        gcImage.fillRectangle(limit+x0, borderHorizontalSize,
                              x1-limit, completionHeight);
      }
      gcImage.setBackground(Colors.colorProgressBar);
      gcImage.fillRectangle(x0, borderHorizontalSize,
                            limit, completionHeight);
    } catch (Exception e) {
      System.out.println("Error Drawing PiecesItem");
      Debug.printStackTrace( e );
    } } else {
        gcImage.setForeground(Colors.grey);
        gcImage.setBackground(Colors.grey);
        gcImage.fillRectangle(x0,y0,newWidth,y1);
    }
    gcImage.dispose();

    Image oldImage = null;
    Graphic graphic = cell.getGraphic();
    if (graphic instanceof UISWTGraphic) {
      oldImage = ((UISWTGraphic) graphic).getImage();
    }
    if (bImageChanged || image != oldImage || !cell.isValid()) {
      if (cell instanceof TableCellSWT) {
        ((TableCellSWT) cell).setGraphic(image);
      } else {
        cell.setGraphic(new UISWTGraphicImpl(image));
      }
      if (bImageChanged || image != oldImage) {
        cell.invalidate();
      }
      infoObj.setData("PiecesImage", image);
      infoObj.setData("PiecesImageBuffer", imageBuffer);
    }
  }
View Full Code Here

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

      CAT_CONTENT,
    });
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    long value = (peer == null) ? 0 : peer.getUniqueAnnounce();

    if (!cell.setSortValue(value) && cell.isValid())
      return;

    cell.setText((value == -1) ? MessageText.getString("PeersView.uniquepiece.none")
View Full Code Here

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

      CAT_SHARING,
    });
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    float value = 0;
    long lDivisor = 0;
    long lDivident = 0;
    if (peer != null) {
      lDivisor = peer.getStats().getTotalBytesDownloadedByPeer() - peer.getStats().getTotalDataBytesSent();
      lDivident = peer.getStats().getTotalDataBytesSent();
      // skip if divisor is small (most likely handshake) or 0 (DivisionByZero)
      if (lDivisor > 1024) {
        value = lDivident / (float)lDivisor;
        if (value == 0)
          value = -1;
View Full Code Here

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

      CAT_CONTENT,
    });
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    int value = (peer == null) ? 0 : peer.getLastPiece();

    if (!cell.setSortValue(value) && cell.isValid())
      return;

    cell.setText(""+value);
View Full Code Here

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

    super(COLUMN_ID, ALIGN_TRAIL, POSITION_INVISIBLE, 35, table_id);
    setRefreshInterval(INTERVAL_LIVE);
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    long value = (peer == null) ? 0 : peer.getStats().getDownloadRateLimitBytesPerSecond();
    if (!cell.setSortValue(value) && cell.isValid())
      return;
   
    if(value == -1) {
      cell.setText(MessageText.getString("MyTorrents.items.DownSpeedLimit.disabled"));
View Full Code Here

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

    super(COLUMN_ID, ALIGN_CENTER, POSITION_INVISIBLE, 40, table_id);
    setRefreshInterval(INTERVAL_LIVE);
  }

  public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer)cell.getDataSource();
    int value = (peer == null) ? -1 : peer.getMessagingMode();

    if (!cell.setSortValue(value) && cell.isValid())
      return;
   
    String text;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.