Java 类net.sf.jasperreports.engine.type.OnErrorTypeEnum 实例源码

项目:jasperreports    文件:RenderableUtil.java   
/**
 *
 */
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);
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * Creates and returns an instance of the JRImageRenderer class after encoding the image object using an image
 * encoder that supports the supplied image type.
 * 
 * @param image the java.awt.Image object to wrap into a JRImageRenderer instance
 * @param imageType the type of the image as specified by one of the constants defined in the JRRenderable interface
 * @param onErrorType one of the error type constants defined in the {@link OnErrorTypeEnum}.
 * @return the image renderer instance
 */
public Renderable getRenderable(Image image, ImageTypeEnum imageType, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        result = new JRImageRenderer(JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(image, imageType));
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType);

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 *
 */
public Renderable getRenderable(InputStream is, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        result = new JRImageRenderer(JRLoader.loadBytes(is));
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType); 

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 *
 */
public Renderable getRenderable(URL url, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        result = new JRImageRenderer(JRLoader.loadBytes(url));
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType); 

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for URL " + url, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 *
 */
public Renderable getRenderable(File file, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        result = new JRImageRenderer(JRLoader.loadBytes(file));
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType); 

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for file " + file, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * @deprecated To be removed.
 */
public Renderable getOnErrorRendererForDimension(Renderable renderer, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        renderer.getDimension(jasperReportsContext);
        result = renderer;
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType);

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * @deprecated To be removed.
 */
public Renderable getOnErrorRendererForImageData(Renderable renderer, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable result;
    try
    {
        renderer.getImageData(jasperReportsContext);
        result = renderer;
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType); 

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
public Renderable getOnErrorRenderer(OnErrorTypeEnum onErrorType, JRException e) throws JRException
{
    Renderable renderer = null;

    switch (onErrorType)
    {
        case ICON :
        {
            renderer = new JRImageRenderer(JRImageLoader.NO_IMAGE_RESOURCE);
            //FIXME cache these renderers
            break;
        }
        case BLANK :
        {
            break;
        }
        case ERROR :
        default :
        {
            throw e;
        }
    }

    return renderer;
}
项目:jasperreports    文件:RenderableUtil.java   
public Renderable getOnErrorRenderer(OnErrorTypeEnum onErrorType, JRRuntimeException e) throws JRRuntimeException
{
    Renderable renderer = null;

    switch (onErrorType)
    {
        case ICON :
        {
            renderer = new JRImageRenderer(JRImageLoader.NO_IMAGE_RESOURCE);
            //FIXME cache these renderers
            break;
        }
        case BLANK :
        {
            break;
        }
        case ERROR :
        default :
        {
            throw e;
        }
    }

    return renderer;
}
项目:jasperreports    文件:ChartConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    JRChart chart = (JRChart)element;

    copyElement(reportConverter, chart, printImage);

    printImage.copyBox(chart.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(chart.getAnchorNameExpression()));
    printImage.setBookmarkLevel(chart.getBookmarkLevel());
    printImage.setLinkType(chart.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setRenderer(getRenderer(reportConverter, chart));
    printImage.setScaleImage(ScaleImageEnum.CLIP);

    return printImage;
}
项目:jasperreports    文件:ElementIconConverter.java   
/**
 * @deprecated To be removed.
 */
protected net.sf.jasperreports.engine.Renderable getRenderer(JasperReportsContext jasperReportsContext)
{
    try
    {
        return 
            net.sf.jasperreports.engine.RenderableUtil.getInstance(jasperReportsContext).getRenderable(
                iconLocation, 
                OnErrorTypeEnum.ERROR);
    }
    catch (JRException e)
    {
        log.warn("Error creating component design preview icon", e);
        return null;
    }
}
项目:jasperreports    文件:JRImageRenderer.java   
/**
 * @deprecated To be removed.
 */
public static JRImageRenderer getOnErrorRendererForImage(JasperReportsContext jasperReportsContext, JRImageRenderer renderer, OnErrorTypeEnum onErrorType) throws JRException
{
    JRImageRenderer result;
    try
    {
        renderer.getImage(jasperReportsContext);
        result = renderer;
    }
    catch (Exception e)
    {
        result = (JRImageRenderer)RenderableUtil.getInstance(jasperReportsContext).handleImageError(e, onErrorType);

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderersCache.java   
/**
 * 
 */
public Renderable getLoadedRenderer(ResourceRenderer resourceRenderer) throws JRException
{
    Renderable loadedRenderer;
    String resourceRendererId = resourceRenderer.getId();
    if (resourceRenderers.containsKey(resourceRendererId))
    {
        loadedRenderer = resourceRenderers.get(resourceRendererId);
    }
    else
    {
        // since we force OnErrorTypeEnum.ERROR, it is guaranteed that the method will return a DataRenderable implementation
        loadedRenderer = rendererUtil.getNonLazyRenderable(resourceRenderer.getResourceLocation(), OnErrorTypeEnum.ERROR);
        resourceRenderers.put(resourceRendererId, loadedRenderer);
    }

    return loadedRenderer;
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getNonLazyRenderable(String resourceLocation, OnErrorTypeEnum onErrorType) throws JRException
{
    byte[] data;

    try
    {
        data = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(resourceLocation);
    }
    catch (Exception e)
    {
        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for location " + resourceLocation, e);
        }

        return handleImageError(e, onErrorType); 
    }

    return SimpleDataRenderer.getInstance(data);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
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);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 * Creates and returns an instance of the JRImageRenderer class after encoding the image object using an image
 * encoder that supports the supplied image type.
 * 
 * @param image the java.awt.Image object to wrap into a JRImageRenderer instance
 * @param imageType the type of the image as specified by one of the constants defined in the JRRenderable interface
 * @param onErrorType one of the error type constants defined in the {@link OnErrorTypeEnum}.
 * @return the image renderer instance
 */
public Renderable getRenderable(Image image, ImageTypeEnum imageType, OnErrorTypeEnum onErrorType) throws JRException
{
    byte[] data = null;
    try
    {
        data = JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(image, imageType);
    }
    catch (Exception e)
    {
        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }

        return handleImageError(e, onErrorType);
    }
    return SimpleDataRenderer.getInstance(data);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getRenderable(InputStream is, OnErrorTypeEnum onErrorType) throws JRException
{
    byte[] data = null;
    try
    {
        data = JRLoader.loadBytes(is);
    }
    catch (Exception e)
    {
        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType, e);
        }

        return handleImageError(e, onErrorType); 
    }
    return SimpleDataRenderer.getInstance(data);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getRenderable(URL url, OnErrorTypeEnum onErrorType) throws JRException
{
    byte[] data = null;
    try
    {
        data = JRLoader.loadBytes(url);
    }
    catch (Exception e)
    {
        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for URL " + url, e);
        }

        return handleImageError(e, onErrorType); 
    }
    return SimpleDataRenderer.getInstance(data);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getRenderable(File file, OnErrorTypeEnum onErrorType) throws JRException
{
    byte[] data = null;
    try
    {
        data = JRLoader.loadBytes(file);
    }
    catch (Exception e)
    {
        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for file " + file, e);
        }

        return handleImageError(e, onErrorType); 
    }
    return SimpleDataRenderer.getInstance(data);
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getOnErrorRenderer(OnErrorTypeEnum onErrorType, JRException e) throws JRException
{
    Renderable renderer = null;

    switch (onErrorType)
    {
        case ICON :
        {
            renderer = NO_IMAGE_RENDERER;
            break;
        }
        case BLANK :
        {
            break;
        }
        case ERROR :
        default :
        {
            throw e;
        }
    }

    return renderer;
}
项目:jasperreports    文件:RendererUtil.java   
/**
 *
 */
public Renderable getOnErrorRenderer(OnErrorTypeEnum onErrorType, JRRuntimeException e) throws JRRuntimeException
{
    Renderable renderer = null;

    switch (onErrorType)
    {
        case ICON :
        {
            renderer = NO_IMAGE_RENDERER;
            break;
        }
        case BLANK :
        {
            break;
        }
        case ERROR :
        default :
        {
            throw e;
        }
    }

    return renderer;
}
项目:jasperreports    文件:ImageServlet.java   
protected byte[] process(
    Renderable renderer,
    Dimension dimension,
    Color backcolor
    ) throws JRException
{
    RendererUtil rendererUtil = RendererUtil.getInstance(getJasperReportsContext());

    if (renderer instanceof ResourceRenderer)
    {
        renderer = //hard to use a cache here and it would be just for some icon type of images, if any 
                rendererUtil.getNonLazyRenderable(
                ((ResourceRenderer)renderer).getResourceLocation(), 
                OnErrorTypeEnum.ERROR
                );
    }

    DataRenderable dataRenderer = 
            rendererUtil.getDataRenderable(
            renderer,
            dimension,
            backcolor
            );

    return dataRenderer.getData(getJasperReportsContext());
}
项目:PDFReporter-Studio    文件:ChartConverter.java   
/**
 *
 */
public JRPrintElement convert(ReportConverter reportConverter, JRElement element) {
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    JRChart chart = (JRChart) element;

    copyElement(reportConverter, chart, printImage);

    printImage.copyBox(chart.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(chart.getAnchorNameExpression()));
    printImage.setBookmarkLevel(chart.getBookmarkLevel());
    printImage.setLinkType(chart.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setRenderable(getRenderer(reportConverter, chart));
    printImage.setScaleImage(ScaleImageEnum.CLIP);

    return printImage;
}
项目:PDFReporter-Studio    文件:ImageConverter.java   
/**
 *
 */
public JRPrintElement convert(final ReportConverter reportConverter, final JRElement element) {
    JRImage image = (JRImage) element;
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    Renderable cacheRenderer = getRenderable(reportConverter, element, image, printImage);
    copyGraphicElement(reportConverter, image, printImage);

    printImage.copyBox(image.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(image.getAnchorNameExpression()));
    printImage.setBookmarkLevel(image.getBookmarkLevel());
    printImage.setHorizontalAlignment(image.getOwnHorizontalAlignmentValue());
    printImage.setLazy(image.isLazy());
    printImage.setLinkType(image.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setVerticalAlignment(image.getOwnVerticalAlignmentValue());
    if (cacheRenderer == null)
        cacheRenderer = getRenderableNoImage(reportConverter.getJasperReportsContext(), image, printImage);
    printImage.setRenderable(cacheRenderer);
    printImage.setScaleImage(image.getOwnScaleImageValue());

    return printImage;
}
项目:PDFReporter-Studio    文件:ImageConverter.java   
/**
 * 
 */
private Renderable getRenderable(JasperReportsContext jasperReportsContext, JRImage imageElement,
        JRPrintImage printImage, KeyValue<JasperReportsContext, String> key) {
    // long ctime = System.currentTimeMillis();
    Renderable r = null;
    String location = ExpressionUtil.eval(imageElement.getExpression(),
            (JasperReportsConfiguration) jasperReportsContext);
    // JRExpressionUtil.getSimpleExpressionText(imageElement.getExpression());
    // long etime = System.currentTimeMillis();
    if (location != null) {
        try {
            r = RenderableUtil.getInstance(jasperReportsContext).getRenderable(location, OnErrorTypeEnum.ERROR, false);
            imgCache.put(key, r);
        } catch (JRException e) {
            if (log.isDebugEnabled())
                log.debug("Creating location renderer for converted image failed.", e);
        }
    }
    if (r == null)
        r = getRenderableNoImage(jasperReportsContext, imageElement, printImage);
    // long ftime = System.currentTimeMillis();
    // System.out.println("GetRenderable: " + (ftime - ctime) + " : " + (ftime - etime) + " " + location);
    return r;
}
项目:PDFReporter-Studio    文件:LazyImageConverter.java   
/**
 * Return the content for an MImage element
 * 
 * @param reportConverter the report converter 
 * @param element a not null MImage element
 * @return An image pointed by the expression of the element if it can be found, the
 * standard not found image otherwise. it is never null
 */
public JRPrintElement convertImage(ReportConverter reportConverter, MGraphicElement element){
    JRImage image = (JRImage) element.getValue();
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    Renderable cacheRenderer = getRenderable(reportConverter, image, element);
    copyGraphicElement(reportConverter, image, printImage);

    printImage.copyBox(image.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(image.getAnchorNameExpression()));
    printImage.setBookmarkLevel(image.getBookmarkLevel());
    printImage.setHorizontalAlignment(image.getOwnHorizontalAlignmentValue());
    printImage.setLazy(image.isLazy());
    printImage.setLinkType(image.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setVerticalAlignment(image.getOwnVerticalAlignmentValue());
    //If it is null load the no image found element
    if (cacheRenderer == null)
        cacheRenderer = getRenderableNoImage(reportConverter.getJasperReportsContext(), image, printImage);
    printImage.setRenderable(cacheRenderer);
    printImage.setScaleImage(image.getOwnScaleImageValue());

    return printImage;
}
项目:jasperreports-wms-component    文件:WmsMapElementImageProvider.java   
public static Renderable getImageRenderable(
    JasperReportsContext jasperReportsContext, String elementName,
    WmsRequestBuilder requestBuilder)
    throws MalformedURLException,
    IOException, JRException {

  URL mapUrl = requestBuilder.toMapUrl();
  HttpURLConnection httpConnection = (HttpURLConnection) mapUrl
      .openConnection();

  // Handle XML response
  validateServerResponse(elementName, mapUrl, httpConnection);

  JasperReportsContext context = jasperReportsContext;
  if (context == null) {
    context = DefaultJasperReportsContext.getInstance();
  }
  Renderable cacheRenderer = RenderableUtil.getInstance(context)
      .getRenderable(
          httpConnection.getInputStream(),
          OnErrorTypeEnum.ERROR);
  // cacheRenderer.getImageData(jasperReportsContext);
  return cacheRenderer;
}
项目:jasperreports    文件:ImageWebResourceHandler.java   
protected byte[] process(
    JasperReportsContext jasperReportsContext,
    Renderable renderer,
    Dimension dimension,
    Color backcolor
    ) throws JRException
{
    RendererUtil rendererUtil = RendererUtil.getInstance(jasperReportsContext);

    if (renderer instanceof ResourceRenderer)
    {
        renderer = //hard to use a cache here and it would be just for some icon type of images, if any 
            rendererUtil.getNonLazyRenderable(
                ((ResourceRenderer)renderer).getResourceLocation(), 
                OnErrorTypeEnum.ERROR
                );
    }

    DataRenderable dataRenderer = 
        rendererUtil.getDataRenderable(
            renderer,
            dimension,
            backcolor
            );

    return dataRenderer.getData(jasperReportsContext);
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * @deprecated Replaced by {@link ResourceRenderer#getInstance(String, boolean)} and {@link RendererUtil#getNonLazyRenderable(String, OnErrorTypeEnum)}.
 */
public Renderable getRenderable(String imageLocation, OnErrorTypeEnum onErrorType, boolean isLazy) throws JRException
{
    if (imageLocation == null)
    {
        return null;
    }

    if (isLazy)
    {
        return new JRImageRenderer(imageLocation);
    }

    Renderable result;
    try
    {
        byte[] data = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(imageLocation);
        result = new JRImageRenderer(data);
    }
    catch (Exception e)
    {
        result = handleImageError(e, onErrorType);

        if (log.isDebugEnabled())
        {
            log.debug("handled image error with type " + onErrorType + " for location " + imageLocation, e);
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * @deprecated To be removed.
 */
public net.sf.jasperreports.renderers.Renderable getOnErrorRendererForDimension(
    RenderersCache renderersCache,
    net.sf.jasperreports.renderers.Renderable renderer, 
    OnErrorTypeEnum onErrorType
    ) throws JRException
{
    net.sf.jasperreports.renderers.Renderable result = null;

    DimensionRenderable dimensionRenderer = renderersCache.getDimensionRenderable(renderer);

    if (dimensionRenderer != null)
    {
        try
        {
            dimensionRenderer.getDimension(jasperReportsContext);
            result = (net.sf.jasperreports.renderers.Renderable)dimensionRenderer;
        }
        catch (Exception e)
        {
            result = handleImageError(e, onErrorType);

            if (log.isDebugEnabled())
            {
                log.debug("handled image error with type " + onErrorType, e);
            }
        }
    }
    return result;
}
项目:jasperreports    文件:RenderableUtil.java   
/**
 * 
 */
public Renderable handleImageError(Exception error, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable errorRenderable;
    if (error instanceof JRException)
    {
        errorRenderable = getOnErrorRenderer(onErrorType, (JRException) error);
    }
    else if (error instanceof JRRuntimeException)
    {
        errorRenderable = getOnErrorRenderer(onErrorType, (JRRuntimeException) error);
    }
    else if (error instanceof RuntimeException)
    {
        throw (RuntimeException) error;
    }
    else
    {
        // we shouldn't get here normally
        if (log.isDebugEnabled())
        {
            log.debug("got unexpected image exception of type " + error.getClass().getName(), error);
        }

        throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_IMAGE_ERROR,
                (Object[])null,
                error);
    }
    return errorRenderable;
}
项目:jasperreports    文件:JRBaseImage.java   
@Override
public void setOnErrorType(OnErrorTypeEnum onErrorTypeValue)
{
    OnErrorTypeEnum old = this.onErrorTypeValue;
    this.onErrorTypeValue = onErrorTypeValue;
    getEventSupport().firePropertyChange(PROPERTY_ON_ERROR_TYPE, old, this.onErrorTypeValue);
}
项目:jasperreports    文件:JRBaseImage.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        scaleImageValue = ScaleImageEnum.getByValue(scaleImage);
        onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType);
        evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime);

        horizontalAlignment = null;
        verticalAlignment = null;
        scaleImage = null;
    }

    if (linkType == null)
    {
         linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType));
    }

    if (linkTarget == null)
    {
         linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget));
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue);
        verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:ImageConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    JRImage image = (JRImage)element;

    copyGraphicElement(reportConverter, image, printImage);

    printImage.copyBox(image.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(image.getAnchorNameExpression()));
    printImage.setBookmarkLevel(image.getBookmarkLevel());
    printImage.setHorizontalImageAlign(image.getOwnHorizontalImageAlign());
    printImage.setLinkType(image.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setVerticalImageAlign(image.getOwnVerticalImageAlign());

    printImage.setRenderer(
        ResourceRenderer.getInstance(
            JRExpressionUtil.getSimpleExpressionText(image.getExpression()),
            image.isLazy()
            )
        );

    printImage.setScaleImage(image.getOwnScaleImageValue());

    return printImage;
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 *
 */
public void writeImage(JRImage image) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_image, getNamespace());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_scaleImage, image.getOwnScaleImageValue());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_hAlign, image.getOwnHorizontalImageAlign());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_vAlign, image.getOwnVerticalImageAlign());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUsingCache, image.getUsingCache());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isLazy, image.isLazy(), false);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_onErrorType, image.getOnErrorTypeValue(), OnErrorTypeEnum.ERROR);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, image.getEvaluationTimeValue(), EvaluationTimeEnum.NOW);

    if (image.getEvaluationGroup() != null)
    {
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, image.getEvaluationGroup().getName());
    }

    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, image.getLinkType(), HyperlinkTypeEnum.NONE.getName());
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, image.getLinkTarget(), HyperlinkTargetEnum.SELF.getName());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK);

    writeReportElement(image);
    writeBox(image.getLineBox());
    writeGraphicElement(image);

    //FIXME class is mandatory in verifier

    writeExpression(JRXmlConstants.ELEMENT_imageExpression, image.getExpression(), true);
    writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, image.getAnchorNameExpression(), false);
    writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, image.getHyperlinkReferenceExpression(), false);
    writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, image.getHyperlinkWhenExpression(), false);//FIXMENOW can we reuse method for writing hyperlink?
    writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, image.getHyperlinkAnchorExpression(), false);
    writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, image.getHyperlinkPageExpression(), false);
    writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, image.getHyperlinkTooltipExpression(), false);
    writeHyperlinkParameters(image.getHyperlinkParameters());

    writer.closeElement();
}
项目:jasperreports    文件:JRDesignImage.java   
@Override
public void setOnErrorType(OnErrorTypeEnum onErrorTypeValue)
{
    OnErrorTypeEnum old = this.onErrorTypeValue;
    this.onErrorTypeValue = onErrorTypeValue;
    getEventSupport().firePropertyChange(JRBaseImage.PROPERTY_ON_ERROR_TYPE, old, this.onErrorTypeValue);
}
项目:jasperreports    文件:JRDesignImage.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        scaleImageValue = ScaleImageEnum.getByValue(scaleImage);
        onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType);
        evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime);

        horizontalAlignment = null;
        verticalAlignment = null;
        scaleImage = null;
    }

    if (linkType == null)
    {
         linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType));
    }

    if (linkTarget == null)
    {
         linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget));
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue);
        verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:JRTemplateImage.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        scaleImageValue = ScaleImageEnum.getByValue(scaleImage);
        onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType);

        horizontalAlignment = null;
        verticalAlignment = null;
        scaleImage = null;
    }

    if (linkType == null)
    {
         linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType));
    }

    if (linkTarget == null)
    {
         linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget));
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue);
        verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:RendererUtil.java   
