19 package org.turro.skills;
22 import java.util.stream.Collectors;
23 import org.turro.skills.tags.SkillItem;
24 import org.turro.skills.tags.SkillSet;
25 import org.turro.skills.tags.SkillTags;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zk.ui.ext.AfterCompose;
29 import org.zkoss.zul.Div;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Separator;
37 public class SkillPanel extends Div implements AfterCompose {
39 private String entityRoot;
41 private Div allSkills;
44 allSkills =
new Div();
45 appendChild(allSkills);
46 appendChild(
new Separator(
"horizontal"));
54 this.entityRoot = entityRoot;
67 private void drawSkills(
long maxUsage) {
68 allSkills.getChildren().clear();
70 final Label label =
new Label(skill.getSkillName());
71 String font = skill.isSelected() ?
"bold" :
"normal";
72 String color = skill.isSelected() ?
"#333" :
"#156dc6";
73 label.setStyle(
"cursor:pointer;font-size:" + (
int) (11 +
74 (5 * (
double)((
double)skill.getUsage() / (
double)maxUsage))) +
75 "px;font-weight:" + font +
";color:" + color);
76 label.setAttribute(
"tag", skill);
77 label.addEventListener(Events.ON_CLICK, (Event event) -> {
78 SkillItem skill1 = (SkillItem) label.getAttribute(
"tag");
79 skill1.setSelected(!skill1.isSelected());
80 Events.postEvent(new Event(Events.ON_CHANGE, SkillPanel.this));
84 Set.of(skill.getSkillName())).stream().map(t -> t.getSkillName())
85 .collect(Collectors.joining(
", ")));
86 allSkills.appendChild(label);
87 allSkills.appendChild(
new Separator(
"vertical"));
Set< SkillItem > getSelected()
void setEntityRoot(String entityRoot)