Author: andrei_exadel
Date: 2009-02-24 08:57:56 -0500 (Tue, 24 Feb 2009)
New Revision: 12727
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/ITagCloudProvider.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
trunk/test-applications/realworld/web/src/main/webapp/includes/tagCloud/
trunk/test-applications/realworld/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
Modified:
trunk/test-applications/realworld/web/src/main/webapp/layout/template.xhtml
trunk/test-applications/realworld/web/src/main/webapp/stylesheet/realworld.css
Log:
RF-6426
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/ITagCloudProvider.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/ITagCloudProvider.java
(rev 0)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/ITagCloudProvider.java 2009-02-24
13:57:56 UTC (rev 12727)
@@ -0,0 +1,18 @@
+/**
+ *
+ */
+package org.richfaces.realworld.tagClound;
+
+import java.util.Map;
+
+/**
+ * Interface defines base method to get scope of tags
+ * @author Andrey Markavtsov
+ *
+ */
+public interface ITagCloudProvider {
+
+ /** Return map of tags. Key - tag label. value - rank. */
+ Map<String, Integer> getTags();
+
+}
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
(rev 0)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-02-24
13:57:56 UTC (rev 12727)
@@ -0,0 +1,94 @@
+/**
+ *
+ */
+package org.richfaces.realworld.tagClound;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.event.ActionEvent;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+
+
+/**
+ * Tag cloud backing bean
+ * @author Andrey Markavtsov
+ *
+ */
+
+@Name("tagCloudBean")
+(a)Scope(ScopeType.CONVERSATION)
+public class TagCloudBean {
+
+ /** Min possible rank for tag */
+ static final int MIN_RANK = 0;
+
+ /** Max possible rank for tag */
+ static final int MAX_RANK = 100;
+
+ /** Scope of existed css classes for each rank. Should be defined ordered ASC by rank
*/
+ static final String [] TAG_CSS_CLASSSES = new String []
+ {"tag-cloud-rank1", "tag-cloud-rank2",
+ "tag-cloud-rank3", "tag-cloud-rank4",
+ "tag-cloud-rank5", "tag-cloud-rank6",
+ "tag-cloud-rank7" } ;
+
+ /** Count of possible ranks' css classes */
+ static final int TAG_RANK_LEVELS_COUNT = TAG_CSS_CLASSSES.length;
+
+ /** Defines the step to the neighbouring rank */
+ int RANK_LEVEL_STEP = (MAX_RANK ) / TAG_RANK_LEVELS_COUNT;;
+
+ //@In
+ //ITagCloudProvider cloudProvider;
+
+
+ /**
+ * @return map of tags
+ */
+ @Out
+ public Map<String, Integer> getTags() {
+ /*if (cloudProvider == null) {
+ throw new NullPointerException("Cloud tag provider is null");
+ }*/
+ //return cloudProvider.getTags();
+ Map<String,Integer> tags = new HashMap<String,Integer>();
+ tags.put("Tag1", 12);
+ tags.put("Tag2", 65);
+ tags.put("Tag3", 89);
+ tags.put("Tag4", 39);
+ tags.put("Tag5", 7);
+ tags.put("Tag6", 59);
+ tags.put("Tag7", 71);
+ tags.put("Tag8", 85);
+ tags.put("Tag9", 29);
+ return tags;
+
+ }
+
+
+ /**
+ * Calculates css class name for tag with rank defined
+ * @param rank - tags rank
+ * @return css class name
+ */
+ public String getTagCssClass(Integer rank) {
+ int i = rank / RANK_LEVEL_STEP;
+ return TAG_CSS_CLASSSES[i];
+ }
+
+
+
+ /**
+ * Action listener for tag click
+ * @param event
+ */
+ public void processTagClick(ActionEvent event) {
+ // TODO: implement this
+ }
+
+}
Added:
trunk/test-applications/realworld/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
===================================================================
---
trunk/test-applications/realworld/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
(rev 0)
+++
trunk/test-applications/realworld/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml 2009-02-24
13:57:56 UTC (rev 12727)
@@ -0,0 +1,17 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:rich="http://richfaces.org/rich">
+ <a4j:outputPanel layout="block" style="width: 200px">
+ <h:form>
+ <c:forEach items="#{tagCloudBean.tags}" var="tag">
+ <a4j:commandLink value=" #{tag.key}"
+ actionListener="#{tagCloudBean.processTagClick(tag.key)}"
+ styleClass="#{tagCloudBean.getTagCssClass(tag.value)}"></a4j:commandLink>
+ </c:forEach>
+ </h:form>
+ </a4j:outputPanel>
+</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/template.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/stylesheet/realworld.css
===================================================================
---
trunk/test-applications/realworld/web/src/main/webapp/stylesheet/realworld.css 2009-02-24
13:37:54 UTC (rev 12726)
+++
trunk/test-applications/realworld/web/src/main/webapp/stylesheet/realworld.css 2009-02-24
13:57:56 UTC (rev 12727)
@@ -244,4 +244,52 @@
z-index: 3;
left: 50%;
top: 40px;
-}
\ No newline at end of file
+}
+
+.tag-cloud-rank {
+ text-decoration: none;
+}
+
+.tag-cloud-rank1 {
+ text-decoration: none;
+ font-size: 8px;
+ color: gray;
+}
+
+.tag-cloud-rank2 {
+ text-decoration: none;
+ font-size: 9px;
+ color: yellow;
+}
+
+.tag-cloud-rank3 {
+ text-decoration: none;
+ font-size: 10px;
+ color: blue;
+}
+
+.tag-cloud-rank4 {
+ text-decoration: none;
+ font-size: 11px;
+ color: green;
+}
+
+.tag-cloud-rank5 {
+ text-decoration: none;
+ font-size: 12px;
+ color: brown;
+}
+
+.tag-cloud-rank6 {
+ text-decoration: none;
+ font-size: 14px;
+ color: red;
+}
+
+.tag-cloud-rank7 {
+ text-decoration: none;
+ font-size: 18px;
+ color: black;
+}
+
+