TransferStatsViewpublic class TransferStatsView extends org.gudy.azureus2.ui.swt.views.AbstractIView
Fields Summary |
---|
org.gudy.azureus2.core3.global.GlobalManager | manager | com.aelitis.azureus.core.AzureusCore | core | org.gudy.azureus2.core3.global.GlobalManagerStats | stats | com.aelitis.azureus.core.speedmanager.SpeedManager | speedManager | org.gudy.azureus2.core3.stats.transfer.OverallStats | totalStats | org.eclipse.swt.widgets.Composite | mainPanel | org.eclipse.swt.widgets.Composite | blahPanel | org.gudy.azureus2.ui.swt.components.BufferedLabel | asn | org.gudy.azureus2.ui.swt.components.BufferedLabel | estUpCap | org.gudy.azureus2.ui.swt.components.BufferedLabel | estDownCap | org.eclipse.swt.widgets.Composite | generalPanel | org.gudy.azureus2.ui.swt.components.BufferedLabel | nowUp | org.gudy.azureus2.ui.swt.components.BufferedLabel | nowDown | org.gudy.azureus2.ui.swt.components.BufferedLabel | sessionDown | org.gudy.azureus2.ui.swt.components.BufferedLabel | sessionUp | org.gudy.azureus2.ui.swt.components.BufferedLabel | session_ratio | org.gudy.azureus2.ui.swt.components.BufferedLabel | sessionTime | org.gudy.azureus2.ui.swt.components.BufferedLabel | totalDown | org.gudy.azureus2.ui.swt.components.BufferedLabel | totalUp | org.gudy.azureus2.ui.swt.components.BufferedLabel | total_ratio | org.gudy.azureus2.ui.swt.components.BufferedLabel | totalTime | org.eclipse.swt.widgets.Group | autoSpeedPanel | org.eclipse.swt.custom.StackLayout | autoSpeedPanelLayout | org.eclipse.swt.widgets.Composite | autoSpeedInfoPanel | org.eclipse.swt.widgets.Composite | autoSpeedDisabledPanel | org.gudy.azureus2.ui.swt.components.graphics.PingGraphic | pingGraph | plotView[] | plot_views | zoneView[] | zone_views | limitToTextHelper | limit_to_text | private final DecimalFormat | formatter |
Methods Summary |
---|
private void | createAutoSpeedPanel()
autoSpeedPanel = new Group(mainPanel,SWT.NONE);
GridData generalPanelData = new GridData(GridData.FILL_BOTH);
autoSpeedPanel.setLayoutData(generalPanelData);
Messages.setLanguageText(autoSpeedPanel,"SpeedView.stats.autospeed");
autoSpeedPanelLayout = new StackLayout();
autoSpeedPanel.setLayout(autoSpeedPanelLayout);
autoSpeedInfoPanel = new Composite(autoSpeedPanel,SWT.NULL);
autoSpeedInfoPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 8;
layout.makeColumnsEqualWidth = true;
autoSpeedInfoPanel.setLayout(layout);
Canvas pingCanvas = new Canvas(autoSpeedInfoPanel,SWT.NO_BACKGROUND);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 4;
pingCanvas.setLayoutData(gridData);
pingGraph = PingGraphic.getInstance();
pingGraph.initialize(pingCanvas);
TabFolder folder = new TabFolder(autoSpeedInfoPanel, SWT.LEFT);
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 4;
folder.setLayoutData(gridData);
folder.setBackground(Colors.background);
ValueFormater speed_formatter =
new ValueFormater()
{
public String
format(
int value)
{
return( DisplayFormatters.formatByteCountToKiBEtc( value ));
}
};
ValueFormater time_formatter =
new ValueFormater()
{
public String
format(
int value)
{
return( value + " ms" );
}
};
ValueFormater[] formatters = new ValueFormater[]{ speed_formatter, speed_formatter, time_formatter };
String[] labels = new String[]{ "up", "down", "ping" };
SpeedManagerPingMapper[] mappers = speedManager.getMappers();
plot_views = new plotView[mappers.length];
zone_views = new zoneView[mappers.length];
for (int i=0;i<mappers.length;i++){
SpeedManagerPingMapper mapper = mappers[i];
TabItem plot_item = new TabItem(folder, SWT.NULL);
plot_item.setText( "Plot " + mapper.getName());
Canvas plotCanvas = new Canvas(folder,SWT.NO_BACKGROUND);
gridData = new GridData(GridData.FILL_BOTH);
plotCanvas.setLayoutData(gridData);
plot_views[i] = new plotView( mapper, plotCanvas, labels, formatters );
plot_item.setControl( plotCanvas );
TabItem zones_item = new TabItem(folder, SWT.NULL);
zones_item.setText( "Zones " + mapper.getName() );
Canvas zoneCanvas = new Canvas(folder,SWT.NO_BACKGROUND);
gridData = new GridData(GridData.FILL_BOTH);
zoneCanvas.setLayoutData(gridData);
zone_views[i] = new zoneView( mapper, zoneCanvas, labels, formatters );
zones_item.setControl( zoneCanvas );
}
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 );
| private void | createBlahPanel()
blahPanel = new Composite(mainPanel,SWT.NONE);
GridData blahPanelData = new GridData(GridData.FILL_HORIZONTAL);
blahPanel.setLayoutData(blahPanelData);
GridLayout panelLayout = new GridLayout();
panelLayout.numColumns = 8;
blahPanel.setLayout(panelLayout);
Label label;
GridData gridData;
label = new Label(blahPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.asn");
asn = new BufferedLabel(blahPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
asn.setLayoutData(gridData);
label = new Label(blahPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.estupcap");
estUpCap = new BufferedLabel(blahPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
estUpCap.setLayoutData(gridData);
label = new Label(blahPanel,SWT.NONE);
Messages.setLanguageText(label,"SpeedView.stats.estdowncap");
estDownCap = new BufferedLabel(blahPanel,SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
estDownCap.setLayoutData(gridData);
label = new Label(blahPanel,SWT.NONE);
label = new Label(blahPanel,SWT.NONE);
| private void | createGeneralPanel()
generalPanel = new Composite(mainPanel,SWT.BORDER);
GridData generalPanelData = new GridData(GridData.FILL_HORIZONTAL);
generalPanel.setLayoutData(generalPanelData);
GridLayout panelLayout = new GridLayout();
panelLayout.numColumns = 5;
panelLayout.makeColumnsEqualWidth = true;
generalPanel.setLayout(panelLayout);
GridData gridData;
Label lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.downloaded");
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.uploaded");
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.ratio");
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.uptime");
lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
/////// NOW /////////
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.now");
nowDown = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
nowDown.setLayoutData(gridData);
nowUp = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
nowUp.setLayoutData(gridData);
lbl = new Label(generalPanel,SWT.NULL);
lbl = new Label(generalPanel,SWT.NULL);
//////// SESSION ////////
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.session");
sessionDown = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
sessionDown.setLayoutData(gridData);
sessionUp = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
sessionUp.setLayoutData(gridData);
session_ratio = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
session_ratio.setLayoutData(gridData);
sessionTime = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
sessionTime.setLayoutData(gridData);
///////// TOTAL ///////////
lbl = new Label(generalPanel,SWT.NULL);
Messages.setLanguageText(lbl,"SpeedView.stats.total");
totalDown = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
totalDown.setLayoutData(gridData);
totalUp = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
totalUp.setLayoutData(gridData);
total_ratio = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
total_ratio.setLayoutData(gridData);
totalTime = new BufferedLabel(generalPanel,SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
totalTime.setLayoutData(gridData);
| public void | delete()
Utils.disposeComposite(generalPanel);
Utils.disposeComposite(blahPanel);
pingGraph.dispose();
for (int i=0;i<plot_views.length;i++){
plot_views[i].dispose();
}
for (int i=0;i<zone_views.length;i++){
zone_views[i].dispose();
}
| public org.eclipse.swt.widgets.Composite | getComposite()
return mainPanel;
| public java.lang.String | getData()
return "TransferStatsView.title.full";
| public java.lang.String | getFullTitle()
return MessageText.getString("SpeedView.title.full"); //$NON-NLS-1$
| protected java.lang.String | getMapperTitle(com.aelitis.azureus.core.speedmanager.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( "" );
| public void | initialize(org.eclipse.swt.widgets.Composite composite)
mainPanel = new Composite(composite,SWT.NULL);
GridLayout mainLayout = new GridLayout();
mainPanel.setLayout(mainLayout);
createGeneralPanel();
createBlahPanel();
createAutoSpeedPanel();
| public void | periodicUpdate()
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);
for (int i=0;i<plot_views.length;i++){
plot_views[i].update();
}
for (int i=0;i<zone_views.length;i++){
zone_views[i].update();
}
}
}
| public void | refresh()
refreshGeneral();
refreshBlahPanel();
refreshPingPanel();
| private void | refreshBlahPanel()
asn.setText(speedManager.getASN());
estUpCap.setText(limit_to_text.getLimitText(speedManager.getEstimatedUploadCapacityBytesPerSec()));
estDownCap.setText(limit_to_text.getLimitText(speedManager.getEstimatedDownloadCapacityBytesPerSec()));
| 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();
pingGraph.refresh();
for (int i=0;i<plot_views.length;i++){
plot_views[i].refresh();
}
for (int i=0;i<zone_views.length;i++){
zone_views[i].refresh();
}
} else {
autoSpeedPanelLayout.topControl = autoSpeedDisabledPanel;
autoSpeedPanel.layout();
}
|
|