Java 类net.sf.jasperreports.engine.JRImage 实例源码

项目:jasperreports    文件:JRBaseObjectFactory.java   
@Override
public void visitImage(JRImage image)
{
    JRBaseImage baseImage = null;

    if (image != null)
    {
        baseImage = (JRBaseImage)get(image);
        if (baseImage == null)
        {
            baseImage = new JRBaseImage(image, this);
        }
    }

    setVisitResult(baseImage);
}
项目:jasperreports    文件:JRFillObjectFactory.java   
@Override
public void visitImage(JRImage image)
{
    JRFillImage fillImage = null;

    if (image != null)
    {
        fillImage = (JRFillImage)get(image);
        if (fillImage == null)
        {
            fillImage = new JRFillImage(filler, image, this);
        }
    }

    setVisitResult(fillImage);
}
项目:jasperreports    文件:JRTemplateImage.java   
/**
 *
 */
protected void setImage(JRImage image)
{
    super.setGraphicElement(image);

    lineBox = image.getLineBox().clone(this);

    setScaleImage(image.getScaleImageValue());
    setUsingCache(image.getUsingCache());
    setHorizontalImageAlign(image.getHorizontalImageAlign());
    setVerticalImageAlign(image.getVerticalImageAlign());
    setLazy(image.isLazy());
    setOnErrorType(image.getOnErrorTypeValue());
    setLinkType(image.getLinkType());
    setLinkTarget(image.getLinkTarget());
}
项目: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;
}
项目:PDFReporter-Studio    文件:LazyImageConverter.java   
/**
 * Extract the requested image from the cache if it is available. If it is available is returned (even if it is 
 * expired). If it is expired is returned but a refresh job is started. Otherwise, if it is unavailable is returned
 * null but a refresh job to try to get the image is started
 * 
 * @param reportConverter the report converter
 * @param image the image element
 * @param modelElement the model that encapsulate the image
 * @return the image to display if it is cached (expired or not), null otherwise
 */
private Renderable getRenderable(ReportConverter reportConverter, JRImage image, MGraphicElement modelElement) {
    JasperReportsContext jrContext = reportConverter.getJasperReportsContext();
    JRExpression expr = image.getExpression();
    KeyValue<JasperReportsContext, String> key = new KeyValue<JasperReportsContext, String>(jrContext, expr != null ? expr.getText() : "");
    TimedCache imageInfo = imgCache.get(key);

    //Check if the image was cached
    if (imageInfo == null){
        imageInfo = new TimedCache();
        imgCache.put(key, imageInfo);
    }

    //If the image is expired (it is also expired when is empty, the refresh thread is started)
    if (imageInfo.isExpired()) refreshImageInfo(imageInfo, modelElement, expr, jrContext, key);

    return imageInfo.getImage();

}
项目:jasperreports    文件:JRBaseImage.java   
/**
 *
 *
protected JRBaseImage()
{
    super();
}


/**
 * Initializes properties that are specific to images. Common properties are initialized by its
 * parent constructors.
 * @param image an element whose properties are copied to this element. Usually it is a
 * {@link net.sf.jasperreports.engine.design.JRDesignImage} that must be transformed into an
 * <tt>JRBaseImage</tt> at compile time.
 * @param factory a factory used in the compile process
 */
