📄 completionitem.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: CompletionItem.java
package org.gudy.azureus2.ui.swt.views.tableitems.mytorrents;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import com.aelitis.azureus.ui.swt.utils.ColorCache;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.graphics.*;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.download.DownloadManagerStats;
import org.gudy.azureus2.core3.util.DisplayFormatters;
import org.gudy.azureus2.plugins.download.DownloadTypeIncomplete;
import org.gudy.azureus2.plugins.ui.tables.*;
import org.gudy.azureus2.ui.swt.plugins.UISWTGraphic;
import org.gudy.azureus2.ui.swt.shells.GCStringPrinter;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWT;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener;
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;
public class CompletionItem extends CoreTableColumn
implements TableCellAddedListener, TableCellRefreshListener, TableCellDisposeListener, TableCellSWTPaintListener
{
public static final Class DATASOURCE_TYPE = org/gudy/azureus2/plugins/download/DownloadTypeIncomplete;
private static final int borderWidth = 1;
public static final String COLUMN_ID = "completion";
private static Font fontText;
private Map mapCellLastPercentDone;
private int marginHeight;
Color textColor;
public CompletionItem(String sTableID)
{
this(sTableID, -1);
}
public void fillTableColumnInfo(TableColumnInfo info)
{
info.addCategories(new String[] {
"progress"
});
}
public CompletionItem(String sTableID, int marginHeight)
{
super(DATASOURCE_TYPE, "completion", 1, 150, sTableID);
mapCellLastPercentDone = new HashMap();
this.marginHeight = -1;
this.marginHeight = marginHeight;
initializeAsGraphic(-1, 150);
setMinWidth(100);
}
public void cellAdded(TableCell cell)
{
if (marginHeight != -1)
cell.setMarginHeight(marginHeight);
else
cell.setMarginHeight(2);
}
public void dispose(TableCell cell)
{
mapCellLastPercentDone.remove(cell);
org.gudy.azureus2.plugins.ui.Graphic graphic = cell.getGraphic();
if (graphic instanceof UISWTGraphic)
{
Image img = ((UISWTGraphic)graphic).getImage();
if (img != null && !img.isDisposed())
img.dispose();
}
}
public void refresh(TableCell cell)
{
int percentDone = getPercentDone(cell);
Integer intObj = (Integer)mapCellLastPercentDone.get(cell);
int lastPercentDone = intObj != null ? intObj.intValue() : 0;
if (!cell.setSortValue(percentDone) && cell.isValid() && lastPercentDone == percentDone)
return;
else
return;
}
public void cellPaint(GC gcImage, TableCellSWT cell)
{
int percentDone = getPercentDone(cell);
Rectangle bounds = cell.getBounds();
int yOfs = (bounds.height - 13) / 2;
int x1 = bounds.width - 1 - 2;
int y1 = bounds.height - 3 - yOfs;
if (x1 < 10 || y1 < 3)
return;
int textYofs = 0;
if (y1 >= 28)
{
yOfs = 2;
y1 = 16;
}
mapCellLastPercentDone.put(cell, new Integer(percentDone));
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgEnd = imageLoader.getImage("dl_bar_end");
Image img0 = imageLoader.getImage("dl_bar_0");
Image img1 = imageLoader.getImage("dl_bar_1");
if (!imgEnd.isDisposed())
{
gcImage.drawImage(imgEnd, bounds.x, bounds.y + yOfs);
gcImage.drawImage(imgEnd, bounds.x + x1 + 1, bounds.y + yOfs);
}
int limit = (x1 * percentDone) / 1000;
if (!img1.isDisposed() && limit > 0)
{
Rectangle imgBounds = img1.getBounds();
gcImage.drawImage(img1, 0, 0, imgBounds.width, imgBounds.height, bounds.x + 1, bounds.y + yOfs, limit, imgBounds.height);
}
if (percentDone < 1000 && !img0.isDisposed())
{
Rectangle imgBounds = img0.getBounds();
gcImage.drawImage(img0, 0, 0, imgBounds.width, imgBounds.height, bounds.x + limit + 1, bounds.y + yOfs, x1 - limit, imgBounds.height);
}
imageLoader.releaseImage("dl_bar_end");
imageLoader.releaseImage("dl_bar_0");
imageLoader.releaseImage("dl_bar_1");
if (textColor == null)
textColor = ColorCache.getColor(gcImage.getDevice(), "#005ACF");
gcImage.setForeground(textColor);
String sPercent = DisplayFormatters.formatPercentFromThousands(percentDone);
GCStringPrinter.printString(gcImage, sPercent, new Rectangle(bounds.x + 4, bounds.y + yOfs, bounds.width - 4, 13), true, false, 0x1000000);
}
private int getPercentDone(TableCell cell)
{
DownloadManager dm = (DownloadManager)cell.getDataSource();
if (dm == null)
return 0;
else
return dm.getStats().getDownloadCompleted(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -