Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 216788

Summary: inconsistent implementation - Figure#setBackgroundColor always calls repaint
Product: [Tools] GEF Reporter: Heiko Böttger <heiko.boettger>
Component: GEF-Legacy Draw2dAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: nyssen, remy.suen
Version: 3.3.1   
Target Milestone: 3.7.1 (Indigo) M5   
Hardware: All   
OS: All   
Whiteboard:

Description Heiko Böttger CLA 2008-01-28 11:14:29 EST
Build ID: M20071023-1652

Steps To Reproduce:
The implementation of setForegroundColor is guarded against assigning the same color while setBackgroundColor is not. 

1. Compare setBackgroundColor with setForegroundColor

/**
 * @see IFigure#setBackgroundColor(Color)
 */
public void setBackgroundColor(Color bg) {
	bgColor = bg;
	repaint();
}


/**
 * @see IFigure#setForegroundColor(Color)
 */
public void setForegroundColor(Color fg) {
	if (fgColor != null && fgColor.equals(fg)) 
		return;
	fgColor = fg;
	repaint();
}


More information:
This would be easy to fix and could improve performance.

public void setBackgroundColor(Color bg) {
	if (bgColor != null && bgColor.equals(bg)) 
		return;
	bgColor = bg;
	repaint();
}
Comment 1 Remy Suen CLA 2008-01-28 23:32:33 EST
IFigure? I think this is a GEF bug.
Comment 2 Heiko Böttger CLA 2008-01-30 02:19:47 EST
Yes, it belongs to GEF. It is in the draw2d-component.
The code is in the org.eclipse.draw2d.Figure class.
Comment 3 Alexander Nyßen CLA 2011-02-02 16:44:16 EST
Added guard to setBackgroundColor(Color) to return if provided color is already set as background color. Committed change to cvs HEAD (3.7M5). Resolving as fixed.