Changeset 294


Ignore:
Timestamp:
09/04/08 17:07:39 (16 years ago)
Author:
ra33
Message:
 
Location:
trunk/src/org/expeditee
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Actions.java

    r286 r294  
    334334                command = command.substring(mname.length()).trim();
    335335                // If no params are provided get them from a text item on the cursor
    336                 if (command.length() == 0 && launcher instanceof Text) {
     336                if (command.length() == 0 && launcher instanceof Text && launcher.isFloating()) {
    337337                        command = launcher.getText();
    338338                }
     
    480480                                } else if (c.getParameterTypes().length == 0 && con == null) {
    481481                                        con = c;
     482                                        params = null;
    482483                                }
    483484                        }
  • trunk/src/org/expeditee/actions/Misc.java

    r284 r294  
    840840
    841841                current.addAllItems(newItems);
    842                 if(item instanceof Text){
    843                         for(Item i: item.getAllConnected()){
    844                                 if(i instanceof Line){
     842                if (item instanceof Text) {
     843                        for (Item i : item.getAllConnected()) {
     844                                if (i instanceof Line) {
    845845                                        item = i;
    846846                                        break;
     
    848848                        }
    849849                }
    850                
    851                 if (!(item instanceof Text)) {
    852                         d[0].setThickness(item.getThickness());
    853                         d[0].setFillColor(item.getFillColor());
     850
     851                Color newColor = item.getColor();
     852                if (newColor != null) {
    854853                        d[0].setColor(item.getColor());
     854                        if (item instanceof Text && item.getBackgroundColor() != null) {
     855                                d[0].setFillColor(item.getBackgroundColor());
     856                        }else{
     857                                d[0].setFillColor(item.getFillColor());
     858                        }
     859                }
     860                float newThickness = item.getThickness();
     861                if (newThickness > 0) {
     862                        d[0].setThickness(newThickness);
    855863                }
    856864
     
    860868                return d[0];
    861869        }
    862        
     870
    863871        public static void StopReminder() {
    864872                Reminders.stop();
  • trunk/src/org/expeditee/agents/Format.java

    r199 r294  
    3030
    3131        public Format() {
     32                super();
    3233        }
    3334
  • trunk/src/org/expeditee/agents/SearchAgent.java

    r292 r294  
    1212
    1313        private static final String DEFAULT_RESULTS_FRAMESET = "SearchResults";
    14        
     14
    1515        protected FrameCreator _results;
    1616
     
    1818
    1919        protected String _replacementString;
    20        
     20
    2121        protected String _startName;
    2222
     
    2424                _pattern = searchText;
    2525        }
    26        
     26
    2727        @Override
    2828        public boolean initialise(Frame frame, Item item) {
    2929                String pattern = item.getText();
    3030                String resultFrameset = null;
    31                
    32                 //TODO use a results frame specified on the profile frame
     31
     32                // TODO use a results frame specified on the profile frame
    3333                if (item.getLink() == null) {
    3434                        resultFrameset = DEFAULT_RESULTS_FRAMESET;
     
    3737                                        false);
    3838                }
    39                 return initialise(frame, item, frame.getFramesetName(), resultFrameset, null, pattern);
     39                return initialise(frame, item, frame.getFramesetName(), resultFrameset,
     40                                null, pattern);
    4041        }
    4142
    42         public boolean initialise(Frame frame, Item item, String startName, String resultsFrameset,
    43                         String replacementString, String pattern) {
    44                 _pattern = pattern.toLowerCase();
     43        /**
     44         *
     45         * @param frame
     46         * @param item
     47         * @param startName
     48         * @param resultsFrameset
     49         * @param replacementString
     50         * @param pattern
     51         *            is ignored if the pattern has already been set earlier.
     52         * @return
     53         */
     54        public boolean initialise(Frame frame, Item item, String startName,
     55                        String resultsFrameset, String replacementString, String pattern) {
     56                //TODO: Put the init params in the constructor!! Dont want to be setting _pattern in two places!
     57               
     58                if (_pattern == null)
     59                        _pattern = pattern.toLowerCase();
    4560                _replacementString = replacementString;
    4661                _startName = startName;
     
    4863                // Create a frame to put the results on with the search query
    4964                // and type as the title
    50                 String title = this.getClass().getSimpleName() + " [" + startName + "] [" + pattern
    51                                 + "]";
     65                String title = this.getClass().getSimpleName() + " [" + startName
     66                                + "] [" + _pattern + "]";
    5267                _results = new FrameCreator(resultsFrameset, null, title, false, true);
    5368                // Set the frame to be displayed after running the agent
    5469                _end = _results.getFirstFrame();
    55                
     70
    5671                return super.initialise(frame, item);
    5772        }
    58        
     73
    5974        public String getResultsFrameName() {
    6075                return _results.getName();
    6176        }
    62        
     77
    6378        public static boolean searchItem(Text itemToSearch, String pattern,
    6479                        String replacementString) {
     
    85100                        // Search for the item and add it to the results page if
    86101                        // it is found
    87                         if (searchItem(itemToSearch, pattern,
    88                                         replacementString)) {
     102                        if (searchItem(itemToSearch, pattern, replacementString)) {
    89103                                // Add a linked item to the results frame
    90104                                results.addText(frameName, null, frameName, null, false);
  • trunk/src/org/expeditee/gui/Frame.java

    r290 r294  
    207207
    208208                if (_change) {
    209                         // Notify the frame listeners that the frame has changed
    210                         for (FrameObserver fl : _observers) {
    211                                 fl.update();
    212                         }
     209                        notifyObservers();
    213210
    214211                        setBufferValid(false);
    215212                        _saved = false;
     213                }
     214        }
     215
     216        public void notifyObservers() {
     217                // Notify the frame listeners that the frame has changed
     218                for (FrameObserver fl : _observers) {
     219                        fl.update();
    216220                }
    217221        }
     
    501505                for (Overlay o : _overlays.keySet())
    502506                        results.addAll(o.Frame.getItemsWithin(poly));
    503                
    504                 for(Item i: getVectorItems()){
     507
     508                for (Item i : getVectorItems()) {
    505509                        if (i.intersects(poly)) {
    506                                 //This assumes a results is a set
     510                                // This assumes a results is a set
    507511                                results.add(i.getEditTarget());
    508512                        }
     
    703707                        InteractiveWidget iw = ((WidgetCorner) item).getWidgetSource();
    704708                        if (!this._iWidgets.contains(iw)) { // A set would have been
    705                                 if(FrameMouseActions.isControlDown())
     709                                if (FrameMouseActions.isControlDown())
    706710                                        _iWidgets.add(iw);
    707711                                else
     
    719723
    720724        public void refreshSize() {
    721                 //assert (size != null);
     725                // assert (size != null);
    722726                boolean bReparse = false;
    723727                for (Item i : getItems()) {
     
    737741                        }
    738742                }
    739                
    740                 //Do the anchors on the overlays
    741                 for(Overlay o: getOverlays()){
     743
     744                // Do the anchors on the overlays
     745                for (Overlay o : getOverlays()) {
    742746                        o.Frame.refreshSize();
    743747                }
    744                
     748
    745749                if (bReparse) {
    746750                        FrameUtils.Parse(this, false);
     
    10771081                        int index = toCheck.indexOf(from);
    10781082
    1079                         //If its the title index will be 0
     1083                        // If its the title index will be 0
    10801084                        if (index < 0)
    10811085                                index = 0;
     
    11111115                int maxY = 0;
    11121116                HighlightMode mode = toAdd.Source.getHighlightMode();
    1113                 if(mode != HighlightMode.None)
     1117                if (mode != HighlightMode.None)
    11141118                        mode = HighlightMode.Connected;
    11151119                Color highlightColor = toAdd.Source.getHighlightColor();
     
    11231127                        i.invalidateAll();
    11241128                        i.invalidateFill();
    1125                         //Get the right most x and bottom most y pos
     1129                        // Get the right most x and bottom most y pos
    11261130                        int itemRight = i.getX() + i.getBoundsWidth();
    1127                         if(itemRight > maxX)
     1131                        if (itemRight > maxX)
    11281132                                maxX = itemRight;
    11291133                        int itemBottom = i.getY() + i.getBoundsHeight();
    1130                         if(itemBottom > maxY)
     1134                        if (itemBottom > maxY)
    11311135                                maxY = itemBottom;
    11321136                }
     
    13091313                                        ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY,
    13101314                                        permission));
    1311                         //i.setPermission(permission);
     1315                        // i.setPermission(permission);
    13121316                        _overlayItems.add(i);
    13131317                }
     
    16901694                for (Overlay o : getOverlays())
    16911695                        o.Frame.refreshItemPermissions(o.permission);
    1692                
    1693                 //Only update the permissions if we have to
     1696
     1697                // Only update the permissions if we have to
    16941698                if (_body.size() > 0 && permission.equals(_body.get(0)._permission))
    16951699                        return;
     
    16981702                        i.setPermission(permission);
    16991703                }
    1700                
    17011704
    17021705        }
     
    19321935                        }
    19331936                }
    1934                
    1935                 for(Vector v: getVectors()){
     1937
     1938                for (Vector v : getVectors()) {
    19361939                        toSave.add(v.Source);
    19371940                }
    1938                
     1941
    19391942                return toSave;
    19401943        }
     
    20392042
    20402043        public void parse() {
    2041                 for(Overlay o: getOverlays()){
     2044                for (Overlay o : getOverlays()) {
    20422045                        o.Frame.parse();
    20432046                }
    2044                 //Must parse the frame AFTER the overlays
     2047                // Must parse the frame AFTER the overlays
    20452048                FrameUtils.Parse(this);
    20462049        }
  • trunk/src/org/expeditee/gui/FrameIO.java

    r286 r294  
    243243
    244244        public static boolean canAccessFrame(String frameName) {
     245                Frame current = DisplayIO.getCurrentFrame();
     246                //Just incase the current frame is not yet saved...
     247                if(frameName.equals(current.getName())){
     248                        FrameIO.SaveFrame(current,false,false);
     249                        current.change();
     250                        return true;
     251                }
     252               
    245253                for (String path : UserSettings.FrameDirs) {
    246254                        if (getFrameFullPathName(path, frameName) != null)
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r293 r294  
    638638                        break;
    639639                case KeyEvent.VK_TAB:
    640                         FrameUtils.getCurrentItem().update();
     640                        calculateItem(current);
    641641                        break;
    642642                case KeyEvent.VK_ESCAPE:
     
    10571057                                break;
    10581058                        case SizeDown:
    1059                                 if(isControlDown){
     1059                                if (isControlDown) {
    10601060                                        UserSettings.ScaleFactor -= 0.05;
    10611061                                        Misc.repaint();
     
    10631063                                }
    10641064                        case SizeUp:
    1065                                 if(isControlDown){
     1065                                if (isControlDown) {
    10661066                                        UserSettings.ScaleFactor += 0.05;
    10671067                                        Misc.repaint();
     
    10781078                        if (isShiftDown || isControlDown) {
    10791079                                if (on != null) {
    1080                                         on.update();
     1080                                        calculateItem(on);
    10811081                                }
    10821082                        }
     
    11321132        }
    11331133
     1134        private static void calculateItem(Item toCalculate) {
     1135                if (!toCalculate.update()) {
     1136                        toCalculate.setFormula(null);
     1137                        MessageBay.errorMessage("Can not calculate formula ["
     1138                                        + toCalculate.getText() + ']');
     1139                }
     1140        }
     1141
    11341142        private static void Save() {
    11351143                Frame current = DisplayIO.getCurrentFrame();
    11361144                current.change();
    1137                 FrameIO.SaveFrame(current,true, true);
     1145                FrameIO.SaveFrame(current, true, true);
    11381146        }
    11391147
     
    20882096        public static void Refresh() {
    20892097                Frame currentFrame = DisplayIO.getCurrentFrame();
     2098               
     2099                //Refresh widgets that use its self as a data source
     2100                currentFrame.notifyObservers();
     2101               
    20902102                if (FrameIO.isProfileFrame(currentFrame)) {
    20912103                        // TODO ensure that users can not delete the first frame in a
  • trunk/src/org/expeditee/items/Item.java

    r291 r294  
    26142614        }
    26152615
    2616         public void update() {
    2617                 calculate(getText());
     2616        public boolean update() {
     2617                return calculate(getText());
    26182618        }
    26192619
  • trunk/src/org/expeditee/items/widgets/DataFrameWidget.java

    r286 r294  
    88import javax.swing.JComponent;
    99
     10import org.expeditee.gui.DisplayIO;
    1011import org.expeditee.gui.Frame;
    1112import org.expeditee.gui.FrameIO;
     
    9697
    9798        public void update() {
     99                Frame parent = getParentFrame();
     100                if(parent != null && parent == DisplayIO.getCurrentFrame()){
     101                        refresh();
     102                }
     103               
    98104                _needsUpdating = true;
    99105        }
  • trunk/src/org/expeditee/items/widgets/InteractiveWidget.java

    r286 r294  
    15551555
    15561556                if (FrameIO.isPositiveInteger(link)) { // relative - convert to
    1557                                                                                                 // absolute
     1557                        // absolute
    15581558
    15591559                        // Get the frameset of this item
     
    15771577                return null;
    15781578        }
    1579        
    1580         /**
    1581          * Sets the border color for the widget.
    1582          * That is, for the source (so it is remembered) and also for all the
    1583          * corners/edges.
     1579
     1580        /**
     1581         * Sets the border color for the widget. That is, for the source (so it is
     1582         * remembered) and also for all the corners/edges.
    15841583         *
    15851584         * @param c
    1586          *              The color to set.
     1585         *            The color to set.
    15871586         */
    15881587        public void setWidgetEdgeColor(Color c) {
    1589                 for (Item i : _expediteeItems) i.setColor(c);
     1588                for (Item i : _expediteeItems)
     1589                        i.setColor(c);
    15901590                // Above indirectly invokes setSourceBorderColor accordingly
    15911591        }
    1592        
     1592
    15931593        /**
    15941594         * Sets the thickness of the widget edge.
     
    15971597         *
    15981598         * @param thickness
    1599          *              The new thickness to set.
     1599         *            The new thickness to set.
    16001600         */
    16011601        public void setWidgetEdgeThickness(float thickness) {
    1602                 for (Item i : _expediteeItems) i.setThickness(thickness);
    1603 //               Above indirectly invokes setSourceThickness accordingly
    1604         }
    1605 
    1606         // TODO: Maybe rename setSource* ..  to update* ... These should actually be friendly!
     1602                for (Item i : _expediteeItems)
     1603                        i.setThickness(thickness);
     1604                // Above indirectly invokes setSourceThickness accordingly
     1605        }
     1606
     1607        // TODO: Maybe rename setSource* .. to update* ... These should actually be
     1608        // friendly!
    16071609        public void setSourceColor(Color c) {
    16081610                _textRepresentation.setColor(c);
     
    16261628
    16271629        protected Point getOrigin() {
    1628                 return _d1.getPosition(); // BROOK: This flips around ... the origin can be any point
     1630                return _d1.getPosition(); // BROOK: This flips around ... the origin
     1631                // can be any point
    16291632        }
    16301633
     
    16321635                return _d1;
    16331636        }
     1637
     1638        public void setAnchorBottom(Float anchor) {
     1639                setPosition(getX(),
     1640                                Math.round(FrameGraphics.getMaxFrameSize().height - anchor - getHeight()));
     1641                getSource().setAnchorBottom(anchor);
     1642        }
     1643
     1644        public void setAnchorRight(Float anchor) {
     1645                setPosition(
     1646                                Math.round(FrameGraphics.getMaxFrameSize().width - anchor - getWidth()),
     1647                                getY());
     1648                getSource().setAnchorRight(anchor);
     1649        }
    16341650}
  • trunk/src/org/expeditee/items/widgets/WidgetCorner.java

    r279 r294  
    66import java.util.List;
    77
     8import org.expeditee.gui.FrameGraphics;
    89import org.expeditee.items.Dot;
    910import org.expeditee.items.ItemParentStateChangedEvent;
     
    1516        WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
    1617                super(x, y, id);
    17                
     18
    1819                if (widgetSource == null)
    1920                        throw new NullPointerException("widgetSource");
     
    5253        }
    5354
    54 //      @Override
    55 //      public void translate(Point2D origin, double ratio) {
    56 //              super.translate(origin, ratio);
    57 //      }
     55        // @Override
     56        // public void translate(Point2D origin, double ratio) {
     57        // super.translate(origin, ratio);
     58        // }
    5859
    5960        @Override
     
    142143        public void setSize(float size) {
    143144        }
    144        
     145
    145146        @Override
    146147        public String getLink() {
     
    149150
    150151        @Override
     152        public void setAnchorBottom(Float anchor) {
     153                _widgetSource.setAnchorBottom(anchor);
     154        }
     155
     156        @Override
     157        public void setAnchorRight(Float anchor) {
     158                _widgetSource.setAnchorRight(anchor);
     159        }
     160
     161        @Override
     162        public Float getAnchorBottom() {
     163                return _widgetSource.getSource().getAnchorBottom();
     164        }
     165
     166        @Override
     167        public Float getAnchorRight() {
     168                return _widgetSource.getSource().getAnchorRight();
     169        }
     170
     171        @Override
    151172        public void setLink(String link) {
    152173                _widgetSource.setLink(link);
    153174        }
    154        
     175
     176        @Override
     177        public void setFormula(String formula) {
     178        }
     179
    155180        @Override
    156181        public void setData(List<String> data) {
     
    160185        @Override
    161186        public boolean contains(int x, int y) {
    162                 return super.contains(x, y) && !_widgetSource.getBounds().contains(x, y);
     187                return super.contains(x, y)
     188                                && !_widgetSource.getBounds().contains(x, y);
    163189        }
    164190
     
    167193                if (_widgetSource != null) {
    168194                        float minThickness = _widgetSource.getMinimumBorderThickness();
    169                         if(newThickness < minThickness)
     195                        if (newThickness < minThickness)
    170196                                newThickness = minThickness;
    171197                        super.setThickness(newThickness, setConnected);
  • trunk/src/org/expeditee/items/widgets/WidgetEdge.java

    r279 r294  
    9898       
    9999        @Override
     100        public void setFormula(String formula) {
     101        }
     102       
     103        @Override
     104        public void setAnchorBottom(Float anchor) {
     105                _widgetSource.setAnchorBottom(anchor);
     106        }
     107
     108        @Override
     109        public void setAnchorRight(Float anchor) {
     110                _widgetSource.setAnchorRight(anchor);
     111        }
     112       
     113        @Override
     114        public Float getAnchorBottom() {
     115                return _widgetSource.getSource().getAnchorBottom();
     116        }
     117       
     118        @Override
     119        public Float getAnchorRight() {
     120                return _widgetSource.getSource().getAnchorRight();
     121        }
     122       
     123        @Override
    100124        public boolean contains(int x, int y) {
    101125                return super.contains(x, y) && !_widgetSource.getBounds().contains(x, y);
  • trunk/src/org/expeditee/items/widgets/charts/AbstractPie.java

    r279 r294  
    6060                for (Text t : dataFrame.getBodyTextItems(false)) {
    6161                        // Ignore line ends for pie charts
    62                         if (t.isLineEnd())
     62                        //TODO find out HOW text became null when i was doing a graph!!
     63                        String text = t.getText();
     64                        if (t.isLineEnd() || text == null)
    6365                                continue;
    64                         AttributeValuePair avp = new AttributeValuePair(t.getText());
     66                        AttributeValuePair avp = new AttributeValuePair(text);
    6567                        if (avp != null) {
    6668                                try {
Note: See TracChangeset for help on using the changeset viewer.