This is a fun one, create a tag cloud from a list of words, which you can also use as a menu.
There are 9 weights which correspond to the 9 font weights available, although not all fonts provide 9 weights. The one I've used as default has 5.
Customizable as much as possible, you can add colors for each weight, set a minimum count to achieve before an item is shown, and quite a bit more.
The actual cloud is created in HTML on a webview.
SLTagCloud
Author: Steve Laming
Version: 0.9
The attached demo is quite large as it has a 10,000+ word list that it builds the cloud from.
When you create a new project with Tagcloud, you'll need to load the fonts into your files tab.
This is definitely a beta library. Copy the jar and xml files to your addl libs folder.
Currrent Version is 0.92
If you are using the V3 Beta3+ please download SLTagCloud-3Beta3+.zip, otherwise download SLTagCloudLibs.zip.
There are 9 weights which correspond to the 9 font weights available, although not all fonts provide 9 weights. The one I've used as default has 5.
Customizable as much as possible, you can add colors for each weight, set a minimum count to achieve before an item is shown, and quite a bit more.
The actual cloud is created in HTML on a webview.
SLTagCloud
Author: Steve Laming
Version: 0.9
- Methods:
- Add(Word As String) As String
Add a word to the word list
AddAll(Words As List) As String
Add all the words in List to the word list
AddFont(Weight As String, FontFile As String) As String
Add/Replace a user font, the files should be added to the Files TAB in the IDE
It is possible to specify fonts with weights of: 100, 200, 300, 400 (Normal), 500, 600, 700 (Bold), 800, 900
If you clear the fonts then the default browser font is used for weights that you don't specify, it is better to double up if you
don't have a font for all weights. you can also specify a minimum and maximum weight to use via the
MinimumWeight and MaximumWeight methods. If you don't clear the fonts then the lato font will be used for any you don't specify.
TagCloud.AddFont(100,"mythinfont")
Background As Object
Get or Set the WebView background to one of ColorDrawable OR GradientDrawable
Will return false setting an Object that is not one of the above
Clear As String
Clear the word list
ClearFont As String
Clear the current fonts in use
If you clear the fonts and don't specify new user fonts with AddFont then the default browser font will be used.
Create As String
Create the TagCloud
Draw As String
Draw the tagCloud
getSize As int
Get the current size of the word list
getTCView As WebView
Returns the WebView Object that is used to display the TagCloud
Initialize(mPnl As Panel, Module As Object, EventName As String) As String
Initializes the object.
Requires a panel on which to put the tagcloud and an event name For callback when an item is selected.
Will return a callback to {EventName}_SelectedItem(Item As String) if it exists in the calling module.
IsInitialized As boolean
Tests whether the object has been initialized.
setBackgroundImage(Image As Bitmap) As String - [Write Only]
Sets the background drawable for the TagCloud
setColor(Color As int) As String - [Write Only]
Set the background color for the TagCloud
setFontSizeRatio(Ratio As float) As String - [Write Only]
If the data set has a small range, you can increase the relative difference in font sizes
setLog(TL As boolean) As String - [Write Only]
Send generated HTML to the Log
setMaximumWeight(Weight As int) As String - [Write Only]
Set the maximum weight to use from range: 100,200,300,400,500,600,700,800,900
Set before calling Create
setMaxWords(NoWords As int) As String - [Write Only]
Set the Maximum number of words to appear on one line
setMinFontSize(MinSize As int) As String - [Write Only]
Set the minimum start font size, Default is 20
setMinimumWeight(Weight As int) As String - [Write Only]
Set the minimum weight to use from range: 100,200,300,400,500,600,700,800,900
Set before calling Create
setMinimumWordCount(Count As int) As String - [Write Only]
Don't display words with a count of less than count.
Set before calling Create
setShowCount(Show As boolean) As String - [Write Only]
Show or hide the word count. Hidden by default
Default font size is 14, you can change this with setShowCountFontSize
setShowCountFontSize(px As int) As String - [Write Only]
If Showcount is requested, you can set a font size. Default is 14px
setTop(Top As int) As String - [Write Only]
Set the top position of the view in the provided panel
setWeightColors(Color As int()) As boolean - [Write Only]
Set colors for each of the 9 available weights. Returns true if successful
If you specify a single word color after setting this, weight colors will be ignored.
If you do not specify enough colors then False will be returned, if you specify
too many it will be logged and the surplus ignored.
setWordColor(Color As int) As String - [Write Only]
Set a single wordcolor. If you also specify weight colors after setting this, it will be ignored.
Style As String
Get or Set additional css styling for the words
Visible As boolean
Get or Set the TagCloud's Visibility
Depends on:
javaobject, SLColorlut V1.01
- Add(Word As String) As String
The attached demo is quite large as it has a 10,000+ word list that it builds the cloud from.
When you create a new project with Tagcloud, you'll need to load the fonts into your files tab.
This is definitely a beta library. Copy the jar and xml files to your addl libs folder.
Currrent Version is 0.92
If you are using the V3 Beta3+ please download SLTagCloud-3Beta3+.zip, otherwise download SLTagCloudLibs.zip.
Attachments
Last edited: