ListCellGraphicpublic class ListCellGraphic extends ListCell implements org.gudy.azureus2.ui.swt.components.BufferedGraphicTableItem
Fields Summary |
---|
private int | marginHeight | private int | marginWidth | private int | orientation | private Image | image | private Rectangle | imageBounds |
Constructors Summary |
---|
public ListCellGraphic(ListRow row, int position, int alignment, Rectangle bounds)
super(row, position, alignment, bounds);
|
Methods Summary |
---|
public void | doPaint(GC gc)
if (getPosition() < 0) {
return;
}
gc.setBackground(getBackground());
if (DEBUG_COLORCELL) {
gc.setBackground(Display.getDefault().getSystemColor(
(int) (Math.random() * 16)));
}
Rectangle bounds = getBounds();
if (bounds == null) {
return;
}
gc.fillRectangle(bounds);
// TODO: Orientation: fill
if (image != null && !image.isDisposed()) {
Point size = getSize();
//System.out.println(bounds);
int x;
int y = marginHeight;
y += (size.y - imageBounds.height) / 2;
if (orientation == SWT.CENTER) {
x = marginWidth;
x += (size.x - (marginWidth * 2) - imageBounds.width) / 2;
} else if (orientation == SWT.RIGHT) {
x = bounds.height - marginWidth - imageBounds.width;
} else {
x = marginWidth;
}
int width = Math.min(bounds.width - x - marginWidth, imageBounds.width);
int height = Math.min(bounds.height - y - marginHeight,
imageBounds.height);
if (width >= 0 && height >= 0) {
gc.drawImage(image, 0, 0, width, height, bounds.x + x, bounds.y + y,
width, height);
}
}
| public Image | getGraphic()
return image;
| public int | getMarginHeight()
return marginHeight;
| public int | getMarginWidth()
return marginWidth;
| public int | getOrientation()
return orientation;
| public Point | getSize()
Rectangle bounds = getBounds();
if (bounds == null) {
return new Point(0, 0);
}
return new Point(bounds.width - (marginWidth * 2), bounds.height
- (marginHeight * 2));
| public boolean | setGraphic(Image img)
//System.out.println(img.getBounds());
if (img != null && img.isDisposed()) {
return false;
}
if (image == img) {
return false;
}
image = img;
if (image != null) {
imageBounds = image.getBounds();
}
((ListView) row.getView()).cellRefresh(this, true, true);
return true;
| public void | setMargin(int width, int height)
if (width >= 0) {
marginWidth = width;
}
if (height >= 0) {
marginHeight = height;
}
| public void | setOrientation(int orientation)
this.orientation = orientation;
|
|