public void clearCache() {
        BufferedImage cache = cachedImage == null ? null : cachedImage.get();
        if (cache != null) {
            cache.flush();
        }
        cacheCleared = true;
        if (!isCacheable()) {
            cachedImage = null;
        }
    }