use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class MainStatusBar method updateShareRatioStatus.
/**
* @since 3.1.1.1
*/
private void updateShareRatioStatus() {
if (overall_stats == null) {
overall_stats = StatsFactory.getStats();
if (overall_stats == null) {
return;
}
}
long ratio = (1000 * overall_stats.getUploadedBytes() / (overall_stats.getDownloadedBytes() + 1));
int sr_status;
if (ratio < 500) {
sr_status = 0;
} else if (ratio < 900) {
sr_status = 1;
} else {
sr_status = 2;
}
if (sr_status != last_sr_status) {
String imgID;
switch(sr_status) {
case 2:
imgID = "greenled";
break;
case 1:
imgID = "yellowled";
break;
default:
imgID = "redled";
break;
}
if (!imgID.equals(lastSRimageID)) {
ImageLoader imageLoader = ImageLoader.getInstance();
srStatus.setImage(imageLoader.getImage(imgID));
if (lastSRimageID != null) {
imageLoader.releaseImage(lastSRimageID);
}
lastSRimageID = imgID;
}
last_sr_status = sr_status;
}
if (ratio != last_sr_ratio) {
String tooltipID;
switch(sr_status) {
case 2:
tooltipID = "MainWindow.sr.status.tooltip.ok";
break;
case 1:
tooltipID = "MainWindow.sr.status.tooltip.poor";
break;
default:
tooltipID = "MainWindow.sr.status.tooltip.bad";
break;
}
String ratio_str = "";
String partial = "" + ratio % 1000;
while (partial.length() < 3) {
partial = "0" + partial;
}
ratio_str = (ratio / 1000) + "." + partial;
srStatus.setToolTipText(MessageText.getString(tooltipID, new String[] { ratio_str }));
last_sr_ratio = ratio;
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class MainStatusBar method updateNatStatus.
/**
* @since 3.1.1.1
*/
private void updateNatStatus() {
// NAT status Section
if (connection_manager == null) {
return;
}
Object[] o_status = connection_manager.getNATStatusEx();
int nat_status = (Integer) o_status[0];
String nat_info = (String) o_status[1];
if (nat_info == null) {
nat_info = "";
}
if (lastNATstatus != nat_status || !lastNATInfo.equals(nat_info)) {
String imgID;
String tooltipID;
String statusID;
switch(nat_status) {
case ConnectionManager.NAT_UNKNOWN:
imgID = "grayled";
tooltipID = "MainWindow.nat.status.tooltip.unknown";
statusID = "MainWindow.nat.status.unknown";
break;
case ConnectionManager.NAT_OK:
imgID = "greenled";
tooltipID = "MainWindow.nat.status.tooltip.ok";
statusID = "MainWindow.nat.status.ok";
break;
case ConnectionManager.NAT_PROBABLY_OK:
imgID = "yellowled";
tooltipID = "MainWindow.nat.status.tooltip.probok";
statusID = "MainWindow.nat.status.probok";
break;
default:
imgID = "redled";
tooltipID = "MainWindow.nat.status.tooltip.bad";
statusID = "MainWindow.nat.status.bad";
break;
}
if (!imgID.equals(lastNATimageID)) {
ImageLoader imageLoader = ImageLoader.getInstance();
natStatus.setImage(imageLoader.getImage(imgID));
if (lastNATimageID != null) {
imageLoader.releaseImage(lastNATimageID);
}
lastNATimageID = imgID;
}
String tt = MessageText.getString(tooltipID);
tt = tt.replaceAll(" \\(TCP\\)", "");
if (!nat_info.isEmpty()) {
tt += "\n" + nat_info;
}
natStatus.setToolTipText(tt);
lastNATInfo = nat_info;
natStatus.setText(MessageText.getString(statusID));
lastNATstatus = nat_status;
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class MainStatusBar method setStatusImageKey.
private void setStatusImageKey(String newStatusImageKey) {
if (("" + statusImageKey).equals("" + newStatusImageKey)) {
return;
}
ImageLoader imageLoader = ImageLoader.getInstance();
if (statusImageKey != null) {
imageLoader.releaseImage(statusImageKey);
}
statusImageKey = newStatusImageKey;
if (statusImageKey != null) {
statusImage = imageLoader.getImage(statusImageKey);
} else {
statusImage = null;
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class MainStatusBar method updateDHTStatus.
/**
* @since 3.1.1.1
*/
private void updateDHTStatus() {
if (dhtPlugin == null) {
return;
}
// DHT Status Section
int dht_status = dhtPlugin.getStatus();
long dht_count = -1;
// boolean reachable = false;
if (dht_status == DHTPlugin.STATUS_RUNNING) {
DHT[] dhts = dhtPlugin.getDHTs();
// reachable = dhts.length > 0 && dhts[0].getTransport().isReachable();
// if ( reachable ){
dht_count = dhts[0].getControl().getStats().getEstimatedDHTSize();
// }
}
if (lastDHTstatus != dht_status || lastDHTcount != dht_count) {
boolean hasImage = dhtStatus.getImage() != null;
boolean needImage = true;
switch(dht_status) {
case DHTPlugin.STATUS_RUNNING:
dhtStatus.setToolTipText(MessageText.getString("MainWindow.dht.status.tooltip"));
dhtStatus.setText(MessageText.getString("MainWindow.dht.status.users").replaceAll("%1", numberFormat.format(dht_count)));
/*
if ( reachable ){
dhtStatus.setImage(ImageRepository.getImage("greenled"));
dhtStatus.setToolTipText(MessageText
.getString("MainWindow.dht.status.tooltip"));
dhtStatus.setText(MessageText.getString("MainWindow.dht.status.users").replaceAll("%1", numberFormat.format(dht_count)));
} else {
dhtStatus.setImage(ImageRepository.getImage("yellowled"));
dhtStatus.setToolTipText(MessageText
.getString("MainWindow.dht.status.unreachabletooltip"));
dhtStatus.setText(MessageText
.getString("MainWindow.dht.status.unreachable"));
}
*/
break;
case DHTPlugin.STATUS_DISABLED:
// dhtStatus.setImage(ImageRepository.getImage("grayled"));
dhtStatus.setText(MessageText.getString("MainWindow.dht.status.disabled"));
break;
case DHTPlugin.STATUS_INITALISING:
// dhtStatus.setImage(ImageRepository.getImage("yellowled"));
dhtStatus.setText(MessageText.getString("MainWindow.dht.status.initializing"));
break;
case DHTPlugin.STATUS_FAILED:
// dhtStatus.setImage(ImageRepository.getImage("redled"));
dhtStatus.setText(MessageText.getString("MainWindow.dht.status.failed"));
break;
default:
needImage = false;
break;
}
if (hasImage != needImage) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (needImage) {
Image img = imageLoader.getImage("sb_count");
dhtStatus.setImage(img);
} else {
imageLoader.releaseImage("sb_count");
dhtStatus.setImage(null);
}
}
lastDHTstatus = dht_status;
lastDHTcount = dht_count;
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class RemotePairingWindow method setupQR.
private void setupQR(final String ac) {
if (soQR == null || soQR.isDisposed()) {
return;
}
if (USE_OUR_QR) {
new AEThread2("QRCodeGetter", true) {
@Override
public void run() {
final File qrCode = pairingManager.getQRCode();
if (qrCode == null) {
setupQR_URL(ac);
return;
}
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
try {
Display display = Display.getCurrent();
InputStream is = new FileInputStream(qrCode);
Image image = new Image(display, is);
is.close();
String id = "RemotePairing.qrCode";
ImageLoader imageLoader = skin.getImageLoader(skin.getSkinProperties());
imageLoader.addImage(id, image);
soQR.setImageByID(id, null);
} catch (Exception e) {
setupQR_URL(ac);
Debug.out(e);
}
}
});
}
}.start();
} else {
setupQR_URL(ac);
}
}
Aggregations