Search in sources :

Example 1 with IImageProvider

use of de.janrufmonitor.util.io.IImageProvider in project janrufmonitor by tbrandt77.

the class ImageHandler method getImageStream.

public InputStream getImageStream(ICaller caller) {
    Object provider = null;
    IAttribute cm_att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
    if (cm_att != null && cm_att.getValue().length() > 0) {
        provider = (IImageProvider) this.m_providers.get(cm_att.getValue());
        if (provider == null)
            provider = (IImageProvider) this.m_providers.get("default");
        if (provider instanceof IImageStreamProvider) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using IImageProvider <" + ((IImageProvider) provider).getID() + "> for getting image stream.");
            InputStream in = ((IImageStreamProvider) provider).getImageInputStream(caller);
            boolean isForceImage = Boolean.parseBoolean(System.getProperty(IJAMConst.SYSTEM_UI_FORCEIMAGE, "false"));
            if (isForceImage) {
                if (in != null)
                    return in;
            } else {
                return (in != null ? in : null);
            }
        }
    }
    return this.getImageStreamFromDefault(caller);
}
Also used : IImageProvider(de.janrufmonitor.util.io.IImageProvider) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IAttribute(de.janrufmonitor.framework.IAttribute)

Example 2 with IImageProvider

use of de.janrufmonitor.util.io.IImageProvider in project janrufmonitor by tbrandt77.

the class ImageHandler method hasImage.

public boolean hasImage(ICaller caller) {
    IImageProvider provider = null;
    IAttribute cm_att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
    if (cm_att != null && cm_att.getValue().length() > 0) {
        provider = (IImageProvider) this.m_providers.get(cm_att.getValue());
        if (provider != null) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using IImageProvider <" + provider.getID() + "> for existance check.");
            boolean isForceImage = Boolean.parseBoolean(System.getProperty(IJAMConst.SYSTEM_UI_FORCEIMAGE, "false"));
            if (isForceImage) {
                if (provider.hasImage(caller))
                    return true;
            } else {
                return provider.hasImage(caller);
            }
        }
    }
    return this.hasImageDefault(caller);
}
Also used : IImageProvider(de.janrufmonitor.util.io.IImageProvider) IAttribute(de.janrufmonitor.framework.IAttribute)

Example 3 with IImageProvider

use of de.janrufmonitor.util.io.IImageProvider in project janrufmonitor by tbrandt77.

the class ImageHandler method getImagePath.

public String getImagePath(ICaller caller) {
    IImageProvider provider = null;
    String imagePath = null;
    IAttribute cm_att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
    if (cm_att != null && cm_att.getValue().length() > 0) {
        provider = (IImageProvider) this.m_providers.get(cm_att.getValue());
        if (provider != null) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using IImageProvider <" + provider.getID() + "> for getting image path.");
            imagePath = provider.getImagePath(caller);
            boolean isForceImage = Boolean.parseBoolean(System.getProperty(IJAMConst.SYSTEM_UI_FORCEIMAGE, "false"));
            if (isForceImage) {
                if (imagePath != null && imagePath.length() > 0)
                    return imagePath;
            } else {
                return ((imagePath != null && imagePath.length() > 0) ? imagePath : "");
            }
        }
    }
    return getImagePathDefault(caller);
}
Also used : IImageProvider(de.janrufmonitor.util.io.IImageProvider) IAttribute(de.janrufmonitor.framework.IAttribute)

Example 4 with IImageProvider

use of de.janrufmonitor.util.io.IImageProvider in project janrufmonitor by tbrandt77.

the class ImageHandler method getImage.

public File getImage(ICaller caller) {
    IImageProvider provider = null;
    File image = null;
    IAttribute cm_att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
    if (cm_att != null && cm_att.getValue().length() > 0) {
        provider = (IImageProvider) this.m_providers.get(cm_att.getValue());
        if (provider != null) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using IImageProvider <" + provider.getID() + "> for getting image file.");
            image = provider.getImage(caller);
            boolean isForceImage = Boolean.parseBoolean(System.getProperty(IJAMConst.SYSTEM_UI_FORCEIMAGE, "false"));
            if (isForceImage) {
                if (image != null && image.exists())
                    return image;
            } else {
                return ((image != null && image.exists()) ? image : null);
            }
        }
    }
    return this.getImageDefault(caller);
}
Also used : IImageProvider(de.janrufmonitor.util.io.IImageProvider) IAttribute(de.janrufmonitor.framework.IAttribute) File(java.io.File)

Aggregations

IAttribute (de.janrufmonitor.framework.IAttribute)4 IImageProvider (de.janrufmonitor.util.io.IImageProvider)4 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1