Package com.diffplug.common.swt.jface
Class ImageDescriptors
- java.lang.Object
-
- com.diffplug.common.swt.jface.ImageDescriptors
-
public class ImageDescriptors extends java.lang.Object
Utilities for usingImageDescriptor
s correctly.
-
-
Constructor Summary
Constructors Constructor Description ImageDescriptors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Image
createManagedImage(ImageData data, Widget lifecycle)
Creates an image from the given data, and disposes it when the lifecycle widget is disposed.static Box.Nullable<ImageDescriptor>
createSetter(Widget lifecycle, java.util.function.Supplier<Image> imageGetter, java.util.function.Consumer<Image> imageSetter)
ImageDescriptor
allows anImage
to be shared in a pool using reference counting.static Image
getFromPool(Widget owner, ImageDescriptor descriptor)
Returns an image which will be bound to the lifecycle of the owner widget.static void
set(Button widget, ImageDescriptor image)
Sets the givenButton
to have the image described by the given descriptor, maintaining proper reference counting.static void
set(Item widget, ImageDescriptor image)
Sets the givenItem
to have the image described by the given descriptor, maintaining proper reference counting.static void
set(Label widget, ImageDescriptor image)
Sets the givenLabel
to have the image described by the given descriptor, maintaining proper reference counting.
-
-
-
Method Detail
-
createManagedImage
public static Image createManagedImage(ImageData data, Widget lifecycle)
Creates an image from the given data, and disposes it when the lifecycle widget is disposed.
-
createSetter
public static Box.Nullable<ImageDescriptor> createSetter(Widget lifecycle, java.util.function.Supplier<Image> imageGetter, java.util.function.Consumer<Image> imageSetter)
ImageDescriptor
allows anImage
to be shared in a pool using reference counting. In order to not screw-up the reference counting, you need to be pretty careful with how you use them.This creates a
Box.Nullable<ImageDescriptor>
which sets and gets images in a way that will keep the reference counting happy.NO ONE MUST SET THE IMAGE EXCEPT THIS SETTER.
- Parameters:
lifecycle
- Any outstanding images will be destroyed with the lifecycle of this Widget.imageGetter
- Function which returns the image currently on the Widget (used to ensure that nobody messed with it).imageSetter
- Function which sets the image on the Widget.- Returns:
- A `Box.Nullable
` for setting the Image
using anImageDescriptor
.
-
set
public static void set(Item widget, ImageDescriptor image)
Sets the givenItem
to have the image described by the given descriptor, maintaining proper reference counting.
-
set
public static void set(Button widget, ImageDescriptor image)
Sets the givenButton
to have the image described by the given descriptor, maintaining proper reference counting.
-
set
public static void set(Label widget, ImageDescriptor image)
Sets the givenLabel
to have the image described by the given descriptor, maintaining proper reference counting.
-
getFromPool
public static Image getFromPool(Widget owner, ImageDescriptor descriptor)
Returns an image which will be bound to the lifecycle of the owner widget.
-
-