private void generateSprites(ResourceReaderHandler cssRsHandler, BinaryResourcesHandler binaryRsHandler,
			Set<String> resourcePaths, JawrConfig jawrConfig, Charset charset) {

		MessageLevel msgLevel = MessageLevel.valueOf(ERROR_LEVEL);
		String sinkLevel = WARN_LEVEL;
		if (LOGGER.isTraceEnabled() || LOGGER.isDebugEnabled() || LOGGER.isInfoEnabled()) { // logLevel.isGreaterOrEqual(Level.DEBUG)
			msgLevel = MessageLevel.valueOf(INFO_LEVEL);
			sinkLevel = INFO_LEVEL;
		} else if (LOGGER.isWarnEnabled() || LOGGER.isErrorEnabled()) { // logLevel.isGreaterOrEqual(Level.WARN)
			msgLevel = MessageLevel.valueOf(WARN_LEVEL);
			sinkLevel = WARN_LEVEL;
		}

		MessageLog messageLog = new MessageLog(new MessageSink[] { new LogMessageSink(sinkLevel) });

		SmartSpritesResourceHandler smartSpriteRsHandler = new SmartSpritesResourceHandler(cssRsHandler,
				binaryRsHandler.getRsReaderHandler(), jawrConfig.getGeneratorRegistry(),
				binaryRsHandler.getConfig().getGeneratorRegistry(), charset.toString(), messageLog);

		smartSpriteRsHandler.setContextPath(jawrConfig.getProperty(JawrConstant.JAWR_CSS_URL_REWRITER_CONTEXT_PATH));

		String outDir = cssRsHandler.getWorkingDirectory() + JawrConstant.CSS_SMARTSPRITES_TMP_DIR;

		// Create temp directories
		File tmpDir = new File(outDir);

		if (!tmpDir.exists()) {
			if (!tmpDir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory : " + tmpDir);
			}
		} else {
			// Copy to backup and clean temp directories
			try {
				File backupDir = new File(
						cssRsHandler.getWorkingDirectory() + JawrConstant.SPRITE_BACKUP_GENERATED_CSS_DIR);
				if (!backupDir.exists()) {
					if (!backupDir.mkdirs()) {
						throw new BundlingProcessException("Impossible to create temporary directory : " + backupDir);
					}
				}
				FileUtils.copyDirectory(tmpDir, backupDir);
				FileUtils.cleanDirectory(tmpDir);

			} catch (IOException e) {
				throw new BundlingProcessException("Impossible to clean temporary directory : " + outDir, e);
			}
		}

		SmartSpritesParameters params = new SmartSpritesParameters("/", null, outDir, null, msgLevel, "",
				PngDepth.valueOf("AUTO"), false, charset.toString(), true);

		SpriteBuilder spriteBuilder = new SpriteBuilder(params, messageLog, smartSpriteRsHandler);
		try {
			spriteBuilder.buildSprites(resourcePaths);
		} catch (IOException e) {
			throw new BundlingProcessException("Unable to build sprites", e);
		}
	}
private void generateSprites ( ResourceReaderHandler cssRsHandler , BinaryResourcesHandler binaryRsHandler , Set < String > resourcePaths , JawrConfig jawrConfig , Charset charset ) { MessageLevel msgLevel = MessageLevel . valueOf ( ERROR_LEVEL ) ; String sinkLevel = WARN_LEVEL ; if ( LOGGER . isTraceEnabled ( ) || LOGGER . isDebugEnabled ( ) || LOGGER . isInfoEnabled ( ) ) { msgLevel = MessageLevel . valueOf ( INFO_LEVEL ) ; sinkLevel = INFO_LEVEL ; } else if ( LOGGER . isWarnEnabled ( ) || LOGGER . isErrorEnabled ( ) ) { msgLevel = MessageLevel . valueOf ( WARN_LEVEL ) ; sinkLevel = WARN_LEVEL ; } MessageLog messageLog = new MessageLog ( new MessageSink [ ] { new LogMessageSink ( sinkLevel ) } ) ; SmartSpritesResourceHandler smartSpriteRsHandler = new SmartSpritesResourceHandler ( cssRsHandler , binaryRsHandler . getRsReaderHandler ( ) , jawrConfig . getGeneratorRegistry ( ) , binaryRsHandler . getConfig ( ) . getGeneratorRegistry ( ) , charset . toString ( ) , messageLog ) ; smartSpriteRsHandler . setContextPath ( jawrConfig . getProperty ( JawrConstant . JAWR_CSS_URL_REWRITER_CONTEXT_PATH ) ) ; String outDir = cssRsHandler . getWorkingDirectory ( ) + JawrConstant . CSS_SMARTSPRITES_TMP_DIR ; File tmpDir = new File ( outDir ) ; if ( ! tmpDir . exists ( ) ) { if ( ! tmpDir . mkdirs ( ) ) { throw new BundlingProcessException ( "Impossible to create temporary directory : " + tmpDir ) ; } } else { try { File backupDir = new File ( cssRsHandler . getWorkingDirectory ( ) + JawrConstant . SPRITE_BACKUP_GENERATED_CSS_DIR ) ; if ( ! backupDir . exists ( ) ) { if ( ! backupDir . mkdirs ( ) ) { throw new BundlingProcessException ( "Impossible to create temporary directory : " + backupDir ) ; } } FileUtils . copyDirectory ( tmpDir , backupDir ) ; FileUtils . cleanDirectory ( tmpDir ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Impossible to clean temporary directory : " + outDir , e ) ; } } SmartSpritesParameters params = new SmartSpritesParameters ( "/" , null , outDir , null , msgLevel , "" , PngDepth . valueOf ( "AUTO" ) , false , charset . toString ( ) , true ) ; SpriteBuilder spriteBuilder = new SpriteBuilder ( params , messageLog , smartSpriteRsHandler ) ; try { spriteBuilder . buildSprites ( resourcePaths ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Unable to build sprites" , e ) ; } }
Generates the image sprites from the smartsprites annotation in the CSS,
rewrite the CSS files to references the generated sprites.

@param cssRsHandler
the css resourceHandler
@param binaryRsHandler
the binary resourceHandler
@param resourcePaths
the set of CSS resource paths to handle
@param jawrConfig
the Jawr config
@param charset
the charset