Author: andrei_exadel
Date: 2009-02-27 14:17:11 -0500 (Fri, 27 Feb 2009)
New Revision: 12778
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/layout/template3.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
Log:
Tag cloud
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-02-27
19:17:11 UTC (rev 12778)
@@ -0,0 +1,68 @@
+/**
+ *
+ */
+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;;
+
+
+
+ /**
+ * 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/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml 2009-02-27
19:17:11 UTC (rev 12778)
@@ -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="#{tagList.tagMap}" 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/realworld2/web/src/main/webapp/layout/template3.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-02-27
18:42:35 UTC (rev 12777)
+++
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-02-27
19:17:11 UTC (rev 12778)
@@ -244,4 +244,47 @@
z-index: 3;
left: 50%;
top: 40px;
-}
\ No newline at end of file
+}
+
+.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;
+}
+