Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320928 - Deprecate Graphics#getXXX methods?
Summary: Deprecate Graphics#getXXX methods?
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.4   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-26 12:33 EDT by Ralf Sternberg CLA
Modified: 2012-11-13 06:55 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.