📄 transferstatsview.java
字号:
/*
* Created on Sep 13, 2004
* Created by Olivier Chalouhi
* Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* AELITIS, SAS au capital de 46,603.30 euros
* 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
*
*/
package org.gudy.azureus2.ui.swt.views.stats;
import java.text.DecimalFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.global.GlobalManagerStats;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.stats.transfer.OverallStats;
import org.gudy.azureus2.core3.stats.transfer.StatsFactory;
import org.gudy.azureus2.core3.util.DisplayFormatters;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.BufferedLabel;
import org.gudy.azureus2.ui.swt.components.Legend;
import org.gudy.azureus2.ui.swt.components.graphics.PingGraphic;
import org.gudy.azureus2.ui.swt.views.AbstractIView;
import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.speedmanager.SpeedManager;
import com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource;
/**
*
*/
public class TransferStatsView extends AbstractIView {
GlobalManager manager;
AzureusCore core;
GlobalManagerStats stats;
OverallStats totalStats;
Composite mainPanel;
Composite generalPanel;
BufferedLabel nowUp, nowDown, sessionDown, sessionUp, session_ratio, sessionTime, totalDown, totalUp, total_ratio, totalTime;
Group autoSpeedPanel;
StackLayout autoSpeedPanelLayout;
Composite autoSpeedInfoPanel;
Composite autoSpeedDisabledPanel;
Canvas pingCanvas;
PingGraphic pingGraph;
BufferedLabel idlePing,maxPing,maxUp,currentPing;
private final DecimalFormat formatter = new DecimalFormat( "##.#" );
public TransferStatsView(GlobalManager manager,AzureusCore core) {
this.core = core;
this.manager = manager;
this.stats = manager.getStats();
this.totalStats = StatsFactory.getStats();
}
public void initialize(Composite composite) {
mainPanel = new Composite(composite,SWT.NULL);
GridLayout mainLayout = new GridLayout();
mainPanel.setLayout(mainLayout);
createGeneralPanel();
createAutoSpeedPanel();
}
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);
}
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -