当前位置: 首页>>代码示例>>Java>>正文


Java PrintJob.getGraphics方法代码示例

本文整理汇总了Java中java.awt.PrintJob.getGraphics方法的典型用法代码示例。如果您正苦于以下问题:Java PrintJob.getGraphics方法的具体用法?Java PrintJob.getGraphics怎么用?Java PrintJob.getGraphics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.PrintJob的用法示例。


在下文中一共展示了PrintJob.getGraphics方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printThisFrame

import java.awt.PrintJob; //导入方法依赖的package包/类
public void printThisFrame(int xoff, int yoff, boolean makeBorder) {

        java.util.Properties printprefs = new java.util.Properties();
        Toolkit toolkit = this.getToolkit();
        PrintJob job = toolkit.getPrintJob(this,"Java Print",printprefs);
        if (job == null) {return;}
        Graphics g = job.getGraphics();
        g.translate(xoff,yoff);                      // Offset from upper left corner
        Dimension size = this.getSize();
        if (makeBorder) {                           // Rectangular border
            g.drawRect(-1,-1,size.width+2,size.height+2);
        }
        g.setClip(0,0,size.width,size.height);
        this.printAll(g);
        g.dispose();
        job.end();

    }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:19,代码来源:ContourFrame.java

示例2: printThisFrame

import java.awt.PrintJob; //导入方法依赖的package包/类
public void printThisFrame(int xoff, int yoff, boolean makeBorder) {

        java.util.Properties printprefs = new java.util.Properties();
        Toolkit toolkit = this.getToolkit();
        PrintJob job = toolkit.getPrintJob(this,"Java Print",printprefs);
        if (job == null) {return;}
        Graphics g = job.getGraphics();
        g.translate(xoff,yoff);     // Offset from upper left corner
        Dimension size = this.getSize();
        if (makeBorder) {           // Rectangular border
            g.drawRect(-1,-1,size.width+2,size.height+2);
        }
        g.setClip(0,0,size.width,size.height);
        this.printAll(g);
        g.dispose();
        job.end();
    }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:18,代码来源:IsoData.java

示例3: printThisFrame

import java.awt.PrintJob; //导入方法依赖的package包/类
public void printThisFrame(int xoff, int yoff, boolean makeBorder) {

        java.util.Properties printprefs = new java.util.Properties();
        Toolkit toolkit = this.getToolkit();
        PrintJob job = toolkit.getPrintJob(this,"Java Print",printprefs);
        if (job == null) {return;}
        Graphics g = job.getGraphics();
        g.translate(xoff,yoff);     // Offset from upper left corner
        Dimension size = this.getSize();
        if (makeBorder) {           // Rectangular border
            g.drawRect(-1,-1,size.width+2,size.height+2);
        }
        g.setClip(0,0,size.width,size.height);
        this.printAll(g);
        g.dispose();
        job.end();

    }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:19,代码来源:PlotParams.java

示例4: printThisFrame

import java.awt.PrintJob; //导入方法依赖的package包/类
public void printThisFrame(int xoff, int yoff, boolean makeBorder) {

        java.util.Properties printprefs = new java.util.Properties();
        Toolkit toolkit = this.getToolkit();
        PrintJob job = toolkit.getPrintJob(this,"Java Print",printprefs);
        if (job == null) {return;}
        Graphics g = job.getGraphics();
        g.translate(xoff,yoff);          // Offset from upper left corner
        Dimension size = this.getSize();
        if (makeBorder) {                // Rectangular border
            g.drawRect(-1,-1,size.width+2,size.height+2);
        }
        g.setClip(0,0,size.width,size.height);
        this.printAll(g);

        g.dispose();
        job.end();
    }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:19,代码来源:SegreFrame.java

示例5: printThisFrame

import java.awt.PrintJob; //导入方法依赖的package包/类
public void printThisFrame(int xoff, int yoff, boolean makeBorder) {

        java.util.Properties printprefs = new java.util.Properties();
        Toolkit toolkit = this.getToolkit();
        PrintJob job = toolkit.getPrintJob(this,"Java Print",printprefs);
        if (job == null) {return;}
        Graphics g = job.getGraphics();
        g.translate(xoff,yoff);          // Offset from upper left corner
        Dimension size = this.getSize();
        if (makeBorder) {               // Rectangular border
            g.drawRect(-1,-1,size.width+2,size.height+2);
        }
        g.setClip(0,0,size.width,size.height);
        this.printAll(g);
        g.dispose();
        job.end();

    }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:19,代码来源:AbPlotFrame.java

示例6: print

import java.awt.PrintJob; //导入方法依赖的package包/类
/**
 * Function for printing image.
 * 
 * @param _pic instance of Picture that is printed.
 */
public static void print(final Picture _pic) {

	BufferedImage bi_pic = _pic.calculateImage();
JFrame jf = new JFrame();
	jf.setSize(
			(int) Toolkit.getDefaultToolkit().getScreenSize().getHeight()
			* bi_pic.getWidth()  / bi_pic.getHeight(),
			(int) Toolkit.getDefaultToolkit().getScreenSize().getHeight());
	jf.setVisible(false);
	PrintJob pjob = Toolkit.getDefaultToolkit().getPrintJob(
			jf, "paintPrint", null);
	if (pjob != null) {
	      Graphics pg = pjob.getGraphics();
	      if (pg != null) {
	    	  bi_pic = resize(bi_pic, jf.getWidth(), jf.getHeight());
	    	  pg.drawImage(bi_pic, 0, 0, null);
	    	  pg.dispose();
	      }
	      pjob.end();
	    }
	jf.dispose();
}
 
开发者ID:juliusHuelsmann,项目名称:paint,代码行数:28,代码来源:Util.java

示例7: printInform

import java.awt.PrintJob; //导入方法依赖的package包/类
/**
 * Print Inform document
 */
public void printInform(jFrame jframe, String title, JTextComponent jif) {
    Properties prop = new Properties();
    PrintJob pjob = jframe.getToolkit().getPrintJob(jframe, title, prop);
    if (pjob != null) {
        Graphics pg = pjob.getGraphics();
        if (pg != null) {
            String s = jif.getText();
            printLongString(pjob, pg, s);
            pg.dispose();
        }
        pjob.end();
    }
}
 
开发者ID:silverslade,项目名称:jif,代码行数:17,代码来源:Utils.java

示例8: print

import java.awt.PrintJob; //导入方法依赖的package包/类
public static void print() {

		ContourPlotter p = new ContourPlotter();
		Toolkit toolkit = p.getToolkit();
		PrintJob job = toolkit.getPrintJob(p, "nzPlane", printprefs);

		if (job == null) return;

		Graphics page = job.getGraphics();

		Dimension size = p.getSize();

		Dimension pagesize = job.getPageDimension();
		page.translate((pagesize.width - 700) / 2, (pagesize.height - 650) / 2);
		page.drawRect(1, 1, 700, 650);
		p.print(page);

		page.dispose();
		job.end();

	}
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:22,代码来源:StochasticElements.java

示例9: printLongString

import java.awt.PrintJob; //导入方法依赖的package包/类
private void printLongString(PrintJob pjob, Graphics pg, String s) {

        // Replacing the TABS with spaces
        s = Utils.replace(s, "\t", "    ");

        int margin = 50;
        int pageNum = 1;
        int linesForThisPage = 0;
        int linesForThisJob = 0;
        // Note: String is immutable so won't change while printing.
        if (!(pg instanceof PrintGraphics)) {
            throw new IllegalArgumentException("Graphics context not PrintGraphics");
        }
        StringReader sr = new StringReader(s);
        LineNumberReader lnr = new LineNumberReader(sr);
        String nextLine;
        int pageHeight = pjob.getPageDimension().height - margin;
        Font helv = new Font("Monospaced", Font.PLAIN, 8);
        //have to set the font to get any output
        pg.setFont(helv);
        FontMetrics fm = pg.getFontMetrics(helv);
        int fontHeight = fm.getHeight();
        int fontDescent = fm.getDescent();
        int curHeight = margin;
        try {
            do {
                nextLine = lnr.readLine();
                if (nextLine != null) {
                    if ((curHeight + fontHeight) > pageHeight) {
                        // New Page
                        //System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
                        if (linesForThisPage == 0) {
                            //System.out.println ("Font is too big for pages of this size; aborting...");
                            break;
                        }
                        pageNum++;
                        linesForThisPage = 0;
                        pg.dispose();
                        pg = pjob.getGraphics();
                        if (pg != null) {
                            pg.setFont(helv);
                        }
                        curHeight = 0;
                    }
                    curHeight += fontHeight;
                    if (pg != null) {
                        pg.drawString(nextLine, margin, curHeight - fontDescent);
                        linesForThisPage++;

                        linesForThisJob++;
                    } else {
                        //System.out.println ("pg null");
                    }
                }
            } while (nextLine != null);
        } catch (EOFException eof) {
            // Fine, ignore
        } catch (Throwable t) { // Anything else
            t.printStackTrace();
        }
        //System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
        //System.out.println ("pages printed: " + pageNum);
        //System.out.println ("total lines printed: " + linesForThisJob);
    }
 
开发者ID:silverslade,项目名称:jif,代码行数:65,代码来源:Utils.java


注:本文中的java.awt.PrintJob.getGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。