當前位置: 首頁>>代碼示例>>Java>>正文


Java Paper.setSize方法代碼示例

本文整理匯總了Java中java.awt.print.Paper.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Paper.setSize方法的具體用法?Java Paper.setSize怎麽用?Java Paper.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.print.Paper的用法示例。


在下文中一共展示了Paper.setSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Get an instance of {@link java.awt.print.PageFormat}.
 * @param pj {@link java.awt.print.PrinterJob} which is 
 * associated with the default printer.
 * @return an instance of <code>PageFormat</code> that describes the size and
 * orientation of a page to be printed.
 */
public static PageFormat getPageFormat(PrinterJob pj) {
    PageFormat pageFormat = null;
    pageFormat = pj.defaultPage();
    Paper p = pageFormat.getPaper();
    int pageOrientation = getPreferences().getInt(PROP_PAGE_ORIENTATION, pageFormat.getOrientation());
    double paperWidth = getPreferences().getDouble(PROP_PAGE_WIDTH, p.getWidth());
    double paperHeight = getPreferences().getDouble(PROP_PAGE_HEIGHT, p.getHeight());
    
    double iaWidth = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, p.getImageableWidth());
    double iaHeight = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, p.getImageableHeight());
    double iaX = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_X, p.getImageableX());
    double iaY = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_Y, p.getImageableY());
    
    pageFormat.setOrientation(pageOrientation);
    p.setSize(paperWidth, paperHeight);
    p.setImageableArea(iaX, iaY, iaWidth, iaHeight);
    pageFormat.setPaper(p);
    return pageFormat;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:PrintPreferences.java

