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.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ELLIPSIS
-
Constructor Summary
Constructors Constructor Description RendererHelper()
-
Method Summary
All Methods Static Methods Concrete Methods 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 texttext
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, maxYstatic 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.
-
-
-
Field Detail
-
ELLIPSIS
private static final java.lang.String ELLIPSIS
- See Also:
- Constant Field Values
-
-
Method Detail
-
createLabel
public static java.lang.String createLabel(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)
Shorten the given texttext
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 measurementt
- the text to shortenwidth
- 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 coloritemColor
- Second color.- Returns:
- true if same object or RGB values are equals.
-
-