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

📄 gcstringprinter.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// 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:   GCStringPrinter.java

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

import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.util.Debug;

public class GCStringPrinter
{
	private class LineInfo
	{

		public int width;
		String originalLine;
		String lineOutputed;
		int excessPos;
		public int relStartPos;
		public int height;
		public int imageIndexes[];
		final GCStringPrinter this$0;

		public String toString()
		{
			return (new StringBuilder()).append(toString()).append(": relStart=").append(relStartPos).append(";xcess=").append(excessPos).append(";orig=").append(originalLine).append(";output=").append(lineOutputed).toString();
		}

		public LineInfo(String originalLine, int relStartPos)
		{
			this$0 = GCStringPrinter.this;
			Object();
			this.originalLine = originalLine;
			this.relStartPos = relStartPos;
		}
	}

	public static class URLInfo
	{

		public String url;
		public String text;
		public Color urlColor;
		public Color dropShadowColor;
		int relStartPos;
		public List hitAreas;
		int titleLength;
		public String fullString;
		public String title;
		public String target;
		public boolean urlUnderline;

		public String toString()
		{
			return (new StringBuilder()).append(toString()).append(": relStart=").append(relStartPos).append(";url=").append(url).append(";title=").append(text).append(";hit=").append(hitAreas != null ? hitAreas.size() : 0).toString();
		}

		public URLInfo()
		{
			hitAreas = null;
		}
	}


	private static final boolean DEBUG = false;
	private static final String GOOD_STRING = "(/|,jI~`gy";
	public static final int FLAG_SKIPCLIP = 1;
	public static final int FLAG_FULLLINESONLY = 2;
	public static final int FLAG_NODRAW = 4;
	public static final int FLAG_KEEP_URL_INFO = 8;
	private static final Pattern patHREF = Pattern.compile("<\\s*?a\\s.*?href\\s*?=\\s*?\"(.+?)\".*?>(.*?)<\\s*?/a\\s*?>", 2);
	private static final Pattern patAHREF_TITLE = Pattern.compile("title=\\\"([^\\\"]+)", 2);
	private static final Pattern patAHREF_TARGET = Pattern.compile("target=\\\"([^\\\"]+)", 2);
	private static final int MAX_LINE_LEN = 4000;
	private static final int MAX_WORD_LEN = 4000;
	private boolean cutoff;
	private GC gc;
	private String string;
	private Rectangle printArea;
	private int swtFlags;
	private int printFlags;
	private Point size;
	private Color urlColor;
	private List listUrlInfo;
	private Image images[];
	private float imageScales[];

	public static boolean printString(GC gc, String string, Rectangle printArea)
	{
		return printString(gc, string, printArea, false, false);
	}

	public static boolean printString(GC gc, String string, Rectangle printArea, boolean skipClip, boolean fullLinesOnly)
	{
		return printString(gc, string, printArea, skipClip, fullLinesOnly, 192);
	}

