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 SummaryConstructors Constructor Description RendererHelper()
- 
Method SummaryModifier and Type Method Description static java.lang.StringcreateLabel(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)Shorten the given texttextso that its length doesn't exceed the given width.static org.eclipse.swt.graphics.PointgetBestSize(int originalX, int originalY, int maxX, int maxY)Get best-fit size for an image drawn in an area of maxX, maxYstatic org.eclipse.swt.graphics.PointgetImageOffset(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 intgetShift(int totalSize, int size)Return the offset to use in order to center an object in a given area.static booleanisColorsEquals(org.eclipse.swt.graphics.Color galleryColor, org.eclipse.swt.graphics.Color itemColor)Checks if two colors are equals by comparing their RGB values.
- 
Constructor Details- 
RendererHelperpublic RendererHelper()
 
- 
- 
Method Details- 
createLabelpublic static java.lang.String createLabel(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)Shorten the given texttextso 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
 
- 
getBestSizepublic 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:
 
- 
getImageOffsetpublic 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:
 
- 
getShiftpublic 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:
 
- 
isColorsEqualspublic 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.
 
 
-