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


Java ImageTypeEnum类代码示例

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


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

示例1: getRenderable

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
/**
 *
 */
public Renderable getRenderable(Image img, OnErrorTypeEnum onErrorType) throws JRException
{
	ImageTypeEnum type = ImageTypeEnum.JPEG;
	if (img instanceof RenderedImage)
	{
		ColorModel colorModel = ((RenderedImage) img).getColorModel();
		//if the image has transparency, encode as PNG
		if (colorModel.hasAlpha() 
				&& colorModel.getTransparency() != Transparency.OPAQUE)
		{
			type = ImageTypeEnum.PNG;
		}
	}
	
	return getRenderable(img, type, onErrorType);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:20,代码来源:RenderableUtil.java

示例2: getImageTypeValue

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
/**
 * 
 */
public static ImageTypeEnum getImageTypeValue(byte[] data) 
{
	if (JRTypeSniffer.isGIF(data)) 
	{
		return ImageTypeEnum.GIF;
	}
	else if (JRTypeSniffer.isJPEG(data)) 
	{
		return ImageTypeEnum.JPEG;
	}
	else if (JRTypeSniffer.isPNG(data)) 
	{
		return ImageTypeEnum.PNG;
	}
	else if (JRTypeSniffer.isTIFF(data)) 
	{
		return ImageTypeEnum.TIFF;
	}
	
	return ImageTypeEnum.UNKNOWN;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:JRTypeSniffer.java

示例3: getSvgInfo

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
/**
 *
 */
public SvgDataSniffer.SvgInfo getSvgInfo(byte[] data)
{
	if (JRTypeSniffer.getImageTypeValue(data) == ImageTypeEnum.UNKNOWN)
	{
		XmlSniffResult xmlSniff = XmlDataSniffer.sniffXml(data);
		if (xmlSniff != null)
		{
			String rootElement = xmlSniff.getRootElementName();
			if (rootElement == null //the sniffer did not determine the root element, trying SVG to be sure
					|| isSvgRootElement(rootElement))
			{
				return getSvgDataSniffer().getSvgInfo(data);
			}
		}
	}
	
	return null;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:RendererUtil.java

示例4: getImageTypeValue

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public ImageTypeEnum getImageTypeValue() 
{
	if (imageType == null)
	{
		try
		{
			return JRTypeSniffer.getImageTypeValue(getImageData());
		}
		catch (JRException e)
		{
			return ImageTypeEnum.UNKNOWN;
		}
	}
	
	return imageType;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:WrappingDeprecatedRenderable.java

示例5: doSaveFile

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
protected void doSaveFile(String filename) {
	if (filename != null) {
		try {
			WSClientHelper.getResource(new NullProgressMonitor(), AFileResourcePageContent.this.res, res.getValue(), filename);
			File file = new File(filename);
			int dotPos = filename.lastIndexOf("."); //$NON-NLS-1$
			String strFilename = filename.substring(0, dotPos);
			ImageTypeEnum itype = JRTypeSniffer.getImageTypeValue(FileUtils.getBytes(file));
			if (itype == ImageTypeEnum.GIF) {
				file = FileUtils.fileRenamed(file, strFilename, ".gif"); //$NON-NLS-1$
			} else if (itype == ImageTypeEnum.JPEG) {
				file = FileUtils.fileRenamed(file, strFilename, ".jpeg"); //$NON-NLS-1$
			} else if (itype == ImageTypeEnum.PNG) {
				file = FileUtils.fileRenamed(file, strFilename, ".png"); //$NON-NLS-1$
			} else if (itype == ImageTypeEnum.TIFF) {
				file = FileUtils.fileRenamed(file, strFilename, ".tiff"); //$NON-NLS-1$
			}
			((AFileResource) res).setFile(file);
		} catch (Exception e1) {
			UIUtils.showError(e1);
		}
		handleFileChange();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:AFileResourcePageContent.java

示例6: exportToIFile

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public IFile exportToIFile(AFileResource res, ResourceDescriptor rd, String fkeyname, IProgressMonitor monitor) throws Exception {
	IFile f = super.exportToIFile(res, rd, fkeyname, monitor);
	if (path == null && f != null) {
		String filename = f.getFullPath().toOSString();
		int dotPos = filename.lastIndexOf(".");
		if (dotPos >= 0)
			filename = filename.substring(0, dotPos);
		ImageTypeEnum itype = JRTypeSniffer.getImageTypeValue(FileUtils.getBytes(f));
		if (itype == ImageTypeEnum.UNKNOWN)
			itype = ImageTypeEnum.PNG;
		if (itype == ImageTypeEnum.GIF) {
			f = FileUtils.fileRenamed(f, filename, ".gif", false, monitor);
		} else if (itype == ImageTypeEnum.JPEG) {
			f = FileUtils.fileRenamed(f, filename, ".jpeg", false, monitor);
		} else if (itype == ImageTypeEnum.PNG) {
			f = FileUtils.fileRenamed(f, filename, ".png", false, monitor);
		} else if (itype == ImageTypeEnum.TIFF) {
			f = FileUtils.fileRenamed(f, filename, ".tiff", false, monitor);
		}
		fileurimap.put(fkeyname, f);
	}
	return f;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:ImageExporter.java

示例7: test

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public void test() {
	super.test();

	numberOfPagesTest(1);

	try {
		byte[] imageData = JRImageLoader.getInstance(DefaultJasperReportsContext.getInstance()).loadBytesFromAwtImage(image, ImageTypeEnum.JPEG);
		JRPrintImage jrImage = (JRPrintImage) getElementAt("title.image1", 0);
		Assert.assertTrue("image data", Arrays.equals(imageData, jrImage.getRenderable().getImageData(DefaultJasperReportsContext.getInstance())));
		Assert.assertEquals("scale image", ScaleImageEnum.CLIP, jrImage.getScaleImageValue());
	} catch (JRException e) {
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:17,代码来源:Image1Test.java

示例8: encode

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public byte[] encode(Image image, ImageTypeEnum imageType) throws JRException
{
	BufferedImage bi = null;
	
	if (image instanceof BufferedImage)
	{
		bi = (BufferedImage)image;
	}
	else
	{
		bi =
			new BufferedImage(
				image.getWidth(null),
				image.getHeight(null),
				// avoid creating JPEG images with transparency that would result 
				// in invalid image files for some viewers (browsers)
				(imageType == ImageTypeEnum.GIF || imageType == ImageTypeEnum.PNG)  
					? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB 
				);

		Graphics g = bi.createGraphics();
		try
		{
			g.drawImage(image, 0, 0, null);
		}
		finally
		{
			g.dispose();
		}
	}

	return encode(bi, imageType);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:35,代码来源:JRAbstractImageEncoder.java

示例9: readObject

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
	in.defaultReadObject();
	
	if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_4_6_0)
	{
		imageTypeValue = ImageTypeEnum.getByValue(imageType);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:10,代码来源:JRImageRenderer.java

示例10: copy

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
protected void copy(JRPrintImage image)
{
	dataset.finishDataset();
	
	JRComponentElement element = fillContext.getComponentElement();
	
    XYChart xyChart = new XYChartBuilder()
    		.width(element.getWidth())
    		.height(element.getHeight())
    		.title(chartTitle == null ? "" : chartTitle)
    		.xAxisTitle(xAxisTitle == null ? "" : xAxisTitle)
    		.yAxisTitle(yAxisTitle == null ? "" : yAxisTitle)
    		.build();
    XYStyler styler = xyChart.getStyler();
    styler.setLegendPosition(Styler.LegendPosition.InsideNE);
    styler.setAxisTitlesVisible(true);
    styler.setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Area);
    styler.setChartBackgroundColor(element.getBackcolor() == null ? Color.WHITE : element.getBackcolor());
    
    List<Comparable<?>> xySeriesNames = dataset.getXYSeriesNames();
	Map<Comparable<?>, XYSeriesData> xySeriesMap = dataset.getXYSeriesMap();
	if(xySeriesMap != null && !xySeriesMap.isEmpty())
	{
		int i = 0;
		for(Comparable<?> name : xySeriesNames)
		{
			XYSeriesData data = xySeriesMap.get(name);
			org.knowm.xchart.XYSeries series = xyChart.addSeries(name.toString(), data.getXData(), data.getYData());
			Color color = data.getColor();
			if(color != null)
			{
				series.setLineColor(color);
				styler.getSeriesColors()[i] = color;
				//series.setFillColor(color);
			}
			i++;
		}
	}
	try
	{
		BufferedImage img = BitmapEncoder.getBufferedImage(xyChart);
		Renderable renderable = RendererUtil
				.getInstance(fillContext.getFiller().getJasperReportsContext())
				.getRenderable(img, ImageTypeEnum.PNG, OnErrorTypeEnum.ERROR);
		image.setRenderer(renderable);
	}
	catch(Exception e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:52,代码来源:FillXYChart.java

示例11: getRenderable

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public Renderable getRenderable(
	JasperReportsContext jasperReportsContext,
	JFreeChart chart, 
	ChartHyperlinkProvider chartHyperlinkProvider,
	Rectangle2D rectangle
	)
{
	int dpi = JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty(Renderable.PROPERTY_IMAGE_DPI, 72);
	double scale = dpi/72d;
	
	BufferedImage bi = 
		new BufferedImage(
			(int) (scale * (int)rectangle.getWidth()),
			(int) (scale * rectangle.getHeight()),
			BufferedImage.TYPE_INT_ARGB
			);

	List<JRPrintImageAreaHyperlink> areaHyperlinks = null;

	Graphics2D grx = bi.createGraphics();
	try
	{
		grx.scale(scale, scale);

		if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks())
		{
			areaHyperlinks = ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, grx, rectangle);
		}
		else
		{
			chart.draw(grx, rectangle);
		}
	}
	finally
	{
		grx.dispose();
	}

	try
	{
		return new SimpleDataRenderer(JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, ImageTypeEnum.PNG), areaHyperlinks);
	}
	catch (JRException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:49,代码来源:ImageChartRendererFactory.java

示例12: getImageTypeValue

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public ImageTypeEnum getImageTypeValue()
{
	return ImageTypeEnum.PNG;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:6,代码来源:JRAbstractSvgRenderer.java

示例13: getImageData

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public byte[] getImageData(JasperReportsContext jasperReportsContext) throws JRException
{
	Dimension2D dimension = getDimension(jasperReportsContext);
	if (dimension == null)
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_DIMENSION_NULL_NOT_ALLOWED, 
				(Object[])null
				);
	}

	int dpi = getImageDataDPI(jasperReportsContext);
	double scale = dpi/72d;
	
	ImageTypeEnum imageType = getImageTypeValue();
	BufferedImage bi =
		new BufferedImage(
			(int) (scale * dimension.getWidth()),
			(int) (scale * dimension.getHeight()),
			// avoid creating JPEG images with transparency that would result 
			// in invalid image files for some viewers (browsers)
			(imageType == ImageTypeEnum.GIF || imageType == ImageTypeEnum.PNG)  
				? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB 
			);

	Graphics2D g = createGraphics(bi);
	try
	{
		g.scale(scale, scale);
		Color backcolor = getBackcolor();
		if (backcolor != null)
		{
			g.setColor(backcolor);
			g.fillRect(0, 0, (int)dimension.getWidth(), (int)dimension.getHeight());
		}
		render(jasperReportsContext, g, new Rectangle((int)dimension.getWidth(), (int)dimension.getHeight()));
	}
	finally
	{
		g.dispose();
	}
	
	return JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, getImageTypeValue());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:47,代码来源:JRAbstractSvgRenderer.java

示例14: getImageTypeValue

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public ImageTypeEnum getImageTypeValue()
{
	return ImageTypeEnum.getByValue(getImageType());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:6,代码来源:JRAbstractRenderer.java

示例15: getImageTypeValue

import net.sf.jasperreports.engine.type.ImageTypeEnum; //导入依赖的package包/类
@Override
public ImageTypeEnum getImageTypeValue() {
	return ImageTypeEnum.getByValue(renderable.getImageType());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:5,代码来源:WrappingRenderable.java


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