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

📄 manualviewer.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		{			stream.close();		} catch (IOException e)		{			System.out.println("Error closing file");		}		editorPane.setText(sb.toString());		editorPane.setCaretPosition(0);		if (!pageFound) setTitle("Electric Manual");	}	/**	 * Method to go to the previous page that was viewed.	 */	private void back()	{		int len = history.size();		if (len <= 1) return;		Object lastPage = history.get(len-2);		history.remove(len-1);		if (lastPage instanceof Integer)		{			history.remove(len-2);			Integer lpi = (Integer)lastPage;			loadPage(lpi.intValue());			return;		}		if (lastPage instanceof String)		{			editorPane.setText((String)lastPage);			editorPane.setCaretPosition(0);		}	}	/**	 * Method to go to the previous page in the manual.	 */	private void prev()	{		int index = currentIndex - 1;		if (index < 0) index = pageSequence.size() - 1;		loadPage(index);	}	/**	 * Method to go to the next page in the manual.	 */	private void next()	{		int index = currentIndex + 1;		if (index >= pageSequence.size()) index = 0;		loadPage(index);	}	private void search()	{		String ret = searchField.getText().trim();		if (ret.length() == 0) return;		Pattern pattern = Pattern.compile(ret, Pattern.CASE_INSENSITIVE);		StringBuffer sbResult = new StringBuffer();		sbResult.append("<CENTER><H1>Search Results for " + ret + "</H1></CENTER>\n");		int numFound = 0;		for(int index=0; index < pageSequence.size(); index++)		{			PageInfo pi = pageSequence.get(index);			InputStream stream = TextUtils.getURLStream(pi.url, null);			InputStreamReader is = new InputStreamReader(stream);			StringBuffer sb = new StringBuffer();			for(;;)			{				String line = getLine(is);				if (line == null) break;				if (line.length() == 0) continue;				if (line.equals("<!-- TRAILER -->")) continue;				if (line.startsWith("<!-- COMMAND ")) continue;				if (line.startsWith("<!-- NEED ")) continue;				if (line.startsWith("<!-- HEADER ")) line = line.substring(12);				sb.append(line);			}			Matcher matcher = pattern.matcher(sb.toString());			if (!matcher.find()) continue;			sbResult.append("<B><A HREF=\"" + pi.fileName + ".html\">" + pi.fullChapterNumber + ": " + pi.title + "</A></B<BR>\n");			numFound++;		}		sbResult.append("<P><B>Found " + numFound + " entries</B>\n");		String wholePage = sbResult.toString();		history.add(wholePage);		editorPane.setText(wholePage);		editorPane.setCaretPosition(0);	}	/**	 * Method to generate a 1-page HTML file with the entire manual.	 * This is an advanced function that is not available to users.	 * The purpose of the single-file HTML is to generate an acrobat file (pdf).	 */	private void manual1Page()	{		String manualFileName = OpenFile.chooseOutputFile(FileType.HTML, "Manual file", "electric.html");		if (manualFileName == null) return;		PrintWriter printWriter = null;		try		{			printWriter = new PrintWriter(new BufferedWriter(new FileWriter(manualFileName)));		} catch (IOException e)		{			System.out.println("Error creating " + manualFileName);			return;		}		Set<String> usedFiles = new HashSet<String>();		for(int index=0; index < pageSequence.size(); index++)		{			PageInfo pi = pageSequence.get(index);			usedFiles.add(pi.fileName + ".html");			InputStream stream = TextUtils.getURLStream(pi.url, null);			InputStreamReader is = new InputStreamReader(stream);			int lastIndex = index - 1;			if (lastIndex < 0) lastIndex = pageSequence.size() - 1;			PageInfo lastPi = pageSequence.get(lastIndex);			String lastFileName = lastPi.fileName;			int nextIndex = index + 1;			if (nextIndex >= pageSequence.size()) nextIndex = 0;			PageInfo nextPi = pageSequence.get(nextIndex);			String nextFileName = nextPi.fileName;			for(;;)			{				String line = getLine(is);				if (line == null) break;				if (line.length() == 0) continue;				if (line.startsWith("<!-- HEADER "))				{					int endPt = line.indexOf("-->");					if (endPt < 0)					{						System.out.println("No end comment on line: "+line);						continue;					}					String pageName = line.substring(12, endPt).trim();					if (pi.level < 2 || pi.newAtLevel)					{						if (pi.chapterNumber > 0 && lastPi.chapterNumber < pi.chapterNumber)						{							printWriter.println("<HR>");							printWriter.println("<CENTER><H1><A NAME=\"" + pi.fileName + "\">Chapter " + pi.chapterName + "</A></H1></CENTER>");						} else						{							printWriter.println("<!-- PAGE BREAK --><A NAME=\"" + pi.fileName + "\"></A>");							printWriter.println("<CENTER><FONT SIZE=6><B>Chapter " + pi.chapterName + "</B></FONT></CENTER>");						}						printWriter.println("<CENTER><TABLE WIDTH=\"90%\" BORDER=0><TR>");						printWriter.println("<TD><CENTER><A HREF=\"" + lastFileName + ".html#" + lastFileName +							".html\"><IMG SRC=\"iconplug.png\" ALT=\"plug\" BORDER=0></A></CENTER></TD>");						printWriter.println("<TD><CENTER><H2>" + pageName + "</H2></CENTER></TD>");						printWriter.println("<TD><CENTER><A HREF=\"" + nextFileName + ".html#" + nextFileName +							".html\"><IMG SRC=\"iconplug.png\" ALT=\"plug\" BORDER=0></A></CENTER></TD></TR></TABLE></CENTER>");						printWriter.println("<HR>");						printWriter.println("<BR>");					} else					{						printWriter.println("<H3>" + pageName + "</H3>");					}					continue;				}				if (line.equals("<!-- TRAILER -->")) continue;				printWriter.println(line);				// look for "SRC=" image references				int imgPos = line.indexOf("SRC=\"");				if (imgPos >= 0)				{					int startPos = line.indexOf('"', imgPos);					if (startPos > 0)					{						int endPos = line.indexOf('"', startPos+1);						if (endPos > startPos)						{							String imgFile = line.substring(startPos+1, endPos);							usedFiles.add(imgFile);						}					}				}				// look for "HREF=" hyperlink references				int refPos = line.indexOf("HREF=\"");				if (refPos >= 0)				{					int startPos = line.indexOf('"', refPos);					if (startPos > 0)					{						int endPos1 = line.indexOf('"', startPos+1);						if (endPos1 < 0) endPos1 = line.length();						int endPos2 = line.indexOf('#', startPos+1);						if (endPos2 < 0) endPos2 = line.length();						int endPos = Math.min(endPos1, endPos2);						if (endPos > startPos)						{							String htmlFile = line.substring(startPos+1, endPos);							if (!htmlFile.startsWith("http://") && !htmlFile.startsWith("mailto:"))								usedFiles.add(htmlFile);						}					}				}			}		}		printWriter.println("</BODY>");		printWriter.println("</HTML>");		printWriter.close();		// report on extraneous files and missing files		usedFiles.add("toc.txt");		usedFiles.add("iconbackarrow.png");		usedFiles.add("iconforearrow.png");		usedFiles.add("iconcontarrow.png");		usedFiles.add("samples.jelib");		usedFiles.add("floatingGates.jelib");		usedFiles.add("demoCage.j3d");		String classPath = htmlBaseClass.getPackage().getName() + "." + htmlDirectory;		List<String> manFiles = TextUtils.getAllResources(classPath);		for(String s : manFiles)		{			if (usedFiles.contains(s)) continue;			System.out.println("File " + s + " is not used");		}		for(String s : usedFiles)		{			if (manFiles.contains(s)) continue;			System.out.println("File " + s + " is missing");		}	}	/**	 * Method to generate a multi-page HTML file with the entire manual.	 * This is an advanced function that is not available to users.	 * The output is a single "index" file, and many chapter files that start with the letter "m"	 * (i.e. "mchap01-01.html").	 * If you copy the "index.html", all of the "mchap" files, and all of the image files,	 * it will be a complete manual.	 */	private void manualManyPages()	{		String manualFileName = OpenFile.chooseOutputFile(FileType.HTML, "Manual file", "index.html");		if (manualFileName == null) return;		PrintWriter printWriter = null;		try		{			printWriter = new PrintWriter(new BufferedWriter(new FileWriter(manualFileName)));		} catch (IOException e)		{			System.out.println("Error creating " + manualFileName);			return;		}		System.out.println("Writing 'index.html' and many files starting with 'mchap'");		// gather the table of contents by chapter		int lastChapterNumber = 0;		StringBuffer chapterText = new StringBuffer();		List<String> chapters = new ArrayList<String>();		StringBuffer afterTOC = new StringBuffer();		for(int index=0; index < pageSequence.size(); index++)		{			PageInfo pi = pageSequence.get(index);			if (pi.chapterNumber <= 0)			{				InputStream stream = TextUtils.getURLStream(pi.url, null);				InputStreamReader is = new InputStreamReader(stream);				for(;;)				{					String line = getLine(is);					if (line == null) break;					if (line.length() == 0) continue;					if (line.startsWith("<!-- HEADER ")) continue;					if (line.startsWith("<!-- TRAILER ")) continue;					if (line.equals("<HR>")) break;					printWriter.println(line);				}				for(;;)				{					String line = getLine(is);					if (line == null) break;					if (line.length() == 0) continue;					if (line.startsWith("<!-- HEADER ")) continue;					if (line.startsWith("<!-- TRAILER ")) continue;					afterTOC.append(line);				}				try				{					is.close();				} catch (IOException e) {}				continue;			}			if (pi.chapterNumber != lastChapterNumber)			{				if (lastChapterNumber > 0) chapters.add(chapterText.toString());				lastChapterNumber = pi.chapterNumber;				chapterText = new StringBuffer();				chapterText.append("<B>Chapter " + pi.chapterName.toUpperCase() + "</B><BR>");			}			chapterText.append("<A HREF=\"m" + pi.fileName + ".html\">" + pi.fullChapterNumber + ": " + pi.title + "</A><BR>");		}		chapters.add(chapterText.toString());		// write the table of contents		printWriter.println("<CENTER><H1>Table of Contents</H1></CENTER>");		printWriter.println("<CENTER><TABLE BORDER=\"1\">");		for(int i=0; i<chapters.size(); i += 2)		{			String leftSide = chapters.get(i);			String rightSide = "";			if (i+1 < chapters.size()) rightSide = chapters.get(i+1);			printWriter.println("<TR><TD VALIGN=TOP>" + leftSide + "</TD>");			printWriter.println("<TD VALIGN=TOP>" + rightSide + "</TD></TR>");		}		printWriter.println("</TABLE></CENTER><HR>");		printWriter.print(afterTOC.toString());		printWriter.println("<CENTER><TABLE BORDER=\"0\"><TR>");		printWriter.println("<TD><A HREF=\"mchap01-01.html\">Next</A></TD>");		printWriter.println("<TD><A HREF=\"mchap01-01.html\"><IMG SRC=\"iconforearrow.png\" ALT=\"Next\" BORDER=\"0\"></A></TD>");		printWriter.println("</TR></TABLE></CENTER>");		printWriter.println("</BODY>");		printWriter.println("</HTML>");		printWriter.close();		for(int index=0; index < pageSequence.size(); index++)		{			PageInfo pi = pageSequence.get(index);			if (pi.chapterNumber <= 0) continue;			InputStream stream = TextUtils.getURLStream(pi.url, null);			InputStreamReader is = new InputStreamReader(stream);			String pageFileName = manualFileName;			int lastSep = pageFileName.lastIndexOf('\\');			if (lastSep >= 0) pageFileName = pageFileName.substring(0, lastSep+1);			pageFileName += "m" + pi.fileName + ".html";			try			{				printWriter = new PrintWriter(new BufferedWriter(new FileWriter(pageFileName)));			} catch (IOException e)			{				System.out.println("Error creating " + pageFileName);				break;			}			printWriter.println("<HTML><HEAD>");			printWriter.println("<TITLE>Electric VLSI Design System User's Manual</TITLE></HEAD>");			printWriter.println("<BODY BGCOLOR=\"#FFFFFF\">");			int lastIndex = index - 1;			if (lastIndex < 0) lastIndex = pageSequence.size() - 1;			PageInfo lastPi = pageSequence.get(lastIndex);			String lastFileName = lastPi.fileName;			if (lastFileName.equals("title")) lastFileName = "index"; else lastFileName = "m" + lastFileName;			int nextIndex = index + 1;			if (nextIndex >= pageSequence.size()) nextIndex = 0;			PageInfo nextPi = pageSequence.get(nextIndex);			String nextFileName = nextPi.fileName;			if (nextFileName.equals("title")) nextFileName = "index"; else nextFileName = "m" + nextFileName;			for(;;)			{				String line = getLine(is);				if (line == null) break;				if (line.length() == 0) continue;				if (line.startsWith("<!-- NEED ")) continue;				if (line.startsWith("<!-- HEADER "))				{					int endPt = line.indexOf("-->");					if (endPt < 0)					{						System.out.println("No end comment on line: "+line);						continue;					}					String pageName = line.substring(12, endPt).trim();					printWriter.println("<A NAME=\"" + pi.fileName + "\"></A>");					printWriter.println("<CENTER><FONT SIZE=6><B>Chapter " + pi.chapterName + "</B></FONT></CENTER>");					printWriter.println("<CENTER><TABLE WIDTH=\"90%\" BORDER=0><TR>");					printWriter.println("<TD><CENTER><A HREF=\"" + lastFileName + ".html#" + lastFileName +						".html\"><IMG SRC=\"iconplug.png\" ALT=\"plug\" BORDER=0></A></CENTER></TD>");					printWriter.println("<TD><CENTER><H2>" + pageName + "</H2></CENTER></TD>");					printWriter.println("<TD><CENTER><A HREF=\"" + nextFileName + ".html#" + nextFileName +						".html\"><IMG SRC=\"iconplug.png\" ALT=\"plug\" BORDER=0></A></CENTER></TD></TR></TABLE></CENTER>");					printWriter.println("<HR>");					printWriter.println("<BR>");					continue;				}				if (line.equals("<!-- TRAILER -->"))				{					printWriter.println("<P>");					printWriter.println("<HR>");					printWriter.println("<CENTER><TABLE BORDER=0><TR>");					printWriter.println("<TD><A HREF=\"" + lastFileName + ".html#" + lastFileName +".html\"><IMG SRC=\"iconbackarrow.png\" ALT=\"Prev\" BORDER=0></A></TD>");					printWriter.println("<TD><A HREF=\"" + lastFileName + ".html#" + lastFileName +".html\">Previous</A></TD>");					printWriter.println("<TD>&nbsp;&nbsp;&nbsp;</TD>");					printWriter.println("<TD><A HREF=\"index.html\"><IMG SRC=\"iconcontarrow.png\" ALT=\"Contents\" BORDER=0></A></TD>");					printWriter.println("<TD><A HREF=\"index.html\">Table of Contents</A></TD>");					printWriter.println("<TD>&nbsp;&nbsp;&nbsp;</TD>");					printWriter.println("<TD><A HREF=\"" + nextFileName + ".html#" + nextFileName +".html\">Next</A></TD>");					printWriter.println("<TD><A HREF=\"" + nextFileName + ".html#" + nextFileName +".html\"><IMG SRC=\"iconforearrow.png\" ALT=\"Next\" BORDER=0></A></TD>");					printWriter.println("</TR></TABLE></CENTER>");					continue;				}				// convert references to other chapters				for(;;)				{					int x = line.indexOf("\"chap");					if (x >= 0)					{						line = line.substring(0, x+1) + "m" + line.substring(x+1);						continue;					}					x = line.indexOf("#chap");					if (x >= 0)					{						line = line.substring(0, x+1) + "m" + line.substring(x+1);						continue;					}					break;				}

⌨️ 快捷键说明

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