	public static boolean printString(GC gc, String string, Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
	{
		GCStringPrinter sp = new GCStringPrinter(gc, string, printArea, skipClip, fullLinesOnly, swtFlags);
		return sp.printString();
		Exception e;
		e;
		e.printStackTrace();
		return false;
	}

	private boolean _printString()
	{
		boolean b = false;
		try
		{
			boolean wasAdvanced = gc.getAdvanced();
			Rectangle clipping = null;
			if (gc.getAdvanced() && gc.getTextAntialias() == -1 && gc.getAlpha() == 255)
			{
				clipping = gc.getClipping();
				gc.setAdvanced(false);
				gc.setClipping(clipping);
			}
			b = __printString();
			if (wasAdvanced)
			{
				gc.setAdvanced(true);
				gc.setClipping(clipping);
			}
		}
		catch (Throwable t)
		{
			Debug.out(t);
		}
		return b;
	}

	private boolean __printString()
	{
		ArrayList lines;
		boolean fullLinesOnly;
		boolean skipClip;
		boolean noDraw;
		boolean wrap;
		Rectangle rectDraw;
		Rectangle oldClipping;
		size = new Point(0, 0);
		if (string == null)
			return false;
		if (printArea == null || printArea.isEmpty())
			return false;
		lines = new ArrayList();
		for (; string.indexOf('\t') >= 0; string = string.replace('\t', ' '));
		fullLinesOnly = (printFlags & 2) > 0;
		skipClip = (printFlags & 1) > 0;
		noDraw = (printFlags & 4) > 0;
		wrap = (swtFlags & 0x40) > 0;
		if ((printFlags & 8) == 0)
		{
			Matcher htmlMatcher = patHREF.matcher(string);
			boolean hasURL = htmlMatcher.find();
			if (hasURL)
			{
				listUrlInfo = new ArrayList(1);
				URLInfo urlInfo;
				for (; hasURL; hasURL = htmlMatcher.find(urlInfo.relStartPos))
				{
					urlInfo = new URLInfo();
					urlInfo.fullString = htmlMatcher.group();
					urlInfo.relStartPos = htmlMatcher.start(0);
					urlInfo.url = string.substring(htmlMatcher.start(1), htmlMatcher.end(1));
					urlInfo.text = string.substring(htmlMatcher.start(2), htmlMatcher.end(2));
					urlInfo.titleLength = urlInfo.text.length();
					Matcher matcherTitle = patAHREF_TITLE.matcher(urlInfo.fullString);
					if (matcherTitle.find())
						urlInfo.title = string.substring(urlInfo.relStartPos + matcherTitle.start(1), urlInfo.relStartPos + matcherTitle.end(1));
					Matcher matcherTarget = patAHREF_TARGET.matcher(urlInfo.fullString);
					if (matcherTarget.find())
						urlInfo.target = string.substring(urlInfo.relStartPos + matcherTarget.start(1), urlInfo.relStartPos + matcherTarget.end(1));
					string = htmlMatcher.replaceFirst(urlInfo.text.replaceAll("\\$", "\\\\\\$"));
					listUrlInfo.add(urlInfo);
					htmlMatcher = patHREF.matcher(string);
				}

			}
		} else
		{
			Matcher htmlMatcher = patHREF.matcher(string);
			string = htmlMatcher.replaceAll("$2");
		}
		rectDraw = new Rectangle(printArea.x, printArea.y, printArea.width, printArea.height);
		oldClipping = null;
		int iCurrentHeight;
		int currentCharPos;
		int posNewLine;
		int posLastNewLine;
		if (!skipClip && !noDraw)
		{
			oldClipping = gc.getClipping();
			gc.setClipping(printArea);
		}
		iCurrentHeight = 0;
		currentCharPos = 0;
		int pos1 = string.indexOf('\n');
		int pos2 = string.indexOf('\r');
		if (pos2 == -1)
			pos2 = pos1;
		posNewLine = Math.min(pos1, pos2);
		if (posNewLine < 0)
			posNewLine = string.length();
		posLastNewLine = 0;
_L17:
		String sLine;
		if (posNewLine < 0 || posLastNewLine >= string.length())
			break MISSING_BLOCK_LABEL_1306;
		sLine = string.substring(posLastNewLine, posNewLine);
_L16:
		LineInfo lineInfo;
		String sProcessedLine;
		lineInfo = new LineInfo(sLine, currentCharPos);
		lineInfo = processLine(gc, lineInfo, printArea, wrap, fullLinesOnly, false);
		sProcessedLine = lineInfo.lineOutputed;
		if (sProcessedLine == null || sProcessedLine.length() <= 0) goto _L2; else goto _L1
_L1:
		Point extent;
		boolean isOverY;
		if (lineInfo.width == 0 || lineInfo.height == 0)
		{
			Point gcExtent = gc.stringExtent(sProcessedLine);
			if (lineInfo.width == 0)
				lineInfo.width = gcExtent.x;
			if (lineInfo.height == 0)
				lineInfo.height = gcExtent.y;
		}
		extent = new Point(lineInfo.width, lineInfo.height);
		iCurrentHeight += extent.y;
		isOverY = iCurrentHeight > printArea.height;
		if (!isOverY || fullLinesOnly) goto _L4; else goto _L3
_L3:
		lines.add(lineInfo);
		  goto _L5
_L4:
		if (!isOverY || !fullLinesOnly) goto _L7; else goto _L6
_L6:
		String excess = lineInfo.excessPos < 0 ? null : sLine.substring(lineInfo.excessPos);
		if (excess == null) goto _L9; else goto _L8
_L8:
		if (!fullLinesOnly) goto _L11; else goto _L10
_L10:
		if (lines.size() <= 0) goto _L13; else goto _L12
_L12:
		lineInfo = (LineInfo)lines.remove(lines.size() - 1);
		sProcessedLine = lineInfo.originalLine.length() <= 4000 ? lineInfo.originalLine : lineInfo.originalLine.substring(0, 4000);
		extent = gc.stringExtent(sProcessedLine);
		  goto _L14
_L13:
		boolean flag = false;
		return flag;
_L11:
		sProcessedLine = sProcessedLine.length() <= 4000 ? sProcessedLine : sProcessedLine.substring(0, 4000);
_L14:
		if (excess.length() > 4000)
			excess = excess.substring(0, 4000);
		StringBuffer outputLine = new StringBuffer(sProcessedLine);
		lineInfo.width = extent.x;
		int newExcessPos = processWord(gc, sProcessedLine, (new StringBuilder()).append(" ").append(excess).toString(), printArea, false, lineInfo, outputLine, new StringBuffer());
		lineInfo.lineOutputed = outputLine.toString();
		lines.add(lineInfo);
_L9:
		cutoff = true;
		outputLine = 0;
		return outputLine;
_L7:
		lines.add(lineInfo);
_L5:
		sLine = lineInfo.excessPos < 0 || !wrap ? null : sLine.substring(lineInfo.excessPos);
		currentCharPos += lineInfo.excessPos < 0 ? lineInfo.lineOutputed.length() : lineInfo.excessPos;
		continue; /* Loop/switch isn't completed */
_L2:
		lines.add(lineInfo);
		currentCharPos++;
		break; /* Loop/switch isn't completed */
		if (sLine != null) goto _L16; else goto _L15
_L15:
		if (string.length() > posNewLine && string.charAt(posNewLine) == '\r' && string.charAt(posNewLine + 1) == '\n')
			posNewLine++;
		posLastNewLine = posNewLine + 1;
		currentCharPos = posLastNewLine;
		int pos1 = string.indexOf('\n', posLastNewLine);
		int pos2 = string.indexOf('\r', posLastNewLine);
		if (pos2 == -1)
			pos2 = pos1;
		posNewLine = Math.min(pos1, pos2);
		if (posNewLine < 0)
			posNewLine = string.length();
		  goto _L17
		break MISSING_BLOCK_LABEL_1642;
		local;
		if (lines.size() > 0)
		{
			StringBuffer fullText = new StringBuffer(string.length() + 10);
			LineInfo lineInfo;
			for (Iterator iter = lines.iterator(); iter.hasNext(); fullText.append(lineInfo.lineOutputed))
			{
				lineInfo = (LineInfo)iter.next();
				if (fullText.length() > 0)
					fullText.append('\n');
			}

			for (Iterator iter = lines.iterator(); iter.hasNext();)
			{
				LineInfo lineInfo = (LineInfo)iter.next();
				size.x = Math.max(lineInfo.width, size.x);
				size.y += lineInfo.height;
			}

			if ((swtFlags & 0x400) != 0)
				rectDraw.y = (rectDraw.y + rectDraw.height) - size.y;
			else
			if ((swtFlags & 0x80) == 0)
				rectDraw.y = rectDraw.y + (rectDraw.height - size.y) / 2;
			if (!noDraw || listUrlInfo != null)
			{
				for (Iterator iter = lines.iterator(); iter.hasNext();)
				{
					LineInfo lineInfo = (LineInfo)iter.next();
					try
					{
						drawLine(gc, lineInfo, swtFlags, rectDraw, noDraw);
					}
					catch (Throwable t)
					{
						t.printStackTrace();
					}
				}

			}
		}
		if (!skipClip && !noDraw)
			gc.setClipping(oldClipping);
		JVM INSTR ret 23;
		cutoff |= size.y > printArea.height;
		return !cutoff;
	}

	private LineInfo processLine(GC gc, LineInfo lineInfo, Rectangle printArea, boolean wrap, boolean fullLinesOnly, boolean hasMoreElements)
	{
		if (lineInfo.originalLine.length() == 0)
		{
			lineInfo.lineOutputed = "";
			lineInfo.height = gc.stringExtent("(/|,jI~`gy").y;
			return lineInfo;
		}
		StringBuffer outputLine = new StringBuffer();
		int excessPos = -1;
		if (images != null || lineInfo.originalLine.length() > 4000 || gc.stringExtent(lineInfo.originalLine).x > printArea.width)
		{
			StringBuffer space = new StringBuffer(1);
			if (!wrap && images == null)
			{
				String sProcessedLine = lineInfo.originalLine.length() <= 4000 ? lineInfo.originalLine : lineInfo.originalLine.substring(0, 4000);
				excessPos = processWord(gc, lineInfo.originalLine, sProcessedLine, printArea, wrap, lineInfo, outputLine, space);
			} else
			{
				int posLastWordStart = 0;
				int posWordStart = lineInfo.originalLine.indexOf(' ');
				if (posWordStart < 0)
					posWordStart = lineInfo.originalLine.length();
				int curPos = 0;
				do
				{

⌨️ 快捷键说明

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