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


Java PageFormat.getImageableY方法代码示例

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


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

示例1: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
/**
 * Prints the chart on a single page.
 *
 * @param g  the graphics context.
 * @param pf  the page format to use.
 * @param pageIndex  the index of the page. If not <code>0</code>, nothing 
 *                   gets print.
 *
 * @return The result of printing.
 */
public int print(Graphics g, PageFormat pf, int pageIndex) {

    if (pageIndex != 0) {
        return NO_SUCH_PAGE;
    }
    Graphics2D g2 = (Graphics2D) g;
    double x = pf.getImageableX();
    double y = pf.getImageableY();
    double w = pf.getImageableWidth();
    double h = pf.getImageableHeight();
    this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor, 
            null);
    return PAGE_EXISTS;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:ChartPanel.java

示例2: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print( Graphics graphics, PageFormat format, int index ) {
    Graphics2D g2d = (Graphics2D)graphics;

    double scalex = g2d.getTransform().getScaleX();
    double scaley = g2d.getTransform().getScaleY();

    double centerx = ( format.getImageableX() +
                     ( format.getImageableWidth() / 2 ) ) * scalex;
    double centery = ( format.getImageableY() +
                     ( format.getImageableHeight() / 2 ) ) * scaley;

    // The following 2 lines cause an error when printing in landscape.
    g2d.scale( 1 / scalex, 1 / scaley );
    g2d.translate( centerx, centery );

    Path2D.Double path = new Path2D.Double();
    path.moveTo( -scalex * 72, -scaley * 72 );
    path.lineTo( -scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, -scaley * 72 );
    path.closePath();

    g2d.draw( path );

    return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LandscapeStackOverflow.java

示例3: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
/**
 * Prints the chart on a single page.
 * 
 * @param g
 *            the graphics context.
 * @param pf
 *            the page format to use.
 * @param pageIndex
 *            the index of the page. If not <code>0</code>, nothing gets print.
 * 
 * @return The result of printing.
 */

@Override
public int print(Graphics g, PageFormat pf, int pageIndex) {

	if (pageIndex != 0) {
		return NO_SUCH_PAGE;
	}
	Graphics2D g2 = (Graphics2D) g;
	double x = pf.getImageableX();
	double y = pf.getImageableY();
	double w = pf.getImageableWidth();
	double h = pf.getImageableHeight();
	this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null);
	return PAGE_EXISTS;

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:AbstractChartPanel.java

示例4: printHeaderFooter

import java.awt.print.PageFormat; //导入方法依赖的package包/类
private void printHeaderFooter(Graphics g, PageFormat pageFormat, int page, String className)
{
    int origPage = page+1;

    // Add header
    g.setColor(Color.BLACK);
    int xOffset = (int)pageFormat.getImageableX();
    int topOffset = (int)pageFormat.getImageableY()+20;
    int bottom = (int)(pageFormat.getImageableY()+pageFormat.getImageableHeight());
    // header line
    g.drawLine(xOffset, topOffset-8, xOffset+(int)pageFormat.getImageableWidth(), topOffset-8);
    // footer line
    g.drawLine(xOffset,                                    bottom-11,
              xOffset+(int)pageFormat.getImageableWidth(), bottom-11);
    g.setFont(new Font(Font.SANS_SERIF,Font.ITALIC,10));

    Graphics2D gg = (Graphics2D) g;
    String pageString = "Page "+origPage;
    int tw = (int) gg.getFont().getStringBounds(pageString,gg.getFontRenderContext()).getWidth();
    
    // header text
    if(className!=null)
        g.drawString(className, xOffset, topOffset-10);
    // footer text
    g.drawString(pageString, xOffset+(int)pageFormat.getImageableWidth()-tw,bottom-2);
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:27,代码来源:BloxsEditor.java

示例5: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
/**
 * Prints the chart on a single page.
 *
 * @param g  the graphics context.
 * @param pf  the page format to use.
 * @param pageIndex  the index of the page. If not <code>0</code>, nothing gets print.
 *
 * @return the result of printing.
 */
public int print(Graphics g, PageFormat pf, int pageIndex) {

    if (pageIndex != 0) {
        return NO_SUCH_PAGE;
    }
    Graphics2D g2 = (Graphics2D) g;
    double x = pf.getImageableX();
    double y = pf.getImageableY();
    double w = pf.getImageableWidth();
    double h = pf.getImageableHeight();
    this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null);
    return PAGE_EXISTS;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:ChartPanel.java

示例6: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
@Override
public int print(Graphics g, PageFormat format, int index) throws PrinterException {
    int pagenum = index + 1;
    if ((pagenum >= 1) && (pagenum <= file.getNumPages())) {
        Graphics2D g2 = (Graphics2D) g;

        PDFPage page = file.getPage(pagenum);

        Rectangle imageArea = new Rectangle((int) format.getImageableX(), (int) format.getImageableY(),
                (int) format.getImageableWidth() , (int) format.getImageableHeight());
        g2.translate(0, 0);
        PDFRenderer pgs = new PDFRenderer(page, g2, imageArea, null, null);
        try {

            page.waitForFinish();

            pgs.run();
        } catch (InterruptedException ie) {
            System.out.println(ie.toString());
        }
        return PAGE_EXISTS;
    } else {
        return NO_SUCH_PAGE;
    }
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:26,代码来源:PrintPdf.java

示例7: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat fmt, int pageNo) {
	if( pageNo>0 ) return NO_SUCH_PAGE;
	Graphics2D g2 = (Graphics2D)g;
	Dimension dim = wwd.getPreferredSize();
	Rectangle r = wwd.getBounds();

	if(r.width>dim.width) r.width = dim.width;
	if(r.height>dim.height) r.height = dim.height;

	org.geomapapp.util.DateFmt df = new org.geomapapp.util.DateFmt();
	int secs = (int)(System.currentTimeMillis()/1000L);
	String date = df.format(secs);
	Font font = new Font("SansSerif", Font.PLAIN, 8);
	g.setFont( font );
	Rectangle2D r2d = font.getStringBounds(date, g2.getFontRenderContext());
//	g2.translate( r.getWidth()-20.-r2d.getWidth(), r.getHeight()+18. );
	g2.setColor( Color.black);

//	g.setClip( new Rectangle( 0, 0, r.width, r.height) );
	double w = fmt.getImageableWidth();
	double h = fmt.getImageableHeight();
	double x = fmt.getImageableX();
	double y = fmt.getImageableY();
	g2.translate(x, y);
	double scale = Math.min( w / r.getWidth(), h / r.getHeight());
	int xd = (int)(scale*r.getWidth()-10.-r2d.getWidth());
	int yd = (int)(scale*r.getHeight()+18.);
	g2.drawString( date, xd, yd);
	g2.translate( -r.getX()*scale, -r.getY()*scale );
	g2.scale( scale, scale);

	wwd.getContext().makeCurrent();
	BufferedImage image = Screenshot.readToBufferedImage(r.width, r.height);
	g2.drawImage(image, 0, 0, this);
	return PAGE_EXISTS;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:37,代码来源:WWMap.java

示例8: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat fmt, int pageNo) {
	printing = true;
	if( pageNo>1 ) {
		printing = false;
		return NO_SUCH_PAGE;
	}
	Rectangle r = getVisibleRect();
	double w = fmt.getImageableWidth();
	double h = fmt.getImageableHeight();
	double x = fmt.getImageableX();
	double y = fmt.getImageableY();
	Insets ins = axes.getInsets();
	double ww = w - ins.left - ins.right;
	double hh = h - ins.top - ins.bottom;
	double rw = (double)(r.width - ins.left - ins.right);
	double rh = (double)(r.height - ins.top - ins.bottom);
	double scale = Math.min( rh/rw, rw/rh);
	double newH = ww * scale;
	double newW = hh * scale;
	if( !tracksWidth || !tracksHeight ) {
		int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
		scale = 72./dpi;
	}
	newW = rw*scale;
	newH = rh*scale;
	x -= (newW-ww)/2;
	y -= (newH-hh)/2;
	w = newW + ins.left + ins.right;
	h = newH +ins.top + ins.bottom;
	printRect = new Rectangle( (int)x,
				(int)y,
				(int)w,
				(int)h );
	paintComponent(g);
	printing = false;
	return PAGE_EXISTS;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:38,代码来源:XYGraph.java

示例9: main

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Page Dialog will be shown.",
                "Change top(in) margin value from 1.0 to 2.0",
                "Then select OK."
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    PrinterJob pj = PrinterJob.getPrinterJob();
    try {
        HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PageFormat pf;
        pf = pj.pageDialog(aset);
        double left = pf.getImageableX();
        double top = pf.getImageableY();
        System.out.println("pageDialog - left/top from pageFormat: " + left / 72
                + " " + top / 72);
        System.out.println("pageDialog - left/top from attribute set: "
                + getPrintableXFromASet(aset) + " "
                + getPrintableYFromASet(aset));
        if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
            throw new RuntimeException("Top margin value not updated");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:PageDialogMarginTest.java

示例10: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat pf, int pi)
        throws PrinterException {
    if (pi != 0) {
        return NO_SUCH_PAGE;
    }
    Graphics2D g2 = (Graphics2D) g;
    g2.setFont(new Font("Serif", Font.PLAIN, 36));
    g2.setPaint(Color.black);
    g2.drawString("Java Source and Support", 100, 100);
    Rectangle2D outline = new Rectangle2D.Double(pf.getImageableX(), pf
            .getImageableY(), pf.getImageableWidth(), pf
            .getImageableHeight());
    g2.draw(outline);
    return PAGE_EXISTS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:PrintTestLexmarkIQ.java

示例11: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
    if (pageIndex>0)
    {
        return NO_SUCH_PAGE;
    }

    StringBuffer s=new StringBuffer();
    for (int i=0;i<10;i++)
    {
        s.append("1234567890ABCDEFGHIJ");
    }

    int x=(int) pageFormat.getImageableX();
    int y=(int) (pageFormat.getImageableY()+50);
    graphics.drawString(s.toString(), x, y);

    return PAGE_EXISTS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:TestUnsupportedResolution.java

示例12: setSize

import java.awt.print.PageFormat; //导入方法依赖的package包/类
private void setSize() {
     int pageCount = printable.getPageCount();
     rowCount = (pageCount - 1) / columnCount + 1;
     pageWidth = 0;
     pageHeight = 0;
     pages = new Page[pageCount];
     PageFormat pageFormat = printable.getPageFormat();
     for (int i = 0; i < pageCount; i++) {
         pageFormat = printable.getPageFormat(pageFormat, i);
         double w = pageFormat.getWidth() + 1;
         double h = pageFormat.getHeight() + 1;
         double iW = pageFormat.getImageableWidth();
         double iH = pageFormat.getImageableHeight();
         double x = pageFormat.getImageableX();
         double y = pageFormat.getImageableY();

         reverce = (pageFormat.getOrientation() == PageFormat.REVERSE_LANDSCAPE);

/*
          * if (pageFormat.getOrientation() == PageFormat.LANDSCAPE) { double
 * t;
 * 
 * t = w; w = h; h = t;
 * 
 * t = iW; iW = iH; iH = t;
 * 
 * t = x; x = y; y = t; }
 */

         Page page = new Page(w, h, x, y, iW, iH);

         if (pageWidth < w)
             pageWidth = w;
         if (pageHeight < h)
             pageHeight = h;
         pages[i] = page;
     }
     width = (columnCount - 1) * (pageWidth + W_SPACE / zoom) + pageWidth;
     height = rowCount * (pageHeight + W_SPACE / zoom);
     Dimension size = new Dimension((int) (width * getZoom()),
             (int) (height * getZoom()));
     this.setSize(size);
     this.setPreferredSize(size);
 }
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:45,代码来源:PrintPreviewComponent.java

示例13: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat pf, int page)
    throws PrinterException {

    if (page > 0) {
        return NO_SUCH_PAGE;
    }
    int ix = (int)pf.getImageableX();
    int iy = (int)pf.getImageableY();
    int iw = (int)pf.getImageableWidth();
    int ih = (int)pf.getImageableHeight();
    System.out.println("ix="+ix+" iy="+iy+" iw="+iw+" ih="+ih);
    if ((ix < 0) || (iy < 0)) {
        throw new RuntimeException("Imageable x or y is a negative value.");
    }


    Paper paper = pf.getPaper();
    int wid = (int)paper.getWidth();
    int hgt = (int)paper.getHeight();
    System.out.println("wid="+wid+" hgt="+hgt);
    /*
     * If imageable width/height is -ve, then print was done with 1" margin
     * e.g. ix=72 iy=72 iw=451 ih=697 and paper wid=595
     * but with fix, we get print with hardware margin e.g.
     * ix=12, iy=12, iw=571, ih=817
     */
    if ((wid - iw > 72) || (hgt - ih > 72)) {
        throw new RuntimeException("Imageable width or height is negative value");
    }
    if ((ix+iw > wid) || (iy+ih > hgt)) {
        throw new RuntimeException("Printable width or height "
                + "exceeds paper width or height.");
    }
    // runtime checking to see if the margins/printable area
    // correspond to the entire size of the paper, for now, make it pass
    // as for linux, the hwmargin is not taken into account - bug6574279
    if (ix == 0 && iy == 0 && (ix+iw == wid) && (iy+ih == hgt)) {
        return PAGE_EXISTS;
    }

    Graphics2D g2d = (Graphics2D)g;
    g2d.translate(ix, iy);
    g2d.setColor(Color.black);
    g2d.drawRect(1, 1, iw-2, ih-2);

    return PAGE_EXISTS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:Margins.java

示例14: print

import java.awt.print.PageFormat; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat fmt, int pageNo) {
	printing = true;
	if( pageNo>1 ) {
		printing = false;
		return NO_SUCH_PAGE;
	}
	Graphics2D g2 = (Graphics2D)g;
	Dimension dim = getPreferredSize();
	Rectangle r = getVisibleRect();
//	if(r.width>dim.width) r.width = dim.width;
//	if(r.height>dim.height) r.height = dim.height;
	double w = fmt.getImageableWidth();
	double h = fmt.getImageableHeight();
	double x = fmt.getImageableX();
	double y = fmt.getImageableY();
	Insets ins = axes.getInsets();
	double ww = w - ins.left - ins.right;
	double hh = h - ins.top - ins.bottom;
	double rw = (double)(r.width - ins.left - ins.right);
	double rh = (double)(r.height - ins.top - ins.bottom);
	double scale = Math.min( rh/rw, rw/rh);
	double newH = ww * scale;
	double newW = hh * scale;
	if( !tracksWidth || !tracksHeight ) {
		int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
		scale = 72./dpi;
	}
	newW = rw*scale;
	newH = rh*scale;
	x -= (newW-ww)/2;
	y -= (newH-hh)/2;
	w = newW + ins.left + ins.right;
	h = newH +ins.top + ins.bottom;
	printRect = new Rectangle( (int)x,
				(int)y,
				(int)w,
				(int)h );
	paintComponent(g);
	printing = false;
	return PAGE_EXISTS;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:42,代码来源:XYGraph.java


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