EchoPoint API - 3.0.0b5
App Webcontainer

echopoint
Class TagCloud

java.lang.Object
  extended by nextapp.echo.app.Component
      extended by echopoint.internal.AbstractContainer
          extended by echopoint.TagCloud
All Implemented Interfaces:
Serializable, RenderIdSupport

public class TagCloud
extends AbstractContainer

A tag cloud component based on client-side code contribued by Tod. Please note that the tag model objects specified for this component should have a unique name property. This component supports the following style properties in addition to those defined in Component:

Note: There is a bug in how updates to the tags properties are handled by the update manager at present. For the time-being, please remove and re-add the tag cloud to its parent if the tags have been updated during an event cycle (see TagCloudTest for example).

The following shows sample usage of this component:

   import echopoint.TagCloud;
   import echopoint.event.TagEvent;
   import echopoint.model.Tag;
   import nextapp.echo.app.Row;

     ...
     final Collection<Tag> tags = new LinkedHashSet<Tag>();
     tags.add( new Tag( "Java", 50 ) );
     tags.add( new Tag( "Objective-C", 25 ) );
     tags.add( new Tag( "Groovy", 10 ) );
     tags.add( new Tag( "JavaScript", 15 ) );

     final Row row = new Row();
     final TagCloud tc = new TagCloud();
     tc.setRolloverEnabled( true );
     tc.setRolloverBackground( new Color( 0xa1a1a1 ) );
     tc.setRolloverForeground( new Color( 0xc1c1c1 ) );
     tc.setTags( tags );
     row.add( tc );

      tc.addActionListener( new ActionListener()
      {
        public void actionPerformed( final ActionEvent event )
        {
          final TagEvent te = (TagEvent) event;
          if ( te.getTag() != null )
          {
            final Component content = Application.getContent().getTestArea();
            content.add( new Label( "Clicked Tag: " + te.getTag().getName() ) );
          }
        }
      });
 

Version:
$Id: TagCloud.java 204 2009-05-20 18:50:57Z sptrakesh $
Author:
Rakesh 2008-07-20
See Also:
Serialized Form

Field Summary
static String PROPERTY_ROLLOVER_BACKGROUND
          The rollover background for the tag element.
static String PROPERTY_ROLLOVER_ENABLED
          A flag indicating whether rollover is enabled for a tag.
static String PROPERTY_ROLLOVER_FOREGROUND
          The rollover foreground for the tag element.
static String PROPERTY_TAGS
          The collection of Tag instances to be represented in the component.
 
Fields inherited from class echopoint.internal.AbstractContainer
ACTION_COMMAND_PROPERTY, ACTION_LISTENERS_CHANGED_PROPERTY, INPUT_ACTION, PROPERTY_ALIGNMENT, PROPERTY_BACKGROUND_IMAGE, PROPERTY_BORDER, PROPERTY_HEIGHT, PROPERTY_INSETS, PROPERTY_WIDTH
 
Fields inherited from class nextapp.echo.app.Component
CHILD_VISIBLE_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_NEXT_ID_CHANGED_PROPERTY, FOCUS_PREVIOUS_ID_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
TagCloud()
           
 
Method Summary
 void addActionListener(ActionListener listener)
          Add the specified action listener to this component.
protected  Collection<Tag> getData()
          Return the collection of tags that represent the model for this component.
 Color getRolloverBackground()
          Return the value of the PROPERTY_ROLLOVER_BACKGROUND property.
 boolean getRolloverEnabled()
          Return the value of the PROPERTY_ROLLOVER_ENABLED property.
 Color getRolloverForeground()
          Return the value of the PROPERTY_ROLLOVER_BACKGROUND property.
 Tag getTag(String name)
          Return the tag identified by its name.
 Collection<Tag> getTags()
          Return the value of the PROPERTY_TAGS property.
 boolean hasActionListeners()
          Determines if the button has any ActionListeners registered.
 boolean isValidChild(Component child)
          TagCloud is NOT allowed to have any children.
 void processInput(String name, Object value)
          
 void removeActionListener(ActionListener listener)
          Remove the specified action listener from the component.
 void setRolloverBackground(Color background)
          Set the value of the PROPERTY_ROLLOVER_BACKGROUND property.
 void setRolloverEnabled(boolean enabled)
          Set the value of the PROPERTY_ROLLOVER_ENABLED property.
 void setRolloverForeground(Color foreground)
          Set the value of the PROPERTY_ROLLOVER_BACKGROUND property.
 void setTags(Collection<Tag> tags)
          Set the value of the PROPERTY_TAGS property.
 
Methods inherited from class echopoint.internal.AbstractContainer
fireActionPerformed, getAlignment, getBackgroundImage, getBorder, getHeight, getInsets, getWidth, setAlignment, setBackgroundImage, setBorder, setHeight, setInsets, setWidth
 
Methods inherited from class nextapp.echo.app.Component
add, add, addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, get, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusNextId, getFocusPreviousId, getFont, getForeground, getId, getIndex, getLayoutData, getLayoutDirection, getLocale, getLocalStyle, getParent, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, removePropertyChangeListener, set, setBackground, setComponents, setEnabled, setFocusNextId, setFocusPreviousId, setFocusTraversalParticipant, setFont, setForeground, setId, setIndex, setLayoutData, setLayoutDirection, setLocale, setRenderId, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_ROLLOVER_ENABLED

public static final String PROPERTY_ROLLOVER_ENABLED
A flag indicating whether rollover is enabled for a tag.

See Also:
Constant Field Values

PROPERTY_ROLLOVER_BACKGROUND

public static final String PROPERTY_ROLLOVER_BACKGROUND
The rollover background for the tag element.

See Also:
Constant Field Values

PROPERTY_ROLLOVER_FOREGROUND

public static final String PROPERTY_ROLLOVER_FOREGROUND
The rollover foreground for the tag element.

See Also:
Constant Field Values

PROPERTY_TAGS

public static final String PROPERTY_TAGS
The collection of Tag instances to be represented in the component.

See Also:
Constant Field Values
Constructor Detail

TagCloud

public TagCloud()
Method Detail

isValidChild

public boolean isValidChild(Component child)
TagCloud is NOT allowed to have any children.

Overrides:
isValidChild in class Component
See Also:
Component.isValidChild(nextapp.echo.app.Component)

getRolloverEnabled

public boolean getRolloverEnabled()
Return the value of the PROPERTY_ROLLOVER_ENABLED property.

Returns:
The flag indicating whether rollover behaviour is enabled or not.

setRolloverEnabled

public void setRolloverEnabled(boolean enabled)
Set the value of the PROPERTY_ROLLOVER_ENABLED property.

Parameters:
enabled - The flag indicating whether rollover behaviour is to be enabled or not.

getRolloverBackground

public Color getRolloverBackground()
Return the value of the PROPERTY_ROLLOVER_BACKGROUND property.

Returns:
The colour used as the background while rolling over the tag.

setRolloverBackground

public void setRolloverBackground(Color background)
Set the value of the PROPERTY_ROLLOVER_BACKGROUND property.

Parameters:
background - The colour used as the background while rolling over.

getRolloverForeground

public Color getRolloverForeground()
Return the value of the PROPERTY_ROLLOVER_BACKGROUND property.

Returns:
The colour used as the foreground while rolling over the tag.

setRolloverForeground

public void setRolloverForeground(Color foreground)
Set the value of the PROPERTY_ROLLOVER_BACKGROUND property.

Parameters:
foreground - The colour used as the foreground while rolling over.

getTags

public Collection<Tag> getTags()
Return the value of the PROPERTY_TAGS property.

Returns:
A read-only view of the collection of tags instances.

getData

protected Collection<Tag> getData()
Return the collection of tags that represent the model for this component.

Returns:
The collection of tag instances.

getTag

public Tag getTag(String name)
Return the tag identified by its name.

Parameters:
name - The unique name for the tag.
Returns:
The tag model object or null if no such tag exists.

setTags

public void setTags(Collection<Tag> tags)
Set the value of the PROPERTY_TAGS property. Note that there is not way to individually add/delete tag instances other than setting a new collection (or a modified version of the original collection you used to set the property).

Parameters:
tags - The collection of tag instances to be represented in this component. Please note that a Set implementation is preferred since this implementation requires unique tag names.

addActionListener

public void addActionListener(ActionListener listener)
Add the specified action listener to this component.

Overrides:
addActionListener in class AbstractContainer
Parameters:
listener - The action listener to add.
See Also:
Component.firePropertyChange(String, Object, Object)

removeActionListener

public void removeActionListener(ActionListener listener)
Remove the specified action listener from the component.

Overrides:
removeActionListener in class AbstractContainer
Parameters:
listener - The listener that is to be removed.
See Also:
Component.firePropertyChange(String, Object, Object)

hasActionListeners

public boolean hasActionListeners()
Determines if the button has any ActionListeners registered.

Overrides:
hasActionListeners in class AbstractContainer
Returns:
true if any action listeners are registered

processInput

public void processInput(String name,
                         Object value)

Overrides:
processInput in class Component

EchoPoint API - 3.0.0b5
App Webcontainer