📄 peerinfoview.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: PeerInfoView.java
package org.gudy.azureus2.ui.swt.views.peer;
import com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Locale;
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.logging.*;
import org.gudy.azureus2.core3.peer.PEPeer;
import org.gudy.azureus2.core3.peer.PEPeerManager;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.utils.Utilities;
import org.gudy.azureus2.pluginsimpl.local.PluginInitializer;
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 PeerInfoView extends AbstractIView
implements ObfusticateImage
{
private static final int BLOCK_FILLSIZE = 14;
private static final int BLOCK_SPACING = 2;
private static final int BLOCK_SIZE = 16;
private static final int BLOCKCOLOR_AVAIL_HAVE = 0;
private static final int BLOCKCOLOR_AVAIL_NOHAVE = 1;
private static final int BLOCKCOLOR_NOAVAIL_HAVE = 2;
private static final int BLOCKCOLOR_NOAVAIL_NOHAVE = 3;
private static final int BLOCKCOLOR_TRANSFER = 4;
private static final int BLOCKCOLOR_NEXT = 5;
private static final int BLOCKCOLOR_AVAILCOUNT = 6;
private Composite peerInfoComposite;
private ScrolledComposite sc;
protected Canvas peerInfoCanvas;
private Color blockColors[];
private Label topLabel;
private Label imageLabel;
private int graphicsUpdate;
private int loopFactor;
private PEPeer peer;
private Plugin countryLocator;
private String sCountryImagesDir;
private Font font;
Image img;
public PeerInfoView()
{
graphicsUpdate = COConfigurationManager.getIntParameter("Graphics Update") * 2;
loopFactor = 0;
countryLocator = null;
font = null;
img = null;
blockColors = (new Color[] {
Colors.blues[9], Colors.blues[2], Colors.fadedGreen, Colors.white, Colors.red, Colors.fadedRed, Colors.black
});
try
{
PluginInterface pi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByID("CountryLocator");
if (pi != null)
{
countryLocator = pi.getPlugin();
if (!pi.getPluginState().isOperational() || pi.getUtilities().compareVersions(pi.getPluginVersion(), "1.6") < 0)
countryLocator = null;
if (countryLocator != null)
sCountryImagesDir = (String)countryLocator.getClass().getMethod("getImageLocation", new Class[] {
Integer.TYPE
}).invoke(countryLocator, new Object[] {
new Integer(0)
});
}
}
catch (Throwable t) { }
}
public void dataSourceChanged(Object newDataSource)
{
if (newDataSource == null)
peer = null;
else
if (newDataSource instanceof Object[])
peer = (PEPeer)((Object[])(Object[])newDataSource)[0];
else
peer = (PEPeer)newDataSource;
fillPeerInfoSection();
}
public String getData()
{
return "PeersView.BlockView.title";
}
public void initialize(Composite composite)
{
if (peerInfoComposite != null && !peerInfoComposite.isDisposed())
{
Logger.log(new LogEvent(LogIDs.GUI, 3, (new StringBuilder()).append("PeerInfoView already initialized! Stack: ").append(Debug.getStackTrace(true, false)).toString()));
delete();
}
createPeerInfoPanel(composite);
}
private Composite createPeerInfoPanel(Composite parent)
{
peerInfoComposite = new Composite(parent, 0);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
peerInfoComposite.setLayout(layout);
GridData gridData = new GridData(4, 4, true, true);
peerInfoComposite.setLayoutData(gridData);
imageLabel = new Label(peerInfoComposite, 0);
gridData = new GridData();
if (countryLocator != null)
gridData.widthHint = 28;
imageLabel.setLayoutData(gridData);
topLabel = new Label(peerInfoComposite, 0);
gridData = new GridData(4, -1, false, false);
topLabel.setLayoutData(gridData);
sc = new ScrolledComposite(peerInfoComposite, 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(16);
peerInfoCanvas = new Canvas(sc, 0x140000);
gridData = new GridData(4, -1, true, false);
peerInfoCanvas.setLayoutData(gridData);
peerInfoCanvas.addPaintListener(new PaintListener() {
final PeerInfoView 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 = PeerInfoView.this;
super();
}
});
Listener doNothingListener = new Listener() {
final PeerInfoView this$0;
public void handleEvent(Event event1)
{
}
{
this$0 = PeerInfoView.this;
super();
}
};
peerInfoCanvas.addListener(1, doNothingListener);
peerInfoCanvas.addListener(11, new Listener() {
final PeerInfoView 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 / 16;
int iNewColCount = peerInfoCanvas.getClientArea().width / 16;
if (iOldColCount != iNewColCount)
refreshInfoCanvas();
}
}
{
this$1 = 3.this;
super();
}
});
}
{
this$0 = PeerInfoView.this;
super();
}
});
sc.setContent(peerInfoCanvas);
Legend.createLegendComposite(peerInfoComposite, blockColors, new String[] {
"PeersView.BlockView.Avail.Have", "PeersView.BlockView.Avail.NoHave", "PeersView.BlockView.NoAvail.Have", "PeersView.BlockView.NoAvail.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) / peerInfoCanvas.getDisplay().getDPI().y;
Font f = peerInfoCanvas.getFont();
FontData fontData[] = f.getFontData();
fontData[0].setHeight(iFontPointHeight);
font = new Font(peerInfoCanvas.getDisplay(), fontData);
return peerInfoComposite;
}
public void fillPeerInfoSection()
{
if (imageLabel.getImage() != null)
{
Image image = imageLabel.getImage();
imageLabel.setImage(null);
image.dispose();
}
if (peer == null)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -