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

📄 generalview.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		Rectangle bounds;
		int xMax;
		int yMax;
		bounds = availabilityImage.getClientArea();
		xMax = bounds.width - 2;
		yMax = bounds.height - 2;
		if (xMax < 10 || yMax < 5)
		{
			this_mon.exit();
			return;
		}
		GC gc;
		GC gcImage;
		if (aImage != null && !aImage.isDisposed())
			aImage.dispose();
		aImage = new Image(display, bounds.width, bounds.height);
		gc = new GC(availabilityImage);
		gcImage = new GC(aImage);
		int allMin;
		String sTotal;
		gcImage.setForeground(Colors.grey);
		gcImage.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1);
		allMin = 0;
		int allMax = 0;
		int total = 0;
		sTotal = "000";
		if (available != null)
		{
			allMin = available.length != 0 ? available[0] : 0;
			allMax = available.length != 0 ? available[0] : 0;
			int nbPieces = available.length;
			for (int i = 0; i < nbPieces; i++)
			{
				if (available[i] < allMin)
					allMin = available[i];
				if (available[i] > allMax)
					allMax = available[i];
			}

			int maxAboveMin = allMax - allMin;
			if (maxAboveMin == 0)
			{
				gcImage.setBackground(Colors.blues[allMin != 0 ? 9 : 0]);
				gcImage.fillRectangle(1, 1, xMax, yMax);
			} else
			{
				for (int i = 0; i < nbPieces; i++)
					if (available[i] > allMin)
						total++;

				total = (total * 1000) / nbPieces;
				sTotal = (new StringBuilder()).append("").append(total).toString();
				if (total < 10)
					sTotal = (new StringBuilder()).append("0").append(sTotal).toString();
				if (total < 100)
					sTotal = (new StringBuilder()).append("0").append(sTotal).toString();
				for (int i = 0; i < xMax; i++)
				{
					int a0 = (i * nbPieces) / xMax;
					int a1 = ((i + 1) * nbPieces) / xMax;
					if (a1 == a0)
						a1++;
					if (a1 > nbPieces)
						a1 = nbPieces;
					int max = 0;
					int min = available[a0];
					int Pi = 1000;
					for (int j = a0; j < a1; j++)
					{
						if (available[j] > max)
							max = available[j];
						if (available[j] < min)
							min = available[j];
						Pi *= available[j];
						Pi /= available[j] + 1;
					}

					int pond = Pi;
					if (max == 0)
					{
						pond = 0;
					} else
					{
						int PiM = 1000;
						for (int j = a0; j < a1; j++)
						{
							PiM *= max + 1;
							PiM /= max;
						}

						pond *= PiM;
						pond /= 1000;
						pond *= max - min;
						pond /= 1000;
						pond += min;
					}
					int index;
					if (pond <= 0 || allMax == 0)
					{
						index = 0;
					} else
					{
						index = ((pond - allMin) * 8) / maxAboveMin + 1;
						if (index > 9)
							index = 9;
					}
					gcImage.setBackground(Colors.blues[index]);
					gcImage.fillRectangle(i + 1, 1, 1, yMax);
				}

			}
		}
		if (availabilityPercent != null && !availabilityPercent.isDisposed())
			break MISSING_BLOCK_LABEL_870;
		gcImage.dispose();
		gc.dispose();
		this_mon.exit();
		return;
		availabilityPercent.setText((new StringBuilder()).append(allMin).append(".").append(sTotal).toString());
		gc.drawImage(aImage, bounds.x, bounds.y);
		gcImage.dispose();
		gc.dispose();
		break MISSING_BLOCK_LABEL_947;
		Exception exception;
		exception;
		gcImage.dispose();
		gc.dispose();
		throw exception;
		this_mon.exit();
		break MISSING_BLOCK_LABEL_969;
		Exception exception1;
		exception1;
		this_mon.exit();
		throw exception1;
	}

	private void updatePiecesInfo(boolean bForce)
	{
		if (manager == null)
			return;
		this_mon.enter();
		if (display == null || display.isDisposed())
		{
			this_mon.exit();
			return;
		}
		if (piecesImage == null || piecesImage.isDisposed())
		{
			this_mon.exit();
			return;
		}
		Rectangle bounds;
		int xMax;
		int yMax;
		DiskManager dm = manager.getDiskManager();
		boolean valid = !bForce;
		boolean new_pieces[] = new boolean[manager.getNbPieces()];
		if (dm != null)
		{
			DiskManagerPiece dm_pieces[] = dm.getPieces();
			for (int i = 0; i < pieces.length; i++)
				new_pieces[i] = dm_pieces[i].isDone();

		}
		if (pieces == null)
		{
			valid = false;
		} else
		{
			int i = 0;
			do
			{
				if (i >= pieces.length)
					break;
				if (pieces[i] != new_pieces[i])
				{
					valid = false;
					break;
				}
				i++;
			} while (true);
		}
		pieces = new_pieces;
		if (valid)
			break MISSING_BLOCK_LABEL_699;
		bounds = piecesImage.getClientArea();
		xMax = bounds.width - 2;
		yMax = bounds.height - 2 - 6;
		if (xMax < 10 || yMax < 5)
		{
			this_mon.exit();
			return;
		}
		int total;
		GC gcImage;
		total = manager.getStats().getDownloadCompleted(true);
		if (pImage != null && !pImage.isDisposed())
			pImage.dispose();
		pImage = new Image(display, bounds.width, bounds.height);
		gcImage = new GC(pImage);
		gcImage.setForeground(Colors.grey);
		gcImage.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1);
		gcImage.drawLine(1, 6, xMax, 6);
		if (pieces != null && pieces.length != 0)
		{
			int nbPieces = pieces.length;
			for (int i = 0; i < xMax; i++)
			{
				int a0 = (i * nbPieces) / xMax;
				int a1 = ((i + 1) * nbPieces) / xMax;
				if (a1 == a0)
					a1++;
				if (a1 > nbPieces)
					a1 = nbPieces;
				int nbAvailable = 0;
				for (int j = a0; j < a1; j++)
				{
					if (pieces[j])
						nbAvailable++;
					int index = (nbAvailable * 9) / (a1 - a0);
					gcImage.setBackground(Colors.blues[index]);
					gcImage.fillRectangle(i + 1, 7, 1, yMax);
				}

			}

		}
		int limit = (xMax * total) / 1000;
		gcImage.setBackground(Colors.colorProgressBar);
		gcImage.fillRectangle(1, 1, limit, 5);
		if (limit < xMax)
		{
			gcImage.setBackground(Colors.blues[0]);
			gcImage.fillRectangle(limit + 1, 1, xMax - limit, 5);
		}
		gcImage.dispose();
		break MISSING_BLOCK_LABEL_608;
		Exception exception;
		exception;
		gcImage.dispose();
		throw exception;
		if (piecesPercent != null && !piecesPercent.isDisposed())
			piecesPercent.setText(DisplayFormatters.formatPercentFromThousands(total));
		if (pImage == null || pImage.isDisposed())
		{
			this_mon.exit();
			return;
		}
		GC gc = new GC(piecesImage);
		gc.drawImage(pImage, bounds.x, bounds.y);
		gc.dispose();
		this_mon.exit();
		break MISSING_BLOCK_LABEL_721;
		Exception exception1;
		exception1;
		this_mon.exit();
		throw exception1;
	}

	private void setTime(String elapsed, String remaining)
	{
		timeElapsed.setText(elapsed);
		timeRemaining.setText(remaining);
	}

	private void setStats(String dl, String ul, String dls, String uls, String ts, String dl_speed, String ul_speed, 
			String s, String p, String completed, String hash_fails, String share_ratio, String ave_comp, String distr_copies)
	{
		if (display == null || display.isDisposed())
		{
			return;
		} else
		{
			download.setText(dl);
			downloadSpeed.setText(dls);
			upload.setText(ul);
			uploadSpeed.setText(uls);
			totalSpeed.setText(ts);
			ave_completion.setText(ave_comp);
			distributedCopies.setText(distr_copies);
			seeds.setText(s);
			peers.setText(p);
			completedLbl.setText(completed);
			hashFails.setText(hash_fails);
			shareRatio.setText(share_ratio);
			return;
		}
	}

	private void setTracker()
	{
		if (display == null || display.isDisposed())
			return;
		String status = manager.getTrackerStatus();
		int time = manager.getTrackerTime();
		TRTrackerAnnouncer trackerClient = manager.getTrackerClient();
		tracker_status.setText(status);
		boolean show_cdp_link = false;
		if (manager.isUnauthorisedOnTracker())
		{
			com.aelitis.azureus.core.util.AZ3Functions.provider az3 = AZ3Functions.getProvider();
			show_cdp_link = az3 != null && az3.canShowCDP(manager);
		}
		if (show_cdp_link)
		{
			tracker_status.setForeground(Colors.colorError);
			tracker_status.setCursor(Cursors.handCursor);
		} else
		{
			tracker_status.setForeground(null);
			tracker_status.setCursor(null);
		}
		if (time < 0)
			trackerUpdateIn.setText(MessageText.getString("GeneralView.label.updatein.querying"));
		else
			trackerUpdateIn.setText(TimeFormatter.formatColon(time));
		String trackerURL = null;
		if (trackerClient != null)
		{
			URL temp = trackerClient.getTrackerUrl();
			if (temp != null)
				trackerURL = temp.toString();
		}
		if (trackerURL == null)
		{
			TOTorrent torrent = manager.getTorrent();
			if (torrent != null)
				trackerURL = torrent.getAnnounceURL().toString();
		}
		if (trackerURL != null)
		{
			trackerUrlValue.setText(trackerURL);
			if (trackerURL.startsWith("http://") || trackerURL.startsWith("https://"))
			{
				trackerUrlValue.setForeground(Colors.blue);
				trackerUrlValue.setCursor(Cursors.handCursor);
				Messages.setLanguageText(trackerUrlValue.getWidget(), "GeneralView.label.trackerurlopen.tooltip", true);
			} else
			{
				trackerUrlValue.setForeground(null);
				trackerUrlValue.setCursor(null);
				Messages.setLanguageText(trackerUrlValue.getWidget(), null);
				trackerUrlValue.setToolTipText(null);
			}
		}
		boolean update_state;
		if (trackerClient != null)
			update_state = SystemTime.getCurrentTime() / 1000L - (long)trackerClient.getLastUpdateTime() >= 60L;
		else
			update_state = false;
		if (updateButton.getEnabled() != update_state)
			updateButton.setEnabled(update_state);
	}

	private void setInfos(final String _fileName, final String _fileSize, final String _torrentStatus, final String _path, final String _hash, final String _pieceData, final String _pieceLength, 
			final String _comment, final String _creation_date, final String _user_comment, final String isPrivate)
	{
		if (display == null || display.isDisposed())
		{
			return;
		} else
		{
			Utils.execSWTThread(new AERunnable() {

				final String val$_fileName;
				final String val$_fileSize;
				final String val$_torrentStatus;
				final String val$_path;
				final String val$_hash;
				final String val$_pieceData;
				final String val$_pieceLength;
				final String val$_creation_date;
				final String val$isPrivate;
				final String val$_comment;
				final String val$_user_comment;
				final GeneralView this$0;

				public void runSupport()
				{
					fileName.setText(_fileName);
					fileSize.setText(_fileSize);
					torrentStatus.setText(_torrentStatus);
					saveIn.setText(_path);
					hash.setText(_hash);
					pieceNumber.setText(_pieceData);
					pieceSize.setText(_pieceLength);
					creation_date.setText(_creation_date);
					privateStatus.setText(isPrivate);
					boolean do_relayout = false;
					do_relayout = GeneralView.setCommentAndFormatLinks(lblComment, _comment.length() <= 5000 || !Constants.isWindowsXP ? _comment : _comment.substring(0, 5000)) | do_relayout;
					do_relayout = GeneralView.setCommentAndFormatLinks(user_comment, _user_comment) | do_relayout;
					if (do_relayout)
						gInfo.layout();
				}

			
			{
				this$0 = GeneralView.this;
				_fileName = s;
				_fileSize = s1;
				_torrentStatus = s2;
				_path = s3;
				_hash = s4;
				_pieceData = s5;
				_pieceLength = s6;
				_creation_date = s7;
				isPrivate = s8;
				_comment = s9;
				_user_comment = s10;
				super();
			}
			});
			return;
		}
	}

	private static boolean setCommentAndFormatLinks(Control c, String new_comment)
	{
		String old_comment = (String)c.getData("comment");
		if (new_comment == null)
			new_comment = "";
		if (new_comment.equals(old_comment))
			return false;
		c.setData("comment", new_comment);
		if (c instanceof Label)
			((Label)c).setText(new_comment);
		else
		if (c instanceof Link)
		{
			String sNewComment = new_comment.replaceAll("([^=\">][\\s]+|^)(http://[\\S]+)", "$1<A HREF=\"$2\">$2</A>");
			sNewComment = sNewComment.replaceAll("(href=)(htt[^\\s>]+)", "$1\"$2\"");
			((Link)c).setText(sNewComment);
		}
		return true;
	}

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

	public Image obfusticatedImage(Image image, Point shellOffset)
	{
		UIDebugGenerator.obfusticateArea(image, (Control)fileName.getWidget(), shellOffset, manager.toString());
		UIDebugGenerator.obfusticateArea(image, (Control)saveIn.getWidget(), shellOffset, Debug.secretFileName(saveIn.getText()));
		return image;
	}





}

⌨️ 快捷键说明

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