Package de.gsi.chart.utils
Class WritableImageCache
- java.lang.Object
-
- java.util.AbstractCollection<T>
-
- de.gsi.dataset.utils.CacheCollection<javafx.scene.image.WritableImage>
-
- de.gsi.chart.utils.WritableImageCache
-
- All Implemented Interfaces:
java.lang.Iterable<javafx.scene.image.WritableImage>,java.util.Collection<javafx.scene.image.WritableImage>
public class WritableImageCache extends de.gsi.dataset.utils.CacheCollection<javafx.scene.image.WritableImage>Implements WritableImage cache collection to minimise memory re-allocation.N.B. This is useful to re-use short-lived data storage container to minimise the amount of garbage to be collected. This is used in situation replacing e.g.
withpublic returnValue frequentlyExecutedFunction(...) { final WritableImage storage = new WritableImage(width, heigth); // allocate new memory block (costly) // [...] do short-lived computation on storage // storage is implicitly finalised by garbage collector (costly) }// ... private final WritableImageCache cache = new WritableImageCache(); // ... public returnValue frequentlyExecutedFunction(...) { final byte[] storage = cache.getImage(width, height); // return previously allocated image (cheap) or allocated new if necessary // [...] do short-lived computation on storage cache.add(storage); // return object to cache }- Author:
- rstein
-
-
Constructor Summary
Constructors Constructor Description WritableImageCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.scene.image.WritableImagegetImage(int requiredWidth, int requiredHeight)static WritableImageCachegetInstance()-
Methods inherited from class de.gsi.dataset.utils.CacheCollection
add, cleanup, clear, contains, iterator, remove, size
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getImage
public javafx.scene.image.WritableImage getImage(int requiredWidth, int requiredHeight)
-
getInstance
public static WritableImageCache getInstance()
-
-