📄 transferstatsview.java
字号:
autoSpeedInfoPanel.setLayout(layout);
Label label;
GridData gridData;
label = new Label(autoSpeedInfoPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.idlePing");
idlePing = new BufferedLabel(autoSpeedInfoPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
idlePing.setLayoutData(gridData);
label = new Label(autoSpeedInfoPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.maxPing");
maxPing = new BufferedLabel(autoSpeedInfoPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
maxPing.setLayoutData(gridData);
label = new Label(autoSpeedInfoPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.maxUp");
maxUp = new BufferedLabel(autoSpeedInfoPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
maxUp.setLayoutData(gridData);
label = new Label(autoSpeedInfoPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.currentPing");
currentPing = new BufferedLabel(autoSpeedInfoPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
currentPing.setLayoutData(gridData);
pingCanvas = new Canvas(autoSpeedInfoPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 8;
pingCanvas.setLayoutData(gridData);
pingGraph = PingGraphic.getInstance();
pingGraph.initialize(pingCanvas);
autoSpeedDisabledPanel = new Composite(autoSpeedPanel,SWT.NULL);
autoSpeedDisabledPanel.setLayout(new GridLayout());
Label disabled = new Label(autoSpeedDisabledPanel,SWT.NULL);
disabled.setEnabled(false);
Messages.setLanguageText(disabled,"SpeedView.stats.autospeed.disabled");
disabled.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL));
SpeedManager speedManager = core.getSpeedManager();
autoSpeedPanelLayout.topControl = speedManager.isAvailable() ? autoSpeedInfoPanel : autoSpeedDisabledPanel;
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 8;
Legend.createLegendComposite(
autoSpeedInfoPanel,
PingGraphic.colors,
new String[]{
"TransferStatsView.legend.pingaverage",
"TransferStatsView.legend.ping1",
"TransferStatsView.legend.ping2",
"TransferStatsView.legend.ping3" },
gridData );
}
public void delete() {
Utils.disposeComposite(generalPanel);
pingGraph.dispose();
}
public String getFullTitle() {
return MessageText.getString("SpeedView.title.full"); //$NON-NLS-1$
}
public Composite getComposite() {
return mainPanel;
}
public void refresh() {
refreshGeneral();
refreshPingPanel();
}
private void refreshGeneral() {
int now_prot_down_rate = stats.getProtocolReceiveRate();
int now_prot_up_rate = stats.getProtocolSendRate();
int now_total_down_rate = stats.getDataReceiveRate() + now_prot_down_rate;
int now_total_up_rate = stats.getDataSendRate() + now_prot_up_rate;
float now_perc_down = (float)(now_prot_down_rate *100) / (now_total_down_rate==0?1:now_total_down_rate);
float now_perc_up = (float)(now_prot_up_rate *100) / (now_total_up_rate==0?1:now_total_up_rate);
nowDown.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec( now_total_down_rate ) +
" (" + DisplayFormatters.formatByteCountToKiBEtcPerSec( now_prot_down_rate ) +
", " +formatter.format( now_perc_down )+ "%)" );
nowUp.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec( now_total_up_rate ) +
" (" + DisplayFormatters.formatByteCountToKiBEtcPerSec( now_prot_up_rate ) +
", " +formatter.format( now_perc_up )+ "%)" );
///////////////////////////////////////////////////////////////////////
long session_prot_received = stats.getTotalProtocolBytesReceived();
long session_prot_sent = stats.getTotalProtocolBytesSent();
long session_total_received = stats.getTotalDataBytesReceived() + session_prot_received;
long session_total_sent = stats.getTotalDataBytesSent() + session_prot_sent;
float session_perc_received = (float)(session_prot_received *100) / (session_total_received==0?1:session_total_received);
float session_perc_sent = (float)(session_prot_sent *100) / (session_total_sent==0?1:session_total_sent);
sessionDown.setText(DisplayFormatters.formatByteCountToKiBEtc( session_total_received ) +
" (" + DisplayFormatters.formatByteCountToKiBEtc( session_prot_received ) +
", " +formatter.format( session_perc_received )+ "%)" );
sessionUp.setText(DisplayFormatters.formatByteCountToKiBEtc( session_total_sent ) +
" (" + DisplayFormatters.formatByteCountToKiBEtc( session_prot_sent ) +
", " +formatter.format( session_perc_sent )+ "%)" );
////////////////////////////////////////////////////////////////////////
totalDown.setText(DisplayFormatters.formatByteCountToKiBEtc( totalStats.getDownloadedBytes() ));
totalUp.setText(DisplayFormatters.formatByteCountToKiBEtc( totalStats.getUploadedBytes() ));
sessionTime.setText( DisplayFormatters.formatETA( totalStats.getSessionUpTime() ) );
totalTime.setText( DisplayFormatters.formatETA( totalStats.getTotalUpTime() ) );
long dl_bytes = totalStats.getDownloadedBytes();
long t_ratio_raw = (1000* totalStats.getUploadedBytes() / (dl_bytes==0?1:dl_bytes) );
long s_ratio_raw = (1000* session_total_sent / (session_total_received==0?1:session_total_received) );
String t_ratio = "";
String s_ratio = "";
String partial = String.valueOf(t_ratio_raw % 1000);
while (partial.length() < 3) {
partial = "0" + partial;
}
t_ratio = (t_ratio_raw / 1000) + "." + partial;
partial = String.valueOf(s_ratio_raw % 1000);
while (partial.length() < 3) {
partial = "0" + partial;
}
s_ratio = (s_ratio_raw / 1000) + "." + partial;
total_ratio.setText( t_ratio );
session_ratio.setText( s_ratio );
}
private void refreshPingPanel() {
SpeedManager speedManager = core.getSpeedManager();
if(speedManager.isAvailable() && speedManager.isEnabled()) {
autoSpeedPanelLayout.topControl = autoSpeedInfoPanel;
autoSpeedPanel.layout();
SpeedManagerPingSource sources[] = speedManager.getPingSources();
if(sources.length > 0) {
int average = 0;
for(int i = 0 ; i < sources.length ; i++) {
average += sources[i].getPingTime();
}
average = average / sources.length;
pingGraph.refresh();
currentPing.setText(average + " ms");
idlePing.setText(speedManager.getIdlePingMillis() + " ms");
maxPing.setText(speedManager.getMaxPingMillis() + " ms");
maxUp.setText(DisplayFormatters.formatByteCountToBase10KBEtcPerSec(speedManager.getMaxUploadSpeed()));
}
} else {
autoSpeedPanelLayout.topControl = autoSpeedDisabledPanel;
autoSpeedPanel.layout();
}
}
public void periodicUpdate() {
SpeedManager speedManager = core.getSpeedManager();
if(speedManager.isAvailable() && speedManager.isEnabled()) {
SpeedManagerPingSource sources[] = speedManager.getPingSources();
if(sources.length > 0) {
int[] pings = new int[sources.length];
for(int i = 0 ; i < sources.length ; i++) {
pings[i] = sources[i].getPingTime();
}
pingGraph.addIntsValue(pings);
}
}
}
public String getData() {
return "TransferStatsView.title.full";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -