19 package org.turro.tags;
22 import java.util.stream.Collectors;
23 import org.zkoss.zk.ui.event.Event;
24 import org.zkoss.zk.ui.event.Events;
25 import org.zkoss.zk.ui.ext.AfterCompose;
26 import org.zkoss.zul.Div;
27 import org.zkoss.zul.Label;
28 import org.zkoss.zul.Separator;
34 public class TagPanel extends Div implements AfterCompose {
36 private String entityRoot;
43 appendChild(
new Separator(
"horizontal"));
51 this.entityRoot = entityRoot;
64 private void drawTags(
long maxUsage) {
65 allTags.getChildren().clear();
67 final Label label =
new Label(tag.getTagName());
68 String font = tag.isSelected() ?
"bold" :
"normal";
69 String color = tag.isSelected() ?
"#333" :
"#156dc6";
70 label.setStyle(
"cursor:pointer;font-size:" + (
int) (11 +
71 (5 * (
double)((
double)tag.getUsage() / (
double)maxUsage))) +
72 "px;font-weight:" + font +
";color:" + color);
73 label.setAttribute(
"tag", tag);
74 label.addEventListener(Events.ON_CLICK, (Event event) -> {
75 TagItem tag1 = (TagItem) label.getAttribute(
"tag");
76 tag1.setSelected(!tag1.isSelected());
77 Events.postEvent(new Event(Events.ON_CHANGE, TagPanel.this));
81 Set.of(tag.getTagName())).stream().map(t -> t.getTagName())
82 .collect(Collectors.joining(
", ")));
83 allTags.appendChild(label);
84 allTags.appendChild(
new Separator(
"vertical"));