⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downspeeditem.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   DownSpeedItem.java

package org.gudy.azureus2.ui.swt.views.tableitems.mytorrents;

import com.aelitis.azureus.plugins.startstoprules.defaultplugin.DefaultRankCalculator;
import com.aelitis.azureus.plugins.startstoprules.defaultplugin.StartStopRulesDefaultPlugin;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.DisplayFormatters;
import org.gudy.azureus2.plugins.download.*;
import org.gudy.azureus2.plugins.ui.tables.*;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;

public class DownSpeedItem extends CoreTableColumn
	implements TableCellAddedListener
{
	public class RefreshListener
		implements TableCellRefreshListener
	{

		private int iLastState;
		private int loop;
		final DownSpeedItem this$0;

		public void refresh(TableCell cell)
		{
			Download dm = (Download)cell.getDataSource();
			long value;
			int iState;
			if (dm == null)
			{
				iState = -1;
				value = 0L;
			} else
			{
				iState = dm.getState();
				value = dm.getStats().getDownloadAverage();
			}
			boolean bChangeColor = ++loop % 10 == 0;
			if (cell.setSortValue(value) || !cell.isValid() || iState != iLastState)
			{
				cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(value));
				bChangeColor = true;
			}
			if (bChangeColor)
			{
				changeColor(cell, dm, iState);
				loop = 0;
			}
		}

		private void changeColor(TableCell cell, Download dl, int iState)
		{
			try
			{
				DefaultRankCalculator calc = StartStopRulesDefaultPlugin.getRankCalculator(dl);
				org.eclipse.swt.graphics.Color newFG = null;
				if (calc != null && dl.getState() == 4 && !calc.getActivelyDownloading())
					newFG = Colors.colorWarning;
				cell.setForeground(Utils.colorToIntArray(newFG));
				iLastState = iState;
			}
			catch (Exception e)
			{
				Debug.printStackTrace(e);
			}
		}

		public RefreshListener()
		{
			this$0 = DownSpeedItem.this;
			super();
			loop = 0;
		}
	}


	public static final Class DATASOURCE_TYPE = org/gudy/azureus2/plugins/download/DownloadTypeIncomplete;
	public static final String COLUMN_ID = "downspeed";

	public DownSpeedItem(String sTableID)
	{
		super(DATASOURCE_TYPE, "downspeed", 2, 60, sTableID);
		setType(1);
		setRefreshInterval(-2);
		setUseCoreDataSource(false);
		setMinWidthAuto(true);
	}

	public void fillTableColumnInfo(TableColumnInfo info)
	{
		info.addCategories(new String[] {
			"essential", "bytes"
		});
	}

	public void cellAdded(TableCell cell)
	{
		cell.addRefreshListener(new RefreshListener());
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -