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

📄 legend.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:   Legend.java

package org.gudy.azureus2.ui.swt.components;

import com.aelitis.azureus.ui.swt.utils.ColorCache;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.config.impl.ConfigurationManager;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;

public class Legend
{

	public Legend()
	{
	}

	public static Composite createLegendComposite(Composite panel, Color blockColors[], String keys[])
	{
		Object layout = panel.getLayout();
		Object layoutData = null;
		if (layout instanceof GridLayout)
			layoutData = new GridData(768);
		return createLegendComposite(panel, blockColors, keys, layoutData);
	}

	public static Composite createLegendComposite(Composite panel, Color blockColors[], String keys[], Object layoutData)
	{
		ConfigurationManager config = ConfigurationManager.getInstance();
		if (blockColors.length != keys.length)
			return null;
		Color defaultColors[] = new Color[blockColors.length];
		ParameterListener paramListeners[] = new ParameterListener[keys.length];
		System.arraycopy(blockColors, 0, defaultColors, 0, blockColors.length);
		Composite legend = new Composite(panel, 0);
		if (layoutData != null)
			legend.setLayoutData(layoutData);
		RowLayout layout = new RowLayout(256);
		layout.wrap = true;
		layout.marginBottom = 0;
		layout.marginTop = 0;
		layout.marginLeft = 0;
		layout.marginRight = 0;
		layout.spacing = 0;
		legend.setLayout(layout);
		for (int i = 0; i < blockColors.length; i++)
		{
			int r = config.getIntParameter((new StringBuilder()).append(keys[i]).append(".red").toString(), -1);
			if (r >= 0)
			{
				int g = config.getIntParameter((new StringBuilder()).append(keys[i]).append(".green").toString());
				int b = config.getIntParameter((new StringBuilder()).append(keys[i]).append(".blue").toString());
				Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
				blockColors[i] = color;
			}
			Composite colorSet = new Composite(legend, 0);
			colorSet.setLayout(new RowLayout(256));
			Canvas cColor = new Canvas(colorSet, 2048);
			cColor.setData("Index", new Integer(i));
			cColor.addPaintListener(new PaintListener(cColor, blockColors) {

				final Canvas val$cColor;
				final Color val$blockColors[];

				public void paintControl(PaintEvent e)
				{
					int i = ((Integer)cColor.getData("Index")).intValue();
					e.gc.setBackground(blockColors[i]);
					e.gc.fillRectangle(e.x, e.y, e.width, e.height);
				}

			
			{
				cColor = canvas;
				blockColors = acolor;
				Object();
			}
			});
			cColor.addMouseListener(new MouseAdapter(cColor, panel, blockColors, config, keys) {

				final Canvas val$cColor;
				final Composite val$panel;
				final Color val$blockColors[];
				final ConfigurationManager val$config;
				final String val$keys[];

				public void mouseUp(MouseEvent e)
				{
					Integer iIndex = (Integer)cColor.getData("Index");
					if (iIndex == null)
						return;
					int index = iIndex.intValue();
					if (e.button == 1)
					{
						ColorDialog cd = new ColorDialog(panel.getShell());
						cd.setRGB(blockColors[index].getRGB());
						RGB rgb = cd.open();
						if (rgb != null)
							config.setRGBParameter(keys[index], rgb.red, rgb.green, rgb.blue);
					} else
					{
						config.removeRGBParameter(keys[index]);
					}
				}

			
			{
				cColor = canvas;
				panel = composite;
				blockColors = acolor;
				config = configurationmanager;
				keys = as;
				MouseAdapter();
			}
			});
			Label lblDesc = new Label(colorSet, 0);
			Messages.setLanguageText(lblDesc, keys[i]);
			RowData data = new RowData();
			data.width = 20;
			data.height = lblDesc.computeSize(-1, -1).y - 3;
			cColor.setLayoutData(data);
			config.addParameterListener(keys[i], paramListeners[i] = new ParameterListener(keys, config, blockColors, panel, cColor, defaultColors) {

				final String val$keys[];
				final ConfigurationManager val$config;
				final Color val$blockColors[];
				final Composite val$panel;
				final Canvas val$cColor;
				final Color val$defaultColors[];

				public void parameterChanged(String parameterName)
				{
					for (int j = 0; j < keys.length; j++)
					{
						if (!keys[j].equals(parameterName))
							continue;
						final int index = j;
						final int r = config.getIntParameter((new StringBuilder()).append(keys[j]).append(".red").toString(), -1);
						if (r >= 0)
						{
							final int g = config.getIntParameter((new StringBuilder()).append(keys[j]).append(".green").toString());
							final int b = config.getIntParameter((new StringBuilder()).append(keys[j]).append(".blue").toString());
							RGB rgb = new RGB(r, g, b);
							if (blockColors[j].isDisposed() || !rgb.equals(blockColors[j].getRGB()))
								Utils.execSWTThread(new AERunnable() {

									final int val$r;
									final int val$g;
									final int val$b;
									final int val$index;
									final 3 this$0;

									public void runSupport()
									{
										if (panel == null || panel.isDisposed())
										{
											return;
										} else
										{
											Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
											blockColors[index] = color;
											cColor.redraw();
											return;
										}
									}

					
					{
						this$0 = 3.this;
						r = i;
						g = j;
						b = k;
						index = l;
						AERunnable();
					}
								});
							continue;
						}
						if (blockColors[j].isDisposed() || !blockColors[j].equals(defaultColors[j]))
							Utils.execSWTThread(new AERunnable() {

								final int val$index;
								final 3 this$0;

								public void runSupport()
								{
									if (panel == null || panel.isDisposed())
									{
										return;
									} else
									{
										blockColors[index] = defaultColors[index];
										cColor.redraw();
										return;
									}
								}

					
					{
						this$0 = 3.this;
						index = i;
						AERunnable();
					}
							});
					}

				}

			
			{
				keys = as;
				config = configurationmanager;
				blockColors = acolor;
				panel = composite;
				cColor = canvas;
				defaultColors = acolor1;
				Object();
			}
			});
		}

		legend.addDisposeListener(new DisposeListener(blockColors, defaultColors, keys, config, paramListeners) {

			final Color val$blockColors[];
			final Color val$defaultColors[];
			final String val$keys[];
			final ConfigurationManager val$config;
			final ParameterListener val$paramListeners[];

			public void widgetDisposed(DisposeEvent e)
			{
				for (int i = 0; i < blockColors.length; i++)
					blockColors[i] = defaultColors[i];

				for (int i = 0; i < keys.length; i++)
					config.removeParameterListener(keys[i], paramListeners[i]);

			}

			
			{
				blockColors = acolor;
				defaultColors = acolor1;
				keys = as;
				config = configurationmanager;
				paramListeners = aparameterlistener;
				Object();
			}
		});
		return legend;
	}
}

⌨️ 快捷键说明

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