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


Java JRGraphics2DExporter类代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.export.JRGraphics2DExporter的典型用法代码示例。如果您正苦于以下问题:Java JRGraphics2DExporter类的具体用法?Java JRGraphics2DExporter怎么用?Java JRGraphics2DExporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JRGraphics2DExporter类属于net.sf.jasperreports.engine.export包,在下文中一共展示了JRGraphics2DExporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
	if (Thread.currentThread().isInterrupted())
	{
		throw new PrinterException("Current thread interrupted.");
	}

	pageIndex += pageOffset;

	if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
	{
		return Printable.NO_SUCH_PAGE;
	}

	try
	{
		JRGraphics2DExporter exporter = new JRGraphics2DExporter();
		exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
		exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
		exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
		exporter.exportReport();
	}
	catch (JRException e)
	{
		e.printStackTrace();
		throw new PrinterException(e.getMessage());
	}

	return Printable.PAGE_EXISTS;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:34,代码来源:JRPrinterAWT300.java

示例2: printPageToImage

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
private Image printPageToImage(int pageIndex, float zoom) throws JRException
{
	Image pageImage = new BufferedImage(
		(int)(jasperPrint.getPageWidth() * zoom) + 1,
		(int)(jasperPrint.getPageHeight() * zoom) + 1,
		BufferedImage.TYPE_INT_RGB
		);

	JRGraphics2DExporter exporter = new JRGraphics2DExporter();
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
	exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
	exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
	exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom));
	exporter.exportReport();

	return pageImage;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:21,代码来源:JRPrinterAWT300.java

示例3: print

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
	if (Thread.interrupted())
	{
		throw new PrinterException("Current thread interrupted.");
	}

	pageIndex += pageOffset;

	if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
	{
		return Printable.NO_SUCH_PAGE;
	}

	try
	{
		JRGraphics2DExporter exporter = new JRGraphics2DExporter(jasperReportsContext);
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput();
		output.setGraphics2D((Graphics2D)graphics);
		exporter.setExporterOutput(output);
		SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration();
		configuration.setPageIndex(pageIndex);
		exporter.setConfiguration(configuration);
		exporter.exportReport();
	}
	catch (JRException e)
	{
		if (log.isDebugEnabled())
		{
			log.debug("Print failed.", e);
		}

		throw new PrinterException(e.getMessage()); //NOPMD
	}

	return Printable.PAGE_EXISTS;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:40,代码来源:JRPrinterAWT.java

示例4: visit

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
@Override
public void visit(JRGenericPrintElement printElement, Offset offset)
{
	GenericElementGraphics2DHandler handler = 
		(GenericElementGraphics2DHandler)GenericElementHandlerEnviroment.getInstance(jasperReportsContext).getElementHandler(
				printElement.getGenericType(), 
				JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY
				);

	if (handler != null)
	{
		handler.exportElement(this.frameDrawer.getExporterContext(), printElement, grx, offset);
	}
	else
	{
		if (log.isDebugEnabled())
		{
			log.debug("No Graphics2D generic element handler for " 
					+ printElement.getGenericType());
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:23,代码来源:PrintDrawVisitor.java

示例5: getGraphics2DExporter

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
@Override
protected JRGraphics2DExporter getGraphics2DExporter() throws JRException
{
	return 
		new JRGraphics2DExporter(viewerContext.getJasperReportsContext())
		{
			@Override
			protected void initReport()
			{
				super.initReport();
				drawVisitor.setClip(true);//FIXMENOW thick border of margin elements is clipped
			}
			@Override
			protected RenderersCache getRenderersCache()
			{
				return viewerContext.getRenderersCache();
			}
		};
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:20,代码来源:JRDesignViewerPanel.java

示例6: exportElement

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
@Override
public void exportElement(
		JRGraphics2DExporterContext exporterContext, 
		JRGenericPrintElement element, 
		Graphics2D grx, 
		Offset offset)
{
	try
	{
		JRGraphics2DExporter exporter = (JRGraphics2DExporter)exporterContext.getExporterRef();
		ImageDrawer imageDrawer = exporter.getDrawVisitor().getImageDrawer();
		
		imageDrawer.draw(
				grx,
				MapElementImageProvider.getImage(exporterContext.getJasperReportsContext(), element), 
				offset.getX(), 
				offset.getY()
				);
	}
	catch (Exception e)
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:MapElementGraphics2DHandler.java

示例7: JSSDrawVisitor

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
public JSSDrawVisitor(ReportConverter reportConverter, Graphics2D grx) {
	this.reportConverter = reportConverter;
	this.convertVisitor = new JSSConvertVisitor(reportConverter);
	final JasperReportsContext jasperReportsContext = reportConverter.getJasperReportsContext();
	this.drawVisitor = new PrintDrawVisitor(jasperReportsContext) {
		@Override
		public void setTextRenderer(JRReport report) {
			AwtTextRenderer textRenderer = new AwtTextRenderer(jasperReportsContext, JRPropertiesUtil.getInstance(
					jasperReportsContext).getBooleanProperty(report, JRGraphics2DExporter.MINIMIZE_PRINTER_JOB_SIZE, true),
					JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(report,
							JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false));

			setTextDrawer(new TextDrawer(jasperReportsContext, textRenderer));
			setFrameDrawer(new FrameDrawer(jasperReportsContext, null, textRenderer));
			
		}

	};
	setTextRenderer(reportConverter.getReport());
	this.grx = grx;
	setGraphics2D(grx);
	this.drawVisitor.setClip(true);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:27,代码来源:JSSDrawVisitor.java

示例8: printPageToImage

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
public Image printPageToImage(int pageIndex, float zoom) throws JRException
{
	PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex);
	
	Image pageImage = new BufferedImage(
		(int)(pageFormat.getPageWidth() * zoom) + 1,
		(int)(pageFormat.getPageHeight() * zoom) + 1,
		BufferedImage.TYPE_INT_RGB
		);

	JRGraphics2DExporter exporter = new JRGraphics2DExporter(jasperReportsContext);
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput();
	output.setGraphics2D((Graphics2D)pageImage.getGraphics());
	exporter.setExporterOutput(output);
	SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration();
	configuration.setPageIndex(pageIndex);
	configuration.setZoomRatio(zoom);
	exporter.setConfiguration(configuration);
	exporter.exportReport();
	
	return pageImage;
}
 
开发者ID:nordpos,项目名称:nordpos,代码行数:27,代码来源:JRPrinterAWT.java

示例9: printPageToImage

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
public Image printPageToImage(int pageIndex, float zoom) throws JRException
{
	PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex);
	
	int rasterWidth = (int) Math.ceil(pageFormat.getPageWidth() * zoom);
	int rasterHeight = (int) Math.ceil(pageFormat.getPageHeight() * zoom);
	Image pageImage = new BufferedImage(
		rasterWidth,
		rasterHeight,
		BufferedImage.TYPE_INT_RGB
		);
	
	Graphics imageGraphics = pageImage.getGraphics();
	Graphics graphics = imageGraphics.create();
	//filling the image background here because JRGraphics2DExporter.exportPage uses the page size
	//which can be smaller than the image size due to Math.ceil above
	graphics.setColor(Color.white);
	graphics.fillRect(0, 0, rasterWidth, rasterHeight);

	JRGraphics2DExporter exporter = new JRGraphics2DExporter(jasperReportsContext);
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput();
	output.setGraphics2D((Graphics2D) imageGraphics);
	exporter.setExporterOutput(output);
	SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration();
	configuration.setPageIndex(pageIndex);
	configuration.setZoomRatio(zoom);
	configuration.setWhitePageBackground(false);
	exporter.setConfiguration(configuration);
	exporter.exportReport();
	
	return pageImage;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:37,代码来源:JRPrinterAWT.java

示例10: draw

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
private void draw(Collection<JRPrintElement> elements) throws JRException
{
	if (elements != null && elements.size() > 0)
	{
		Shape clipArea = grx.getClip();
		for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();)
		{
			JRPrintElement element = it.next();
			boolean isGenericElement = element instanceof JRGenericPrintElement;
			JRGenericPrintElement genericElement =  isGenericElement ? (JRGenericPrintElement)element : null;
			GenericElementGraphics2DHandler handler = isGenericElement 
					? (GenericElementGraphics2DHandler)GenericElementHandlerEnviroment.getInstance(getJasperReportsContext()).getElementHandler(genericElement.getGenericType(), JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY)
					: null;
			
			boolean isGenericElementToExport = isGenericElement && handler != null && handler.toExport(genericElement); 
			
			if (
				(filter != null && !filter.isToExport(element))
				|| !clipArea.intersects(
					element.getX() + elementOffset.getX() - ELEMENT_RECTANGLE_PADDING, 
					element.getY() + elementOffset.getY() - ELEMENT_RECTANGLE_PADDING, 
					element.getWidth() + 2 * ELEMENT_RECTANGLE_PADDING, 
					element.getHeight() + 2 * ELEMENT_RECTANGLE_PADDING)
				)
			{
				continue;
			}
			else if(isGenericElementToExport)
			{
				handler.exportElement(exporterContext, genericElement, grx, elementOffset);
			}
			else
			{
				element.accept(drawVisitor, elementOffset);
			}
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:42,代码来源:FrameDrawer.java

示例11: getGraphics2DExporter

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
protected JRGraphics2DExporter getGraphics2DExporter() throws JRException
{
	return 
		new JRGraphics2DExporter(viewerContext.getJasperReportsContext())
		{
			@Override
			protected RenderersCache getRenderersCache()
			{
				return viewerContext.getRenderersCache();
			}
		};
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:13,代码来源:JRViewerPanel.java

示例12: print

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 *
 */
   @Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
	if (Thread.currentThread().isInterrupted())
	{
		throw new PrinterException("Current thread interrupted.");
	}

	pageIndex += pageOffset;

	if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
	{
		return Printable.NO_SUCH_PAGE;
	}

	try
	{
		JRGraphics2DExporter exporter = new JRGraphics2DExporter();
		exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
		exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
		exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
		exporter.exportReport();
	}
	catch (JRException e)
	{
		throw new PrinterException(e.getMessage());
	}

	return Printable.PAGE_EXISTS;
}
 
开发者ID:gnoopy,项目名称:wifepos,代码行数:34,代码来源:JRPrinterAWT300.java

示例13: logPrintImages

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 * Cria arquivos de imagens das provas. Utilizado exclusivamente em depuracao de codigo
 * @param jp
 * @param eventVO 
 */
protected static void logPrintImages(JasperPrint jp, EventVO eventVO) {
	if(!log.isDebugEnabled()){
		return;
	}
	
	try {

		int pageCount = jp.getPages().size();

		for (int i = 0; i < pageCount; i++) {

			File file = new File("result/evento_"+eventVO.getPK()+"_pg_" + (i + 1) + "."+ JazzOMRImageParser.IMG_EXT);
			
			file.mkdirs();

			JRGraphics2DExporter graphics2dExporter = new JRGraphics2DExporter();
			BufferedImage bi = new BufferedImage(600, 900, BufferedImage.TYPE_4BYTE_ABGR);
			Graphics graphics = bi.createGraphics();
			graphics2dExporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
			graphics2dExporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
			graphics2dExporter.setParameter(JRGraphics2DExporterParameter.PAGE_INDEX, i);
			graphics2dExporter.exportReport();

			ImageIO.write(bi, JazzOMRImageParser.IMG_EXT, file);
		}

	} catch (JRException e1) {
		throw new RuntimeException("erro", e1);
	} catch (IOException e) {
		throw new RuntimeException("erro", e);
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:38,代码来源:ParticipationHelper.java

示例14: printImages

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
/**
 * @param jp
 */
protected void printImages(JasperPrint jp) {
	try {

		int pageCount = jp.getPages().size();

		for (int i = 0; i < pageCount; i++) {

			File file = new File("result/pagina_" + (i + 1) + "."+ JazzOMRImageParser.IMG_EXT);

			JRGraphics2DExporter graphics2dExporter = new JRGraphics2DExporter();
			BufferedImage bi = new BufferedImage(600, 800, BufferedImage.TYPE_4BYTE_ABGR);
			Graphics graphics = bi.createGraphics();
			graphics2dExporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
			graphics2dExporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
			graphics2dExporter.setParameter(JRGraphics2DExporterParameter.PAGE_INDEX, i);
			graphics2dExporter.exportReport();

			ImageIO.write(bi, JazzOMRImageParser.IMG_EXT, file);
		}

	} catch (JRException e1) {
		throw new RuntimeException("erro", e1);
	} catch (IOException e) {
		throw new RuntimeException("erro", e);
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:30,代码来源:OMRModelTest.java

示例15: renderPage

import net.sf.jasperreports.engine.export.JRGraphics2DExporter; //导入依赖的package包/类
private Image renderPage() throws Throwable {
	JasperPrint jr = rViewer.getReport();
	BufferedImage img = new BufferedImage((int) (jr.getPageWidth() * zoom) + 1, (int) (jr.getPageHeight() * zoom) + 1, BufferedImage.TYPE_INT_RGB);

	Graphics2D g2d = (Graphics2D) img.getGraphics();
	try {
		JRGraphics2DExporter exporter = new JRGraphics2DExporter(jContext);
		exporter.setExporterInput(new SimpleExporterInput(jr));

		SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput();
		output.setGraphics2D(g2d);
		exporter.setExporterOutput(output);

		SimpleGraphics2DReportConfiguration grxConfiguration = new SimpleGraphics2DReportConfiguration();
		grxConfiguration.setPageIndex(rViewer.getPageIndex());
		grxConfiguration.setZoomRatio(zoom);
		exporter.setConfiguration(grxConfiguration);

		exporter.exportReport();

		g2d.setColor(Color.black);
		g2d.setStroke(new BasicStroke(1));
		g2d.drawRect(0, 0, (int) (img.getWidth() / zoom), (int) (img.getHeight() / zoom));
	} finally {
		g2d.dispose();
	}
	return UIUtils.awt2Swt(img);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:29,代码来源:ViewerCanvas.java


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