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