protected JRBaseImage(JRImage image, JRBaseObjectFactory factory)
{
    super(image, factory);

    scaleImageValue = image.getOwnScaleImageValue();
    horizontalImageAlign = image.getOwnHorizontalImageAlign();
    verticalImageAlign = image.getOwnVerticalImageAlign();
    isUsingCache = image.getUsingCache();
    isLazy = image.isLazy();
    onErrorTypeValue = image.getOnErrorTypeValue();
    evaluationTimeValue = image.getEvaluationTimeValue();
    linkType = image.getLinkType();
    linkTarget = image.getLinkTarget();
    hyperlinkParameters = JRBaseHyperlink.copyHyperlinkParameters(image, factory);

    lineBox = image.getLineBox().clone(this);

    evaluationGroup = factory.getGroup(image.getEvaluationGroup());
    expression = factory.getExpression(image.getExpression());
    anchorNameExpression = factory.getExpression(image.getAnchorNameExpression());
    hyperlinkReferenceExpression = factory.getExpression(image.getHyperlinkReferenceExpression());
    hyperlinkWhenExpression = factory.getExpression(image.getHyperlinkWhenExpression());
    hyperlinkAnchorExpression = factory.getExpression(image.getHyperlinkAnchorExpression());
    hyperlinkPageExpression = factory.getExpression(image.getHyperlinkPageExpression());
    hyperlinkTooltipExpression = factory.getExpression(image.getHyperlinkTooltipExpression());
    bookmarkLevel = image.getBookmarkLevel();
}
项目: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    文件:ConvertVisitor.java   
@Override
public void visitImage(JRImage image)
{
    JRPrintElement printImage = ImageConverter.getInstance().convert(reportConverter, image);
    addElement(parentFrame, printImage);
    addContour(reportConverter, parentFrame, printImage);
}
项目:jasperreports    文件:XmlWriterVisitor.java   
@Override
public void visitImage(JRImage image)
{
    try
    {
        xmlWriter.writeImage(image);
    }
    catch (IOException e)
    {
        throw new JRRuntimeException(e);
    }
}
项目: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    文件:JRVerifier.java   
public void verifyElement(JRElement element)
{
    if (element instanceof JRStaticText)
    {
        verifyStaticText((JRStaticText)element);
    }
    else if (element instanceof JRTextField)
    {
        verifyTextField((JRTextField)element);
    }
    else if (element instanceof JRImage)
    {
        verifyImage((JRImage)element);
    }
    else if (element instanceof JRSubreport)
    {
        verifySubreport((JRSubreport)element);
    }
    else if (element instanceof JRCrosstab)
    {
        verifyCrosstab((JRDesignCrosstab) element);
    }
    else if (element instanceof JRChart)
    {
        verifyChart((JRChart) element);
    }
    else if (element instanceof JRFrame)
    {
        verifyFrame((JRFrame) element);
    }
    else if (element instanceof JRComponentElement)
    {
        verifyComponentElement((JRComponentElement) element);
    }
    else if (element instanceof JRGenericElement)
    {
        verifyGenericElement((JRGenericElement) element);
    }
}
项目:jasperreports    文件:JRVerifier.java   
/**
 *
 */
private void verifyImage(JRImage image)
{
    verifyReportElement(image);
    verifyAnchor(image);
    verifyHyperlink(image);
}
项目:jasperreports    文件:JRFillImage.java   
/**
 *
 */
protected JRFillImage(
    JRBaseFiller filler,
    JRImage image, 
    JRFillObjectFactory factory
    )
{
    super(filler, image, factory);

    initLineBox = image.getLineBox().clone(this);

    evaluationGroup = factory.getGroup(image.getEvaluationGroup());
}
项目:jasperreports    文件:JRTemplateImage.java   
/**
 *
 */
