Package com.lightcrafts.utils.filecache

Examples of com.lightcrafts.utils.filecache.FileCache


        final int imageWidth = metadata.getImageWidth();
        final int imageHeight = metadata.getImageHeight();

        String cacheKey = null;
        File imageFile = null;
        final FileCache fileCache = RawImageCache.getCacheFor( imageInfo );

        if ( CACHE_CONVERSION && fileCache != null ) {
            System.out.println("Checking cache for: " + imageInfo);
            final long t1 = System.currentTimeMillis();
            cacheKey = RawImageCache.getCacheKeyFor( imageInfo );
View Full Code Here


        final String cacheKey = getCacheKeyFor( imageInfo );
        return cacheKey != null ? getCachedImageFileFor( cacheKey ) : null;
    }

    static File getCachedImageFileFor( String cacheKey ) {
        final FileCache fileCache = FileCacheFactory.getGlobalCache();
        return fileCache != null ? fileCache.getFileFor( cacheKey ) : null;
    }
View Full Code Here

            System.out.println("Caching image: " + currentJob.cacheKey);

            long t1 = System.currentTimeMillis();

            final FileCache fileCache = FileCacheFactory.getGlobalCache();
            if (fileCache != null) {
                try {
                    final File cacheFile = fileCache.putToFile(currentJob.cacheKey);

                    try {
                        LCTIFFWriter writer = new LCTIFFWriter(cacheFile.getAbsolutePath(),
                                                               currentJob.image.getWidth(),
                                                               currentJob.image.getHeight());
                        writer.setByteField( TIFFTags.TIFF_ICC_PROFILE, JAIContext.linearProfile.getData());
                        writer.putImageTiled(currentJob.image, null);
                    } catch ( LCImageLibException e) {
                        e.printStackTrace();
                    } finally {
                        fileCache.notifyAboutCloseOf(cacheFile);
                    }
                } catch ( IOException e ) {
                    // nevermind, do without cache...
                    e.printStackTrace();
                }
View Full Code Here

     */
    void setCachedFile(File file) {
        if (file != null) {
            try {
                String key = ImageTask.getImageKey(file);
                FileCache cache = FileCacheFactory.get(file.getParentFile());
                File cachedFile = cache.getFileFor(key);

                if (cachedFile != null)
                    image = JPEGImageType.getImageFromInputStream(new FileInputStream(cachedFile), null,
                                                                  ImageTask.CacheImageSize, ImageTask.CacheImageSize);
            }
View Full Code Here

                        );
                        showErrorDialog(e);
                        success = false;
                    }
                    try {
                        FileCache cache = FileCacheFactory.getGlobalCache();
                        if (cache != null) {
                            cache.clear();
                        }
                    }
                    catch (IOException e) {
                        System.err.println(
                            "StartupCrach failed to clear FileCache"
View Full Code Here

            );
            if (option != 0) {
                return;
            }
            try {
                FileCache cache = FileCacheFactory.getGlobalCache();
                if (cache != null) {
                    cache.clear();
                }
                else {
                    throw new IOException("Global cache does not exist");
                }
            }
View Full Code Here

    /**
     * Accept a precomputed in-memory image to cache as the preview for
     * an image file.
     */
    public static void cachePreviewForImage(File file, RenderedImage image) {
        final FileCache cache = FileCacheFactory.get(file);
        if (cache == null) {
            return;
        }
        // Write the given preview to the cache
        final String key = getImageKey(file);
        try {
            final OutputStream out = cache.putToStream(key);
            final OutputStreamImageDataReceiver receiver =
                new OutputStreamImageDataReceiver(out);
            try {
                final LCJPEGWriter writer = new LCJPEGWriter(
                    receiver, 32 * 1024,
                    image.getWidth(), image.getHeight(),
                    image.getColorModel().getNumComponents(),
                    CS_RGB, 90
                );
                writer.putImage(image);
                writer.dispose();
            }
            catch (LCImageLibException e) {
                logNonFatalStatic(file, e, "caching preview");
                cache.remove(key);
            }
            out.close();
            receiver.dispose();
        }
        catch (IOException e) {
View Full Code Here

TOP

Related Classes of com.lightcrafts.utils.filecache.FileCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.