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

📄 plot3d.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:   Plot3D.java

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

import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.Canvas;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.mainwindow.HSLColor;

// Referenced classes of package org.gudy.azureus2.ui.swt.components.graphics:
//			Graphic, ValueFormater

public class Plot3D
	implements Graphic, ParameterListener
{

	private Canvas canvas;
	private String title;
	private String labels[];
	private ValueFormater formatters[];
	private int internalLoop;
	private int graphicsUpdate;
	private Point oldSize;
	protected Image bufferImage;
	protected AEMonitor this_mon;
	private int values[][];
	private Color colours[];

	public Plot3D(String _labels[], ValueFormater _formatters[])
	{
		title = "";
		this_mon = new AEMonitor("Plot3D");
		values = new int[0][];
		labels = _labels;
		formatters = _formatters;
		COConfigurationManager.addAndFireParameterListener("Graphics Update", this);
		parameterChanged("Graphics Update");
	}

	public void initialize(Canvas _canvas)
	{
		canvas = _canvas;
		org.eclipse.swt.graphics.Device device = canvas.getDisplay();
		colours = new Color[16];
		HSLColor hsl = new HSLColor();
		hsl.initHSLbyRGB(130, 240, 240);
		int step = 128 / colours.length;
		int hue = colours.length * step;
		for (int i = 0; i < colours.length; i++)
		{
			hsl.setHue(hue);
			hue -= step;
			colours[i] = new Color(device, hsl.getRed(), hsl.getGreen(), hsl.getBlue());
		}

	}

	public void setTitle(String str)
	{
		title = str;
	}

	public Color[] getColours()
	{
		return colours;
	}

	public void refresh()
	{
		if (canvas == null || canvas.isDisposed())
			return;
		Rectangle bounds = canvas.getClientArea();
		if (bounds.height < 30 || bounds.width < 100 || bounds.width > 2000 || bounds.height > 2000)
			return;
		boolean sizeChanged = oldSize == null || oldSize.x != bounds.width || oldSize.y != bounds.height;
		oldSize = new Point(bounds.width, bounds.height);
		internalLoop++;
		if (internalLoop > graphicsUpdate)
			internalLoop = 0;
		if (internalLoop == 0 || sizeChanged)
			drawPlot();
		GC gc = new GC(canvas);
		gc.drawImage(bufferImage, bounds.x, bounds.y);
		gc.dispose();
	}

	protected void drawPlot()
	{
		double ANGLE_TAN;
		int PAD_TOP = 10;
		int PAD_BOTTOM = 10;
		int PAD_RIGHT = 10;
		int PAD_LEFT = 10;
		double ANGLE_RADS = 0.69999999999999996D;
		ANGLE_TAN = Math.tan(0.69999999999999996D);
		this_mon.enter();
		Rectangle bounds = canvas.getClientArea();
		if (bufferImage != null && !bufferImage.isDisposed())
			bufferImage.dispose();
		bufferImage = new Image(canvas.getDisplay(), bounds);
		GC image = new GC(bufferImage);
		int max_x = 0;
		int max_y = 0;
		int max_z = 0;
		for (int i = 0; i < values.length; i++)
		{
			int entry[] = (int[])values[i];
			if (entry[0] > max_x)
				max_x = entry[0];
			if (entry[1] > max_y)
				max_y = entry[1];
			if (entry[2] > max_z)
				max_z = entry[2];
		}

		int usable_width = bounds.width - 10 - 10;
		int usable_height = bounds.height - 10 - 10;
		try
		{
			image.setAntialias(1);
		}
		catch (Exception e) { }
		double x_ratio = ((double)(float)usable_width - (double)(usable_height / 2) / ANGLE_TAN) / (double)max_x;
		double y_ratio = (float)usable_height / 2.0F / (float)max_y;
		double z_ratio = (float)usable_height / 2.0F / (float)max_z;
		int x_axis_left_x = 10;
		int x_axis_left_y = usable_height + 10;
		int x_axis_right_x = 10 + usable_width;
		int x_axis_right_y = usable_height + 10;
		int y_axis_left_x = 10;
		int y_axis_left_y = usable_height + 10;
		int y_axis_right_x = 10 + (int)((double)(usable_height / 2) / ANGLE_TAN);
		int y_axis_right_y = usable_height / 2;
		int z_axis_bottom_x = 10;
		int z_axis_bottom_y = usable_height + 10;
		int z_axis_top_x = 10;
		int z_axis_top_y = 10 + usable_height / 2;
		Rectangle old_clip = image.getClipping();
		image.setClipping(new Rectangle(10, 10, usable_width, usable_height));
		image.setForeground(Colors.light_grey);
		int x_lines = 10;
		for (int i = 1; i < x_lines; i++)
		{
			int x1 = x_axis_left_x + ((y_axis_right_x - y_axis_left_x) * i) / x_lines;
			int y1 = x_axis_left_y - ((y_axis_left_y - y_axis_right_y) * i) / x_lines;
			int x2 = x_axis_right_x;
			int y2 = y1;
			image.drawLine(x1, y1, x2, y2);
		}

		int y_lines = 10;
		for (int i = 1; i < y_lines; i++)
		{
			int x1 = y_axis_left_x + ((x_axis_right_x - x_axis_left_x) * i) / x_lines;
			int y1 = y_axis_left_y;
			int x2 = y_axis_right_x + ((x_axis_right_x - x_axis_left_x) * i) / x_lines;
			int y2 = y_axis_right_y;
			image.drawLine(x1, y1, x2, y2);
		}

		image.setClipping(old_clip);
		int z_lines = 10;
		for (int i = 1; i < z_lines; i++)
		{
			int z = z_axis_bottom_y + ((z_axis_top_y - z_axis_bottom_y) * i) / z_lines;
			image.drawLine(z_axis_bottom_x, z, z_axis_bottom_x - 4, z);
		}

		for (int i = 0; i < values.length; i++)
		{
			int entry[] = (int[])values[i];
			int draw_x = (int)(x_ratio * (double)entry[0]);
			int draw_y = (int)(y_ratio * (double)entry[1]);
			int draw_z = (int)(z_ratio * (double)entry[2]);
			draw_x = (int)((double)draw_x + (double)draw_y / ANGLE_TAN);
			image.setForeground(colours[(int)(((float)entry[2] / (float)max_z) * (float)(colours.length - 1))]);
			image.drawLine(10 + draw_x, (10 + usable_height) - draw_y, 10 + draw_x, (10 + usable_height) - (draw_y + draw_z));
		}

		image.setForeground(Colors.black);
		image.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1);
		int font_height = image.getFontMetrics().getHeight();
		int char_width = image.getFontMetrics().getAverageCharWidth();
		image.drawLine(x_axis_left_x, x_axis_left_y, x_axis_right_x, x_axis_right_y);
		image.drawLine(usable_width, x_axis_right_y - 4, x_axis_right_x, x_axis_right_y);
		image.drawLine(usable_width, x_axis_right_y + 4, x_axis_right_x, x_axis_right_y);
		String x_text = (new StringBuilder()).append(labels[0]).append(" - ").append(formatters[0].format(max_x)).toString();
		image.drawText(x_text, x_axis_right_x - 20 - x_text.length() * char_width, x_axis_right_y - font_height - 2, 1);
		String z_text = (new StringBuilder()).append(labels[2]).append(" - ").append(formatters[2].format(max_z)).toString();
		image.drawText(z_text, z_axis_top_x + 4, z_axis_top_y + 10, 1);
		image.drawLine(z_axis_bottom_x, z_axis_bottom_y, z_axis_top_x, z_axis_top_y);
		image.drawLine(z_axis_top_x - 4, z_axis_top_y + 10, z_axis_top_x, z_axis_top_y);
		image.drawLine(z_axis_top_x + 4, z_axis_top_y + 10, z_axis_top_x, z_axis_top_y);
		image.drawLine(y_axis_left_x, y_axis_left_y, y_axis_right_x, y_axis_right_y);
		image.drawLine(y_axis_right_x - 6, y_axis_right_y, y_axis_right_x, y_axis_right_y);
		image.drawLine(y_axis_right_x, y_axis_right_y + 6, y_axis_right_x, y_axis_right_y);
		String y_text = (new StringBuilder()).append(labels[1]).append(" - ").append(formatters[1].format(max_y)).toString();
		image.drawText(y_text, y_axis_right_x - y_text.length() * char_width, y_axis_right_y - font_height - 2, 1);
		image.drawText(title, (bounds.width - title.length() * char_width) / 2, 1, 1);
		image.dispose();
		this_mon.exit();
		break MISSING_BLOCK_LABEL_1171;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}

	public void parameterChanged(String parameter)
	{
		graphicsUpdate = COConfigurationManager.getIntParameter("Graphics Update");
	}

	public void dispose()
	{
		if (bufferImage != null && !bufferImage.isDisposed())
			bufferImage.dispose();
		if (colours != null)
		{
			for (int i = 0; i < colours.length; i++)
				colours[i].dispose();

		}
		COConfigurationManager.removeParameterListener("Graphics Update", this);
	}

	public void update(int _values[][])
	{
		this_mon.enter();
		values = _values;
		this_mon.exit();
		break MISSING_BLOCK_LABEL_32;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}
}

⌨️ 快捷键说明

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