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 sizes
    boolean isSelected()
    true is the current item is selected
    void 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)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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
  • Constructor Details

  • 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

      public Gallery getGallery()
      Get current gallery.
      Returns:
    • setGallery

      public void setGallery​(Gallery gallery)
      Set the current gallery. This method is automatically called by Gallery.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