Class AbstractGalleryItemRenderer
- java.lang.Object
-
- org.eclipse.nebula.widgets.gallery.AbstractGalleryItemRenderer
-
- Direct Known Subclasses:
DefaultGalleryItemRenderer,ListItemRenderer
public abstract class AbstractGalleryItemRenderer extends java.lang.ObjectBase 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.StringEMPTY_STRINGprotected Gallerygallery(package private) org.eclipse.swt.graphics.ColorgalleryBackgroundColor(package private) org.eclipse.swt.graphics.ColorgalleryForegroundColorstatic java.lang.StringOVERLAY_BOTTOM_LEFTId for decorators located at the bottom left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.StringOVERLAY_BOTTOM_RIGHTId for decorators located at the bottom right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.StringOVERLAY_TOP_LEFTId for decorators located at the top left of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); static java.lang.StringOVERLAY_TOP_RIGHTId for decorators located at the top right of the item image Example : item.setData( AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT ,); protected booleanselected
-
Constructor Summary
Constructors Constructor Description AbstractGalleryItemRenderer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voiddispose()abstract voiddraw(org.eclipse.swt.graphics.GC gc, GalleryItem item, int index, int x, int y, int width, int height)Draws an item.protected voiddrawAllOverlays(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 voiddrawOverlayImages(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.ColorgetBackground(GalleryItem item)Check the GalleryItem, Gallery, and Display in order for the active background color for the given GalleryItem.protected org.eclipse.swt.graphics.FontgetFont(GalleryItem item)Check the GalleryItem, Gallery, and Display in order for the active font for the given GalleryItem.protected org.eclipse.swt.graphics.ColorgetForeground(GalleryItem item)Check the GalleryItem, Gallery, and Display in order for the active foreground color for the given GalleryItem.GallerygetGallery()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 doublegetOverlayRatio(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.PointgetOverlaySize(org.eclipse.swt.graphics.Image[] images)Return overlay size, summing all images sizesbooleanisSelected()true is the current item is selectedvoidpostDraw(org.eclipse.swt.graphics.GC gc)This method is called after drawing the last item.voidpreDraw(org.eclipse.swt.graphics.GC gc)This method is called before drawing the first item.voidsetGallery(Gallery gallery)Set the current gallery.voidsetSelected(boolean selected)
-
-
-
Field Detail
-
OVERLAY_BOTTOM_RIGHT
public static final 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 ,); - See Also:
- Constant Field Values
-
OVERLAY_BOTTOM_LEFT
public static final 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 ,); - See Also:
- Constant Field Values
-
OVERLAY_TOP_RIGHT
public static final 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 ,); - See Also:
- Constant Field Values
-
OVERLAY_TOP_LEFT
public static final 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 ,); - See Also:
- Constant Field Values
-
EMPTY_STRING
protected static final java.lang.String EMPTY_STRING
- See Also:
- Constant Field Values
-
gallery
protected Gallery gallery
-
galleryBackgroundColor
org.eclipse.swt.graphics.Color galleryBackgroundColor
-
galleryForegroundColor
org.eclipse.swt.graphics.Color galleryForegroundColor
-
selected
protected boolean selected
-
-
Method Detail
-
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
public Gallery getGallery()
Get current gallery.- Returns:
-
setGallery
public void setGallery(Gallery gallery)
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
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.- Parameters:
item-id-- Returns:
- Image[] or null
-
getBackground
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.- Parameters:
item-- Returns:
- the background Color to use for this item
-
getForeground
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.- Parameters:
item-- Returns:
- the foreground Color to use for this item
-
getFont
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.- Parameters:
item-- Returns:
- the Font to use for this item
-
-