/**
* Print the plot to a printer, represented by the specified graphics
* object.
*
* @param graphics The context into which the page is drawn.
* @param format The size and orientation of the page being drawn.
* @param index The zero based index of the page to be drawn.
* @return PAGE_EXISTS if the page is rendered successfully, or
* NO_SUCH_PAGE if pageIndex specifies a non-existent page.
* @exception PrinterException If the print job is terminated.
*/
public synchronized int print(Graphics graphics, PageFormat format,
int index) throws PrinterException {
if (graphics == null) return Printable.NO_SUCH_PAGE;
// We only print on one page.
if (index >= 1) {
return Printable.NO_SUCH_PAGE;
}
Graphics2D graphics2D = (Graphics2D) graphics;
// Scale the printout to fit the pages.
// Contributed by Laurent ETUR, Schlumberger Riboud Product Center
double scalex = format.getImageableWidth() / (double) getWidth();
double scaley = format.getImageableHeight() / (double) getHeight();
double scale = Math.min(scalex, scaley);
graphics2D.translate((int)format.getImageableX(),
(int)format.getImageableY());
graphics2D.scale(scale, scale);
_drawPlot(graphics, true);
return Printable.PAGE_EXISTS;
}
PlotBox.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:OpenDA
作者:
评论列表
文章目录