Cameron Hotchkies

Categories

  • Coding

Tags

  • SrsBiznas
  • controls
  • opensource
  • wordcloud

I recently found a need for a Cocoa based implementation of a word cloud and ended up throwing one together. I know word clouds provide very little informational value and they’re kinda 2004 but I made it anyways. I’ve released the source under the Apache 2.0 license (as per the usual). More info is available at the Srs Biznas site (or in the case there’s a distant future where Srs Biznas no longer exists, here’s the GitHub link)

Word cloud for my music

Usage is very easy, just lay out a custom NSView in Interface Builder and change the class to SRSWordCloudView.

SRSRankedWord* rw1 = [[SRSRankedWord alloc] init]; 
SRSRankedWord* rw2 = [[SRSRankedWord alloc] init]; 
SRSRankedWord* rw3 = [[SRSRankedWord alloc] init]; 

NSMutableArray* words = [NSMutableArray array]; 

rw1.word = @"Word 1"; 
rw1.rank = 1; 
[words addObject:rw1]; 

rw2.word = @"Word 2"; 
rw2.rank = 10; 
[words addObject:rw2]; 

rw3.word = @"Word 3"; 
rw3.rank = 25; 
[words addObject:rw3]; 

wordCloud.wordList = words; 
wordCloud.delegate = self; 

The NSTextFields in the word cloud respond to right click & control click events with a context menu. The context menu can be supplied by implementing the SRSWordCloudViewDelegate protocol.