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 and Description |
---|
RendererHelper() |
Modifier and Type | Method and 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.
|
public static java.lang.String createLabel(java.lang.String text, org.eclipse.swt.graphics.GC gc, int width)
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.CLabelgc
- the gc to use for text measurementt
- the text to shortenwidth
- the width to shorten the text to, in pixelspublic static org.eclipse.swt.graphics.Point getBestSize(int originalX, int originalY, int maxX, int maxY)
originalX
- originalY
- maxX
- maxY
- public static org.eclipse.swt.graphics.Point getImageOffset(int imageWidth, int imageHeight, int areaWidth, int areaHeight)
imageWidth
- imageHeight
- areaWidth
- areaHeight
- public static int getShift(int totalSize, int size)
totalSize
- size
- public static boolean isColorsEquals(org.eclipse.swt.graphics.Color galleryColor, org.eclipse.swt.graphics.Color itemColor)
galleryColor
- First coloritemColor
- Second color.