TagCloud

A Java Swing Tag Cloud Component

Created by Richard Eigenmann / richard.eigenmann@gmail.com

Try it out

Java Web Start: http://richardeigenmann.github.io/TagCloud/TagCloud.jnlp

Or, if that didn't work, the next two slides show screenshots.

Example

Here the font size correlates the the height of the person and the color reflects the Body Mass Index of the person.

Disclaimer: Data sourced from untrustworthy sites on the Internet.

Another Example

Here is an example where the font size and font color correlate to the population size of big cities.

(Data sourced from Wikipedia)

Open Source

Usage


// create a List of WeightedWord objects
List<WeightedWordInterface> weightedWordList = new ArrayList<>();
weightedWordList.add( new WeightedWord( "Word1", 10, 50 ) );
weightedWordList.add( new WeightedWord( "Word2", 60, 20 ) );

// create the TagCloud
TagCloud tagCloud = new TagCloud();
tagCloud.setWordsList( weightedWordList );
	

Respond to click events


tagCloud.addTagClickListener( new TagClickListener() {
  @Override
  public void tagClicked( WeightedWordInterface weightedWord ) {
    doTagClicked( weightedWord );
  }
} );

public void doTagClicked( WeightedWordInterface weightedWord ) {
  System.out.println( String.format( "The word: %s was clicked",
	  weightedWord.getWord() ) );
}

Customise Font and Color


tagCloud.setColorProvider( new BMIColorProvider() );
tagCloud.setFontProvider( new SansSerifFontProvider() );

Pre-built ColorProviders:

  • BlackToWhiteGradient
  • BMIColorProvider
  • ColorInterpolator
  • ColorPicker
  • SampleGradientColors
  • ShadesOfLightBlue
  • YellowBrownGradient

Pre-built FontProviders:

  • HeavyFontProvider
  • SansSerifFontProvider
  • SerifFontProvider

Impressum