Default Constructor super("UpRatio", ALIGN_TRAIL, POSITION_INVISIBLE, 70, table_id); setRefreshInterval(INTERVAL_LIVE);
super("UpRatio", ALIGN_TRAIL, POSITION_INVISIBLE, 70, table_id); setRefreshInterval(INTERVAL_LIVE);
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; } else if (lDivident > 0) value = Constants.INFINITY_AS_INT; } if (!cell.setSortValue((long)(value * 1000)) && cell.isValid()) return; String s; if (lDivisor <= 0) s = ""; else if (value == Constants.INFINITY_AS_INT) s = Constants.INFINITY_STRING + ":1"; else if (value == -1) s = "1:" + Constants.INFINITY_STRING; else s = DisplayFormatters.formatDecimal(value, 2) + ":1"; cell.setText(s);