Changeset 940


Ignore:
Timestamp:
12/09/14 14:54:14 (9 years ago)
Author:
bln4
Message:

Continued work on update to tooltips to be actual items so that data can be stored.

Location:
trunk/src/org/expeditee
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameCreator.java

    r919 r940  
    2020
    2121import java.awt.Color;
     22import java.util.*;
    2223
    2324import org.expeditee.agents.ExistingFramesetException;
    2425import org.expeditee.items.Item;
    25 import org.expeditee.items.PermissionPair;
    2626import org.expeditee.items.Text;
    27 import org.expeditee.items.UserAppliedPermission;
    2827
    2928public class FrameCreator {
     
    5756
    5857        private boolean _multiColumn;
     58       
     59        private final List<Frame> framesCreated = new LinkedList<Frame>();
    5960
    6061        public FrameCreator(String frameTitle) {
     
    124125                if (toUse == null) {
    125126                        toUse = FrameIO.CreateFrame(name, frameTitle, null);
     127                        this.framesCreated.add(toUse);
    126128                }
    127129
     
    149151                                        _current.getTitle(), null);
    150152
     153                        this.framesCreated.add(newFrame);
     154                       
    151155                        // add link to previous frame
    152156                        // _prev =
     
    168172                        return false;
    169173                }
     174        }
     175       
     176        public List<Frame> getFramesCreated() {
     177                return this.framesCreated;
    170178        }
    171179
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r919 r940  
    541541                        if(current != null) {
    542542                                current.paintTooltip(bg);
    543                         } else {
    544                                 Item.clearTooltipOwner();
    545                         }
     543                        } //else {
     544//                              Item.clearTooltipOwner();
     545//                      }
     546                        if(previous != null) previous.clearTooltips();
     547                        previous = current;
    546548                }
    547549
     
    550552                        PaintNonLinesNonPicture(bg, FreeItems.getCursor());
    551553        }
     554       
     555        private static Item previous = null;
    552556
    553557        // creates a new line so that lines are shown correctly when spanning
  • trunk/src/org/expeditee/items/Item.java

    r919 r940  
    4646import org.expeditee.actions.Misc;
    4747import org.expeditee.actions.Simple;
    48 import org.expeditee.gui.AttributeUtils;
    4948import org.expeditee.gui.AttributeValuePair;
    5049import org.expeditee.gui.DisplayIO;
     
    164163        protected boolean _filled = true;
    165164       
    166         private List<String> _tooltip = null;
    167         private static Text _tooltipItem = null;
    168         private static Item _tooltipOwner = null;
     165        private Tooltip _tooltip = new Tooltip();
    169166
    170167        public enum AnchorEdgeType {
     
    11581155        public abstract void paint(Graphics2D g);
    11591156       
    1160         public void setTooltips(List<String> tooltips) {
    1161                 if (tooltips == null || tooltips.size() == 0) {
    1162                         _tooltip = null;
    1163                 } else {
    1164                         _tooltip = new LinkedList<String>(tooltips);
    1165                 }
    1166         }
    1167        
    1168         public void setTooltip(String tooltip) {
    1169                 if(_tooltip == null || _tooltip.size() == 0) {
    1170                         _tooltip = new LinkedList<String>();
    1171                 }
     1157        public void setTooltips(final List<String> tooltips) {
     1158                if(tooltips == null || tooltips.size() == 0) _tooltip = new Tooltip();
     1159                else for(final String content: tooltips) _tooltip.addTooltip(content);
     1160        }
     1161       
     1162        public void setTooltip(final String tooltip) {
    11721163                if(tooltip != null && tooltip.trim().length() > 0) {
    1173                         _tooltip.add(tooltip);
     1164                        _tooltip.addTooltip(tooltip);
    11741165                }
    11751166        }
    11761167       
    11771168        public List<String> getTooltip() {
    1178                 return _tooltip;
    1179         }
    1180        
    1181         public static void clearTooltipOwner() {
    1182                 _tooltipOwner = null;
    1183         }
    1184        
    1185         public void paintTooltip(Graphics2D g) {
    1186                 if(_tooltipOwner != this) {
    1187                         _tooltipItem = null;
    1188                         _tooltipOwner = this;
    1189                 }
    1190                 // generate tooltip item
    1191                 if(_tooltipItem == null) {
    1192                         if(_tooltip != null && _tooltip.size() > 0) {
    1193                                 StringBuffer tooltip = new StringBuffer();
    1194                                 for(String t : _tooltip) {
    1195                                         tooltip.append(t).append("\n");
    1196                                 }
    1197                                 if(tooltip.length() > 0) {
    1198                                         tooltip.deleteCharAt(tooltip.length() - 1);
    1199                                 }
    1200                                 _tooltipItem = (Text) getParentOrCurrentFrame().getTooltipTextItem("");
    1201                                 for(String s : _tooltip) {
    1202                                         // set text
    1203                                         if(s.trim().toLowerCase().startsWith("text") && s.contains(":")) {
    1204                                                 _tooltipItem.appendLine(s.substring(s.indexOf(':') + 1).trim());
    1205                                         } else {
    1206                                                 AttributeUtils.setAttribute(_tooltipItem, new Text(s));
    1207                                         }
    1208                                 }
    1209                         } else {
    1210                                 return;
    1211                         }
    1212                 }
    1213                 Rectangle bounds = getPolygon().getBounds();
    1214                 _tooltipItem.invalidateAll();
     1169                return _tooltip.asStringList();
     1170        }
     1171       
     1172        public List<Text> getTooltipItems() {
     1173                return _tooltip.getTooltips();
     1174        }
     1175
     1176        public void clearTooltips() {
     1177                final Frame frame = this.getParent();
     1178                for(final Text tooltip: _tooltip.getTooltips()) frame.removeItem(tooltip);
     1179        }
     1180       
     1181        public void paintTooltip(final Graphics2D g) {
     1182                final Rectangle bounds = this.getPolygon().getBounds();
    12151183                int x = bounds.x + bounds.width;
    1216                 if(x + _tooltipItem.getPolygon().getBounds().width > FrameGraphics.getMaxFrameSize().width) {
    1217                         x -= x + _tooltipItem.getPolygon().getBounds().width - FrameGraphics.getMaxFrameSize().width;
    1218                 }
    1219                 int y = bounds.y + bounds.height + bounds.height / 2;
    1220                 if(y + _tooltipItem.getPolygon().getBounds().height > FrameGraphics.getMaxFrameSize().height) {
    1221                         y = bounds.y + bounds.height / 2 - _tooltipItem.getPolygon().getBounds().height;
    1222                 }
    1223                 _tooltipItem.setPosition(x, y);
    1224                 _tooltipItem.paint(g);
     1184                if(x + _tooltip.getWidth() > FrameGraphics.getMaxFrameSize().width) {
     1185                        x -= x + _tooltip.getWidth() - FrameGraphics.getMaxFrameSize().width;
     1186                }
     1187                int y = bounds.y + bounds.height;
     1188                if(y + _tooltip.getCollectiveHeight() > FrameGraphics.getMaxFrameSize().height) {
     1189                        y = bounds.y + bounds.height / 2 - _tooltip.getCollectiveHeight();
     1190                }
     1191                for(final Text tooltip : _tooltip.getTooltips()) {
     1192                        this.getParent().addItem(tooltip);
     1193                        tooltip.setPosition(x, y);
     1194                        tooltip.paint(g);
     1195                        y += tooltip.getHeight();
     1196                }
    12251197        }
    12261198       
Note: See TracChangeset for help on using the changeset viewer.