Changeset 376 for trunk/src/org/expeditee/actions/Misc.java
- Timestamp:
- 11/02/08 13:05:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.