Class ImageRemapperUtil
- java.lang.Object
-
- net.sf.basedb.clients.web.extensions.skin.ImageRemapperUtil
-
public class ImageRemapperUtil extends Object
Utility class for working with image remapping.- Since:
- 3.4
- Author:
- nicklas
-
-
Field Summary
Fields Modifier and Type Field Description private static ImageRemapper
currentImageRemapper
private static boolean
newMapperIsNeeded
private static ServletContext
servletContext
-
Constructor Summary
Constructors Constructor Description ImageRemapperUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImageRemapper
getCurrentMapper()
Get the current image remapper.static ImageRemapper
getNewImageRemapperIfNeeded(ServletContext context)
Get a new image remapper if it is needed, otherwise null.static void
init(ServletContext context)
Initialized at server startup.static void
remapAllTo(ImageRemapper mapper, String url)
Scan the given url for images (png and gif) and remap them.static void
setCurrentMapper(ImageRemapper remapper)
Changes the current image remapper.
-
-
-
Field Detail
-
servletContext
private static ServletContext servletContext
-
currentImageRemapper
private static ImageRemapper currentImageRemapper
-
newMapperIsNeeded
private static transient boolean newMapperIsNeeded
-
-
Method Detail
-
init
public static void init(ServletContext context)
Initialized at server startup.
-
getNewImageRemapperIfNeeded
public static ImageRemapper getNewImageRemapperIfNeeded(ServletContext context)
Get a new image remapper if it is needed, otherwise null. Once the remapping is complete, usesetCurrentMapper(ImageRemapper)
to change the current image remapper.
-
getCurrentMapper
public static ImageRemapper getCurrentMapper()
Get the current image remapper. Can be null if remapping is not needed.
-
setCurrentMapper
public static void setCurrentMapper(ImageRemapper remapper)
Changes the current image remapper. The remapping should have been complete before calling this method since the image remapper is not thread-safe for writing. If the new remapper size is 0 the current remapper is set to null.
-
remapAllTo
public static void remapAllTo(ImageRemapper mapper, String url)
Scan the given url for images (png and gif) and remap them. The url can be a path that is relative the root of the server or root of the context. It should always start with a /. The remapping is done so that the given path is searched recursively and the subpaths found are remapped the full path. For example, if url is /extensions/example.jar/remap and this folder contains a subfolder with two images (images/baselogo.png and images/cancel.png) the following remap is done: /images/baselogo.png --> /extensions/example.jar/remap/images/baselogo.png /images/cancel.png --> /extensions/example.jar/remap/images/cancel.png
-
-