Make tag cloud in Java by using SWT drawing

This post also assumes that you have a standalone Eclipse RCP application. You can find out how to make one here.

You may have tried some free tools to generate tag cloud or text cloud, but they may not exactly what you want. As a Java programmer, you can quickly implement such a function by using SWT drawing function. We can draw text with different size, color and in different shapes. Even even further, we can use dome mathematical functions to project those text and make a very professional text cloud. The following example only shows how to draw some text by using SWT GC class. To make a tag/text cloud, we can start with the following program and keep adding more functionality.

public void createPartControl(final Composite parent) {
	parent.setLayout(new FillLayout());
	parent.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			GC gc = e.gc;
			Font font = new Font(e.display,"Arial",12, SWT.BOLD | SWT.ITALIC); 
			font = new Font(e.display, "Times", 18, SWT.UNDERLINE_SINGLE);
			gc.drawText("OK", 100, 100);								

The code example above will generate the following diagram.

Category >> Rich Client Platform(RCP)  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";