protected JRTemplateImage(JROrigin origin, JRDefaultStyleProvider defaultStyleProvider, JRImage image)
{
    super(origin, defaultStyleProvider);

    setImage(image);
}
项目:PDFReporter-Studio    文件:ImageConverter.java   
protected Renderable getRenderable(final ReportConverter reportConverter, final JRElement element,
        final JRImage image, final JRBasePrintImage printImage) {
    Renderable cacheRenderer = null;
    try {
        cacheRenderer = cache.get(element);
        if (image.getExpression() != null) {
            String expr = image.getExpression().getText();
            KeyValue<String, Long> last = running.get(element);
            Renderable r = null;
            if (cacheRenderer == null) {
                cacheRenderer = getRenderableNoImage(reportConverter.getJasperReportsContext(), image, printImage);
                cache.put(element, cacheRenderer);
                if (last == null)
                    r = doFindImage(reportConverter, element, image, printImage, expr, cacheRenderer);
            }
            if (last != null
                    && (!last.key.equals(expr) || (last.value != null && System.currentTimeMillis() - last.value.longValue() > 2000))) {
                r = doFindImage(reportConverter, element, image, printImage, expr, cacheRenderer);
            }
            if (last == null)
                r = doFindImage(reportConverter, element, image, printImage, expr, cacheRenderer);
            if (r != null)
                cacheRenderer = r;
        } else {
            running.remove(element);
            cacheRenderer = getRenderableNoImage(reportConverter.getJasperReportsContext(), image, printImage);
            cache.put(element, cacheRenderer);
        }
    } catch (Throwable e) {
        return getRenderableNoImage(reportConverter.getJasperReportsContext(), image, printImage);
    }
    return cacheRenderer;
}
项目:PDFReporter-Studio    文件:ImageConverter.java   
private Renderable getRenderableNoImage(JasperReportsContext jasperReportsContext, JRImage imageElement,
        JRPrintImage printImage) {
    try {
        printImage.setScaleImage(ScaleImageEnum.CLIP);
        if (noImage == null)
            noImage = RenderableUtil.getInstance(jasperReportsContext).getRenderable(JRImageLoader.NO_IMAGE_RESOURCE,
                    imageElement.getOnErrorTypeValue(), false);
    } catch (Exception e) {
        if (log.isDebugEnabled())
            log.debug("Creating icon renderer for converted image failed.", e);
    }
    return noImage;
}
项目:PDFReporter-Studio    文件:LazyImageConverter.java   
/**
 * Return the standard printable element when the image is not found
 * 
 * @param jasperReportsContext the context
 * @param imageElement the actual element
 * @param printImage the print image
 * @return return the not printable element
 */
