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

Bug 320928

Summary: Deprecate Graphics#getXXX methods?
Product: [RT] RAP Reporter: Ralf Sternberg <rsternberg>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 1.4   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Ralf Sternberg CLA 2010-07-26 12:33:45 EDT
The Graphics#getColor() and Graphics#getFont() methods are obsoleted by the fly-weights approach. They should be deprecated as they provide no value-add compared to the constructors.

Graphics#getImage() methods are not so clear. These methods still have an advantage over constructors - the receive an additional parameter that is used as caching key internally. On the other hand, caching can be done by using JFace registries, or in case of an RWT standalone environment, by caching ImageData. The latter is a bit less effective than Graphics#getImage() because new Image( Device, ImageData ) needs to read the data array to get the caching key.

Opinions?
Comment 1 Ivan Furnadjiev CLA 2010-08-20 12:35:51 EDT
Maybe factory created fonts can be used as an internal undisposable font copy in some cases - see these bug 323183 and bug 321135.
Comment 2 Ralf Sternberg CLA 2012-11-13 06:55:51 EST
I've deprecated the entire class in commit 1966db9a1f021fa86ed93c4ef4c14e26073293db.

Factory-created resources are obsolete, resources should always be created using a constructor. The remaining methods were related to text size measurement, which should also be possible using SWT API (GC) with one exception: GC#textExtent() does not support a wrap-width parameter.

If there is interest, we could offer a public utility class for text size measurement. I've opened bug 394169 to suggest that.