亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hardcopywriter.java

?? 本書收入了164個完整的Java編程實例
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */package com.davidflanagan.examples.print;import java.awt.*;import java.awt.event.*;import java.io.*;import java.text.*;import java.util.*;/**  * A character output stream that sends output to a printer. **/public class HardcopyWriter extends Writer {    // These are the instance variables for the class    protected PrintJob job;                 // The PrintJob object in use    protected Graphics page;                // Graphics object for current page    protected String jobname;               // The name of the print job    protected int fontsize;                 // Point size of the font    protected String time;                  // Current time (appears in header)    protected Dimension pagesize;           // Size of the page (in dots)    protected int pagedpi;                  // Page resolution in dots per inch    protected Font font, headerfont;        // Body font and header font    protected FontMetrics metrics;          // Metrics for the body font    protected FontMetrics headermetrics;    // Metrics for the header font    protected int x0, y0;                   // Upper-left corner inside margin    protected int width, height;            // Size (in dots) inside margins    protected int headery;                  // Baseline of the page header    protected int charwidth;                // The width of each character    protected int lineheight;               // The height of each line    protected int lineascent;               // Offset of font baseline    protected int chars_per_line;           // Number of characters per line    protected int lines_per_page;           // Number of lines per page    protected int charnum = 0, linenum = 0; // Current column and line position    protected int pagenum = 0;              // Current page number    // A field to save state between invocations of the write() method    private boolean last_char_was_return = false;    // A static variable that holds user preferences between print jobs    protected static Properties printprops = new Properties();    /**     * The constructor for this class has a bunch of arguments:       * The frame argument is required for all printing in Java.     * The jobname appears left justified at the top of each printed page.     * The font size is specified in points, as on-screen font sizes are.     * The margins are specified in inches (or fractions of inches).     **/    public HardcopyWriter(Frame frame, String jobname, int fontsize, 			  double leftmargin, double rightmargin,			  double topmargin, double bottommargin) 	throws HardcopyWriter.PrintCanceledException    {	// Get the PrintJob object with which we'll do all the printing.	// The call is synchronized on the static printprops object, which 	// means that only one print dialog can be popped up at a time.	// If the user clicks Cancel in the print dialog, throw an exception.	Toolkit toolkit = frame.getToolkit();   // get Toolkit from Frame	synchronized(printprops) {	    job = toolkit.getPrintJob(frame, jobname, printprops);	}	if (job == null) 	    throw new PrintCanceledException("User cancelled print request");		pagesize = job.getPageDimension();      // query the page size	pagedpi = job.getPageResolution();      // query the page resolution		// Bug Workaround:	// On windows, getPageDimension() and getPageResolution don't work, so	// we've got to fake them.	if (System.getProperty("os.name").regionMatches(true,0,"windows",0,7)){	    // Use screen dpi, which is what the PrintJob tries to emulate	    pagedpi = toolkit.getScreenResolution();	    // Assume a 8.5" x 11" page size.  A4 paper users must change this.	    pagesize = new Dimension((int)(8.5 * pagedpi), 11*pagedpi);	    // We also have to adjust the fontsize.  It is specified in points,	    // (1 point = 1/72 of an inch) but Windows measures it in pixels.	    fontsize = fontsize * pagedpi / 72;	}		// Compute coordinates of the upper-left corner of the page.	// I.e. the coordinates of (leftmargin, topmargin).  Also compute	// the width and height inside of the margins.	x0 = (int)(leftmargin * pagedpi);	y0 = (int)(topmargin * pagedpi);	width = pagesize.width - (int)((leftmargin + rightmargin) * pagedpi);	height = pagesize.height - (int)((topmargin + bottommargin) * pagedpi);		// Get body font and font size	font = new Font("Monospaced", Font.PLAIN, fontsize);  	metrics = frame.getFontMetrics(font);	lineheight = metrics.getHeight();	lineascent = metrics.getAscent();	charwidth = metrics.charWidth('0');  // Assumes a monospaced font!		// Now compute columns and lines will fit inside the margins	chars_per_line = width / charwidth;	lines_per_page = height / lineheight;		// Get header font information	// And compute baseline of page header: 1/8" above the top margin	headerfont = new Font("SansSerif", Font.ITALIC, fontsize);	headermetrics = frame.getFontMetrics(headerfont);	headery = y0 - (int)(0.125 * pagedpi) -  	    headermetrics.getHeight() + headermetrics.getAscent();		// Compute the date/time string to display in the page header	DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,						       DateFormat.SHORT);	df.setTimeZone(TimeZone.getDefault());	time = df.format(new Date());		this.jobname = jobname;                 // save name	this.fontsize = fontsize;               // save font size    }        /**     * This is the write() method of the stream.  All Writer subclasses      * implement this.  All other versions of write() are variants of this one     **/    public void write(char[] buffer, int index, int len) {	synchronized(this.lock) {  // For thread safety	    // Loop through all the characters passed to us	    for(int i = index; i < index + len; i++) {		// If we haven't begun a page (or a new page), do that now.		if (page == null) newpage();				// If the character is a line terminator, then begin new line, 		// unless it is a \n immediately after a \r.		if (buffer[i] == '\n') {		    if (!last_char_was_return) newline();		    continue;		}		if (buffer[i] == '\r') {		    newline();		    last_char_was_return = true;		    continue;		}		else last_char_was_return = false;				// If it some other non-printing character, ignore it.		if (Character.isWhitespace(buffer[i]) &&		    !Character.isSpaceChar(buffer[i]) && (buffer[i] != '\t'))		    continue;				// If no more characters will fit on the line, start new line.		if (charnum >= chars_per_line) {		    newline();		    // Also start a new page, if necessary		    if (page == null) newpage();  		}				// Now print the character:		// If it is a space, skip one space, without output.		// If it is a tab, skip the necessary number of spaces.		// Otherwise, print the character.		// It is inefficient to draw only one character at a time, but		// because our FontMetrics don't match up exactly to what the		// printer uses we need to position each character individually		if (Character.isSpaceChar(buffer[i])) charnum++;		else if (buffer[i] == '\t') charnum += 8 - (charnum % 8);		else {		    page.drawChars(buffer, i, 1, 				   x0 + charnum * charwidth, 				   y0 + (linenum*lineheight) + lineascent);		    charnum++;		}	    }	}    }        /**      * This is the flush() method that all Writer subclasses must implement.     * There is no way to flush a PrintJob without prematurely printing the     * page, so we don't do anything.     **/    public void flush() { /* do nothing */ }        /**     * This is the close() method that all Writer subclasses must implement.     * Print the pending page (if any) and terminate the PrintJob.     */    public void close() {	synchronized(this.lock) {	    if (page != null) page.dispose();   // Send page to the printer	    job.end();                          // Terminate the job	}    }        /**     * Set the font style.  The argument should be one of the font style      * constants defined by the java.awt.Font class.  All subsequent output     * will be in that style.  This method relies on all styles of the     * Monospaced font having the same metrics.     **/    public void setFontStyle(int style) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产露脸精彩对白| 久久国产福利国产秒拍| 夜夜嗨av一区二区三区中文字幕| 亚洲婷婷国产精品电影人久久| 中文字幕国产一区二区| 国产精品黄色在线观看| 日韩一区有码在线| 一区二区三区在线视频免费| 亚洲综合色网站| 午夜av一区二区三区| 日本欧美久久久久免费播放网| 久久99精品一区二区三区三区| 国产在线精品一区二区夜色| 国产91精品一区二区麻豆网站 | 日本欧美加勒比视频| 秋霞午夜鲁丝一区二区老狼| 另类小说一区二区三区| 高清久久久久久| 色8久久精品久久久久久蜜| 在线观看免费一区| 欧美一级片在线| 91精品国产综合久久精品| 精品国产乱码久久久久久闺蜜| 中文字幕不卡的av| 亚洲综合在线电影| 韩日精品视频一区| 国产精品99久久久久久宅男| 91色乱码一区二区三区| 56国语精品自产拍在线观看| 久久人人超碰精品| 亚洲精品日产精品乱码不卡| 五月综合激情网| 国产精品亚洲午夜一区二区三区| www.久久久久久久久| 337p亚洲精品色噜噜噜| 国产欧美中文在线| 亚洲国产精品视频| 成人av在线网| 日韩手机在线导航| 一二三区精品视频| 99久久国产综合精品麻豆| 精品欧美久久久| 色一情一伦一子一伦一区| 精品久久久久久久人人人人传媒 | 欧美调教femdomvk| 国产精品不卡在线| 国产成人综合视频| 日韩精品一区二区三区中文不卡| 亚洲一区免费视频| 色综合天天做天天爱| 国产精品欧美极品| 国产福利精品导航| 欧美va亚洲va在线观看蝴蝶网| 亚洲五码中文字幕| 色狠狠色狠狠综合| 亚洲欧美日韩在线播放| 国产盗摄女厕一区二区三区| 日韩一区二区视频在线观看| 亚洲一区二区中文在线| 色综合中文字幕| 椎名由奈av一区二区三区| 国产成人精品一区二| 久久精品视频在线看| 国产呦精品一区二区三区网站| 91精品久久久久久久99蜜桃| 夜夜精品浪潮av一区二区三区| 93久久精品日日躁夜夜躁欧美| 中文字幕成人av| 成人免费观看视频| 国产精品久久夜| www.日韩大片| 日韩理论片网站| 色妞www精品视频| 亚洲欧美日韩一区| 色www精品视频在线观看| 亚洲欧美电影院| 欧美在线观看视频在线| 亚洲一区二区三区在线| 欧美曰成人黄网| 丝袜美腿成人在线| 日韩一二在线观看| 韩国毛片一区二区三区| 久久久午夜精品| 成人高清免费观看| 亚洲欧美一区二区不卡| 欧美色中文字幕| 男女性色大片免费观看一区二区 | 亚洲成人一区在线| 欧美人与性动xxxx| 日本成人在线网站| 欧美xxxx在线观看| 国产91丝袜在线播放九色| 国产精品初高中害羞小美女文| 91香蕉视频mp4| 亚洲国产日韩a在线播放| 91.xcao| 黑人巨大精品欧美黑白配亚洲| 国产亚洲精品精华液| 99热99精品| 一区二区三区蜜桃网| 91精品黄色片免费大全| 精品一区二区三区av| 久久精品网站免费观看| 91视视频在线观看入口直接观看www| 亚洲免费观看高清| 在线播放91灌醉迷j高跟美女| 久久99精品久久久久婷婷| 中文一区二区在线观看| 色婷婷一区二区三区四区| 午夜不卡av在线| 久久精品一区八戒影视| 色先锋资源久久综合| 日本人妖一区二区| 日本一区二区三区四区| 在线亚洲人成电影网站色www| 日本成人超碰在线观看| 亚洲国产成人自拍| 欧美日韩精品久久久| 国产精品一区二区91| 一区二区三区在线视频观看| 日韩美女在线视频| 色综合久久中文综合久久牛| 免费人成在线不卡| 综合中文字幕亚洲| 日韩欧美久久久| 91女神在线视频| 国产综合色精品一区二区三区| 亚洲欧美电影一区二区| 欧美本精品男人aⅴ天堂| 一本一本大道香蕉久在线精品| 奇米色一区二区三区四区| 中文字幕日本不卡| 欧美mv日韩mv国产网站| 色av成人天堂桃色av| 国产高清成人在线| 日韩专区一卡二卡| 亚洲欧美一区二区三区国产精品| 欧美电视剧免费观看| 欧美午夜免费电影| 处破女av一区二区| 男女性色大片免费观看一区二区 | 成人av网址在线观看| 欧美aaaaa成人免费观看视频| 中文字幕在线观看一区二区| 欧美一区二区三区的| 色婷婷精品大视频在线蜜桃视频| 国产在线精品视频| 日本不卡一二三区黄网| 亚洲男人的天堂一区二区| 精品国产电影一区二区| 欧美日本在线一区| 一本色道久久加勒比精品| 国产高清视频一区| 久久精品国产一区二区三 | 成人一级视频在线观看| 美女看a上一区| 亚洲成人先锋电影| 亚洲综合久久久| 18涩涩午夜精品.www| 国产欧美精品一区二区色综合| 欧美一区二区免费观在线| 欧美日韩国产一区| 91精品办公室少妇高潮对白| 不卡电影免费在线播放一区| 狠狠色狠狠色综合日日91app| 偷拍日韩校园综合在线| 亚洲午夜av在线| 色婷婷国产精品综合在线观看| 国产激情精品久久久第一区二区 | 欧美日韩免费电影| 色婷婷国产精品综合在线观看| 懂色av一区二区三区免费观看| 国内精品第一页| 久久99精品久久久久久国产越南| 麻豆久久一区二区| 免费观看一级欧美片| 爽好多水快深点欧美视频| 亚洲国产精品一区二区www在线 | 欧美吞精做爰啪啪高潮| 色香蕉成人二区免费| 一本一道波多野结衣一区二区| 91在线视频播放地址| 91首页免费视频| 在线看国产日韩| 欧美偷拍一区二区| 欧美美女一区二区在线观看| 欧美最新大片在线看| 欧美午夜一区二区| 欧美猛男gaygay网站| 555夜色666亚洲国产免| 91精品国产91久久久久久最新毛片| 欧美久久久久久久久中文字幕| 欧美精品第1页| 69久久夜色精品国产69蝌蚪网| 欧美日韩精品一区二区三区蜜桃| 欧美日韩精品一区视频| 91精品欧美久久久久久动漫| 日韩一区二区精品葵司在线| 欧美变态口味重另类| 久久久久国产免费免费|