private Renderable getRenderableNoImage(JasperReportsContext jasperReportsContext, JRImage imageElement,
        JRPrintImage printImage) {
    try {
        printImage.setScaleImage(ScaleImageEnum.CLIP);
        if (noImage == null)
            noImage = RenderableUtil.getInstance(jasperReportsContext).getRenderable(JRImageLoader.NO_IMAGE_RESOURCE,
                    imageElement.getOnErrorTypeValue(), false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return noImage;
}
项目:ireport-fork    文件:ElementNameVisitor.java   
/**
 *
 */
public void visitImage(JRImage image)
{
    name = Misc.getExpressionText( image.getExpression() );
    if (name.length() > 15)
    {
        name = name.substring(0,15) + "...";
    }
}
项目:jasperreports    文件:JRDelegationVisitor.java   
@Override
public void visitImage(JRImage image)
{
    visitor.visitImage(image);
}
项目:jasperreports    文件:UniformElementVisitor.java   
@Override
public void visitImage(JRImage image)
{
    visitElement(image);
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
public void writeImage( JRImage image, String imageName)
{
    if(image != null)
    {
        write( "JRDesignImage " + imageName + " = new JRDesignImage(jasperDesign);\n");
        write( imageName + ".setScaleImage({0});\n", image.getOwnScaleImageValue());
        write( imageName + ".setHorizontalImageAlign({0});\n", image.getOwnHorizontalImageAlign());
        write( imageName + ".setVerticalImageAlign({0});\n", image.getOwnVerticalImageAlign());
        write( imageName + ".setUsingCache({0});\n", image.getUsingCache());
        write( imageName + ".setLazy({0});\n", image.isLazy(), false);
        write( imageName + ".setOnErrorType({0});\n",image.getOnErrorTypeValue(),  OnErrorTypeEnum.ERROR);
        write( imageName + ".setEvaluationTime({0});\n", image.getEvaluationTimeValue(), EvaluationTimeEnum.NOW);
        write( imageName + ".setEvaluationGroup({0});\n", getGroupName(image.getEvaluationGroup()));

        if(image.getLinkType() != null)
        {
            write( imageName + ".setLinkType(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(image.getLinkType()), HyperlinkTypeEnum.NONE.getName());
        }
        if(image.getLinkTarget() != null)
        {
            write( imageName + ".setLinkTarget(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(image.getLinkTarget()), HyperlinkTargetEnum.SELF.getName());
        }
        write( imageName + ".setBookmarkLevel({0, number, #});\n", image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK);

        writeReportElement( image, imageName);
        writeBox( image.getLineBox(), imageName + ".getLineBox()");
        writeGraphicElement( image, imageName);

        writeExpression( image.getExpression(), imageName, "Expression");
        writeExpression( image.getAnchorNameExpression(), imageName, "AnchorNameExpression");
        writeExpression( image.getHyperlinkReferenceExpression(), imageName, "HyperlinkReferenceExpression");
        writeExpression( image.getHyperlinkWhenExpression(), imageName, "HyperlinkWhenExpression");
        writeExpression( image.getHyperlinkAnchorExpression(), imageName, "HyperlinkAnchorExpression");
        writeExpression( image.getHyperlinkPageExpression(), imageName, "HyperlinkPageExpression");
        writeExpression( image.getHyperlinkTooltipExpression(), imageName, "HyperlinkTooltipExpression");

        writeHyperlinkParameters( image.getHyperlinkParameters(), imageName);
        flush();
    }
}
项目:jasperreports    文件:JRApiWriter.java   
@Override
public void visitImage(JRImage image)
{
    apiWriter.writeImage(image, name);
}
项目:jasperreports    文件:JRVisitorSupport.java   
@Override
public void visitImage(JRImage image)
{
    // NOOP
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public ScaleImageEnum getOwnScaleImageValue()
{
    return providerStyle == null || providerStyle.getOwnScaleImageValue() == null ? ((JRImage)this.parent).getOwnScaleImageValue() : providerStyle.getOwnScaleImageValue();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public HorizontalImageAlignEnum getOwnHorizontalImageAlign()
{
    return providerStyle == null || providerStyle.getOwnHorizontalImageAlign() == null ? ((JRImage)this.parent).getOwnHorizontalImageAlign() : providerStyle.getOwnHorizontalImageAlign();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public VerticalImageAlignEnum getOwnVerticalImageAlign()
{
    return providerStyle == null || providerStyle.getOwnVerticalImageAlign() == null ? ((JRImage)this.parent).getOwnVerticalImageAlign() : providerStyle.getOwnVerticalImageAlign();
}
项目:jasperreports    文件:JRFillImage.java   
/**
 * @deprecated Replaced by {@link #getUsingCache()}.
 */
@Override
public boolean isUsingCache()
{
    return ((JRImage)this.parent).isUsingCache();
}
项目:jasperreports    文件:JRFillImage.java   
/**
 * @deprecated Replaced by {@link #getUsingCache()}.
 */
@Override
public Boolean isOwnUsingCache()
{
    return ((JRImage)this.parent).isOwnUsingCache();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public Boolean getUsingCache()
{
    return ((JRImage)this.parent).getUsingCache();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public boolean isLazy()
{
    return ((JRImage)this.parent).isLazy();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public OnErrorTypeEnum getOnErrorTypeValue()
{
    return ((JRImage)this.parent).getOnErrorTypeValue();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public EvaluationTimeEnum getEvaluationTimeValue()
{
    return ((JRImage)this.parent).getEvaluationTimeValue();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public HyperlinkTypeEnum getHyperlinkTypeValue()
{
    return ((JRImage)parent).getHyperlinkTypeValue();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public byte getHyperlinkTarget()
{
    return ((JRImage)this.parent).getHyperlinkTarget();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public String getLinkTarget()
{
    return ((JRImage)this.parent).getLinkTarget();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public JRExpression getExpression()
{
    return ((JRImage)this.parent).getExpression();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public JRExpression getAnchorNameExpression()
{
    return ((JRImage)this.parent).getAnchorNameExpression();
}
项目:jasperreports    文件:JRFillImage.java   
@Override
public JRExpression getHyperlinkReferenceExpression()
{
    return ((JRImage)this.parent).getHyperlinkReferenceExpression();
}