📄 pieceinfoview.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: PieceInfoView.java
package org.gudy.azureus2.ui.swt.views.piece;
import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.disk.DiskManager;
import org.gudy.azureus2.core3.disk.DiskManagerPiece;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.download.DownloadManagerPieceListener;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.peer.*;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.Legend;
import org.gudy.azureus2.ui.swt.debug.ObfusticateImage;
import org.gudy.azureus2.ui.swt.debug.UIDebugGenerator;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.views.AbstractIView;
public class PieceInfoView extends AbstractIView
implements ObfusticateImage, DownloadManagerPieceListener
{
private static class BlockInfo
{
public int haveWidth;
int availNum;
boolean availDotted;
boolean uploadingIndicator;
boolean uploadingIndicatorSmall;
boolean downloadingIndicator;
public boolean equals(Object obj)
{
BlockInfo otherBlockInfo = (BlockInfo)obj;
return haveWidth == otherBlockInfo.haveWidth && availNum == otherBlockInfo.availNum && availDotted == otherBlockInfo.availDotted && uploadingIndicator == otherBlockInfo.uploadingIndicator && uploadingIndicatorSmall == otherBlockInfo.uploadingIndicatorSmall && downloadingIndicator == otherBlockInfo.downloadingIndicator;
}
public BlockInfo()
{
haveWidth = -1;
}
}
private static final int BLOCK_FILLSIZE = 14;
private static final int BLOCK_SPACING = 3;
private static final int BLOCK_SIZE = 17;
private static final int BLOCKCOLOR_HAVE = 0;
private static final int BLOCKCOLORL_NOHAVE = 1;
private static final int BLOCKCOLOR_TRANSFER = 2;
private static final int BLOCKCOLOR_NEXT = 3;
private static final int BLOCKCOLOR_AVAILCOUNT = 4;
private Composite pieceInfoComposite;
private ScrolledComposite sc;
protected Canvas pieceInfoCanvas;
private Color blockColors[];
private Label topLabel;
private Label imageLabel;
private int graphicsUpdate;
private int loopFactor;
private Font font;
Image img;
private DownloadManager dlm;
BlockInfo oldBlockInfo[];
private boolean alreadyFilling;
public PieceInfoView()
{
graphicsUpdate = COConfigurationManager.getIntParameter("Graphics Update") * 2;
loopFactor = 0;
font = null;
img = null;
alreadyFilling = false;
blockColors = (new Color[] {
Colors.blues[9], Colors.white, Colors.red, Colors.fadedRed, Colors.black
});
}
public void dataSourceChanged(Object newDataSource)
{
if (newDataSource instanceof DownloadManager)
{
oldBlockInfo = null;
if (dlm != null)
dlm.removePieceListener(this);
dlm = (DownloadManager)newDataSource;
dlm.addPieceListener(this, false);
fillPieceInfoSection();
}
}
public String getData()
{
return "PeersView.BlockView.title";
}
public void initialize(Composite composite)
{
if (pieceInfoComposite != null && !pieceInfoComposite.isDisposed())
{
Logger.log(new LogEvent(LogIDs.GUI, 3, (new StringBuilder()).append("PeerInfoView already initialized! Stack: ").append(Debug.getStackTrace(true, false)).toString()));
delete();
}
createPeerInfoPanel(composite);
fillPieceInfoSection();
}
private Composite createPeerInfoPanel(Composite parent)
{
pieceInfoComposite = new Composite(parent, 0);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
pieceInfoComposite.setLayout(layout);
GridData gridData = new GridData(4, 4, true, true);
pieceInfoComposite.setLayoutData(gridData);
imageLabel = new Label(pieceInfoComposite, 0);
gridData = new GridData();
imageLabel.setLayoutData(gridData);
topLabel = new Label(pieceInfoComposite, 0);
gridData = new GridData(4, -1, false, false);
topLabel.setLayoutData(gridData);
sc = new ScrolledComposite(pieceInfoComposite, 512);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
layout = new GridLayout();
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
sc.setLayout(layout);
gridData = new GridData(4, 4, true, true, 2, 1);
sc.setLayoutData(gridData);
sc.getVerticalBar().setIncrement(17);
pieceInfoCanvas = new Canvas(sc, 0x140000);
gridData = new GridData(4, -1, true, false);
pieceInfoCanvas.setLayoutData(gridData);
pieceInfoCanvas.addPaintListener(new PaintListener() {
final PieceInfoView this$0;
public void paintControl(PaintEvent e)
{
if (e.width <= 0 || e.height <= 0)
return;
try
{
Rectangle bounds = img != null ? img.getBounds() : null;
if (bounds == null)
{
e.gc.fillRectangle(e.x, e.y, e.width, e.height);
} else
{
if (e.x + e.width > bounds.width)
e.gc.fillRectangle(bounds.width, e.y, ((e.x + e.width) - bounds.width) + 1, e.height);
if (e.y + e.height > bounds.height)
e.gc.fillRectangle(e.x, bounds.height, e.width, ((e.y + e.height) - bounds.height) + 1);
int width = Math.min(e.width, bounds.width - e.x);
int height = Math.min(e.height, bounds.height - e.y);
e.gc.drawImage(img, e.x, e.y, width, height, e.x, e.y, width, height);
}
}
catch (Exception ex) { }
}
{
this$0 = PieceInfoView.this;
super();
}
});
Listener doNothingListener = new Listener() {
final PieceInfoView this$0;
public void handleEvent(Event event1)
{
}
{
this$0 = PieceInfoView.this;
super();
}
};
pieceInfoCanvas.addListener(1, doNothingListener);
pieceInfoCanvas.addListener(11, new Listener() {
final PieceInfoView this$0;
public void handleEvent(Event e)
{
e.widget.getDisplay().asyncExec(new AERunnable() {
final 3 this$1;
public void runSupport()
{
if (img != null)
{
int iOldColCount = img.getBounds().width / 17;
int iNewColCount = pieceInfoCanvas.getClientArea().width / 17;
if (iOldColCount != iNewColCount)
refreshInfoCanvas();
}
}
{
this$1 = 3.this;
super();
}
});
}
{
this$0 = PieceInfoView.this;
super();
}
});
sc.setContent(pieceInfoCanvas);
Legend.createLegendComposite(pieceInfoComposite, blockColors, new String[] {
"PiecesView.BlockView.Have", "PiecesView.BlockView.NoHave", "PeersView.BlockView.Transfer", "PeersView.BlockView.NextRequest", "PeersView.BlockView.AvailCount"
}, new GridData(4, -1, true, false, 2, 1));
int iFontPixelsHeight = 10;
int iFontPointHeight = (iFontPixelsHeight * 72) / pieceInfoCanvas.getDisplay().getDPI().y;
Font f = pieceInfoCanvas.getFont();
FontData fontData[] = f.getFontData();
fontData[0].setHeight(iFontPointHeight);
font = new Font(pieceInfoCanvas.getDisplay(), fontData);
return pieceInfoComposite;
}
public void fillPieceInfoSection()
{
if (alreadyFilling)
{
return;
} else
{
alreadyFilling = true;
Utils.execSWTThreadLater(100, new AERunnable() {
final PieceInfoView this$0;
public void runSupport()
{
if (!alreadyFilling)
return;
if (imageLabel == null || imageLabel.isDisposed())
{
alreadyFilling = false;
return;
}
if (imageLabel.getImage() != null)
{
Image image = imageLabel.getImage();
imageLabel.setImage(null);
image.dispose();
}
refreshInfoCanvas();
alreadyFilling = false;
break MISSING_BLOCK_LABEL_114;
Exception exception;
exception;
alreadyFilling = false;
throw exception;
}
{
this$0 = PieceInfoView.this;
super();
}
});
return;
}
}
public void refresh()
{
super.refresh();
if (loopFactor++ % graphicsUpdate == 0)
refreshInfoCanvas();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -