FileDocCategorySizeDatePackage
BufferedTableItemImpl.javaAPI DocAzureus 3.0.3.44895Fri May 04 14:33:54 BST 2007org.gudy.azureus2.ui.swt.components

BufferedTableItemImpl

public abstract class BufferedTableItemImpl extends Object implements BufferedTableItem
author
Olivier

Fields Summary
protected BufferedTableRow
row
private int
position
private Color
ourFGColor
private String
text
private Image
icon
Constructors Summary
public BufferedTableItemImpl(BufferedTableRow row, int position)


	     
		this.row = row;
		this.position = position;
	
Methods Summary
public voiddispose()

		if (ourFGColor != null && !ourFGColor.isDisposed())
			ourFGColor.dispose();
	
public voiddoPaint(GC gc)

	
public ColorgetBackground()

		return row.getBackground();
	
public ImagegetBackgroundImage()

		Table table = row.getTable();
		
		Rectangle bounds = getBounds();
		
		if (bounds.isEmpty()) {
			return null;
		}
		
		Image image = new Image(table.getDisplay(), bounds.width, bounds.height);
		
		GC gc = new GC(table);
		gc.copyArea(image, bounds.x, bounds.y);
		gc.dispose();
		
		return image;
	
public RectanglegetBounds()

		if (position != -1)
			return row.getBounds(position);
		return null;
	
public ColorgetForeground()

		if (position == -1)
			return null;

		return row.getForeground(position);
	
public ImagegetIcon()

		if (position != -1) {
			Image image = row.getImage(position);
			return (image != null) ? image : icon;
		}

		return null;
	
public intgetMaxLines()

  	return 1;
  
public intgetPosition()

		return position;
	
public org.eclipse.swt.widgets.TablegetTable()

		return row.getTable();
	
public java.lang.StringgetText()

		if (Utils.SWT32_TABLEPAINT) {
			return text;
		}

		if (position != -1)
			return row.getText(position);
		return "";
	
public booleanisShown()

		return true;
// XXX Bounds check is almost always slower than any changes we
//     are going to do to the column
//		if (position < 0) {
//			return false;
//		}
//		
//		Rectangle bounds = row.getBounds(position);
//		if (bounds == null) {
//			return false;
//		}
//
//		return row.getTable().getClientArea().intersects(bounds);
	
public voidlocationChanged()

	
public booleanneedsPainting()

		return false;
	
public voidredraw()

  
public booleansetForeground(Color color)

		if (position == -1)
			return false;

		boolean ok;
		if (ourFGColor != null) {
			ok = row.setForeground(position, color);
			if (ok) {
				if (!color.isDisposed())
					color.dispose();
				ourFGColor = null;
			}
		} else {
			ok = row.setForeground(position, color);
		}
		return ok;
	
public booleansetForeground(int red, int green, int blue)

		if (position == -1)
			return false;

		Color oldColor = row.getForeground(position);

		RGB newRGB = new RGB(red, green, blue);

		if (oldColor != null && oldColor.getRGB().equals(newRGB)) {
			return false;
		}

		Color newColor = new Color(row.getTable().getDisplay(), newRGB);
		boolean ok = row.setForeground(position, newColor);
		if (ok) {
			if (ourFGColor != null && !ourFGColor.isDisposed())
				ourFGColor.dispose();
			ourFGColor = newColor;
		} else {
			if (!newColor.isDisposed())
				newColor.dispose();
		}

		return ok;
	
public voidsetIcon(Image img)

		if (position != -1) {
			row.setImage(position, img);
			icon = img;
		}
	
public voidsetRowForeground(Color color)

		row.setForeground(color);
	
public booleansetText(java.lang.String text)

		if (Utils.SWT32_TABLEPAINT) {
			if (this.text.equals(text)) {
				return false;
			}
	
			this.text = (text == null) ? "" : text;
			
			Rectangle bounds = getBounds();
			if (bounds != null) {
				Table table = row.getTable();
				Rectangle dirty = table.getClientArea().intersection(bounds);
				table.redraw(dirty.x, dirty.y, dirty.width, dirty.height, false);
			}
			
			return true;
		}

		if (position != -1)
			return row.setText(position, text);
		return false;