示例2: getPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
public PageFormat getPageFormat() {
    PrinterJob job = PrinterJob.getPrinterJob();

    if (myPageFormat == null) {
        myPageFormat = job.defaultPage();

        // restore
        myPageFormat.setOrientation(round(get(PAGE_ORIENTATION, PageFormat.PORTRAIT)));
        Paper paper = myPageFormat.getPaper();

        if (get(PAPER_WIDTH, null) != null && get(PAPER_HEIGHT, null) != null) {
            paper.setSize(get(PAPER_WIDTH, INCH), get(PAPER_HEIGHT, INCH));
        }
        if (get(AREA_X, null) != null && get(AREA_Y, null) != null && get(AREA_WIDTH, null) != null && get(AREA_HEIGHT, null) != null) {
            paper.setImageableArea(get(AREA_X, INCH), get(AREA_Y, INCH), get(AREA_WIDTH, INCH), get(AREA_HEIGHT, INCH));
        }
        myPageFormat.setPaper(paper);
    }
    return myPageFormat;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:Config.java

示例3: testGetPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
public void testGetPageFormat() {
    PrinterJob pj = PrinterJob.getPrinterJob();
    PageFormat expResult = PrintPreferences.getPageFormat(pj);
    PrintPreferences.setPageFormat(expResult);
    PageFormat result = PrintPreferences.getPageFormat(pj);
    assertEquals(expResult.getHeight(), result.getHeight());
    assertEquals(expResult.getWidth(), result.getWidth());
    assertEquals(expResult.getOrientation(), result.getOrientation());
    assertEquals(expResult.getPaper().getHeight(), result.getPaper().getHeight());
    assertEquals(expResult.getPaper().getWidth(), result.getPaper().getWidth());
    assertEquals(expResult.getPaper().getImageableHeight(), result.getPaper().getImageableHeight());
    assertEquals(expResult.getPaper().getImageableWidth(), result.getPaper().getImageableWidth());
    assertEquals(expResult.getPaper().getImageableX(), result.getPaper().getImageableX());
    assertEquals(expResult.getPaper().getImageableY(), result.getPaper().getImageableY());
    
    double w = expResult.getPaper().getWidth() + 10;
    double h = expResult.getPaper().getHeight() + 10;
    Paper p = expResult.getPaper();
    double ix = p.getImageableX() + 10;
    double iy = p.getImageableY() + 10;
    double iw = p.getImageableWidth() + 10;
    double ih = p.getImageableHeight() + 10;
    p.setImageableArea(ix, iy, iw, ih);
    p.setSize(w, h);
    expResult.setPaper(p);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(h, PrintPreferences.getPageFormat(pj).getHeight());
    assertEquals(w, PrintPreferences.getPageFormat(pj).getWidth());
    assertEquals(ix, PrintPreferences.getPageFormat(pj).getPaper().getImageableX());
    assertEquals(iy, PrintPreferences.getPageFormat(pj).getPaper().getImageableY());
    assertEquals(iw, PrintPreferences.getPageFormat(pj).getPaper().getImageableWidth());
    assertEquals(ih, PrintPreferences.getPageFormat(pj).getPaper().getImageableHeight());
    
    expResult.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(PageFormat.REVERSE_LANDSCAPE, PrintPreferences.getPageFormat(pj).getOrientation());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:PrintPreferencesTest.java

示例4: EPSPrinter

import java.awt.print.Paper; //導入方法依賴的package包/類
public EPSPrinter(Printable printable, String title,
                  PrintStream stream,
                  int x, int y, int wid, int hgt) {

    this.printable = printable;
    this.epsTitle = title;
    this.stream = stream;
    llx = x;
    lly = y;
    urx = llx+wid;
    ury = lly+hgt;
    // construct a PageFormat with zero margins representing the
    // exact bounds of the applet. ie construct a theoretical
    // paper which happens to exactly match applet panel size.
    Paper p = new Paper();
    p.setSize((double)wid, (double)hgt);
    p.setImageableArea(0.0,0.0, (double)wid, (double)hgt);
    pf = new PageFormat();
    pf.setPaper(p);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:PSPrinterJob.java

示例5: doTest

import java.awt.print.Paper; //導入方法依賴的package包/類
private static void doTest() {
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(Chromaticity.MONOCHROME);

    MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
    float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
    Paper paper = new Paper();
    paper.setSize(size[0] * 72.0, size[1] * 72.0);
    paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
    PageFormat pf = new PageFormat();
    pf.setPaper(paper);

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf));
    if (job.printDialog()) {
        try {
            job.print(aset);
        } catch (PrinterException pe) {
            throw new RuntimeException(pe);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:WrongPaperPrintingTest.java

示例6: setPaperWidth

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Sets the width for this page. This also validates the imageable bounds of
 * the paper.
 */
public boolean setPaperWidth(double width) {
	if (width == pageFormat.getWidth())
		return false;

	double oldWidth = pageFormat.getWidth();
	Paper paper = pageFormat.getPaper();
	paper.setSize(width, paper.getHeight());
	pageFormat.setPaper(paper);
	firePropertyChange(PROPERTY_WIDTH, new Double(oldWidth), new Double(
			width));

	validateImageableBounds();

	return true;
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:20,代碼來源:PrintLayout.java

示例7: setPaperHeight

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Sets the height for this page. This also validates the imageable bounds
 * of the paper.
 */
public boolean setPaperHeight(double height) {
	if (height == pageFormat.getHeight())
		return false;

	double oldHeight = pageFormat.getHeight();
	Paper paper = pageFormat.getPaper();
	paper.setSize(paper.getWidth(), height);
	pageFormat.setPaper(paper);
	firePropertyChange(PROPERTY_WIDTH, new Double(oldHeight), new Double(
			height));

	validateImageableBounds();

	return true;
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:20,代碼來源:PrintLayout.java

示例8: getPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
private PageFormat getPageFormat() {
	final double mmToDots = 72 / 2.54;

	SettingsModel settings = Controller.get().getConfig();
	Paper p = new Paper();
	p.setSize(
		settings.getValue("PageWidht", 21.0 * mmToDots),
		settings.getValue("PageHeight", 29.7 * mmToDots)
	);
	p.setImageableArea(
		settings.getValue("PageImageableX", 2.5 * mmToDots),
		settings.getValue("PageImageableY", 1.0 * mmToDots),
		settings.getValue("PageImageableWidth", 17.5 * mmToDots),
		settings.getValue("PageImageableHeight", 27.7 * mmToDots)
	);
	PageFormat pf = new PageFormat();
	pf.setPaper(p);
	pf.setOrientation(settings.getValue("PageOrientation", PageFormat.PORTRAIT));
	return pf;
}
 
開發者ID:SmallLars,項目名稱:esadb,代碼行數:21,代碼來源:GUI.java

示例9: getPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Gets a page format instance that describes this page's geometry in terms
 * of the Java print API.
 * 
 * @return A throwaway PageFormat object that describes this page's current
 *         geometry. Changes to the returned PageFormat object will not
 *         affect this page in any way.
 */
public PageFormat getPageFormat() {
    PageFormat pageFormat = new PageFormat();
    pageFormat.setOrientation(getOrientation().getPrintApiCode());
    Paper paper = new Paper();
    
    if (getOrientation() == PageOrientation.PORTRAIT) {
        paper.setSize(getWidth(), getHeight());
    } else {
        paper.setSize(getHeight(), getWidth());
    }

    // the imageable area on the page format we return determines the clipping
    // region for the print API, so we always want to set it as big as possible
    // regardless of our own margin guides
    paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());

    pageFormat.setPaper(paper);
    
    return pageFormat;
}
 
開發者ID:SQLPower,項目名稱:wabit,代碼行數:29,代碼來源:Page.java

示例10: pageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * Returns the page format for printing.
 */
public PageFormat pageFormat() {
    if (fPageFormat == null) {
        // initialize with defaults
        PrinterJob job = PrinterJob.getPrinterJob();
        fPageFormat = job.defaultPage();
        Paper p = fPageFormat.getPaper();
        p.setSize(Options.PRINT_PAGEFORMAT_WIDTH,
                Options.PRINT_PAGEFORMAT_HEIGHT);
        fPageFormat.setPaper(p);
        if (Options.PRINT_PAGEFORMAT_ORIENTATION.equals("portrait"))
            fPageFormat.setOrientation(PageFormat.PORTRAIT);
        else if (Options.PRINT_PAGEFORMAT_ORIENTATION.equals("landscape"))
            fPageFormat.setOrientation(PageFormat.LANDSCAPE);
        else if (Options.PRINT_PAGEFORMAT_ORIENTATION.equals("seascape"))
            fPageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    }
    return fPageFormat;
}
 
開發者ID:vnu-dse,項目名稱:rtl,代碼行數:22,代碼來源:MainWindow.java

示例11: main

import java.awt.print.Paper; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    PDFJob job=new PDFJob(new FileOutputStream("test.pdf"));   
    PageFormat pf=new PageFormat();
    pf.setOrientation(PageFormat.PORTRAIT);
    Paper p = new Paper();
    p.setSize(210,297); //A4
    pf.setPaper(p);
    
    BufferedImage img = ImageIO.read(new File("earth.jpg"));
    
    int w = 200;
    
    for(int i=0;i<10;i++){
        Graphics g = job.getGraphics();
        g.drawImage(img, 0, 0,w,w, null);
        g.dispose();
    }
    
    job.end();
}
 
開發者ID:jindrapetrik,項目名稱:jpexs-decompiler,代碼行數:21,代碼來源:Test.java

示例12: setPageFormatFromString

import java.awt.print.Paper; //導入方法依賴的package包/類
/**
 * @param pPageFormat
 * @param pPageFormatProperty
 */
public static void setPageFormatFromString(Paper pPaper,
		String pPageFormatProperty) {
	try {
		// parse string:
		StringTokenizer tokenizer = new StringTokenizer(
				pPageFormatProperty, ";");
		if (tokenizer.countTokens() != 6) {
			logger.warning("Page format property has not the correct format:"
					+ pPageFormatProperty);
			return;
		}
		pPaper.setSize(nt(tokenizer), nt(tokenizer));
		pPaper.setImageableArea(nt(tokenizer), nt(tokenizer),
				nt(tokenizer), nt(tokenizer));
	} catch (Exception e) {
		freemind.main.Resources.getInstance().logException(e);
	}
}
 
開發者ID:iwabuchiken,項目名稱:freemind_1.0.0_20140624_214725,代碼行數:23,代碼來源:Tools.java

示例13: internalizePageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
/** Reads a PageFormat instance from ObjectInput
* @param obtis
* @return deserialized PageFormat instance
*/
private static PageFormat internalizePageFormat(ObjectInput obtis)
throws IOException, ClassNotFoundException {
    PageFormat pf = new PageFormat();
    Paper paper = pf.getPaper();
    int etc = obtis.readInt();
    if (etc == (PageFormat.LANDSCAPE ^ PageFormat.REVERSE_LANDSCAPE ^ PageFormat.PORTRAIT)) {
        return null;
    }
    pf.setOrientation(etc);
    // paper size
    paper.setSize(obtis.readDouble(), obtis.readDouble());
    // imageable
    paper.setImageableArea(obtis.readDouble(),
                           obtis.readDouble(),
                           obtis.readDouble(),
                           obtis.readDouble());
    pf.setPaper(paper);
    return pf;
}
 
開發者ID:CharlesSkelton,項目名稱:studio,代碼行數:24,代碼來源:PrintSettings.java

示例14: createPageFormat

import java.awt.print.Paper; //導入方法依賴的package包/類
/** @return A newly created {@link PageFormat} with the current settings. */
public PageFormat createPageFormat() {
	PageFormat format = new PageFormat();
	PageOrientation orientation = getPageOrientation();
	double[] size = getPaperSize(LengthUnits.PT);
	double[] margins = getPaperMargins(LengthUnits.PT);
	Paper paper = new Paper();

	if (orientation == PageOrientation.PORTRAIT) {
		format.setOrientation(PageFormat.PORTRAIT);
	} else if (orientation == PageOrientation.LANDSCAPE) {
		format.setOrientation(PageFormat.LANDSCAPE);
	} else if (orientation == PageOrientation.REVERSE_PORTRAIT) {
		// REVERSE_PORTRAIT doesn't exist in the old PageFormat class
		format.setOrientation(PageFormat.PORTRAIT);
	} else if (orientation == PageOrientation.REVERSE_LANDSCAPE) {
		format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
	}
	paper.setSize(size[0], size[1]);
	paper.setImageableArea(margins[1], margins[0], size[0] - (margins[1] + margins[3]), size[1] - (margins[0] + margins[2]));
	format.setPaper(paper);
	return format;
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:24,代碼來源:PrintManager.java

示例15: transSVG

import java.awt.print.Paper; //導入方法依賴的package包/類
protected PdfTemplate transSVG( String svgPath, byte[] svgData, float x,
		float y, float height, float width, String helpText )
		throws IOException, DocumentException
{
	PdfTemplate template = contentByte.createTemplate( width, height );
	Graphics2D g2D = template.createGraphics( width, height );

	PrintTranscoder transcoder = new PrintTranscoder( );
	if ( null != svgData && svgData.length > 0 )
	{
		transcoder.transcode( new TranscoderInput(
				new ByteArrayInputStream( svgData ) ), null );
	}
	else if ( null != svgPath )
	{
		transcoder.transcode( new TranscoderInput( svgPath ), null );
	}
	PageFormat pg = new PageFormat( );
	Paper p = new Paper( );
	p.setSize( width, height );
	p.setImageableArea( 0, 0, width, height );
	pg.setPaper( p );
	transcoder.print( g2D, pg, 0 );
	g2D.dispose( );
	return template;
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:27,代碼來源:PDFPage.java


注:本文中的java.awt.print.Paper.setSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。