Last change
on this file since 938 was 938, checked in by bln4, 9 years ago |
Initial cut at a Tooltip class that stores Text Items inside it
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | package org.expeditee.items;
|
---|
2 |
|
---|
3 | import java.util.*;
|
---|
4 |
|
---|
5 | public class Tooltip {
|
---|
6 |
|
---|
7 | private List<Text> tooltipItems = new LinkedList<Text>();
|
---|
8 |
|
---|
9 | public Text addTooltip(String content) {
|
---|
10 | if(content.trim().toLowerCase().startsWith("text") && content.contains(":"))
|
---|
11 | content = content.substring(content.indexOf(':') + 1);
|
---|
12 | final Text tooltip = new Text(content);
|
---|
13 | return addTooltip((Text) tooltip.getParentOrCurrentFrame().getTooltipTextItem(content));
|
---|
14 | }
|
---|
15 |
|
---|
16 | public Text addTooltip(final Text tooltip) {
|
---|
17 | tooltipItems.add(tooltip);
|
---|
18 | return tooltip;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public List<Text> getTooltips() { return tooltipItems; }
|
---|
22 |
|
---|
23 | public List<String> asStringList() {
|
---|
24 | final List<String> ret = new LinkedList<String>();
|
---|
25 | for(final Text tooltip: tooltipItems) ret.add(tooltip.getText());
|
---|
26 | return ret;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public int getWidth() {
|
---|
30 | int max = 0;
|
---|
31 | for(final Text tooltip: tooltipItems) if(tooltip.getBoundsWidth() > max) max = tooltip.getBoundsWidth();
|
---|
32 | return max;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public int getHeight() {
|
---|
36 | int max = 0;
|
---|
37 | for(final Text tooltip: tooltipItems) if(tooltip.getBoundsWidth() > max) max = tooltip.getBoundsHeight();
|
---|
38 | return max;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public int getCollectiveHeight() {
|
---|
42 | int height = 0;
|
---|
43 | for(final Text tooltip: tooltipItems) height += tooltip.getBoundsHeight();
|
---|
44 | return height;
|
---|
45 | }
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.