Ignore:
Timestamp:
01/07/14 12:26:01 (10 years ago)
Author:
jts21
Message:

Implement tooltips

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Item.java

    r655 r656  
    157157
    158158        protected boolean _filled = true;
     159       
     160        private String _tooltip = null;
     161        private Text _tooltipItem = null;
    159162
    160163        public static void DuplicateItem(Item source, Item dest) {
     
    174177                dest.setBorderColor(source.getBorderColor());
    175178
     179                dest.setTooltip(source.getTooltip());
    176180                dest.setData(source.getData());
    177181                dest.setTag(source.getTag());
     
    11221126         */
    11231127        public abstract void paint(Graphics2D g);
    1124 
     1128       
     1129        public void setTooltip(String tooltip) {
     1130                _tooltip = tooltip;
     1131                _tooltipItem = null;
     1132        }
     1133       
     1134        public String getTooltip() {
     1135                return _tooltip;
     1136        }
     1137       
     1138        public void paintTooltip(Graphics2D g) {
     1139                // don't try to show an empty tooltip
     1140                if(_tooltipItem == null) {
     1141                        if(_tooltip != null && _tooltip.trim().length() != 0) {
     1142                                _tooltipItem = (Text) getParentOrCurrentFrame().getStatsTextItem(_tooltip);
     1143                                _tooltipItem.setWidth(300);
     1144                        } else {
     1145                                return;
     1146                        }
     1147                }
     1148                Rectangle bounds = getPolygon().getBounds();
     1149                _tooltipItem.invalidateAll();
     1150                int x = bounds.x + bounds.width;
     1151                if(x + _tooltipItem.getPolygon().getBounds().width > FrameGraphics.getMaxFrameSize().width) {
     1152                        x = bounds.x - _tooltipItem.getPolygon().getBounds().width;
     1153                }
     1154                int y = bounds.y + bounds.height;
     1155                if(y + _tooltipItem.getPolygon().getBounds().height > FrameGraphics.getMaxFrameSize().height) {
     1156                        y = bounds.y - _tooltipItem.getPolygon().getBounds().height;
     1157                }
     1158                _tooltipItem.setPosition(x, y);
     1159                _tooltipItem.paint(g);
     1160        }
     1161       
    11251162        public void paintFill(Graphics2D g) {
    11261163                Color fillColor = getFillColor();
Note: See TracChangeset for help on using the changeset viewer.