public static String formatByteCountToKiBEtc( long n, boolean rate, boolean bTruncateZeros) { return formatByteCountToKiBEtc(n, rate, bTruncateZeros, -1); }
@Override public String format( int value) { return DisplayFormatters.formatByteCountToKiBEtcPerSec( value ); } };
@Override public String formatDateOnly(long millis) { return DisplayFormatters.formatCustomDateOnly(millis); }
/** * Prints byte value in BITS/second in either binary or decimal units as required * @param n byte count * @return */ public static String formatByteCountToBitsPerSec2( long n) { double dbl = n * 8; int unitIndex = UNIT_B; long div = getKinB(); while (dbl >= div && unitIndex < unitsStopAt){ dbl /= div; unitIndex++; } int precision = UNITS_PRECISION[unitIndex]; return( formatDecimal(dbl, precision, true, true) + units_bits[unitIndex] + per_sec ); }
@Override public void handleEvent(Event e){ String newVal = setting.getText(); try{ int newValInt = Integer.parseInt(newVal); if( echoLbl!=null ){ echoLbl.setText( DisplayFormatters.formatByteCountToBitsPerSec2(newValInt*DisplayFormatters.getKinB())); } }catch(Throwable t){ //echo.setText(" - "); } } }//class
all_units[UNIT_TB] = getUnit("TiB"); all_units[UNIT_GB] = getUnit("GiB"); all_units[UNIT_MB] = getUnit("MiB"); all_units[UNIT_KB] = getUnit("KiB"); all_units[UNIT_B] = getUnit("B"); case UNIT_TB: units[UNIT_TB] = all_units[UNIT_TB]; units_bits[UNIT_TB] = getUnit("Tibit"); units_rate[UNIT_TB] = (use_units_rate_bits) ? getUnit("Tibit") : getUnit("TiB"); case UNIT_GB: units[UNIT_GB]= all_units[UNIT_GB]; units_bits[UNIT_GB]= getUnit("Gibit"); units_rate[UNIT_GB] = (use_units_rate_bits) ? getUnit("Gibit") : getUnit("GiB"); case UNIT_MB: units[UNIT_MB] = all_units[UNIT_MB]; units_bits[UNIT_MB] = getUnit("Mibit"); units_rate[UNIT_MB] = (use_units_rate_bits) ? getUnit("Mibit") : getUnit("MiB"); case UNIT_KB: units_bits[UNIT_KB] = getUnit("Kibit"); units_rate[UNIT_KB] = (use_units_rate_bits) ? getUnit("Kibit") : getUnit("KiB"); case UNIT_B: units[UNIT_B] =all_units[UNIT_B]; units_bits[UNIT_B] = getUnit("bit"); units_rate[UNIT_B] = (use_units_rate_bits) ? getUnit("bit") : getUnit("B"); all_units[UNIT_TB] = getUnit("TB");
String eta = DisplayFormatters.formatETA(manager.getStats().getSmoothedETA()); String data_rem = DisplayFormatters.formatByteCountToKiBEtc( rem ); String swarm_speed = DisplayFormatters.formatByteCountToKiBEtcPerSec( stats.getTotalAverage() ) + " ( " +DisplayFormatters.formatByteCountToKiBEtcPerSec( stats.getTotalAveragePerPeer())+ " " +MessageText.getString("GeneralView.label.averagespeed") + " )"; int comp = pm.getAverageCompletionInThousandNotation(); if( comp >= 0 ) { swarm_completion = DisplayFormatters.formatPercentFromThousands( comp ); int kInB = DisplayFormatters.getKinB(); DisplayFormatters.formatDownloaded(stats), DisplayFormatters.formatByteCountToKiBEtc(stats.getTotalDataBytesSent()), DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataReceiveRate()), DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataSendRate()), swarm_speed, ""+manager.getStats().getDownloadRateLimitBytesPerSecond() /kInB, peers_str, completed, DisplayFormatters.formatHashFails(manager), _shareRatio, swarm_completion, String creation_date = DisplayFormatters.formatDate(manager.getTorrentCreationDate()*1000); byte[] created_by = torrent == null ? null : torrent.getCreatedBy(); if (created_by != null) {
tt += DisplayFormatters.formatDownloadStatus( manager ) + ", " + DisplayFormatters.formatPercentFromThousands(manager.getStats().getCompleted()); DisplayFormatters.formatPercentFromThousands(target.getPercentDoneInThousandNotation()) + "\r\n" + "Up=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( stats.getDataSendRate() + stats.getProtocolSendRate()) + ", " + "Down=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( stats.getDataReceiveRate() + stats.getProtocolReceiveRate());
public static long getMinB() { long k = getKinB(); return( k * k ); }
@Override public String convert(int value) { return DisplayFormatters.formatPercentFromThousands(value); } });
public static String formatETA(long eta) { return( formatETA( eta, false )); }
/** * Format a real number to the precision specified. Does not round the number * or truncate trailing zeros. * * @param value real number to format * @param precision # of digits after the decimal place * @return formatted string */ public static String formatDecimal( double value, int precision) { return formatDecimal(value, precision, TRUNCZEROS_NO, ROUND_NO); }
public static String formatCustomDateOnly(long date) { if (date == 0) {return "";} return formatDate(date, "dd-MMM-yyyy"); }
private void refreshWrites() { int perThousands; long writesToCache = stats.getBytesWrittenToCache(); long writesToFile = stats.getBytesWrittenToFile(); long nbWritesToCache = stats.getCacheWriteCount(); long nbWritesToFile = stats.getFileWriteCount(); lblNumberWritesToCache.setText("" + nbWritesToCache); lblNumberWritesToFile.setText("" + nbWritesToFile); if(nbWritesToCache != 0) { long avgReadToCache = writesToCache / nbWritesToCache; lblAvgSizeToCache.setText(DisplayFormatters.formatByteCountToKiBEtc(avgReadToCache)); } else { lblAvgSizeToCache.setText("--"); } if(nbWritesToFile != 0) { long avgReadToFile = writesToFile / nbWritesToFile; lblAvgSizeToFile.setText(DisplayFormatters.formatByteCountToKiBEtc(avgReadToFile)); } else { lblAvgSizeToFile.setText("--"); } lblWritesToCache.setText(DisplayFormatters.formatByteCountToKiBEtc(writesToCache)); lblWritesToFile.setText(DisplayFormatters.formatByteCountToKiBEtc(writesToFile)); long totalNbWrites = nbWritesToCache + nbWritesToFile; if(totalNbWrites > 0) { perThousands = (int) ((1000l * nbWritesToCache) / totalNbWrites); lblPercentWrites.setText(DisplayFormatters.formatPercentFromThousands(perThousands) + " " + MessageText.getString("CacheView.writes.hits")); pbWrites.setSelection(perThousands); } }
result = "reserved=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( slack_bytes_per_sec ); result += ", limit=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( rate_limit ); result += ", last[choke=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( latest_choke ) + ", ratio=" + DisplayFormatters.formatDecimal(last_incomplete_average/last_complete_average, 2) + "]";
protected String getMapperTitle( SpeedManagerPingMapper mapper ) { if ( mapper.isActive()){ SpeedManagerLimitEstimate up_1 = mapper.getEstimatedUploadLimit(false); SpeedManagerLimitEstimate up_2 = mapper.getEstimatedUploadLimit(true); SpeedManagerLimitEstimate down_1 = mapper.getEstimatedDownloadLimit(false); SpeedManagerLimitEstimate down_2 = mapper.getEstimatedDownloadLimit(true); return( "ul=" + DisplayFormatters.formatByteCountToKiBEtc(up_1.getBytesPerSec()) + ":" + DisplayFormatters.formatByteCountToKiBEtc(up_2.getBytesPerSec())+ ",dl=" + DisplayFormatters.formatByteCountToKiBEtc(down_1.getBytesPerSec()) + ":" + DisplayFormatters.formatByteCountToKiBEtc(down_2.getBytesPerSec()) + ",mr=" + DisplayFormatters.formatDecimal( mapper.getCurrentMetricRating(),2)); } return( "" ); }
@Override public String getStatus(boolean localised) { return (localised)? DisplayFormatters.formatDownloadStatus( dm ) : getStatus(); }
content.append("Size:\t").append(DisplayFormatters.formatByteCountToKiBEtc(torrent.getSize())).append(", piece size=") .append(DisplayFormatters.formatByteCountToKiBEtc(torrent.getPieceLength())).append(", piece count=") .append(torrent.getPieces().length).append(NL); content.append("Created On:\t").append(DisplayFormatters.formatDate(c_date * 1000)).append(NL); content.append("\t").append(f_name).append("\t\t").append(DisplayFormatters.formatByteCountToKiBEtc(tf.getLength())) .append(NL);
@Override public void cellHover(TableCell cell) { super.cellHover(cell); Object oTooltip = cell.getToolTip(); String s = (oTooltip instanceof String) ? (String) oTooltip + "\n" : ""; DownloadManager dm = (DownloadManager) cell.getDataSource(); long dateAdded = (dm == null) ? 0 : dm.getDownloadState().getLongParameter( DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME); if (dateAdded != 0) { s += MessageText.getString("TableColumn.header.date_added") + ": " + DisplayFormatters.formatDate(dateAdded) + " (" + DisplayFormatters.formatETA((SystemTime.getCurrentTime() - dateAdded) / 1000, false) + ")"; cell.setToolTip(s); } } }
String sr_str = DisplayFormatters.formatDecimal((double) sr / 1000, 3); next_eta_str = Constants.INFINITY_STRING + ": "; }else{ next_eta_str = DisplayFormatters.formatETA(next_eta) + ": ";