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

📄 imagerepository.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:   ImageRepository.java

package org.gudy.azureus2.ui.swt;

import com.aelitis.azureus.ui.skin.SkinProperties;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.lang.reflect.Method;
import javax.imageio.ImageIO;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.FileUtil;

// Referenced classes of package org.gudy.azureus2.ui.swt:
//			Utils

public class ImageRepository
{

	private static final String noCacheExtList[] = {
		".exe"
	};
	private static final boolean forceNoAWT;

	public ImageRepository()
	{
	}

	static void addPath(String path, String id)
	{
		SkinProperties skinProperties[] = ImageLoader.getInstance().getSkinProperties();
		if (skinProperties != null && skinProperties.length > 0)
			skinProperties[0].addProperty(id, path);
	}

	/**
	 * @deprecated Method getImage is deprecated
	 */

	public static org.eclipse.swt.graphics.Image getImage(String name)
	{
		return ImageLoader.getInstance().getImage(name);
	}

	public static org.eclipse.swt.graphics.Image getIconFromExtension(String ext, boolean bBig, boolean minifolder)
	{
		org.eclipse.swt.graphics.Image image = null;
		String key;
		key = (new StringBuilder()).append("osicon").append(ext).toString();
		if (bBig)
			key = (new StringBuilder()).append(key).append("-big").toString();
		if (minifolder)
			key = (new StringBuilder()).append(key).append("-fold").toString();
		image = ImageLoader.getInstance().getImage(key);
		if (ImageLoader.isRealImage(image))
			return image;
		try
		{
			ImageLoader.getInstance().releaseImage(key);
			image = null;
			ImageData imageData = null;
			if (Constants.isWindows && bBig)
				try
				{
					Class ehancerClass = Class.forName("org.gudy.azureus2.ui.swt.win32.Win32UIEnhancer");
					Method method = ehancerClass.getMethod("getBigImageData", new Class[] {
						java/lang/String
					});
					imageData = (ImageData)method.invoke(null, new Object[] {
						ext
					});
				}
				catch (Exception e)
				{
					Debug.printStackTrace(e);
				}
			if (imageData == null)
			{
				Program program = Program.findProgram(ext);
				if (program != null)
					imageData = program.getImageData();
			}
			if (imageData != null)
			{
				image = new org.eclipse.swt.graphics.Image(Display.getDefault(), imageData);
				if (!bBig)
					image = force16height(image);
				if (minifolder)
					image = minifolderize(image, bBig);
				ImageLoader.getInstance().addImageNoDipose(key, image);
			}
		}
		catch (Throwable e) { }
		if (image == null)
			return getImage(minifolder ? "folder" : "transparent");
		else
			return image;
	}

	private static org.eclipse.swt.graphics.Image minifolderize(org.eclipse.swt.graphics.Image img, boolean big)
	{
		org.eclipse.swt.graphics.Image imgFolder = getImage(big ? "folder" : "foldersmall");
		Rectangle folderBounds = imgFolder.getBounds();
		Rectangle dstBounds = img.getBounds();
		org.eclipse.swt.graphics.Image tempImg = Utils.renderTransparency(Display.getCurrent(), img, imgFolder, new Point(dstBounds.width - folderBounds.width, dstBounds.height - folderBounds.height), 204);
		if (tempImg != null)
		{
			img.dispose();
			img = tempImg;
		}
		return img;
	}

	private static org.eclipse.swt.graphics.Image force16height(org.eclipse.swt.graphics.Image image)
	{
		Rectangle bounds;
		org.eclipse.swt.graphics.Image newImage;
		GC gc;
		if (image == null)
			return image;
		bounds = image.getBounds();
		if (bounds.height == 16)
			break MISSING_BLOCK_LABEL_99;
		newImage = new org.eclipse.swt.graphics.Image(image.getDevice(), 16, 16);
		gc = new GC(newImage);
		if (!Constants.isUnix)
			gc.setAdvanced(true);
		gc.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0, 16, 16);
		gc.dispose();
		break MISSING_BLOCK_LABEL_93;
		Exception exception;
		exception;
		gc.dispose();
		throw exception;
		image.dispose();
		image = newImage;
		return image;
	}

	public static org.eclipse.swt.graphics.Image getPathIcon(String path, boolean bBig, boolean minifolder)
	{
		File file;
		boolean bDeleteFile;
		boolean noAWT;
		if (path == null)
			return null;
		file = null;
		bDeleteFile = false;
		noAWT = forceNoAWT || !bBig;
		file = new File(path);
		if (!file.isDirectory())
			break MISSING_BLOCK_LABEL_64;
		if (noAWT)
			return getImage("folder");
		String key;
		key = file.getPath();
		break MISSING_BLOCK_LABEL_168;
		int idxDot;
		idxDot = file.getName().lastIndexOf(".");
		if (idxDot != -1)
			break MISSING_BLOCK_LABEL_99;
		if (noAWT)
			return getImage("folder");
		key = "?!blank";
		break MISSING_BLOCK_LABEL_168;
		String ext;
		ext = file.getName().substring(idxDot);
		key = ext;
		if (noAWT)
			return getIconFromExtension(ext, bBig, minifolder);
		int i = 0;
		do
		{
			if (i >= noCacheExtList.length)
				break;
			if (noCacheExtList[i].equalsIgnoreCase(ext))
			{
				key = file.getPath();
				break;
			}
			i++;
		} while (true);
		org.eclipse.swt.graphics.Image image;
		if (bBig)
			key = (new StringBuilder()).append(key).append("-big").toString();
		if (minifolder)
			key = (new StringBuilder()).append(key).append("-fold").toString();
		key = (new StringBuilder()).append("osicon").append(key).toString();
		image = ImageLoader.getInstance().getImage(key);
		if (ImageLoader.isRealImage(image))
			return image;
		ImageLoader.getInstance().releaseImage(key);
		image = null;
		bDeleteFile = !file.exists();
		if (bDeleteFile)
			file = File.createTempFile("AZ_", FileUtil.getExtension(path));
		Image awtImage = null;
		Class sfClass = Class.forName("sun.awt.shell.ShellFolder");
		if (sfClass != null && file != null)
		{
			Method method = sfClass.getMethod("getShellFolder", new Class[] {
				java/io/File
			});
			if (method != null)
			{
				Object sfInstance = method.invoke(null, new Object[] {
					file
				});
				if (sfInstance != null)
				{
					method = sfClass.getMethod("getIcon", new Class[] {
						Boolean.TYPE
					});
					if (method != null)
						awtImage = (Image)method.invoke(sfInstance, new Object[] {
							new Boolean(bBig)
						});
				}
			}
		}
		if (awtImage == null)
			break MISSING_BLOCK_LABEL_536;
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		ImageIO.write((BufferedImage)awtImage, "png", outStream);
		ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
		image = new org.eclipse.swt.graphics.Image(Display.getDefault(), inStream);
		if (!bBig)
			image = force16height(image);
		if (minifolder)
			image = minifolderize(image, bBig);
		ImageLoader.getInstance().addImageNoDipose(key, image);
		if (bDeleteFile && file != null && file.exists())
			file.delete();
		return image;
		Exception e;
		e;
		if (bDeleteFile && file != null && file.exists())
			file.delete();
		String ext = FileUtil.getExtension(path);
		if (ext.length() == 0)
			return getImage("folder");
		else
			return getIconFromExtension(ext, bBig, minifolder);
	}

	public static void main(String args[])
	{
		Display display = new Display();
		Shell shell = new Shell(display, 1264);
		shell.setLayout(new FillLayout(512));
		Label label = new Label(shell, 2048);
		Text text = new Text(shell, 2048);
		text.addModifyListener(new ModifyListener(text, label) {

			final Text val$text;
			final Label val$label;

			public void modifyText(ModifyEvent e)
			{
				org.eclipse.swt.graphics.Image pathIcon = ImageRepository.getPathIcon(text.getText(), false, false);
				label.setImage(pathIcon);
			}

			
			{
				text = text1;
				label = label1;
				super();
			}
		});
		shell.open();
		do
		{
			if (shell.isDisposed())
				break;
			if (!display.readAndDispatch())
				display.sleep();
		} while (true);
	}

	static 
	{
		forceNoAWT = Constants.isOSX;
	}
}

⌨️ 快捷键说明

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