Changeset 376
- Timestamp:
- 11/02/08 13:05:01 (16 years ago)
- 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 721 721 int ind = 0; 722 722 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 */ 726 727 if (paramTypes[ind] == Frame.class) { 727 728 objects[ind] = source; … … 886 887 return PerformAction(current, launcher, command); 887 888 } catch (RuntimeException e) { 889 e.printStackTrace(); 888 890 MessageBay.errorMessage("Action failed: " + e.getMessage()); 889 891 } catch (Exception e) { 892 e.printStackTrace(); 890 893 MessageBay.errorMessage("Action failed: " 891 894 + e.getClass().getSimpleName()); -
trunk/src/org/expeditee/actions/Misc.java
r362 r376 17 17 import javax.imageio.ImageIO; 18 18 19 import org.expeditee. agents.wordprocessing.JSpellChecker;19 import org.expeditee.gui.AttributeUtils; 20 20 import org.expeditee.gui.Browser; 21 21 import org.expeditee.gui.DisplayIO; … … 35 35 import org.expeditee.simple.SString; 36 36 import org.expeditee.stats.CometStats; 37 import org.expeditee.stats.DocumentStats ;37 import org.expeditee.stats.DocumentStatsFast; 38 38 import org.expeditee.stats.SessionStats; 39 39 import org.expeditee.stats.StatsLogger; … … 274 274 275 275 } 276 276 277 277 public static String GetDocumentStats(Frame frame) { 278 278 TimeKeeper timer = new TimeKeeper(); 279 279 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()); 282 283 String result = docStats.toString(); 283 284 284 285 MessageBay.overwriteMessage("Document stats time: " 285 286 + timer.getElapsedStringSeconds()); … … 436 437 * PNGFrame(currentFrame.getName()) 437 438 */ 438 public static void PNGFrame( ) {439 ImageFrame( DisplayIO.getCurrentFrame().getName(), "PNG");439 public static void PNGFrame(Frame frame) { 440 ImageFrame(frame.getName(), "PNG"); 440 441 } 441 442 442 443 public static String SaveImage(BufferedImage screen, String format, 443 444 String directory, String fileName) { 445 String suffix = "." + format.toLowerCase(); 446 String shortFileName = fileName; 444 447 // Check if we need to append the suffix 445 448 if (fileName.indexOf('.') < 0) 446 fileName += "." + format.toLowerCase(); 449 fileName += suffix; 450 else 451 shortFileName = fileName.substring(0, fileName.length() - suffix.length()); 447 452 448 453 try { 454 int count = 2; 449 455 // 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 452 462 if (!out.getParentFile().exists()) 453 463 out.mkdirs(); … … 910 920 } 911 921 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 block920 e.printStackTrace();921 }922 return null;923 }924 925 public static String spellCheck(String word) {926 return checkSpelling(word);927 }928 929 922 public static int wordCount(String paragraph) { 930 923 return paragraph.trim().split("\\s+").length + 1; 931 924 } 932 925 933 926 public static int wordCount(Frame frame) { 934 927 int count = 0; 935 936 for (Text t: frame.getBodyTextItems(false)){928 929 for (Text t : frame.getBodyTextItems(false)) { 937 930 count += wordCount(t.getText()); 938 931 } 939 932 940 933 return count; 941 934 } 942 943 public static void moveToPublic(Frame frame) {935 936 public static void moveToPublic(Frame frame) { 944 937 FrameIO.moveFrameset(frame.getFramesetName(), FrameIO.PUBLIC_PATH); 945 938 } 946 947 public static void moveToPrivate(Frame frame) {939 940 public static void moveToPrivate(Frame frame) { 948 941 FrameIO.moveFrameset(frame.getFramesetName(), FrameIO.FRAME_PATH); 949 942 } 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 } 950 956 } -
trunk/src/org/expeditee/actions/Simple.java
r362 r376 20 20 import org.expeditee.agents.DisplayTree; 21 21 import org.expeditee.agents.SearchAgent; 22 import org.expeditee.agents.SearchFramesetAndReplace; 22 23 import org.expeditee.agents.SearchFrameset; 23 import org.expeditee.agents.Search FramesetFast;24 import org.expeditee.agents.SearchTreeAndReplace; 24 25 import org.expeditee.agents.SearchTree; 25 import org.expeditee.agents.SearchTreeFast;26 26 import org.expeditee.agents.WriteTree; 27 27 import org.expeditee.gui.AttributeUtils; … … 328 328 boolean acceptKeyboardInput, boolean step, int pause, Color color) { 329 329 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 } 331 337 332 338 _stepColor = color == null ? Color.green : color; … … 339 345 340 346 // an item without a link signals to run the current frame 341 if (current .getLink() == null) {347 if (current != null && current.getLink() == null) { 342 348 // Make a copy but hide it 343 349 current = current.copy(); … … 351 357 t.start(); 352 358 } catch (Exception e) { 359 e.printStackTrace(); 353 360 } 354 361 } … … 932 939 // The fast search does not do replacement 933 940 if (bReplace) { 941 searchAgent = new SearchFramesetAndReplace(firstFrame, 942 maxFrame, null); 943 } else { 934 944 searchAgent = new SearchFrameset(firstFrame, maxFrame, null); 935 } else {936 searchAgent = new SearchFramesetFast(firstFrame, maxFrame, null);937 945 } 938 946 searchAgent.initialise(null, null, frameset, resultsFrameset, … … 975 983 // now The fast search does not do replacement 976 984 if (bReplace) { 985 searchAgent = new SearchTreeAndReplace(null); 986 } else { 977 987 searchAgent = new SearchTree(null); 978 } else {979 searchAgent = new SearchTreeFast(null);980 988 } 981 989 _agent = searchAgent; … … 1675 1683 String s = getMessage(tokens, context, code.toString(), tokens[0] 1676 1684 .equals("type") ? " " : "", 1); 1677 1685 1678 1686 DisplayIO.typeStringDirect(0.025, s); 1679 1687 } else if (tokens[0].equals("runstring")) { … … 2031 2039 } catch (Exception e) { 2032 2040 } 2033 }else{ 2034 Frame zero = FrameIO.LoadFrame(freshCopy.getFramesetName() + "0"); 2041 } else { 2042 Frame zero = FrameIO.LoadFrame(freshCopy.getFramesetName() 2043 + "0"); 2035 2044 freshCopy.setPath(zero.getPath()); 2036 2045 } -
trunk/src/org/expeditee/agents/Format.java
r307 r376 5 5 import java.util.Collections; 6 6 import java.util.Comparator; 7 import java.util.HashSet; 7 8 import java.util.List; 8 9 … … 45 46 @Override 46 47 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 50 52 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 52 57 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 } 53 66 } 54 67 55 68 ArrayList<Item> columnHeads = new ArrayList<Item>(); 56 69 … … 175 188 overwriteMessage("Formatting complete."); 176 189 } 177 190 178 191 @Override 179 192 protected void message(String message) { -
trunk/src/org/expeditee/agents/SearchAgent.java
r362 r376 1 1 package org.expeditee.agents; 2 3 import java.util.Collection; 2 4 3 5 import org.expeditee.gui.Frame; … … 24 26 25 27 public SearchAgent(String searchText) { 26 _pattern = searchText.toLowerCase(); 28 if (searchText != null) 29 _pattern = searchText.toLowerCase(); 27 30 } 28 31 … … 39 42 false); 40 43 } 41 return initialise(frame, item, frame.getFramesetName(), resultFrameset,44 return initialise(frame, item, getSearchDescription(frame), resultFrameset, 42 45 null, pattern); 46 } 47 48 /** 49 * @param frame 50 * @return 51 */ 52 protected String getSearchDescription(Frame frame) { 53 return frame.getFramesetName(); 43 54 } 44 55 … … 56 67 public boolean initialise(Frame frame, Item item, String startName, 57 68 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 60 72 if (_pattern == null) 61 73 _pattern = pattern.toLowerCase(); … … 66 78 // and type as the title 67 79 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); 70 83 // Set the frame to be displayed after running the agent 71 84 _end = _results.getFirstFrame(); 72 85 73 86 return super.initialise(frame, item); 87 } 88 89 protected String getResultsTitleSuffix() { 90 return " [" + _pattern + "]"; 74 91 } 75 92 … … 111 128 return true; 112 129 } 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 } 113 166 } -
trunk/src/org/expeditee/agents/SearchFrameset.java
r362 r376 4 4 5 5 import org.expeditee.gui.Frame; 6 import org.expeditee.gui.FrameGraphics;7 6 import org.expeditee.gui.FrameIO; 8 7 9 public class SearchFrameset Fastextends SearchAgent {8 public class SearchFrameset extends SearchAgent { 10 9 private long _firstFrame = 1; 11 10 12 11 private long _maxFrame = Integer.MAX_VALUE; 13 12 14 public SearchFrameset Fast(long firstFrame, long maxFrame, String searchText) {13 public SearchFrameset(long firstFrame, long maxFrame, String searchText) { 15 14 this(searchText); 16 15 _firstFrame = firstFrame; … … 18 17 } 19 18 20 public SearchFrameset Fast(String searchText) {19 public SearchFrameset(String searchText) { 21 20 super(searchText); 22 21 } … … 38 37 Collection<String> found = FrameIO.searchFrame(frameName, _pattern, 39 38 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); 62 40 } 63 41 _results.save(); -
trunk/src/org/expeditee/agents/SearchGreenstone.java
r336 r376 1 1 package org.expeditee.agents; 2 2 3 import java.util.Enumeration;4 3 import java.util.HashMap; 5 4 import java.util.Map; … … 30 29 protected static Greenstone3Connection _gsdl = null; 31 30 31 public static Greenstone3Connection getConnection() { 32 return _gsdl; 33 } 34 32 35 private static String _maxResults = "10"; 33 36 … … 84 87 } 85 88 89 public SearchGreenstone(int resultsCount) { 90 this(null); 91 _thisMaxResults = resultsCount + ""; 92 } 93 86 94 public SearchGreenstone() { 87 95 super(null); … … 113 121 else if (attribute.equals("autoconnect")) 114 122 connect(); 115 116 123 else if (attribute.equals("maxresults")) { 117 124 try { … … 119 126 } catch (Exception e) { 120 127 } 121 } 122 123 else if (attribute.equals("dostemming")) 128 } else if (attribute.equals("dostemming")) 124 129 _doStemming = true; 125 130 else if (attribute.startsWith("showabstract")) … … 139 144 } 140 145 146 protected String getResultsTitle() { 147 return this.getClass().getSimpleName() + "[" + getCursorText() + "]"; 148 } 149 141 150 @Override 142 151 protected Frame process(Frame frame) { 143 String resultsTitle = this.getClass().getSimpleName() + "[" 144 + _fullCaseSearchQuery + "]"; 152 String resultsTitle = getResultsTitle(); 145 153 _results.setTitle(resultsTitle); 146 154 … … 150 158 } else if (_currentResultSet != null) { 151 159 Text newText = DisplayIO.getCurrentFrame().createNewText( 152 _fullCaseSearchQuery);160 getCursorText()); 153 161 _clicked = newText; 154 162 FrameMouseActions.pickup(newText); 155 163 } 156 164 157 if (_currentResultSet == null ) {158 MessageBay.errorMessage( "Could not find Greenstone query text");165 if (_currentResultSet == null || _currentResultSet.size() == 0) { 166 MessageBay.errorMessage(getNoResultsMessage()); 159 167 return null; 160 168 } … … 171 179 172 180 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; 173 192 } 174 193 … … 189 208 Query query = createQuery(queryText); 190 209 QueryOutcome queryOutcome = _gsdl.issueQueryToServer(query); 191 _currentResultSet = getResultSetMetadata(queryOutcome); 210 if (queryOutcome != null) 211 _currentResultSet = getResultSetMetadata(queryOutcome); 192 212 } 193 213 … … 281 301 282 302 if (rd.metadataExists("Title")) { 283 resultText.append("title =" + rd.getTitle()).append('\n');303 resultText.append("title: " + rd.getTitle()).append('\n'); 284 304 } 285 305 if (rd.metadataExists("Date")) { 286 resultText.append("date =" + rd.getDate()).append('\n');306 resultText.append("date: " + rd.getDate()).append('\n'); 287 307 } 288 308 if (rd.metadataExists("Booktitle")) { 289 resultText.append("booktitle =" + rd.getBooktitle()).append('\n');309 resultText.append("booktitle: " + rd.getBooktitle()).append('\n'); 290 310 } 291 311 if (rd.metadataExists("Pages")) { 292 resultText.append("pages =" + rd.getPages()).append('\n');312 resultText.append("pages: " + rd.getPages()).append('\n'); 293 313 } 294 314 if (rd.metadataExists("Journal")) { 295 resultText.append("journal =" + rd.getJournal()).append('\n');315 resultText.append("journal: " + rd.getJournal()).append('\n'); 296 316 } 297 317 if (rd.metadataExists("Volume")) { 298 resultText.append("volume =" + rd.getVolume()).append('\n');318 resultText.append("volume: " + rd.getVolume()).append('\n'); 299 319 } 300 320 if (rd.metadataExists("Number")) { 301 resultText.append("number =" + rd.getNumber()).append('\n');321 resultText.append("number: " + rd.getNumber()).append('\n'); 302 322 } 303 323 if (rd.metadataExists("Editor")) { 304 resultText.append("editor =" + rd.getEditor()).append('\n');324 resultText.append("editor: " + rd.getEditor()).append('\n'); 305 325 } 306 326 if (rd.metadataExists("Publisher")) { 307 resultText.append("publisher =" + rd.getPublisher()).append('\n');327 resultText.append("publisher: " + rd.getPublisher()).append('\n'); 308 328 } 309 329 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 322 340 resultText.deleteCharAt(resultText.length() - 1); 323 341 … … 356 374 } 357 375 376 public static void clearSession() { 377 getConnection().getSessionResults().clear(); 378 _currentResultSet = null; 379 } 380 358 381 } -
trunk/src/org/expeditee/agents/SearchTree.java
r362 r376 11 11 import java.util.Map; 12 12 13 import org.expeditee.gui.AttributeValuePair; 13 14 import org.expeditee.gui.Frame; 14 import org.expeditee.gui.FrameGraphics;15 15 import org.expeditee.gui.FrameIO; 16 16 import org.expeditee.gui.UserSettings; 17 17 import org.expeditee.io.Conversion; 18 18 19 public class SearchTree Fastextends SearchAgent {19 public class SearchTree extends SearchAgent { 20 20 private Map<String, Collection<String>> _searchResults = new HashMap<String, Collection<String>>(); 21 21 22 public SearchTree Fast(String searchText) {22 public SearchTree(String searchText) { 23 23 super(searchText); 24 24 } 25 25 26 26 @Override 27 27 protected Frame process(Frame frame) { 28 if (frame == null)28 if (frame == null) 29 29 frame = FrameIO.LoadFrame(_startName); 30 31 searchTree(frame.getName(), _pattern, _searchResults, new HashSet<String>()); 32 30 31 searchTree(frame.getName(), _searchResults, new HashSet<String>()); 33 32 _results.save(); 34 33 … … 36 35 if (_clicked != null) 37 36 _clicked.setLink(resultFrameName); 38 37 39 38 return _results.getFirstFrame(); 40 39 } 41 40 41 @Override 42 /** 43 * @param frame 44 * @return 45 */ 46 protected String getSearchDescription(Frame frame) { 47 return frame.getName(); 48 } 49 42 50 /** 43 51 * 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 48 62 */ 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)) 52 67 return; 53 68 54 69 visited.add(frameName); 55 70 56 71 String fullPath = null; 57 72 for (String possiblePath : UserSettings.FrameDirs) { … … 64 79 if (fullPath == null) 65 80 return; 66 81 67 82 _frameCount++; 68 83 overwriteMessage("Searching " + frameName); 69 84 70 85 String frameset = Conversion.getFramesetName(frameName); 71 86 72 87 Collection<String> frameResults = new LinkedList<String>(); 73 88 // Open the file and search the text items … … 75 90 BufferedReader reader = new BufferedReader(new FileReader(fullPath)); 76 91 String next; 92 StringBuffer sb = new StringBuffer(); 93 String link = null; 94 boolean ignore = false; 95 77 96 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))) 85 141 link = frameset + link; 86 searchTree(link, pattern, results, visited);87 142 } 88 143 } 89 // Only add the results if a match was found on the frame90 if (frameResults.size() > 0){144 // Only add the results if a match was found on the frame 145 if (frameResults.size() > 0) { 91 146 results.put(frameName, frameResults); 92 147 } … … 97 152 } 98 153 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); 103 161 } 104 162 } 163 164 protected String getResultSurrogate(String toSearch) { 165 if (toSearch.toLowerCase().contains(_pattern)) 166 return toSearch; 167 return null; 168 } 105 169 } -
trunk/src/org/expeditee/agents/wordprocessing/JSpellChecker.java
r362 r376 1 1 package org.expeditee.agents.wordprocessing; 2 2 3 import java.awt.Color; 3 4 import java.io.File; 4 5 import java.io.FileNotFoundException; … … 8 9 import java.util.List; 9 10 11 import org.expeditee.gui.Frame; 10 12 import org.expeditee.gui.FrameIO; 13 import org.expeditee.gui.MessageBay; 14 import org.expeditee.items.Text; 11 15 12 16 import com.swabunga.spell.engine.Configuration; … … 59 63 public static JSpellChecker _theInstance = null; 60 64 61 public static JSpellChecker getInstance() throws FileNotFoundException, IOException { 65 public static JSpellChecker getInstance() throws FileNotFoundException, 66 IOException { 62 67 if (_theInstance == null) { 63 68 create(); … … 66 71 } 67 72 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 68 88 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/"; 74 93 75 94 public JSpellChecker() { … … 79 98 public void init() throws FileNotFoundException, IOException { 80 99 log(this.hashCode() + ": JSpellChecker.init"); 100 MessageBay.displayMessage("Loading spell checker..."); 81 101 82 102 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); 85 110 86 111 initialized = true; 112 113 MessageBay.displayMessage("Spell checker Loaded", Color.green.darker()); 87 114 } 88 115 … … 97 124 checker.addSpellCheckListener(listener); 98 125 checker.reset(); 126 event = null; 99 127 } 100 128 … … 137 165 138 166 } 139 140 if (s.length() == 0){167 168 if (s.length() == 0) { 141 169 return "No suggestions"; 142 170 } … … 146 174 // + "|"; 147 175 // } 148 return s.substring(0, s.length() -1);176 return s.substring(0, s.length() - 1); 149 177 } 150 178 -
trunk/src/org/expeditee/greenstone/Greenstone3Connection.java
r352 r376 17 17 import java.util.Set; 18 18 19 //import org.apache.xerces.parsers.DOMParser;19 import org.apache.xerces.parsers.DOMParser; 20 20 import org.w3c.dom.Document; 21 21 import org.w3c.dom.NamedNodeMap; … … 53 53 * keys. All the results returned in this session. 54 54 */ 55 private Map allResults;55 private Map<String, ResultDocument> allResults; 56 56 57 57 /** … … 156 156 } 157 157 this.queryList = Collections.synchronizedList(new ArrayList()); 158 this.allResults = Collections.synchronizedMap(new HashMap()); 158 this.allResults = Collections 159 .synchronizedMap(new HashMap<String, ResultDocument>()); 159 160 this.allKeywords = Collections.synchronizedMap(new HashMap()); 160 161 this.allAuthors = Collections.synchronizedMap(new HashMap()); … … 164 165 } 165 166 166 public Map getSessionResults() {167 public Map<String, ResultDocument> getSessionResults() { 167 168 return this.allResults; 168 169 }; … … 270 271 while (iter.hasNext()) { 271 272 String docID = (String) iter.next(); 272 ResultDocument resultDocument = (ResultDocument) allResults 273 .get(docID); 273 ResultDocument resultDocument = allResults.get(docID); 274 274 System.out.println("____________" + docID + " ___________"); 275 275 System.out.println(resultDocument.toString()); … … 286 286 while (iter.hasNext()) { 287 287 String docID = (String) iter.next(); 288 ResultDocument resultDocument = (ResultDocument) allResults 289 .get(docID); 288 ResultDocument resultDocument = allResults.get(docID); 290 289 System.out.println(docID + "\t" + resultDocument.getTitle()); 291 290 } … … 305 304 */ 306 305 public ResultDocument getDocument(String docID) { 307 return (ResultDocument)allResults.get(docID);306 return allResults.get(docID); 308 307 } 309 308 … … 425 424 StringReader sr = new StringReader(result); 426 425 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; 499 485 } 500 486 … … 545 531 */ 546 532 public void getDocumentMetadataFromServer(String docID, String metadata) { 547 ResultDocument resultDocument = (ResultDocument)allResults.get(docID);533 ResultDocument resultDocument = allResults.get(docID); 548 534 if (resultDocument.metadataExists(metadata)) { 549 535 return; … … 566 552 StringReader sr = new StringReader(result); 567 553 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); 571 557 } catch (SAXException se) { 572 558 System.err.println(se); 573 559 } catch (IOException ioe) { 574 560 System.err.println(ioe); 575 }*/ 576 //Document d = p.getDocument(); 577 Document d = null; 561 } 562 Document d = p.getDocument(); 578 563 NodeList metadataList = d.getElementsByTagName("metadata"); 579 564 String metadataval = null; … … 609 594 String s = authors[i] + ", " + authors[i + 1]; 610 595 611 // Handle names with jr. in them596 // Handle names with jr. in them 612 597 if (containsExtraName) { 613 598 if (i + 2 < authors.length … … 703 688 StringReader sr = new StringReader(result); 704 689 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 } 713 698 714 699 String returnName = null; 715 700 716 //Document d = p.getDocument();717 Document d = null;701 Document d = p.getDocument(); 702 // Document d = null; 718 703 NodeList metadataList = d.getElementsByTagName("metadata"); 719 704 for (int i = 0; i < metadataList.getLength(); i++) { … … 750 735 StringReader sr = new StringReader(result); 751 736 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 762 747 NodeList childList = d.getElementsByTagName("classifierNode"); 763 748 NodeList documentList = d.getElementsByTagName("documentNode"); -
trunk/src/org/expeditee/greenstone/ResultDocument.java
r313 r376 35 35 36 36 private Set<String> retrievedMetadata; 37 38 private double sessionScore; 37 39 38 40 public ResultDocument() { … … 50 52 publisher = null; 51 53 frequencyReturned = 1; 54 sessionScore = 0; 52 55 queryContexts = new Vector<QueryContext>(); 53 56 retrievedMetadata = new HashSet<String>(); … … 158 161 this.retrievedMetadata.add("Publisher"); 159 162 } 163 164 public double getSessionScore() { 165 return this.sessionScore; 166 } 167 public void setSessionScore(double s) { 168 this.sessionScore = s; 169 } 160 170 161 171 public void incrementFrequencyReturned() { … … 165 175 public void addQueryContext(QueryContext queryContext) { 166 176 this.queryContexts.addElement(queryContext); 177 if (this.frequencyReturned == 1) 178 this.sessionScore = Double.parseDouble(queryContext.getScore()); 167 179 } 168 180 … … 170 182 return authors; 171 183 } 184 185 public Vector<String> getAuthor() { 186 return getAuthors(); 187 } 172 188 173 189 public Vector<String> getKeywords() { 174 190 return keywords; 175 191 } 192 193 public Vector<String> getKeyword() { 194 return getKeywords(); 195 } 176 196 177 197 public String getTitle() { … … 218 238 return frequencyReturned; 219 239 } 220 221 public Vector getQueryContexts() {240 241 public Vector<QueryContext> getQueryContexts() { 222 242 return this.queryContexts; 223 243 } -
trunk/src/org/expeditee/gui/AttributeUtils.java
r348 r376 171 171 172 172 _SetMethods.put("p", Item.class.getMethod("setPosition", pPoint)); 173 _SetMethods.put("xy", Item.class.getMethod("setPosition", pPoint)); 173 174 _SetMethods.put("pos", Item.class.getMethod("setPosition", pPoint)); 174 175 _SetMethods.put("thickness", Item.class.getMethod("setThickness", … … 209 210 "setGradientColor", pColor)); 210 211 211 _SetMethods.put("ga", Item.class .getMethod("setGradientAngle",212 pInt));212 _SetMethods.put("ga", Item.class 213 .getMethod("setGradientAngle", pInt)); 213 214 _SetMethods.put("gradientangle", Item.class.getMethod( 214 215 "setGradientAngle", pInt)); … … 272 273 _SetMethods.put("s", Item.class.getMethod("setSize", pFloat)); 273 274 275 // TODO have a separate map for item and frame methods. 276 // This will remove the need for p0 etc 274 277 _SetMethods.put("foregroundcolor", Frame.class.getMethod( 275 278 "setForegroundColor", pColor)); … … 282 285 _SetMethods.put("permission", Frame.class.getMethod( 283 286 "setPermission", pPermission)); 287 _SetMethods.put("p0", Frame.class.getMethod("setPermission", 288 pPermission)); 284 289 285 290 } catch (SecurityException e) { … … 321 326 if (m.getDeclaringClass().isAssignableFrom(toExtract.getClass())) { 322 327 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) 346 331 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 value357 else358 o = i;359 } else if (o instanceof Float) {360 if (((Float) o) < -0.0001)361 continue;362 // Null indicates default363 o = Math.round((Float) o);364 } else if (o instanceof Double) {365 // -1 indicates default value366 if (((Double) o) < 0.0001)367 continue;368 } else if (o instanceof Color) {369 // converts the color to the Expeditee code370 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 attributes397 .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 values411 if (((Boolean) o).booleanValue())412 continue;413 }414 332 // Append the attributes 415 333 attributes.append(m.getName().substring(GET_LENGTH)) 416 334 .append(AttributeValuePair.SEPARATOR_STRING) 417 .append( o).append('\n');335 .append(s).append('\n'); 418 336 } catch (Exception e) { 419 337 // TODO Auto-generated catch block … … 434 352 Item attribs = current.getStatsTextItem(attributes.toString()); 435 353 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(); 436 476 } 437 477 … … 653 693 text.setText(avp.toString()); 654 694 } 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 } 655 721 } -
trunk/src/org/expeditee/gui/AttributeValuePair.java
r286 r376 54 54 if (text.charAt(0) == ANNOTATION_CHAR) { 55 55 _bAnnotation = true; 56 if (text.length() == 1 || !Character.isLetterOrDigit(text.charAt(1))) 56 if (text.length() == 1 57 || !Character.isLetterOrDigit(text.charAt(1))) 57 58 return; 58 59 // All chars in the attribute must be letters or digits … … 98 99 public Double getDoubleValue() throws NumberFormatException { 99 100 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 100 106 return _value.doubleValue(); 101 107 } … … 103 109 public Double getDoubleAttribute() throws NumberFormatException { 104 110 assert (_attribute != null); 105 106 111 return _attribute.doubleValue(); 107 112 } … … 186 191 } 187 192 193 public boolean hasAttributeOrValue() { 194 return _attribute != null || _value != null; 195 } 196 188 197 } -
trunk/src/org/expeditee/gui/Browser.java
r355 r376 16 16 import java.io.File; 17 17 import java.util.Collection; 18 import java.util.LinkedList; 18 19 19 20 import javax.swing.JFrame; … … 163 164 Frame defaultProfile = loadProfile(UserSettings.DEFAULT_PROFILE_NAME); 164 165 165 Collection<String> warningMessages = FrameUtils 166 .ParseProfile(defaultProfile); 167 166 Collection<String> warningMessages = new LinkedList<String>(); 167 warningMessages.addAll(FrameUtils.ParseProfile(defaultProfile)); 168 168 warningMessages.addAll(FrameUtils.ParseProfile(profile)); 169 170 169 // set the layout to absolute layout for widgets 171 170 this.getContentPane().setLayout(new AbsoluteLayout()); … … 239 238 MessageBay.warningMessage(message); 240 239 241 this.getContentPane().addKeyListener(FrameKeyboardActions.getInstance()); 240 this.getContentPane().addKeyListener( 241 FrameKeyboardActions.getInstance()); 242 242 this.addKeyListener(FrameKeyboardActions.getInstance()); 243 243 -
trunk/src/org/expeditee/gui/DisplayIO.java
r363 r376 72 72 * The title to display in the Title bar. 73 73 */ 74 public static final String TITLE = "Exp 09Oct2008A";74 public static final String TITLE = "Exp31Oct2008A"; 75 75 76 76 private DisplayIO() { … … 142 142 143 143 public static void setTextCursor(Text text, int cursorMovement) { 144 setTextCursor(text, cursorMovement, false, false );144 setTextCursor(text, cursorMovement, false, false, false, false); 145 145 } 146 146 147 147 public static void setTextCursor(Text text, int cursorMovement, 148 boolean newSize, boolean isShiftDown ) {148 boolean newSize, boolean isShiftDown, boolean isCtrlDown, boolean allowClearSelection) { 149 149 150 150 int size = Math.round(text.getSize()); 151 if(allowClearSelection && !isShiftDown && text.hasSelection()) 152 text.clearSelection(); 153 151 154 Point2D.Float newMouse = text.moveCursor(cursorMovement, DisplayIO 152 .getFloatMouseX(), FrameMouseActions.MouseY, isShiftDown );155 .getFloatMouseX(), FrameMouseActions.MouseY, isShiftDown, isCtrlDown); 153 156 154 157 if (!newSize && cursorType == Item.TEXT_CURSOR) { … … 187 190 188 191 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; 190 193 191 194 Image image = Toolkit.getDefaultToolkit().createImage( … … 846 849 */ 847 850 public static void MoveCursorToEndOfItem(Item i) { 848 setTextCursor((Text) i, Text.END, true, false );851 setTextCursor((Text) i, Text.END, true, false, false, false); 849 852 } 850 853 -
trunk/src/org/expeditee/gui/Frame.java
r362 r376 204 204 boolean oldValue = _change; 205 205 206 if (value) {207 208 }206 // if (value) { 207 // notifyObservers(); 208 // } 209 209 210 210 if (oldValue == value) … … 219 219 } 220 220 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 } 222 234 // 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(); 225 248 } 226 249 } … … 370 393 if (UserSettings.TitleTemplate == null) { 371 394 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); 372 400 frameTitle.resetTitlePosition(); 373 401 } else { … … 721 749 item.onParentStateChanged(new ItemParentStateChangedEvent(this, 722 750 ItemParentStateChangedEvent.EVENT_TYPE_ADDED)); 723 if (recalculate && item.recalculateWhenChanged()) 724 recalculate(); 751 752 // if (recalculate && item.recalculateWhenChanged()) 753 // recalculate(); 725 754 726 755 change(); … … 799 828 } 800 829 // TODO Improve efficiency when removeAll is called 801 if (recalculate && item.recalculateWhenChanged())802 830 // if (recalculate && item.recalculateWhenChanged()) 831 // recalculate(); 803 832 } 804 833 } … … 834 863 Item undo = null; 835 864 boolean bReparse = false; 865 boolean bRecalculate = false; 836 866 837 867 if (_undo.size() <= 0) … … 871 901 for (Item i : toRestore) { 872 902 bReparse |= i.hasOverlay(); 903 bRecalculate |= i.recalculateWhenChanged(); 873 904 if (i instanceof Line) { 874 905 Line line = (Line) i; … … 885 916 if (bReparse) 886 917 FrameUtils.Parse(this, false); 918 else { 919 notifyObservers(bRecalculate); 920 } 887 921 FrameGraphics.Repaint(); 888 922 ItemUtils.EnclosedCheck(_body); … … 1455 1489 // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width); 1456 1490 // 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); 1467 1501 // } 1468 1502 addItem(t); … … 2023 2057 2024 2058 public void recalculate() { 2059 2025 2060 for (Item i : getItems()) { 2026 2061 if (i.hasFormula() && !i.isAnnotation()) { … … 2118 2153 } 2119 2154 } 2155 2156 public boolean hasObservers() { 2157 return _observers != null && _observers.size() > 0; 2158 } 2120 2159 } -
trunk/src/org/expeditee/gui/FrameGraphics.java
r348 r376 351 351 } 352 352 353 // if(isActual) 353 354 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 } 356 360 bg.fillRect(0, 0, _MaxSize.width, _MaxSize.height); 357 361 … … 514 518 // creates a new line so that lines are shown correctly when spanning 515 519 // across frames in TwinFrames mode 516 private static Line TransposeLine(Line line, Item d, Frame toPaint,517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 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 // } 554 558 555 559 private static void Paint(Graphics g, Image left, Image right, … … 658 662 if (done.contains(i)) 659 663 continue; 660 else if (!isAudienceMode() || !i.isConnectedToAnnotation()) { 664 else if (!isAudienceMode() || 665 !i.isConnectedToAnnotation()) { 661 666 toFill.add(i); 662 667 } … … 674 679 // System.out.println(a.getEnclosureID() + " " + 675 680 // b.getID());\ 676 // Shapes to the left go underneath681 // Shapes to the left go underneath 677 682 Polygon pA = a.getEnclosedShape(); 678 683 Polygon pB = b.getEnclosedShape(); 679 if (pA == null || pB == null)684 if (pA == null || pB == null) 680 685 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); 683 688 } 684 689 return cmp * -1; -
trunk/src/org/expeditee/gui/FrameIO.java
r362 r376 771 771 } 772 772 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 */ 773 779 public static String SaveFrame(Frame toSave, boolean inc) { 774 780 return SaveFrame(toSave, inc, true); -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r362 r376 57 57 58 58 public synchronized void keyTyped(KeyEvent e) { 59 59 60 if (Simple.isProgramRunning()) { 60 61 if (e.isControlDown() … … 153 154 } 154 155 155 FrameUtils.setLastEdited(text);156 157 156 // 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() */) { 159 163 // DisplayIO.UpdateTitle(); 160 164 text = createText(ch); … … 164 168 DisplayIO.setTextCursor(text, Text.NONE); 165 169 return; 166 } 170 } else { 171 FrameUtils.setLastEdited(text); 172 } 173 174 float oldY = FrameMouseActions.MouseY; 167 175 168 176 DisplayIO.setTextCursor(text, Text.NONE); … … 180 188 FrameMouseActions.MouseY); 181 189 } 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 182 216 DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false); 183 217 … … 303 337 } 304 338 305 private void move(int direction, boolean isShiftDown ) {339 private void move(int direction, boolean isShiftDown, boolean isCtrlDown) { 306 340 Item on = FrameUtils.getCurrentItem(); 307 341 … … 320 354 } else { 321 355 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); 325 358 } 326 359 } … … 426 459 break; 427 460 case KeyEvent.VK_LEFT: 428 move(Text.LEFT, e.isShiftDown() );461 move(Text.LEFT, e.isShiftDown(), e.isControlDown()); 429 462 break; 430 463 case KeyEvent.VK_RIGHT: 431 move(Text.RIGHT, e.isShiftDown() );464 move(Text.RIGHT, e.isShiftDown(), e.isControlDown()); 432 465 break; 433 466 case KeyEvent.VK_PAGE_DOWN: … … 441 474 NextTextItem(FrameUtils.getCurrentItem(), false); 442 475 } else { 443 move(Text.UP, e.isShiftDown() );476 move(Text.UP, e.isShiftDown(), e.isControlDown()); 444 477 } 445 478 break; … … 448 481 NextTextItem(FrameUtils.getCurrentItem(), true); 449 482 } else { 450 move(Text.DOWN, e.isShiftDown() );483 move(Text.DOWN, e.isShiftDown(), e.isControlDown()); 451 484 } 452 485 break; 453 486 case KeyEvent.VK_END: 454 487 if (e.isControlDown()) 455 move(Text.END, e.isShiftDown() );488 move(Text.END, e.isShiftDown(), e.isControlDown()); 456 489 else 457 move(Text.LINE_END, e.isShiftDown() );490 move(Text.LINE_END, e.isShiftDown(), e.isControlDown()); 458 491 break; 459 492 case KeyEvent.VK_HOME: 460 493 if (e.isControlDown()) 461 move(Text.HOME, e.isShiftDown() );494 move(Text.HOME, e.isShiftDown(), e.isControlDown()); 462 495 else 463 move(Text.LINE_HOME, e.isShiftDown() );496 move(Text.LINE_HOME, e.isShiftDown(), e.isControlDown()); 464 497 break; 465 498 // TODO remove this when upgrading Java … … 486 519 // Move the cursor to the next text item 487 520 Frame current = DisplayIO.getCurrentFrame(); 488 Itemtitle = current.getTitleItem();521 Text title = current.getTitleItem(); 489 522 490 523 Collection<Text> currentItems = FrameUtils.getCurrentTextItems(); … … 494 527 textItems.addAll(currentItems); 495 528 } else { 496 textItems.add(current.getTitleItem()); 529 if (title != null) 530 textItems.add(title); 497 531 textItems.addAll(current.getBodyTextItems(true)); 498 532 } … … 504 538 if (title == null) 505 539 return; 506 DisplayIO.MoveCursorToEndOfItem(title); 540 if (title != null) 541 DisplayIO.MoveCursorToEndOfItem(title); 507 542 FrameGraphics.Repaint(); 508 543 return; … … 634 669 // FrameMouseActions.pickup(t); 635 670 // } else { 636 // remove the link for alt+l671 // remove the link for ctrl+l 637 672 Item current = FrameUtils.getCurrentItem(); 638 673 Frame currentFrame = DisplayIO.getCurrentFrame(); … … 641 676 case KeyEvent.VK_HOME: 642 677 if (current != null && current instanceof Text) { 643 move(Text.HOME, isShiftDown );678 move(Text.HOME, isShiftDown, true); 644 679 } else { 645 680 while (DisplayIO.Back()) … … 649 684 case KeyEvent.VK_END: 650 685 if (current != null && current instanceof Text) { 651 move(Text.END, isShiftDown );686 move(Text.END, isShiftDown, true); 652 687 } else { 653 688 while (DisplayIO.Forward()) … … 682 717 break; 683 718 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 } 685 725 break; 686 726 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 } 688 733 break; 689 734 case KeyEvent.VK_UP: 690 if (current instanceof Text) {691 692 } else {693 694 }735 // if (current instanceof Text) { 736 NextTextItem(FrameUtils.getCurrentItem(), false); 737 // } else { 738 // DisplayIO.translateCursor(0, -distance); 739 // } 695 740 break; 696 741 case KeyEvent.VK_DOWN: 697 if (current instanceof Text) {698 699 } else {700 701 }742 // if (current instanceof Text) { 743 NextTextItem(FrameUtils.getCurrentItem(), true); 744 // } else { 745 // DisplayIO.translateCursor(0, distance); 746 // } 702 747 break; 703 748 case KeyEvent.VK_L: … … 923 968 Text text = getCurrentTextItem(); 924 969 if (text == null) { 925 for (Text t : FrameUtils.getCurrentTextItems()) {970 for (Text t : currentFrame.getBodyTextItems(false)) { 926 971 justify(t); 927 972 } … … 1134 1179 SetSize(on, repeat, true, false); 1135 1180 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); 1137 1183 } 1138 1184 break; … … 1140 1186 SetSize(on, -repeat, true, false); 1141 1187 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); 1143 1190 } 1144 1191 break; … … 1181 1228 1182 1229 private static void calculateItem(Item toCalculate) { 1230 if (toCalculate == null) 1231 return; 1232 1183 1233 if (!toCalculate.update()) { 1184 1234 toCalculate.setFormula(null); … … 1421 1471 if (firstItem == null) { 1422 1472 firstItem = null; 1473 return; 1423 1474 } 1424 1475 … … 2187 2238 2188 2239 // Refresh widgets that use its self as a data source 2189 currentFrame.notifyObservers( );2240 currentFrame.notifyObservers(true); 2190 2241 2191 2242 if (FrameIO.isProfileFrame(currentFrame)) { -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r364 r376 639 639 private void leftButton(Item clicked, Collection<Item> clickedIn, 640 640 boolean isShiftDown, boolean isControlDown) { 641 641 642 // if the user is pointing at something then either follow the link or 642 643 // do TDFC … … 698 699 if (clicked != null) { 699 700 // check item permissions 700 if ((clicked.hasLink() && !clicked 701 boolean hasLinkOrAction = clicked.hasLink() || clicked.hasAction(); 702 703 if ((hasLinkOrAction && !clicked 701 704 .hasPermission(Permission.followLinks)) 702 || (! clicked.hasLink()&& !clicked705 || (!hasLinkOrAction && !clicked 703 706 .hasPermission(Permission.createFrames))) { 704 707 Item editTarget = clicked.getEditTarget(); … … 756 759 tdfc(clickedOn); 757 760 } catch (RuntimeException e) { 758 MessageBay.errorMessage( e.getMessage());761 MessageBay.errorMessage("TDFC error: " + e.getMessage()); 759 762 } 760 763 return; … … 997 1000 } else { 998 1001 Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(), Math 999 .round(MouseX), Math.round(MouseY) );1002 .round(MouseX), Math.round(MouseY), true); 1000 1003 // If we have permission to copy this item then pick it up 1001 1004 if (on != null && on.isLineEnd() … … 1344 1347 } else { 1345 1348 Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(), 1346 MouseX, MouseY );1349 MouseX, MouseY, true); 1347 1350 // if its on a line then create a line from that line 1348 1351 if (on instanceof Line && on.hasPermission(Permission.full)) { … … 1510 1513 } 1511 1514 1512 DisplayIO.setTextCursor(_lastRanged, Text.NONE );1515 DisplayIO.setTextCursor(_lastRanged, Text.NONE, false, e.isShiftDown(), e.isControlDown(), false); 1513 1516 FrameGraphics.Repaint(); 1514 1517 return; … … 1544 1547 && _lastClickedOn == null && _lastClickedIn == null) { 1545 1548 Item on = FrameUtils.onItem(DisplayIO.getCurrentFrame(), e.getX(), 1546 e.getY() );1549 e.getY(), true); 1547 1550 1548 1551 if (FreeItems.getInstance().size() == 0) { … … 2162 2165 2163 2166 public static void delete(Item toDelete) { 2167 boolean bRecalculate = false; 2168 2164 2169 FrameUtils.setLastEdited(null); 2165 2170 _offX = _offY = 0; 2166 2171 2167 Frame current = DisplayIO.getCurrentFrame();2172 Frame currentFrame = DisplayIO.getCurrentFrame(); 2168 2173 // 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); 2171 2176 FrameGraphics.Repaint(); 2172 2177 return; … … 2190 2195 SessionStats.DeletedItem(free); 2191 2196 // List<String> temp = anchored.getText(); 2192 anchored.setTextList(free.getTextList()); 2197 anchored.setText(free.getText()); 2198 anchored.setFormula(free.getFormula()); 2193 2199 2194 2200 // free.setTextList(temp); … … 2196 2202 2197 2203 anchored.getParent().setChanged(true); 2204 2205 bRecalculate |= free.recalculateWhenChanged(); 2206 bRecalculate |= anchored.recalculateWhenChanged(); 2198 2207 2199 2208 // update the offset since the text has changed … … 2206 2215 // reset the mouse cursor 2207 2216 updateCursor(); 2208 FrameGraphics.Repaint();2209 return;2210 2217 // the user is not pointing at an item 2211 2218 } else if (toDelete == null) { … … 2304 2311 toUndo = toDelete.getConnected(); 2305 2312 } else { 2313 bRecalculate |= toDelete.recalculateWhenChanged(); 2306 2314 toUndo = toDelete.getConnected(); // copy(toDelete.getConnected()); 2307 2315 } … … 2318 2326 FrameGraphics.requestRefresh(false); 2319 2327 } 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(); 2324 2336 } 2325 2337 … … 2330 2342 public static void deleteItems(Collection<Item> itemList, boolean addToUndo) { 2331 2343 boolean bReparse = false; 2344 boolean bRecalculate = false; 2345 2332 2346 SessionStats.DeletedItems(itemList); 2333 2347 List<Frame> modifiedFrames = new LinkedList<Frame>(); … … 2339 2353 i.setHighlightMode(HighlightMode.None); 2340 2354 bReparse |= i.hasOverlay(); 2355 bRecalculate |= i.recalculateWhenChanged(); 2341 2356 } 2342 2357 // If they are all free items then add the current frame … … 2388 2403 currentFrame.addAllToUndo(itemList); 2389 2404 itemList.clear(); 2390 if (bReparse) 2405 if (bReparse) { 2391 2406 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 } 2392 2414 2393 2415 } … … 2558 2580 if (merger.size() == 1 && txt.getLink() != null) { 2559 2581 // If the text item is linked then use that 2560 ((WidgetCorner)mergee).setLink(txt.getAbsoluteLink(), txt); 2582 ((WidgetCorner) mergee).setLink(txt 2583 .getAbsoluteLink(), txt); 2561 2584 } else { 2562 2585 remain.addAll(merger); … … 2566 2589 if (merger.size() == 1 && txt.getLink() != null) { 2567 2590 // If the text item is linked then use that 2568 ((WidgetEdge)mergee).setLink(txt.getAbsoluteLink(), txt); 2591 ((WidgetEdge) mergee).setLink(txt 2592 .getAbsoluteLink(), txt); 2569 2593 } else { 2570 2594 remain.addAll(merger); … … 2608 2632 } 2609 2633 updateCursor(); 2634 2610 2635 mergee.getParent().setChanged(true); 2636 2611 2637 ItemUtils.EnclosedCheck(mergee.getParent().getItems()); 2612 2638 // Mike: Why does parse frame have to be called?!? … … 2666 2692 2667 2693 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(); 2670 2698 Iterator<Item> iter = toGrab.iterator(); 2671 2699 while (iter.hasNext()) { … … 2677 2705 if (i.equals(_lastHighlightedItem)) 2678 2706 _lastHighlightedItem = null; 2707 2708 bRecalculate |= i.recalculateWhenChanged(); 2679 2709 // i.setSelectedMode(SelectedMode.None); 2680 2710 // Check if it has a relative link if so make it absolute … … 2683 2713 if (i.getParent() != null) { 2684 2714 i.getParent().removeItem(i); 2685 if (currentFrame .equals(i.getParent().getName()))2715 if (currentFrameName.equals(i.getParent().getName())) 2686 2716 i.setParent(null); 2687 2717 } … … 2704 2734 } 2705 2735 } 2706 frame.recalculate(); 2736 currentFrame.change(); 2737 2707 2738 _lastHighlightedItem = null; 2708 2739 updateCursor(); … … 2744 2775 } 2745 2776 if (bReparse) 2746 FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false); 2777 FrameUtils.Parse(currentFrame, false, false); 2778 else 2779 currentFrame.notifyObservers(bRecalculate); 2747 2780 2748 2781 FrameGraphics.Repaint(); … … 2805 2838 public static void anchor(Collection<Item> toAnchor) { 2806 2839 boolean bReparse = false; 2840 boolean bRecalculate = false; 2807 2841 // Need to make sure we check enclosure for overlays etc 2808 2842 Set<Frame> checkEnclosure = new HashSet<Frame>(); … … 2827 2861 checkEnclosure.add(i.getParentOrCurrentFrame()); 2828 2862 bReparse |= i.hasOverlay(); 2863 bRecalculate |= i.recalculateWhenChanged(); 2829 2864 } 2830 2865 } … … 2834 2869 for (Frame f : checkEnclosure) { 2835 2870 ItemUtils.EnclosedCheck(f.getItems()); 2836 f.recalculate(); 2837 } 2871 } 2872 2873 Frame currentFrame = DisplayIO.getCurrentFrame(); 2838 2874 if (bReparse) 2839 FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false); 2875 FrameUtils.Parse(currentFrame, false, false); 2876 else { 2877 currentFrame.notifyObservers(bRecalculate); 2878 } 2840 2879 FrameGraphics.Repaint(); 2841 2880 } -
trunk/src/org/expeditee/gui/FrameObserver.java
r214 r376 5 5 6 6 public abstract void removeSubject(Frame frame); 7 8 public abstract boolean isVisible(); 7 9 } -
trunk/src/org/expeditee/gui/FrameUtils.java
r373 r376 240 240 } 241 241 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()) { 243 245 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 } 244 254 245 255 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 } 256 257 for (int i = 1; i < toAlign.size(); i++) { 257 258 Item current = toAlign.get(i); … … 580 581 // check for all tags setting user values 581 582 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()); 687 698 } 688 699 } … … 692 703 693 704 private static List<Text> getStyle(Frame child) { 705 if (child == null) 706 return new LinkedList<Text>(); 707 694 708 List<Text> style = new ArrayList<Text>(8); 695 709 for (int i = 0; i < 10; i++) { … … 750 764 return alt; 751 765 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 } 758 775 759 776 return alt; … … 1125 1142 } 1126 1143 1144 public static Item onItem(float floatX, float floatY, 1145 boolean changeLastEdited) { 1146 return onItem(DisplayIO.getCurrentFrame(), floatX, floatY, 1147 changeLastEdited); 1148 } 1149 1127 1150 /** 1128 1151 * Searches through the list of items on this frame to find one at the given … … 1135 1158 * @return The Item at the given coordinates, or NULL if none is found. 1136 1159 */ 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) { 1138 1162 // System.out.println("MouseX: " + floatX + " MouseY: " + floatY); 1139 1163 int x = Math.round(floatX); … … 1172 1196 // otherwise, the mouse is on the frame 1173 1197 } 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 } 1184 1210 } 1185 1211 ArrayList<Item> checkList = new ArrayList<Item>(); … … 1236 1262 public synchronized static Item getCurrentItem() { 1237 1263 return onItem(DisplayIO.getCurrentFrame(), DisplayIO.getMouseX(), 1238 FrameMouseActions.getY() );1264 FrameMouseActions.getY(), true); 1239 1265 } 1240 1266 … … 1433 1459 1434 1460 yPos += spacing; 1435 profile.addText(xPos, yPos, "@HomeFrame : " + profile.getName(), null,1461 profile.addText(xPos, yPos, "@HomeFrame", null, 1436 1462 profile.getName()); 1437 1463 yPos += spacing; 1438 1464 String defaultFrameName = profile.getFramesetName() + "0"; 1439 profile.addText(xPos, yPos, "@DefaultFrame : " + defaultFrameName, null,1465 profile.addText(xPos, yPos, "@DefaultFrame", null, 1440 1466 defaultFrameName); 1441 1467 yPos += spacing; … … 1539 1565 1540 1566 public static void setLastEdited(Text lastEdited) { 1567 1541 1568 // If the lastEdited is being changed then check if its @i 1542 1569 Frame toReparse = null; 1543 1570 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 1545 1579 if (lastEdited != LastEdited) { 1546 1580 if (LastEdited.startsWith("@i")) { … … 1574 1608 } 1575 1609 } 1576 toReparse = LastEdited.getParent();1610 toReparse = parent; 1577 1611 } else if (LastEdited.recalculateWhenChanged()) { 1578 toRecalculate = LastEdited.getParentOrCurrentFrame(); 1612 toRecalculate = parent; 1613 } 1614 1615 if (parent.hasObservers()) { 1616 toUpdateObservers = parent; 1579 1617 } 1580 1618 // Update the formula if in XRay mode … … 1584 1622 } 1585 1623 if (lastEdited != LastEdited && LastEdited.getText().length() == 0) { 1586 LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);1624 parent.removeItem(LastEdited); 1587 1625 } 1588 1626 } … … 1592 1630 if (toReparse != null) { 1593 1631 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 } 1596 1640 } 1597 1641 } -
trunk/src/org/expeditee/gui/MessageBay.java
r336 r376 262 262 boolean displayAlways, String action) { 263 263 List<String> actions = new LinkedList<String>(); 264 actions.add(action); 264 if (action != null) 265 actions.add(action); 265 266 return displayMessage(message, link, actions, color, displayAlways); 266 267 } -
trunk/src/org/expeditee/gui/MouseEventRouter.java
r328 r376 39 39 40 40 private Container _contentPane; 41 41 42 42 private List<MouseListener> _mouseListeners = new LinkedList<MouseListener>(); 43 43 44 private List<MouseMotionListener> _mouseMotionListeners = new LinkedList<MouseMotionListener>(); 45 44 46 private List<MouseWheelListener> _mouseWheelListeners = new LinkedList<MouseWheelListener>(); 45 47 … … 50 52 * 51 53 * @param menuBar 52 * 54 * Must not be null. 53 55 * 54 56 * @param contentPane 55 * 57 * Must not be null. 56 58 */ 57 59 public MouseEventRouter(JMenuBar menuBar, Container contentPane) { … … 69 71 this._contentPane = contentPane; 70 72 } 71 73 72 74 /** 73 75 * Listens only to events to frames... i.e. to exeditee, not to widgets. 74 76 * 75 77 * @param listener 76 * 78 * The listener to add. 77 79 */ 78 80 public void addExpediteeMouseListener(MouseListener listener) { 79 if (listener == null) throw new NullPointerException("listener"); 81 if (listener == null) 82 throw new NullPointerException("listener"); 80 83 _mouseListeners.add(listener); 81 84 } 82 83 85 84 86 public void removeExpediteeMouseListener(MouseListener listener) { 85 if (listener == null) throw new NullPointerException("listener"); 87 if (listener == null) 88 throw new NullPointerException("listener"); 86 89 _mouseListeners.remove(listener); 87 90 } 88 91 89 92 public void addExpediteeMouseMotionListener(MouseMotionListener listener) { 90 if (listener == null) throw new NullPointerException("listener"); 93 if (listener == null) 94 throw new NullPointerException("listener"); 91 95 _mouseMotionListeners.add(listener); 92 96 } 93 97 94 98 public void removeExpediteeMouseMotionListener(MouseMotionListener listener) { 95 if (listener == null) throw new NullPointerException("listener"); 99 if (listener == null) 100 throw new NullPointerException("listener"); 96 101 _mouseMotionListeners.remove(listener); 97 102 } 98 103 99 104 public void addExpediteeMouseWheelListener(MouseWheelListener listener) { 100 if (listener == null) throw new NullPointerException("listener"); 105 if (listener == null) 106 throw new NullPointerException("listener"); 101 107 _mouseWheelListeners.add(listener); 102 108 } 103 109 104 110 public void removeExpediteeMouseWheelListener(MouseWheelListener listener) { 105 if (listener == null) throw new NullPointerException("listener"); 111 if (listener == null) 112 throw new NullPointerException("listener"); 106 113 _mouseWheelListeners.remove(listener); 107 114 } … … 109 116 /** 110 117 * Conceal event catching from outside 118 * 111 119 * @author Brook Novak 112 120 */ 113 121 private class EventCatcher implements AWTEventListener { 114 122 115 123 /** 116 124 * All events for every component in frame are fired to here … … 121 129 } 122 130 } 123 131 124 132 } 125 133 … … 133 141 */ 134 142 private void routeMouseEvent(MouseEvent e) { 135 143 136 144 _currentMouseEvent = e; 137 145 138 146 // First convert the point to expeditee space 139 147 Point containerPoint = SwingUtilities.convertPoint(e.getComponent(), e … … 158 166 // whether an expeditee item is currently picked up 159 167 boolean forwardToExpiditee = false; 160 boolean isOverPopup = PopupManager.getInstance().isPointOverPopup(containerPoint); 168 boolean isOverPopup = PopupManager.getInstance().isPointOverPopup( 169 containerPoint); 161 170 if (isOverPopup) { 162 171 // Popups have highest preference 163 172 // 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 166 176 // popups. 167 177 if (!FreeItems.getInstance().isEmpty()) { … … 169 179 } 170 180 171 // Note: all frame.content pane events belong to expeditee181 // Note: all frame.content pane events belong to expeditee 172 182 } else if (e.getSource() == _contentPane 173 183 || e.getSource() == Browser._theBrowser 174 184 || !FreeItems.getInstance().isEmpty()) { 175 185 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? */ 180 188 // NOTE: Do not use FrameUtils.getCurrentItem() - thats relevent 181 189 // for old mouse position only … … 188 196 // when passing mouse events!!! 189 197 forwardToExpiditee = (FrameUtils.onItem(DisplayIO 190 .getCurrentFrame(), containerPoint.x, containerPoint.y) != null); 191 } 192 198 .getCurrentFrame(), containerPoint.x, containerPoint.y, 199 true) != null); 200 } 201 193 202 // 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 197 206 // NOTE: Convert util masks-out the needed extensions 198 207 MouseEvent withExtensions = null; … … 205 214 switch (e.getID()) { 206 215 case MouseEvent.MOUSE_MOVED: 207 216 208 217 for (MouseMotionListener listener : _mouseMotionListeners) { 209 218 listener.mouseMoved(expediteeEvent); 210 219 } 211 220 212 221 // Ensure that expiditee has focus only if no popups exist 213 222 if (Browser._theBrowser != null … … 221 230 222 231 break; 223 232 224 233 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 228 239 for (MouseListener listener : _mouseListeners) { 229 240 listener.mouseClicked(withExtensions); 230 241 } 231 232 break; 233 242 243 break; 244 234 245 case MouseEvent.MOUSE_PRESSED: 235 236 withExtensions = duplicateMouseEvent(expediteeEvent, e.getModifiers() | e.getModifiersEx()); 246 247 withExtensions = duplicateMouseEvent(expediteeEvent, e 248 .getModifiers() 249 | e.getModifiersEx()); 237 250 238 251 for (MouseListener listener : _mouseListeners) { 239 252 listener.mousePressed(withExtensions); 240 253 } 241 242 break; 243 254 255 break; 256 244 257 case MouseEvent.MOUSE_RELEASED: 245 withExtensions = duplicateMouseEvent(expediteeEvent, e.getModifiers() | e.getModifiersEx()); 258 withExtensions = duplicateMouseEvent(expediteeEvent, e 259 .getModifiers() 260 | e.getModifiersEx()); 246 261 247 262 for (MouseListener listener : _mouseListeners) { … … 251 266 break; 252 267 case MouseEvent.MOUSE_WHEEL: 253 MouseWheelEvent mwe = (MouseWheelEvent) expediteeEvent;268 MouseWheelEvent mwe = (MouseWheelEvent) expediteeEvent; 254 269 for (MouseWheelListener listener : _mouseWheelListeners) { 255 270 listener.mouseWheelMoved(mwe); … … 274 289 275 290 } else { 276 291 277 292 // Keep expeditees mouse X/Y updated 278 293 FrameMouseActions.MouseX = expediteeEvent.getX(); … … 283 298 // to give visual feedback yo users such that swing has focus. 284 299 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); 287 304 } 288 305 … … 297 314 } 298 315 } 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 300 318 // 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())) { 303 323 PopupManager.getInstance().hideAutohidePopups(); 304 324 } … … 327 347 return false; 328 348 } 329 349 330 350 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()); 344 358 } 345 359 346 360 public static MouseEvent getCurrentMouseEvent() { 347 361 348 362 return _currentMouseEvent; 349 363 -
trunk/src/org/expeditee/gui/Reminders.java
r348 r376 11 11 12 12 public synchronized static void init(final Frame reminderFrame) { 13 if(reminderFrame == null) 14 return; 15 13 16 for (Text text : reminderFrame.getBodyTextItems(false)) { 14 17 try { -
trunk/src/org/expeditee/io/AbstractHTMLWriter.java
r348 r376 9 9 10 10 import org.expeditee.gui.Frame; 11 import org.expeditee.gui.FrameIO; 11 12 import org.expeditee.gui.MessageBay; 12 13 import org.expeditee.gui.UserSettings; … … 23 24 _format = ".html"; 24 25 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 } 25 37 26 38 _writer.write("<html>" + ItemWriter.NEW_LINE); -
trunk/src/org/expeditee/io/DefaultFrameWriter.java
r348 r376 75 75 _ItemTags.put("I", Item.class.getMethod("getAnchorBottom", param)); 76 76 _ItemTags.put("P", Item.class.getMethod("getPosition", param)); 77 _ItemTags.put("T", Text.class.getMethod("getText", param)); 77 78 _ItemTags.put("F", Item.class.getMethod("getLink", param)); 78 79 _ItemTags.put("X", Item.class.getMethod("getAction", param)); … … 107 108 // Store the formula in the text property NOT the answer 108 109 _ItemTags.put("J", Item.class.getMethod("getFormula", param)); 109 _ItemTags.put("T", Text.class.getMethod("getText", param));110 110 111 111 _ItemTags.put("a", Text.class.getMethod("getWordSpacing", param)); -
trunk/src/org/expeditee/io/DefaultTreeWriter.java
r290 r376 15 15 16 16 private int _indent = 0; 17 17 18 18 // the list of frames currently being processed 19 19 private Stack<FrameCounter> _frames = new Stack<FrameCounter>(); … … 81 81 82 82 Frame next = FrameIO.LoadFrame(cur.frame); 83 83 84 if (next == null) { 84 85 return; 85 86 } 87 88 Text title = next.getTitleItem(); 86 89 87 90 // the items on the frame currently being processed. … … 109 112 // ignore annotation and framenames 110 113 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) { 114 121 cur.index = i; 115 122 _frames.push(cur); … … 139 146 // Dont write out the title here because it is written 140 147 // out earlier 141 } else if (item != next.getTitleItem())148 } else if (item != title) 142 149 this.writeItem(item); 143 150 } … … 177 184 } 178 185 } 179 186 180 187 protected int getIndent() { 181 188 return _indent; -
trunk/src/org/expeditee/io/HTMLWriter.java
r362 r376 8 8 import org.expeditee.actions.Misc; 9 9 import org.expeditee.gui.FrameIO; 10 import org.expeditee.items.FramePicture; 10 11 import org.expeditee.items.Item; 11 12 import org.expeditee.items.Picture; … … 14 15 import sun.awt.image.ToolkitImage; 15 16 16 public class HTML BWriter extends AbstractHTMLWriter {17 public class HTMLWriter extends AbstractHTMLWriter { 17 18 18 19 @Override … … 20 21 throws IOException { 21 22 int indent = getIndent(); 22 if (indent == 0)23 if (indent == 0) 23 24 return; 24 25 25 26 String heading = toWrite.getText(); 26 27 String tag = "h" + indent; … … 41 42 @Override 42 43 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 46 63 String filesFolder = getFilesFolder(); 47 64 String fileName; 48 65 // If its a bufferedImage then just write it out to the files directory 49 // This means it is probably a FrameImage50 if (image instanceof BufferedImage || image instanceof ToolkitImage) {66 // This means it is probably a FrameImage 67 if (image instanceof BufferedImage) { 51 68 String link = pic.getAbsoluteLink(); 52 69 // Account for the possiblitly of an unlinked buffered image 53 70 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(); 62 75 63 76 String oldImageName = FrameIO.IMAGES_PATH + fileName; -
trunk/src/org/expeditee/io/TXTWriter.java
r306 r376 10 10 import org.expeditee.items.Text; 11 11 12 public class TXTWriter extends DefaultTreeWriter {12 public class TXTWriter extends DefaultTreeWriter { 13 13 14 14 private boolean _join = false; … … 72 72 @Override 73 73 protected void writeText(Text text) throws IOException { 74 for (String s : text.getTextList()) {74 String s = text.getText(); 75 75 76 77 76 for (int i = 0; i < _indent; i++) 77 _writer.write("\t"); 78 78 79 _writer.write(s); 80 _writer.write(ItemWriter.NEW_LINE); 81 } 79 _writer.write(s); 80 _writer.write(ItemWriter.NEW_LINE); 82 81 83 82 if (!_join) -
trunk/src/org/expeditee/io/oldHTMLWriter.java
r362 r376 10 10 import org.expeditee.items.Text; 11 11 12 public class HTMLWriter extends DefaultTreeWriter {12 public class oldHTMLWriter extends DefaultTreeWriter { 13 13 14 14 private int _indent = 0; -
trunk/src/org/expeditee/items/Circle.java
r311 r376 143 143 + Math.pow(Math.abs(_center.getY() - y), 2)); 144 144 145 return Math.abs(distance - radius) < Item.getGravity() * 2;145 return Math.abs(distance - radius) < getGravity() * 2; 146 146 } 147 147 … … 337 337 _line.refreshStroke(thick); 338 338 } 339 340 @Override 341 public boolean isConnectedToAnnotation() { 342 return false; 343 } 339 344 } -
trunk/src/org/expeditee/items/Dot.java
r282 r376 26 26 // Standard Item variables 27 27 28 private static final int _MINIMUM_DOT_SIZE = 6;28 //private static final int _MINIMUM_DOT_SIZE = 6; 29 29 30 30 private static final int MINIMUM_DOT_SIZE = 2; … … 120 120 // Draw the highlighting rectangle surrounding the dot 121 121 // this is drawn even if its part of a rectangle 122 123 if(isVectorItem()) 124 updatePolygon(); 125 122 126 Rectangle rect = getPolygon().getBounds(); 123 127 if (_mode == HighlightMode.Enclosed || … … 177 181 int thick = Math.round(getThickness()); 178 182 // Sets a minimum size for the dot 179 thick = Math.max(thick, _MINIMUM_DOT_SIZE);183 thick = Math.max(thick, getGravity() * 2); 180 184 181 185 int x = getX() - thick / 2; -
trunk/src/org/expeditee/items/Item.java
r362 r376 26 26 import org.expeditee.actions.Misc; 27 27 import org.expeditee.actions.Simple; 28 import org.expeditee.gui.AttributeValuePair; 28 29 import org.expeditee.gui.DisplayIO; 29 30 import org.expeditee.gui.Frame; … … 31 32 import org.expeditee.gui.FrameIO; 32 33 import org.expeditee.gui.FrameKeyboardActions; 34 import org.expeditee.gui.FrameMouseActions; 33 35 import org.expeditee.gui.FrameUtils; 34 36 import org.expeditee.gui.FreeItems; … … 229 231 } 230 232 231 public static int getGravity() { 233 public int getGravity() { 234 if (isVectorItem()) { 235 return 2; 236 } 232 237 return org.expeditee.gui.UserSettings.Gravity; 233 238 } … … 323 328 324 329 protected int _highlightThickness = 2; 330 331 protected int _vectorHighlightThickness = 1; 325 332 326 333 // arrowhead parameters … … 700 707 public Color getHighlightColor() { 701 708 if (_highlightColor.equals(getPaintColor())) 702 return ALTERNATE_HIGHLIGHT;703 return _highlightColor;709 return getAlternateHighlightColor(); 710 return getDefaultHighlightColor(); 704 711 } 705 712 … … 762 769 public boolean hasFormula() { 763 770 return _formula != null; 771 } 772 773 public boolean hasAttributeValuePair() { 774 return _attributeValuePair != null && _attributeValuePair.hasPair(); 764 775 } 765 776 … … 853 864 854 865 protected Color getPaintHighlightColor() { 855 Color highlightColor = _highlightColor;866 Color highlightColor = getDefaultHighlightColor(); 856 867 if (hasVisibleBorder()) { 857 868 if (getPaintBorderColor().equals(highlightColor)) { 858 highlightColor = ALTERNATE_HIGHLIGHT;869 highlightColor = getDefaultHighlightColor(); 859 870 } 860 871 } else if (getPaintBackgroundColor().equals(highlightColor)) { 861 highlightColor = ALTERNATE_HIGHLIGHT;872 highlightColor = getDefaultHighlightColor(); 862 873 } 863 874 if (getParent() != null … … 867 878 if (hasVisibleBorder()) { 868 879 if (highlightColor.equals(getBorderColor()) 869 && getThickness() == _highlightThickness) {880 && getThickness() == getHighlightThickness()) { 870 881 highlightColor = new Color(highlightColor.getRed(), 871 882 highlightColor.getGreen(), highlightColor.getBlue(), … … 875 886 876 887 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; 877 914 } 878 915 … … 2461 2498 private Overlay _overlay = null; 2462 2499 2500 protected AttributeValuePair _attributeValuePair = null; 2501 2463 2502 /** 2464 2503 * For now there can only be one enclosure per item … … 2745 2784 updatePolygon(); 2746 2785 } 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 }*/ 2747 2811 } -
trunk/src/org/expeditee/items/Permission.java
r115 r376 1 1 package org.expeditee.items; 2 2 3 public enum Permission {3 public enum Permission { 4 4 none, followLinks, copy, createFrames, full; 5 5 6 6 /** 7 * Converts the given Expeditee justification code into a int corresponding8 * t o the constants defined in Item.7 * Converts the given Expeditee permission code into a int corresponding to 8 * the constants defined in Item. 9 9 * 10 10 * @param permissionCode 11 * The Expeditee justification code to convert11 * The Expeditee permission code to convert 12 12 * @return The resulting int corresponding to one of the constants defined 13 13 * in Item … … 16 16 return getPermission(permissionCode, Permission.full); 17 17 } 18 19 public static Permission getPermission(String permissionCode, Permission defaultPermission) { 18 19 public static Permission getPermission(String permissionCode, 20 Permission defaultPermission) { 20 21 if (permissionCode == null) 21 22 return defaultPermission; 22 23 23 24 permissionCode = permissionCode.trim().toLowerCase(); 24 25 if (permissionCode.length() == 0) 25 26 return defaultPermission; 26 27 27 28 // if it is a single char just match the first character 28 try {29 try { 29 30 return values()[Integer.parseInt(permissionCode)]; 30 31 // 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) { 35 36 } 36 37 } … … 39 40 return defaultPermission; 40 41 } 41 42 42 43 43 public int getCode() { … … 52 52 return p1.ordinal() < p2.ordinal() ? p1 : p2; 53 53 } 54 54 55 55 public static Permission max(Permission p1, Permission p2) { 56 56 return p1.ordinal() > p2.ordinal() ? p1 : p2; -
trunk/src/org/expeditee/items/Picture.java
r311 r376 64 64 private Point _cropEnd = null; 65 65 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); 69 69 70 70 private boolean _showCropping = false; … … 277 277 } 278 278 279 public Point getStart() { 280 return _start; 281 } 282 283 public Point getEnd() { 284 return _end; 285 } 286 279 287 /** 280 288 * Gets the width with which the picture is displayed on the screen. … … 354 362 g.drawPolygon(getPolygon()); 355 363 } 356 364 357 365 if (isHighlighted()) { 358 366 Stroke borderStroke = new BasicStroke(1, CAP, JOIN); … … 361 369 g.drawPolygon(getPolygon()); 362 370 } 363 } 364 371 372 //System.out.print("p_"); 373 } 374 365 375 @Override 366 376 public Color getHighlightColor() { … … 484 494 485 495 public Image getCroppedImage() { 486 if (_image == null)496 if (_image == null) 487 497 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; 491 521 } 492 522 … … 616 646 617 647 } 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) { 621 651 setScale(getScale() * scale); 622 652 super.scale(scale, originX, originY); -
trunk/src/org/expeditee/items/Text.java
r371 r376 259 259 260 260 /** 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. 262 263 * 263 264 * @param text … … 266 267 @Override 267 268 public void setText(String text) { 268 if (_text != null && text.length() < _text.length())269 269 // if (_text != null && text.length() < _text.length()) 270 invalidateAll(); 270 271 _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); 271 280 rebuild(true); 272 281 invalidateAll(); … … 277 286 return; 278 287 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(); 285 303 } 286 304 … … 589 607 // otherwise, we are inserting text 590 608 } else { 591 setProcessedText(null); 592 setFormula(null); 609 clearCache(); 593 610 // determine what line is being pointed to 594 611 line = getLinePosition(mouseY); … … 729 746 730 747 /** 748 * 749 */ 750 private void clearCache() { 751 _attributeValuePair = null; 752 setProcessedText(null); 753 setFormula(null); 754 } 755 756 /** 731 757 * @param pos 732 758 * @return … … 741 767 742 768 public Point2D.Float moveCursor(int direction, float mouseX, float mouseY, 743 boolean setSelection ) {769 boolean setSelection, boolean wholeWord) { 744 770 if (setSelection) { 745 if ( getSelectionSize() <= 0) {771 if (!hasSelection()) { 746 772 setSelectionStart(mouseX, mouseY); 747 773 } 774 } else { 775 // clearSelection(); 748 776 } 749 777 … … 789 817 if (direction == LEFT) { 790 818 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') { 798 841 line--; 799 842 hit = _textLayouts.get(line) … … 807 850 hit = _textLayouts.get(line).getNextRightHit( 808 851 _textLayouts.get(line).getCharacterCount() - 1); 852 /* 853 * Skip the spaces at the end of a line with soft 854 * linebreak 855 */ 809 856 while (hit.getCharIndex() > 0 810 857 && _text.charAt(_lineOffsets.get(line) … … 817 864 .getCharacterCount()) { 818 865 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 820 869 && hit.getCharIndex() < _textLayouts.get(line) 821 870 .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))) 824 874 hit = _textLayouts.get(line).getNextRightHit(hit); 825 875 } else if (line < _textLayouts.size() - 1) { … … 1514 1564 g.setColor(getPaintHighlightColor()); 1515 1565 Stroke highlightStroke = new BasicStroke( 1516 (float) _highlightThickness, CAP, JOIN);1566 (float) getHighlightThickness(), CAP, JOIN); 1517 1567 g.setStroke(highlightStroke); 1518 1568 if (HighlightMode.Enclosed.equals(getHighlightMode())) … … 1553 1603 } 1554 1604 1555 layout.draw(g, getX() + getJustOffset(layout), y);1605 layout.draw(g, 1 + getX() + getJustOffset(layout), y); 1556 1606 1557 1607 /* … … 1608 1658 copy.setWidth(getWidth()); 1609 1659 copy.setFont(getFont()); 1610 copy.setText(_text.toString()); 1660 if (hasFormula()) { 1661 copy.calculate(getFormula()); 1662 } else { 1663 copy.setText(_text.toString()); 1664 } 1611 1665 copy.setHidden(!isVisible()); 1612 1666 // copy.setWidth(getWidth()); … … 1798 1852 Frame modelFrame = getParentOrCurrentFrame(); 1799 1853 if (modelFrame != null) { 1800 setRightMargin( getParentOrCurrentFrame().getNameItem().getX()1854 setRightMargin(modelFrame.getNameItem().getX() 1801 1855 - MARGIN_LEFT); 1802 1856 } else { 1857 System.out.print("Error: text.resetTitlePosition, getParent or currentFrame returned null"); 1803 1858 setRightMargin(MARGIN_LEFT); 1804 1859 } … … 1837 1892 Text template = this.copy(); 1838 1893 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 */ 1843 1899 template.setText("@"); 1844 1900 return template; … … 1958 2014 return false; 1959 2015 } 2016 formula = formula.replace(':', '='); 2017 1960 2018 String lowercaseFormula = formula.toLowerCase(); 1961 2019 ExpediteeJEP myParser = new ExpediteeJEP(); … … 1970 2028 continue; 1971 2029 if (i instanceof Text && !i.isAnnotation()) { 1972 AttributeValuePair pair = new AttributeValuePair(i.getText());2030 AttributeValuePair pair = i.getAttributeValuePair(); 1973 2031 if (pair.hasPair()) { 1974 2032 try { … … 1985 2043 try { 1986 2044 double value = pair.getDoubleValue(); 1987 myParser.addVariable("$" + nextVarNo++, value); 2045 if (value != Double.NaN) 2046 myParser.addVariable("$" + nextVarNo++, value); 1988 2047 } catch (NumberFormatException nfe) { 1989 2048 continue; … … 2022 2081 this.setText(result); 2023 2082 this.setFormula(formula); 2083 2084 if (!this.hasAction()) { 2085 setActionMark(false); 2086 setAction("extract formula"); 2087 } 2024 2088 } 2025 2089 } catch (Throwable e) { 2026 this.setText(getFormula()); 2090 String formula2 = getFormula(); 2091 this.setText(formula2); 2092 this.setFormula(formula2); 2027 2093 return false; 2028 2094 } 2095 2096 _attributeValuePair = null; 2097 2029 2098 return true; 2030 2099 } … … 2042 2111 double enclosureArea = Double.MAX_VALUE; 2043 2112 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 */ 2046 2117 if (!seen.contains(i) && i.isEnclosed()) { 2047 2118 seen.addAll(i.getEnclosingDots()); … … 2064 2135 2065 2136 /** 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 2067 2139 */ 2068 2140 public boolean recalculateWhenChanged() { 2069 2141 if (/* 2070 2142 * !isAnnotation() && 2071 */(hasFormula() || getText().contains(":") ||isLineEnd()))2143 */(hasFormula() || isLineEnd())) 2072 2144 return true; 2073 2145 try { 2074 Double.parseDouble(getText()); 2075 return true; 2146 AttributeValuePair avp = getAttributeValuePair(); 2147 2148 if (!avp.getDoubleValue().equals(Double.NaN)) 2149 return true; 2076 2150 } catch (Exception e) { 2077 } 2151 e.printStackTrace(); 2152 } 2153 2078 2154 return false; 2079 2155 } -
trunk/src/org/expeditee/items/widgets/DataFrameWidget.java
r352 r376 59 59 * changed so it will be refreshed when the user goes back 60 60 */ 61 assert (false);62 // _needsUpdating = true;61 assert (false); 62 // _needsUpdating = true; 63 63 // update(); 64 64 } … … 119 119 if (oldLink == null) { 120 120 _needsUpdating = true; 121 // Need to refresh imediately so that the data appears when adding a 122 // link to a graph 123 refresh(); 121 124 } else { 122 125 refresh(); -
trunk/src/org/expeditee/items/widgets/SampleWidget2.java
r203 r376 2 2 3 3 4 import java.awt.Color; 4 5 import java.awt.FlowLayout; 6 import java.awt.Font; 5 7 6 import javax.swing.J Button;8 import javax.swing.JCheckBox; 7 9 import javax.swing.JComboBox; 8 10 import javax.swing.JLabel; … … 10 12 import javax.swing.JSplitPane; 11 13 import javax.swing.JTextArea; 14 import javax.swing.JToggleButton; 12 15 13 16 import org.expeditee.items.Text; … … 21 24 super(source, new JSplitPane(JSplitPane.VERTICAL_SPLIT), 60, -1, 40, -1); 22 25 26 Font bigFont = null; 27 23 28 JSplitPane sp = (JSplitPane)super._swingComponent; 24 29 25 30 JPanel p = new JPanel(new FlowLayout()); 31 p.setBackground(new Color(255,228,195)); 26 32 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); 28 36 29 JButton button = new JButton("Click Me!"); 37 JToggleButton button = new JToggleButton("Toggle Style"); 38 button.setFont(bigFont); 30 39 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"); 32 47 33 48 _text = new JTextArea(); 49 _text.setFont(bigFont); 34 50 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); 36 53 37 54 p.add(lbl); 38 55 p.add(_combo); 39 56 p.add(button); 40 p.add( button2);57 p.add(checkBox); 41 58 42 59 sp.setTopComponent(p); -
trunk/src/org/expeditee/items/widgets/charts/AbstractCategory.java
r311 r376 54 54 } 55 55 } 56 } catch ( NumberFormatException e) {56 } catch (Exception e) { 57 57 58 58 } -
trunk/src/org/expeditee/items/widgets/charts/AbstractChart.java
r298 r376 85 85 case SizeUp: 86 86 invalidateLink(); 87 FrameKeyboardActions.SetSize(getFirstCorner(), 1, false, true); 87 FrameKeyboardActions.SetSize(getFirstCorner(), 1, false, 88 true); 88 89 invalidateSelf(); 89 90 FrameGraphics.refresh(true); 90 // FrameGraphics.requestRefresh(true);91 // FrameGraphics.requestRefresh(true); 91 92 break; 92 93 case SizeDown: 93 94 invalidateLink(); 94 FrameKeyboardActions.SetSize(getFirstCorner(), -1, false, true); 95 FrameKeyboardActions.SetSize(getFirstCorner(), -1, false, 96 true); 95 97 invalidateSelf(); 96 98 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); 100 102 break; 101 103 case ChangeColor: … … 221 223 protected void refreshData(Frame dataFrame) { 222 224 clearSubjects(); 225 223 226 boolean swap = false; 224 227 if (dataFrame.hasAnnotation("swap")) { … … 265 268 } 266 269 /* if (foundData) */{ 270 /* 271 * At minimum add the data frame as a subject even if there is no data 272 * on it... yet 273 */ 267 274 addSubject(dataFrame); 268 275 } … … 362 369 if (legend != null) { 363 370 legend.setFrame(new BlockBorder(newThickness, newThickness, 364 newThickness, newThickness, getSource().get Color()));371 newThickness, newThickness, getSource().getPaintColor())); 365 372 legend.setItemFont(legend.getItemFont().deriveFont(fontSize)); 366 373 float pad = newThickness + 1; -
trunk/src/org/expeditee/math/ExpediteeJEP.java
r311 r376 84 84 continue; 85 85 86 AttributeValuePair avp = new AttributeValuePair(t.getText());86 AttributeValuePair avp = t.getAttributeValuePair(); 87 87 if (avp.hasPair()) { 88 88 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 } 92 95 } catch (Exception e) { 93 96 e.printStackTrace(); … … 111 114 if (i instanceof Text && !i.isAnnotation() && !i.isLineEnd()) { 112 115 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)) { 116 118 vector.add(value); 117 119 } 118 } catch (NumberFormatException e) { 120 } catch (Exception e) { 121 e.printStackTrace(); 119 122 } 120 123 } -
trunk/src/org/expeditee/simple/SString.java
r235 r376 3 3 public class SString extends SPrimitive<String> { 4 4 public static String prefix = SVariable.prefix + "s" + SVariable.separator; 5 6 Double doubleValue_ = null; 5 7 6 8 public SString() { … … 12 14 } 13 15 14 public SString(String value) /* throws Exception*/{16 public SString(String value) /* throws Exception */{ 15 17 super(value); 16 18 } … … 19 21 public void parse(String s) { 20 22 value_ = s; 23 doubleValue_ = null; 21 24 } 22 25 … … 39 42 @Override 40 43 public Double doubleValue() { 44 if (doubleValue_ != null) 45 return doubleValue_; 46 41 47 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 } 46 59 } 47 return (double) Long.decode(value_);60 return doubleValue_; 48 61 } 49 62 … … 64 77 public void setValue(SPrimitive v) { 65 78 value_ = v.stringValue(); 79 doubleValue_ = null; 66 80 } 67 81 -
trunk/src/org/expeditee/stats/DocumentStats.java
r362 r376 12 12 protected int _treeFrames = 0; 13 13 14 protected int _characters = 0; 15 14 16 protected int _words = 0; 15 17 … … 33 35 34 36 // Initialise variables with the data for this frames comet 37 _characters = 0; 35 38 _words = 0; 36 39 _textItems = 0; … … 44 47 _words += text.split("\\s+").length; 45 48 _sentances += text.split("\\.+").length; 49 _characters += text.length(); 46 50 47 51 String link = i.getAbsoluteLink(); … … 59 63 visited); 60 64 _words += childItemStats._words; 65 _characters += childItemStats._characters; 61 66 _textItems += childItemStats._textItems; 62 67 _sentances += childItemStats._sentances; … … 69 74 StringBuffer sb = new StringBuffer(); 70 75 sb.append(SessionStats.getDate()); 71 sb.append("DocStats: 72 sb.append("Title: ").append(_title).append('\n');76 sb.append("DocStats: ").append(_name).append('\n'); 77 sb.append("Title: ").append(_title).append('\n'); 73 78 sb.append("Frames: ").append(_treeFrames).append('\n'); 74 79 sb.append("TextItems: ").append(_textItems).append('\n'); 75 80 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); 77 83 return sb.toString(); 78 84 }
Note:
See TracChangeset
for help on using the changeset viewer.