|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.tagcloud.TagCloud
public class TagCloud
Generates HTML for a tag cloud.
A tag cloud accepts a series of (string , score, color) triples and creates HTML to display the strings in descending order by score. The font size for each string is based upon the relative value of that string's score. The colors are standard HTML colors, e.g., blue, green, black, etc. The styles are defined by TagCloudTextStyle and can be plain, bold, italicized, or bold and italicized.
To create a tag cloud:
TagCloud tagCloud = new TagCloud();
To add an entry to the cloud:
tagCloud.addTag( "my tag" , 10.234 , "black" ,
new TagCloudTextStyle( false , false ) );
To get the HTML for displaying the cloud after all the tags have been added:
String html = tagCloud.getHTML();
The generated HTML only contains style settings and a div wrapping a sequence of lines for displaying the tags. This allows the tag cloud html to be embedded within a larger html context.
To set the font size for the largest score (default 100):
tagCloud.setMaximumFontSize( 150 );
To set the minimum font size for display (default 3):
tagCloud.setMinimumFontSize( 150 );
Tags whose font sizes are smaller than minFontSize are not displayed in the cloud.
To deactivate a tag once it has been added, so that the tag will not display in the cloud:
tagCloud.deactivateTag( "my tag" , 10.234 );
Both the tag and score must match an existing tag or the deactivation request is ignored. To reactivate a tag for display:
tagCloud.activateTag( "my tag" , 10.234 );
Field Summary | |
---|---|
protected java.lang.StringBuffer |
cloudHTML
Holds HTML text for tag cloud. |
protected double |
maxFontSize
Maximum font point size for display. |
protected double |
minFontSize
Minimum font point size for display. |
protected SortedArrayList |
tagScoreList
Tags sorted by score. |
Constructor Summary | |
---|---|
TagCloud()
Create empty tag cloud. |
Method Summary | |
---|---|
void |
activateTag(java.lang.String tag,
double score)
Activate tag in cloud. |
protected void |
addFooter()
Add footer. |
protected void |
addHeader()
Add header. |
protected void |
addHTML(java.lang.String html)
Add HTML line to cloud. |
void |
addTag(java.lang.String tag,
double score)
Add tag to cloud. |
void |
addTag(java.lang.String tag,
double score,
java.lang.String color)
Add tag to cloud. |
void |
addTag(java.lang.String tag,
double score,
java.lang.String color,
TagCloudTextStyle style)
Add tag to cloud. |
void |
deactivateTag(java.lang.String tag,
double score)
Deactivate tag in cloud. |
java.lang.String |
getHTML()
Return tag cloud HTML. |
void |
setMaximumFontSize(double maxFontSize)
Set the maximum font size. |
void |
setMinimumFontSize(double minFontSize)
Set the minimum font size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.StringBuffer cloudHTML
protected SortedArrayList tagScoreList
protected double maxFontSize
protected double minFontSize
Constructor Detail |
---|
public TagCloud()
Method Detail |
---|
public void addTag(java.lang.String tag, double score, java.lang.String color, TagCloudTextStyle style)
tag
- The tag string.score
- The tag score.color
- The color for the string.
Should be specified using standard HTML
color names, e.g., "black" , "blue", etc.style
- The style for the string. public void addTag(java.lang.String tag, double score, java.lang.String color)
tag
- The tag string.score
- The tag score.color
- The color for the string.
Should be specified using standard HTML
color names, e.g., "black" , "blue", etc.
Uses plain normal as the text style.
public void addTag(java.lang.String tag, double score)
tag
- The tag string.score
- The tag score.
Uses plain normal as the text style and black as the text color.
public void deactivateTag(java.lang.String tag, double score)
tag
- The tag string.score
- The tag score. public void activateTag(java.lang.String tag, double score)
tag
- The tag string.score
- The tag score. public java.lang.String getHTML()
public void setMaximumFontSize(double maxFontSize)
maxFontSize
- Maximum font size for display. public void setMinimumFontSize(double minFontSize)
minFontSize
- Minimum font size for display.
Tags whose font sizes are smaller than minFontSize are not displayed in the cloud.
protected void addHTML(java.lang.String html)
protected void addHeader()
protected void addFooter()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |