source: trunk/src/org/expeditee/items/Tooltip.java@ 977

Last change on this file since 977 was 977, checked in by bln4, 8 years ago

Updates to how Next and LastItem magnetic constraint actions work; so as to deal with close items.

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1package org.expeditee.items;
2
3import java.util.Collection;
4import java.util.HashMap;
5import java.util.LinkedList;
6import java.util.List;
7import java.util.Map;
8
9import org.expeditee.settings.templates.TemplateSettings;
10
11public class Tooltip {
12
13 Tooltip() { }
14
15 private Map<Text, Item> tooltipItems = new HashMap<Text, Item>();
16
17 public Text addTooltip(String content, final Item toItem) {
18 if(content.trim().toLowerCase().startsWith("text") && content.contains(":"))
19 content = content.substring(content.indexOf(':') + 1);
20 final Text tooltip = TemplateSettings.TooltipTemplate.get().copy();
21 tooltip.setText(content);
22 return addTooltip(tooltip, toItem);
23 }
24
25 public Text addTooltip(final Text tooltip, final Item toItem) {
26 tooltipItems.put(tooltip, toItem);
27 return tooltip;
28 }
29
30 public Collection<Text> getTooltips() { return tooltipItems.keySet(); }
31
32 public List<String> asStringList() {
33 final List<String> ret = new LinkedList<String>();
34 for(final Text tooltip: tooltipItems.keySet()) ret.add(tooltip.getText());
35 return ret;
36 }
37
38 public int getWidth() {
39 int max = 0;
40 for(final Text tooltip: tooltipItems.keySet())
41 if(tooltip.getBoundsWidth() > max) max = tooltip.getBoundsWidth();
42 return max;
43 }
44
45 public int getHeight() {
46 int max = 0;
47 for(final Text tooltip: tooltipItems.keySet())
48 if(tooltip.getBoundsWidth() > max) max = tooltip.getBoundsHeight();
49 return max;
50 }
51
52 public int getCollectiveHeight() {
53 int height = 0;
54 for(final Text tooltip: tooltipItems.keySet()) height += tooltip.getBoundsHeight();
55 return height;
56 }
57}
Note: See TracBrowser for help on using the repository browser.