use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class SwarmAverageSpeed method refresh.
@Override
public void refresh(TableCell cell) {
long speed = -1;
DownloadManager dm = (DownloadManager) cell.getDataSource();
if (dm != null) {
speed = dm.getStats().getTotalAveragePerPeer();
}
if (!cell.setSortValue(speed) && cell.isValid()) {
return;
}
if (speed < 0) {
cell.setText("");
} else {
cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(speed));
}
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class TagColorsItem method cellPaint.
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
List<Color> colors = new ArrayList<>();
if (dm != null) {
List<Tag> tags = tag_manager.getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL, dm);
for (Tag tag : tags) {
int[] rgb = tag.getColor();
if (rgb != null && rgb.length == 3) {
colors.add(ColorCache.getColor(gc.getDevice(), rgb));
}
}
}
int num_colors = colors.size();
if (num_colors > 0) {
Rectangle bounds = cell.getBounds();
bounds.x += 1;
bounds.y += 1;
bounds.width -= 1;
bounds.height -= 1;
if (num_colors == 1) {
gc.setBackground(colors.get(0));
gc.fillRectangle(bounds);
} else {
int width = bounds.width;
int chunk = width / num_colors;
if (chunk == 0) {
chunk = 1;
}
bounds.width = chunk;
for (int i = 0; i < num_colors; i++) {
if (i == num_colors - 1) {
int rem = width - (chunk * (num_colors - 1));
if (rem > 0) {
bounds.width = rem;
}
}
gc.setBackground(colors.get(i));
gc.fillRectangle(bounds);
bounds.x += chunk;
}
}
}
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class TimeSinceDownloadItem method refresh.
@Override
public void refresh(TableCell cell) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
int value = (dm == null) ? -2 : dm.getStats().getTimeSinceLastDataReceivedInSeconds();
if (!cell.setSortValue(value == -1 ? Integer.MAX_VALUE : value) && cell.isValid())
return;
cell.setText(value == -2 ? "" : (value == -1 ? Constants.INFINITY_STRING : TimeFormatter.format(value)));
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class TorrentCreateDateItem method refresh.
@Override
public void refresh(TableCell cell, long timestamp) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
timestamp = (dm == null) ? 0 : dm.getTorrentCreationDate();
super.refresh(cell, timestamp * 1000);
// cell.setText(DisplayFormatters.formatDate(timestamp));
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class SeedToPeerRatioItem method refresh.
@Override
public void refresh(TableCell cell) {
float ratio = -1;
DownloadManager dm = (DownloadManager) cell.getDataSource();
if (dm != null) {
TRTrackerScraperResponse response = dm.getTrackerScrapeResponse();
int seeds;
int peers;
if (response != null && response.isValid()) {
seeds = Math.max(dm.getNbSeeds(), response.getSeeds());
int trackerPeerCount = response.getPeers();
peers = dm.getNbPeers();
if (peers == 0 || trackerPeerCount > peers) {
if (trackerPeerCount <= 0) {
peers = dm.getActivationCount();
} else {
peers = trackerPeerCount;
}
}
} else {
seeds = dm.getNbSeeds();
peers = dm.getNbPeers();
}
if (peers < 0 || seeds < 0) {
ratio = 0;
} else {
if (peers == 0) {
if (seeds == 0)
ratio = 0;
else
ratio = Float.POSITIVE_INFINITY;
} else {
ratio = (float) seeds / peers;
}
}
}
if (!cell.setSortValue(ratio) && cell.isValid()) {
return;
}
if (ratio == -1) {
cell.setText("");
} else if (ratio == 0) {
cell.setText("??");
} else {
cell.setText(DisplayFormatters.formatDecimal(ratio, 3));
}
}
Aggregations