Class RendererHelper

java.lang.Object
org.eclipse.nebula.widgets.gallery.RendererHelper

public class RendererHelper
extends java.lang.Object

Utility methods for Gallery item and group renderers

NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.

  • Constructor Summary

    Constructors 
    Constructor Description
    RendererHelper()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String createLabel​(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)
    Shorten the given text text so that its length doesn't exceed the given width.
    static org.eclipse.swt.graphics.Point getBestSize​(int originalX, int originalY, int maxX, int maxY)
    Get best-fit size for an image drawn in an area of maxX, maxY
    static org.eclipse.swt.graphics.Point getImageOffset​(int imageWidth, int imageHeight, int areaWidth, int areaHeight)
    Return both width and height offsets for an image to be centered in a given area.
    static int getShift​(int totalSize, int size)
    Return the offset to use in order to center an object in a given area.
    static boolean isColorsEquals​(org.eclipse.swt.graphics.Color galleryColor, org.eclipse.swt.graphics.Color itemColor)
    Checks if two colors are equals by comparing their RGB values.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • createLabel

      public static java.lang.String createLabel​(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)
      Shorten the given text text so that its length doesn't exceed the given width. The default implementation replaces characters in the center of the original string with an ellipsis ("..."). Override if you need a different strategy. Note: Code originally from org.eclipse.cwt.CLabel
      Parameters:
      gc - the gc to use for text measurement
      t - the text to shorten
      width - the width to shorten the text to, in pixels
      Returns:
      the shortened text
    • getBestSize

      public static org.eclipse.swt.graphics.Point getBestSize​(int originalX, int originalY, int maxX, int maxY)
      Get best-fit size for an image drawn in an area of maxX, maxY
      Parameters:
      originalX -
      originalY -
      maxX -
      maxY -
      Returns:
    • getImageOffset

      public static org.eclipse.swt.graphics.Point getImageOffset​(int imageWidth, int imageHeight, int areaWidth, int areaHeight)
      Return both width and height offsets for an image to be centered in a given area.
      Parameters:
      imageWidth -
      imageHeight -
      areaWidth -
      areaHeight -
      Returns:
    • getShift

      public static int getShift​(int totalSize, int size)
      Return the offset to use in order to center an object in a given area.
      Parameters:
      totalSize -
      size -
      Returns:
    • isColorsEquals

      public static boolean isColorsEquals​(org.eclipse.swt.graphics.Color galleryColor, org.eclipse.swt.graphics.Color itemColor)
      Checks if two colors are equals by comparing their RGB values. This method is null-proof.
      Parameters:
      galleryColor - First color
      itemColor - Second color.
      Returns:
      true if same object or RGB values are equals.