Changeset 376


Ignore:
Timestamp:
11/02/08 13:05:01 (16 years ago)
Author:
ra33
Message:
 
Location:
trunk/src/org/expeditee
Files:
7 added
40 edited
1 copied
3 moved

Legend:

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

    r313 r376  
    721721                int ind = 0;
    722722
    723                 // if the first class in the list is a frame or item, it is the source
    724                 // or launcher
    725                 // length must be at least one if we are still running
     723                /*
     724                 * if the first class in the list is a frame or item, it is the source
     725                 * or launcher length must be at least one if we are still running
     726                 */
    726727                if (paramTypes[ind] == Frame.class) {
    727728                        objects[ind] = source;
     
    886887                        return PerformAction(current, launcher, command);
    887888                } catch (RuntimeException e) {
     889                        e.printStackTrace();
    888890                        MessageBay.errorMessage("Action failed: " + e.getMessage());
    889891                } catch (Exception e) {
     892                        e.printStackTrace();
    890893                        MessageBay.errorMessage("Action failed: "
    891894                                        + e.getClass().getSimpleName());
  • trunk/src/org/expeditee/actions/Misc.java

    r362 r376  
    1717import javax.imageio.ImageIO;
    1818
    19 import org.expeditee.agents.wordprocessing.JSpellChecker;
     19import org.expeditee.gui.AttributeUtils;
    2020import org.expeditee.gui.Browser;
    2121import org.expeditee.gui.DisplayIO;
     
    3535import org.expeditee.simple.SString;
    3636import org.expeditee.stats.CometStats;
    37 import org.expeditee.stats.DocumentStats;
     37import org.expeditee.stats.DocumentStatsFast;
    3838import org.expeditee.stats.SessionStats;
    3939import org.expeditee.stats.StatsLogger;
     
    274274
    275275        }
    276        
     276
    277277        public static String GetDocumentStats(Frame frame) {
    278278                TimeKeeper timer = new TimeKeeper();
    279279                MessageBay.displayMessage("Computing document stats...");
    280 
    281                 DocumentStats docStats = new DocumentStats(frame);
     280                FrameIO.ForceSaveFrame(frame);
     281                DocumentStatsFast docStats = new DocumentStatsFast(frame.getName(),
     282                                frame.getTitle());
    282283                String result = docStats.toString();
    283                
     284
    284285                MessageBay.overwriteMessage("Document stats time: "
    285286                                + timer.getElapsedStringSeconds());
     
    436437         * PNGFrame(currentFrame.getName())
    437438         */
    438         public static void PNGFrame() {
    439                 ImageFrame(DisplayIO.getCurrentFrame().getName(), "PNG");
     439        public static void PNGFrame(Frame frame) {
     440                ImageFrame(frame.getName(), "PNG");
    440441        }
    441442
    442443        public static String SaveImage(BufferedImage screen, String format,
    443444                        String directory, String fileName) {
     445                String suffix = "." + format.toLowerCase();
     446                String shortFileName = fileName;
    444447                // Check if we need to append the suffix
    445448                if (fileName.indexOf('.') < 0)
    446                         fileName += "." + format.toLowerCase();
     449                        fileName += suffix;
     450                else
     451                        shortFileName = fileName.substring(0, fileName.length() - suffix.length());
    447452
    448453                try {
     454                        int count = 2;
    449455                        // set up the file for output
    450                         String fullFileName = directory + fileName;
    451                         File out = new File(fullFileName);
     456                        File out = new File(directory + fileName);
     457                        while (out.exists()) {
     458                                fileName = shortFileName + "_" + count++ + suffix;
     459                                out = new File(directory + fileName);
     460                        }
     461
    452462                        if (!out.getParentFile().exists())
    453463                                out.mkdirs();
     
    910920        }
    911921
    912         public static String checkSpelling(String word) {
    913                 try {
    914                         return JSpellChecker.getInstance().getSuggestions(word);
    915                 } catch (FileNotFoundException e) {
    916                         MessageBay.errorMessage("Could not find dictionary: "
    917                                         + e.getMessage());
    918                 } catch (IOException e) {
    919                         // TODO Auto-generated catch block
    920                         e.printStackTrace();
    921                 }
    922                 return null;
    923         }
    924        
    925         public static String spellCheck(String word) {
    926                 return checkSpelling(word);
    927         }
    928        
    929922        public static int wordCount(String paragraph) {
    930923                return paragraph.trim().split("\\s+").length + 1;
    931924        }
    932        
     925
    933926        public static int wordCount(Frame frame) {
    934927                int count = 0;
    935                
    936                 for(Text t: frame.getBodyTextItems(false)){
     928
     929                for (Text t : frame.getBodyTextItems(false)) {
    937930                        count += wordCount(t.getText());
    938931                }
    939                
     932
    940933                return count;
    941934        }
    942        
    943         public static void moveToPublic(Frame frame){
     935
     936        public static void moveToPublic(Frame frame) {
    944937                FrameIO.moveFrameset(frame.getFramesetName(), FrameIO.PUBLIC_PATH);
    945938        }
    946        
    947         public static void moveToPrivate(Frame frame){
     939
     940        public static void moveToPrivate(Frame frame) {
    948941                FrameIO.moveFrameset(frame.getFramesetName(), FrameIO.FRAME_PATH);
    949942        }
     943
     944        /**
     945         * Returns the value of a specified item attribute.
     946         *
     947         * @param item
     948         *            from which to extract the value
     949         * @param attribute
     950         *            name of an items attribute
     951         * @return the value of the attribute
     952         */
     953        public static String extract(Item item, String attribute) {
     954                return AttributeUtils.getAttribute(item, attribute);
     955        }
    950956}
  • trunk/src/org/expeditee/actions/Simple.java

    r362 r376  
    2020import org.expeditee.agents.DisplayTree;
    2121import org.expeditee.agents.SearchAgent;
     22import org.expeditee.agents.SearchFramesetAndReplace;
    2223import org.expeditee.agents.SearchFrameset;
    23 import org.expeditee.agents.SearchFramesetFast;
     24import org.expeditee.agents.SearchTreeAndReplace;
    2425import org.expeditee.agents.SearchTree;
    25 import org.expeditee.agents.SearchTreeFast;
    2626import org.expeditee.agents.WriteTree;
    2727import org.expeditee.gui.AttributeUtils;
     
    328328                        boolean acceptKeyboardInput, boolean step, int pause, Color color) {
    329329                try {
    330                         DisplayIO.addToBack(current.getParent());
     330                        if (current != null) {
     331                                DisplayIO.addToBack(current.getParent());
     332                        } else {
     333                                /*TODO we should not have to pass an item just to run a frame!*/
     334                                current = new Text("Dummy");
     335                                current.setLink(frame.getName());
     336                        }
    331337
    332338                        _stepColor = color == null ? Color.green : color;
     
    339345
    340346                        // an item without a link signals to run the current frame
    341                         if (current.getLink() == null) {
     347                        if (current != null && current.getLink() == null) {
    342348                                // Make a copy but hide it
    343349                                current = current.copy();
     
    351357                        t.start();
    352358                } catch (Exception e) {
     359                        e.printStackTrace();
    353360                }
    354361        }
     
    932939                                // The fast search does not do replacement
    933940                                if (bReplace) {
     941                                        searchAgent = new SearchFramesetAndReplace(firstFrame,
     942                                                        maxFrame, null);
     943                                } else {
    934944                                        searchAgent = new SearchFrameset(firstFrame, maxFrame, null);
    935                                 } else {
    936                                         searchAgent = new SearchFramesetFast(firstFrame, maxFrame, null);
    937945                                }
    938946                                searchAgent.initialise(null, null, frameset, resultsFrameset,
     
    975983                                // now The fast search does not do replacement
    976984                                if (bReplace) {
     985                                        searchAgent = new SearchTreeAndReplace(null);
     986                                } else {
    977987                                        searchAgent = new SearchTree(null);
    978                                 } else {
    979                                         searchAgent = new SearchTreeFast(null);
    980988                                }
    981989                                _agent = searchAgent;
     
    16751683                        String s = getMessage(tokens, context, code.toString(), tokens[0]
    16761684                                        .equals("type") ? " " : "", 1);
    1677                        
     1685
    16781686                        DisplayIO.typeStringDirect(0.025, s);
    16791687                } else if (tokens[0].equals("runstring")) {
     
    20312039                                } catch (Exception e) {
    20322040                                }
    2033                         }else{
    2034                                 Frame zero = FrameIO.LoadFrame(freshCopy.getFramesetName() + "0");
     2041                        } else {
     2042                                Frame zero = FrameIO.LoadFrame(freshCopy.getFramesetName()
     2043                                                + "0");
    20352044                                freshCopy.setPath(zero.getPath());
    20362045                        }
  • trunk/src/org/expeditee/agents/Format.java

    r307 r376  
    55import java.util.Collections;
    66import java.util.Comparator;
     7import java.util.HashSet;
    78import java.util.List;
    89
     
    4546        @Override
    4647        public Frame process(Frame start) {
    47                 //TODO What will happen if user runs the SIMPLE form of this...
    48                 //Does format box need to be disabled?!?!
    49                 //Check the position of the cursor and only format stuff inside the same box as the cursor
     48                // TODO What will happen if user runs the SIMPLE form of this...
     49                // Does format box need to be disabled?!?!
     50                // Check the position of the cursor and only format stuff inside the
     51                // same box as the cursor
    5052                Collection<Text> itemsToFormat = FrameUtils.getCurrentTextItems();
    51                 if(itemsToFormat.size() < 1){
     53
     54                // If the cursor is not inside a box...
     55                if (itemsToFormat.size() < 1) {
     56                        // Add all the items that are in free space
    5257                        itemsToFormat = start.getBodyTextItems(true);
     58                        // Remove all the enclosed items
     59                        Collection<Item> seen = new HashSet<Item>();
     60                        for (Item i : start.getVisibleItems()) {
     61                                if (!seen.contains(i) && i.isEnclosed()) {
     62                                        seen.addAll(i.getEnclosingDots());
     63                                        itemsToFormat.removeAll(i.getEnclosedItems());
     64                                }
     65                        }
    5366                }
    54                
     67
    5568                ArrayList<Item> columnHeads = new ArrayList<Item>();
    5669
     
    175188                        overwriteMessage("Formatting complete.");
    176189        }
    177        
     190
    178191        @Override
    179192        protected void message(String message) {
  • trunk/src/org/expeditee/agents/SearchAgent.java

    r362 r376  
    11package org.expeditee.agents;
     2
     3import java.util.Collection;
    24
    35import org.expeditee.gui.Frame;
     
    2426
    2527        public SearchAgent(String searchText) {
    26                 _pattern = searchText.toLowerCase();
     28                if (searchText != null)
     29                        _pattern = searchText.toLowerCase();
    2730        }
    2831
     
    3942                                        false);
    4043                }
    41                 return initialise(frame, item, frame.getFramesetName(), resultFrameset,
     44                return initialise(frame, item, getSearchDescription(frame), resultFrameset,
    4245                                null, pattern);
     46        }
     47
     48        /**
     49         * @param frame
     50         * @return
     51         */
     52        protected String getSearchDescription(Frame frame) {
     53                return frame.getFramesetName();
    4354        }
    4455
     
    5667        public boolean initialise(Frame frame, Item item, String startName,
    5768                        String resultsFrameset, String replacementString, String pattern) {
    58                 //TODO: Put the init params in the constructor!! Dont want to be setting _pattern in two places!
    59                
     69                // TODO: Put the init params in the constructor!! Dont want to be
     70                // setting _pattern in two places!
     71
    6072                if (_pattern == null)
    6173                        _pattern = pattern.toLowerCase();
     
    6678                // and type as the title
    6779                String title = this.getClass().getSimpleName() + " [" + startName
    68                                 + "] [" + _pattern + "]";
    69                 _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title, false, true);
     80                                + "]"+getResultsTitleSuffix();
     81                _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title,
     82                                false, true);
    7083                // Set the frame to be displayed after running the agent
    7184                _end = _results.getFirstFrame();
    7285
    7386                return super.initialise(frame, item);
     87        }
     88
     89        protected String getResultsTitleSuffix() {
     90                return " [" + _pattern + "]";
    7491        }
    7592
     
    111128                return true;
    112129        }
     130       
     131        protected int addResults(String frameName, Collection<String> found) {
     132                return addResults(frameName, frameName, found);
     133        }
     134       
     135        /**
     136         * @param frameNumber
     137         * @param frameName
     138         * @param found
     139         * @return
     140         */
     141        protected int addResults(String frameNumber, String frameName, Collection<String> found) {
     142                int size = found == null ? 0 : found.size();
     143                // If the frame exists
     144                if (found != null)
     145                        _frameCount++;
     146                if (size > 0) {
     147                        // String repeats = size > 1? ("("+ size+ ")") : "";
     148                        for (String s : found) {
     149                                StringBuffer surrogate = new StringBuffer();
     150                                surrogate.append("[").append(frameNumber).append("] ");
     151                                if (s.length() > SearchAgent.SURROGATE_LENGTH)
     152                                        surrogate.append(
     153                                                        s.substring(0, SearchAgent.SURROGATE_LENGTH - 3))
     154                                                        .append("...");
     155                                else {
     156                                        surrogate.append(s);
     157                                }
     158
     159                                _results.addText(surrogate.toString(), null,
     160                                                frameName, null, false);
     161                                FrameGraphics.requestRefresh(true);
     162                        }
     163                }
     164                return size;
     165        }
    113166}
  • trunk/src/org/expeditee/agents/SearchFrameset.java

    r362 r376  
    44
    55import org.expeditee.gui.Frame;
    6 import org.expeditee.gui.FrameGraphics;
    76import org.expeditee.gui.FrameIO;
    87
    9 public class SearchFramesetFast extends SearchAgent {
     8public class SearchFrameset extends SearchAgent {
    109        private long _firstFrame = 1;
    1110
    1211        private long _maxFrame = Integer.MAX_VALUE;
    1312
    14         public SearchFramesetFast(long firstFrame, long maxFrame, String searchText) {
     13        public SearchFrameset(long firstFrame, long maxFrame, String searchText) {
    1514                this(searchText);
    1615                _firstFrame = firstFrame;
     
    1817        }
    1918
    20         public SearchFramesetFast(String searchText) {
     19        public SearchFrameset(String searchText) {
    2120                super(searchText);
    2221        }
     
    3837                        Collection<String> found = FrameIO.searchFrame(frameName, _pattern,
    3938                                        path);
    40                         int size = found == null ? 0 : found.size();
    41                         // If the frame exists
    42                         if (found != null)
    43                                 _frameCount++;
    44                         if (size > 0) {
    45                                 // String repeats = size > 1? ("("+ size+ ")") : "";
    46                                 for (String s : found) {
    47                                         StringBuffer surrogate = new StringBuffer();
    48                                         surrogate.append("[").append(i).append("] ");
    49                                         if (s.length() > SearchAgent.SURROGATE_LENGTH)
    50                                                 surrogate.append(
    51                                                                 s.substring(0, SearchAgent.SURROGATE_LENGTH - 3))
    52                                                                 .append("...");
    53                                         else {
    54                                                 surrogate.append(s);
    55                                         }
    56 
    57                                         _results.addText(surrogate.toString(), null,
    58                                                         frameName, null, false);
    59                                         FrameGraphics.requestRefresh(true);
    60                                 }
    61                         }
     39                        addResults(i + "", frameName, found);
    6240                }
    6341                _results.save();
  • trunk/src/org/expeditee/agents/SearchGreenstone.java

    r336 r376  
    11package org.expeditee.agents;
    22
    3 import java.util.Enumeration;
    43import java.util.HashMap;
    54import java.util.Map;
     
    3029        protected static Greenstone3Connection _gsdl = null;
    3130
     31        public static Greenstone3Connection getConnection() {
     32                return _gsdl;
     33        }
     34
    3235        private static String _maxResults = "10";
    3336
     
    8487        }
    8588
     89        public SearchGreenstone(int resultsCount) {
     90                this(null);
     91                _thisMaxResults = resultsCount + "";
     92        }
     93
    8694        public SearchGreenstone() {
    8795                super(null);
     
    113121                        else if (attribute.equals("autoconnect"))
    114122                                connect();
    115 
    116123                        else if (attribute.equals("maxresults")) {
    117124                                try {
     
    119126                                } catch (Exception e) {
    120127                                }
    121                         }
    122 
    123                         else if (attribute.equals("dostemming"))
     128                        } else if (attribute.equals("dostemming"))
    124129                                _doStemming = true;
    125130                        else if (attribute.startsWith("showabstract"))
     
    139144        }
    140145
     146        protected String getResultsTitle() {
     147                return this.getClass().getSimpleName() + "[" + getCursorText() + "]";
     148        }
     149
    141150        @Override
    142151        protected Frame process(Frame frame) {
    143                 String resultsTitle = this.getClass().getSimpleName() + "["
    144                                 + _fullCaseSearchQuery + "]";
     152                String resultsTitle = getResultsTitle();
    145153                _results.setTitle(resultsTitle);
    146154
     
    150158                } else if (_currentResultSet != null) {
    151159                        Text newText = DisplayIO.getCurrentFrame().createNewText(
    152                                         _fullCaseSearchQuery);
     160                                        getCursorText());
    153161                        _clicked = newText;
    154162                        FrameMouseActions.pickup(newText);
    155163                }
    156164
    157                 if (_currentResultSet == null) {
    158                         MessageBay.errorMessage("Could not find Greenstone query text");
     165                if (_currentResultSet == null || _currentResultSet.size() == 0) {
     166                        MessageBay.errorMessage(getNoResultsMessage());
    159167                        return null;
    160168                }
     
    171179
    172180                return _results.getFirstFrame();
     181        }
     182
     183        protected String getNoResultsMessage() {
     184                return "Could not find Greenstone query text";
     185        }
     186
     187        /**
     188         * @return
     189         */
     190        protected String getCursorText() {
     191                return _fullCaseSearchQuery;
    173192        }
    174193
     
    189208                Query query = createQuery(queryText);
    190209                QueryOutcome queryOutcome = _gsdl.issueQueryToServer(query);
    191                 _currentResultSet = getResultSetMetadata(queryOutcome);
     210                if (queryOutcome != null)
     211                        _currentResultSet = getResultSetMetadata(queryOutcome);
    192212        }
    193213
     
    281301
    282302                if (rd.metadataExists("Title")) {
    283                         resultText.append("title = " + rd.getTitle()).append('\n');
     303                        resultText.append("title: " + rd.getTitle()).append('\n');
    284304                }
    285305                if (rd.metadataExists("Date")) {
    286                         resultText.append("date = " + rd.getDate()).append('\n');
     306                        resultText.append("date: " + rd.getDate()).append('\n');
    287307                }
    288308                if (rd.metadataExists("Booktitle")) {
    289                         resultText.append("booktitle = " + rd.getBooktitle()).append('\n');
     309                        resultText.append("booktitle: " + rd.getBooktitle()).append('\n');
    290310                }
    291311                if (rd.metadataExists("Pages")) {
    292                         resultText.append("pages = " + rd.getPages()).append('\n');
     312                        resultText.append("pages: " + rd.getPages()).append('\n');
    293313                }
    294314                if (rd.metadataExists("Journal")) {
    295                         resultText.append("journal = " + rd.getJournal()).append('\n');
     315                        resultText.append("journal: " + rd.getJournal()).append('\n');
    296316                }
    297317                if (rd.metadataExists("Volume")) {
    298                         resultText.append("volume = " + rd.getVolume()).append('\n');
     318                        resultText.append("volume: " + rd.getVolume()).append('\n');
    299319                }
    300320                if (rd.metadataExists("Number")) {
    301                         resultText.append("number = " + rd.getNumber()).append('\n');
     321                        resultText.append("number: " + rd.getNumber()).append('\n');
    302322                }
    303323                if (rd.metadataExists("Editor")) {
    304                         resultText.append("editor = " + rd.getEditor()).append('\n');
     324                        resultText.append("editor: " + rd.getEditor()).append('\n');
    305325                }
    306326                if (rd.metadataExists("Publisher")) {
    307                         resultText.append("publisher = " + rd.getPublisher()).append('\n');
     327                        resultText.append("publisher: " + rd.getPublisher()).append('\n');
    308328                }
    309329                if (rd.metadataExists("Abstract")) {
    310                         resultText.append("abstract = " + rd.getAbstract()).append('\n');
    311                 }
    312                 Vector<String> authors = rd.getAuthors();
    313                 for (Enumeration a = authors.elements(); a.hasMoreElements();) {
    314                         String author = (String) a.nextElement();
    315                         resultText.append("author = " + author).append('\n');
    316                 }
    317                 Vector<String> keywords = rd.getKeywords();
    318                 for (Enumeration k = keywords.elements(); k.hasMoreElements();) {
    319                         String keyword = (String) k.nextElement();
    320                         resultText.append("keyword = " + keyword).append('\n');
    321                 }
     330                        resultText.append("abstract: " + rd.getAbstract()).append('\n');
     331                }
     332                for (String author : rd.getAuthors()) {
     333                        resultText.append("author: " + author).append('\n');
     334                }
     335
     336                for (String keyword : rd.getKeywords()) {
     337                        resultText.append("keyword: " + keyword).append('\n');
     338                }
     339
    322340                resultText.deleteCharAt(resultText.length() - 1);
    323341
     
    356374        }
    357375
     376        public static void clearSession() {
     377                getConnection().getSessionResults().clear();
     378                _currentResultSet = null;
     379        }
     380
    358381}
  • trunk/src/org/expeditee/agents/SearchTree.java

    r362 r376  
    1111import java.util.Map;
    1212
     13import org.expeditee.gui.AttributeValuePair;
    1314import org.expeditee.gui.Frame;
    14 import org.expeditee.gui.FrameGraphics;
    1515import org.expeditee.gui.FrameIO;
    1616import org.expeditee.gui.UserSettings;
    1717import org.expeditee.io.Conversion;
    1818
    19 public class SearchTreeFast extends SearchAgent {
     19public class SearchTree extends SearchAgent {
    2020        private Map<String, Collection<String>> _searchResults = new HashMap<String, Collection<String>>();
    2121
    22         public SearchTreeFast(String searchText) {
     22        public SearchTree(String searchText) {
    2323                super(searchText);
    2424        }
    25        
     25
    2626        @Override
    2727        protected Frame process(Frame frame) {
    28                 if(frame == null)
     28                if (frame == null)
    2929                        frame = FrameIO.LoadFrame(_startName);
    30                
    31                 searchTree(frame.getName(), _pattern, _searchResults, new HashSet<String>());
    32                
     30
     31                searchTree(frame.getName(), _searchResults, new HashSet<String>());
    3332                _results.save();
    3433
     
    3635                if (_clicked != null)
    3736                        _clicked.setLink(resultFrameName);
    38                
     37
    3938                return _results.getFirstFrame();
    4039        }
    41        
     40
     41        @Override
     42        /**
     43         * @param frame
     44         * @return
     45         */
     46        protected String getSearchDescription(Frame frame) {
     47                return frame.getName();
     48        }
     49
    4250        /**
    4351         * Returns a list of the frames searched and any matches on those frames.
    44          * @param frameName the name of the top not in the tree of frames to search
    45          * @param pattern the pattern to search for
    46          * @param results a list of frames on which matches were found and the text that matched the pattern
    47          * @param visited a list of the frames that were visited in the searchTree
     52         *
     53         * @param frameName
     54         *            the name of the top not in the tree of frames to search
     55         * @param pattern
     56         *            the pattern to search for
     57         * @param results
     58         *            a list of frames on which matches were found and the text that
     59         *            matched the pattern
     60         * @param visited
     61         *            a list of the frames that were visited in the searchTree
    4862         */
    49         public void searchTree(String frameName, String pattern, Map<String, Collection<String>> results, Collection<String> visited) {
    50                 //Check if this node has already been visited
    51                 if(visited.contains(frameName))
     63        public void searchTree(String frameName,
     64                        Map<String, Collection<String>> results, Collection<String> visited) {
     65                // Check if this node has already been visited
     66                if (visited.contains(frameName))
    5267                        return;
    53                
     68
    5469                visited.add(frameName);
    55                
     70
    5671                String fullPath = null;
    5772                for (String possiblePath : UserSettings.FrameDirs) {
     
    6479                if (fullPath == null)
    6580                        return;
    66                
     81
    6782                _frameCount++;
    6883                overwriteMessage("Searching " + frameName);
    69                
     84
    7085                String frameset = Conversion.getFramesetName(frameName);
    71                
     86
    7287                Collection<String> frameResults = new LinkedList<String>();
    7388                // Open the file and search the text items
     
    7590                        BufferedReader reader = new BufferedReader(new FileReader(fullPath));
    7691                        String next;
     92                        StringBuffer sb = new StringBuffer();
     93                        String link = null;
     94                        boolean ignore = false;
     95
    7796                        while (reader.ready() && ((next = reader.readLine()) != null)) {
    78                                 if (next.startsWith("T")) {
    79                                         String toSearch = next.substring(2);
    80                                         if (toSearch.toLowerCase().contains(pattern))
    81                                                 frameResults.add(toSearch);
    82                                 }else if (next.startsWith("F")) {
    83                                         String link = next.substring(2);
    84                                         if(!FrameIO.isValidFrameName(link))
     97
     98                                if (next.length() == 0) {
     99                                        // Ignore annotations
     100                                        if (ignore) {
     101                                                ignore = false;
     102                                                link = null;
     103                                                continue;
     104                                        }
     105
     106                                        // Ignore non text items
     107                                        if (sb.length() == 0) {
     108                                                link = null;
     109                                                continue;
     110                                        }
     111
     112                                        String toSearch = sb.substring(0, sb.length() - 1);
     113                                        String resultSurrogate = getResultSurrogate(toSearch);
     114                                        if (resultSurrogate != null) {
     115                                                frameResults.add(resultSurrogate);
     116                                        }
     117
     118                                        if (link != null) {
     119                                                searchTree(link, results, visited);
     120                                        }
     121
     122                                        // Reinit the item variables
     123                                        link = null;
     124                                        sb = new StringBuffer();
     125
     126                                } else if (ignore) {
     127                                        continue;
     128                                } else if (next.startsWith("T")) {
     129                                        String text = next.substring(2).trim();
     130                                        // Ignore the rest of annotation items...
     131                                        if (text.length() > 0
     132                                                        && text.charAt(0) == AttributeValuePair.ANNOTATION_CHAR) {
     133                                                ignore = true;
     134                                                continue;
     135                                        }
     136                                        sb.append(text).append('\n');
     137                                } else if (next.startsWith("F")) {
     138                                        link = next.substring(2);
     139                                        // Convert number only links
     140                                        if (Character.isDigit(link.charAt(0)))
    85141                                                link = frameset + link;
    86                                         searchTree(link, pattern, results, visited);
    87142                                }
    88143                        }
    89                         //Only add the results if a match was found on the frame
    90                         if(frameResults.size() > 0){
     144                        // Only add the results if a match was found on the frame
     145                        if (frameResults.size() > 0) {
    91146                                results.put(frameName, frameResults);
    92147                        }
     
    97152                }
    98153                int size = frameResults.size();
    99                 if(size > 0){
    100                         String repeats = size > 1? ("("+ size+ ")") : "";
    101                         _results.addText(frameName + repeats, null, frameName, null, false);
    102                         FrameGraphics.requestRefresh(true);
     154                if (size > 0) {
     155                        addResults(frameName, frameResults);
     156
     157                        // String repeats = size > 1 ? ("(" + size + ")") : "";
     158                        // _results.addText(frameName + repeats, null, frameName, null,
     159                        // false);
     160                        // FrameGraphics.requestRefresh(true);
    103161                }
    104162        }
     163
     164        protected String getResultSurrogate(String toSearch) {
     165                if (toSearch.toLowerCase().contains(_pattern))
     166                        return toSearch;
     167                return null;
     168        }
    105169}
  • trunk/src/org/expeditee/agents/wordprocessing/JSpellChecker.java

    r362 r376  
    11package org.expeditee.agents.wordprocessing;
    22
     3import java.awt.Color;
    34import java.io.File;
    45import java.io.FileNotFoundException;
     
    89import java.util.List;
    910
     11import org.expeditee.gui.Frame;
    1012import org.expeditee.gui.FrameIO;
     13import org.expeditee.gui.MessageBay;
     14import org.expeditee.items.Text;
    1115
    1216import com.swabunga.spell.engine.Configuration;
     
    5963        public static JSpellChecker _theInstance = null;
    6064
    61         public static JSpellChecker getInstance() throws FileNotFoundException, IOException {
     65        public static JSpellChecker getInstance() throws FileNotFoundException,
     66                        IOException {
    6267                if (_theInstance == null) {
    6368                        create();
     
    6671        }
    6772
     73        public static void create(Frame frame) throws FileNotFoundException,
     74                        IOException {
     75                if(_theInstance == null)
     76                        _theInstance = new JSpellChecker();
     77                _theInstance.init();
     78
     79                if (frame != null) {
     80                        for (Text t : frame.getBodyTextItems(false)) {
     81                                for (String s : t.getText().split(" ")) {
     82                                        _theInstance.checker.addToDictionary(s);
     83                                }
     84                        }
     85                }
     86        }
     87
    6888        public static void create() throws FileNotFoundException, IOException {
    69                 _theInstance = new JSpellChecker();
    70                 _theInstance.init();
    71         }
    72 
    73         public static String dictFile = FrameIO.PARENT_FOLDER + "dict/english.0";
     89                create(null);
     90        }
     91
     92        public static String dictDirectory = FrameIO.PARENT_FOLDER + "dict/";
    7493
    7594        public JSpellChecker() {
     
    7998        public void init() throws FileNotFoundException, IOException {
    8099                log(this.hashCode() + ": JSpellChecker.init");
     100                MessageBay.displayMessage("Loading spell checker...");
    81101
    82102                checker = new SpellChecker();
    83 
    84                 checker.addDictionary(new SpellDictionaryHashMap(new File(dictFile)));
     103                SpellDictionaryHashMap dictionaryHashMap = new SpellDictionaryHashMap();
     104
     105                for (File dict : new File(dictDirectory).listFiles()) {
     106                        dictionaryHashMap.addDictionary(dict);
     107                }
     108
     109                checker.addDictionary(dictionaryHashMap);
    85110
    86111                initialized = true;
     112
     113                MessageBay.displayMessage("Spell checker Loaded", Color.green.darker());
    87114        }
    88115
     
    97124                checker.addSpellCheckListener(listener);
    98125                checker.reset();
     126                event = null;
    99127        }
    100128
     
    137165
    138166                }
    139                
    140                 if(s.length() == 0){
     167
     168                if (s.length() == 0) {
    141169                        return "No suggestions";
    142170                }
     
    146174                // + "|";
    147175                // }
    148                 return s.substring(0, s.length()-1);
     176                return s.substring(0, s.length() - 1);
    149177        }
    150178
  • trunk/src/org/expeditee/greenstone/Greenstone3Connection.java

    r352 r376  
    1717import java.util.Set;
    1818
    19 //import org.apache.xerces.parsers.DOMParser;
     19import org.apache.xerces.parsers.DOMParser;
    2020import org.w3c.dom.Document;
    2121import org.w3c.dom.NamedNodeMap;
     
    5353         * keys. All the results returned in this session.
    5454         */
    55         private Map allResults;
     55        private Map<String, ResultDocument> allResults;
    5656
    5757        /**
     
    156156                }
    157157                this.queryList = Collections.synchronizedList(new ArrayList());
    158                 this.allResults = Collections.synchronizedMap(new HashMap());
     158                this.allResults = Collections
     159                                .synchronizedMap(new HashMap<String, ResultDocument>());
    159160                this.allKeywords = Collections.synchronizedMap(new HashMap());
    160161                this.allAuthors = Collections.synchronizedMap(new HashMap());
     
    164165        }
    165166
    166         public Map getSessionResults() {
     167        public Map<String, ResultDocument> getSessionResults() {
    167168                return this.allResults;
    168169        };
     
    270271                while (iter.hasNext()) {
    271272                        String docID = (String) iter.next();
    272                         ResultDocument resultDocument = (ResultDocument) allResults
    273                                         .get(docID);
     273                        ResultDocument resultDocument = allResults.get(docID);
    274274                        System.out.println("____________" + docID + " ___________");
    275275                        System.out.println(resultDocument.toString());
     
    286286                while (iter.hasNext()) {
    287287                        String docID = (String) iter.next();
    288                         ResultDocument resultDocument = (ResultDocument) allResults
    289                                         .get(docID);
     288                        ResultDocument resultDocument = allResults.get(docID);
    290289                        System.out.println(docID + "\t" + resultDocument.getTitle());
    291290                }
     
    305304         */
    306305        public ResultDocument getDocument(String docID) {
    307                 return (ResultDocument) allResults.get(docID);
     306                return allResults.get(docID);
    308307        }
    309308
     
    425424                StringReader sr = new StringReader(result);
    426425                InputSource is = new InputSource(sr);
    427                
    428                
    429                
    430                
    431                
    432                
    433                
    434                
    435                
    436                
    437                 return null;
    438                
    439 //              DOMParser p = new DOMParser();
    440 //
    441 //              try {
    442 //                      p.parse(is);
    443 //              } catch (SAXException se) {
    444 //                      System.err.println(se);
    445 //              } catch (IOException ioe) {
    446 //                      System.err.println(ioe);
    447 //              }
    448 //              Document d = p.getDocument();
    449 //              NodeList metadataList = d.getElementsByTagName("metadata");
    450 //              for (int i = 0; i < metadataList.getLength(); i++) {
    451 //                      Node n = metadataList.item(i);
    452 //                      NamedNodeMap nnm = n.getAttributes();
    453 //                      Node att = nnm.getNamedItem("name");
    454 //                      if (att.getNodeValue().compareTo("numDocsMatched") == 0) {
    455 //                              queryOutcome.setHowManyDocsMatched(n.getFirstChild()
    456 //                                              .getNodeValue());
    457 //                      } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) {
    458 //                              queryOutcome.setHowManyDocsReturned(n.getFirstChild()
    459 //                                              .getNodeValue());
    460 //                      }
    461 //              }
    462 //
    463 //              NodeList documentList = d.getElementsByTagName("documentNode");
    464 //              for (int i = 0; i < documentList.getLength(); i++) {
    465 //                      Node n = documentList.item(i);
    466 //                      NamedNodeMap nnm = n.getAttributes();
    467 //                      Node nid = nnm.getNamedItem("nodeID");
    468 //                      Node nscore = nnm.getNamedItem("rank");
    469 //                      String docID = nid.getFirstChild().getNodeValue();
    470 //                      queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild()
    471 //                                      .getNodeValue());
    472 //              }
    473 //              query.addQueryOutcome(queryOutcome);
    474 //              Query q = (Query) query.clone();
    475 //              queryList.add(q);
    476 //
    477 //              for (int i = 0; i < documentList.getLength(); i++) {
    478 //                      Node n = documentList.item(i);
    479 //                      NamedNodeMap nnm = n.getAttributes();
    480 //                      Node nid = nnm.getNamedItem("nodeID");
    481 //                      Node nscore = nnm.getNamedItem("rank");
    482 //                      String docID = nid.getFirstChild().getNodeValue();
    483 //
    484 //                      QueryContext queryContext = new QueryContext(firstDoc + i, nscore
    485 //                                      .getFirstChild().getNodeValue(), q);
    486 //                      if (allResults.containsKey(docID)) {
    487 //                              ResultDocument resultDocument = (ResultDocument) allResults
    488 //                                              .get(docID);
    489 //                              resultDocument.incrementFrequencyReturned();
    490 //                              resultDocument.addQueryContext(queryContext);
    491 //                              allResults.put(docID, resultDocument);
    492 //                      } else {
    493 //                              ResultDocument resultDocument = new ResultDocument();
    494 //                              resultDocument.addQueryContext(queryContext);
    495 //                              allResults.put(docID, resultDocument);
    496 //                      }
    497 //              }
    498 //              return queryOutcome;
     426
     427                DOMParser p = new DOMParser();
     428                try {
     429                        p.parse(is);
     430                } catch (SAXException se) {
     431                        System.err.println(se);
     432                } catch (IOException ioe) {
     433                        System.err.println(ioe);
     434                }
     435                Document d = p.getDocument();
     436                NodeList metadataList = d.getElementsByTagName("metadata");
     437                for (int i = 0; i < metadataList.getLength(); i++) {
     438                        Node n = metadataList.item(i);
     439                        NamedNodeMap nnm = n.getAttributes();
     440                        Node att = nnm.getNamedItem("name");
     441                        if (att.getNodeValue().compareTo("numDocsMatched") == 0) {
     442                                queryOutcome.setHowManyDocsMatched(n.getFirstChild()
     443                                                .getNodeValue());
     444                        } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) {
     445                                queryOutcome.setHowManyDocsReturned(n.getFirstChild()
     446                                                .getNodeValue());
     447                        }
     448                }
     449
     450                NodeList documentList = d.getElementsByTagName("documentNode");
     451                for (int i = 0; i < documentList.getLength(); i++) {
     452                        Node n = documentList.item(i);
     453                        NamedNodeMap nnm = n.getAttributes();
     454                        Node nid = nnm.getNamedItem("nodeID");
     455                        Node nscore = nnm.getNamedItem("rank");
     456                        String docID = nid.getFirstChild().getNodeValue();
     457                        queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild()
     458                                        .getNodeValue());
     459                }
     460                query.addQueryOutcome(queryOutcome);
     461                Query q = (Query) query.clone();
     462                queryList.add(q);
     463
     464                for (int i = 0; i < documentList.getLength(); i++) {
     465                        Node n = documentList.item(i);
     466                        NamedNodeMap nnm = n.getAttributes();
     467                        Node nid = nnm.getNamedItem("nodeID");
     468                        Node nscore = nnm.getNamedItem("rank");
     469                        String docID = nid.getFirstChild().getNodeValue();
     470
     471                        QueryContext queryContext = new QueryContext(firstDoc + i, nscore
     472                                        .getFirstChild().getNodeValue(), q);
     473                        if (allResults.containsKey(docID)) {
     474                                ResultDocument resultDocument = allResults.get(docID);
     475                                resultDocument.incrementFrequencyReturned();
     476                                resultDocument.addQueryContext(queryContext);
     477                                allResults.put(docID, resultDocument);
     478                        } else {
     479                                ResultDocument resultDocument = new ResultDocument();
     480                                resultDocument.addQueryContext(queryContext);
     481                                allResults.put(docID, resultDocument);
     482                        }
     483                }
     484                return queryOutcome;
    499485        }
    500486
     
    545531         */
    546532        public void getDocumentMetadataFromServer(String docID, String metadata) {
    547                 ResultDocument resultDocument = (ResultDocument) allResults.get(docID);
     533                ResultDocument resultDocument = allResults.get(docID);
    548534                if (resultDocument.metadataExists(metadata)) {
    549535                        return;
     
    566552                StringReader sr = new StringReader(result);
    567553                InputSource is = new InputSource(sr);
    568                 //DOMParser p = new DOMParser();
    569         /*      try {
    570                         //p.parse(is);
     554                DOMParser p = new DOMParser();
     555                try {
     556                        p.parse(is);
    571557                } catch (SAXException se) {
    572558                        System.err.println(se);
    573559                } catch (IOException ioe) {
    574560                        System.err.println(ioe);
    575                 }*/
    576                 //Document d = p.getDocument();
    577                 Document d = null;
     561                }
     562                Document d = p.getDocument();
    578563                NodeList metadataList = d.getElementsByTagName("metadata");
    579564                String metadataval = null;
     
    609594                                        String s = authors[i] + ", " + authors[i + 1];
    610595
    611                                         //Handle names with jr. in them
     596                                        // Handle names with jr. in them
    612597                                        if (containsExtraName) {
    613598                                                if (i + 2 < authors.length
     
    703688                StringReader sr = new StringReader(result);
    704689                InputSource is = new InputSource(sr);
    705 //              DOMParser p = new DOMParser();
    706 //              try {
    707 //                      p.parse(is);
    708 //              } catch (SAXException se) {
    709 //                      System.err.println(se);
    710 //              } catch (IOException ioe) {
    711 //                      System.err.println(ioe);
    712 //              }
     690                DOMParser p = new DOMParser();
     691                try {
     692                        p.parse(is);
     693                } catch (SAXException se) {
     694                        System.err.println(se);
     695                } catch (IOException ioe) {
     696                        System.err.println(ioe);
     697                }
    713698
    714699                String returnName = null;
    715700
    716                 //Document d = p.getDocument();
    717                 Document d = null;
     701                Document d = p.getDocument();
     702                // Document d = null;
    718703                NodeList metadataList = d.getElementsByTagName("metadata");
    719704                for (int i = 0; i < metadataList.getLength(); i++) {
     
    750735                StringReader sr = new StringReader(result);
    751736                InputSource is = new InputSource(sr);
    752 //              DOMParser p = new DOMParser();
    753 //              try {
    754 //                      p.parse(is);
    755 //              } catch (SAXException se) {
    756 //                      System.err.println(se);
    757 //              } catch (IOException ioe) {
    758 //                      System.err.println(ioe);
    759 //              }
    760 //              Document d = p.getDocument();
    761                 Document d = null;
     737                DOMParser p = new DOMParser();
     738                try {
     739                        p.parse(is);
     740                } catch (SAXException se) {
     741                        System.err.println(se);
     742                } catch (IOException ioe) {
     743                        System.err.println(ioe);
     744                }
     745                Document d = p.getDocument();
     746
    762747                NodeList childList = d.getElementsByTagName("classifierNode");
    763748                NodeList documentList = d.getElementsByTagName("documentNode");
  • trunk/src/org/expeditee/greenstone/ResultDocument.java

    r313 r376  
    3535
    3636        private Set<String> retrievedMetadata;
     37
     38        private double sessionScore;
    3739
    3840        public ResultDocument() {
     
    5052                publisher = null;
    5153                frequencyReturned = 1;
     54                sessionScore = 0;
    5255                queryContexts = new Vector<QueryContext>();
    5356                retrievedMetadata = new HashSet<String>();
     
    158161                this.retrievedMetadata.add("Publisher");
    159162        }
     163       
     164        public double getSessionScore() {
     165                return this.sessionScore;
     166        }
     167        public void setSessionScore(double s) {
     168                this.sessionScore  = s;
     169        }
    160170
    161171        public void incrementFrequencyReturned() {
     
    165175        public void addQueryContext(QueryContext queryContext) {
    166176                this.queryContexts.addElement(queryContext);
     177                if (this.frequencyReturned == 1)
     178                        this.sessionScore = Double.parseDouble(queryContext.getScore());
    167179        }
    168180
     
    170182                return authors;
    171183        }
     184       
     185        public Vector<String> getAuthor() {
     186                return getAuthors();
     187        }
    172188
    173189        public Vector<String> getKeywords() {
    174190                return keywords;
    175191        }
     192       
     193        public Vector<String> getKeyword() {
     194                return getKeywords();
     195        }
    176196
    177197        public String getTitle() {
     
    218238                return frequencyReturned;
    219239        }
    220 
    221         public Vector getQueryContexts() {
     240       
     241        public Vector<QueryContext> getQueryContexts() {
    222242                return this.queryContexts;
    223243        }
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r348 r376  
    171171
    172172                        _SetMethods.put("p", Item.class.getMethod("setPosition", pPoint));
     173                        _SetMethods.put("xy", Item.class.getMethod("setPosition", pPoint));
    173174                        _SetMethods.put("pos", Item.class.getMethod("setPosition", pPoint));
    174175                        _SetMethods.put("thickness", Item.class.getMethod("setThickness",
     
    209210                                        "setGradientColor", pColor));
    210211
    211                         _SetMethods.put("ga", Item.class.getMethod("setGradientAngle",
    212                                         pInt));
     212                        _SetMethods.put("ga", Item.class
     213                                        .getMethod("setGradientAngle", pInt));
    213214                        _SetMethods.put("gradientangle", Item.class.getMethod(
    214215                                        "setGradientAngle", pInt));
     
    272273                        _SetMethods.put("s", Item.class.getMethod("setSize", pFloat));
    273274
     275                        // TODO have a separate map for item and frame methods.
     276                        // This will remove the need for p0 etc
    274277                        _SetMethods.put("foregroundcolor", Frame.class.getMethod(
    275278                                        "setForegroundColor", pColor));
     
    282285                        _SetMethods.put("permission", Frame.class.getMethod(
    283286                                        "setPermission", pPermission));
     287                        _SetMethods.put("p0", Frame.class.getMethod("setPermission",
     288                                        pPermission));
    284289
    285290                } catch (SecurityException e) {
     
    321326                        if (m.getDeclaringClass().isAssignableFrom(toExtract.getClass())) {
    322327                                try {
    323                                         Object o = m.invoke(toExtract, (Object[]) null);
    324 
    325                                         if (o == null) {
    326                                                 // methods that return null are only included if they
    327                                                 // are in the AllowNull list
    328                                                 if (_AllowNull.contains(m)) {
    329                                                         String name = m.getName().substring(GET_LENGTH)
    330                                                                         .toLowerCase();
    331                                                         if (name.equals("color"))
    332                                                                 o = "default";
    333                                                         else if (name.equals("backgroundcolor"))
    334                                                                 o = "transparent";
    335                                                         else if (name.equals("foregroundcolor"))
    336                                                                 o = "auto";
    337                                                         else
    338                                                                 o = "";
    339                                                 } else {
    340                                                         continue;
    341                                                 }
    342                                         }
    343                                         // skip methods that are in the ignore lists
    344                                         if (_ExtractIgnore.contains(m.getName().substring(
    345                                                         GET_LENGTH).toLowerCase())) {
     328                                        String s = getValue(m, toExtract, true);
     329
     330                                        if (s == null)
    346331                                                continue;
    347                                         }
    348 
    349                                         if (o instanceof Integer) {
    350                                                 Integer i = (Integer) o;
    351                                                 if (i == Item.DEFAULT_INTEGER)
    352                                                         continue;
    353                                                 if (m.getName().endsWith("Justification")
    354                                                                 && ((Justification) o).toString() != null)
    355                                                         o = ((Justification) o).toString();
    356                                                 // -1 indicates default value
    357                                                 else
    358                                                         o = i;
    359                                         } else if (o instanceof Float) {
    360                                                 if (((Float) o) < -0.0001)
    361                                                         continue;
    362                                                 // Null indicates default
    363                                                 o = Math.round((Float) o);
    364                                         } else if (o instanceof Double) {
    365                                                 // -1 indicates default value
    366                                                 if (((Double) o) < 0.0001)
    367                                                         continue;
    368                                         } else if (o instanceof Color) {
    369                                                 // converts the color to the Expeditee code
    370                                                 o = Conversion.getExpediteeColorCode((Color) o);
    371                                                 if (o == null)
    372                                                         continue;
    373                                         } else if (o instanceof Point) {
    374                                                 Point p = (Point) o;
    375                                                 o = Math.round(p.getX()) + " " + Math.round(p.getY());
    376                                         } else if (o instanceof Font) {
    377                                                 Font f = (Font) o;
    378 
    379                                                 String s = f.getName() + "-";
    380                                                 if (f.isPlain())
    381                                                         s += "Plain";
    382 
    383                                                 if (f.isBold())
    384                                                         s += "Bold";
    385 
    386                                                 if (f.isItalic())
    387                                                         s += "Italic";
    388 
    389                                                 s += "-" + f.getSize();
    390                                                 o = s;
    391                                         } else if (o instanceof Text) {
    392                                                 o = ((Text) o).getFirstLine();
    393                                         } else if (o instanceof List) {
    394                                                 List list = (List) o;
    395                                                 for (Object ob : list)
    396                                                         attributes
    397                                                                         .append(m.getName().substring(GET_LENGTH))
    398                                                                         .append(AttributeValuePair.SEPARATOR_STRING)
    399                                                                         .append(ob).append('\n');
    400                                                 continue;
    401                                         } else if (o instanceof int[]) {
    402                                                 StringBuffer sb = new StringBuffer();
    403                                                 int[] values = (int[]) o;
    404                                                 for (int i = 0; i < values.length; i++) {
    405                                                         sb.append(values[i]).append(' ');
    406                                                 }
    407                                                 sb.deleteCharAt(sb.length() - 1);
    408                                                 o = sb.toString();
    409                                         } else if (o instanceof Boolean) {
    410                                                 // true is the default for boolean values
    411                                                 if (((Boolean) o).booleanValue())
    412                                                         continue;
    413                                         }
    414332                                        // Append the attributes
    415333                                        attributes.append(m.getName().substring(GET_LENGTH))
    416334                                                        .append(AttributeValuePair.SEPARATOR_STRING)
    417                                                         .append(o).append('\n');
     335                                                        .append(s).append('\n');
    418336                                } catch (Exception e) {
    419337                                        // TODO Auto-generated catch block
     
    434352                Item attribs = current.getStatsTextItem(attributes.toString());
    435353                return attribs;
     354        }
     355
     356        /**
     357         * Gets a string form of the value for a given item get method.
     358         * @param method
     359         * @param item
     360         * @param ignore true if the attributes in the IGNORE list should be ignored
     361         * @return
     362         */
     363        private static String getValue(Method method, Object item, boolean ignore) {
     364                assert(method.getName().startsWith("get"));
     365               
     366                Object o = null;
     367                try {
     368                        o = method.invoke(item, (Object[]) null);
     369                } catch (IllegalArgumentException e) {
     370                        e.printStackTrace();
     371                        return null;
     372                } catch (IllegalAccessException e) {
     373                        e.printStackTrace();
     374                        return null;
     375                } catch (InvocationTargetException e) {
     376                        e.printStackTrace();
     377                        return null;
     378                }
     379
     380                if (o == null) {
     381                        // methods that return null are only included if they
     382                        // are in the AllowNull list
     383                        if (_AllowNull.contains(method)) {
     384                                String name = method.getName().substring(GET_LENGTH)
     385                                                .toLowerCase();
     386                                if (name.equals("color"))
     387                                        o = "default";
     388                                else if (name.equals("backgroundcolor"))
     389                                        o = "transparent";
     390                                else if (name.equals("foregroundcolor"))
     391                                        o = "auto";
     392                                else
     393                                        o = "";
     394                        } else {
     395                                return null;
     396                        }
     397                }
     398                // skip methods that are in the ignore lists
     399                if (ignore
     400                                && _ExtractIgnore.contains(method.getName().substring(
     401                                                GET_LENGTH).toLowerCase())) {
     402                        return null;
     403                }
     404
     405                if (o instanceof Integer) {
     406                        Integer i = (Integer) o;
     407                        if (i == Item.DEFAULT_INTEGER)
     408                                return null;
     409                        if (method.getName().endsWith("Justification")
     410                                        && ((Justification) o).toString() != null)
     411                                o = ((Justification) o).toString();
     412                        // -1 indicates default value
     413                        else
     414                                o = i;
     415                } else if (o instanceof Float) {
     416                        if (((Float) o) < -0.0001)
     417                                return null;
     418                        // Null indicates default
     419                        o = Math.round((Float) o);
     420                } else if (o instanceof Double) {
     421                        // -1 indicates default value
     422                        if (((Double) o) < 0.0001)
     423                                return null;
     424                } else if (o instanceof Color) {
     425                        // converts the color to the Expeditee code
     426                        o = Conversion.getExpediteeColorCode((Color) o);
     427                        if (o == null)
     428                                return null;
     429                } else if (o instanceof Point) {
     430                        Point p = (Point) o;
     431                        o = Math.round(p.getX()) + " " + Math.round(p.getY());
     432                } else if (o instanceof Font) {
     433                        Font f = (Font) o;
     434
     435                        String s = f.getName() + "-";
     436                        if (f.isPlain())
     437                                s += "Plain";
     438
     439                        if (f.isBold())
     440                                s += "Bold";
     441
     442                        if (f.isItalic())
     443                                s += "Italic";
     444
     445                        s += "-" + f.getSize();
     446                        o = s;
     447                } else if (o instanceof Text) {
     448                        o = ((Text) o).getFirstLine();
     449                } else if (o instanceof List) {
     450                        List list = (List) o;
     451                        StringBuffer sb = new StringBuffer();
     452                        for (Object ob : list)
     453                                // TODO check that this works ok
     454                                if (sb.length() == 0) {
     455                                        sb.append(ob);
     456                                } else {
     457                                        sb.append('\n').append(
     458                                                        method.getName().substring(GET_LENGTH)).append(
     459                                                        AttributeValuePair.SEPARATOR_STRING).append(ob);
     460                                }
     461                        return sb.toString();
     462                } else if (o instanceof int[]) {
     463                        StringBuffer sb = new StringBuffer();
     464                        int[] values = (int[]) o;
     465                        for (int i = 0; i < values.length; i++) {
     466                                sb.append(values[i]).append(' ');
     467                        }
     468                        sb.deleteCharAt(sb.length() - 1);
     469                        o = sb.toString();
     470                } else if (o instanceof Boolean) {
     471                        // true is the default for boolean values
     472                        if (((Boolean) o).booleanValue())
     473                                return null;
     474                }
     475                return o.toString();
    436476        }
    437477
     
    653693                text.setText(avp.toString());
    654694        }
     695
     696        public static String getAttribute(Item item, String attribute) {
     697
     698                // ensure the lists are populated
     699                if (_Ignore == null)
     700                        initLists();
     701
     702                // separate attribute and value from string
     703                String lowerAttribute = attribute.trim().toLowerCase();
     704
     705                String methodName = "get"
     706                                + Character.toUpperCase(lowerAttribute.charAt(0))
     707                                + lowerAttribute.substring(1);
     708
     709                try {
     710                        return attribute + ": " + getValue(item.getClass().getMethod(methodName,
     711                                        new Class[] {}), item, false);
     712                } catch (SecurityException e) {
     713                        e.printStackTrace();
     714                } catch (NoSuchMethodException e) {
     715                        MessageBay
     716                                        .errorMessage("Could no extract unknown attribute value: "
     717                                                        + attribute);
     718                }
     719                return null;
     720        }
    655721}
  • trunk/src/org/expeditee/gui/AttributeValuePair.java

    r286 r376  
    5454                if (text.charAt(0) == ANNOTATION_CHAR) {
    5555                        _bAnnotation = true;
    56                         if (text.length() == 1 || !Character.isLetterOrDigit(text.charAt(1)))
     56                        if (text.length() == 1
     57                                        || !Character.isLetterOrDigit(text.charAt(1)))
    5758                                return;
    5859                        // All chars in the attribute must be letters or digits
     
    9899        public Double getDoubleValue() throws NumberFormatException {
    99100                assert (_value != null);
     101                // Can be null if the text for the AVP was empty
     102                if (_value == null) {
     103                        return Double.NaN;
     104                }
     105
    100106                return _value.doubleValue();
    101107        }
     
    103109        public Double getDoubleAttribute() throws NumberFormatException {
    104110                assert (_attribute != null);
    105 
    106111                return _attribute.doubleValue();
    107112        }
     
    186191        }
    187192
     193        public boolean hasAttributeOrValue() {
     194                return _attribute != null || _value != null;
     195        }
     196
    188197}
  • trunk/src/org/expeditee/gui/Browser.java

    r355 r376  
    1616import java.io.File;
    1717import java.util.Collection;
     18import java.util.LinkedList;
    1819
    1920import javax.swing.JFrame;
     
    163164                Frame defaultProfile = loadProfile(UserSettings.DEFAULT_PROFILE_NAME);
    164165
    165                 Collection<String> warningMessages = FrameUtils
    166                                 .ParseProfile(defaultProfile);
    167 
     166                Collection<String> warningMessages = new LinkedList<String>();
     167                warningMessages.addAll(FrameUtils.ParseProfile(defaultProfile));
    168168                warningMessages.addAll(FrameUtils.ParseProfile(profile));
    169 
    170169                // set the layout to absolute layout for widgets
    171170                this.getContentPane().setLayout(new AbsoluteLayout());
     
    239238                                MessageBay.warningMessage(message);
    240239
    241                         this.getContentPane().addKeyListener(FrameKeyboardActions.getInstance());
     240                        this.getContentPane().addKeyListener(
     241                                        FrameKeyboardActions.getInstance());
    242242                        this.addKeyListener(FrameKeyboardActions.getInstance());
    243243
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r363 r376  
    7272         * The title to display in the Title bar.
    7373         */
    74         public static final String TITLE = "Exp09Oct2008A";
     74        public static final String TITLE = "Exp31Oct2008A";
    7575
    7676        private DisplayIO() {
     
    142142
    143143        public static void setTextCursor(Text text, int cursorMovement) {
    144                 setTextCursor(text, cursorMovement, false, false);
     144                setTextCursor(text, cursorMovement, false, false, false, false);
    145145        }
    146146
    147147        public static void setTextCursor(Text text, int cursorMovement,
    148                         boolean newSize, boolean isShiftDown) {
     148                        boolean newSize, boolean isShiftDown, boolean isCtrlDown, boolean allowClearSelection) {
    149149
    150150                int size = Math.round(text.getSize());
     151                if(allowClearSelection && !isShiftDown && text.hasSelection())
     152                        text.clearSelection();
     153               
    151154                Point2D.Float newMouse = text.moveCursor(cursorMovement, DisplayIO
    152                                 .getFloatMouseX(), FrameMouseActions.MouseY, isShiftDown);
     155                                .getFloatMouseX(), FrameMouseActions.MouseY, isShiftDown, isCtrlDown);
    153156
    154157                if (!newSize && cursorType == Item.TEXT_CURSOR) {
     
    187190
    188191                for (int i = start; i < cursorSize; i++)
    189                         pixels[i * cursorSize] = pixels[(i * cursorSize) + 1] = 0xFF000000;
     192                        pixels[i * cursorSize] = pixels[i * cursorSize + 1] = 0xFF000000;
    190193
    191194                Image image = Toolkit.getDefaultToolkit().createImage(
     
    846849         */
    847850        public static void MoveCursorToEndOfItem(Item i) {
    848                 setTextCursor((Text) i, Text.END, true, false);
     851                setTextCursor((Text) i, Text.END, true, false, false, false);
    849852        }
    850853
  • trunk/src/org/expeditee/gui/Frame.java

    r362 r376  
    204204                boolean oldValue = _change;
    205205
    206                 if (value) {
    207                         notifyObservers();
    208                 }
     206                // if (value) {
     207                // notifyObservers();
     208                // }
    209209
    210210                if (oldValue == value)
     
    219219        }
    220220
    221         public void notifyObservers() {
     221        //private static int updateCount = 0;
     222
     223        /**
     224         * Notify items observing the data on this frame that the frame content has
     225         * changed.
     226         *
     227         * @param recalculate
     228         *            true if the frame should be recalculated first.
     229         */
     230        public void notifyObservers(boolean bRecalculate) {
     231                if(bRecalculate){
     232                        recalculate();
     233                }
    222234                // Notify the frame listeners that the frame has changed
    223                 for (FrameObserver fl : _observers) {
    224                         fl.update();
     235                /*
     236                 * Avoid ConcurrentMod Exceptions when user anchors an item onto this
     237                 * frame which is observing this frame, by NOT using foreach loop.
     238                 * Calling update on a dataFrameWidget resets its subjects hence
     239                 * changing this frames observer list.
     240                 */
     241                Collection<FrameObserver> observersCopy = new LinkedList<FrameObserver>(
     242                                _observers);
     243                //System.out.println(++updateCount + " update");
     244
     245                for (FrameObserver fl : observersCopy) {
     246                        if (/* !Item.isLocked(fl) && */fl.isVisible())
     247                                fl.update();
    225248                }
    226249        }
     
    370393                        if (UserSettings.TitleTemplate == null) {
    371394                                frameTitle = new Text(getNextItemID(), title);
     395                                /*
     396                                 * Need to set the parent otherwise an exception is thrown when
     397                                 * new profile is created
     398                                 */
     399                                frameTitle.setParent(this);
    372400                                frameTitle.resetTitlePosition();
    373401                        } else {
     
    721749                item.onParentStateChanged(new ItemParentStateChangedEvent(this,
    722750                                ItemParentStateChangedEvent.EVENT_TYPE_ADDED));
    723                 if (recalculate && item.recalculateWhenChanged())
    724                         recalculate();
     751
     752                // if (recalculate && item.recalculateWhenChanged())
     753                // recalculate();
    725754
    726755                change();
     
    799828                        }
    800829                        // TODO Improve efficiency when removeAll is called
    801                         if (recalculate && item.recalculateWhenChanged())
    802                                 recalculate();
     830                        // if (recalculate && item.recalculateWhenChanged())
     831                        // recalculate();
    803832                }
    804833        }
     
    834863                Item undo = null;
    835864                boolean bReparse = false;
     865                boolean bRecalculate = false;
    836866
    837867                if (_undo.size() <= 0)
     
    871901                        for (Item i : toRestore) {
    872902                                bReparse |= i.hasOverlay();
     903                                bRecalculate |= i.recalculateWhenChanged();
    873904                                if (i instanceof Line) {
    874905                                        Line line = (Line) i;
     
    885916                if (bReparse)
    886917                        FrameUtils.Parse(this, false);
     918                else {
     919                        notifyObservers(bRecalculate);
     920                }
    887921                FrameGraphics.Repaint();
    888922                ItemUtils.EnclosedCheck(_body);
     
    14551489                // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    14561490                // if (t.getWidth() <= 0) {
    1457 //              String maxWidthString = getAnnotationValue("maxwidth");
    1458 //              int width = FrameGraphics.getMaxFrameSize().width;
    1459 //              if (maxWidthString != null) {
    1460 //                      try {
    1461 //                              width = Math.min(width, Integer.parseInt(maxWidthString));
    1462 //                      } catch (NumberFormatException nfe) {
    1463 //                      }
    1464 //              }
    1465 //
    1466 //              t.setRightMargin(width);
     1491                // String maxWidthString = getAnnotationValue("maxwidth");
     1492                // int width = FrameGraphics.getMaxFrameSize().width;
     1493                // if (maxWidthString != null) {
     1494                // try {
     1495                // width = Math.min(width, Integer.parseInt(maxWidthString));
     1496                // } catch (NumberFormatException nfe) {
     1497                // }
     1498                // }
     1499                //
     1500                // t.setRightMargin(width);
    14671501                // }
    14681502                addItem(t);
     
    20232057
    20242058        public void recalculate() {
     2059
    20252060                for (Item i : getItems()) {
    20262061                        if (i.hasFormula() && !i.isAnnotation()) {
     
    21182153                }
    21192154        }
     2155
     2156        public boolean hasObservers() {
     2157                return _observers != null && _observers.size() > 0;
     2158        }
    21202159}
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r348 r376  
    351351                }
    352352
     353                // if(isActual)
    353354                bg.setColor(backgroundColor);
    354                 // bg.setColor(Color.pink); // TODO: TEMP FOR DEBUGGING
    355 
     355                if (isActualFrame){
     356                        //bg.setColor(Color.white); // TODO: TEMP FOR DEBUGGING
     357                       
     358                        //System.out.println("paintPic");
     359                }
    356360                bg.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
    357361
     
    514518        // creates a new line so that lines are shown correctly when spanning
    515519        // across frames in TwinFrames mode
    516         private static Line TransposeLine(Line line, Item d, Frame toPaint,
    517                         int base, int adj) {
    518                 Line nl = null;
    519 
    520                 if (toPaint != DisplayIO.getCurrentFrame() && d.getParent() == null
    521                                 && line.getOppositeEnd(d).getParent() == toPaint) {
    522                         nl = line.copy();
    523                         if (d == line.getStartItem())
    524                                 d = nl.getStartItem();
    525                         else
    526                                 d = nl.getEndItem();
    527 
    528                         if (DisplayIO.FrameOnSide(toPaint) == 0)
    529                                 d.setX(base);
    530                         else
    531                                 d.setX(base + adj);
    532 
    533                 } else if (toPaint == DisplayIO.getCurrentFrame()
    534                                 && d.getParent() == null
    535                                 && line.getOppositeEnd(d).getParent() != toPaint) {
    536                         nl = line.copy();
    537 
    538                         if (d == line.getStartItem())
    539                                 d = nl.getEndItem();
    540                         else
    541                                 d = nl.getStartItem();
    542 
    543                         if (DisplayIO.FrameOnSide(toPaint) == 1)
    544                                 d.setX(d.getX() - DisplayIO.getMiddle());
    545                         else
    546                                 d.setX(d.getX() + DisplayIO.getMiddle());
    547                 }
    548                 if (nl != null) {
    549                         nl.invalidateAll();
    550                         FrameGraphics.requestRefresh(true);
    551                 }
    552                 return nl;
    553         }
     520        // private static Line TransposeLine(Line line, Item d, Frame toPaint,
     521        // int base, int adj) {
     522        // Line nl = null;
     523        //
     524        // if (toPaint != DisplayIO.getCurrentFrame() && d.getParent() == null
     525        // && line.getOppositeEnd(d).getParent() == toPaint) {
     526        // nl = line.copy();
     527        // if (d == line.getStartItem())
     528        // d = nl.getStartItem();
     529        // else
     530        // d = nl.getEndItem();
     531        //
     532        // if (DisplayIO.FrameOnSide(toPaint) == 0)
     533        // d.setX(base);
     534        // else
     535        // d.setX(base + adj);
     536        //
     537        // } else if (toPaint == DisplayIO.getCurrentFrame()
     538        // && d.getParent() == null
     539        // && line.getOppositeEnd(d).getParent() != toPaint) {
     540        // nl = line.copy();
     541        //
     542        // if (d == line.getStartItem())
     543        // d = nl.getEndItem();
     544        // else
     545        // d = nl.getStartItem();
     546        //
     547        // if (DisplayIO.FrameOnSide(toPaint) == 1)
     548        // d.setX(d.getX() - DisplayIO.getMiddle());
     549        // else
     550        // d.setX(d.getX() + DisplayIO.getMiddle());
     551        // }
     552        // if (nl != null) {
     553        // nl.invalidateAll();
     554        // FrameGraphics.requestRefresh(true);
     555        // }
     556        // return nl;
     557        // }
    554558
    555559        private static void Paint(Graphics g, Image left, Image right,
     
    658662                                if (done.contains(i))
    659663                                        continue;
    660                                 else if (!isAudienceMode() || !i.isConnectedToAnnotation()) {
     664                                else if (!isAudienceMode() ||
     665                                                !i.isConnectedToAnnotation()) {
    661666                                        toFill.add(i);
    662667                                }
     
    674679                                        // System.out.println(a.getEnclosureID() + " " +
    675680                                        // b.getID());\
    676                                         //Shapes to the left go underneath
     681                                        // Shapes to the left go underneath
    677682                                        Polygon pA = a.getEnclosedShape();
    678683                                        Polygon pB = b.getEnclosedShape();
    679                                         if(pA == null || pB == null)
     684                                        if (pA == null || pB == null)
    680685                                                return 0;
    681                                         return new Integer(pA.getBounds().x)
    682                                                         .compareTo(pB.getBounds().x);
     686                                        return new Integer(pA.getBounds().x).compareTo(pB
     687                                                        .getBounds().x);
    683688                                }
    684689                                return cmp * -1;
  • trunk/src/org/expeditee/gui/FrameIO.java

    r362 r376  
    771771        }
    772772
     773        /**
     774         * Saves a frame.
     775         * @param toSave the frame to save
     776         * @param inc true if the frames counter should be incremented
     777         * @return the text content of the frame
     778         */
    773779        public static String SaveFrame(Frame toSave, boolean inc) {
    774780                return SaveFrame(toSave, inc, true);
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r362 r376  
    5757
    5858        public synchronized void keyTyped(KeyEvent e) {
     59
    5960                if (Simple.isProgramRunning()) {
    6061                        if (e.isControlDown()
     
    153154                }
    154155
    155                 FrameUtils.setLastEdited(text);
    156 
    157156                // if the user is in free space, create a new text item
    158                 if (on == null || !on.isHighlighted()) {
     157                /*
     158                 * MikeSays: Why do we have to check is highlighted... doing so causes
     159                 * problems if you type characters to fast, they turn into multiple text
     160                 * items. ie. JK together on the Linux laptop.
     161                 */
     162                if (on == null /* || !on.isHighlighted() */) {
    159163                        // DisplayIO.UpdateTitle();
    160164                        text = createText(ch);
     
    164168                        DisplayIO.setTextCursor(text, Text.NONE);
    165169                        return;
    166                 }
     170                } else {
     171                        FrameUtils.setLastEdited(text);
     172                }
     173
     174                float oldY = FrameMouseActions.MouseY;
    167175
    168176                DisplayIO.setTextCursor(text, Text.NONE);
     
    180188                                        FrameMouseActions.MouseY);
    181189                }
     190                /*
     191                 * check if the user hit enter and the cursor is now on another text
     192                 * item
     193                 */
     194                if (oldY < newMouse.y) {
     195                        //float diff = newMouse.y - oldY;
     196                        // System.out.print("c");
     197                        Rectangle rect = text.getPolygon().getBounds();
     198                       
     199                        //Text lastEdited = FrameUtils.getLastEdited();
     200                        //FrameUtils.setLastEdited(null);
     201                       
     202                        Item justBelow = FrameUtils.onItem(DisplayIO.getCurrentFrame(),
     203                                        text.getX() + 10, rect.y + rect.height + 1, false);
     204                       
     205                        //FrameUtils.setLastEdited(lastEdited);
     206                       
     207                        //Dont drop unless
     208                        if (justBelow != null && justBelow instanceof Text && justBelow != on) {
     209                                // Drop all the items below it down!
     210                                // Get the list of items that must be dropped
     211                                List<Text> column = DisplayIO.getCurrentFrame().getColumn(on);
     212                                FrameUtils.Align(column, false, 0);
     213                        }
     214                }
     215
    182216                DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false);
    183217
     
    303337        }
    304338
    305         private void move(int direction, boolean isShiftDown) {
     339        private void move(int direction, boolean isShiftDown, boolean isCtrlDown) {
    306340                Item on = FrameUtils.getCurrentItem();
    307341
     
    320354                        } else {
    321355                                FrameUtils.setLastEdited(text);
    322                                 if (!isShiftDown)
    323                                         text.clearSelection();
    324                                 DisplayIO.setTextCursor(text, direction, false, isShiftDown);
     356                                DisplayIO.setTextCursor(text, direction, false, isShiftDown,
     357                                                isCtrlDown, true);
    325358                        }
    326359                }
     
    426459                        break;
    427460                case KeyEvent.VK_LEFT:
    428                         move(Text.LEFT, e.isShiftDown());
     461                        move(Text.LEFT, e.isShiftDown(), e.isControlDown());
    429462                        break;
    430463                case KeyEvent.VK_RIGHT:
    431                         move(Text.RIGHT, e.isShiftDown());
     464                        move(Text.RIGHT, e.isShiftDown(), e.isControlDown());
    432465                        break;
    433466                case KeyEvent.VK_PAGE_DOWN:
     
    441474                                NextTextItem(FrameUtils.getCurrentItem(), false);
    442475                        } else {
    443                                 move(Text.UP, e.isShiftDown());
     476                                move(Text.UP, e.isShiftDown(), e.isControlDown());
    444477                        }
    445478                        break;
     
    448481                                NextTextItem(FrameUtils.getCurrentItem(), true);
    449482                        } else {
    450                                 move(Text.DOWN, e.isShiftDown());
     483                                move(Text.DOWN, e.isShiftDown(), e.isControlDown());
    451484                        }
    452485                        break;
    453486                case KeyEvent.VK_END:
    454487                        if (e.isControlDown())
    455                                 move(Text.END, e.isShiftDown());
     488                                move(Text.END, e.isShiftDown(), e.isControlDown());
    456489                        else
    457                                 move(Text.LINE_END, e.isShiftDown());
     490                                move(Text.LINE_END, e.isShiftDown(), e.isControlDown());
    458491                        break;
    459492                case KeyEvent.VK_HOME:
    460493                        if (e.isControlDown())
    461                                 move(Text.HOME, e.isShiftDown());
     494                                move(Text.HOME, e.isShiftDown(), e.isControlDown());
    462495                        else
    463                                 move(Text.LINE_HOME, e.isShiftDown());
     496                                move(Text.LINE_HOME, e.isShiftDown(), e.isControlDown());
    464497                        break;
    465498                // TODO remove this when upgrading Java
     
    486519                // Move the cursor to the next text item
    487520                Frame current = DisplayIO.getCurrentFrame();
    488                 Item title = current.getTitleItem();
     521                Text title = current.getTitleItem();
    489522
    490523                Collection<Text> currentItems = FrameUtils.getCurrentTextItems();
     
    494527                        textItems.addAll(currentItems);
    495528                } else {
    496                         textItems.add(current.getTitleItem());
     529                        if (title != null)
     530                                textItems.add(title);
    497531                        textItems.addAll(current.getBodyTextItems(true));
    498532                }
     
    504538                        if (title == null)
    505539                                return;
    506                         DisplayIO.MoveCursorToEndOfItem(title);
     540                        if (title != null)
     541                                DisplayIO.MoveCursorToEndOfItem(title);
    507542                        FrameGraphics.Repaint();
    508543                        return;
     
    634669                // FrameMouseActions.pickup(t);
    635670                // } else {
    636                 // remove the link for alt+l
     671                // remove the link for ctrl+l
    637672                Item current = FrameUtils.getCurrentItem();
    638673                Frame currentFrame = DisplayIO.getCurrentFrame();
     
    641676                case KeyEvent.VK_HOME:
    642677                        if (current != null && current instanceof Text) {
    643                                 move(Text.HOME, isShiftDown);
     678                                move(Text.HOME, isShiftDown, true);
    644679                        } else {
    645680                                while (DisplayIO.Back())
     
    649684                case KeyEvent.VK_END:
    650685                        if (current != null && current instanceof Text) {
    651                                 move(Text.END, isShiftDown);
     686                                move(Text.END, isShiftDown, true);
    652687                        } else {
    653688                                while (DisplayIO.Forward())
     
    682717                        break;
    683718                case KeyEvent.VK_LEFT:
    684                         DisplayIO.translateCursor(-distance, 0);
     719                        if (current instanceof Text) {
     720                                DisplayIO.setTextCursor((Text) current, Text.LEFT, false,
     721                                                isShiftDown, true, true);
     722                        } else {
     723                                DisplayIO.translateCursor(-distance, 0);
     724                        }
    685725                        break;
    686726                case KeyEvent.VK_RIGHT:
    687                         DisplayIO.translateCursor(distance, 0);
     727                        if (current instanceof Text) {
     728                                DisplayIO.setTextCursor((Text) current, Text.RIGHT, false,
     729                                                isShiftDown, true, true);
     730                        } else {
     731                                DisplayIO.translateCursor(distance, 0);
     732                        }
    688733                        break;
    689734                case KeyEvent.VK_UP:
    690                         if (current instanceof Text) {
    691                                 NextTextItem(FrameUtils.getCurrentItem(), false);
    692                         } else {
    693                                 DisplayIO.translateCursor(0, -distance);
    694                         }
     735                        // if (current instanceof Text) {
     736                        NextTextItem(FrameUtils.getCurrentItem(), false);
     737                        // } else {
     738                        // DisplayIO.translateCursor(0, -distance);
     739                        // }
    695740                        break;
    696741                case KeyEvent.VK_DOWN:
    697                         if (current instanceof Text) {
    698                                 NextTextItem(FrameUtils.getCurrentItem(), true);
    699                         } else {
    700                                 DisplayIO.translateCursor(0, distance);
    701                         }
     742                        // if (current instanceof Text) {
     743                        NextTextItem(FrameUtils.getCurrentItem(), true);
     744                        // } else {
     745                        // DisplayIO.translateCursor(0, distance);
     746                        // }
    702747                        break;
    703748                case KeyEvent.VK_L:
     
    923968                        Text text = getCurrentTextItem();
    924969                        if (text == null) {
    925                                 for (Text t : FrameUtils.getCurrentTextItems()) {
     970                                for (Text t : currentFrame.getBodyTextItems(false)) {
    926971                                        justify(t);
    927972                                }
     
    11341179                        SetSize(on, repeat, true, false);
    11351180                        if (on instanceof Text) {
    1136                                 DisplayIO.setTextCursor((Text) on, Text.NONE, true, false);
     1181                                DisplayIO.setTextCursor((Text) on, Text.NONE, true, false,
     1182                                                false, true);
    11371183                        }
    11381184                        break;
     
    11401186                        SetSize(on, -repeat, true, false);
    11411187                        if (on instanceof Text) {
    1142                                 DisplayIO.setTextCursor((Text) on, Text.NONE, true, false);
     1188                                DisplayIO.setTextCursor((Text) on, Text.NONE, true, false,
     1189                                                false, true);
    11431190                        }
    11441191                        break;
     
    11811228
    11821229        private static void calculateItem(Item toCalculate) {
     1230                if (toCalculate == null)
     1231                        return;
     1232
    11831233                if (!toCalculate.update()) {
    11841234                        toCalculate.setFormula(null);
     
    14211471                if (firstItem == null) {
    14221472                        firstItem = null;
     1473                        return;
    14231474                }
    14241475
     
    21872238
    21882239                // Refresh widgets that use its self as a data source
    2189                 currentFrame.notifyObservers();
     2240                currentFrame.notifyObservers(true);
    21902241
    21912242                if (FrameIO.isProfileFrame(currentFrame)) {
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r364 r376  
    639639        private void leftButton(Item clicked, Collection<Item> clickedIn,
    640640                        boolean isShiftDown, boolean isControlDown) {
     641
    641642                // if the user is pointing at something then either follow the link or
    642643                // do TDFC
     
    698699                if (clicked != null) {
    699700                        // check item permissions
    700                         if ((clicked.hasLink() && !clicked
     701                        boolean hasLinkOrAction = clicked.hasLink() || clicked.hasAction();
     702
     703                        if ((hasLinkOrAction && !clicked
    701704                                        .hasPermission(Permission.followLinks))
    702                                         || (!clicked.hasLink() && !clicked
     705                                        || (!hasLinkOrAction && !clicked
    703706                                                        .hasPermission(Permission.createFrames))) {
    704707                                Item editTarget = clicked.getEditTarget();
     
    756759                                        tdfc(clickedOn);
    757760                                } catch (RuntimeException e) {
    758                                         MessageBay.errorMessage(e.getMessage());
     761                                        MessageBay.errorMessage("TDFC error: " + e.getMessage());
    759762                                }
    760763                                return;
     
    9971000                } else {
    9981001                        Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(), Math
    999                                         .round(MouseX), Math.round(MouseY));
     1002                                        .round(MouseX), Math.round(MouseY), true);
    10001003                        // If we have permission to copy this item then pick it up
    10011004                        if (on != null && on.isLineEnd()
     
    13441347                                } else {
    13451348                                        Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(),
    1346                                                         MouseX, MouseY);
     1349                                                        MouseX, MouseY, true);
    13471350                                        // if its on a line then create a line from that line
    13481351                                        if (on instanceof Line && on.hasPermission(Permission.full)) {
     
    15101513                        }
    15111514
    1512                         DisplayIO.setTextCursor(_lastRanged, Text.NONE);
     1515                        DisplayIO.setTextCursor(_lastRanged, Text.NONE, false, e.isShiftDown(), e.isControlDown(), false);
    15131516                        FrameGraphics.Repaint();
    15141517                        return;
     
    15441547                                && _lastClickedOn == null && _lastClickedIn == null) {
    15451548                        Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(), e.getX(),
    1546                                         e.getY());
     1549                                        e.getY(), true);
    15471550
    15481551                        if (FreeItems.getInstance().size() == 0) {
     
    21622165
    21632166        public static void delete(Item toDelete) {
     2167                boolean bRecalculate = false;
     2168
    21642169                FrameUtils.setLastEdited(null);
    21652170                _offX = _offY = 0;
    21662171
    2167                 Frame current = DisplayIO.getCurrentFrame();
     2172                Frame currentFrame = DisplayIO.getCurrentFrame();
    21682173                // check if the user is pointing at the frame's framename
    2169                 if (toDelete != null && toDelete == current.getNameItem()) {
    2170                         current.clear(false);
     2174                if (toDelete != null && toDelete == currentFrame.getNameItem()) {
     2175                        currentFrame.clear(false);
    21712176                        FrameGraphics.Repaint();
    21722177                        return;
     
    21902195                                SessionStats.DeletedItem(free);
    21912196                                // List<String> temp = anchored.getText();
    2192                                 anchored.setTextList(free.getTextList());
     2197                                anchored.setText(free.getText());
     2198                                anchored.setFormula(free.getFormula());
    21932199
    21942200                                // free.setTextList(temp);
     
    21962202
    21972203                                anchored.getParent().setChanged(true);
     2204
     2205                                bRecalculate |= free.recalculateWhenChanged();
     2206                                bRecalculate |= anchored.recalculateWhenChanged();
    21982207
    21992208                                // update the offset since the text has changed
     
    22062215                        // reset the mouse cursor
    22072216                        updateCursor();
    2208                         FrameGraphics.Repaint();
    2209                         return;
    22102217                        // the user is not pointing at an item
    22112218                } else if (toDelete == null) {
     
    23042311                                toUndo = toDelete.getConnected();
    23052312                        } else {
     2313                                bRecalculate |= toDelete.recalculateWhenChanged();
    23062314                                toUndo = toDelete.getConnected(); // copy(toDelete.getConnected());
    23072315                        }
     
    23182326                                FrameGraphics.requestRefresh(false);
    23192327                        }
    2320                         FrameGraphics.Repaint();
    2321                 }
    2322                 // check
    2323                 DisplayIO.setCursor(Item.DEFAULT_CURSOR);
     2328
     2329                        DisplayIO.setCursor(Item.DEFAULT_CURSOR);
     2330
     2331                }
     2332
     2333                currentFrame.notifyObservers(bRecalculate);
     2334
     2335                FrameGraphics.Repaint();
    23242336        }
    23252337
     
    23302342        public static void deleteItems(Collection<Item> itemList, boolean addToUndo) {
    23312343                boolean bReparse = false;
     2344                boolean bRecalculate = false;
     2345
    23322346                SessionStats.DeletedItems(itemList);
    23332347                List<Frame> modifiedFrames = new LinkedList<Frame>();
     
    23392353                        i.setHighlightMode(HighlightMode.None);
    23402354                        bReparse |= i.hasOverlay();
     2355                        bRecalculate |= i.recalculateWhenChanged();
    23412356                }
    23422357                // If they are all free items then add the current frame
     
    23882403                currentFrame.addAllToUndo(itemList);
    23892404                itemList.clear();
    2390                 if (bReparse)
     2405                if (bReparse) {
    23912406                        FrameUtils.Parse(currentFrame, false, false);
     2407                        /*
     2408                         * TODO check if I need to recalculate even if reparse occurs, here
     2409                         * and in anchor, pickup etc
     2410                         */
     2411                } else {
     2412                        currentFrame.notifyObservers(bRecalculate);
     2413                }
    23922414
    23932415        }
     
    25582580                                                        if (merger.size() == 1 && txt.getLink() != null) {
    25592581                                                                // If the text item is linked then use that
    2560                                                                 ((WidgetCorner)mergee).setLink(txt.getAbsoluteLink(), txt);
     2582                                                                ((WidgetCorner) mergee).setLink(txt
     2583                                                                                .getAbsoluteLink(), txt);
    25612584                                                        } else {
    25622585                                                                remain.addAll(merger);
     
    25662589                                                        if (merger.size() == 1 && txt.getLink() != null) {
    25672590                                                                // If the text item is linked then use that
    2568                                                                 ((WidgetEdge)mergee).setLink(txt.getAbsoluteLink(), txt);
     2591                                                                ((WidgetEdge) mergee).setLink(txt
     2592                                                                                .getAbsoluteLink(), txt);
    25692593                                                        } else {
    25702594                                                                remain.addAll(merger);
     
    26082632                }
    26092633                updateCursor();
     2634
    26102635                mergee.getParent().setChanged(true);
     2636
    26112637                ItemUtils.EnclosedCheck(mergee.getParent().getItems());
    26122638                // Mike: Why does parse frame have to be called?!?
     
    26662692
    26672693                boolean bReparse = false;
    2668                 Frame frame = DisplayIO.getCurrentFrame();
    2669                 String currentFrame = frame.getName();
     2694                boolean bRecalculate = false;
     2695
     2696                Frame currentFrame = DisplayIO.getCurrentFrame();
     2697                String currentFrameName = currentFrame.getName();
    26702698                Iterator<Item> iter = toGrab.iterator();
    26712699                while (iter.hasNext()) {
     
    26772705                        if (i.equals(_lastHighlightedItem))
    26782706                                _lastHighlightedItem = null;
     2707
     2708                        bRecalculate |= i.recalculateWhenChanged();
    26792709                        // i.setSelectedMode(SelectedMode.None);
    26802710                        // Check if it has a relative link if so make it absolute
     
    26832713                        if (i.getParent() != null) {
    26842714                                i.getParent().removeItem(i);
    2685                                 if (currentFrame.equals(i.getParent().getName()))
     2715                                if (currentFrameName.equals(i.getParent().getName()))
    26862716                                        i.setParent(null);
    26872717                        }
     
    27042734                        }
    27052735                }
    2706                 frame.recalculate();
     2736                currentFrame.change();
     2737
    27072738                _lastHighlightedItem = null;
    27082739                updateCursor();
     
    27442775                }
    27452776                if (bReparse)
    2746                         FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false);
     2777                        FrameUtils.Parse(currentFrame, false, false);
     2778                else
     2779                        currentFrame.notifyObservers(bRecalculate);
    27472780
    27482781                FrameGraphics.Repaint();
     
    28052838        public static void anchor(Collection<Item> toAnchor) {
    28062839                boolean bReparse = false;
     2840                boolean bRecalculate = false;
    28072841                // Need to make sure we check enclosure for overlays etc
    28082842                Set<Frame> checkEnclosure = new HashSet<Frame>();
     
    28272861                                checkEnclosure.add(i.getParentOrCurrentFrame());
    28282862                                bReparse |= i.hasOverlay();
     2863                                bRecalculate |= i.recalculateWhenChanged();
    28292864                        }
    28302865                }
     
    28342869                for (Frame f : checkEnclosure) {
    28352870                        ItemUtils.EnclosedCheck(f.getItems());
    2836                         f.recalculate();
    2837                 }
     2871                }
     2872
     2873                Frame currentFrame = DisplayIO.getCurrentFrame();
    28382874                if (bReparse)
    2839                         FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false);
     2875                        FrameUtils.Parse(currentFrame, false, false);
     2876                else {
     2877                        currentFrame.notifyObservers(bRecalculate);
     2878                }
    28402879                FrameGraphics.Repaint();
    28412880        }
  • trunk/src/org/expeditee/gui/FrameObserver.java

    r214 r376  
    55
    66        public abstract void removeSubject(Frame frame);
     7       
     8        public abstract boolean isVisible();
    79}
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r373 r376  
    240240                        }
    241241
    242                         if (above != curr.getNameItem() && above != curr.getTitleItem())
     242                        // Need to do things differently for FORMAT than for DROPPING
     243                        if (moveAll && above != curr.getNameItem()
     244                                        && above != curr.getTitleItem()) {
    243245                                x = above.getX();
     246                                from.setY((int) above.getPolygon().getBounds().getMaxY()
     247                                                + space
     248                                                + ((int) (from.getY() - from.getPolygon().getBounds()
     249                                                                .getMinY())));
     250                                from.setX(x);
     251                        } else {
     252                                x = from.getX();
     253                        }
    244254
    245255                        space += adjust;
    246 
    247                         from.setY((int) above.getPolygon().getBounds().getMaxY()
    248                                         + space
    249                                         + ((int) (from.getY() - from.getPolygon().getBounds()
    250                                                         .getMinY())));
    251 
    252                         if (moveAll)
    253                                 from.setX(x);
    254                 }
    255 
     256                }
    256257                for (int i = 1; i < toAlign.size(); i++) {
    257258                        Item current = toAlign.get(i);
     
    580581                // check for all tags setting user values
    581582                for (Text item : profile.getBodyTextItems(false)) {
    582 
    583                         AttributeValuePair avp = new AttributeValuePair(item.getText());
    584                         String attributeFullCase = avp.getAttributeOrValue();
    585 
    586                         if (attributeFullCase == null)
    587                                 continue;
    588                         String attribute = attributeFullCase.toLowerCase();
    589 
    590                         if (attribute.equals("homeframe")) {
    591                                 String first = getLink(item, UserSettings.HomeFrame);
    592                                 // do not use non-existant frames as the first frame
    593                                 if (FrameIO.isValidFrameName(first)) {
    594                                         UserSettings.HomeFrame = first;
    595                                 }
    596                                 // warn the user
    597                                 else {
    598                                         // MessageBay.warningMessage("Home frame: " + first
    599                                         // + " is not a valid frame.");
    600                                         UserSettings.HomeFrame = profile.getName();
    601                                 }
    602                         } else if (attribute.equals("username")) {
    603                                 UserSettings.UserName = avp.getValue();
    604                         } else if (attribute.equals("spellchecker")) {
    605 
    606                                 try {
    607                                         JSpellChecker.create();
    608                                 } catch (FileNotFoundException e) {
    609                                         MessageBay.errorMessage("Could not find dictionary: "
    610                                                         + e.getMessage());
    611                                 } catch (IOException e) {
    612                                         // TODO Auto-generated catch block
    613                                         e.printStackTrace();
    614                                 }
    615                         } else if (attribute.equals("defaultframe"))
    616                                 UserSettings.DefaultFrame = getLink(item,
    617                                                 UserSettings.DefaultFrame);
    618                         else if (attribute.equals("mailsettings"))
    619                                 MailSession.init(item.getChild());
    620                         else if (attribute.equals("networksettings"))
    621                                 FrameShare.init(item.getChild());
    622                         else if (attribute.equals("greenstonesettings")) {
    623                                 SearchGreenstone.init(item.getChild());
    624                         } else if (attribute.equals("reminders"))
    625                                 Reminders.init(item.getChild());
    626                         else if (attribute.equals("antialias"))
    627                                 UserSettings.AntiAlias = avp.getBooleanValue();
    628                         else if (attribute.equals("gravity"))
    629                                 UserSettings.Gravity = avp.getIntegerValue();
    630                         else if (attribute.equals("showlinehighlight"))
    631                                 UserSettings.LineHighlight = avp.getBooleanValue();
    632                         else if (attribute.equals("linestraightenthreshold"))
    633                                 UserSettings.LineStraightenThreshold = avp.getIntegerValue();
    634                         else if (attribute.equals("noopthreshold"))
    635                                 UserSettings.NoOpThreshold = avp.getIntegerValue();
    636                         else if (attribute.equals("formatspacingmin")) {
    637                                 FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue();
    638                         } else if (attribute.equals("formatspacingmax")) {
    639                                 FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue();
    640                         } else if (attribute.equals("initialwidth")) {
    641                                 UserSettings.InitialWidth = avp.getIntegerValue();
    642                         } else if (attribute.equals("initialheight")) {
    643                                 UserSettings.InitialHeight = avp.getIntegerValue();
    644                         } else if (attribute.equals("titleposition")) {
    645                                 UserSettings.TitlePosition = avp.getIntegerValue();
    646                         } else if (attribute.equals("logging")) {
    647                                 UserSettings.Logging = avp.getBooleanValue();
    648                         } else if (attribute.equals("itemtemplate")) {
    649                                 UserSettings.ItemTemplate = ((Text) item).getTemplateForm();
    650                         } else if (attribute.equals("annotationtemplate")) {
    651                                 UserSettings.AnnotationTemplate = ((Text) item)
    652                                                 .getTemplateForm();
    653                         } else if (attribute.equals("statstemplate")) {
    654                                 UserSettings.StatTemplate = ((Text) item).getTemplateForm();
    655                         } else if (attribute.equals("commenttemplate")) {
    656                                 UserSettings.CodeCommentTemplate = ((Text) item)
    657                                                 .getTemplateForm();
    658                         } else if (attribute.equals("dottemplate")) {
    659                                 UserSettings.DotTemplate = ((Text) item).getTemplateForm();
    660                         } else if (attribute.equals("framesetdir")) {
    661                                 String dir = getDir(avp.getValue());
    662                                 if (dir != null) {
    663                                         UserSettings.FrameDirs.add(dir);
    664                                 }
    665                         } else if (attribute.equals("logdir")) {
    666                                 org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue());
    667                         } else if (attribute.equals("imagedir")) {
    668                                 String dir = getDir(avp.getValue());
    669                                 if (dir != null)
    670                                         UserSettings.ImageDirs.add(0, dir);
    671                         } else if (attribute.equals("threading")) {
    672                                 UserSettings.Threading = avp.getBooleanValue();
    673                         } else if (attribute.equals("colorwheel")) {
    674                                 Item.COLOR_WHEEL = getColorWheel(item);
    675                         } else if (attribute.equals("fillcolorwheel")) {
    676                                 Item.FILL_COLOR_WHEEL = getColorWheel(item);
    677                         } else if (attribute.equals("backgroundcolorwheel")) {
    678                                 Frame.COLOR_WHEEL = getColorWheel(item);
    679                         } else if (attribute.equals("framesetdirs")) {
    680                                 UserSettings.FrameDirs.addAll(getDirs(item));
    681                         } else if (attribute.equals("imagedirs")) {
    682                                 UserSettings.ImageDirs.addAll(getDirs(item));
    683                         } else if (attribute.equals("style")) {
    684                                 UserSettings.Style = getStyle(item.getChild());
    685                         } else {
    686                                 errors.add(attributeFullCase + " is not a profile frame tag");
     583                        try {
     584
     585                                AttributeValuePair avp = new AttributeValuePair(item.getText());
     586                                String attributeFullCase = avp.getAttributeOrValue();
     587
     588                                if (attributeFullCase == null)
     589                                        continue;
     590                                String attribute = attributeFullCase.toLowerCase();
     591
     592                                if (attribute.equals("homeframe")) {
     593                                        String first = getLink(item, UserSettings.HomeFrame);
     594                                        // do not use non-existant frames as the first frame
     595                                        if (FrameIO.isValidFrameName(first)) {
     596                                                UserSettings.HomeFrame = first;
     597                                        }
     598                                        // warn the user
     599                                        else {
     600                                                // MessageBay.warningMessage("Home frame: " + first
     601                                                // + " is not a valid frame.");
     602                                                UserSettings.HomeFrame = profile.getName();
     603                                        }
     604                                } else if (attribute.equals("username")) {
     605                                        UserSettings.UserName = avp.getValue();
     606                                } else if (attribute.equals("spellchecker")) {
     607
     608                                        try {
     609                                                JSpellChecker.create();
     610                                        } catch (FileNotFoundException e) {
     611                                                MessageBay.errorMessage("Could not find dictionary: "
     612                                                                + e.getMessage());
     613                                        } catch (IOException e) {
     614                                                // TODO Auto-generated catch block
     615                                                e.printStackTrace();
     616                                        }
     617                                } else if (attribute.equals("defaultframe"))
     618                                        UserSettings.DefaultFrame = getLink(item,
     619                                                        UserSettings.DefaultFrame);
     620                                else if (attribute.equals("mailsettings"))
     621                                        MailSession.init(item.getChild());
     622                                else if (attribute.equals("networksettings"))
     623                                        FrameShare.init(item.getChild());
     624                                else if (attribute.equals("spelling"))
     625                                        JSpellChecker.create(item.getChild());
     626                                else if (attribute.equals("greenstonesettings")) {
     627                                        SearchGreenstone.init(item.getChild());
     628                                } else if (attribute.equals("reminders"))
     629                                        Reminders.init(item.getChild());
     630                                else if (attribute.equals("antialias"))
     631                                        UserSettings.AntiAlias = avp.getBooleanValue();
     632                                else if (attribute.equals("gravity"))
     633                                        UserSettings.Gravity = avp.getIntegerValue();
     634                                else if (attribute.equals("showlinehighlight"))
     635                                        UserSettings.LineHighlight = avp.getBooleanValue();
     636                                else if (attribute.equals("linestraightenthreshold"))
     637                                        UserSettings.LineStraightenThreshold = avp
     638                                                        .getIntegerValue();
     639                                else if (attribute.equals("noopthreshold"))
     640                                        UserSettings.NoOpThreshold = avp.getIntegerValue();
     641                                else if (attribute.equals("formatspacingmin")) {
     642                                        FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue();
     643                                } else if (attribute.equals("formatspacingmax")) {
     644                                        FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue();
     645                                } else if (attribute.equals("initialwidth")) {
     646                                        UserSettings.InitialWidth = avp.getIntegerValue();
     647                                } else if (attribute.equals("initialheight")) {
     648                                        UserSettings.InitialHeight = avp.getIntegerValue();
     649                                } else if (attribute.equals("titleposition")) {
     650                                        UserSettings.TitlePosition = avp.getIntegerValue();
     651                                } else if (attribute.equals("logging")) {
     652                                        UserSettings.Logging = avp.getBooleanValue();
     653                                } else if (attribute.equals("itemtemplate")) {
     654                                        UserSettings.ItemTemplate = ((Text) item).getTemplateForm();
     655                                } else if (attribute.equals("annotationtemplate")) {
     656                                        UserSettings.AnnotationTemplate = ((Text) item)
     657                                                        .getTemplateForm();
     658                                } else if (attribute.equals("statstemplate")) {
     659                                        UserSettings.StatTemplate = ((Text) item).getTemplateForm();
     660                                } else if (attribute.equals("commenttemplate")) {
     661                                        UserSettings.CodeCommentTemplate = ((Text) item)
     662                                                        .getTemplateForm();
     663                                } else if (attribute.equals("dottemplate")) {
     664                                        UserSettings.DotTemplate = ((Text) item).getTemplateForm();
     665                                } else if (attribute.equals("framesetdir")) {
     666                                        String dir = getDir(avp.getValue());
     667                                        if (dir != null) {
     668                                                UserSettings.FrameDirs.add(dir);
     669                                        }
     670                                } else if (attribute.equals("logdir")) {
     671                                        org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue());
     672                                } else if (attribute.equals("imagedir")) {
     673                                        String dir = getDir(avp.getValue());
     674                                        if (dir != null)
     675                                                UserSettings.ImageDirs.add(0, dir);
     676                                } else if (attribute.equals("threading")) {
     677                                        UserSettings.Threading = avp.getBooleanValue();
     678                                } else if (attribute.equals("colorwheel")) {
     679                                        Item.COLOR_WHEEL = getColorWheel(item);
     680                                } else if (attribute.equals("fillcolorwheel")) {
     681                                        Item.FILL_COLOR_WHEEL = getColorWheel(item);
     682                                } else if (attribute.equals("backgroundcolorwheel")) {
     683                                        Frame.COLOR_WHEEL = getColorWheel(item);
     684                                } else if (attribute.equals("framesetdirs")) {
     685                                        UserSettings.FrameDirs.addAll(getDirs(item));
     686                                } else if (attribute.equals("imagedirs")) {
     687                                        UserSettings.ImageDirs.addAll(getDirs(item));
     688                                } else if (attribute.equals("style")) {
     689                                        UserSettings.Style = getStyle(item.getChild());
     690                                } else {
     691                                        errors.add(attributeFullCase
     692                                                        + " is not a profile frame tag");
     693                                }
     694                        } catch (Exception e) {
     695                                e.printStackTrace();
     696                                errors.add("Error parsing [" + item.getText() + "] on "
     697                                                + profile.getName());
    687698                        }
    688699                }
     
    692703
    693704        private static List<Text> getStyle(Frame child) {
     705                if (child == null)
     706                        return new LinkedList<Text>();
     707
    694708                List<Text> style = new ArrayList<Text>(8);
    695709                for (int i = 0; i < 10; i++) {
     
    750764                        return alt;
    751765
    752                 String value = new AttributeValuePair(item.getText()).getValue().trim();
    753                 if (value.length() > 0) {
    754                         item.setLink(value);
    755                         return value;
    756                 } else if (item.getLink() != null)
    757                         return item.getLink();
     766                AttributeValuePair avp = new AttributeValuePair(item.getText());
     767                assert (avp != null);
     768               
     769                if (avp.hasPair()) {
     770                        item.setLink(avp.getValue());
     771                        return avp.getValue();
     772                } else if (item.getLink() != null) {
     773                        return item.getAbsoluteLink();
     774                }
    758775
    759776                return alt;
     
    11251142        }
    11261143
     1144        public static Item onItem(float floatX, float floatY,
     1145                        boolean changeLastEdited) {
     1146                return onItem(DisplayIO.getCurrentFrame(), floatX, floatY,
     1147                                changeLastEdited);
     1148        }
     1149
    11271150        /**
    11281151         * Searches through the list of items on this frame to find one at the given
     
    11351158         * @return The Item at the given coordinates, or NULL if none is found.
    11361159         */
    1137         public static Item onItem(Frame toCheck, float floatX, float floatY) {
     1160        public static Item onItem(Frame toCheck, float floatX, float floatY,
     1161                        boolean bResetLastEdited) {
    11381162                // System.out.println("MouseX: " + floatX + " MouseY: " + floatY);
    11391163                int x = Math.round(floatX);
     
    11721196                        // otherwise, the mouse is on the frame
    11731197                } else {
    1174                         if (LastEdited != null && /*
    1175                                                                                  * LastEdited.isVisible() &&
    1176                                                                                  */LastEdited.contains(x, y)
    1177                                         && !FreeItems.getInstance().contains(LastEdited)
    1178                                         && LastEdited.getParent() == DisplayIO.getCurrentFrame()
    1179                                         && LastEdited.getParent().getItems().contains(LastEdited)) {
    1180                                 LastEdited.setPermission(Permission.full);
    1181                                 return LastEdited;
    1182                         } else {
    1183                                 setLastEdited(null);
     1198                        if (LastEdited != null) {
     1199                                if (LastEdited.contains(x, y)
     1200                                                && !FreeItems.getInstance().contains(LastEdited)
     1201                                                && LastEdited.getParent() == DisplayIO
     1202                                                                .getCurrentFrame()
     1203                                                && LastEdited.getParent().getItems().contains(
     1204                                                                LastEdited)) {
     1205                                        LastEdited.setPermission(Permission.full);
     1206                                        return LastEdited;
     1207                                } else if (bResetLastEdited) {
     1208                                        setLastEdited(null);
     1209                                }
    11841210                        }
    11851211                        ArrayList<Item> checkList = new ArrayList<Item>();
     
    12361262        public synchronized static Item getCurrentItem() {
    12371263                return onItem(DisplayIO.getCurrentFrame(), DisplayIO.getMouseX(),
    1238                                 FrameMouseActions.getY());
     1264                                FrameMouseActions.getY(), true);
    12391265        }
    12401266
     
    14331459
    14341460                yPos += spacing;
    1435                 profile.addText(xPos, yPos, "@HomeFrame: " + profile.getName(), null,
     1461                profile.addText(xPos, yPos, "@HomeFrame", null,
    14361462                                profile.getName());
    14371463                yPos += spacing;
    14381464                String defaultFrameName = profile.getFramesetName() + "0";
    1439                 profile.addText(xPos, yPos, "@DefaultFrame: " + defaultFrameName, null,
     1465                profile.addText(xPos, yPos, "@DefaultFrame", null,
    14401466                                defaultFrameName);
    14411467                yPos += spacing;
     
    15391565
    15401566        public static void setLastEdited(Text lastEdited) {
     1567
    15411568                // If the lastEdited is being changed then check if its @i
    15421569                Frame toReparse = null;
    15431570                Frame toRecalculate = null;
    1544                 if (LastEdited != null) {
     1571                Frame toUpdateObservers = null;
     1572
     1573                if (LastEdited == null) {
     1574                        // System.out.print("N");
     1575                } else if (LastEdited != null) {
     1576                        // System.out.print("T");
     1577                        Frame parent = LastEdited.getParentOrCurrentFrame();
     1578
    15451579                        if (lastEdited != LastEdited) {
    15461580                                if (LastEdited.startsWith("@i")) {
     
    15741608                                                }
    15751609                                        }
    1576                                         toReparse = LastEdited.getParent();
     1610                                        toReparse = parent;
    15771611                                } else if (LastEdited.recalculateWhenChanged()) {
    1578                                         toRecalculate = LastEdited.getParentOrCurrentFrame();
     1612                                        toRecalculate = parent;
     1613                                }
     1614
     1615                                if (parent.hasObservers()) {
     1616                                        toUpdateObservers = parent;
    15791617                                }
    15801618                                // Update the formula if in XRay mode
     
    15841622                        }
    15851623                        if (lastEdited != LastEdited && LastEdited.getText().length() == 0) {
    1586                                 LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);
     1624                                parent.removeItem(LastEdited);
    15871625                        }
    15881626                }
     
    15921630                        if (toReparse != null) {
    15931631                                Parse(toReparse, false, false);
    1594                         } else if (toRecalculate != null) {
    1595                                 toRecalculate.recalculate();
     1632                        } else {
     1633                                if (toRecalculate != null) {
     1634                                        toRecalculate.recalculate();
     1635                                }
     1636
     1637                                if (toUpdateObservers != null) {
     1638                                        toUpdateObservers.notifyObservers(false);
     1639                                }
    15961640                        }
    15971641                }
  • trunk/src/org/expeditee/gui/MessageBay.java

    r336 r376  
    262262                        boolean displayAlways, String action) {
    263263                List<String> actions = new LinkedList<String>();
    264                 actions.add(action);
     264                if (action != null)
     265                        actions.add(action);
    265266                return displayMessage(message, link, actions, color, displayAlways);
    266267        }
  • trunk/src/org/expeditee/gui/MouseEventRouter.java

    r328 r376  
    3939
    4040        private Container _contentPane;
    41        
     41
    4242        private List<MouseListener> _mouseListeners = new LinkedList<MouseListener>();
     43
    4344        private List<MouseMotionListener> _mouseMotionListeners = new LinkedList<MouseMotionListener>();
     45
    4446        private List<MouseWheelListener> _mouseWheelListeners = new LinkedList<MouseWheelListener>();
    4547
     
    5052         *
    5153         * @param menuBar
    52          *              Must not be null.
     54         *            Must not be null.
    5355         *
    5456         * @param contentPane
    55          *              Must not be null.
     57         *            Must not be null.
    5658         */
    5759        public MouseEventRouter(JMenuBar menuBar, Container contentPane) {
     
    6971                this._contentPane = contentPane;
    7072        }
    71        
     73
    7274        /**
    7375         * Listens only to events to frames... i.e. to exeditee, not to widgets.
    7476         *
    7577         * @param listener
    76          *              The listener to add.
     78         *            The listener to add.
    7779         */
    7880        public void addExpediteeMouseListener(MouseListener listener) {
    79                 if (listener == null) throw new NullPointerException("listener");
     81                if (listener == null)
     82                        throw new NullPointerException("listener");
    8083                _mouseListeners.add(listener);
    8184        }
    82        
    83        
     85
    8486        public void removeExpediteeMouseListener(MouseListener listener) {
    85                 if (listener == null) throw new NullPointerException("listener");
     87                if (listener == null)
     88                        throw new NullPointerException("listener");
    8689                _mouseListeners.remove(listener);
    8790        }
    88        
     91
    8992        public void addExpediteeMouseMotionListener(MouseMotionListener listener) {
    90                 if (listener == null) throw new NullPointerException("listener");
     93                if (listener == null)
     94                        throw new NullPointerException("listener");
    9195                _mouseMotionListeners.add(listener);
    9296        }
    93        
     97
    9498        public void removeExpediteeMouseMotionListener(MouseMotionListener listener) {
    95                 if (listener == null) throw new NullPointerException("listener");
     99                if (listener == null)
     100                        throw new NullPointerException("listener");
    96101                _mouseMotionListeners.remove(listener);
    97102        }
    98        
     103
    99104        public void addExpediteeMouseWheelListener(MouseWheelListener listener) {
    100                 if (listener == null) throw new NullPointerException("listener");
     105                if (listener == null)
     106                        throw new NullPointerException("listener");
    101107                _mouseWheelListeners.add(listener);
    102108        }
    103        
     109
    104110        public void removeExpediteeMouseWheelListener(MouseWheelListener listener) {
    105                 if (listener == null) throw new NullPointerException("listener");
     111                if (listener == null)
     112                        throw new NullPointerException("listener");
    106113                _mouseWheelListeners.remove(listener);
    107114        }
     
    109116        /**
    110117         * Conceal event catching from outside
     118         *
    111119         * @author Brook Novak
    112120         */
    113121        private class EventCatcher implements AWTEventListener {
    114                
     122
    115123                /**
    116124                 * All events for every component in frame are fired to here
     
    121129                        }
    122130                }
    123                
     131
    124132        }
    125133
     
    133141         */
    134142        private void routeMouseEvent(MouseEvent e) {
    135                
     143
    136144                _currentMouseEvent = e;
    137                
     145
    138146                // First convert the point to expeditee space
    139147                Point containerPoint = SwingUtilities.convertPoint(e.getComponent(), e
     
    158166                        // whether an expeditee item is currently picked up
    159167                        boolean forwardToExpiditee = false;
    160                         boolean isOverPopup = PopupManager.getInstance().isPointOverPopup(containerPoint);
     168                        boolean isOverPopup = PopupManager.getInstance().isPointOverPopup(
     169                                        containerPoint);
    161170                        if (isOverPopup) {
    162171                                // Popups have highest preference
    163172                                // forwardToExpiditee = false...
    164                                
    165                                 // If there ate items in free space - keep them moving with the cursor over the
     173
     174                                // If there ate items in free space - keep them moving with the
     175                                // cursor over the
    166176                                // popups.
    167177                                if (!FreeItems.getInstance().isEmpty()) {
     
    169179                                }
    170180
    171                         // Note: all frame.content pane events belong to expeditee
     181                                // Note: all frame.content pane events belong to expeditee
    172182                        } else if (e.getSource() == _contentPane
    173183                                        || e.getSource() == Browser._theBrowser
    174184                                        || !FreeItems.getInstance().isEmpty()) {
    175185                                forwardToExpiditee = true;
    176                         } else if (DisplayIO.getCurrentFrame() != null) { // is mouse over
    177                                 // a specific
    178                                 // expeditee
    179                                 // item?
     186                        } else if (DisplayIO.getCurrentFrame() != null) {
     187                                /* is mouse over a specific expeditee item? */
    180188                                // NOTE: Do not use FrameUtils.getCurrentItem() - thats relevent
    181189                                // for old mouse position only
     
    188196                                // when passing mouse events!!!
    189197                                forwardToExpiditee = (FrameUtils.onItem(DisplayIO
    190                                                 .getCurrentFrame(), containerPoint.x, containerPoint.y) != null);
    191                         }
    192                        
     198                                                .getCurrentFrame(), containerPoint.x, containerPoint.y,
     199                                                true) != null);
     200                        }
     201
    193202                        // Create artificial mouse event and forward it to expeditee
    194                         MouseEvent expediteeEvent = SwingUtilities.convertMouseEvent(
    195                                         e.getComponent(), e, _contentPane);
    196                        
     203                        MouseEvent expediteeEvent = SwingUtilities.convertMouseEvent(e
     204                                        .getComponent(), e, _contentPane);
     205
    197206                        // NOTE: Convert util masks-out the needed extensions
    198207                        MouseEvent withExtensions = null;
     
    205214                                switch (e.getID()) {
    206215                                case MouseEvent.MOUSE_MOVED:
    207                                        
     216
    208217                                        for (MouseMotionListener listener : _mouseMotionListeners) {
    209218                                                listener.mouseMoved(expediteeEvent);
    210219                                        }
    211                                        
     220
    212221                                        // Ensure that expiditee has focus only if no popups exist
    213222                                        if (Browser._theBrowser != null
     
    221230
    222231                                        break;
    223                                        
     232
    224233                                case MouseEvent.MOUSE_CLICKED:
    225                                        
    226                                         withExtensions = duplicateMouseEvent(expediteeEvent, e.getModifiers() | e.getModifiersEx());
    227                                        
     234
     235                                        withExtensions = duplicateMouseEvent(expediteeEvent, e
     236                                                        .getModifiers()
     237                                                        | e.getModifiersEx());
     238
    228239                                        for (MouseListener listener : _mouseListeners) {
    229240                                                listener.mouseClicked(withExtensions);
    230241                                        }
    231                                        
    232                                         break;
    233                                        
     242
     243                                        break;
     244
    234245                                case MouseEvent.MOUSE_PRESSED:
    235                                        
    236                                         withExtensions = duplicateMouseEvent(expediteeEvent, e.getModifiers() | e.getModifiersEx());
     246
     247                                        withExtensions = duplicateMouseEvent(expediteeEvent, e
     248                                                        .getModifiers()
     249                                                        | e.getModifiersEx());
    237250
    238251                                        for (MouseListener listener : _mouseListeners) {
    239252                                                listener.mousePressed(withExtensions);
    240253                                        }
    241                                        
    242                                         break;
    243                                        
     254
     255                                        break;
     256
    244257                                case MouseEvent.MOUSE_RELEASED:
    245                                         withExtensions = duplicateMouseEvent(expediteeEvent, e.getModifiers() | e.getModifiersEx());
     258                                        withExtensions = duplicateMouseEvent(expediteeEvent, e
     259                                                        .getModifiers()
     260                                                        | e.getModifiersEx());
    246261
    247262                                        for (MouseListener listener : _mouseListeners) {
     
    251266                                        break;
    252267                                case MouseEvent.MOUSE_WHEEL:
    253                                         MouseWheelEvent mwe = (MouseWheelEvent)expediteeEvent;
     268                                        MouseWheelEvent mwe = (MouseWheelEvent) expediteeEvent;
    254269                                        for (MouseWheelListener listener : _mouseWheelListeners) {
    255270                                                listener.mouseWheelMoved(mwe);
     
    274289
    275290                        } else {
    276                                
     291
    277292                                // Keep expeditees mouse X/Y updated
    278293                                FrameMouseActions.MouseX = expediteeEvent.getX();
     
    283298                                // to give visual feedback yo users such that swing has focus.
    284299                                Item i = FrameMouseActions.getlastHighlightedItem();
    285                                 if (i != null && i.getHighlightMode() != Item.HighlightMode.None) {
    286                                         FrameGraphics.changeHighlightMode(i, Item.HighlightMode.None);
     300                                if (i != null
     301                                                && i.getHighlightMode() != Item.HighlightMode.None) {
     302                                        FrameGraphics.changeHighlightMode(i,
     303                                                        Item.HighlightMode.None);
    287304                                }
    288305
     
    297314                                                }
    298315                                        }
    299                                         // Auto-hide popups when user click on something other other than
     316                                        // Auto-hide popups when user click on something other other
     317                                        // than
    300318                                        // a popup - and is not a on a popup invoker
    301                                 } else if (!isOverPopup && e.getID() == MouseEvent.MOUSE_PRESSED &&
    302                                                 !PopupManager.getInstance().isInvoker(e.getComponent())) {
     319                                } else if (!isOverPopup
     320                                                && e.getID() == MouseEvent.MOUSE_PRESSED
     321                                                && !PopupManager.getInstance().isInvoker(
     322                                                                e.getComponent())) {
    303323                                        PopupManager.getInstance().hideAutohidePopups();
    304324                                }
     
    327347                return false;
    328348        }
    329        
     349
    330350        private MouseEvent duplicateMouseEvent(MouseEvent e, int modifiers) {
    331                 return new MouseEvent(
    332                                 e.getComponent(),
    333                                 e.getID(),
    334                                 e.getWhen(),
    335                                 modifiers,
    336                                 e.getX(),
    337                                 e.getY(),
    338                                 /**The below methods are not compatible with Java 1.5*/
    339                                 /*e.getXOnScreen(),
    340                                 e.getYOnScreen(),*/
    341                                 e.getClickCount(),
    342                                 e.isPopupTrigger(),
    343                                 e.getButton());
     351                return new MouseEvent(e.getComponent(), e.getID(), e.getWhen(),
     352                                modifiers, e.getX(), e.getY(),
     353                                /** The below methods are not compatible with Java 1.5 */
     354                                /*
     355                                 * e.getXOnScreen(), e.getYOnScreen(),
     356                                 */
     357                                e.getClickCount(), e.isPopupTrigger(), e.getButton());
    344358        }
    345359
    346360        public static MouseEvent getCurrentMouseEvent() {
    347                
     361
    348362                return _currentMouseEvent;
    349363
  • trunk/src/org/expeditee/gui/Reminders.java

    r348 r376  
    1111
    1212        public synchronized static void init(final Frame reminderFrame) {
     13                if(reminderFrame == null)
     14                        return;
     15               
    1316                for (Text text : reminderFrame.getBodyTextItems(false)) {
    1417                        try {
  • trunk/src/org/expeditee/io/AbstractHTMLWriter.java

    r348 r376  
    99
    1010import org.expeditee.gui.Frame;
     11import org.expeditee.gui.FrameIO;
    1112import org.expeditee.gui.MessageBay;
    1213import org.expeditee.gui.UserSettings;
     
    2324                _format = ".html";
    2425                super.initialise(start, writer);
     26
     27                // Clear the filesFolder
     28                String filesFolderName = FrameIO.EXPORTS_DIR + getFilesFolder();
     29                if (filesFolderName.length() > 0) {
     30                        File filesFolder = new File(filesFolderName);
     31                        for (File f : filesFolder.listFiles()) {
     32                                f.delete();
     33                        }
     34                        filesFolder.delete();
     35                        _filesFolderName = null;
     36                }
    2537
    2638                _writer.write("<html>" + ItemWriter.NEW_LINE);
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r348 r376  
    7575                        _ItemTags.put("I", Item.class.getMethod("getAnchorBottom", param));
    7676                        _ItemTags.put("P", Item.class.getMethod("getPosition", param));
     77                        _ItemTags.put("T", Text.class.getMethod("getText", param));
    7778                        _ItemTags.put("F", Item.class.getMethod("getLink", param));
    7879                        _ItemTags.put("X", Item.class.getMethod("getAction", param));
     
    107108                        // Store the formula in the text property NOT the answer
    108109                        _ItemTags.put("J", Item.class.getMethod("getFormula", param));
    109                         _ItemTags.put("T", Text.class.getMethod("getText", param));
    110110
    111111                        _ItemTags.put("a", Text.class.getMethod("getWordSpacing", param));
  • trunk/src/org/expeditee/io/DefaultTreeWriter.java

    r290 r376  
    1515
    1616        private int _indent = 0;
    17        
     17
    1818        // the list of frames currently being processed
    1919        private Stack<FrameCounter> _frames = new Stack<FrameCounter>();
     
    8181
    8282                        Frame next = FrameIO.LoadFrame(cur.frame);
     83
    8384                        if (next == null) {
    8485                                return;
    8586                        }
     87
     88                        Text title = next.getTitleItem();
    8689
    8790                        // the items on the frame currently being processed.
     
    109112                                // ignore annotation and framenames
    110113                                if (item.getID() >= 0) {
    111                                         //Only follow the links of text items
    112                                         if (item instanceof Text && item.getLink() != null
    113                                                         && !item.isAnnotation()) {
     114                                        // Only follow the links of non annotation text items
     115                                        boolean followLink = item instanceof Text
     116                                                        && item.getLink() != null
     117                                                        && (!item.isAnnotation() /*|| item.getText()
     118                                                                        .toLowerCase().equals("@next")*/);
     119
     120                                        if (followLink) {
    114121                                                cur.index = i;
    115122                                                _frames.push(cur);
     
    139146                                                // Dont write out the title here because it is written
    140147                                                // out earlier
    141                                         } else if (item != next.getTitleItem())
     148                                        } else if (item != title)
    142149                                                this.writeItem(item);
    143150                                }
     
    177184                }
    178185        }
    179        
     186
    180187        protected int getIndent() {
    181188                return _indent;
  • trunk/src/org/expeditee/io/HTMLWriter.java

    r362 r376  
    88import org.expeditee.actions.Misc;
    99import org.expeditee.gui.FrameIO;
     10import org.expeditee.items.FramePicture;
    1011import org.expeditee.items.Item;
    1112import org.expeditee.items.Picture;
     
    1415import sun.awt.image.ToolkitImage;
    1516
    16 public class HTMLBWriter extends AbstractHTMLWriter {
     17public class HTMLWriter extends AbstractHTMLWriter {
    1718
    1819        @Override
     
    2021                        throws IOException {
    2122                int indent = getIndent();
    22                 if(indent == 0)
     23                if (indent == 0)
    2324                        return;
    24                
     25
    2526                String heading = toWrite.getText();
    2627                String tag = "h" + indent;
     
    4142        @Override
    4243        protected void writePicture(Picture pic) throws IOException {
    43                 //TODO: Deal with cropped images!
    44                
    45                 Image image = pic.getImage();
     44                // TODO handle different colored @f's of the same frame
     45                // TODO handle cropped images
     46                Image image = null;
     47
     48                if (pic instanceof FramePicture || pic.isCropped()) {
     49                        image = pic.getImage();
     50                        // Crop the image
     51                        BufferedImage bufferedImage = new BufferedImage(pic
     52                                        .getUnscaledWidth(), pic.getUnscaledHeight(),
     53                                        BufferedImage.TYPE_INT_ARGB);
     54                        bufferedImage.getGraphics().drawImage(image, 0, 0,
     55                                        pic.getUnscaledWidth(), pic.getUnscaledHeight(),
     56                                        pic.getStart().x, pic.getStart().y, pic.getEnd().x,
     57                                        pic.getEnd().y, null);
     58                        image = bufferedImage;
     59                } else {
     60                        image = pic.getImage();
     61                }
     62
    4663                String filesFolder = getFilesFolder();
    4764                String fileName;
    4865                // If its a bufferedImage then just write it out to the files directory
    49                 //This means it is probably a FrameImage
    50                 if (image instanceof BufferedImage || image instanceof ToolkitImage) {
     66                // This means it is probably a FrameImage
     67                if (image instanceof BufferedImage) {
    5168                        String link = pic.getAbsoluteLink();
    5269                        // Account for the possiblitly of an unlinked buffered image
    5370                        fileName = link == null ? ("Image" + pic.getID()) : link;
    54                         fileName = Misc.SaveImage((BufferedImage) image, "PNG", FrameIO.EXPORTS_DIR
    55                                         + filesFolder, fileName);
    56                 } else {//It is a normal Image stored somewhere
    57                        
    58                         Text source = pic.getSource();
    59 
    60                         fileName = source.getFirstLine();
    61                         fileName = fileName.substring(fileName.indexOf(":") + 1).trim();
     71                        fileName = Misc.SaveImage((BufferedImage) image, "PNG",
     72                                        FrameIO.EXPORTS_DIR + filesFolder, fileName);
     73                } else {// It is a normal Image stored somewhere
     74                        fileName = pic.getName();
    6275
    6376                        String oldImageName = FrameIO.IMAGES_PATH + fileName;
  • trunk/src/org/expeditee/io/TXTWriter.java

    r306 r376  
    1010import org.expeditee.items.Text;
    1111
    12 public class TXTWriter extends DefaultTreeWriter{
     12public class TXTWriter extends DefaultTreeWriter {
    1313
    1414        private boolean _join = false;
     
    7272        @Override
    7373        protected void writeText(Text text) throws IOException {
    74                 for (String s : text.getTextList()) {
     74                String s = text.getText();
    7575
    76                         for (int i = 0; i < _indent; i++)
    77                                 _writer.write("\t");
     76                for (int i = 0; i < _indent; i++)
     77                        _writer.write("\t");
    7878
    79                         _writer.write(s);
    80                         _writer.write(ItemWriter.NEW_LINE);
    81                 }
     79                _writer.write(s);
     80                _writer.write(ItemWriter.NEW_LINE);
    8281
    8382                if (!_join)
  • trunk/src/org/expeditee/io/oldHTMLWriter.java

    r362 r376  
    1010import org.expeditee.items.Text;
    1111
    12 public class HTMLWriter extends DefaultTreeWriter {
     12public class oldHTMLWriter extends DefaultTreeWriter {
    1313
    1414        private int _indent = 0;
  • trunk/src/org/expeditee/items/Circle.java

    r311 r376  
    143143                                + Math.pow(Math.abs(_center.getY() - y), 2));
    144144
    145                 return Math.abs(distance - radius) < Item.getGravity() * 2;
     145                return Math.abs(distance - radius) < getGravity() * 2;
    146146        }
    147147
     
    337337                _line.refreshStroke(thick);
    338338        }
     339       
     340        @Override
     341        public boolean isConnectedToAnnotation() {
     342                return false;
     343        }
    339344}
  • trunk/src/org/expeditee/items/Dot.java

    r282 r376  
    2626        // Standard Item variables
    2727
    28         private static final int _MINIMUM_DOT_SIZE = 6;
     28        //private static final int _MINIMUM_DOT_SIZE = 6;
    2929
    3030        private static final int MINIMUM_DOT_SIZE = 2;
     
    120120                        // Draw the highlighting rectangle surrounding the dot
    121121                        // this is drawn even if its part of a rectangle
     122                       
     123                        if(isVectorItem())
     124                                updatePolygon();
     125                       
    122126                        Rectangle rect = getPolygon().getBounds();
    123127                        if (_mode == HighlightMode.Enclosed ||
     
    177181                int thick = Math.round(getThickness());
    178182                // Sets a minimum size for the dot
    179                 thick = Math.max(thick, _MINIMUM_DOT_SIZE);
     183                thick = Math.max(thick, getGravity() * 2);
    180184
    181185                int x = getX() - thick / 2;
  • trunk/src/org/expeditee/items/Item.java

    r362 r376  
    2626import org.expeditee.actions.Misc;
    2727import org.expeditee.actions.Simple;
     28import org.expeditee.gui.AttributeValuePair;
    2829import org.expeditee.gui.DisplayIO;
    2930import org.expeditee.gui.Frame;
     
    3132import org.expeditee.gui.FrameIO;
    3233import org.expeditee.gui.FrameKeyboardActions;
     34import org.expeditee.gui.FrameMouseActions;
    3335import org.expeditee.gui.FrameUtils;
    3436import org.expeditee.gui.FreeItems;
     
    229231        }
    230232
    231         public static int getGravity() {
     233        public int getGravity() {
     234                if (isVectorItem()) {
     235                        return 2;
     236                }
    232237                return org.expeditee.gui.UserSettings.Gravity;
    233238        }
     
    323328
    324329        protected int _highlightThickness = 2;
     330
     331        protected int _vectorHighlightThickness = 1;
    325332
    326333        // arrowhead parameters
     
    700707        public Color getHighlightColor() {
    701708                if (_highlightColor.equals(getPaintColor()))
    702                         return ALTERNATE_HIGHLIGHT;
    703                 return _highlightColor;
     709                        return getAlternateHighlightColor();
     710                return getDefaultHighlightColor();
    704711        }
    705712
     
    762769        public boolean hasFormula() {
    763770                return _formula != null;
     771        }
     772       
     773        public boolean hasAttributeValuePair() {
     774                return _attributeValuePair != null && _attributeValuePair.hasPair();
    764775        }
    765776
     
    853864
    854865        protected Color getPaintHighlightColor() {
    855                 Color highlightColor = _highlightColor;
     866                Color highlightColor = getDefaultHighlightColor();
    856867                if (hasVisibleBorder()) {
    857868                        if (getPaintBorderColor().equals(highlightColor)) {
    858                                 highlightColor = ALTERNATE_HIGHLIGHT;
     869                                highlightColor = getDefaultHighlightColor();
    859870                        }
    860871                } else if (getPaintBackgroundColor().equals(highlightColor)) {
    861                         highlightColor = ALTERNATE_HIGHLIGHT;
     872                        highlightColor = getDefaultHighlightColor();
    862873                }
    863874                if (getParent() != null
     
    867878                if (hasVisibleBorder()) {
    868879                        if (highlightColor.equals(getBorderColor())
    869                                         && getThickness() == _highlightThickness) {
     880                                        && getThickness() == getHighlightThickness()) {
    870881                                highlightColor = new Color(highlightColor.getRed(),
    871882                                                highlightColor.getGreen(), highlightColor.getBlue(),
     
    875886
    876887                return highlightColor;
     888        }
     889
     890        static final int BRIGHTNESS = 185;
     891
     892        protected Color getDefaultHighlightColor() {
     893                if (isVectorItem()
     894                                && !this.contains(FrameMouseActions.getX(), FrameMouseActions
     895                                                .getY())) {
     896                        return new Color(255, BRIGHTNESS, BRIGHTNESS);
     897                }
     898                return _highlightColor;
     899        }
     900
     901        protected Color getAlternateHighlightColor() {
     902                if (isVectorItem()
     903                                && !this.contains(FrameMouseActions.getX(), FrameMouseActions
     904                                                .getY())) {
     905                        return new Color(BRIGHTNESS, BRIGHTNESS, 255);
     906                }
     907                return ALTERNATE_HIGHLIGHT;
     908        }
     909
     910        protected int getHighlightThickness() {
     911                if (isVectorItem())
     912                        return _vectorHighlightThickness;
     913                return _highlightThickness;
    877914        }
    878915
     
    24612498        private Overlay _overlay = null;
    24622499
     2500        protected AttributeValuePair _attributeValuePair = null;
     2501
    24632502        /**
    24642503         * For now there can only be one enclosure per item
     
    27452784                updatePolygon();
    27462785        }
     2786
     2787        protected boolean isVectorItem() {
     2788                return _editTarget != this;
     2789        }
     2790
     2791        public AttributeValuePair getAttributeValuePair() {
     2792                if(_attributeValuePair  == null){
     2793                        _attributeValuePair = new AttributeValuePair(getText());
     2794                }
     2795                return _attributeValuePair;
     2796        }
     2797
     2798        /*private static Set<Object> _locks = new HashSet<Object>();
     2799
     2800        public static void lock(Object itemToLock) {
     2801                _locks.add(itemToLock);
     2802        }
     2803       
     2804        public static void unlock(Object itemToUnlock) {
     2805                _locks.remove(itemToUnlock);
     2806        }
     2807       
     2808        public static boolean isLocked(Object item) {
     2809                return _locks.contains(item);
     2810        }*/
    27472811}
  • trunk/src/org/expeditee/items/Permission.java

    r115 r376  
    11package org.expeditee.items;
    22
    3 public enum Permission{
     3public enum Permission {
    44        none, followLinks, copy, createFrames, full;
    55
    66        /**
    7          * Converts the given Expeditee justification code into a int corresponding
    8          * to the constants defined in Item.
     7         * Converts the given Expeditee permission code into a int corresponding to
     8         * the constants defined in Item.
    99         *
    1010         * @param permissionCode
    11          *            The Expeditee justification code to convert
     11         *            The Expeditee permission code to convert
    1212         * @return The resulting int corresponding to one of the constants defined
    1313         *         in Item
     
    1616                return getPermission(permissionCode, Permission.full);
    1717        }
    18        
    19         public static Permission getPermission(String permissionCode, Permission defaultPermission) {
     18
     19        public static Permission getPermission(String permissionCode,
     20                        Permission defaultPermission) {
    2021                if (permissionCode == null)
    2122                        return defaultPermission;
    22                
     23
    2324                permissionCode = permissionCode.trim().toLowerCase();
    2425                if (permissionCode.length() == 0)
    2526                        return defaultPermission;
    26                
     27
    2728                // if it is a single char just match the first character
    28                 try{
     29                try {
    2930                        return values()[Integer.parseInt(permissionCode)];
    3031                        // Otherwise match the whole string
    31                 }catch(Exception ex){
    32                         try{
    33                         return valueOf(permissionCode);
    34                         }catch (Exception e) {
     32                } catch (Exception ex) {
     33                        try {
     34                                return valueOf(permissionCode);
     35                        } catch (Exception e) {
    3536                        }
    3637                }
     
    3940                return defaultPermission;
    4041        }
    41 
    4242
    4343        public int getCode() {
     
    5252                return p1.ordinal() < p2.ordinal() ? p1 : p2;
    5353        }
    54        
     54
    5555        public static Permission max(Permission p1, Permission p2) {
    5656                return p1.ordinal() > p2.ordinal() ? p1 : p2;
  • trunk/src/org/expeditee/items/Picture.java

    r311 r376  
    6464        private Point _cropEnd = null;
    6565
    66         private Point _start = new Point(0, 0);;
    67 
    68         private Point _end = new Point(0, 0);;
     66        private Point _start = new Point(0, 0);
     67
     68        private Point _end = new Point(0, 0);
    6969
    7070        private boolean _showCropping = false;
     
    277277        }
    278278
     279        public Point getStart() {
     280                return _start;
     281        }
     282       
     283        public Point getEnd() {
     284                return _end;
     285        }
     286       
    279287        /**
    280288         * Gets the width with which the picture is displayed on the screen.
     
    354362                        g.drawPolygon(getPolygon());
    355363                }
    356                
     364
    357365                if (isHighlighted()) {
    358366                        Stroke borderStroke = new BasicStroke(1, CAP, JOIN);
     
    361369                        g.drawPolygon(getPolygon());
    362370                }
    363         }
    364        
     371               
     372                //System.out.print("p_");       
     373        }
     374
    365375        @Override
    366376        public Color getHighlightColor() {
     
    484494
    485495        public Image getCroppedImage() {
    486                 if(_image == null)
     496                if (_image == null)
    487497                        return null;
    488                 return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(
    489                                 _image.getSource(),
    490                                 new CropImageFilter(_start.x, _start.y, getWidth(), getHeight())));
     498                if (!isCropped()) {
     499                        return _image;
     500                }
     501               
     502                return Toolkit.getDefaultToolkit().createImage(
     503                                new FilteredImageSource(_image.getSource(),
     504                                                new CropImageFilter(_start.x, _start.y,
     505                                                                getUnscaledWidth(), getUnscaledHeight())));
     506        }
     507
     508        public int getUnscaledWidth() {
     509                return _end.x - _start.x;
     510        }
     511
     512        public int getUnscaledHeight() {
     513                return _end.y - _start.y;
     514        }
     515
     516        /**
     517         * @return true if this is a cropped image.
     518         */
     519        public boolean isCropped() {
     520                return _end.x != 0 || _end.y != 0 || _start.y != 0 || _start.x != 0;
    491521        }
    492522
     
    616646
    617647        }
    618        
    619         @Override
    620         public void scale(Float scale, int originX, int originY){
     648
     649        @Override
     650        public void scale(Float scale, int originX, int originY) {
    621651                setScale(getScale() * scale);
    622652                super.scale(scale, originX, originY);
  • trunk/src/org/expeditee/items/Text.java

    r371 r376  
    259259
    260260        /**
    261          * Sets the text displayed on the screen to the given String
     261         * Sets the text displayed on the screen to the given String. It does not
     262         * reset the formula, attributeValuePair or other cached values.
    262263         *
    263264         * @param text
     
    266267        @Override
    267268        public void setText(String text) {
    268                 if (_text != null && text.length() < _text.length())
    269                         invalidateAll();
     269                // if (_text != null && text.length() < _text.length())
     270                invalidateAll();
    270271                _text = new StringBuffer(text);
     272
     273                /*
     274                 * Adding the lines below remove formulas when moving in and out of XRay
     275                 * mode
     276                 */
     277                // Reset properties
     278                // setProcessedText(null);
     279                // setFormula(null);
    271280                rebuild(true);
    272281                invalidateAll();
     
    277286                        return;
    278287
    279                 setText(text.get(0));
    280                 for (int i = 1; i < text.size(); i++) {
    281                         appendText("\n");
    282                         appendText(text.get(i));
    283                 }
    284                 rebuild(false);
     288                invalidateAll();
     289
     290                StringBuffer sb = new StringBuffer();
     291
     292                for (int i = 0; i < text.size(); i++) {
     293                        sb.append(text.get(i)).append('\n');
     294                }
     295
     296                if (sb.length() > 0)
     297                        sb.deleteCharAt(sb.length() - 1);
     298
     299                setText(sb.toString());
     300
     301                rebuild(true);
     302                invalidateAll();
    285303        }
    286304
     
    589607                        // otherwise, we are inserting text
    590608                } else {
    591                         setProcessedText(null);
    592                         setFormula(null);
     609                        clearCache();
    593610                        // determine what line is being pointed to
    594611                        line = getLinePosition(mouseY);
     
    729746
    730747        /**
     748         *
     749         */
     750        private void clearCache() {
     751                _attributeValuePair = null;
     752                setProcessedText(null);
     753                setFormula(null);
     754        }
     755
     756        /**
    731757         * @param pos
    732758         * @return
     
    741767
    742768        public Point2D.Float moveCursor(int direction, float mouseX, float mouseY,
    743                         boolean setSelection) {
     769                        boolean setSelection, boolean wholeWord) {
    744770                if (setSelection) {
    745                         if (getSelectionSize() <= 0) {
     771                        if (!hasSelection()) {
    746772                                setSelectionStart(mouseX, mouseY);
    747773                        }
     774                } else {
     775                        // clearSelection();
    748776                }
    749777
     
    789817                                if (direction == LEFT) {
    790818                                        if (hit.getInsertionIndex() > 0) {
    791                                                 hit = _textLayouts.get(line).getNextLeftHit(hit);
    792                                                 // This takes care of the case where the user has put a
    793                                                 // hard
    794                                                 // line break in
    795                                                 if (line > 0
    796                                                                 && _text.charAt(hit.getInsertionIndex()
    797                                                                                 + _lineOffsets.get(line)) == '\n') {
     819
     820                                                char prevChar = ' ';
     821                                                do {
     822                                                        hit = _textLayouts.get(line).getNextLeftHit(hit);
     823
     824                                                        // Stop if at the start of the line
     825                                                        if (hit.getInsertionIndex() == 0)
     826                                                                break;
     827                                                        // Keep going if the char to the left is a
     828                                                        // letterOrDigit
     829                                                        prevChar = _text.charAt(hit.getInsertionIndex() - 1
     830                                                                        + _lineOffsets.get(line));
     831                                                } while (wholeWord
     832                                                                && Character.isLetterOrDigit(prevChar));
     833                                                // TODO Go to the start of the word instead of before
     834                                                // the word
     835                                                char nextChar = _text.charAt(hit.getInsertionIndex()
     836                                                                + _lineOffsets.get(line));
     837                                                /*
     838                                                 * This takes care of hard line break in
     839                                                 */
     840                                                if (line > 0 && nextChar == '\n') {
    798841                                                        line--;
    799842                                                        hit = _textLayouts.get(line)
     
    807850                                                hit = _textLayouts.get(line).getNextRightHit(
    808851                                                                _textLayouts.get(line).getCharacterCount() - 1);
     852                                                /*
     853                                                 * Skip the spaces at the end of a line with soft
     854                                                 * linebreak
     855                                                 */
    809856                                                while (hit.getCharIndex() > 0
    810857                                                                && _text.charAt(_lineOffsets.get(line)
     
    817864                                                        .getCharacterCount()) {
    818865                                                hit = _textLayouts.get(line).getNextRightHit(hit);
    819                                                 while (hit.getCharIndex() > 0
     866                                                // Skip whole word if needs be
     867                                                while (wholeWord
     868                                                                && hit.getCharIndex() > 0
    820869                                                                && hit.getCharIndex() < _textLayouts.get(line)
    821870                                                                                .getCharacterCount()
    822                                                                 && _text.charAt(_lineOffsets.get(line)
    823                                                                                 + hit.getCharIndex() - 1) == '\t')
     871                                                                && Character.isLetterOrDigit(_text
     872                                                                                .charAt(_lineOffsets.get(line)
     873                                                                                                + hit.getCharIndex() - 1)))
    824874                                                        hit = _textLayouts.get(line).getNextRightHit(hit);
    825875                                        } else if (line < _textLayouts.size() - 1) {
     
    15141564                        g.setColor(getPaintHighlightColor());
    15151565                        Stroke highlightStroke = new BasicStroke(
    1516                                         (float) _highlightThickness, CAP, JOIN);
     1566                                        (float) getHighlightThickness(), CAP, JOIN);
    15171567                        g.setStroke(highlightStroke);
    15181568                        if (HighlightMode.Enclosed.equals(getHighlightMode()))
     
    15531603                                }
    15541604
    1555                                 layout.draw(g, getX() + getJustOffset(layout), y);
     1605                                layout.draw(g, 1 + getX() + getJustOffset(layout), y);
    15561606
    15571607                                /*
     
    16081658                copy.setWidth(getWidth());
    16091659                copy.setFont(getFont());
    1610                 copy.setText(_text.toString());
     1660                if (hasFormula()) {
     1661                        copy.calculate(getFormula());
     1662                } else {
     1663                        copy.setText(_text.toString());
     1664                }
    16111665                copy.setHidden(!isVisible());
    16121666                // copy.setWidth(getWidth());
     
    17981852                Frame modelFrame = getParentOrCurrentFrame();
    17991853                if (modelFrame != null) {
    1800                         setRightMargin(getParentOrCurrentFrame().getNameItem().getX()
     1854                        setRightMargin(modelFrame.getNameItem().getX()
    18011855                                        - MARGIN_LEFT);
    18021856                } else {
     1857                        System.out.print("Error: text.resetTitlePosition, getParent or currentFrame returned null");
    18031858                        setRightMargin(MARGIN_LEFT);
    18041859                }
     
    18371892                Text template = this.copy();
    18381893                template.setID(-1);
    1839                 // The template must have text otherwise the bounds height will be
    1840                 // zero!!
    1841                 // This will stop escape drop down from working if there is no item
    1842                 // template
     1894                /*
     1895                 * The template must have text otherwise the bounds height will be
     1896                 * zero!! This will stop escape drop down from working if there is no
     1897                 * item template
     1898                 */
    18431899                template.setText("@");
    18441900                return template;
     
    19582014                        return false;
    19592015                }
     2016                formula = formula.replace(':', '=');
     2017
    19602018                String lowercaseFormula = formula.toLowerCase();
    19612019                ExpediteeJEP myParser = new ExpediteeJEP();
     
    19702028                                continue;
    19712029                        if (i instanceof Text && !i.isAnnotation()) {
    1972                                 AttributeValuePair pair = new AttributeValuePair(i.getText());
     2030                                AttributeValuePair pair = i.getAttributeValuePair();
    19732031                                if (pair.hasPair()) {
    19742032                                        try {
     
    19852043                                try {
    19862044                                        double value = pair.getDoubleValue();
    1987                                         myParser.addVariable("$" + nextVarNo++, value);
     2045                                        if (value != Double.NaN)
     2046                                                myParser.addVariable("$" + nextVarNo++, value);
    19882047                                } catch (NumberFormatException nfe) {
    19892048                                        continue;
     
    20222081                                this.setText(result);
    20232082                                this.setFormula(formula);
     2083
     2084                                if (!this.hasAction()) {
     2085                                        setActionMark(false);
     2086                                        setAction("extract formula");
     2087                                }
    20242088                        }
    20252089                } catch (Throwable e) {
    2026                         this.setText(getFormula());
     2090                        String formula2 = getFormula();
     2091                        this.setText(formula2);
     2092                        this.setFormula(formula2);
    20272093                        return false;
    20282094                }
     2095
     2096                _attributeValuePair = null;
     2097
    20292098                return true;
    20302099        }
     
    20422111                double enclosureArea = Double.MAX_VALUE;
    20432112                for (Item i : parent.getVisibleItems()) {
    2044                         // Go through all the enclosures looking for one that includes this
    2045                         // shape
     2113                        /*
     2114                         * Go through all the enclosures looking for one that includes this
     2115                         * item
     2116                         */
    20462117                        if (!seen.contains(i) && i.isEnclosed()) {
    20472118                                seen.addAll(i.getEnclosingDots());
     
    20642135
    20652136        /**
    2066          * Returns true if this text item should be recalculated when it is modified
     2137         * Returns true if items of the parent frame should be recalculated when
     2138         * this item is modified
    20672139         */
    20682140        public boolean recalculateWhenChanged() {
    20692141                if (/*
    20702142                         * !isAnnotation() &&
    2071                          */(hasFormula() || getText().contains(":") || isLineEnd()))
     2143                         */(hasFormula() || isLineEnd()))
    20722144                        return true;
    20732145                try {
    2074                         Double.parseDouble(getText());
    2075                         return true;
     2146                        AttributeValuePair avp = getAttributeValuePair();
     2147
     2148                        if (!avp.getDoubleValue().equals(Double.NaN))
     2149                                return true;
    20762150                } catch (Exception e) {
    2077                 }
     2151                        e.printStackTrace();
     2152                }
     2153
    20782154                return false;
    20792155        }
  • trunk/src/org/expeditee/items/widgets/DataFrameWidget.java

    r352 r376  
    5959                                 * changed so it will be refreshed when the user goes back
    6060                                 */
    61                                 assert(false);
    62                                 //_needsUpdating = true;
     61                                assert (false);
     62                                // _needsUpdating = true;
    6363                                // update();
    6464                        }
     
    119119                if (oldLink == null) {
    120120                        _needsUpdating = true;
     121                        // Need to refresh imediately so that the data appears when adding a
     122                        // link to a graph
     123                        refresh();
    121124                } else {
    122125                        refresh();
  • trunk/src/org/expeditee/items/widgets/SampleWidget2.java

    r203 r376  
    22
    33
     4import java.awt.Color;
    45import java.awt.FlowLayout;
     6import java.awt.Font;
    57
    6 import javax.swing.JButton;
     8import javax.swing.JCheckBox;
    79import javax.swing.JComboBox;
    810import javax.swing.JLabel;
     
    1012import javax.swing.JSplitPane;
    1113import javax.swing.JTextArea;
     14import javax.swing.JToggleButton;
    1215
    1316import org.expeditee.items.Text;
     
    2124                super(source, new JSplitPane(JSplitPane.VERTICAL_SPLIT), 60, -1, 40, -1);
    2225
     26                Font bigFont = null;
     27               
    2328                JSplitPane sp = (JSplitPane)super._swingComponent;
    2429               
    2530                JPanel p = new JPanel(new FlowLayout());
     31                p.setBackground(new Color(255,228,195));
    2632
    27                 JLabel lbl = new JLabel("This widget has multiple JComponents!");
     33                JLabel lbl = new JLabel("This is an example InteractiveWidget!");
     34                bigFont = lbl.getFont().deriveFont(24F);
     35                lbl.setFont(bigFont);
    2836               
    29                 JButton button = new JButton("Click Me!");
     37                JToggleButton button = new JToggleButton("Toggle Style");
     38                button.setFont(bigFont);
    3039               
    31                 JButton button2 = new JButton("Or Me!");
     40                JCheckBox checkBox = new JCheckBox("Big Font");
     41                checkBox.setBackground(null);
     42                checkBox.setSelected(true);
     43                checkBox.setFont(bigFont);
     44               
     45               
     46                //JButton button2 = new JButton("Example CheckBox");
    3247               
    3348                _text = new JTextArea();
     49                _text.setFont(bigFont);
    3450               
    35                 _combo = new JComboBox(new String[] {"Item 1", "Item 2", "Item 3", "Item 21", "Item 22", "Item 23", "Item 31", "Item 32", "Item 33", "Item 41", "Item 42", "Item 43"});
     51                _combo = new JComboBox(new String[] {"Peach", "Item 2", "Item 3", "Item 21", "Item 22", "Item 23", "Item 31", "Item 32", "Item 33", "Item 41", "Item 42", "Item 43"});
     52                _combo.setFont(bigFont);
    3653               
    3754                p.add(lbl);
    3855                p.add(_combo);
    3956                p.add(button);
    40                 p.add(button2);
     57                p.add(checkBox);
    4158               
    4259                sp.setTopComponent(p);
  • trunk/src/org/expeditee/items/widgets/charts/AbstractCategory.java

    r311 r376  
    5454                                        }
    5555                                }
    56                         } catch (NumberFormatException e) {
     56                        } catch (Exception e) {
    5757
    5858                        }
  • trunk/src/org/expeditee/items/widgets/charts/AbstractChart.java

    r298 r376  
    8585                                case SizeUp:
    8686                                        invalidateLink();
    87                                         FrameKeyboardActions.SetSize(getFirstCorner(), 1, false, true);
     87                                        FrameKeyboardActions.SetSize(getFirstCorner(), 1, false,
     88                                                        true);
    8889                                        invalidateSelf();
    8990                                        FrameGraphics.refresh(true);
    90                                         //FrameGraphics.requestRefresh(true);
     91                                        // FrameGraphics.requestRefresh(true);
    9192                                        break;
    9293                                case SizeDown:
    9394                                        invalidateLink();
    94                                         FrameKeyboardActions.SetSize(getFirstCorner(), -1, false, true);
     95                                        FrameKeyboardActions.SetSize(getFirstCorner(), -1, false,
     96                                                        true);
    9597                                        invalidateSelf();
    9698                                        FrameGraphics.refresh(true);
    97                                         //FrameGraphics.ForceRepaint();
    98                                         //FrameGraphics.refresh(true);
    99                                         //FrameGraphics.requestRefresh(true);
     99                                        // FrameGraphics.ForceRepaint();
     100                                        // FrameGraphics.refresh(true);
     101                                        // FrameGraphics.requestRefresh(true);
    100102                                        break;
    101103                                case ChangeColor:
     
    221223        protected void refreshData(Frame dataFrame) {
    222224                clearSubjects();
     225               
    223226                boolean swap = false;
    224227                if (dataFrame.hasAnnotation("swap")) {
     
    265268                }
    266269                /* if (foundData) */{
     270                        /*
     271                         * At minimum add the data frame as a subject even if there is no data
     272                         * on it... yet
     273                         */
    267274                        addSubject(dataFrame);
    268275                }
     
    362369                if (legend != null) {
    363370                        legend.setFrame(new BlockBorder(newThickness, newThickness,
    364                                         newThickness, newThickness, getSource().getColor()));
     371                                        newThickness, newThickness, getSource().getPaintColor()));
    365372                        legend.setItemFont(legend.getItemFont().deriveFont(fontSize));
    366373                        float pad = newThickness + 1;
  • trunk/src/org/expeditee/math/ExpediteeJEP.java

    r311 r376  
    8484                                continue;
    8585
    86                         AttributeValuePair avp = new AttributeValuePair(t.getText());
     86                        AttributeValuePair avp = t.getAttributeValuePair();
    8787                        if (avp.hasPair()) {
    8888                                try {
    89                                         if (getVar(avp.getAttribute()) == null)
    90                                                 addVariable(avp.getAttribute(), avp.getDoubleValue());
    91                                 } catch (NumberFormatException e) {
     89                                        if (getVar(avp.getAttribute()) == null) {
     90                                                Double d = avp.getDoubleValue();
     91                                                if (!d.equals(Double.NaN))
     92                                                        addVariable(avp.getAttribute(), avp
     93                                                                        .getDoubleValue());
     94                                        }
    9295                                } catch (Exception e) {
    9396                                        e.printStackTrace();
     
    111114                        if (i instanceof Text && !i.isAnnotation() && !i.isLineEnd()) {
    112115                                try {
    113                                         Double value = new AttributeValuePair(i.getText())
    114                                                         .getDoubleValue();
    115                                         if (value != null) {
     116                                        Double value = i.getAttributeValuePair().getDoubleValue();
     117                                        if (!value.equals(Double.NaN)) {
    116118                                                vector.add(value);
    117119                                        }
    118                                 } catch (NumberFormatException e) {
     120                                } catch (Exception e) {
     121                                        e.printStackTrace();
    119122                                }
    120123                        }
  • trunk/src/org/expeditee/simple/SString.java

    r235 r376  
    33public class SString extends SPrimitive<String> {
    44        public static String prefix = SVariable.prefix + "s" + SVariable.separator;
     5
     6        Double doubleValue_ = null;
    57
    68        public SString() {
     
    1214        }
    1315
    14         public SString(String value) /*throws Exception*/ {
     16        public SString(String value) /* throws Exception */{
    1517                super(value);
    1618        }
     
    1921        public void parse(String s) {
    2022                value_ = s;
     23                doubleValue_ = null;
    2124        }
    2225
     
    3942        @Override
    4043        public Double doubleValue() {
     44                if (doubleValue_ != null)
     45                        return doubleValue_;
     46
    4147                if (value_.equals(""))
    42                         return 0.0;
    43                 try {
    44                         return Double.parseDouble(value_);
    45                 } catch (NumberFormatException ne) {
     48                        doubleValue_ = 0.0;
     49                else {
     50                        try {
     51                                doubleValue_ = Double.parseDouble(value_);
     52                        } catch (NumberFormatException ne) {
     53                                try{
     54                                doubleValue_ =(double) Long.decode(value_);
     55                                }catch(Exception e){
     56                                        doubleValue_ = Double.NaN;
     57                                }
     58                        }
    4659                }
    47                 return (double) Long.decode(value_);
     60                return doubleValue_;
    4861        }
    4962
     
    6477        public void setValue(SPrimitive v) {
    6578                value_ = v.stringValue();
     79                doubleValue_ = null;
    6680        }
    6781
  • trunk/src/org/expeditee/stats/DocumentStats.java

    r362 r376  
    1212        protected int _treeFrames = 0;
    1313
     14        protected int _characters = 0;
     15       
    1416        protected int _words = 0;
    1517
     
    3335
    3436                // Initialise variables with the data for this frames comet
     37                _characters = 0;
    3538                _words = 0;
    3639                _textItems = 0;
     
    4447                        _words += text.split("\\s+").length;
    4548                        _sentances += text.split("\\.+").length;
     49                        _characters += text.length();
    4650                       
    4751                        String link = i.getAbsoluteLink();
     
    5963                                        visited);
    6064                        _words += childItemStats._words;
     65                        _characters += childItemStats._characters;
    6166                        _textItems += childItemStats._textItems;
    6267                        _sentances += childItemStats._sentances;
     
    6974                StringBuffer sb = new StringBuffer();
    7075                sb.append(SessionStats.getDate());
    71                 sb.append("DocStats:  ").append(_name).append('\n');
    72                 sb.append("Title:  ").append(_title).append('\n');
     76                sb.append("DocStats: ").append(_name).append('\n');
     77                sb.append("Title:    ").append(_title).append('\n');
    7378                sb.append("Frames:    ").append(_treeFrames).append('\n');
    7479                sb.append("TextItems: ").append(_textItems).append('\n');
    7580                sb.append("Sentances: ").append(_sentances).append('\n');
    76                 sb.append("Words:     ").append(_words);
     81                sb.append("Words:     ").append(_words).append('\n');
     82                sb.append("Chars:     ").append(_characters);
    7783                return sb.toString();
    7884        }
Note: See TracChangeset for help on using the changeset viewer.