/**
 * 
 */
public Renderable handleImageError(Exception error, OnErrorTypeEnum onErrorType) throws JRException
{
    Renderable errorRenderable;
    if (error instanceof JRException)
    {
        errorRenderable = getOnErrorRenderer(onErrorType, (JRException) error);
    }
    else if (error instanceof JRRuntimeException)
    {
        errorRenderable = getOnErrorRenderer(onErrorType, (JRRuntimeException) error);
    }
    else if (error instanceof RuntimeException)
    {
        throw (RuntimeException) error;
    }
    else
    {
        // we shouldn't get here normally
        if (log.isDebugEnabled())
        {
            log.debug("got unexpected image exception of type " + error.getClass().getName(), error);
        }

        throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_IMAGE_ERROR,
                (Object[])null,
                error
                );
    }
    return errorRenderable;
}
项目:jasperreports    文件:MapXmlFactory.java   
@Override
public Object createObject(Attributes atts)
{
    StandardMapComponent map = new StandardMapComponent();

    EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime));
    if (evaluationTime != null)
    {
        map.setEvaluationTime(evaluationTime);
    }

    if (map.getEvaluationTime() == EvaluationTimeEnum.GROUP)
    {
        String groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup);
        map.setEvaluationGroup(groupName);
    }

    MapTypeEnum mapType = MapTypeEnum.getByName(atts.getValue(ATTRIBUTE_mapType));
    if(mapType != null)
    {
        map.setMapType(mapType);
    }
    MapScaleEnum mapScale = MapScaleEnum.getByName(atts.getValue(ATTRIBUTE_mapScale));
    if(mapScale != null)
    {
        map.setMapScale(mapScale);
    }
    MapImageTypeEnum imageType = MapImageTypeEnum.getByName(atts.getValue(ATTRIBUTE_imageType));
    if(imageType != null)
    {
        map.setImageType(imageType);
    }
    OnErrorTypeEnum onErrorType = OnErrorTypeEnum.getByName(atts.getValue(ATTRIBUTE_onErrorType));
    if(onErrorType != null)
    {
        map.setOnErrorType(onErrorType);
    }

    return map;
}