Class AbstractGalleryItemRenderer
java.lang.Object
org.eclipse.nebula.widgets.gallery.AbstractGalleryItemRenderer
- Direct Known Subclasses:
DefaultGalleryItemRenderer
,ListItemRenderer
public abstract class AbstractGalleryItemRenderer
extends java.lang.Object
Base class used to implement a custom gallery item renderer.
NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
EMPTY_STRING
protected Gallery
gallery
(package private) org.eclipse.swt.graphics.Color
galleryBackgroundColor
(package private) org.eclipse.swt.graphics.Color
galleryForegroundColor
static java.lang.String
OVERLAY_BOTTOM_LEFT
Id for decorators located at the bottom left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.String
OVERLAY_BOTTOM_RIGHT
Id for decorators located at the bottom right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.String
OVERLAY_TOP_LEFT
Id for decorators located at the top left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.String
OVERLAY_TOP_RIGHT
Id for decorators located at the top right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); protected boolean
selected
-
Constructor Summary
Constructors Constructor Description AbstractGalleryItemRenderer()
-
Method Summary
Modifier and Type Method Description abstract void
dispose()
abstract void
draw(org.eclipse.swt.graphics.GC gc, GalleryItem item, int index, int x, int y, int width, int height)
Draws an item.protected void
drawAllOverlays(org.eclipse.swt.graphics.GC gc, GalleryItem item, int x, int y, org.eclipse.swt.graphics.Point imageSize, int xShift, int yShift)
Draw image overlays.protected void
drawOverlayImages(org.eclipse.swt.graphics.GC gc, int x, int y, double ratio, org.eclipse.swt.graphics.Image[] images)
Draw overlay images for one corner.protected org.eclipse.swt.graphics.Color
getBackground(GalleryItem item)
Check the GalleryItem, Gallery, and Display in order for the active background color for the given GalleryItem.protected org.eclipse.swt.graphics.Font
getFont(GalleryItem item)
Check the GalleryItem, Gallery, and Display in order for the active font for the given GalleryItem.protected org.eclipse.swt.graphics.Color
getForeground(GalleryItem item)
Check the GalleryItem, Gallery, and Display in order for the active foreground color for the given GalleryItem.Gallery
getGallery()
Get current gallery.protected org.eclipse.swt.graphics.Image[]
getImageOverlay(GalleryItem item, java.lang.String id)
Returns an array of images or null of no overlay was defined for this image.protected double
getOverlayRatio(org.eclipse.swt.graphics.Point imageSize, org.eclipse.swt.graphics.Point overlaySizeTopLeft, org.eclipse.swt.graphics.Point overlaySizeTopRight, org.eclipse.swt.graphics.Point overlaySizeBottomLeft, org.eclipse.swt.graphics.Point overlaySizeBottomRight)
Returns the best size ratio for overlay images.protected org.eclipse.swt.graphics.Point
getOverlaySize(org.eclipse.swt.graphics.Image[] images)
Return overlay size, summing all images sizesboolean
isSelected()
true is the current item is selectedvoid
postDraw(org.eclipse.swt.graphics.GC gc)
This method is called after drawing the last item.void
preDraw(org.eclipse.swt.graphics.GC gc)
This method is called before drawing the first item.void
setGallery(Gallery gallery)
Set the current gallery.void
setSelected(boolean selected)
-
Field Details
-
OVERLAY_BOTTOM_RIGHT
public static final java.lang.String OVERLAY_BOTTOM_RIGHTId for decorators located at the bottom right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); - See Also:
- Constant Field Values
-
OVERLAY_BOTTOM_LEFT
public static final java.lang.String OVERLAY_BOTTOM_LEFTId for decorators located at the bottom left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); - See Also:
- Constant Field Values
-
OVERLAY_TOP_RIGHT
public static final java.lang.String OVERLAY_TOP_RIGHTId for decorators located at the top right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); - See Also:
- Constant Field Values
-
OVERLAY_TOP_LEFT
public static final java.lang.String OVERLAY_TOP_LEFTId for decorators located at the top left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); - See Also:
- Constant Field Values
-
EMPTY_STRING
protected static final java.lang.String EMPTY_STRING- See Also:
- Constant Field Values
-
gallery
-
galleryBackgroundColor
org.eclipse.swt.graphics.Color galleryBackgroundColor -
galleryForegroundColor
org.eclipse.swt.graphics.Color galleryForegroundColor -
selected
protected boolean selected
-
-
Constructor Details
-
AbstractGalleryItemRenderer
public AbstractGalleryItemRenderer()
-
-
Method Details
-
isSelected
public boolean isSelected()true is the current item is selected- Returns:
-
setSelected
public void setSelected(boolean selected) -
draw
public abstract void draw(org.eclipse.swt.graphics.GC gc, GalleryItem item, int index, int x, int y, int width, int height)Draws an item.- Parameters:
gc
-item
-index
-x
-y
-width
-height
-
-
dispose
public abstract void dispose() -
preDraw
public void preDraw(org.eclipse.swt.graphics.GC gc)This method is called before drawing the first item. It may be used to calculate some values (like font metrics) that will be used for each item.- Parameters:
gc
-
-
postDraw
public void postDraw(org.eclipse.swt.graphics.GC gc)This method is called after drawing the last item. It may be used to cleanup and release resources created in preDraw().- Parameters:
gc
-
-
getGallery
Get current gallery.- Returns:
-
setGallery
Set the current gallery. This method is automatically called byGallery.setItemRenderer(AbstractGalleryItemRenderer)
. There is not need to call it from user code.- Parameters:
gallery
-
-
getOverlayRatio
protected double getOverlayRatio(org.eclipse.swt.graphics.Point imageSize, org.eclipse.swt.graphics.Point overlaySizeTopLeft, org.eclipse.swt.graphics.Point overlaySizeTopRight, org.eclipse.swt.graphics.Point overlaySizeBottomLeft, org.eclipse.swt.graphics.Point overlaySizeBottomRight)Returns the best size ratio for overlay images. This ensure that all images can fit without being drawn on top of others.- Parameters:
imageSize
-overlaySizeTopLeft
-overlaySizeTopRight
-overlaySizeBottomLeft
-overlaySizeBottomRight
-- Returns:
-
drawAllOverlays
protected void drawAllOverlays(org.eclipse.swt.graphics.GC gc, GalleryItem item, int x, int y, org.eclipse.swt.graphics.Point imageSize, int xShift, int yShift)Draw image overlays. Overlays are defined with image.setData using the following keys :- org.eclipse.nebula.widget.gallery.bottomLeftOverlay
- org.eclipse.nebula.widget.gallery.bottomRightOverlay
- org.eclipse.nebula.widget.gallery.topLeftOverlay
- org.eclipse.nebula.widget.gallery.topRightOverlay
-
drawOverlayImages
protected void drawOverlayImages(org.eclipse.swt.graphics.GC gc, int x, int y, double ratio, org.eclipse.swt.graphics.Image[] images)Draw overlay images for one corner.- Parameters:
gc
-x
-y
-ratio
-images
-
-
getOverlaySize
protected org.eclipse.swt.graphics.Point getOverlaySize(org.eclipse.swt.graphics.Image[] images)Return overlay size, summing all images sizes- Parameters:
images
-- Returns:
-
getImageOverlay
Returns an array of images or null of no overlay was defined for this image.- Parameters:
item
-id
-- Returns:
- Image[] or null
-
getBackground
Check the GalleryItem, Gallery, and Display in order for the active background color for the given GalleryItem.- Parameters:
item
-- Returns:
- the background Color to use for this item
-
getForeground
Check the GalleryItem, Gallery, and Display in order for the active foreground color for the given GalleryItem.- Parameters:
item
-- Returns:
- the foreground Color to use for this item
-
getFont
Check the GalleryItem, Gallery, and Display in order for the active font for the given GalleryItem.- Parameters:
item
-- Returns:
- the Font to use for this item
-