FileDocCategorySizeDatePackage
ActivityView.javaAPI DocAzureus 3.0.3.45676Mon Jun 04 15:18:32 BST 2007org.gudy.azureus2.ui.swt.views.stats

ActivityView

public class ActivityView extends org.gudy.azureus2.ui.swt.views.AbstractIView implements org.gudy.azureus2.core3.config.ParameterListener
author
Olivier

Fields Summary
org.gudy.azureus2.core3.global.GlobalManager
manager
org.gudy.azureus2.core3.global.GlobalManagerStats
stats
org.gudy.azureus2.core3.stats.transfer.OverallStats
totalStats
org.eclipse.swt.widgets.Composite
panel
org.eclipse.swt.widgets.Canvas
downSpeedCanvas
org.gudy.azureus2.ui.swt.components.graphics.SpeedGraphic
downSpeedGraphic
org.eclipse.swt.widgets.Canvas
upSpeedCanvas
org.gudy.azureus2.ui.swt.components.graphics.SpeedGraphic
upSpeedGraphic
Constructors Summary
public ActivityView(org.gudy.azureus2.core3.global.GlobalManager manager)

    this.manager = manager;
    this.stats = manager.getStats();
    this.totalStats = StatsFactory.getStats();
  
Methods Summary
public voiddelete()

    
    Utils.disposeComposite(panel);
    downSpeedGraphic.dispose();
    upSpeedGraphic.dispose();
    COConfigurationManager.removeParameterListener("Stats Graph Dividers", this);
  
public org.eclipse.swt.widgets.CompositegetComposite()

    return panel;
  
public java.lang.StringgetData()

    return "SpeedView.title.full";
  
public java.lang.StringgetFullTitle()

    return MessageText.getString("SpeedView.title.full"); //$NON-NLS-1$
  
public voidinitialize(org.eclipse.swt.widgets.Composite composite)

    panel = new Composite(composite,SWT.NULL);
    panel.setLayout(new GridLayout());
    GridData gridData;
        
    Group gDownSpeed = new Group(panel,SWT.NULL);
    Messages.setLanguageText(gDownSpeed,"SpeedView.downloadSpeed.title");
    gridData = new GridData(GridData.FILL_BOTH);
    gDownSpeed.setLayoutData(gridData);    
    gDownSpeed.setLayout(new GridLayout());
    
    downSpeedCanvas = new Canvas(gDownSpeed,SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_BOTH);
    downSpeedCanvas.setLayoutData(gridData);
    downSpeedGraphic = SpeedGraphic.getInstance();
    downSpeedGraphic.initialize(downSpeedCanvas);
    Color[] colors = downSpeedGraphic.colors;
    
    Group gUpSpeed = new Group(panel,SWT.NULL);
    Messages.setLanguageText(gUpSpeed,"SpeedView.uploadSpeed.title");
    gridData = new GridData(GridData.FILL_BOTH);
    gUpSpeed.setLayoutData(gridData);
    gUpSpeed.setLayout(new GridLayout());
    
    upSpeedCanvas = new Canvas(gUpSpeed,SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_BOTH);
    upSpeedCanvas.setLayoutData(gridData);
    upSpeedGraphic = SpeedGraphic.getInstance();
    upSpeedGraphic.initialize(upSpeedCanvas);
    
    COConfigurationManager.addAndFireParameterListener("Stats Graph Dividers", this);
   
    upSpeedGraphic.setLineColors(colors);
  
	String[] colorConfigs = new String[] {
		"ActivityView.legend.peeraverage",
		"ActivityView.legend.achieved",
		"ActivityView.legend.limit",
		"ActivityView.legend.swarmaverage",
		"ActivityView.legend.trimmed"
	};

	Legend.createLegendComposite(panel, colors, colorConfigs);
  
public voidparameterChanged(java.lang.String param_name)

	  boolean update_dividers = COConfigurationManager.getBooleanParameter("Stats Graph Dividers");
	  int update_divider_width = update_dividers ? 60 : 0;
      downSpeedGraphic.setUpdateDividerWidth(update_divider_width);
      upSpeedGraphic.setUpdateDividerWidth(update_divider_width);
  
public voidperiodicUpdate()

	  
	int swarms_peer_speed = (int)stats.getTotalSwarmsPeerRate(true,false);
	
    downSpeedGraphic.addIntsValue(
    	new int[]{ 	stats.getDataReceiveRate() + stats.getProtocolReceiveRate(),
    				COConfigurationManager.getIntParameter("Max Download Speed KBs") * 1024,
    				swarms_peer_speed });
   
    upSpeedGraphic.addIntsValue(
    	new int[]{	stats.getDataSendRate() + stats.getProtocolSendRate(), 
    				COConfigurationManager.getIntParameter(TransferSpeedValidator.getActiveUploadParameter( manager )) * 1024,
    				swarms_peer_speed });
  
public voidrefresh()

    downSpeedGraphic.refresh();
    upSpeedGraphic.refresh();