Changeset 80 for trunk/src/org
- Timestamp:
- 05/30/08 10:14:43 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 3 added
- 58 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r72 r80 7 7 import java.net.URL; 8 8 import java.util.ArrayList; 9 import java.util.Collection; 9 10 import java.util.Enumeration; 10 11 import java.util.HashMap; … … 26 27 27 28 /** 28 * The Action class is used to launch KMS Actions as well as launching JAGs.29 * The Action class is used to launch Actions and Agents. 29 30 * 30 31 * This class checks all class files in the same directory, and reads in and … … 32 33 * the lowercase method names can be mapped to the correctly capatilized method 33 34 * names (to provide case-insensitivity) 35 * 36 * When adding an action to a class in the actions folder the following must be 37 * considered: 38 * <li> If the first parameter is of type Frame or Item they will be called with 39 * the current frame and the item used to execute the action.</li> 40 * <li> If the second item is also of type Frame or Item it will be set to the 41 * current frame or item.</li> 42 * <li> If there are multiple overloads for the same method they should be 43 * declared in order of the methods with the most parameteres to least 44 * parameters.</li> 34 45 */ 35 46 public class Actions { … … 59 70 // Get a File object for the package 60 71 File directory = null; 61 String path = pckgname.replace('.', '/');72 String path = pckgname.replace('.', File.separatorChar); 62 73 try { 63 74 ClassLoader cld = Thread.currentThread().getContextClassLoader(); … … 65 76 throw new ClassNotFoundException("Can't get class loader."); 66 77 } 67 URL resource = cld.getResource(path); 78 URL resource = null; 79 try { 80 Enumeration<URL> resources = cld.getResources(path); 81 while (resources.hasMoreElements()) { 82 URL url = resources.nextElement(); 83 // Ingore the classes in the test folder when we are running 84 // the program from Eclipse 85 // This doesnt apply when running directly from the jar 86 // because the test classes are not compiled into the jar. 87 if (!url.toString().toLowerCase().contains("test")) { 88 resource = url; 89 break; 90 } 91 } 92 } catch (Exception e) { 93 94 } 68 95 if (resource == null) { 69 96 throw new ClassNotFoundException("No resource for " + path); … … 137 164 * Clears out the Action and JAG Hashtables and refills them. Normally this 138 165 * is only called once when the system starts. 139 */ 140 public static void Init() { 166 * @return a warning message if there were any problems loading agents or actions. 167 */ 168 public static Collection<String> Init() { 169 Collection<String> warnings = new LinkedList<String>(); 141 170 Class[] classes; 171 142 172 try { 143 173 classes = getClasses(AGENTS_PACKAGE); … … 149 179 } 150 180 } catch (Exception e) { 151 System.out 152 .println("You must have Java 1.5 or higher to run Expeditee"); 153 System.out.println(e.getMessage()); 181 warnings.add("You must have Java 1.5 or higher to run Expeditee"); 182 warnings.add(e.getMessage()); 154 183 } 155 184 try { … … 158 187 for (int i = 0; i < classes.length; i++) { 159 188 String name = classes[i].getSimpleName(); 189 // Ignore the test classes 190 if (name.toLowerCase().contains("test")) 191 continue; 160 192 // read in all the methods from the class 161 193 try { 162 // System.out.println(name) ;194 // System.out.println(name) 163 195 LoadMethods(Class.forName(ACTIONS_PACKAGE + name)); 164 196 } catch (ClassNotFoundException e) { … … 168 200 } 169 201 } catch (Exception e) { 170 System.out.println(e.getMessage()); 171 } 202 warnings.add(e.getMessage()); 203 } 204 return warnings; 172 205 } 173 206 … … 186 219 // only allow methods with the right modifiers 187 220 if (MethodCheck(m)) { 188 if (!(_Actions.containsKey(m.getName().toLowerCase()))) 189 _Actions.put(m.getName().toLowerCase(), m); 221 String lowercaseName = m.getName().toLowerCase(); 222 if (!(_Actions.containsKey(lowercaseName))) 223 _Actions.put(lowercaseName, m); 190 224 else { 191 225 int i = 0; 192 while (_Actions.containsKey( m.getName().toLowerCase()+ i))226 while (_Actions.containsKey(lowercaseName + i)) 193 227 i++; 194 228 195 _Actions.put( m.getName().toLowerCase()+ i, m);229 _Actions.put(lowercaseName + i, m); 196 230 } 197 231 … … 259 293 mname = mname.substring(1); 260 294 261 mname = mname.trim() .toLowerCase();262 295 mname = mname.trim(); 296 String lowercaseName = mname.toLowerCase(); 263 297 // check for protection on frame 264 298 if (ItemUtils.ContainsTag(source.getItems(), "@No" + mname)) { … … 269 303 270 304 // retrieve methods that match the name 271 Method toRun = _Actions.get( mname);305 Method toRun = _Actions.get(lowercaseName); 272 306 273 307 // if this is not the name of a method, it may be the name of an agent … … 287 321 possibles.add(toRun); 288 322 int i = 0; 289 while (_Actions.containsKey( mname + i)) {290 possibles.add(_Actions.get( mname + i));323 while (_Actions.containsKey(lowercaseName + i)) { 324 possibles.add(_Actions.get(lowercaseName + i)); 291 325 i++; 292 326 } … … 301 335 Object[] parameters = CreateObjects(possible, source, launcher, 302 336 command); 337 // Check that there are the same amount of params 338 if (parameters == null) { 339 continue; 340 } 303 341 304 342 possible.invoke(null, parameters); … … 322 360 */ 323 361 private static void LaunchAgent(String name, String parameters, Frame source) { 362 // Use the correct case version for printing error messages 363 String nameWithCorrectCase = name; 364 name = name.toLowerCase(); 324 365 // save the current frame (if necesssary) 325 366 FrameUtils.LeavingFrame(source); … … 362 403 // if there is no constructor, return 363 404 if (con == null) { 364 FrameGraphics.DisplayMessage("Invalid parametres for agent."); 405 FrameGraphics.DisplayMessage("Invalid parametres for agent: " 406 + nameWithCorrectCase); 365 407 // System.out.println("Constructor not found..."); 366 408 return; … … 375 417 // check for errors during initialisation 376 418 if (!_Agent.initialise(source)) { 377 FrameGraphics.ErrorMessage("Error initialising agent: " + name); 419 FrameGraphics.ErrorMessage("Error initialising agent: " 420 + nameWithCorrectCase); 378 421 return; 379 422 } … … 390 433 391 434 } catch (ClassNotFoundException cnf) { 392 FrameGraphics.ErrorMessage("Error: '" + name 393 + "' is not an action statement or Agent.");435 FrameGraphics.ErrorMessage("Error: '" + nameWithCorrectCase 436 + "' is not an action or agent."); 394 437 } catch (Exception e) { 395 FrameGraphics.ErrorMessage("Error creating Agent: '" + name + "'"); 438 FrameGraphics.ErrorMessage("Error creating Agent: '" 439 + nameWithCorrectCase + "'"); 396 440 System.out.println("Agent set to Null."); 397 441 _Agent = null; … … 421 465 */ 422 466 public static void stopAgent() { 423 if (_Agent != null ) {467 if (_Agent != null && _Agent.isRunning()) { 424 468 FrameGraphics.DisplayMessage("Stopping Agent..."); 425 469 _Agent.stop(); 426 427 // while (_Agent.isRunning())428 // ;429 // FrameGraphics.DisplayMessage("Agent Stopped.");430 470 } 431 471 } … … 489 529 param = values.trim(); 490 530 // check if its a string 491 if (param.length() > 0 && param.charAt(0) == '"') {531 if (param.length() > 0 && param.charAt(0) == '"') { 492 532 int endOfString = param.indexOf('"', 1); 493 if (endOfString > 0) {494 param = param.substring(0, endOfString);533 if (endOfString > 0) { 534 param = param.substring(0, endOfString); 495 535 } 496 536 } … … 501 541 // convert the value to an object 502 542 Object o = Conversion.Convert(paramTypes[ind], param); 543 if (o == null) 544 return null; 503 545 objects[ind] = o; 504 546 } … … 530 572 if (params.charAt(0) == '"') { 531 573 int endOfString = params.indexOf('"', 1); 532 if (endOfString > 0) {574 if (endOfString > 0) { 533 575 if (endOfString > params.length()) 534 576 return ""; -
trunk/src/org/expeditee/actions/IDE.java
r22 r80 13 13 public static void CompileClass() { 14 14 Frame source = DisplayIO.getCurrentFrame(); 15 String title = source.getTitle ().getTextNoList();15 String title = source.getTitleItem().getText(); 16 16 String[] tokens = title.split(" "); 17 17 String className = tokens[tokens.length - 1]; … … 33 33 34 34 public static String getClassName(Frame source) { 35 return source.getTitle ().getTextNoList().trim();35 return source.getTitleItem().getText().trim(); 36 36 //String title = source.getTitle().getTextNoList(); 37 37 //String[] tokens = title.split(" "); -
trunk/src/org/expeditee/actions/Misc.java
r78 r80 98 98 public static void RunCurrentItem(Item current) { 99 99 if (current instanceof Text) { 100 List<String> actions = ((Text) current).getText ();100 List<String> actions = ((Text) current).getTextList(); 101 101 102 102 for (String action : actions) { … … 117 117 Frame toDelete = DisplayIO.getCurrentFrame(); 118 118 DisplayIO.Back(); 119 String deletedFrame = toDelete.get FrameName();119 String deletedFrame = toDelete.getName(); 120 120 String deletedFrameNameLowercase = deletedFrame.toLowerCase(); 121 121 try { … … 123 123 if (!del) { 124 124 FrameGraphics.ErrorMessage("Error trying to delete " 125 + toDelete.get FrameName());125 + toDelete.getName()); 126 126 } else { 127 127 Frame current = DisplayIO.getCurrentFrame(); … … 316 316 */ 317 317 public static void JpegFrame(String framename) { 318 ImageFrame(framename, "JP G");318 ImageFrame(framename, "JPEG"); 319 319 } 320 320 321 321 /** 322 322 * Saves the current frame as a JPEG image. This is the same as calling 323 * JpegFrame(currentFrame.get FrameName())323 * JpegFrame(currentFrame.getName()) 324 324 */ 325 325 public static void JpegFrame() { 326 ImageFrame(DisplayIO.getCurrentFrame().getFrameName(), "JPG"); 326 ImageFrame(DisplayIO.getCurrentFrame().getName(), "JPEG"); 327 } 328 329 public static void JPGFrame() { 330 JpegFrame(); 327 331 } 328 332 … … 339 343 /** 340 344 * Saves the current frame as a PNG image. This is the same as calling 341 * PNGFrame(currentFrame.get FrameName())345 * PNGFrame(currentFrame.getName()) 342 346 */ 343 347 public static void PNGFrame() { 344 ImageFrame(DisplayIO.getCurrentFrame().getFrameName(), "PNG"); 348 ImageFrame(DisplayIO.getCurrentFrame().getName(), "PNG"); 349 } 350 351 public static String SaveImage(BufferedImage screen, String format, String directory, String fileName){ 352 // Check if we need to append the suffix 353 if (fileName.indexOf('.') < 0) 354 fileName += "." + format.toLowerCase(); 355 356 try { 357 // set up the file for output 358 String fullFileName = directory + fileName; 359 File out = new File(fullFileName); 360 if (!out.getParentFile().exists()) 361 out.mkdirs(); 362 363 // If the image is successfully written out return the fileName 364 if (ImageIO.write(screen, format, out)) 365 return fileName; 366 367 } catch (Exception e) { 368 e.printStackTrace(); 369 } 370 return null; 371 } 372 373 public static String ImageFrame(Frame frame, String format, String directory) { 374 assert (frame != null); 375 376 FrameGraphics.UpdateBuffer(frame, false); 377 378 BufferedImage screen = null; 379 Image frameBuffer = frame.getBuffer(); 380 if (frame.getBuffer() instanceof BufferedImage) { 381 screen = (BufferedImage) frameBuffer; 382 } else if (frameBuffer instanceof VolatileImage) { 383 screen = ((VolatileImage) frameBuffer).getSnapshot(); 384 } else { 385 assert (false); 386 } 387 return SaveImage(screen, format, directory, frame.getExportFileName()); 345 388 } 346 389 … … 355 398 public static void ImageFrame(String framename, String format) { 356 399 Frame loaded = FrameIO.LoadFrame(framename); 357 String fileName = loaded.getExportFileName();358 400 359 401 // if the frame was loaded successfully 360 402 if (loaded != null) { 361 // check if the buffer needs to be redrawn 362 // if (loaded.getBuffer() == null) 363 FrameGraphics.UpdateBuffer(loaded, false); 364 365 BufferedImage screen = null; 366 Image frameBuffer = loaded.getBuffer(); 367 if (loaded.getBuffer() instanceof BufferedImage){ 368 screen = (BufferedImage)frameBuffer; 369 }else if (frameBuffer instanceof VolatileImage){ 370 screen = ((VolatileImage)frameBuffer).getSnapshot(); 371 }else{ 372 assert(false); 373 } 374 375 try { 376 // set up the file for output 377 File out = new File(FrameIO.EXPORTS_DIR + fileName + "." 378 + format.toLowerCase()); 379 if (!out.getParentFile().exists()) 380 out.mkdirs(); 381 382 ImageIO.write(screen, format, out); 403 String path = FrameIO.IMAGES_PATH; 404 String frameName = ImageFrame(loaded, format, path); 405 if (frameName != null) 383 406 FrameGraphics.DisplayMessage("Frame successfully saved to " 384 + FrameIO.EXPORTS_DIR + out.getName());385 } catch (IOException e) {386 FrameGraphics.ErrorMessage( e.getMessage());387 }407 + path + frameName); 408 else 409 FrameGraphics.ErrorMessage("Could not find image writer for " 410 + format + " format"); 388 411 // if the frame was not loaded successfully, alert the user 389 412 } else … … 455 478 timeKeeper.restart(); 456 479 for (int j = 0; j < repsPerTest; j++) { 457 methodA.invoke((Object) null, new Object[] {});480 methodA.invoke((Object) null, new Object[] {}); 458 481 } 459 482 timeA += timeKeeper.getElapsedMillis(); … … 461 484 // Test methodB 462 485 for (int j = 0; j < repsPerTest; j++) { 463 methodB.invoke((Object) null, new Object[] {});486 methodB.invoke((Object) null, new Object[] {}); 464 487 } 465 488 timeB += timeKeeper.getElapsedMillis(); … … 530 553 // swap the items links 531 554 item.setActions(current.getAction()); 532 item.setLink(childFrame.get FrameName());533 current.setLink(parentFrame.get FrameName());555 item.setLink(childFrame.getName()); 556 current.setLink(parentFrame.getName()); 534 557 // current.setLink(null); 535 558 current.setActions(null); … … 564 587 565 588 for (Item i : body) 566 if (i != child.getTitle () && !i.isAnnotation()) {589 if (i != child.getTitleItem() && !i.isAnnotation()) { 567 590 item = i; 568 591 break; -
trunk/src/org/expeditee/actions/NavigationActions.java
r70 r80 21 21 _LastItemUsed = i; 22 22 if (i.getParent() != null) { 23 _Parent = i.getParent().get FrameName();23 _Parent = i.getParent().getName(); 24 24 } 25 25 } … … 196 196 197 197 // ByMike: If the 'Next' child is being sought for the 1st time... 198 String sourceName = source.get FrameName().toLowerCase();198 String sourceName = source.getName().toLowerCase(); 199 199 200 200 // ByMike: Find the first occurence of a ParentItem linked to the source … … 212 212 && !items.get(i).isAnnotation() 213 213 && !items.get(i).getAbsoluteLink().equalsIgnoreCase( 214 source.get FrameName())) {214 source.getName())) { 215 215 _LastItemUsed = items.get(i); 216 216 FrameUtils.DisplayFrame(_LastItemUsed.getAbsoluteLink(), false); -
trunk/src/org/expeditee/actions/Simple.java
r78 r80 8 8 import java.util.ArrayList; 9 9 import java.util.Collection; 10 import java.util.HashMap; 10 11 import java.util.LinkedList; 11 12 import java.util.List; 13 import java.util.Map; 12 14 import java.util.Random; 13 15 … … 63 65 private static final String DEFAULT_FRAME = "$fp."; 64 66 67 private static final String DEFAULT_ASSOCIATION = "$ap."; 68 65 69 private static final String EXIT_TEXT = "exitall"; 66 70 … … 121 125 List<String> actions = new ArrayList<String>(); 122 126 actions.add(RUN_FRAME_ACTION); 123 newSimpleTest.getTitle ().setActions(actions);127 newSimpleTest.getTitleItem().setActions(actions); 124 128 FrameUtils.DisplayFrame(newSimpleTest, true); 125 129 FrameGraphics.DisplayMessage("New test created"); … … 131 135 next = FrameIO.LoadNext(next); 132 136 } while (next != null 133 && (next.getTitle () == null || !RUN_FRAME_ACTION134 .equalsIgnoreCase(next.getTitle ().getFirstAction())));137 && (next.getTitleItem() == null || !RUN_FRAME_ACTION 138 .equalsIgnoreCase(next.getTitleItem().getFirstAction()))); 135 139 FrameUtils.DisplayFrame(next, true); 136 140 } … … 141 145 prev = FrameIO.LoadPrevious(prev); 142 146 } while (prev != null 143 && (prev.getTitle () == null || !RUN_FRAME_ACTION144 .equalsIgnoreCase(prev.getTitle ().getFirstAction())));147 && (prev.getTitleItem() == null || !RUN_FRAME_ACTION 148 .equalsIgnoreCase(prev.getTitleItem().getFirstAction()))); 145 149 146 150 FrameUtils.DisplayFrame(prev, true); … … 153 157 // check if its a test frame 154 158 if (next != null 155 && next.getTitle () != null156 && RUN_FRAME_ACTION.equalsIgnoreCase(next.getTitle ()159 && next.getTitleItem() != null 160 && RUN_FRAME_ACTION.equalsIgnoreCase(next.getTitleItem() 157 161 .getFirstAction())) { 158 162 lastTest = next; … … 191 195 if (nextFrame == null) 192 196 continue; 193 Item frameTitle = nextFrame.getTitle ();197 Item frameTitle = nextFrame.getTitleItem(); 194 198 if (frameTitle == null) 195 199 continue; … … 248 252 if (current.getLink() == null) { 249 253 current = current.copy(); 250 current.setLink(DisplayIO.getCurrentFrame().get FrameName());254 current.setLink(DisplayIO.getCurrentFrame().getName()); 251 255 } 252 256 … … 264 268 265 269 private static void FlagError(Item item) { 266 FrameUtils.DisplayFrame(item.getParent().get FrameName(), true);270 FrameUtils.DisplayFrame(item.getParent().getName(), true); 267 271 item.setSelectedMode(SelectedMode.Normal); 268 272 item.setSelectionColor(Color.CYAN); … … 342 346 Frame frame = i.getParent(); 343 347 344 if (i == frame.getTitle () || i == frame.getFrameNameItem()348 if (i == frame.getTitleItem() || i == frame.getNameItem() 345 349 || i.isAnnotation()) { 346 350 return false; … … 357 361 */ 358 362 private static String[] parseStatement(Text code) throws Exception { 359 String statement = code.getText NoList();363 String statement = code.getText(); 360 364 ArrayList<String> tokens = new ArrayList<String>(); 361 365 … … 420 424 // Add call to the start of the title if it doesnt exist 421 425 // This makes the call and signature tokens counts match 422 String procedureTitle = procedure.getTitle ().getFirstLine();426 String procedureTitle = procedure.getTitleItem().getFirstLine(); 423 427 if (!procedureTitle.toLowerCase().startsWith("call ")) 424 428 procedureTitle = "call " + procedureTitle; … … 588 592 throw new RuntimeException(e.getMessage()); 589 593 } 594 } else if (tokens[0].equals("setassociation")) { 595 assertMinParametreCount(tokens, 3); 596 597 Map map = (Map) context.getPointers().getVariable(tokens[1]) 598 .getValue(); 599 String attribute = context.getPrimitives().getStringValue( 600 tokens[2]); 601 String value = context.getPrimitives() 602 .getStringValue(tokens[3]); 603 map.put(attribute, value); 604 return Status.OK; 590 605 } else if (tokens[0].equals("setframevalue")) { 591 606 assertMinParametreCount(tokens, 3); … … 605 620 // Begin the search 606 621 for (Text text : targetFrame.getBodyTextItems(true)) { 607 String s = text.getText NoList().toLowerCase();622 String s = text.getText().toLowerCase(); 608 623 609 624 if (s.startsWith(targetAttribute)) { … … 697 712 Item item = (Item) context.getPointers().getVariable( 698 713 tokens[1]).getValue(); 699 item.setAction(context.getPrimitives().getVariable( tokens[2])700 .stringValue());714 item.setAction(context.getPrimitives().getVariable( 715 tokens[2]).stringValue()); 701 716 } else if (tokens[0].equals("setitemfillcolor")) { 702 717 assertVariableType(tokens[1], 1, SPointer.itemPrefix); … … 757 772 Text item = (Text) context.getPointers().getVariable(tokens[1]) 758 773 .getValue(); 759 List<String> itemText = item.getText ();774 List<String> itemText = item.getTextList(); 760 775 761 776 while (row >= itemText.size()) { … … 858 873 // Begin the search 859 874 for (Text text : targetFrame.getBodyTextItems(true)) { 860 String s = text.getText NoList().toLowerCase();875 String s = text.getText().toLowerCase(); 861 876 if (s.startsWith(targetAttribute)) { 862 877 attributeItem = text; 863 value = AttributeUtils. stripValue(s);878 value = AttributeUtils.getValue(s); 864 879 if (value.length() > 0) { 865 880 found = true; … … 880 895 found = true; 881 896 valueItem = text; 882 value = text.getText NoList();897 value = text.getText(); 883 898 break; 884 899 } … … 915 930 frameVar).getValue(); 916 931 context.getPrimitives().setValue(frameNameVar, 917 frame.get FrameName());932 frame.getName()); 918 933 return Status.OK; 919 934 } else if (tokens[0].startsWith("getframefilepath")) { … … 932 947 String log = SessionStats.getFrameEventList(); 933 948 Text t; 934 // try { 949 935 950 t = (Text) context.getPointers().getVariable(tokens[1]) 936 951 .getValue(); 937 952 t.setText(log); 938 // } catch (Exception e) {939 // t = new Text(-1, log);940 // context.getPointers().setObject(tokens[1], t);941 // }942 953 943 954 return Status.OK; 944 955 } 956 } else if (tokens[0].equals("getassociation")) { 957 assertMinParametreCount(tokens, 3); 958 Map map = (Map) context.getPointers().getVariable(tokens[1]) 959 .getValue(); 960 String attribute = context.getPrimitives().getStringValue( 961 tokens[2]); 962 String newValue = map.get(attribute).toString(); 963 context.getPrimitives().setValue(tokens[3], newValue); 964 return Status.OK; 945 965 } else if (tokens[0].startsWith("getcurrent")) { 946 966 if (tokens[0].equals("getcurrentframe")) { … … 954 974 if (tokens.length > 2) { 955 975 context.getPrimitives().setValue(tokens[2], 956 new SString(currentFrame.get FrameName()));976 new SString(currentFrame.getName())); 957 977 } 958 978 return Status.OK; … … 1017 1037 context.getPrimitives().setValue(tokens[2], 1018 1038 new SString(action)); 1019 } else if (tokens[0].equals("getitemfillcolor")) {1039 } else if (tokens[0].equals("getitemfillcolor")) { 1020 1040 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1021 1041 // assertPrimitiveType(tokens[2], 2); … … 1043 1063 tokens[2], 1044 1064 new SString((item instanceof Text) ? ((Text) item) 1045 .getText NoList() : ""));1065 .getText() : "")); 1046 1066 } else 1047 1067 throw new Exception("Unsupported getItem command: " … … 1209 1229 String s = getMessage(tokens, context, code.toString(), " ", 2); 1210 1230 for (int i = 0; i < s.length(); i++) { 1211 FrameKeyboardActions.processChar(s.charAt(i) );1231 FrameKeyboardActions.processChar(s.charAt(i), false); 1212 1232 Thread.sleep((int) (delay * 1000)); 1213 1233 } … … 1218 1238 .equals("type") ? " " : "", 1); 1219 1239 for (int i = 0; i < s.length(); i++) { 1220 FrameKeyboardActions.processChar(s.charAt(i) );1240 FrameKeyboardActions.processChar(s.charAt(i), false); 1221 1241 Thread.sleep(25); 1222 1242 } … … 1566 1586 tokens[1]).getValue(); 1567 1587 FrameIO.SuspendCache(); 1568 Frame freshCopy = FrameIO.LoadFrame(frameToCopy.get FrameName());1588 Frame freshCopy = FrameIO.LoadFrame(frameToCopy.getName()); 1569 1589 // Change the frameset if one was provided 1570 1590 if (tokens.length > 3) { … … 1658 1678 new SCharacter(nextChar)); 1659 1679 1680 return Status.OK; 1681 } else if (tokens[0].equals("createassociation")) { 1682 1683 String associationVar = DEFAULT_ASSOCIATION; 1684 1685 if (tokens.length > 0) { 1686 assertVariableType(tokens[1], 2, SPointer.associationPrefix); 1687 associationVar = tokens[1]; 1688 } 1689 Map<String, String> newMap = new HashMap<String, String>(); 1690 context.getPointers().setObject(associationVar, newMap); 1691 return Status.OK; 1692 } else if (tokens[0].equals("deleteassociation")) { 1693 1694 String associationVar = DEFAULT_ASSOCIATION; 1695 1696 if (tokens.length > 0) { 1697 assertVariableType(tokens[1], 2, SPointer.associationPrefix); 1698 associationVar = tokens[1]; 1699 } 1700 context.getPointers().delete(associationVar); 1660 1701 return Status.OK; 1661 1702 } else if (tokens[0].equals("openreadfile")) { … … 1847 1888 int count = 0; 1848 1889 if (item instanceof Text) 1849 count = countCharsInString(((Text) item).getTextNoList(), 1850 pattern); 1890 count = countCharsInString(((Text) item).getText(), pattern); 1851 1891 context.getPrimitives().setValue(tokens[3], new SInteger(count)); 1852 1892 return Status.OK; … … 2141 2181 } 2142 2182 2143 assertVariableType(tokens[ 1], 1, SPointer.itemPrefix);2144 assertVariableType(tokens[ 2], 2, SPointer.framePrefix);2183 assertVariableType(tokens[2], 2, SPointer.itemPrefix); 2184 assertVariableType(tokens[1], 1, SPointer.framePrefix); 2145 2185 Frame currFrame = (Frame) context.getPointers().getVariable( 2146 tokens[ 2]).getValue();2186 tokens[1]).getValue(); 2147 2187 // Create the ip variable 2148 Item frameName = currFrame.getFrameNameItem(); 2149 Item frameTitle = currFrame.getTitle(); 2188 Item frameTitle = currFrame.getTitleItem(); 2150 2189 2151 2190 for (Item i : currFrame.getItems()) { 2152 if (i == frame Name || i == frameTitle)2191 if (i == frameTitle) 2153 2192 continue; 2154 2193 if (!(itemType.isInstance(i))) 2155 2194 continue; 2156 2195 2157 context.getPointers().setObject(tokens[ 1], i);2196 context.getPointers().setObject(tokens[2], i); 2158 2197 Status status = RunFrameAndReportError(code, context); 2159 2198 // check if we need to exit this loop because of … … 2182 2221 context.getPrimitives().exp(tokens[1], tokens[2]); 2183 2222 } else if (tokens[0].equals("log")) { 2184 context.getPrimitives().log(tokens[ 1], tokens[2]);2223 context.getPrimitives().log(tokens[2], tokens[2]); 2185 2224 } else if (tokens[0].equals("log10")) { 2186 2225 context.getPrimitives().log10(tokens[1], tokens[2]); … … 2188 2227 context.getPrimitives().sqrt(tokens[1], tokens[2]); 2189 2228 } else if (tokens[0].equals("add")) { 2190 context.getPrimitives().add(tokens[ 1], tokens[2]);2229 context.getPrimitives().add(tokens[2], tokens[1]); 2191 2230 } else if (tokens[0].equals("subtract")) { 2192 context.getPrimitives().subtract(tokens[ 1], tokens[2]);2231 context.getPrimitives().subtract(tokens[2], tokens[1]); 2193 2232 } else if (tokens[0].equals("multiply")) { 2194 context.getPrimitives().multiply(tokens[ 1], tokens[2]);2233 context.getPrimitives().multiply(tokens[2], tokens[1]); 2195 2234 } else if (tokens[0].equals("divide")) { 2196 context.getPrimitives().divide(tokens[ 1], tokens[2]);2235 context.getPrimitives().divide(tokens[2], tokens[1]); 2197 2236 } else 2198 2237 throw new RuntimeException("Invalid statement:"); … … 2200 2239 } 2201 2240 } else if (tokens.length == 4) { 2241 if (tokens[0].equals("foreachassociation")) { 2242 assertExactParametreCount(tokens, 3); 2243 assertVariableType(tokens[1], 1, SPointer.associationPrefix); 2244 Map<String,String> map = (Map<String,String>) context.getPointers().getVariable( 2245 tokens[1]).getValue(); 2246 for(Map.Entry entry: map.entrySet()){ 2247 String value = entry.getValue().toString(); 2248 String key = entry.getKey().toString(); 2249 context.getPrimitives().setValue(tokens[2], key); 2250 context.getPrimitives().setValue(tokens[3], value); 2251 Status status = RunFrameAndReportError(code, context); 2252 // check if we need to exit this loop because of 2253 // statements in the code that was run 2254 if (status == Status.Exit || status == Status.Return) 2255 return status; 2256 else if (status == Status.Break) 2257 return Status.OK; 2258 } 2259 return Status.OK; 2260 } 2261 2202 2262 if (Primitives.isPrimitive(tokens[1]) 2203 2263 && Primitives.isPrimitive(tokens[2]) -
trunk/src/org/expeditee/agents/ClipboardTree.java
r4 r80 8 8 * 9 9 */ 10 public class ClipboardTree extends WriteTree { 11 10 public class ClipboardTree extends WriteTree { 12 11 public ClipboardTree() { 13 super( "clipboard");12 super(CLIPBOARD); 14 13 } 15 14 16 15 public ClipboardTree(String format) { 17 super(format + " clipboard");16 super(format + " " + CLIPBOARD); 18 17 } 19 18 -
trunk/src/org/expeditee/agents/ComputeTree.java
r66 r80 97 97 if (value == null) { 98 98 value = AttributeUtils.getDoubleValue(((Text) i) 99 .getText NoList());99 .getText()); 100 100 } 101 101 … … 126 126 127 127 if (result != null) { 128 AttributeUtils.setSingleValue(frame.getTitle (), _format128 AttributeUtils.setSingleValue(frame.getTitleItem(), _format 129 129 .format(result)); 130 130 } -
trunk/src/org/expeditee/agents/CopyTree.java
r45 r80 64 64 FrameIO.SuspendCache(); 65 65 66 Frame fresh = FrameIO.LoadFrame(toProcess.get FrameName());67 if (_nameMap.containsKey(fresh.get FrameName().toLowerCase())) {66 Frame fresh = FrameIO.LoadFrame(toProcess.getName()); 67 if (_nameMap.containsKey(fresh.getName().toLowerCase())) { 68 68 fresh 69 .set FrameName(_nameMap.get(fresh.getFrameName()69 .setName(_nameMap.get(fresh.getName() 70 70 .toLowerCase())); 71 71 } else { … … 73 73 fresh.setFrameNumber(++_lastNumber); 74 74 75 _nameMap.put(toProcess.get FrameName().toLowerCase(), fresh76 .get FrameName().toLowerCase());75 _nameMap.put(toProcess.getName().toLowerCase(), fresh 76 .getName().toLowerCase()); 77 77 } 78 78 … … 98 98 // annotation links need to be parsed at the end 99 99 if (i.getAbsoluteLink().toLowerCase().startsWith(_nameFrom)) { 100 _toReparse.add(fresh.get FrameName());100 _toReparse.add(fresh.getName()); 101 101 added = true; 102 102 } -
trunk/src/org/expeditee/agents/DefaultAgent.java
r72 r80 16 16 */ 17 17 public abstract class DefaultAgent implements Agent { 18 18 public static final String CLIPBOARD = "Clipboard"; 19 19 20 protected long _timeRemaining = 0; 20 21 -
trunk/src/org/expeditee/agents/Format.java
r78 r80 162 162 protected void finalise(Frame start) { 163 163 if (_success) 164 overwriteMessage("Formating complete."); 164 overwriteMessage("Formatting complete."); 165 } 166 167 @Override 168 protected void message(String message) { 169 } 170 171 @Override 172 protected void overwriteMessage(String message) { 165 173 } 166 174 -
trunk/src/org/expeditee/agents/Sort.java
r4 r80 23 23 if (i instanceof Text) 24 24 // do not sort title and framename 25 if (i.getID() > -1 && i != start.getTitle ()25 if (i.getID() > -1 && i != start.getTitleItem() 26 26 && !i.isAnnotation()) { 27 27 textItems.add((Text) i); -
trunk/src/org/expeditee/agents/SwitchyardTree.java
r50 r80 16 16 for (Text textItem : frame.getBodyTextItems(false)) { 17 17 // Delete all non-annotations with more that one letter 18 if (textItem.getText NoList().length() > 1)18 if (textItem.getText().length() > 1) 19 19 frame.removeItem(textItem); 20 20 else { -
trunk/src/org/expeditee/agents/TreeProcessor.java
r70 r80 39 39 return null; 40 40 41 _frames.push(new FrameCounter(toProcess.get FrameName(), -1));41 _frames.push(new FrameCounter(toProcess.getName(), -1)); 42 42 43 43 // process the entire tree of frames in depth-first order … … 56 56 if (cur.index < 0) { 57 57 if (next != null) 58 overwriteMessage("Processing: " + next.get FrameName());58 overwriteMessage("Processing: " + next.getName()); 59 59 processFrame(next); 60 60 } … … 78 78 if (linked != null) { 79 79 FrameCounter fc = new FrameCounter(linked 80 .get FrameName(), -1);80 .getName(), -1); 81 81 if (!_frames.contains(fc)) { 82 82 // remember what frame we are on before -
trunk/src/org/expeditee/agents/WriteTree.java
r50 r80 3 3 import java.io.IOException; 4 4 import java.lang.reflect.Constructor; 5 import java.lang.reflect.InvocationTargetException;6 5 7 6 import org.expeditee.actions.Actions; … … 34 33 35 34 public WriteTree(String params) { 36 String format = params.trim() .toLowerCase();35 String format = params.trim(); 37 36 38 if (format.equals ("clipboard")) {37 if (format.equalsIgnoreCase(CLIPBOARD)) { 39 38 _clipboard = true; 40 39 return; … … 48 47 _format = params.substring(0, ind).toLowerCase(); 49 48 50 if (lastParam.equals ("clipboard"))49 if (lastParam.equalsIgnoreCase(CLIPBOARD)) 51 50 _clipboard = true; 52 51 else … … 97 96 98 97 if (_clipboard) 99 _treeWriter.setOutputLocation( "clipboard");98 _treeWriter.setOutputLocation(CLIPBOARD); 100 99 else if (_outFile != null) 101 100 _treeWriter.setOutputLocation(_outFile); … … 110 109 111 110 if (_clipboard) 112 _frameWriter.setOutputLocation( "clipboard");111 _frameWriter.setOutputLocation(CLIPBOARD); 113 112 else if (_outFile != null) 114 113 _frameWriter.setOutputLocation(_outFile); … … 116 115 117 116 } catch (ClassNotFoundException e) { 118 // TODO Auto-generated catch block119 // e.printStackTrace();120 117 FrameGraphics 121 118 .WarningMessage("The agent does not exist or has incorrect parametres."); 122 119 return false; 123 } catch (InstantiationException e) { 124 // TODO Auto-generated catch block 125 e.printStackTrace(); 126 return false; 127 } catch (IllegalAccessException e) { 128 // TODO Auto-generated catch block 129 e.printStackTrace(); 130 return false; 131 } catch (SecurityException e) { 132 // TODO Auto-generated catch block 133 e.printStackTrace(); 134 return false; 135 } catch (NoSuchMethodException e) { 136 // TODO Auto-generated catch block 137 e.printStackTrace(); 138 return false; 139 } catch (IllegalArgumentException e) { 140 // TODO Auto-generated catch block 141 e.printStackTrace(); 142 return false; 143 } catch (InvocationTargetException e) { 144 // TODO Auto-generated catch block 120 } catch (Exception e) { 145 121 e.printStackTrace(); 146 122 return false; … … 163 139 } 164 140 } catch (IOException e) { 165 System.out.println("Caught");141 //System.out.println("Caught"); 166 142 Logger.Log(e); 167 FrameGraphics.ErrorMessage(" Exception in WriteTree: "143 FrameGraphics.ErrorMessage("IOException in WriteTree: " 168 144 + e.getMessage()); 169 145 e.printStackTrace(); -
trunk/src/org/expeditee/gui/AttributeUtils.java
r78 r80 77 77 _AllowNull = new LinkedList<Method>(); 78 78 _AllowNull.add(Item.class.getMethod("getColor", param)); 79 _AllowNull.add(Item.class.getMethod("getBackgroundColor", param));80 79 81 80 _AllowNull.add(Frame.class.getMethod("getBackgroundColor", param)); … … 160 159 pColor)); 161 160 162 _SetMethods.put("action", Item.class.getMethod("setActions", pList)); 161 _SetMethods 162 .put("action", Item.class.getMethod("setActions", pList)); 163 163 _SetMethods.put("a", Item.class.getMethod("setActions", pList)); 164 164 _SetMethods.put("d", Item.class.getMethod("setData", pList)); … … 180 180 _SetMethods.put("linkmark", Item.class.getMethod("setLinkMark", 181 181 pBool)); 182 _SetMethods.put("lm", Item.class.getMethod("setLinkMark", 183 pBool)); 182 _SetMethods.put("lm", Item.class.getMethod("setLinkMark", pBool)); 184 183 _SetMethods.put("actionmark", Item.class.getMethod("setActionMark", 185 184 pBool)); 186 _SetMethods.put("am", Item.class.getMethod("setActionMark", 187 pBool)); 185 _SetMethods.put("am", Item.class.getMethod("setActionMark", pBool)); 188 186 189 187 _SetMethods.put("actioncursorenter", Item.class.getMethod( … … 206 204 _SetMethods.put("lp", Item.class.getMethod("setLinePattern", 207 205 pIntArray)); 208 206 209 207 _SetMethods.put("linkframeset", Item.class.getMethod( 210 208 "setLinkFrameset", pString)); 211 _SetMethods.put("lf", Item.class.getMethod( 212 "setLinkFrameset",pString));209 _SetMethods.put("lf", Item.class.getMethod("setLinkFrameset", 210 pString)); 213 211 _SetMethods.put("linktemplate", Item.class.getMethod( 214 212 "setLinkTemplate", pString)); 215 _SetMethods.put("lt", Item.class.getMethod( 216 "setLinkTemplate",pString));213 _SetMethods.put("lt", Item.class.getMethod("setLinkTemplate", 214 pString)); 217 215 218 216 _SetMethods.put("family", Text.class … … 236 234 _SetMethods.put("bgc0", Frame.class.getMethod("setBackgroundColor", 237 235 pColor)); 238 _SetMethods.put("protection", Frame.class.getMethod( "setProtection",239 pString));236 _SetMethods.put("protection", Frame.class.getMethod( 237 "setProtection", pString)); 240 238 241 239 } catch (SecurityException e) { … … 280 278 try { 281 279 Object o = m.invoke(toExtract, (Object[]) null); 282 if (o != null) { 283 // skip methods that are in the ignore lists 284 if (_ExtractIgnore.contains(m.getName().substring( 285 GET_LENGTH).toLowerCase())) 280 281 if (o == null) { 282 // methods that return null are only included if they 283 // are in the AllowNull list 284 if (_AllowNull.contains(m)) { 285 String name = m.getName().substring( 286 GET_LENGTH).toLowerCase(); 287 if (name.equals("color")) 288 o = "default"; 289 else if (name.equals("backgroundcolor")) 290 o = "transparent"; 291 else if (name.equals("foregroundcolor")) 292 o = "auto"; 293 else 294 o = ""; 295 } else { 286 296 continue; 287 288 if (o instanceof Integer) { 289 if (m.getName().endsWith("Justification") 290 && convertJustificationToString((Integer) o) != null) 291 attributes 292 .append( 293 m.getName().substring( 294 GET_LENGTH)) 295 .append(SEPARATOR_STRING) 296 .append( 297 convertJustificationToString((Integer) o)) 298 .append("\n"); 299 // -1 indicates default value 300 else if (((Integer) o) > -1) 301 attributes.append( 302 m.getName().substring(GET_LENGTH)) 303 .append(SEPARATOR_STRING).append(o) 304 .append("\n"); 305 } else if (o instanceof Float) { 306 // -1 indicates default value 307 if (((Float) o) > 0.0001) 308 attributes.append( 309 m.getName().substring(GET_LENGTH)) 310 .append(SEPARATOR_STRING).append(o) 311 .append("\n"); 312 } else if (o instanceof Double) { 313 // -1 indicates default value 314 if (((Double) o) > 0.0001) 315 attributes.append( 316 m.getName().substring(GET_LENGTH)) 317 .append(SEPARATOR_STRING).append(o) 318 .append("\n"); 319 } else if (o instanceof Color) { 320 // converts the color to the KMS code 321 String s = Conversion.getKMSColorCode((Color) o); 322 if (s != null) 323 attributes.append( 324 m.getName().substring(GET_LENGTH)) 325 .append(SEPARATOR_STRING).append(s) 326 .append("\n"); 327 } else if (o instanceof Point) { 328 Point p = (Point) o; 329 String s = (int) p.getX() + " " + (int) p.getY(); 297 } 298 } 299 // skip methods that are in the ignore lists 300 if (_ExtractIgnore.contains(m.getName().substring( 301 GET_LENGTH).toLowerCase())) { 302 continue; 303 } 304 305 if (o instanceof Integer) { 306 Integer i = (Integer)o; 307 if (i == Item.DEFAULT_INTEGER) 308 continue; 309 if (m.getName().endsWith("Justification") 310 && convertJustificationToString((Integer) o) != null) 311 o = convertJustificationToString((Integer) o); 312 // -1 indicates default value 313 else 314 o = i; 315 } else if (o instanceof Float) { 316 // -1 indicates default value 317 if (((Float) o) < 0.0001) 318 continue; 319 } else if (o instanceof Double) { 320 // -1 indicates default value 321 if (((Double) o) < 0.0001) 322 continue; 323 } else if (o instanceof Color) { 324 // converts the color to the Expeditee code 325 o = Conversion.getExpediteeColorCode((Color) o); 326 if (o == null) 327 continue; 328 } else if (o instanceof Point) { 329 Point p = (Point) o; 330 o = (int) p.getX() + " " + (int) p.getY(); 331 } else if (o instanceof Font) { 332 Font f = (Font) o; 333 334 String s = f.getName() + "-"; 335 if (f.isPlain()) 336 s += "Plain"; 337 338 if (f.isBold()) 339 s += "Bold"; 340 341 if (f.isItalic()) 342 s += "Italic"; 343 344 s += "-" + f.getSize(); 345 o = s; 346 } else if (o instanceof Text) { 347 o = ((Text) o).getFirstLine(); 348 } else if (o instanceof List) { 349 List list = (List) o; 350 for (Object ob : list) 330 351 attributes 331 352 .append(m.getName().substring(GET_LENGTH)) 332 .append(SEPARATOR_STRING).append(s).append( 333 "\n"); 334 } else if (o instanceof Font) { 335 Font f = (Font) o; 336 337 String s = f.getName() + "-"; 338 if (f.isPlain()) 339 s += "Plain"; 340 341 if (f.isBold()) 342 s += "Bold"; 343 344 if (f.isItalic()) 345 s += "Italic"; 346 347 s += "-" + f.getSize(); 348 349 attributes 350 .append(m.getName().substring(GET_LENGTH)) 351 .append(SEPARATOR_STRING).append(s).append( 352 "\n"); 353 } else if (o instanceof Text) { 354 attributes 355 .append(m.getName().substring(GET_LENGTH)) 356 .append(SEPARATOR_STRING).append( 357 ((Text) o).getFirstLine()).append( 358 "\n"); 359 } else if (o instanceof List) { 360 List list = (List) o; 361 for (Object ob : list) 362 attributes.append( 363 m.getName().substring(GET_LENGTH)) 364 .append(SEPARATOR_STRING).append(ob) 365 .append("\n"); 366 } else if (o instanceof int[]) { 367 attributes 368 .append(m.getName().substring(GET_LENGTH)) 369 .append(SEPARATOR_STRING); 370 int[] values = (int[]) o; 371 for (int i = 0; i < values.length; i++) { 372 attributes.append(values[i]).append(' '); 373 } 374 attributes.deleteCharAt(attributes.length() - 1); 375 attributes.append("\n"); 376 } else if (o instanceof Boolean) { 377 // true is the default for boolean values 378 if (!((Boolean) o).booleanValue()) 379 attributes.append( 380 m.getName().substring(GET_LENGTH)) 381 .append(SEPARATOR_STRING).append(o) 382 .append("\n"); 383 } else 384 attributes 385 .append(m.getName().substring(GET_LENGTH)) 386 .append(SEPARATOR_STRING).append(o).append( 387 "\n"); 388 389 /* 390 * } catch (SecurityException e) { e.printStackTrace(); } 391 * /*catch (NoSuchMethodException e) { 392 * e.printStackTrace(); } 393 */ 394 395 // methods that return null are only included if they 396 // are in the AllowNull list 397 } else if (_AllowNull.contains(m)) 398 attributes.append(m.getName().substring(GET_LENGTH)) 399 .append(SEPARATOR_CHAR + "\n"); 400 } catch (IllegalArgumentException e) { 401 // TODO Auto-generated catch block 402 e.printStackTrace(); 403 } catch (IllegalAccessException e) { 404 // TODO Auto-generated catch block 405 e.printStackTrace(); 406 } catch (InvocationTargetException e) { 353 .append(SEPARATOR_STRING).append(ob) 354 .append("\n"); 355 continue; 356 } else if (o instanceof int[]) { 357 StringBuffer sb = new StringBuffer(); 358 int[] values = (int[]) o; 359 for (int i = 0; i < values.length; i++) { 360 sb.append(values[i]).append(' '); 361 } 362 sb.deleteCharAt(attributes.length() - 1); 363 o = sb.toString(); 364 } else if (o instanceof Boolean) { 365 // true is the default for boolean values 366 if (((Boolean) o).booleanValue()) 367 continue; 368 } 369 //Append the attributes 370 attributes.append(m.getName().substring(GET_LENGTH)) 371 .append(SEPARATOR_STRING).append(o).append("\n"); 372 } catch (Exception e) { 407 373 // TODO Auto-generated catch block 408 374 e.printStackTrace(); … … 471 437 472 438 // get the list of attribute: value pairs 473 List<String> values = attribs.getText ();439 List<String> values = attribs.getTextList(); 474 440 // if no paris exist, we are done 475 441 if (values.size() == 0 … … 495 461 // if the attribute is the same as v, then it is a 496 462 // continuation 497 if (v.indexOf( stripAttribute(next.toString())) == 0) {463 if (v.indexOf(getAttribute(next.toString())) == 0) { 498 464 // strip the attribute from next 499 next = new StringBuffer( stripValue(next.toString()));465 next = new StringBuffer(getValue(next.toString())); 500 466 // if the attribute is not the same, then it may be a 501 467 // new method … … 519 485 // otherwise, this is a list of attributes, so continue 520 486 else { 521 String stripped = stripAttribute(v.toString());487 String stripped = getAttribute(v.toString()); 522 488 if (stripped == null) { 523 489 // This happens when there is an attribute at the start … … 530 496 // attributes to ignore when copying 531 497 FrameGraphics.WarningMessage("Attribute: '" 532 + stripAttribute(v.toString())498 + getAttribute(v.toString()) 533 499 + "' does not exist."); 534 500 } else { … … 538 504 types += c.getSimpleName() + " "; 539 505 FrameGraphics.WarningMessage("Wrong arguments for: '" 540 + stripAttribute(v.toString()) + "' expecting "506 + getAttribute(v.toString()) + "' expecting " 541 507 + types.trim() + " found '" 542 + stripValue(v.toString()) + "'");508 + getValue(v.toString()) + "'"); 543 509 } 544 510 } … … 553 519 boolean isAttributeList) { 554 520 // separate attribute and value from string 555 String attribute = stripAttribute(value);556 value = stripValue(value);521 String attribute = getAttribute(value); 522 value = getValue(value); 557 523 558 524 // if there was no colon … … 601 567 Class toSetSuperClass = toSetClass.getSuperclass(); 602 568 // find the corresponding get method for this set method 569 // and get the current value of the attribute 603 570 for (Method m : _GetMethods) { 604 571 if ((m.getDeclaringClass() == toSetClass || m … … 651 618 652 619 /** 653 * Returns the part of the given string that is after a colon, or null if 654 * the given String has no colon 620 * Returns the part of the given string that is after the attribute value 621 * pair separator. If that character is not there it returns the empty 622 * string if it is an annotation item or the entire string if it is not. 655 623 * 656 * @param toStrip 624 * @param attributeValuePair 625 * the string to get the value from. 626 * @return the value from the attribute value pair. 627 */ 628 public static String getValue(String toStrip) { 629 assert (toStrip != null); 630 if (toStrip.length() == 0) 631 return ""; 632 633 int ind = toStrip.lastIndexOf(SEPARATOR_CHAR); 634 635 if (ind < 0) { 636 // If it is an annotation item return the empty string 637 // Annotation items can not be values only 638 if (toStrip.charAt(0) == '@') { 639 return ""; 640 } 641 // It is a value with no attribute. 642 return toStrip; 643 } 644 645 return toStrip.substring(ind + 1).trim(); 646 } 647 648 /** 649 * Returns the part of the given string that is before the attribute value 650 * pair separator, or null if the given String does not include the 651 * separator. 652 * 653 * @param attributeValuePair 657 654 * The String to strip 658 * @return The part of the String that is after a colon if there is one, or 659 * the entire string if there is no colon 655 * @return the attribute if there is one or null if there is not 660 656 */ 661 public static String stripValue(String toStrip) { 662 int ind = toStrip.lastIndexOf(SEPARATOR_CHAR); 663 if (ind < 0) 664 return toStrip; 665 666 toStrip = toStrip.substring(ind + 1); 667 // This line must be separate from above 668 // It removes spaces from the string returned by the above statement 669 toStrip = toStrip.trim(); 670 671 return toStrip; 672 } 673 674 /** 675 * Returns the part of the given string that is before a colon, or null if 676 * the given String has no colon 677 * 678 * @param toStrip 679 * The String to strip 680 * @return The part of the String that is before a colon if there is one, or 681 * null if there is no colon 682 */ 683 public static String stripAttribute(String toStrip) { 684 int ind = toStrip.indexOf(SEPARATOR_CHAR); 657 public static String getAttribute(String attributeValuePair) { 658 int ind = attributeValuePair.indexOf(SEPARATOR_CHAR); 685 659 if (ind < 0) 686 660 return null; 687 661 688 toStrip = toStrip.substring(0, ind);689 toStrip = toStrip.trim();690 691 if ( toStrip.length() == 0)662 attributeValuePair = attributeValuePair.substring(0, ind); 663 attributeValuePair = attributeValuePair.trim(); 664 665 if (attributeValuePair.length() == 0) 692 666 return null; 693 667 694 return toStrip;668 return attributeValuePair; 695 669 } 696 670 … … 698 672 assert (value != null); 699 673 700 String oldText = text.getText NoList();701 String attribute = stripAttribute(oldText);674 String oldText = text.getText(); 675 String attribute = getAttribute(oldText); 702 676 703 677 if (attribute == null) 704 attribute = text.getText NoList().trim();678 attribute = text.getText().trim(); 705 679 706 680 text.setText(attribute + SEPARATOR_STRING + value); … … 708 682 709 683 public static Double getDoubleValue(String attributeValuePair) { 710 String value = stripValue(attributeValuePair);684 String value = getValue(attributeValuePair); 711 685 712 686 if (value == null) -
trunk/src/org/expeditee/gui/Browser.java
r72 r80 12 12 import java.awt.event.WindowListener; 13 13 import java.awt.event.WindowStateListener; 14 import java.util.Collection; 14 15 15 16 import javax.swing.JFrame; … … 59 60 setSize(size); 60 61 setPreferredSize(size); 61 62 FrameGraphics.setMaxSize( this.getContentPane().getSize());62 Dimension paneSize = getContentPane().getSize(); 63 FrameGraphics.setMaxSize(paneSize); 63 64 } 64 65 … … 128 129 */ 129 130 public void go() { 130 131 Actions.Init(); 131 Collection<String> warningMessages = Actions.Init(); 132 132 DisplayIO.Init(this); 133 133 // Set visible must be just after DisplayIO.Init for the message box to … … 145 145 DisplayIO.setCurrentFrame(firstFrame); 146 146 DisplayIO.UpdateTitle(); 147 148 149 150 for(String message: warningMessages) 151 FrameGraphics.WarningMessage(message); 147 152 148 153 FrameKeyboardActions keyboardListner = new FrameKeyboardActions(); -
trunk/src/org/expeditee/gui/ColorUtils.java
r4 r80 8 8 // search through the colour wheel to find the next colour 9 9 int pos = -1; 10 for (int i = 0; i < wheel.length; i++) 11 if (color == null || color.equals(wheel[i])) { 10 for (int i = 0; i < wheel.length; i++){ 11 if (color == null) { 12 break; 13 } else if (color.equals(wheel[i])) { 12 14 pos = i; 13 15 break; 14 16 } 15 // if we didnt find the color on the wheel16 if (pos < 0) {17 return null;18 } else {19 pos++;20 pos = pos % wheel.length;21 color = wheel[pos];22 17 } 18 pos++; 19 pos = pos % wheel.length; 20 color = wheel[pos]; 23 21 24 22 return color; -
trunk/src/org/expeditee/gui/DisplayIO.java
r78 r80 58 58 * The title to display in the Title bar. 59 59 */ 60 public static final String TITLE = "Exp 26May2008A";60 public static final String TITLE = "Exp30May2008A"; 61 61 62 62 private DisplayIO() { … … 259 259 // do not allow duplicate frames 260 260 if (_VisitedFrames[side].size() > 0) 261 if (_VisitedFrames[side].peek().equals(toAdd.get FrameName())) {261 if (_VisitedFrames[side].peek().equals(toAdd.getName())) { 262 262 return; 263 263 } … … 265 265 Item ip = FrameUtils.getCurrentItem(); 266 266 if (ip == null) 267 _VisitedFrames[side].push(toAdd.get FrameName());267 _VisitedFrames[side].push(toAdd.getName()); 268 268 else 269 _VisitedFrames[side].push(toAdd.get FrameName());269 _VisitedFrames[side].push(toAdd.getName()); 270 270 } 271 271 … … 312 312 if (frame == getCurrentFrame()) { 313 313 FrameGraphics.Repaint(); 314 FrameGraphics.DisplayMessage(frame.get FrameName()314 FrameGraphics.DisplayMessage(frame.getName() 315 315 + " is already the current frame."); 316 316 return; … … 327 327 .contains(new Overlay(frame, 1))) { 328 328 FrameIO.SuspendCache(); 329 frame = FrameIO.LoadFrame(frame.get FrameName());329 frame = FrameIO.LoadFrame(frame.getName()); 330 330 FrameIO.ResumeCache(); 331 331 } … … 455 455 if (FrameGraphics.isAudienceMode()) 456 456 title.append(" - Audience Mode"); 457 else if (FrameGraphics.isXRayMode()) 458 title.append(" - X-Ray Mode"); 457 459 else 458 460 title.append(" [").append(SessionStats.getShortStats()).append(']'); … … 564 566 } 565 567 566 String oldFrame = getCurrentFrame().get FrameName().toLowerCase();568 String oldFrame = getCurrentFrame().getName().toLowerCase(); 567 569 568 570 // do not get a cached version (in case it is in the other window) … … 625 627 Frame hiding = _CurrentFrames[opposite]; 626 628 FrameUtils.LeavingFrame(hiding); 627 _VisitedFrames[opposite].add(hiding.get FrameName());629 _VisitedFrames[opposite].add(hiding.getName()); 628 630 _CurrentFrames[opposite] = null; 629 631 _CurrentFrames[current].setMaxSize(FrameGraphics.getMaxFrameSize()); … … 649 651 FrameIO.SuspendCache(); 650 652 _CurrentFrames[side] = FrameIO.LoadFrame(_CurrentFrames[side] 651 .get FrameName());653 .getName()); 652 654 FrameIO.ResumeCache(); 653 655 } -
trunk/src/org/expeditee/gui/Frame.java
r78 r80 35 35 public class Frame implements ImageObserver { 36 36 37 public static final Color[] COLOR_WHEEL = { Color.BLACK, Color.GRAY,37 public static Color[] COLOR_WHEEL = { Color.BLACK, Color.WHITE, Color.GRAY, 38 38 new Color(235, 235, 235), new Color(225, 225, 255), 39 39 new Color(195, 255, 255), new Color(225, 255, 225), … … 60 60 private String _frozenDate = null; 61 61 62 private Color _background; 63 64 private Color _foreground = Item.DEFAULT_FOREGROUND; 62 // Background color is clear 63 private Color _background = null; 64 65 // Foreground color is automatic by default 66 private Color _foreground = null; 65 67 66 68 public String path; … … 236 238 } 237 239 } 238 bodyTextItems.remove(getTitle ());240 bodyTextItems.remove(getTitleItem()); 239 241 240 242 return bodyTextItems; … … 285 287 */ 286 288 public void setTitle(String title) { 287 if (title == null || title == "")289 if (title == null || title.equals("")) 288 290 return; 289 291 … … 292 294 // remove any numbering this title has 293 295 title = title.replaceAll("^\\d*[.] *", ""); 294 Text frameTitle = getTitle ();296 Text frameTitle = getTitleItem(); 295 297 296 298 if (frameTitle == null) { … … 305 307 addItem(frameTitle); 306 308 } else { 309 // If it begins with a tag remove it 310 311 // Remove the @ symbol if it is there 312 title = ItemUtils.StripTagSymbol(title); 307 313 frameTitle.setText(title); 308 title = ItemUtils.StripTagSymbol(title); 314 // If the @ symbol is followed by numbering or a bullet remove that 315 // too 309 316 String autoBulletText = FrameKeyboardActions.getAutoBullet(title); 310 317 if (autoBulletText.length() > 0) … … 314 321 // Brook: Cannot figure what is going on above... widget annot titles 315 322 // should be stripped always 316 if (ItemUtils 317 . isTag(frameTitle, ItemUtils.GetTag(ItemUtils.TAG_IWIDGET))) {323 if (ItemUtils.startsWithTag(frameTitle, ItemUtils 324 .GetTag(ItemUtils.TAG_IWIDGET))) { 318 325 frameTitle.stripFirstWord(); 319 326 } … … 325 332 } 326 333 327 public Text getTitle () {334 public Text getTitleItem() { 328 335 List<Item> items = getItems(); 329 336 for (Item i : items) { 330 337 if (i instanceof Text && i.getX() < UserSettings.TitlePosition 331 && i.getY() < UserSettings.TitlePosition )338 && i.getY() < UserSettings.TitlePosition && i.getY() > 0) 332 339 return (Text) i; 333 340 } … … 336 343 } 337 344 338 public Item getFrameNameItem() { 345 public String getTitle() { 346 Text title = getTitleItem(); 347 if (title == null) 348 return getName(); 349 350 return title.getFirstLine(); 351 } 352 353 public Item getNameItem() { 339 354 return _frameName; 340 355 } … … 424 439 } 425 440 426 public void set FrameName(String framename) {441 public void setName(String framename) { 427 442 int num = Conversion.getFrameNumber(framename); 428 443 String frameset = Conversion.getFrameset(framename, false); 429 444 430 set FrameName(frameset, num);445 setName(frameset, num); 431 446 } 432 447 … … 465 480 * @return The Frame number of this Frame or -1 if it is not set. 466 481 */ 467 public int get FrameNumber() {482 public int getNumber() { 468 483 return _number; 469 484 } … … 575 590 _body.add(item); 576 591 item.setParent(this); 592 593 // If the item is a line end and has constraints with items already 594 // on the frame then make sure the constraints hold 595 if (item.isLineEnd()) { 596 item.setPosition(item.getPosition()); 597 } 577 598 578 599 _sorted = false; … … 636 657 * The List of Items to add to the undo stack. 637 658 */ 638 public void addAllToUndo( List<Item> items) {659 public void addAllToUndo(Collection<Item> items) { 639 660 if (items.size() < 1) 640 661 return; … … 718 739 } 719 740 720 public String get FrameName() {741 public String getName() { 721 742 return getFramesetName() + _number; 722 743 } … … 765 786 _background = back; 766 787 change(); 767 FrameGraphics.Repaint();788 // FrameGraphics.Repaint(); 768 789 } 769 790 … … 784 805 _foreground = front; 785 806 change(); 786 FrameGraphics.Repaint();807 // FrameGraphics.Repaint(); 787 808 } 788 809 … … 792 813 793 814 public Color getPaintForegroundColor() { 794 final int GRAY = 127;815 final int GRAY = Color.gray.getBlue(); 795 816 final int THRESHOLD = 10; 796 817 … … 802 823 return Color.WHITE; 803 824 804 Color fore = new Color(Math.abs(255 - back.getRed()), Math 805 .abs(255 - back.getGreen()), Math.abs(255 - back.getBlue())); 825 Color fore = new Color( 826 Math.abs(Conversion.RGB_MAX - back.getRed()), Math 827 .abs(Conversion.RGB_MAX - back.getGreen()), Math 828 .abs(Conversion.RGB_MAX - back.getBlue())); 806 829 return fore; 807 // return Item.DEFAULT_FOREGROUND;808 830 } 809 831 … … 1167 1189 public boolean equals(Object o) { 1168 1190 if (o instanceof String) { 1169 return (String.CASE_INSENSITIVE_ORDER .compare((String) o,1170 getFrameName()) == 0);1191 return (String.CASE_INSENSITIVE_ORDER 1192 .compare((String) o, getName()) == 0); 1171 1193 } 1172 1194 1173 1195 if (o instanceof Frame) { 1174 return get FrameName().equals(((Frame) o).getFrameName());1196 return getName().equals(((Frame) o).getName()); 1175 1197 } 1176 1198 … … 1188 1210 1189 1211 List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems()); 1190 copies.remove(toMergeWith.get FrameNameItem());1212 copies.remove(toMergeWith.getNameItem()); 1191 1213 1192 1214 for (Item i : copies) { … … 1234 1256 List<Item> newBody = new ArrayList<Item>(0); 1235 1257 for (Item i : _body) 1236 if (i.isAnnotation() || i == get FrameNameItem() || i == getTitle())1258 if (i.isAnnotation() || i == getNameItem() || i == getTitleItem()) 1237 1259 newBody.add(i); 1238 1260 … … 1300 1322 // check for an updated template... 1301 1323 for (Item i : this.getItems()) { 1302 if (ItemUtils. isTag(i, templateTag)) {1324 if (ItemUtils.startsWithTag(i, templateTag)) { 1303 1325 t = (Text) i; 1304 1326 break; … … 1401 1423 */ 1402 1424 public boolean isNormalTextItem(Item it) { 1403 if (it instanceof Text && it != getTitle () && it != _frameName1425 if (it instanceof Text && it != getTitleItem() && it != _frameName 1404 1426 && !((Text) it).isSpecialAnnotation()) { 1405 1427 return true; … … 1455 1477 if (it instanceof Text) { 1456 1478 Text t = (Text) it; 1457 if (t.getText NoList().toLowerCase().startsWith("@start")1458 || t.getText NoList().toLowerCase().equals("@start:")) {1479 if (t.getText().toLowerCase().startsWith("@start") 1480 || t.getText().toLowerCase().equals("@start:")) { 1459 1481 t.stripFirstWord(); 1460 1482 1461 if (t.getText NoList().equals(""))1483 if (t.getText().equals("")) 1462 1484 DisplayIO.getCurrentFrame().removeItem(t); 1463 1485 if (!Frame.itemAttachedToCursor()) { … … 1491 1513 } 1492 1514 1493 return _frameName.getText NoList();1515 return _frameName.getText(); 1494 1516 } 1495 1517 … … 1499 1521 } 1500 1522 1501 public void set FrameName(String frameset, int i) {1523 public void setName(String frameset, int i) { 1502 1524 setFrameset(frameset); 1503 1525 setFrameNumber(i); -
trunk/src/org/expeditee/gui/FrameCreator.java
r78 r80 61 61 _prev = _Mprev.copy(); 62 62 _prev.setID(newFrame.getNextItemID()); 63 _prev.setLink(_current.get FrameName());63 _prev.setLink(_current.getName()); 64 64 newFrame.addItem(_prev); 65 65 … … 67 67 _next = _Mnext.copy(); 68 68 _next.setID(_current.getNextItemID()); 69 _next.setLink(newFrame.get FrameName());69 _next.setLink(newFrame.getName()); 70 70 _current.addItem(_next); 71 71 FrameIO.SaveFrame(_current, false); … … 80 80 81 81 private void resetGlobals(Frame toUse) { 82 _lastY = START_Y + toUse.getTitle ().getPosition().y;82 _lastY = START_Y + toUse.getTitleItem().getPosition().y; 83 83 _lastX = START_X; 84 84 //Check for @Start … … 86 86 if (it instanceof Text) { 87 87 Text t = (Text) it; 88 if (t.getText NoList().toLowerCase().equals("@start") ||89 t.getText NoList().toLowerCase().startsWith("@start:")) {88 if (t.getText().toLowerCase().equals("@start") || 89 t.getText().toLowerCase().startsWith("@start:")) { 90 90 t.stripFirstWord(); 91 91 92 if (t.getText NoList().equals("")){92 if (t.getText().equals("")){ 93 93 _lastY = t.getY(); 94 94 _lastX = t.getX(); … … 157 157 return null; 158 158 159 return _current.get FrameName();159 return _current.getName(); 160 160 } 161 161 } -
trunk/src/org/expeditee/gui/FrameGraphics.java
r78 r80 16 16 import java.util.Collection; 17 17 import java.util.HashSet; 18 import java.util.Iterator; 18 19 import java.util.LinkedList; 19 20 import java.util.List; … … 73 74 74 75 // The link to the message frameset 75 public static Item MessageLink = new Text(-2, MESSAGES_FRAMESET_NAME);76 public static Item MessageLink = new Text(-2, "@" + MESSAGES_FRAMESET_NAME); 76 77 77 78 // creator for creating the message frames … … 98 99 FrameUtils.Parse(current); 99 100 DisplayIO.UpdateTitle(); 101 setMaxSize(new Dimension(_MaxSize.width, _MessageBuffer.getHeight() 102 + _MaxSize.height)); 100 103 Repaint(); 101 104 } … … 112 115 113 116 FrameUtils.Parse(DisplayIO.getCurrentFrame()); 117 DisplayIO.UpdateTitle(); 114 118 Repaint(); 115 119 } … … 133 137 _MaxSize = max; 134 138 135 // Mike assumes this is the height of the Message window? 136 _MaxSize.setSize(max.width, max.height - MESSAGE_BUFFER_HEIGHT); 139 // Hide the message buffer if in audience mode 140 int newMaxHeight = max.height 141 - (isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT); 142 if (newMaxHeight > 0) 143 _MaxSize.setSize(max.width, newMaxHeight); 144 137 145 if (DisplayIO.getCurrentFrame() != null) { 138 146 DisplayIO.getCurrentFrame().setBuffer(null); … … 140 148 } 141 149 142 _MessageBuffer = null; 143 144 for (int i = 0; i < Messages.length; i++) { 145 if (Messages[i] != null) { 146 Messages[i].setOffset(0, -_MaxSize.height); 147 Messages[i].setMaxSize(_MaxSize); 148 } 149 } 150 151 MessageLink.setOffset(0, -_MaxSize.height); 152 MessageLink.setMaxSize(_MaxSize); 153 MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET, 154 MESSAGE_LINK_X); 155 150 if (newMaxHeight > 0) { 151 _MessageBuffer = null; 152 153 for (int i = 0; i < Messages.length; i++) { 154 if (Messages[i] != null) { 155 Messages[i].setOffset(0, -_MaxSize.height); 156 Messages[i].setMaxSize(_MaxSize); 157 } 158 } 159 160 MessageLink.setOffset(0, -_MaxSize.height); 161 MessageLink.setMaxSize(_MaxSize); 162 MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET, 163 MESSAGE_LINK_X); 164 } 156 165 // Repaint(); 157 166 } … … 254 263 List<Item> copies = ItemUtils.CopyItems(vector.getItems()); 255 264 // FrameMouseActions 256 for (Item i : copies) { 265 Iterator<Item> iterator = copies.iterator(); 266 while(iterator.hasNext()){ 267 Item i = iterator.next(); 268 //Dont paint annotation items for @v 269 if (i.isAnnotation()){ 270 iterator.remove(); 271 continue; 272 } 273 i.setLinkMark(false); 274 i.setActionMark(false); 257 275 if (!(i instanceof Line)) { 258 276 i.setPosition((int) (i.getX() * scale + dx + 0.5), (int) (i … … 260 278 * scale + dy + 0.5)); 261 279 i.setThickness((int) (i.getThickness() * scale + 0.5)); 280 i.setArrowheadLength((int) (i.getArrowheadLength() * scale + 0.5)); 262 281 } 263 282 if (i instanceof Text) … … 419 438 420 439 if (isActualFrame) { 421 PaintItem(bg, toPaint.get FrameNameItem());440 PaintItem(bg, toPaint.getNameItem()); 422 441 } 423 442 … … 476 495 _MessageBuffer = ge.getDefaultScreenDevice() 477 496 .getDefaultConfiguration().createCompatibleVolatileImage( 478 _MaxSize.width, MESSAGE_BUFFER_HEIGHT); 497 _MaxSize.width, 498 (isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT)); 479 499 } 480 500 … … 507 527 g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null); 508 528 } 509 // draw the message area 510 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null); 529 // Dont display the message area in audience mode 530 if (!isAudienceMode()) { 531 // draw the message area 532 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null); 533 } 511 534 g.dispose(); 512 535 … … 749 772 MessageLink.setLink(_creator.getCurrent()); 750 773 Repaint(); 774 775 System.out.println(message); 751 776 } 752 777 -
trunk/src/org/expeditee/gui/FrameIO.java
r78 r80 41 41 FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator; 42 42 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator; 43 IMAGES_PATH = PARENT_FOLDER + "images" + File.separator;43 IMAGES_PATH = PARENT_FOLDER + IMAGES_FOLDER; 44 44 HELP_PATH = PARENT_FOLDER + "help" + File.separator; 45 45 PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator; … … 53 53 * subdirectory in this directory. 54 54 */ 55 55 public static String IMAGES_FOLDER = "images" + File.separator; 56 56 57 public static String TRASH_PATH; 57 58 … … 263 264 _Cache.clear(); 264 265 265 if (frame.get FrameNumber() > 0 && isCacheOn())266 if (frame.getNumber() > 0 && isCacheOn()) 266 267 _Cache.put(frameName.toLowerCase(), frame); 267 268 … … 286 287 _UseCache = false; 287 288 Frame fresh = FrameIO.LoadFrame(DisplayIO.getCurrentFrame() 288 .get FrameName());289 .getName()); 289 290 _UseCache = cache; 290 if (_Cache.containsKey(fresh.get FrameName().toLowerCase()))291 _Cache.put(fresh.get FrameName().toLowerCase(), fresh);291 if (_Cache.containsKey(fresh.getName().toLowerCase())) 292 _Cache.put(fresh.getName().toLowerCase(), fresh); 292 293 DisplayIO.setCurrentFrame(fresh); 293 294 } … … 298 299 // the current name and number 299 300 String name = current.getFramesetName(); 300 int num = current.get FrameNumber() - 1;301 int num = current.getNumber() - 1; 301 302 302 303 // loop until a frame that exists is found … … 324 325 325 326 // the current name and number 326 int num = current.get FrameNumber() + 1;327 int num = current.getNumber() + 1; 327 328 int max = num + 1; 328 329 String name = current.getFramesetName(); … … 424 425 425 426 // Dont delete the zero frame 426 if (toDelete.get FrameNumber() == 0) {427 if (toDelete.getNumber() == 0) { 427 428 FrameGraphics.ErrorMessage("Zero frame's can not be deleted"); 428 429 return false; … … 447 448 // get the fill path to determine which file version it is 448 449 String source = getFrameFullPathName(toDelete.path, toDelete 449 .get FrameName());450 451 String oldFrameName = toDelete.get FrameName().toLowerCase();450 .getName()); 451 452 String oldFrameName = toDelete.getName().toLowerCase(); 452 453 // Now save the frame in the new location 453 454 toDelete.setFrameset(DELETED_FRAMES); … … 519 520 520 521 // set the number and title of the new frame 521 template.set FrameName(frameset, ++ next);522 template.setName(frameset, ++ next); 522 523 template.setTitle(frameTitle); 523 524 524 525 Logger.Log(Logger.SYSTEM, Logger.TDFC, "Creating new frame: " 525 + template.get FrameName() + " from TDFC");526 + template.getName() + " from TDFC"); 526 527 527 528 // update INF file … … 536 537 template.resetDateCreated(); 537 538 for (Item i : template.getItems()) { 538 if (ItemUtils. isTag(i, ItemUtils.TAG_PARENT))539 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_PARENT)) 539 540 i.setLink(null); 540 541 } … … 656 657 657 658 //Dont save if the frame is protected 658 if (toSave.get FrameNameItem().Permission < Item.PERMISSION_TDFC)659 if (toSave.getNameItem().Permission < Item.PERMISSION_TDFC) 659 660 return ""; 660 661 … … 665 666 // Exp format. 666 667 String fullPath = getFrameFullPathName(toSave.path, toSave 667 .get FrameName());668 .getName()); 668 669 669 670 // Check if the frame exists … … 691 692 // remove this frame from the cache if it is there 692 693 // This will make sure links to the original are set correctly 693 _Cache.remove(toSave.get FrameName().toLowerCase());694 _Cache.remove(toSave.getName().toLowerCase()); 694 695 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 695 696 SuspendCache(); 696 Frame original = LoadFrame(toSave.get FrameName());697 Frame original = LoadFrame(toSave.getName()); 697 698 toSave.setFrameNumber(nextnum); 698 699 ResumeCache(); 699 700 // Put the modified version in the cache 700 _Cache.put(toSave.get FrameName().toLowerCase(), toSave);701 _Cache.put(toSave.getName().toLowerCase(), toSave); 701 702 // Show the messages alerting the user 702 703 Text originalMessage = new Text(-1); 703 704 originalMessage.setColor(FrameGraphics.ERROR_COLOR); 704 originalMessage.setText(original.get FrameName()705 originalMessage.setText(original.getName() 705 706 + " was updated by another user."); 706 originalMessage.setLink(original.get FrameName());707 originalMessage.setLink(original.getName()); 707 708 Text yourMessage = new Text(-1); 708 709 yourMessage.setColor(FrameGraphics.ERROR_COLOR); 709 710 yourMessage.setText("Your version was renamed " 710 + toSave.get FrameName());711 yourMessage.setLink(toSave.get FrameName());711 + toSave.getName()); 712 yourMessage.setLink(toSave.getName()); 712 713 FrameGraphics.DisplayMessage(originalMessage); 713 714 FrameGraphics.DisplayMessage(yourMessage); … … 716 717 ItemUtils.TAG_BACKUP)) { 717 718 SuspendCache(); 718 Frame original = LoadFrame(toSave.get FrameName());719 Frame original = LoadFrame(toSave.getName()); 719 720 if (original == null) 720 721 original = toSave; 721 int orignum = original.get FrameNumber();722 int orignum = original.getNumber(); 722 723 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 723 724 … … 731 732 Item i = ItemUtils.FindExactTag(toSave.getItems(), 732 733 ItemUtils.TAG_BACKUP); 733 i.setLink(original.get FrameName());734 i.setLink(original.getName()); 734 735 toSave.setFrameNumber(orignum); 735 736 ResumeCache(); … … 741 742 toSave.setSaved(); 742 743 if (inc) 743 SessionStats.SavedFrame(toSave.get FrameName());744 SessionStats.SavedFrame(toSave.getName()); 744 745 745 746 // avoid out-of-sync frames (when in TwinFrames mode) 746 if (_Cache.containsKey(toSave.get FrameName().toLowerCase()))747 _Cache.put(toSave.get FrameName().toLowerCase(), toSave);747 if (_Cache.containsKey(toSave.getName().toLowerCase())) 748 _Cache.put(toSave.getName().toLowerCase(), toSave); 748 749 749 750 Logger.Log(Logger.SYSTEM, Logger.SAVE, "Saving " 750 + toSave.get FrameName() + " to disk.");751 + toSave.getName() + " to disk."); 751 752 752 753 // check that the INF file is not out of date 753 754 int last = ReadINF(toSave.path, toSave.getFramesetName()); 754 if (last <= toSave.get FrameNumber())755 if (last <= toSave.getNumber()) 755 756 WriteINF(toSave.path, toSave.getFramesetName(), toSave 756 .get FrameName());757 .getName()); 757 758 758 759 // check if this was the profile frame (and thus needs … … 874 875 875 876 public static Frame CreateNewFrame(Item linker) throws RuntimeException { 876 String title = null; 877 if (linker instanceof Text) 878 title = ((Text) linker).getFirstLine(); 879 880 String templateLink = linker.getLinkTemplate(); 881 String framesetLink = linker.getLinkFrameset(); 877 String title = linker.getName(); 878 879 String templateLink = linker.getAbsoluteLinkTemplate(); 880 String framesetLink = linker.getAbsoluteLinkFrameset(); 882 881 String frameset = (framesetLink != null ? framesetLink : DisplayIO 883 882 .getCurrentFrame().getFramesetName()); … … 886 885 887 886 // do auto shrinking of the title IF not in twin frames mode 888 Item titleItem = newFrame.getTitle ();887 Item titleItem = newFrame.getTitleItem(); 889 888 890 889 if (!DisplayIO.isTwinFramesOn()) { 891 890 // BROOK: This had recursion!! Changed to avoid... 892 if ((titleItem.getX() + 1) < newFrame.get FrameNameItem().getX()) {891 if ((titleItem.getX() + 1) < newFrame.getNameItem().getX()) { 893 892 while (titleItem.getBoundsWidth() + titleItem.getX() > newFrame 894 .get FrameNameItem().getX()) {893 .getNameItem().getX()) { 895 894 titleItem.setSize(titleItem.getSize() - 1); 896 895 } … … 1122 1121 } 1123 1122 1123 /** 1124 * Copies a file from one location to another. 1125 * @param existingFile 1126 * @param newFileName 1127 * @throws Exception 1128 */ 1124 1129 public static void copyFile(String existingFile, String newFileName) 1125 1130 throws Exception { -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r78 r80 29 29 private static Text _toRemove = null; 30 30 31 // these numbers correspond to the Function Key numbers (0 = Escape key)32 public static final int DROP_DOWN = 0;33 34 public static final int SIZE_UP = 1;35 36 public static final int SIZE_DOWN = 2;37 38 public static final int COLOR_CHANGE = 3;39 40 public static final int ANNOTATION_CHANGE = 4;41 42 public static final int DATE_ITEM = 5;43 44 public static final int NEW_FRAMESET = 6;45 46 public static final int FONT_STYLE_CHANGE = 7;47 48 public static final int FONT_FAMILY_CHANGE = 8;49 50 public static final int AUDIENCE_MODE = 9;51 52 public static final int XRAY_MODE = 10;53 54 // public static final int RUN_MENU = 11;55 56 public static final int FORCE_REPAINT = 12;57 58 31 public synchronized void keyTyped(KeyEvent e) { 59 32 if (Simple.acceptKeyboardInput()) { … … 93 66 // remove the link for alt+l 94 67 if (ch == 'l') { 95 FrameUtils.getCurrentItem().setLink(null); 68 Item current = FrameUtils.getCurrentItem(); 69 // If its not linked then link it to its self 70 if (current instanceof Text && current.getLink() == null) { 71 String text = ((Text) current).getText(); 72 if (FrameIO.isValidFrameName(text)) { 73 current.setLink(text); 74 } else if (FrameIO.isValidFramesetName(text)) { 75 current.setLink(text + '1'); 76 } 77 } else { 78 // If its linked remove the link 79 current.setLink(null); 80 } 81 FrameGraphics.Repaint(); 82 } else if (ch == 'a') { 83 Item current = FrameUtils.getCurrentItem(); 84 // If its not linked then link it to its self 85 if (current instanceof Text && current.getAction() == null) { 86 String text = ((Text) current).getText().trim(); 87 if (text.startsWith("a:")) { 88 text = text.substring(2).trim(); 89 } else if (text.startsWith("@")) { 90 text = text.substring(1).trim(); 91 } 92 current.setAction(text); 93 } else { 94 // If its linked remove the link 95 current.setActions(null); 96 } 96 97 FrameGraphics.Repaint(); 97 98 } 98 99 } 99 100 } else { 100 processChar(ch );101 processChar(ch, e.isShiftDown()); 101 102 } 102 103 // FrameGraphics.Repaint(); 103 104 } 104 105 105 public static void processChar(char ch ) {106 public static void processChar(char ch, boolean isShiftDown) { 106 107 NavigationActions.ResetLastAddToBack(); 107 108 Item on = FrameUtils.getCurrentItem(); … … 169 170 170 171 DisplayIO.setTextCursor(text.getSize()); 171 Point newMouse = text.insertChar(ch, DisplayIO.getMouseX(), DisplayIO 172 .getMouseY()); 172 Point newMouse = null; 173 if (ch == '\t') { 174 if (isShiftDown) { 175 newMouse = text.removeTab(ch, DisplayIO.getMouseX(), DisplayIO 176 .getMouseY()); 177 } else { 178 newMouse = text.insertTab(ch, DisplayIO.getMouseX(), DisplayIO 179 .getMouseY()); 180 } 181 } else { 182 newMouse = text.insertChar(ch, DisplayIO.getMouseX(), DisplayIO 183 .getMouseY()); 184 } 173 185 DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false); 174 186 … … 332 344 333 345 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { 334 functionKey( DROP_DOWN);346 functionKey(FunctionKey.DropDown); 335 347 SessionStats.Escape(); 336 348 return; 337 349 } else if (e.getKeyCode() >= KeyEvent.VK_F1 338 350 && e.getKeyCode() <= KeyEvent.VK_F12) { 339 functionKey(e.getKeyCode() - KeyEvent.VK_F1 + 1); 351 functionKey(FunctionKey.values()[e.getKeyCode() - KeyEvent.VK_F1 352 + 1]); 340 353 return; 341 354 } else if (e.isControlDown() && e.getKeyCode() != KeyEvent.VK_CONTROL) … … 378 391 if (e.isControlDown()) { 379 392 FrameMouseActions.leftButton(FrameUtils.getCurrentItem()); 393 FrameMouseActions.updateCursor(); 380 394 } 381 395 break; … … 394 408 // Move the cursor to the next text item 395 409 Frame current = DisplayIO.getCurrentFrame(); 396 Item title = current.getTitle ();410 Item title = current.getTitleItem(); 397 411 List<Text> textItems = current.getBodyTextItems(false); 398 412 if (textItems.size() == 0) { … … 402 416 } 403 417 418 // If the user is mouse wheeling in free space... 404 419 if (currentItem == null) { 405 420 // find the nearest item in the correct direction … … 411 426 DisplayIO.setCursorPosition(t.getPosition()); 412 427 } else { 413 if (i == 0) 414 break; 415 DisplayIO.setCursorPosition(textItems.get(i - 1) 416 .getPosition()); 428 if (i == 0) { 429 DisplayIO.setCursorPosition(current.getTitleItem() 430 .getPosition()); 431 } else { 432 DisplayIO.setCursorPosition(textItems.get(i - 1) 433 .getPosition()); 434 } 417 435 } 418 436 FrameGraphics.Repaint(); … … 420 438 } 421 439 } 422 DisplayIO.setCursorPosition(title.getPosition()); 423 return; 424 } 425 426 if (current.getTitle().equals(currentItem)) { 440 // If we are at the botton of the screen and the user scrolls down 441 // then scroll backup to the title 442 if (textItems.size() > 0) { 443 DisplayIO.setCursorPosition(textItems.get(textItems.size() - 1) 444 .getPosition()); 445 } 446 return; 447 } 448 // If the user is on the title item 449 if (current.getTitleItem().equals(currentItem)) { 427 450 if (down) { 428 451 // Show the first item 429 452 DisplayIO.setCursorPosition(textItems.get(0).getPosition()); 430 } else { 431 // Show the last item 432 DisplayIO.setCursorPosition(textItems.get(textItems.size() - 1) 433 .getPosition()); 434 } 435 FrameGraphics.Repaint(); 453 FrameGraphics.Repaint(); 454 } 436 455 return; 437 456 } … … 440 459 if (textItems.get(i).equals(currentItem)) { 441 460 int nextIndex = i + (down ? 1 : -1); 442 if (nextIndex >= 0 && nextIndex < textItems.size()) { 443 DisplayIO.setCursorPosition(textItems.get(nextIndex) 444 .getPosition()); 461 if (nextIndex >= 0) { 462 if (nextIndex < textItems.size()) { 463 DisplayIO.setCursorPosition(textItems.get(nextIndex) 464 .getPosition()); 465 } 445 466 } else { 446 467 DisplayIO.setCursorPosition(title.getPosition()); … … 502 523 if (clicked.Permission < Item.PERMISSION_FULL 503 524 && clicked.getParent() != null 504 && clicked.getParent().get FrameNameItem() != clicked) {525 && clicked.getParent().getNameItem() != clicked) { 505 526 FrameGraphics.DisplayMessage("Insufficient Permission"); 506 527 return; … … 563 584 String text = ""; 564 585 565 List<String> lines = ((Text) on).getText ();586 List<String> lines = ((Text) on).getTextList(); 566 587 for (String s : lines) 567 588 text += s + "\n"; … … 578 599 } else if (ch.charAt(0) == KeyEvent.VK_D) { 579 600 // perform a delete operation 580 processChar((char) KeyEvent.VK_DELETE );601 processChar((char) KeyEvent.VK_DELETE, e.isShiftDown()); 581 602 FrameGraphics.Repaint(); 582 603 } else if (ch.charAt(0) == KeyEvent.VK_J) { … … 599 620 if (text == null) 600 621 return; 601 List<String> textLines = text.getText ();622 List<String> textLines = text.getTextList(); 602 623 if (textLines.size() <= 1) 603 624 return; … … 653 674 } 654 675 655 public static void functionKey( intkey) {676 public static void functionKey(FunctionKey key) { 656 677 functionKey(key, 1); 657 678 } … … 661 682 * action based on the key. 662 683 */ 663 public static void functionKey( intkey, int repeat) {684 public static void functionKey(FunctionKey key, int repeat) { 664 685 // get whatever the user is pointing at 665 686 Item on = FrameUtils.getCurrentItem(); 666 687 667 688 // check for enclosed mode 668 if (on == null && key < AUDIENCE_MODE) {689 if (on == null && key.ordinal() < FunctionKey.AudienceMode.ordinal()) { 669 690 Collection<Item> enclosed = FrameUtils.getCurrentItems(); 670 691 … … 688 709 689 710 switch (key) { 690 case S IZE_UP:711 case SizeUp: 691 712 if (resizeLines 692 713 || (!(firstConnected instanceof Line) && !(firstConnected instanceof Dot))) 693 714 SetSize(firstConnected, repeat, false); 694 715 break; 695 case S IZE_DOWN:716 case SizeDown: 696 717 if (resizeLines 697 718 || (!(firstConnected instanceof Line) && !(firstConnected instanceof Dot))) 698 719 SetSize(firstConnected, -repeat, false); 699 720 break; 700 // case COLOR_CHANGE: SetFillColor(firstConnected); break; 701 case ANNOTATION_CHANGE: 721 case ChangeColor: 722 if (connected.size() > 0) { 723 for (Item d : dots) { 724 SetFillColor(d); 725 break; 726 } 727 } 728 break; 729 case ToggleAnnotation: 702 730 ToggleAnnotation(firstConnected); 703 731 break; 704 case FONT_STYLE_CHANGE:732 case ChangeFontStyle: 705 733 ToggleFontStyle(firstConnected); 706 734 break; 707 case FONT_FAMILY_CHANGE:735 case ChangeFontFamily: 708 736 ToggleFontFamily(firstConnected); 709 737 break; 710 case DATE_ITEM:738 case InsertDate: 711 739 AddDate(firstConnected); 712 740 break; 713 741 } 714 715 if (key == COLOR_CHANGE && connected.size() > 0) { 716 for (Item d : dots) { 717 SetFillColor(d); 718 break; 719 } 720 } 742 return; 743 } 744 } 745 String displayMessage = "F" + key.ordinal() + ": " + key.toString(); 746 // Show a description of the function key pressed if the user is in free 747 // space and return for the F keys that dont do anything in free space. 748 if (on == null) { 749 switch (key) { 750 case DropDown: 751 case InsertDate: 752 case XRayMode: 753 case AudienceMode: 754 case Refresh: 755 break; 756 default: 757 FrameGraphics.DisplayMessage(displayMessage); 721 758 return; 722 759 } … … 724 761 725 762 switch (key) { 726 case D ROP_DOWN:763 case DropDown: 727 764 Drop(on); 728 break;729 case S IZE_UP:765 return; 766 case SizeUp: 730 767 SetSize(on, repeat, true); 731 768 break; 732 case S IZE_DOWN:769 case SizeDown: 733 770 SetSize(on, -repeat, true); 734 771 break; 735 case C OLOR_CHANGE:772 case ChangeColor: 736 773 SetColor(on); 737 774 break; 738 case ANNOTATION_CHANGE:775 case ToggleAnnotation: 739 776 ToggleAnnotation(on); 740 777 break; 741 case FONT_STYLE_CHANGE:778 case ChangeFontStyle: 742 779 ToggleFontStyle(on); 743 780 break; 744 case FONT_FAMILY_CHANGE:781 case ChangeFontFamily: 745 782 ToggleFontFamily(on); 746 783 break; 747 case DATE_ITEM:784 case InsertDate: 748 785 AddDate(on); 749 break;750 case N EW_FRAMESET:786 return; 787 case NewFrameset: 751 788 CreateFrameset(on); 752 789 break; 753 case XR AY_MODE:790 case XRayMode: 754 791 ToggleXRayMode(on); 755 792 break; 756 case A UDIENCE_MODE:793 case AudienceMode: 757 794 ToggleAudience(on); 758 795 break; 759 case FORCE_REPAINT:796 case Refresh: 760 797 Repaint(on); 761 798 break; 762 799 } 800 if (on == null) 801 FrameGraphics.DisplayMessage(displayMessage); 763 802 } 764 803 … … 818 857 } 819 858 820 Item title = DisplayIO.getCurrentFrame().getTitle ();859 Item title = DisplayIO.getCurrentFrame().getTitleItem(); 821 860 822 861 // We wont do auto bulleting when dropping from titles … … 829 868 if (Frame.textItemAttachedToCursor()) { 830 869 dummyItem = (Text) Frame.getItemAttachedToCursor(); 831 String autoBullet = getAutoBullet(dummyItem.getText NoList());870 String autoBullet = getAutoBullet(dummyItem.getText()); 832 871 833 872 if (autoBullet.length() > 0) 834 873 newItemText = ""; 835 dummyItem.setText(newItemText + dummyItem.getText NoList());874 dummyItem.setText(newItemText + dummyItem.getText()); 836 875 } 837 876 dummyItem = createText(); … … 839 878 Text t = (Text) Frame.getItemAttachedToCursor(); 840 879 dummyItem.setSize(t.getSize()); 841 for (int i = 0; i < t.getText ().size(); i++) {880 for (int i = 0; i < t.getTextList().size(); i++) { 842 881 newItemText += '\n'; 843 882 } … … 879 918 boolean mouseMoved = FrameMouseActions.tdfc(i); 880 919 Frame moreFrame = DisplayIO.getCurrentFrame(); 881 moreFrame.setTitle(firstFrame.getTitle() 882 .getTextNoList()); 920 moreFrame.setTitle(firstFrame.getTitleItem().getText()); 883 921 // need to move the mouse to the top of the frame if 884 922 // there 885 923 // wasnt an @start on it 886 924 if (!mouseMoved) { 887 Item moreTitle = moreFrame.getTitle ();925 Item moreTitle = moreFrame.getTitleItem(); 888 926 moreTitle.Permission = Item.PERMISSION_FULL; 889 927 Drop(moreTitle); … … 926 964 } catch (RuntimeException e) { 927 965 FrameGraphics.ErrorMessage(e.getMessage()); 966 e.printStackTrace(); 928 967 } 929 968 } … … 962 1001 * "@NoAutoBullets"); if (i != null) return newItemText; 963 1002 */ 1003 // Separate the space at the start of the text item 1004 String preceedingSpace = ""; 1005 for (int i = 0; i < s.length(); i++) { 1006 if (!Character.isSpaceChar(s.charAt(i))) { 1007 preceedingSpace = s.substring(0, i); 1008 s = s.substring(i); 1009 break; 1010 } 1011 } 964 1012 965 1013 // figure out the type of the text item … … 975 1023 || s.charAt(0) == '~' || s.charAt(0) == '#') { 976 1024 int nonSpaceIndex = 1; 1025 // Find the end of the bullet and space after the bullet 977 1026 while (nonSpaceIndex < s.length() 978 1027 && s.charAt(nonSpaceIndex) == ' ') { … … 993 1042 } 994 1043 } 995 return newItemText;1044 return preceedingSpace + newItemText; 996 1045 } 997 1046 … … 1101 1150 } 1102 1151 } else { 1152 if (item.isFrameName()) { 1153 FrameGraphics.DisplayMessage("Can not resize the frame name"); 1154 return; 1155 } 1103 1156 // check permissions 1104 1157 if (item.Permission < Item.PERMISSION_FULL) { … … 1194 1247 color = ColorUtils.getNextColor(color, Item.FILL_COLOR_WHEEL); 1195 1248 1196 // TODO what happens if the above statement returns null?? 1249 if (color == null) { 1250 FrameGraphics.DisplayMessage("FillColor is now transparent"); 1251 } 1197 1252 1198 1253 toSet.setFillColor(color); … … 1212 1267 // first determine the next color 1213 1268 Color color = null; 1214 1269 Frame currentFrame = DisplayIO.getCurrentFrame(); 1215 1270 if (ip == null) { 1216 1271 if (Frame.itemAttachedToCursor()) { … … 1221 1276 // change the background color if the user is pointing on the 1222 1277 // frame name 1223 } else if (ip == DisplayIO.getCurrentFrame().getFrameNameItem()) { 1224 DisplayIO.getCurrentFrame().toggleBackgroundColor(); 1278 } else if (ip == currentFrame.getNameItem()) { 1279 currentFrame.toggleBackgroundColor(); 1280 // Display a message if the color has changed to transparent 1281 if (currentFrame.getBackgroundColor() == null) 1282 FrameGraphics 1283 .DisplayMessage("Background color is now transparent"); 1284 FrameGraphics.Repaint(); 1225 1285 return; 1226 1286 } else { … … 1238 1298 // if we didnt find the color on the wheel 1239 1299 if (color == null) { 1240 color = DisplayIO.getCurrentFrame().getItemTemplate().getColor();1300 FrameGraphics.DisplayMessage("Color is set to default"); 1241 1301 } 1242 1302 … … 1248 1308 toSet.setColor(color); 1249 1309 toSet.getParent().setChanged(true); 1250 1251 } 1252 1310 } 1253 1311 FrameGraphics.Repaint(); 1254 1312 } … … 1272 1330 return; 1273 1331 } 1274 1275 1332 toToggle.setAnnotation(!toToggle.isAnnotation()); 1333 1276 1334 toToggle.getParent().setChanged(true); 1277 1335 FrameGraphics.Repaint(); … … 1364 1422 Text textItem = (Text) toAdd; 1365 1423 1366 String text = textItem.getText NoList();1424 String text = textItem.getText(); 1367 1425 1368 1426 // check if the default date has already been put on this item … … 1402 1460 } else { 1403 1461 for (int i = 0; i < date1.length(); i++) { 1404 processChar(date1.charAt(i) );1462 processChar(date1.charAt(i), false); 1405 1463 } 1406 1464 } … … 1462 1520 Frame linkTo = FrameIO.CreateNewFrameset(text.getFirstLine()); 1463 1521 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 1464 text.setLink(linkTo.get FrameName());1522 text.setLink(linkTo.getName()); 1465 1523 text.getParent().setChanged(true); 1466 1524 FrameUtils.DisplayFrame(linkTo, true); -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r78 r80 439 439 Item i = Frame.getItemAttachedToCursor(); 440 440 if (i != null && i instanceof Text) { 441 lastRanged.replaceSelectedText(((Text) i).getText NoList());441 lastRanged.replaceSelectedText(((Text) i).getText()); 442 442 Frame.FreeItems.clear(); 443 443 } else … … 507 507 508 508 // if the user is cropping an image 509 if (clickedOn != null && clickedOn == _lastCropped 510 && _lastCropped.getCroppedSize() > 0) { 511 Picture cropped = _lastCropped.copy(); 512 cropped.setParent(null); 513 pickup(cropped); 514 515 } 516 517 // if the user has cropped an imate, either the above happend or this is 509 if (clickedOn != null && clickedOn == _lastCropped) { 510 if (_lastCropped.isCropTooSmall()) { 511 _lastCropped = null; 512 // FrameGraphics 513 // .WarningMessage("Crop cancelled because it was below the 514 // minimum size"); 515 } else { 516 Picture cropped = _lastCropped.copy(); 517 cropped.setParent(null); 518 pickup(cropped); 519 } 520 } 521 522 // if the user has cropped an image, either the above happend or this is 518 523 // a no-op 519 if (_lastCropped != null && _lastCropped.getCroppedSize() > 0) {524 if (_lastCropped != null) { 520 525 _lastCropped.clearCropping(); 521 526 _lastCropped = null; … … 570 575 571 576 if (clicked instanceof Text) { 572 if (((Text) clicked).getText NoList().length() == 0)577 if (((Text) clicked).getText().length() == 0) 573 578 clicked = null; 574 579 } … … 681 686 if (clicked.Permission < Item.PERMISSION_FULL 682 687 && clicked.getParent() != null 683 && clicked.getParent().get FrameNameItem() != clicked) {688 && clicked.getParent().getNameItem() != clicked) { 684 689 FrameGraphics.DisplayMessage("Insufficient permission"); 685 690 return; … … 862 867 // check permissions 863 868 if (clicked.Permission < Item.PERMISSION_FULL 864 && clicked.getParent().get FrameNameItem() != clicked) {869 && clicked.getParent().getNameItem() != clicked) { 865 870 FrameGraphics 866 871 .DisplayMessage("Insufficient permission to merge items"); … … 1255 1260 LastRobotX = null; 1256 1261 LastRobotY = null; 1257 // System.out.println("RobotTimer");1262 // System.out.println("RobotTimer"); 1258 1263 } 1259 1264 }); … … 1508 1513 } 1509 1514 1510 private static void move( List<Item> toMove) {1515 private static void move(Collection<Item> toMove) { 1511 1516 1512 1517 // Gets the origin of the first item to move 1513 1518 int xPos = (DisplayIO.getMouseX() - _offX); 1514 1519 1515 Item firstDot = toMove. get(0);1520 Item firstDot = toMove.iterator().next(); 1516 1521 1517 1522 int deltax = firstDot.getX() - xPos; … … 1565 1570 Frame next = FrameIO.CreateNewFrame(linker); 1566 1571 1567 linker.setLink("" + next.get FrameNumber());1572 linker.setLink("" + next.getNumber()); 1568 1573 1569 1574 for (Item i : next.getBodyTextItems(true)) { 1570 1575 // Set the link for @Parent annotation item if one 1571 if (ItemUtils.isTag(i, ItemUtils.TAG_PARENT) && i.getLink() == null) { 1576 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_PARENT) 1577 && i.getLink() == null) { 1572 1578 Frame parent = linker.getParentOrCurrentFrame(); 1573 i.setLink(parent.get FrameName());1574 } else if (ItemUtils. isTag(i, ItemUtils.TAG_BACKUP, false)) {1579 i.setLink(parent.getName()); 1580 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_BACKUP, false)) { 1575 1581 // Delink backup tag if it is on the frame 1576 1582 i.setLink(null); … … 1631 1637 // check if the user is pointing at the frame's framename 1632 1638 if (toDelete != null 1633 && toDelete == DisplayIO.getCurrentFrame().get FrameNameItem()) {1639 && toDelete == DisplayIO.getCurrentFrame().getNameItem()) { 1634 1640 DisplayIO.getCurrentFrame().clear(); 1635 1641 FrameGraphics.Repaint(); … … 1654 1660 SessionStats.DeletedItem(free); 1655 1661 // List<String> temp = anchored.getText(); 1656 anchored.setTextList(free.getText ());1662 anchored.setTextList(free.getTextList()); 1657 1663 1658 1664 // free.setTextList(temp); … … 1680 1686 1681 1687 if (items != null) { 1682 List<Item> toRemove = new ArrayList<Item>(items.size()); 1688 Collection<Item> toRemove = new LinkedHashSet<Item>(items 1689 .size()); 1683 1690 for (Item ip : items) { 1684 1691 if (ip.Permission >= Item.PERMISSION_FULL) { … … 1719 1726 current.setChanged(true); 1720 1727 1721 List<Item> toUndo = null;1728 Collection<Item> toUndo = null; 1722 1729 if (toDelete.isLineEnd()) { 1723 1730 toUndo = deleteLineEnd(toDelete); … … 1737 1744 } 1738 1745 1739 private static void deleteItems( List<Item> itemList) {1746 private static void deleteItems(Collection<Item> itemList) { 1740 1747 SessionStats.DeletedItems(itemList); 1741 1748 List<Frame> modifiedFrames = new LinkedList<Frame>(); … … 1746 1753 modifiedFrames.add(parent); 1747 1754 } 1748 1749 List<Item> toUndo = new LinkedList<Item>(); 1750 List<Item> seen = new LinkedList<Item>(); 1751 1755 // If they are all free items then add the current frame 1756 if (modifiedFrames.size() == 0) { 1757 modifiedFrames.add(DisplayIO.getCurrentFrame()); 1758 } 1759 1760 Collection<Item> toUndo = new LinkedHashSet<Item>(); 1752 1761 // disconnect any connected items 1753 1762 for (Item i : itemList) { 1754 1763 if (i.getLines().size() > 0) { 1755 List<Item> copy= deleteLineEnd(i);1764 Collection<Item> toDelete = deleteLineEnd(i); 1756 1765 // add the copied items to the undo stack 1757 for (Item cop : copy) 1758 if (!toUndo.contains(cop)) 1759 toUndo.add(cop); 1760 } else { 1761 if (!seen.contains(i)) 1762 toUndo.addAll(copy(i)); 1763 } 1764 seen.add(i); 1766 for (Item itemToUndo : toDelete) 1767 if (!toUndo.contains(itemToUndo)) 1768 toUndo.add(itemToUndo); 1769 } else if (!toUndo.contains(i)) { 1770 toUndo.add(i); // Why was is this a copy 1771 } 1765 1772 } 1766 1773 for (Frame f : modifiedFrames) { … … 1774 1781 } 1775 1782 1776 private static List<Item> deleteLineEnd(Item lineEnd) {1783 private static Collection<Item> deleteLineEnd(Item lineEnd) { 1777 1784 1778 1785 if (lineEnd instanceof WidgetCorner) { // Brook … … 1795 1802 } else { 1796 1803 1797 // create a backup copy of the dot 1798 List<Item> copy = copy(lineEnd.getConnected()); 1799 // Remove lines from their anchored dots 1800 // note: the line is kept so that it can be properly restored 1801 for (Item ic : copy) { 1802 if (ic instanceof Line) { 1803 Line line = (Line) ic; 1804 // Remove the line from the item that is not the copy of the 1805 // line end being deletedF 1806 if (!copy.contains(line.getStartItem())) 1807 line.getStartItem().removeLine(line); 1808 if (!copy.contains(line.getEndItem())) 1809 line.getEndItem().removeLine(line); 1810 } 1811 } 1804 // // create a backup copy of the dot and its lines 1805 // List<Item> copy = copy(lineEnd.getConnected()); 1806 // 1807 // // Remove lines from their anchored dots 1808 // // note: the line is kept so that it can be properly restored 1809 // for (Item ic : copy) { 1810 // if (ic instanceof Line) { 1811 // Line line = (Line) ic; 1812 // // Remove the line from the item that is not the copy of the 1813 // // line end being deletedF 1814 // if (!copy.contains(line.getStartItem())) 1815 // line.getStartItem().removeLine(line); 1816 // if (!copy.contains(line.getEndItem())) 1817 // line.getEndItem().removeLine(line); 1818 // } 1819 // } 1820 1821 Collection<Item> copy = lineEnd.getConnected(); 1812 1822 1813 1823 // remove all lines being deleted … … 1852 1862 1853 1863 public static Collection<Item> merge(List<Item> merger, Item mergee) { 1854 if (mergee.getParent().get FrameNameItem() == mergee) {1864 if (mergee.getParent().getNameItem() == mergee) { 1855 1865 return mergee.getParent().merge(merger); 1856 1866 } … … 1925 1935 // set mouse position for text merges 1926 1936 if (mergee instanceof Text) 1927 ((Text) mergee).insertText(txt.getTextNoList(), 1928 DisplayIO.getMouseX(), DisplayIO 1929 .getMouseY()); 1937 ((Text) mergee).insertText(txt.getText(), DisplayIO 1938 .getMouseX(), DisplayIO.getMouseY()); 1930 1939 1931 1940 else if (mergee instanceof Dot) { … … 1954 1963 } 1955 1964 } else { 1956 if (mergee instanceof Dot || mergee instanceof Text) {1965 if (mergee instanceof Dot || mergee instanceof Text) { 1957 1966 DisplayIO.setCursorPosition(mergee.getPosition()); 1958 1967 } … … 1984 1993 if (toGrab.isFrameName()) 1985 1994 return; 1986 1995 1987 1996 if (toGrab.Permission < Item.PERMISSION_FULL) { 1988 1997 FrameGraphics … … 2008 2017 public static void pickup(Collection<Item> toGrab) { 2009 2018 2010 String currentFrame = DisplayIO.getCurrentFrame().get FrameName();2019 String currentFrame = DisplayIO.getCurrentFrame().getName(); 2011 2020 Iterator<Item> iter = toGrab.iterator(); 2012 2021 while (iter.hasNext()) { … … 2022 2031 if (i.getParent() != null) { 2023 2032 i.getParent().removeItem(i); 2024 if (currentFrame.equals(i.getParent().get FrameName()))2033 if (currentFrame.equals(i.getParent().getName())) 2025 2034 i.setParent(null); 2026 2035 } … … 2057 2066 + soleItem.getOffset().x; 2058 2067 _offY = MouseY - soleItem.getY() + soleItem.getOffset().y; 2068 // Now call move so that if we are on a message in the message box 2069 // It doesnt appear up the top of the scree!! 2070 move(toGrab); 2059 2071 } else { 2060 2072 FrameGraphics … … 2079 2091 2080 2092 return line; 2081 }2082 2083 private static List<Item> copy(Item toCopy) {2084 return copy(toCopy.getConnected());2085 2093 } 2086 2094 … … 2161 2169 } else if (arg0.getWheelRotation() != 0 && arg0.isShiftDown()) { 2162 2170 2163 int rotationType = FrameKeyboardActions.SIZE_UP;2171 FunctionKey rotationType = FunctionKey.SizeUp; 2164 2172 if (arg0.getWheelRotation() > 0) { 2165 rotationType = F rameKeyboardActions.SIZE_DOWN;2173 rotationType = FunctionKey.SizeDown; 2166 2174 } 2167 2175 -
trunk/src/org/expeditee/gui/FrameUtils.java
r78 r80 90 90 return false; 91 91 92 if (bullet1 == "" || bullet2 == "")92 if (bullet1.equals("") || bullet2.equals("")) 93 93 return false; 94 94 … … 107 107 108 108 private static boolean needsRenumbering(String s) { 109 if (s == null || s == "")109 if (s == null || s.equals("")) 110 110 return false; 111 111 if (!Character.isLetterOrDigit(s.charAt(0))) … … 152 152 if (above != null && curr.isNormalTextItem(above)) 153 153 lastBullet = FrameKeyboardActions.getAutoBullet(((Text) above) 154 .getText NoList());154 .getText()); 155 155 else { 156 156 lastBullet = FrameKeyboardActions.getBullet(((Text) toAlign.get(0)) 157 .getText NoList());157 .getText()); 158 158 } 159 159 if (needsRenumbering(lastBullet)) { … … 164 164 Text currentText = ((Text) toAlign.get(i)); 165 165 String currentBullet = FrameKeyboardActions 166 .getAutoBullet(currentText.getText NoList());166 .getAutoBullet(currentText.getText()); 167 167 168 168 if (sameBulletType(lastBullet, currentBullet)) { 169 169 currentText.stripFirstWord(); 170 170 171 currentText.setText(lastBullet 172 + currentText.getTextNoList()); 171 currentText.setText(lastBullet + currentText.getText()); 173 172 lastBullet = FrameKeyboardActions.getAutoBullet(currentText 174 .getText NoList());173 .getText()); 175 174 } 176 175 } … … 183 182 // if we are dropping from the title make the space a little bigger 184 183 // than normal 185 if (above != curr.getTitle () && above != null) {184 if (above != curr.getTitleItem() && above != null) { 186 185 // Make the gap between all items the same as the gap between 187 186 // the first two … … 192 191 space = MINIMUM_INTERITEM_SPACING; 193 192 194 if (above != curr.get FrameNameItem() && above != curr.getTitle())193 if (above != curr.getNameItem() && above != curr.getTitleItem()) 195 194 x = above.getX(); 196 195 … … 481 480 return true; 482 481 } 483 482 484 483 private static boolean createFrameBitmap(Frame frame, Text txt) { 485 484 if (txt.getLink() == null) … … 558 557 return; 559 558 560 UserSettings.TitleTemplate = profile.getTitle ();559 UserSettings.TitleTemplate = profile.getTitleItem(); 561 560 562 561 List<Item> items = profile.getItems(); … … 564 563 // check for all tags setting user values 565 564 for (Item item : items) { 566 if (ItemUtils. isTag(item, "@HomeFrame:")) {565 if (ItemUtils.startsWithTag(item, "@HomeFrame")) { 567 566 String first = getLink(item, UserSettings.FirstFrame); 568 567 // do not use non-existant frames as the first frame … … 574 573 FrameGraphics.WarningMessage("Home frame: " + first 575 574 + " is not a valid frame."); 576 UserSettings.FirstFrame = profile.get FrameName();577 } 578 } else if (ItemUtils. isTag(item, "@MenuFrame:"))575 UserSettings.FirstFrame = profile.getName(); 576 } 577 } else if (ItemUtils.startsWithTag(item, "@MenuFrame")) 579 578 UserSettings.MenuFrame = getLink(item, UserSettings.MenuFrame); 580 else if (ItemUtils. isTag(item, "@DefaultFrame:"))579 else if (ItemUtils.startsWithTag(item, "@DefaultFrame")) 581 580 UserSettings.DefaultFrame = getLink(item, 582 581 UserSettings.DefaultFrame); 583 else if (ItemUtils. isTag(item, "@AntiAlias:"))582 else if (ItemUtils.startsWithTag(item, "@AntiAlias")) 584 583 UserSettings.AntiAlias = getBoolean(item, 585 584 UserSettings.AntiAlias); 586 else if (ItemUtils. isTag(item, "@Gravity:"))585 else if (ItemUtils.startsWithTag(item, "@Gravity")) 587 586 UserSettings.Gravity = getInt(item, UserSettings.Gravity); 588 else if (ItemUtils. isTag(item, "@ShowLineHighlight:"))587 else if (ItemUtils.startsWithTag(item, "@ShowLineHighlight")) 589 588 UserSettings.LineHighlight = getBoolean(item, 590 589 UserSettings.LineHighlight); 591 else if (ItemUtils. isTag(item, "@LineStraightenThreshold:"))590 else if (ItemUtils.startsWithTag(item, "@LineStraightenThreshold")) 592 591 UserSettings.LineStraightenThreshold = getInt(item, 593 592 UserSettings.LineStraightenThreshold); 594 else if (ItemUtils. isTag(item, "@NoOpThreshold:"))593 else if (ItemUtils.startsWithTag(item, "@NoOpThreshold")) 595 594 UserSettings.NoOpThreshold = getInt(item, 596 595 UserSettings.NoOpThreshold); 597 else if (ItemUtils. isTag(item, "@InitialWidth:")) {596 else if (ItemUtils.startsWithTag(item, "@InitialWidth")) { 598 597 UserSettings.InitialWidth = getInt(item, 599 598 UserSettings.InitialWidth); 600 } else if (ItemUtils. isTag(item, "@InitialHeight:")) {599 } else if (ItemUtils.startsWithTag(item, "@InitialHeight")) { 601 600 UserSettings.InitialHeight = getInt(item, 602 601 UserSettings.InitialHeight); 603 } else if (ItemUtils. isTag(item, "@TitlePosition:")) {602 } else if (ItemUtils.startsWithTag(item, "@TitlePosition")) { 604 603 UserSettings.TitlePosition = getInt(item, 605 604 UserSettings.TitlePosition); 606 } else if (ItemUtils. isTag(item, "@Logging:")) {605 } else if (ItemUtils.startsWithTag(item, "@Logging")) { 607 606 UserSettings.Logging = getBoolean(item, UserSettings.Logging); 608 } else if (ItemUtils.isTag(item, ItemUtils.TAG_ITEM_TEMPLATE)) { 607 } else if (ItemUtils.startsWithTag(item, 608 ItemUtils.TAG_ITEM_TEMPLATE)) { 609 609 UserSettings.ItemTemplate = ((Text) item).getTemplateForm(); 610 } else if (ItemUtils.isTag(item, ItemUtils.TAG_ANNOTATION_TEMPLATE)) { 610 } else if (ItemUtils.startsWithTag(item, 611 ItemUtils.TAG_ANNOTATION_TEMPLATE)) { 611 612 UserSettings.AnnotationTemplate = ((Text) item) 612 613 .getTemplateForm(); 613 } else if (ItemUtils.isTag(item, ItemUtils.TAG_STAT_TEMPLATE)) { 614 } else if (ItemUtils.startsWithTag(item, 615 ItemUtils.TAG_STAT_TEMPLATE)) { 614 616 UserSettings.StatTemplate = ((Text) item).getTemplateForm(); 615 } else if (ItemUtils. isTag(item,617 } else if (ItemUtils.startsWithTag(item, 616 618 ItemUtils.TAG_CODE_COMMENT_TEMPLATE)) { 617 619 UserSettings.CodeCommentTemplate = ((Text) item) 618 620 .getTemplateForm(); 619 } else if (ItemUtils.isTag(item, ItemUtils.TAG_LINE_TEMPLATE)) { 621 } else if (ItemUtils.startsWithTag(item, 622 ItemUtils.TAG_LINE_TEMPLATE)) { 620 623 UserSettings.LineTemplate = ((Text) item).getTemplateForm(); 621 } else if (ItemUtils. isTag(item, "@FramesetDir:")) {624 } else if (ItemUtils.startsWithTag(item, "@FramesetDir")) { 622 625 String dir = getDir(item, null); 623 626 if (dir != null) 624 627 UserSettings.FrameDirs.add(dir); 625 } else if (ItemUtils. isTag(item, "@LogDir:")) {628 } else if (ItemUtils.startsWithTag(item, "@LogDir")) { 626 629 org.expeditee.gui.FrameIO.LOGS_DIR = getDir(item, 627 630 org.expeditee.gui.FrameIO.LOGS_DIR); 628 } else if (ItemUtils. isTag(item, "@ImageDir:")) {631 } else if (ItemUtils.startsWithTag(item, "@ImageDir")) { 629 632 String dir = getDir(item, null); 630 633 if (dir != null) 631 634 UserSettings.ImageDirs.add(0, dir); 632 } else if (ItemUtils. isTag(item, "@Threading:")) {635 } else if (ItemUtils.startsWithTag(item, "@Threading")) { 633 636 UserSettings.Threading = getBoolean(item, 634 637 UserSettings.Threading); 635 } else if (ItemUtils. isTag(item, "@ColorWheel")) {638 } else if (ItemUtils.startsWithTag(item, "@ColorWheel")) { 636 639 Item.COLOR_WHEEL = getColorWheel(item); 637 } else if (ItemUtils. isTag(item, "@BackgroundColorWheel")) {640 } else if (ItemUtils.startsWithTag(item, "@FillColorWheel")) { 638 641 Item.FILL_COLOR_WHEEL = getColorWheel(item); 639 } else if (ItemUtils.isTag(item, "@FramesetDirs")) { 642 } else if (ItemUtils.startsWithTag(item, "@BackgroundColorWheel")) { 643 Frame.COLOR_WHEEL = getColorWheel(item); 644 } else if (ItemUtils.startsWithTag(item, "@FramesetDirs")) { 640 645 UserSettings.FrameDirs.addAll(getDirs(item)); 641 646 } … … 643 648 644 649 if (UserSettings.FirstFrame == null) 645 UserSettings.FirstFrame = profile.get FrameName();650 UserSettings.FirstFrame = profile.getName(); 646 651 else { 647 652 if (FrameIO.LoadFrame(UserSettings.FirstFrame) == null) { 648 653 FrameGraphics.WarningMessage("Home frame: " 649 654 + UserSettings.FirstFrame + " could not be found."); 650 UserSettings.FirstFrame = profile.get FrameName();655 UserSettings.FirstFrame = profile.getName(); 651 656 } 652 657 } … … 660 665 if (child != null) { 661 666 List<Text> textItems = child.getBodyTextItems(true); 662 Color[] colorList = new Color[textItems.size() ];667 Color[] colorList = new Color[textItems.size() + 1]; 663 668 for (int i = 0; i < textItems.size(); i++) { 664 669 colorList[i] = textItems.get(i).getColor(); 665 670 } 671 // Make the last item transparency or default for forecolor 672 colorList[colorList.length - 1] = null; 673 666 674 return colorList; 667 675 } 668 676 } 669 return new Color[] { Color.black, Color.white 677 return new Color[] { Color.black, Color.white, null}; 670 678 } 671 679 … … 674 682 return alt; 675 683 676 String value = AttributeUtils. stripValue(((Text) item).getFirstLine())684 String value = AttributeUtils.getValue(((Text) item).getFirstLine()) 677 685 .trim(); 678 686 if (value.length() > 0) { … … 689 697 return alt; 690 698 691 String value = AttributeUtils. stripValue(((Text) item).getFirstLine())699 String value = AttributeUtils.getValue(((Text) item).getFirstLine()) 692 700 .trim().toLowerCase(); 693 701 if (value != null && value.length() > 0) { … … 709 717 return alt; 710 718 711 String value = AttributeUtils. stripValue(((Text) item).getFirstLine())719 String value = AttributeUtils.getValue(((Text) item).getFirstLine()) 712 720 .trim().toLowerCase(); 713 721 try { … … 741 749 if (dirListFrame != null) { 742 750 for (Text t : dirListFrame.getBodyTextItems(false)) { 743 String dirName = t.getText NoList().trim();751 String dirName = t.getText().trim(); 744 752 File tester = new File(dirName); 745 753 if (tester.exists() && tester.isDirectory()) { … … 767 775 return alt; 768 776 769 String value = AttributeUtils. stripValue(((Text) item).getFirstLine())777 String value = AttributeUtils.getValue(((Text) item).getFirstLine()) 770 778 .trim(); 771 779 if (value != null && value.length() > 0) … … 835 843 try { 836 844 i.Permission = permissionLevel; 837 if (ItemUtils. isTag(i, ItemUtils.TAG_POINTTYPE)) {845 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_POINTTYPE)) { 838 846 Text txt = (Text) i; 839 847 String line = txt.getFirstLine(); … … 860 868 // check for Images and widgets 861 869 if (!FrameGraphics.isXRayMode()) { 862 if (ItemUtils. isTag(i, ItemUtils.TAG_IMAGE))870 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IMAGE)) 863 871 createPicture(toParse, (Text) i); 864 872 // check for frame images 865 else if (i.getLink() != null && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getFrameName())){ 866 if(ItemUtils.isTag(i, ItemUtils.TAG_FRAME_IMAGE)){ 873 else if (i.getLink() != null 874 && !i.getAbsoluteLink().equalsIgnoreCase( 875 toParse.getName())) { 876 if (ItemUtils.startsWithTag(i, 877 ItemUtils.TAG_FRAME_IMAGE)) { 867 878 createFramePicture(toParse, (Text) i); 868 }else if (ItemUtils.isTag(i, ItemUtils.TAG_BITMAP_IMAGE)){ 879 } else if (ItemUtils.startsWithTag(i, 880 ItemUtils.TAG_BITMAP_IMAGE)) { 869 881 createFrameBitmap(toParse, (Text) i); 870 882 } 871 883 } 872 884 // Check for interactive widgets 873 else if (ItemUtils. isTag(i, ItemUtils.TAG_IWIDGET)) {885 else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IWIDGET)) { 874 886 createWidget(toParse, (Text) i); 875 887 } … … 877 889 878 890 // check for new VECTOR items 879 if (ItemUtils. isTag(i, ItemUtils.TAG_VECTOR)891 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR) 880 892 && i.getLink() != null) { 881 893 Frame vector = FrameIO.LoadFrame(i.getAbsoluteLink()); 882 894 if (vector != null) { 883 String scaleString = ItemUtils.StripTag(((Text) i)884 .get FirstLine());895 String scaleString = AttributeUtils.getValue(((Text) i) 896 .getText()); 885 897 Float scale = 1F; 886 898 try { … … 893 905 894 906 // check for new OVERLAY items 895 if (ItemUtils. isTag(i, ItemUtils.TAG_OVERLAY)907 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_OVERLAY) 896 908 && i.getLink() != null) { 897 909 Frame overlay = FrameIO.LoadFrame(i.getAbsoluteLink()); … … 903 915 904 916 // check for ACTIVE_OVERLAY items 905 if (ItemUtils. isTag(i, ItemUtils.TAG_ACTIVE_OVERLAY)917 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_ACTIVE_OVERLAY) 906 918 && i.getLink() != null) { 907 919 String link = i.getAbsoluteLink(); … … 909 921 // Parse(overlay); 910 922 // get level if specified 911 String level = ItemUtils912 . StripTag(((Text) i).getFirstLine());923 String level = AttributeUtils.getValue(((Text) i) 924 .getFirstLine()); 913 925 // default permission (if none is specified) 914 926 int permission = getPermissionLevel(level, … … 955 967 // remove Text that is all whitespace 956 968 if (i instanceof Text) { 957 List<String> text = ((Text) i).getText ();969 List<String> text = ((Text) i).getTextList(); 958 970 // remove empty text items 959 971 if (text == null || text.size() == 0) … … 1083 1095 ArrayList<Item> checkList = new ArrayList<Item>(); 1084 1096 checkList.addAll(toCheck.getItems()); 1085 checkList.add(toCheck.get FrameNameItem());1097 checkList.add(toCheck.getNameItem()); 1086 1098 for (Item i : checkList) { 1087 1099 // do not check annotation items in audience mode … … 1089 1101 if (i.contains(x, y) && !Frame.FreeItems.contains(i)) { 1090 1102 // names have copy permissions only 1091 if (i == toCheck.get FrameNameItem()) {1103 if (i == toCheck.getNameItem()) { 1092 1104 // i.Permission = Item.PERMISSION_TDFC; 1093 1105 possibles.add(i); … … 1136 1148 + Math.pow(Math.abs(i.getY() - y), 2))); 1137 1149 1138 // System.out.println(d);1150 // System.out.println(d); 1139 1151 if (d <= distance) { 1140 1152 distance = d; … … 1292 1304 */ 1293 1305 public static void CreateDefaultProfile(Frame profile) { 1294 Text title = profile.getTitle ();1306 Text title = profile.getTitleItem(); 1295 1307 title.setText("Profile Frame"); 1296 1308 title.setSize(50); … … 1306 1318 1307 1319 yPos += spacing; 1308 profile.addText(xPos, yPos, "@HomeFrame: " + profile.get FrameName(),1309 null, profile.getFrameName());1320 profile.addText(xPos, yPos, "@HomeFrame: " + profile.getName(), null, 1321 profile.getName()); 1310 1322 yPos += spacing; 1311 1323 String defaultFrameName = profile.getFramesetName() + "0"; … … 1368 1380 t = profile.addText(xPos, yPos, indexFrame 1369 1381 .getFramesetName(), null); 1370 t.setLink(indexFrame.get FrameName());1382 t.setLink(indexFrame.getName()); 1371 1383 } 1372 1384 } -
trunk/src/org/expeditee/gui/UserSettings.java
r78 r80 6 6 import java.util.List; 7 7 8 import org.expeditee.items.Item;9 8 import org.expeditee.items.Text; 10 9 -
trunk/src/org/expeditee/io/Conversion.java
r72 r80 12 12 import org.expeditee.items.Item; 13 13 import org.expeditee.items.Text; 14 import org.junit.Assert; 14 15 15 16 /** 16 17 * This class provides various methods for converting values to\from Java 17 * objects and KMSfile values.18 * objects and Expeditee file values. 18 19 * 19 20 * @author jdm18 … … 22 23 public class Conversion { 23 24 24 private static final int PERCENT_MAX = 100;25 private static final int RGB_MAX = 255; 26 private static final double RGB_CONVERSION_FACTOR = 2.55;27 28 /** 29 * Returns the Color corresponding to the given KMS color code. For example:30 * <br>25 public static final int RGB_MAX = 255; 26 27 private static final float RGB_CONVERSION_FACTOR = 2.55F; 28 29 /** 30 * Returns the Color corresponding to the given Expeditee color code. For 31 * example: <br> 31 32 * green4 = 0% red, 40% green, 0% blue. 32 33 * 33 34 * @param colorCode 34 * The KMScolor code to convert35 * The Expeditee color code to convert 35 36 * @return The Color object corresponding to the given code 36 37 */ 37 38 public static Color getColor(String colorCode, Color current) { 38 if (colorCode == null || colorCode.equals("null") 39 || colorCode.equals("none")) { 40 return current; 41 } 39 if (colorCode == null) { 40 return null; 41 } 42 // The if we dont do this then we end up getting black 43 colorCode = colorCode.toLowerCase(); 44 if (colorCode.equals("null")) 45 return null; 42 46 43 47 // check if its a normal rgb code ie. 100 0 40 … … 69 73 70 74 float color[] = { 0, 0, 0 }; 71 72 if (colorCode.toLowerCase().startsWith("red")) 75 Assert.assertTrue(color.length == 3); 76 77 if (colorCode.startsWith("red")) 73 78 color[0] = amount / MAX_AMOUNT; 74 else if (colorCode. toLowerCase().startsWith("green"))79 else if (colorCode.startsWith("green")) 75 80 color[1] = amount / MAX_AMOUNT; 76 else if (colorCode. toLowerCase().startsWith("blue"))81 else if (colorCode.startsWith("blue")) 77 82 color[2] = amount / MAX_AMOUNT; 78 83 else 79 //TODO: Should we not throw an error here! 80 return current; 84 return null; 81 85 82 86 return new Color(color[0], color[1], color[2]); … … 84 88 85 89 private static Color getRGBColor(String colorCode, Color current) { 86 int color[] = { 0, 0, 0 }; 90 int color[] = new int[3]; 91 Assert.assertTrue(color.length == 3); 87 92 88 93 try { 89 94 String[] values = colorCode.trim().split("\\s+"); 95 // For now no transparency only RGB 96 if (values.length > color.length) 97 return null; 90 98 91 99 String r = values.length > 0 ? values[0] : "0"; … … 111 119 112 120 private static Integer toColorPercent(int rgb) { 121 assert (rgb >= 0); 122 assert (rgb <= RGB_MAX); 123 113 124 int percent = (int) Math.round(rgb / RGB_CONVERSION_FACTOR); 114 if (percent > PERCENT_MAX) 115 percent = PERCENT_MAX; 116 else if (percent < 0) 117 percent = 0; 125 126 // Dont need to do the checking below because this method will always be 127 // called with good values 128 // if (percent > PERCENT_MAX) 129 // percent = PERCENT_MAX; 130 // else if (percent < 0) 131 // percent = 0; 118 132 119 133 return percent; … … 121 135 122 136 private static Integer toRGB(int percent) { 123 int rgb = (int)Math.round(percent * RGB_CONVERSION_FACTOR);137 int rgb = Math.round(percent * RGB_CONVERSION_FACTOR); 124 138 if (rgb > RGB_MAX) 125 139 rgb = RGB_MAX; … … 130 144 } 131 145 132 133 134 /** 135 * Converts the given Color object to the corresponding KMS color code 146 /** 147 * Converts the given Color object to the corresponding Expeditee color code 136 148 * 137 149 * @param color 138 * The Color to be turned into KMScolor code.139 * @return A String containing the KMS color code, NULL if the color is140 * black.141 */ 142 public static String get KMSColorCode(Color color) {150 * The Color to be turned into Expeditee color code. 151 * @return A String containing the Expeditee color code, NULL if the color 152 * is black. 153 */ 154 public static String getExpediteeColorCode(Color color) { 143 155 if (color == null) 144 156 return null; … … 152 164 153 165 /** 154 * Converts the given Font to a corresponding KMSfont code.166 * Converts the given Font to a corresponding Expeditee font code. 155 167 * 156 168 * @param font 157 169 * The Font to convert to a code. 158 * @return The KMSfont code that corresponds to the given Font.159 */ 160 public static String get KMSFontCode(Font font) {170 * @return The Expeditee font code that corresponds to the given Font. 171 */ 172 public static String getExpediteeFontCode(Font font) { 161 173 String code = "t"; 162 174 String fontName = font.getFamily().toLowerCase(); … … 183 195 break; 184 196 } 185 197 186 198 code += font.getSize(); 187 199 return code; … … 189 201 190 202 /** 191 * Converts the given KMSfont code to a Font object.<br>203 * Converts the given Expeditee font code to a Font object.<br> 192 204 * For example: <br> 193 205 * tr16 = times, roman, 16pt … … 198 210 */ 199 211 public static Font getFont(String fontCode) { 212 assert (fontCode != null); 213 200 214 String code = Text.FONT_WHEEL[0]; 201 215 … … 229 243 try { 230 244 int size = Integer.parseInt(fontCode.substring(2)); 231 // double dsize = size * FONT_SCALE;232 // if (dsize - ((int) dsize) > FONT_ROUNDING)233 // 234 235 // code += (int) dsize;245 // double dsize = size * FONT_SCALE; 246 // if (dsize - ((int) dsize) > FONT_ROUNDING) 247 // dsize = Math.ceil(dsize); 248 249 // code += (int) dsize; 236 250 code += size; 237 251 238 252 font = Font.decode(code); 239 253 } catch (NumberFormatException nfe) { … … 264 278 } 265 279 } 266 267 try { 268 return Integer.parseInt(num); 269 } catch (NumberFormatException nfe) { 270 return -1; 271 } 280 return Integer.parseInt(num); 272 281 } 273 282 … … 304 313 305 314 /** 306 * Converts the given KMS justification code into a int corresponding to the307 * constants defined in Item.315 * Converts the given Expeditee justification code into a int corresponding 316 * to the constants defined in Item. 308 317 * 309 318 * @param justCode 310 * The KMSjustification code to convert319 * The Expeditee justification code to convert 311 320 * @return The resulting int corresponding to one of the constants defined 312 321 * in Item … … 343 352 } 344 353 345 public static String get KMSJustificationCode(int justification) {354 public static String getExpediteeJustificationCode(int justification) { 346 355 switch (justification) { 347 356 case Item.JUSTIFICATION_CENTER: … … 356 365 return null; 357 366 } 358 359 367 } 360 368 … … 363 371 } 364 372 365 // Will convert from KMScolor values to RGB...373 // Will convert from Expeditee color values to RGB... 366 374 public static Object Convert(Class type, String value, Object orig) { 367 375 // System.out.println("Orig: " + orig); 376 assert (type != null); 377 368 378 if (value == null) 369 379 return null; 370 value = value.trim(); 371 372 if (type == String.class 373 && String.CASE_INSENSITIVE_ORDER.compare(value, "") == 0) 374 return null; 375 else if (type == String.class) 376 return value; 380 381 String fullCaseValue = value.trim(); 382 value = fullCaseValue.toLowerCase(); 377 383 378 384 if (type == Font.class) { … … 409 415 410 416 if (value.equals("null")) 411 return -1;417 return Item.DEFAULT_INTEGER; 412 418 413 419 return Integer.parseInt(value); … … 455 461 456 462 if (type.equals(boolean.class)) { 457 value = value.toLowerCase().trim();458 459 463 if (value.equals("t") || value.equals("true") 460 464 || value.equals("yes") || value.equals("y") 461 465 || value.equals("")) 462 466 return true; 463 464 if (value.equals("f") || value.equals("false") 465 || value.equals("no") || value.equals("n")) 466 return false; 467 468 return null; 469 } 470 471 // return name + ": " + value; 472 /* 473 * String[] val = new String[1]; val[0] = value; 474 */ 475 return null; 476 467 return false; 468 469 } 470 471 if (type.equals(Point.class)) { 472 Point p = new Point(); 473 String xPos = value.substring(0, value.indexOf(" ")); 474 String yPos = value.substring(value.indexOf(" ") + 1); 475 476 if (orig == null) { 477 p.x = Integer.parseInt(xPos.trim()); 478 p.y = Integer.parseInt(yPos.trim()); 479 } else { 480 assert (orig instanceof Point); 481 Point originalPoint = (Point) orig; 482 p.x = (Integer) Convert(int.class, xPos, originalPoint.x); 483 p.y = (Integer) Convert(int.class, yPos, originalPoint.y); 484 } 485 return p; 486 } 487 488 assert (type == String.class); 489 if (value.equals("")) 490 return null; 491 return fullCaseValue; 477 492 } 478 493 … … 481 496 } 482 497 498 /** 499 * Converts parameters for setting an attribute from a string form into an 500 * object array form. The object array can then be passed when invoke the 501 * set method via reflection. 502 * 503 * @param method 504 * a method which sets an attribute 505 * @param value 506 * new value for the attribute 507 * @param current 508 * current value of the attribute 509 * @return 510 */ 483 511 public static Object[] Convert(Method method, String value, Object current) { 484 512 value = value.trim(); … … 486 514 String name = method.getName(); 487 515 Class[] types = method.getParameterTypes(); 488 if (name.equals("setPosition")) { 489 Point[] p = new Point[1]; 490 p[0] = new Point(); 491 String xPos = value.substring(0, value.indexOf(" ")); 492 String yPos = value.substring(value.indexOf(" ") + 1); 493 494 if (current == null) { 495 p[0].x = Integer.parseInt(xPos); 496 p[0].y = Integer.parseInt(yPos); 497 } else { 498 assert (current instanceof Point); 499 assert (p.length == 1); 500 Point originalPoint = (Point) current; 501 p[0].x = (Integer) Convert(int.class, xPos, originalPoint.x); 502 p[0].y = (Integer) Convert(int.class, yPos, originalPoint.y); 503 } 504 return p; 505 } 506 507 if (name.equals("setJustification")) { 516 517 if (name.endsWith("Justification")) { 508 518 Integer[] just = new Integer[1]; 509 519 just[0] = getJustification(value); … … 515 525 return null; 516 526 517 Integer a = Integer 518 .parseInt(value.substring(0, value.indexOf(" "))); 519 Double b = Double.parseDouble(value 520 .substring(value.indexOf(" ") + 1)); 527 Integer length = null; 528 Double ratio = null; 529 530 if (current == null) { 531 length = getArrowLength(value); 532 ratio = getArrowRatio(value); 533 } else { 534 assert (current instanceof String); 535 int oldLength = getArrowLength(current.toString()); 536 double oldRatio = getArrowRatio(current.toString()); 537 length = (Integer) Convert(int.class, value.substring(0, value 538 .indexOf(" ")), oldLength); 539 ratio = (Double) Convert(double.class, value.substring( 540 value.indexOf(" ")).trim(), oldRatio); 541 } 521 542 522 543 Object[] vals = new Object[2]; 523 vals[0] = a;524 vals[1] = b;544 vals[0] = length; 545 vals[1] = ratio; 525 546 return vals; 526 547 } … … 537 558 } 538 559 539 if (types.length == 1) { 540 Object o[] = new Object[1]; 541 o[0] = Convert(types[0], value, current); 542 return o; 543 } 544 545 String[] val = new String[1]; 546 val[0] = value; 547 return val; 548 } 549 550 public static Object ConvertToKMS(Method method, Object output) { 560 assert (types.length == 1); 561 562 Object o[] = new Object[1]; 563 o[0] = Convert(types[0], value, current); 564 return o; 565 } 566 567 private static int getArrowLength(String s) { 568 return Integer.parseInt(s.substring(0, s.indexOf(" "))); 569 } 570 571 private static double getArrowRatio(String s) { 572 return Double.parseDouble(s.substring(s.indexOf(" ")).trim()); 573 } 574 575 public static Object ConvertToExpeditee(Method method, Object output) { 551 576 if (output == null) 552 577 return null; 553 578 554 assert (method != null);579 assert (method != null); 555 580 556 581 String name = method.getName(); … … 560 585 561 586 if (name.endsWith("Justification")) 562 return get KMSJustificationCode((Integer) output);587 return getExpediteeJustificationCode((Integer) output); 563 588 564 589 // strings can be returned immediately … … 576 601 // convert fonts 577 602 if (output instanceof Font) 578 return get KMSFontCode((Font) output);603 return getExpediteeFontCode((Font) output); 579 604 580 605 // convert colors 581 606 if (output instanceof Color) 582 return get KMSColorCode((Color) output);607 return getExpediteeColorCode((Color) output); 583 608 584 609 // covert points -
trunk/src/org/expeditee/io/DefaultFrameWriter.java
r67 r80 7 7 import java.util.LinkedHashMap; 8 8 9 import org.expeditee.agents.WriteTree; 9 10 import org.expeditee.gui.Frame; 10 11 import org.expeditee.gui.FrameIO; … … 42 43 43 44 try { 44 _FrameTags.put("A", Frame.class.getMethod("get FrameName", param));45 _FrameTags.put("A", Frame.class.getMethod("getName", param)); 45 46 _FrameTags.put("V", Frame.class.getMethod("getVersion", param)); 46 47 _FrameTags.put("p", Frame.class.getMethod("getProtection", param)); … … 88 89 _ItemTags.put("f", Text.class.getMethod("getFont", param)); 89 90 _ItemTags.put("t", Text.class.getMethod("getSpacing", param)); 90 _ItemTags.put("T", Text.class.getMethod("getText ", param));91 _ItemTags.put("T", Text.class.getMethod("getTextList", param)); 91 92 92 93 _ItemTags.put("a", Text.class.getMethod("getWordSpacing", param)); … … 125 126 } 126 127 128 /** 129 * Called before writing out the body items of each frame. 130 * @param starting the name of the frame currently being written out. 131 * @throws IOException 132 */ 127 133 protected void writeStartFrame(Frame starting) throws IOException { 128 if (starting.getTitle () != null) {129 if (starting.getTitle ().isAnnotation())130 this.writeAnnotationTitle(starting.getTitle ());134 if (starting.getTitleItem() != null) { 135 if (starting.getTitleItem().isAnnotation()) 136 this.writeAnnotationTitle(starting.getTitleItem()); 131 137 else 132 this.writeTitle(starting.getTitle(), starting.getItems()); 133 } 134 } 135 138 this.writeTitle(starting.getTitleItem(), starting.getItems()); 139 } 140 } 141 142 /** 143 * Called after writing out the body items of each frame. 144 * @param ending the name of the frame currently being written out. 145 * @throws IOException 146 */ 136 147 protected void writeEndFrame(Frame ending) throws IOException { 137 148 } … … 139 150 protected void initialise(Frame start) throws IOException { 140 151 if (_filename == null) 141 _filename = FrameIO.EXPORTS_DIR + start.getFrameName() + _format;142 143 if (_filename. toLowerCase().equals("clipboard")) {152 _filename = FrameIO.EXPORTS_DIR + getValidFilename(start.getTitle()) + _format; 153 154 if (_filename.equalsIgnoreCase(WriteTree.CLIPBOARD)) { 144 155 _writer = new ProxyWriter(true); 145 _output = "Clipboard";156 _output = WriteTree.CLIPBOARD; 146 157 } else { 147 158 if (_filename.contains(File.separator)) { … … 168 179 } 169 180 181 protected static String getValidFilename(String filename) { 182 return filename.replaceAll("[ \\.]", "_"); 183 } 184 170 185 protected String finalise() throws IOException { 171 186 try { -
trunk/src/org/expeditee/io/DefaultTreeWriter.java
r46 r80 9 9 import org.expeditee.gui.FrameIO; 10 10 import org.expeditee.items.Item; 11 import org.expeditee.items.Text; 11 12 12 13 public abstract class DefaultTreeWriter extends DefaultFrameWriter implements … … 15 16 // the list of frames currently being processed 16 17 private Stack<FrameCounter> _frames = new Stack<FrameCounter>(); 18 17 19 private int _frameCount = 0; 18 20 19 21 public int getFrameCount() { 20 22 return _frameCount; … … 24 26 try { 25 27 initialise(toWrite); 26 27 28 outputTree(toWrite); 28 29 29 _running = false;30 return finaliseTree();31 30 } catch (IOException ioe) { 32 31 _running = false; 33 32 throw ioe; 33 } catch (Exception e) { 34 e.printStackTrace(); 34 35 } 36 _running = false; 37 return finaliseTree(); 35 38 } 36 39 … … 66 69 return; 67 70 68 _frames.push(new FrameCounter(toWrite.get FrameName(), -1));71 _frames.push(new FrameCounter(toWrite.getName(), -1)); 69 72 70 73 // process the entire tree of frames in depth-first order 71 74 while (_frames.size() > 0) { 72 75 FrameCounter cur = _frames.pop(); 76 77 if (_stop) 78 return; 73 79 74 80 Frame next = FrameIO.LoadFrame(cur.frame); … … 85 91 this.resumeFrame(next); 86 92 } else { 87 FrameGraphics.OverwriteMessage("Writing: " 88 + next.getFrameName()); 89 _frameCount ++; 93 FrameGraphics.OverwriteMessage("Writing: " + next.getName()); 94 _frameCount++; 90 95 writeStartFrame(next); 91 96 } … … 102 107 // ignore annotation and framenames 103 108 if (item.getID() >= 0) { 104 if (item.getLink() != null && !item.isAnnotation()) { 109 //Only follow the links of text items 110 if (item instanceof Text && item.getLink() != null 111 && !item.isAnnotation()) { 105 112 cur.index = i; 106 113 _frames.push(cur); … … 110 117 this.writeStartLink(item); 111 118 112 Frame linked = FrameIO.LoadFrame(item.getAbsoluteLink()); 119 Frame linked = FrameIO 120 .LoadFrame(item.getAbsoluteLink()); 113 121 114 122 // if the linked frame was found, then display it next 115 123 if (linked != null) { 116 FrameCounter fc = new FrameCounter( linked117 .getFrameName(), -1);124 FrameCounter fc = new FrameCounter( 125 linked.getName(), -1); 118 126 if (!_frames.contains(fc)) { 119 127 // remember what frame we are on before … … 127 135 } 128 136 } 129 } else if (item != next.getTitle()) 137 // Dont write out the title here because it is written 138 // out earlier 139 } else if (item != next.getTitleItem()) 130 140 this.writeItem(item); 131 141 } … … 160 170 if (o instanceof FrameCounter) 161 171 return (((FrameCounter) o).frame.equals(frame));// && fc.index 162 172 // == index); 163 173 164 174 return false; -
trunk/src/org/expeditee/io/ExpReader.java
r72 r80 66 66 try { 67 67 // Framename must be set before setting the frame number 68 newFrame.set FrameName(_frameName);68 newFrame.setName(_frameName); 69 69 70 70 // First read all the header lines … … 167 167 Character tag = getTag(line); 168 168 String value = getValue(line); 169 169 170 170 Method toRun = _ItemTags.get(tag); 171 171 if (toRun == null) -
trunk/src/org/expeditee/io/ExpWriter.java
r67 r80 9 9 import java.util.List; 10 10 11 import org.expeditee.agents.DefaultAgent; 11 12 import org.expeditee.gui.Frame; 12 13 import org.expeditee.items.Constraint; … … 20 21 21 22 /** 22 * Writes a Frame out to a KMSformat file.23 * Writes a Frame out to a Expeditee format file. 23 24 * 24 25 * @author jdm18 … … 42 43 if (_filename == null) 43 44 _filename = start.path + name + File.separator 44 + start.get FrameNumber() + ExpReader.EXTENTION;45 + start.getNumber() + ExpReader.EXTENTION; 45 46 46 47 _stringWriter = new StringBuilder(); 47 if (_filename. toLowerCase().equals("clipboard")) {48 if (_filename.equalsIgnoreCase(DefaultAgent.CLIPBOARD)) { 48 49 _writer = new ProxyWriter(true); 49 _filename = "Clipboard";50 _filename = DefaultAgent.CLIPBOARD; 50 51 } else 51 52 _writer = new ProxyWriter(new FileWriter(_filename)); … … 59 60 60 61 /** 61 * Writes the given Frame (and all items it contains) to a KMSfile. Note:62 * Writes the given Frame (and all items it contains) to a Expeditee file. Note: 62 63 * File path and location must be set before calling this or it will do 63 64 * nothing. … … 113 114 try { 114 115 Object o = _FrameTags.get(tag).invoke(toWrite, param); 115 o = Conversion.ConvertTo KMS(_FrameTags.get(tag), o);116 o = Conversion.ConvertToExpeditee(_FrameTags.get(tag), o); 116 117 if (o != null) { 117 118 writeLine(tag, (String) o); … … 272 273 try { 273 274 Object o = toRun.invoke(toWrite, param); 274 o = Conversion.ConvertTo KMS(toRun, o);275 o = Conversion.ConvertToExpeditee(toRun, o); 275 276 if (o != null) { 276 277 if (o instanceof List) { -
trunk/src/org/expeditee/io/FrameReader.java
r74 r80 40 40 41 41 try { 42 _FrameTags.put('A', Frame.class.getMethod("set FrameName", pString));42 _FrameTags.put('A', Frame.class.getMethod("setName", pString)); 43 43 _FrameTags.put('V', Frame.class.getMethod("setVersion", pInt)); 44 44 _FrameTags … … 94 94 _ItemTags.put('t', Text.class.getMethod("setSpacing", pInt)); 95 95 _ItemTags.put('T', Text.class.getMethod("appendLine", pString)); 96 97 96 _ItemTags.put('a', Text.class.getMethod("setWordSpacing", pInt)); 98 97 _ItemTags.put('b', Text.class.getMethod("setLetterSpacing", pInt)); -
trunk/src/org/expeditee/io/HTMLBWriter.java
r20 r80 1 1 package org.expeditee.io; 2 2 3 import java.awt.Image; 4 import java.awt.image.BufferedImage; 3 5 import java.io.IOException; 4 6 import java.util.List; 5 7 6 import org.expeditee.gui.Frame; 8 import org.expeditee.actions.Misc; 9 import org.expeditee.gui.FrameIO; 7 10 import org.expeditee.items.Item; 8 11 import org.expeditee.items.Picture; 9 12 import org.expeditee.items.Text; 10 13 11 public class HTMLBWriter extends DefaultTreeWriter { 12 13 private int _indent = 0; 14 15 private static final String INDENT = " "; 16 17 @Override 18 protected void initialise(Frame start) throws IOException { 19 _format = ".html"; 20 super.initialise(start); 21 22 _writer.write("<HTML>" + ItemWriter.NEW_LINE); 23 _writer.write("<HEAD>" + ItemWriter.NEW_LINE); 24 _writer.write("</HEAD>" + ItemWriter.NEW_LINE); 25 _writer.write("<BODY>" + ItemWriter.NEW_LINE); 26 } 27 28 @Override 29 protected String finaliseTree() throws IOException { 30 _writer.write("</BODY>" + ItemWriter.NEW_LINE); 31 return super.finaliseTree(); 32 } 33 34 @Override 35 protected void writeStartLink(Item linker) throws IOException { 36 _indent++; 37 } 38 39 @Override 40 protected void writeEndLink(Item linker) throws IOException { 41 _indent--; 42 } 14 public class HTMLBWriter extends AbstractHTMLWriter { 43 15 44 16 @Override 45 17 protected void writeTitle(Text toWrite, List<Item> items) 46 18 throws IOException { 47 String heading = toWrite.getText NoList();48 String tag = " H" + (_indent+ 1);19 String heading = toWrite.getText(); 20 String tag = "h" + (getIndent() + 1); 49 21 // indenting for tag 50 22 indent(); … … 57 29 indent(); 58 30 _writer.write("<p>"); 59 _writer.write(text.getText NoList().replace('\n', ' '));31 _writer.write(text.getText().replace('\n', ' ')); 60 32 _writer.write("</p>" + ItemWriter.NEW_LINE); 61 }62 63 private void indent() throws IOException {64 for (int i = 0; i < _indent; i++)65 _writer.write(INDENT);66 33 } 67 34 68 35 @Override 69 36 protected void writePicture(Picture pic) throws IOException { 70 Text source = pic.getText(); 37 Image image = pic.getImage(); 38 String filesFolder = getFilesFolder(); 39 String fileName; 40 // If its a bufferedImage then just write it out to the files directory 41 //This means it is probably a FrameImage 42 if (image instanceof BufferedImage) { 43 String link = pic.getAbsoluteLink(); 44 // Account for the possiblitly of an unlinked buffered image 45 fileName = link == null ? ("Image" + pic.getID()) : link; 46 fileName = Misc.SaveImage((BufferedImage) image, "PNG", FrameIO.EXPORTS_DIR 47 + filesFolder, fileName); 48 } else {//It is a normal Image stored somewhere 49 Text source = pic.getText(); 71 50 72 String line = source.getFirstLine();73 line = line.substring(line.indexOf(":") + 1).trim();51 fileName = source.getFirstLine(); 52 fileName = fileName.substring(fileName.indexOf(":") + 1).trim(); 74 53 54 String oldImageName = FrameIO.IMAGES_PATH + fileName; 55 String newImageName = FrameIO.EXPORTS_DIR + filesFolder + fileName; 56 try { 57 FrameIO.copyFile(oldImageName, newImageName); 58 } catch (Exception e) { 59 filesFolder = ""; 60 } 61 if (filesFolder.equals("")) { 62 filesFolder = "../" + FrameIO.IMAGES_FOLDER; 63 } 64 } 75 65 indent(); 76 77 _writer.write("<img src = '../images/" + line + "'>"); 66 StringBuffer imageTag = new StringBuffer("<img src=\""); 67 imageTag.append(filesFolder).append(fileName); 68 imageTag.append("\" height=").append(pic.getHeight()); 69 imageTag.append(" width=").append(pic.getWidth()); 70 imageTag.append(" border=1>"); 71 _writer.write(imageTag.toString()); 78 72 _writer.write(ItemWriter.NEW_LINE); 79 73 } -
trunk/src/org/expeditee/io/HTMLWriter.java
r4 r80 30 30 31 31 Text text = (Text) linker; 32 List<String> toWrite = text.getText ();32 List<String> toWrite = text.getTextList(); 33 33 34 34 String first = toWrite.get(0); … … 67 67 68 68 Text text = (Text) linker; 69 List<String> toWrite = text.getText ();69 List<String> toWrite = text.getTextList(); 70 70 71 71 String first = toWrite.get(0); … … 84 84 @Override 85 85 protected void writeText(Text text) throws IOException { 86 for (String s : text.getText ()) {86 for (String s : text.getTextList()) { 87 87 88 88 indent(); -
trunk/src/org/expeditee/io/ItemWriter.java
r78 r80 21 21 } 22 22 23 /** 24 * Called for each item on each frame to write out the contents of the items. 25 * @param toWrite the item to be written out. 26 * @throws IOException 27 */ 23 28 protected void writeItem(Item toWrite) throws IOException { 24 29 if (toWrite.isAnnotation()) { … … 77 82 protected void writeDot(Item toWrite) throws IOException { 78 83 } 79 80 /*81 * public static final String NEW_LINE =82 * System.getProperty("line.separator");83 *84 * protected BufferedWriter _writer = null;85 *86 * public FrameWriter(String format){}87 *88 * public String initialise(String path, String filename) throws89 * IOException{ if(path.charAt(path.length() - 1) != File.separatorChar)90 * path += File.separator;91 *92 * _writer = new BufferedWriter(new FileWriter(path.toLowerCase() +93 * filename.toLowerCase()));94 *95 * return filename; }96 *97 * public void initialise(Frame toWrite) throws IOException{ String name =98 * toWrite.getFrameset().toLowerCase(); if(name.endsWith(".")) name =99 * name.substring(0, name.length() - 1);100 *101 * String filepath = toWrite.path + name;102 *103 * String filename = name + "." + toWrite.getFrameNumber();104 *105 * initialise(filepath, filename); }106 *107 * public void write(Frame toWrite) throws IOException{ initialise(toWrite);108 *109 * writeFrame(toWrite);110 *111 * finalise(); }112 *113 * public void writeFrame(Frame toWrite) throws IOException{ for(Item i :114 * toWrite.getItems()) writeItem(i, 0); }115 *116 * public void writeItem(Item item, int indent) throws IOException{ if(item117 * instanceof Text) writeText((Text) item, indent);118 *119 * if(item instanceof Dot) writeDot((Dot) item);120 *121 * if(item instanceof Line) writeLine((Line) item);122 *123 * if(item instanceof Picture) writePicture((Picture) item); }124 *125 * public void writeStartLinkItem(Item item, int indent) throws IOException{ }126 *127 * public void writeEndLinkItem(Item item, int indent) throws IOException{ }128 *129 * protected void writeText(Text text, int indent) throws IOException{}130 *131 * protected void writeDot(Dot dot) throws IOException{}132 *133 * protected void writeLine(Line line) throws IOException{}134 *135 * protected void writePicture(Picture pic) throws IOException{}136 *137 * public abstract void insertLine() throws IOException;138 *139 * public abstract void indent() throws IOException;140 *141 * public void finalise() throws IOException{ _writer.flush();142 * _writer.close(); _writer = null; }143 */144 84 } -
trunk/src/org/expeditee/io/JAVAWriter.java
r22 r80 46 46 protected void writeTitle(Text toWrite, List<Item> items) 47 47 throws IOException { 48 String heading = toWrite.getText NoList();48 String heading = toWrite.getText(); 49 49 50 50 _writer.write("public class " + heading + "{" + ItemWriter.NEW_LINE); … … 54 54 protected void writeText(Text text) throws IOException { 55 55 indent(); 56 _writer.write(text.getText NoList().replace('\n', ' '));56 _writer.write(text.getText().replace('\n', ' ')); 57 57 _writer.write(";" + ItemWriter.NEW_LINE); 58 58 } -
trunk/src/org/expeditee/io/KMSReader.java
r74 r80 45 45 46 46 try { 47 _FrameTags.put("A", Frame.class.getMethod("set FrameName", pString));47 _FrameTags.put("A", Frame.class.getMethod("setName", pString)); 48 48 _FrameTags.put("V", Frame.class.getMethod("setVersion", pInt)); 49 49 _FrameTags … … 98 98 _ItemTags.put("f", Text.class.getMethod("setFont", pFont)); 99 99 _ItemTags.put("t", Text.class.getMethod("setSpacing", pInt)); 100 _ItemTags.put("T", Text.class.getMethod(" setText", pString));100 _ItemTags.put("T", Text.class.getMethod("appendText", pString)); 101 101 102 102 _ItemTags.put("a", Text.class.getMethod("setWordSpacing", pInt)); -
trunk/src/org/expeditee/io/KMSWriter.java
r72 r80 10 10 import java.util.List; 11 11 12 import org.expeditee.agents.DefaultAgent; 12 13 import org.expeditee.gui.Frame; 13 14 import org.expeditee.items.Constraint; … … 43 44 if (_filename == null) 44 45 _filename = start.path + name + File.separator + name + "." 45 + start.get FrameNumber();46 + start.getNumber(); 46 47 47 48 _stringWriter = new StringBuilder(); 48 if (_filename.toLowerCase().equals( "clipboard")) {49 if (_filename.toLowerCase().equals(DefaultAgent.CLIPBOARD)) { 49 50 _writer = new ProxyWriter(true); 50 _filename = "Clipboard";51 _filename = DefaultAgent.CLIPBOARD; 51 52 } else 52 53 _writer = new ProxyWriter(new FileWriter(_filename)); … … 104 105 try { 105 106 Object o = _FrameTags.get(tag).invoke(toWrite, param); 106 o = Conversion.ConvertTo KMS(_FrameTags.get(tag), o);107 o = Conversion.ConvertToExpeditee(_FrameTags.get(tag), o); 107 108 if (o != null) { 108 109 writeLine(tag, (String) o); … … 145 146 if (_writer == null) 146 147 return; 148 149 if (item.offScreen()) { 150 //System.out.println("item offscreen!"); 151 return; 152 } 147 153 148 154 writeLine(""); … … 253 259 try { 254 260 Object o = toRun.invoke(toWrite, param); 255 o = Conversion.ConvertTo KMS(toRun, o);261 o = Conversion.ConvertToExpeditee(toRun, o); 256 262 if (o != null) { 257 263 if (o instanceof List) { -
trunk/src/org/expeditee/io/TEXWriter.java
r17 r80 34 34 _writer.write("\\" + command + "{"); 35 35 36 List<String> titleLines = _title.getText ();36 List<String> titleLines = _title.getTextList(); 37 37 for (int i = 0; i < titleLines.size() - 1; i++) { 38 38 _writer.write(titleLines.get(i)); … … 54 54 55 55 Text text = (Text) linker; 56 List<String> toWrite = text.getText ();56 List<String> toWrite = text.getTextList(); 57 57 58 58 String first = toWrite.get(0); … … 73 73 74 74 Text text = (Text) linker; 75 List<String> toWrite = text.getText ();75 List<String> toWrite = text.getTextList(); 76 76 77 77 String first = toWrite.get(0); … … 86 86 @Override 87 87 protected void writeText(Text text) throws IOException { 88 for (String s : text.getText ()) {88 for (String s : text.getTextList()) { 89 89 _writer.write(s); 90 90 _writer.write(ItemWriter.NEW_LINE); -
trunk/src/org/expeditee/io/TXTWriter.java
r4 r80 9 9 import org.expeditee.items.Text; 10 10 11 public class TXTWriter extends DefaultTreeWriter implements FrameWriter{11 public class TXTWriter extends DefaultTreeWriter{ 12 12 13 13 private boolean _join = false; … … 39 39 indent = _indent - 1; 40 40 41 for (String s : title.getText ()) {41 for (String s : title.getTextList()) { 42 42 43 43 for (int i = 0; i < indent; i++) … … 71 71 @Override 72 72 protected void writeText(Text text) throws IOException { 73 for (String s : text.getText ()) {73 for (String s : text.getTextList()) { 74 74 75 75 for (int i = 0; i < _indent; i++) -
trunk/src/org/expeditee/items/FrameBitmap.java
r79 r80 10 10 11 11 public class FrameBitmap extends FramePicture { 12 public FrameBitmap(Text source, String size,ImageObserver observer)12 public FrameBitmap(Text source, String size, ImageObserver observer) 13 13 throws IllegalArgumentException { 14 14 super(); … … 17 17 18 18 refresh(); 19 19 20 20 if (_image == null) 21 21 throw new IllegalArgumentException(); … … 26 26 @Override 27 27 public boolean refresh() { 28 // Check if the picture is being created with @f29 28 assert (_source.getLink() != null); 30 29 Frame frame = FrameIO.LoadFrame(_source.getAbsoluteLink()); 31 // if the frame cant be found just use the current image32 if (frame == null) {30 // if the frame cant be found just use the current image 31 if (frame == null) { 33 32 return false; 34 33 } 35 34 36 35 List<Text> textList = frame.getBodyTextItems(false); 37 36 if (textList.size() == 0) 38 37 return false; 39 List<String> imageLines = textList.get(0).getText ();38 List<String> imageLines = textList.get(0).getTextList(); 40 39 int width = 0; 41 40 int height = imageLines.size(); … … 48 47 BufferedImage.TYPE_INT_ARGB); 49 48 // now set the bits on the image 50 final int transparent = (new Color(0F,0F,0F,0F)).getRGB(); 51 final int black = _source.getColor().getRGB(); 52 int currentColor = transparent; 49 final int transparent = (new Color(0F, 0F, 0F, 0F)).getRGB(); 50 final int main = _source.getColor().getRGB(); 51 final Color c = _source.getColor(); 52 int currentColor = main; 53 53 int row = 0; 54 54 for (String s : imageLines) { 55 55 for (int i = 0; i < width; i++) { 56 if (i < s.length() && s.charAt(i) != '0') { 57 currentColor = black; 58 } else { 59 currentColor = transparent; 56 currentColor = transparent; 57 if (i < s.length()) { 58 char currentPixel = s.charAt(i); 59 // Space is transparent as is 0 60 if (Character.isDigit(currentPixel)) { 61 int alpha = (int)((currentPixel - '0') * 25.5F + 0.5F); 62 currentColor = new Color(c.getRed(), c.getGreen(), c 63 .getBlue(), alpha).getRGB(); 64 }else if (currentPixel != ' ') { 65 currentColor = main; 66 } 60 67 } 61 68 bi.setRGB(i, row, currentColor); … … 64 71 } 65 72 _image = bi; 66 73 67 74 return true; 68 75 } 69 76 70 77 @Override 71 protected Picture createPicture() {78 protected Picture createPicture() { 72 79 return ItemUtils.CreateFrameBitmap((Text) _source.copy(), 73 80 _imageObserver); 74 81 } 82 83 @Override 84 protected String getTagText() { 85 return "@b: "; 86 } 75 87 } -
trunk/src/org/expeditee/items/FrameImage.java
r79 r80 28 28 _imageObserver = observer; 29 29 30 // Check if the picture is being created with @f31 30 refresh(); 32 31 … … 57 56 return true; 58 57 } 58 59 @Override 60 protected String getTagText() { 61 return "@f: "; 62 } 59 63 } -
trunk/src/org/expeditee/items/FramePicture.java
r79 r80 27 27 updatePolygon(); 28 28 } 29 30 @Override 31 public String getName() { 32 return _source.getAbsoluteLink(); 33 } 29 34 } -
trunk/src/org/expeditee/items/InteractiveWidget.java
r78 r80 101 101 String TAG = ItemUtils.GetTag(ItemUtils.TAG_IWIDGET); 102 102 103 String text = source.getText NoList();103 String text = source.getText(); 104 104 if (text == null) 105 105 throw new IllegalArgumentException("source does not have any text"); -
trunk/src/org/expeditee/items/Item.java
r78 r80 41 41 // if this dot is part of an enclosing shape 42 42 private Collection<Item> _enclosure = null; 43 43 44 44 public static final int LEFT_MARGIN = 13; 45 45 … … 78 78 79 79 public static final Color DEFAULT_BACKGROUND = Color.white; 80 81 public static final Color TRANSPARENT = new Color(0, 0,0,0);80 81 public static final Color TRANSPARENT = new Color(0, 0, 0, 0); 82 82 83 83 /** … … 99 99 */ 100 100 public static Color[] COLOR_WHEEL = { Color.BLACK, Color.RED, Color.BLUE, 101 Item.GREEN, Color.MAGENTA, Color.YELLOW.darker(), 102 DEFAULT_BACKGROUND }; 101 Item.GREEN, Color.MAGENTA, Color.YELLOW.darker(), Color.WHITE, null }; 103 102 104 103 public static Color[] FILL_COLOR_WHEEL = { Color.BLACK, 105 104 new Color(255, 150, 150), new Color(150, 150, 255), 106 105 new Color(150, 255, 150), new Color(255, 150, 255), 107 new Color(255, 255, 100), DEFAULT_BACKGROUND};106 new Color(255, 255, 100), Color.WHITE, null }; 108 107 109 108 public static final int UNCHANGED_CURSOR = -100; … … 117 116 public static final int CROP_CURSOR = Cursor.CROSSHAIR_CURSOR; 118 117 119 public static final int JUSTIFICATION_NONE = -1; 118 //The default value for integer attributes 119 public static final int DEFAULT_INTEGER = -1; 120 121 public static final int JUSTIFICATION_NONE = DEFAULT_INTEGER; 120 122 121 123 public static final int JUSTIFICATION_FULL = 0; … … 230 232 public int Permission = PERMISSION_FULL; 231 233 234 // A fill color of null represents transparent 232 235 private Color _colorFill = null; 233 236 234 private Color _color = DEFAULT_FOREGROUND; 237 // A fore color of null represents the default color 238 private Color _color = null; 235 239 236 240 private Color _highlightColor = DEFAULT_HIGHLIGHT; … … 392 396 } else 393 397 return false; 394 }395 396 final public String getAbsoluteLink() {397 String link = getLink();398 399 if (link == null)400 return null;401 // assert (_parent!= null);402 if (_parent == null) {403 // if parent is null it is an item on the message box404 // so it must already be absolute405 assert (!FrameIO.isPositiveInteger(link));406 return link;407 }408 409 // if its a relative link then return absolute410 if (FrameIO.isPositiveInteger(link)) {411 return _parent.getFramesetName() + link;412 }413 return link;414 398 } 415 399 … … 731 715 */ 732 716 public Color getPaintColor() { 717 // If color is null then get the paint foregroundColor for the frame the 718 // item is on which is a color adjusted to suit the background 733 719 if (_color == null) { 734 720 if (getParent() != null) 735 721 return getParent().getPaintForegroundColor(); 736 722 737 if (DisplayIO.getCurrentFrame() == null) 723 Frame current = DisplayIO.getCurrentFrame(); 724 if (current == null) 738 725 return DEFAULT_FOREGROUND; 739 726 740 return DisplayIO.getCurrentFrame().getPaintForegroundColor();727 return current.getPaintForegroundColor(); 741 728 } 742 729 … … 854 841 855 842 public boolean isFrameName() { 856 if (this.getParent() == null 857 || this.getParent().getFrameNameItem() != this) 843 if (this.getParent() == null || this.getParent().getNameItem() != this) 858 844 return false; 859 845 return true; … … 861 847 862 848 public boolean isFrameTitle() { 863 if (this.getParent() == null || this.getParent().getTitle () != this)849 if (this.getParent() == null || this.getParent().getTitleItem() != this) 864 850 return false; 865 851 return true; … … 916 902 public boolean isOldTag() { 917 903 if (this instanceof Text) 918 if (((Text) this).getText ().get(0).toLowerCase().equals("@old"))904 if (((Text) this).getTextList().get(0).toLowerCase().equals("@old")) 919 905 return true; 920 906 return false; … … 944 930 if (getFillColor() != null && getEnclosingDots() != null) { 945 931 g.setColor(getFillColor()); 946 // Shape s = getEnclosedShape();947 // Rectangle b = s.getBounds();948 // GradientPaint gp = new GradientPaint((int) (b.x + b.width * 0.3),949 // 950 // 951 // g.setPaint(gp);952 // g.fill(s);932 // Shape s = getEnclosedShape(); 933 // Rectangle b = s.getBounds(); 934 // GradientPaint gp = new GradientPaint((int) (b.x + b.width * 0.3), 935 // b.y, getFillColor(), (int) (b.x + b.width * 1.3), b.y, 936 // Color.white); 937 // g.setPaint(gp); 938 // g.fill(s); 953 939 g.fillPolygon(getEnclosedShape()); 954 940 } … … 1653 1639 _actions.add(string); 1654 1640 } 1655 1641 1656 1642 protected int getLinkYOffset() { 1657 1643 return 0; … … 1659 1645 1660 1646 /** 1647 * Paint the link symbol for the item if it is a 1648 * 1661 1649 * @param g 1662 1650 */ 1663 1651 protected void paintLink(Graphics2D g) { 1652 if (FrameGraphics.isAudienceMode()) 1653 return; 1654 1664 1655 if (getLink() != null || getAction() != null) { 1665 1656 if (getLink() != null && getAction() != null) { … … 1670 1661 g.setColor(ACTION_COLOR); 1671 1662 } 1672 1663 1673 1664 AffineTransform at = new AffineTransform(); 1674 1665 AffineTransform orig = g.getTransform(); 1675 at.translate(getX() - LEFT_MARGIN, getY() + getLinkYOffset());1666 at.translate(getX() - LEFT_MARGIN, getY() + getLinkYOffset()); 1676 1667 g.setTransform(at); 1677 1668 1678 1669 if (getLinkMark() && getLink() != null) { 1679 1670 g.drawPolygon(getCircle()); 1680 1671 1681 1672 // if the link is not valid, cross out the circle 1682 1673 if (!isLinkValid()) 1683 1674 g.drawPolygon(getCircleCross()); 1684 1675 } 1685 1676 1686 1677 if (getActionMark() && getAction() != null) { 1687 1678 g.drawPolygon(getCircle()); 1688 1679 g.fillPolygon(getCircle()); 1689 1680 1690 1681 // if the link is not valid, cross out the circle 1691 1682 if (!isLinkValid() && getLink() != null) { … … 1694 1685 } 1695 1686 } 1696 1687 1697 1688 // reset the graphics tranformation 1698 1689 g.setTransform(orig); 1699 1690 } 1700 1691 } 1701 1692 1702 1693 /** 1703 1694 * Gets the distance between the start of the text and the left border of … … 1712 1703 - MARGIN_RIGHT : MARGIN_RIGHT); 1713 1704 } 1705 1706 public String getName() { 1707 return null; 1708 } 1709 1710 final public String getAbsoluteLinkTemplate() { 1711 return getAbsoluteLink(getLinkTemplate()); 1712 } 1713 1714 final public String getAbsoluteLinkFrameset() { 1715 return getAbsoluteLink(getLinkFrameset()); 1716 } 1717 1718 final public String getAbsoluteLink() { 1719 return getAbsoluteLink(getLink()); 1720 } 1721 1722 /** 1723 * @param link 1724 * @return 1725 */ 1726 private String getAbsoluteLink(String link) { 1727 if (link == null) 1728 return null; 1729 // assert (_parent!= null); 1730 if (_parent == null) { 1731 // if parent is null it is an item on the message box 1732 // so it must already be absolute 1733 assert (!FrameIO.isPositiveInteger(link)); 1734 return link; 1735 } 1736 1737 // if its a relative link then return absolute 1738 if (FrameIO.isPositiveInteger(link)) { 1739 return _parent.getFramesetName() + link; 1740 } 1741 return link; 1742 } 1714 1743 } -
trunk/src/org/expeditee/items/ItemUtils.java
r78 r80 19 19 import javax.swing.JFrame; 20 20 21 import org.expeditee.gui.AttributeUtils; 21 22 import org.expeditee.gui.DisplayIO; 22 23 import org.expeditee.gui.Frame; … … 70 71 71 72 public static final int TAG_STAT_TEMPLATE = 18; 72 73 73 74 public static final int TAG_VECTOR = 19; 74 75 75 76 public static final int TAG_BITMAP_IMAGE = 20; 76 77 … … 145 146 for (Item i : items) { 146 147 if (i instanceof Text && i.isAnnotation()) 147 if (((Text) i).getText NoList().trim().equalsIgnoreCase(toFind))148 if (((Text) i).getText().trim().equalsIgnoreCase(toFind)) 148 149 return (Item) i; 149 150 } … … 166 167 * @return True if the Item matches the given tag, false otherwise 167 168 */ 168 public static boolean isTag(Item toCheck, int tag) {169 return isTag(toCheck, GetTag(tag));170 } 171 172 public static boolean isTag(Item toCheck, int tag, boolean hasValue) {173 return isTag(toCheck, GetTag(tag), hasValue);174 } 175 176 /** 177 * Checks if the given Item contains the desired tag (case insensitive)169 public static boolean startsWithTag(Item toCheck, int tag) { 170 return startsWithTag(toCheck, GetTag(tag)); 171 } 172 173 public static boolean startsWithTag(Item toCheck, int tag, boolean hasValue) { 174 return startsWithTag(toCheck, GetTag(tag), hasValue); 175 } 176 177 /** 178 * Checks if the given Item begins with the desired tag (case insensitive). 178 179 * 179 180 * @param toCheck … … 185 186 * @return True if the tag is found in the given Item, False otherwise. 186 187 */ 187 public static boolean isTag(Item toCheck, String tag, boolean hasValue) {188 if (!(toCheck instanceof Text) || !toCheck.isAnnotation())188 public static boolean startsWithTag(Item toCheck, String tag, boolean valueAllowed) { 189 if (!(toCheck instanceof Text)) 189 190 return false; 190 191 191 192 Text txt = (Text) toCheck; 192 // tags are ase-insensitive 193 return String.CASE_INSENSITIVE_ORDER.compare(txt.getFirstLine().trim(), 194 tag) == 0 195 || (hasValue && txt.startsWith(tag + " ", true)); 196 } 197 198 public static boolean isTag(Item toCheck, String tag) { 199 return isTag(toCheck, tag, true); 193 String value = ItemUtils.StripTag(txt.getText(), tag); 194 195 if (value == null) 196 return false; 197 return valueAllowed || value.equals(""); 198 } 199 200 /** 201 * Checks if the item begins with the desired tag. 202 * @param toCheck 203 * @param tag 204 * @return 205 */ 206 public static boolean startsWithTag(Item toCheck, String tag) { 207 return startsWithTag(toCheck, tag, true); 200 208 } 201 209 202 210 /** 203 211 * Strips off the given tag from the given String, and returns wathever is 204 * left 212 * left. 205 213 * 206 214 * @param toStrip … … 212 220 */ 213 221 public static String StripTag(String toStrip, String tag) { 214 if (toStrip.toLowerCase().startsWith(tag.toLowerCase())) { 215 toStrip = toStrip.substring(tag.length()).trim(); 216 return toStrip; 217 } 218 219 /** 220 * TODO: Change this to use REGEX 221 */ 222 223 return null; 224 } 225 226 /** 227 * The same as StripTag(String, String), but this method iterates through 228 * the list of pre-defined tags until one is found. 229 * 230 * @param toStrip 231 * The String to strip the tag from 232 * @return The String that results from stripping off the Tag, or null if 233 * the given String was not a tag 234 */ 235 public static String StripTag(String toStrip) { 236 // there must be something left after stripping 237 if (toStrip == null)// || toStrip.trim().indexOf(" ") < 0) 238 return toStrip; 239 240 for (int i = TAG_MIN; i <= TAG_MAX; i++) { 241 String res = StripTag(toStrip, GetTag(i)); 242 if (res != null) 243 return res; 244 } 245 246 return null; 247 } 248 249 /** 250 * Strips the first character from a string if it is the @ symbol 222 if (toStrip == null) 223 return null; 224 toStrip = toStrip.trim(); 225 if (!toStrip.toLowerCase().startsWith(tag.toLowerCase())) 226 return null; 227 228 if (toStrip.length() == tag.length()) 229 return ""; 230 // remove tag and ensure the char is the tag separator 231 char separator = toStrip.charAt(tag.length()); 232 if (separator != ':') 233 return null; 234 235 if (toStrip.length() == tag.length() + 1) 236 return ""; 237 238 return toStrip.substring(tag.length() + 1).trim(); 239 } 240 241 /** 242 * Strips the first character from a string if it is the tag symbol and 243 * returns the remainder. 251 244 * @param toStrip 252 245 * the string to be stripped 253 * @return the stripped version of the string 246 * @return the stripped version of the string. 254 247 */ 255 248 public static String StripTagSymbol(String toStrip) { 256 249 // there must be something left after stripping 257 250 if (toStrip != null) { 251 toStrip = toStrip.trim(); 258 252 if (toStrip.length() > 0) { 259 253 if (toStrip.charAt(0) == '@') { … … 262 256 } 263 257 } 264 265 258 return toStrip; 266 259 } … … 293 286 return "@ao"; 294 287 case TAG_IMAGE: 295 return "@i :";288 return "@i"; 296 289 case TAG_ITEM_TEMPLATE: 297 290 return "@itemtemplate"; … … 317 310 return "@old"; 318 311 case TAG_POINTTYPE: 319 return "@pointtype :";312 return "@pointtype"; 320 313 case TAG_IWIDGET: 321 314 return "@iw"; … … 358 351 */ 359 352 public static Picture CreatePicture(Text source, ImageObserver observer) { 360 String text = source.getText NoList();353 String text = source.getText(); 361 354 String path = ""; 355 String fileName = ""; 362 356 String size = ""; 363 357 … … 368 362 text = text.trim(); 369 363 370 if (text.indexOf(".") >= text.lastIndexOf(" ")) 364 int fileSuffixChar = text.indexOf('.'); 365 if (fileSuffixChar < 0) 366 return null; 367 int endOfFileName = text.indexOf(' ', fileSuffixChar); 368 if (endOfFileName < 0) { 371 369 path = text; 372 else 373 path = text.substring(0, text.lastIndexOf(" ")); 374 375 size = text.substring(path.length()).trim(); 370 size = ""; 371 } else { 372 path = text.substring(0, endOfFileName); 373 size = text.substring(endOfFileName).trim(); 374 } 375 fileName = path; 376 376 377 377 // try images subdirectory … … 415 415 416 416 try { 417 Picture pic = new Picture(source, path, size, observer);417 Picture pic = new Picture(source, fileName, path, size, observer); 418 418 419 419 return pic; … … 429 429 430 430 // remove @f tag 431 size = size.replaceFirst("@f", ""); 432 size = size.trim(); 431 size = AttributeUtils.getValue(size); 433 432 434 433 try { … … 440 439 } 441 440 } 442 441 443 442 public static Picture CreateFrameBitmap(Text source, ImageObserver observer) { 444 443 String size = source.getFirstLine(); 445 444 446 445 // remove @b tag 447 size = size.replaceFirst("@b", ""); 448 size = size.trim(); 446 size = AttributeUtils.getValue(size); 449 447 450 448 try { … … 515 513 // if this is the frame name, make sure the frame is saved (in 516 514 // case it is a TDFC frame) 517 if (i == i.getParent().get FrameNameItem())515 if (i == i.getParent().getNameItem()) 518 516 i.getParent().setChanged(true); 519 517 520 518 // if this is the title of the frame, link it to the frame 521 if (i.getLink() == null && i == i.getParent().getTitle ()519 if (i.getLink() == null && i == i.getParent().getTitleItem() 522 520 && toCopy.size() == 1) { 523 521 // save the frame after copying 524 522 i.getParent().setChanged(true); 525 copy.setLink(i.getParent().get FrameName());523 copy.setLink(i.getParent().getName()); 526 524 } 527 525 } … … 552 550 for (Line line : lines) { 553 551 Line lineCopy = line.copy(); 554 // get the lineEnd we copied above if it is in the MAPPING552 // get the lineEnd we copied above if it is in the MAPPING 555 553 Item originalLineEnd = line.getEndItem(); 556 554 Item actualLineEnd = lineEndMap.get(originalLineEnd); … … 559 557 else 560 558 lineCopy.setEndItem(actualLineEnd); 561 559 562 560 Item originalLineStart = line.getStartItem(); 563 561 Item actualLineStart = lineEndMap.get(originalLineStart); … … 566 564 else 567 565 lineCopy.setStartItem(actualLineStart); 568 566 569 567 copies.add(lineCopy); 570 568 } … … 593 591 594 592 return copies; 595 }596 597 private static void ReplaceAll(List<Item> list, Item replace, Item with) {598 // replace all other instances with the copy599 for (int pos = 0; pos < list.size(); pos++)600 if (list.get(pos) == replace) {601 list.set(pos, with);602 }603 593 } 604 594 -
trunk/src/org/expeditee/items/Line.java
r78 r80 839 839 public Item forceMerge(Item spot, int mouseX, int mouseY) { 840 840 841 spot.removeAllConstraints(); 842 843 _end.removeAllConstraints(); 844 845 _start.removeAllConstraints(); 841 // spot.removeAllConstraints(); 842 // _end.removeAllConstraints(); 843 // _start.removeAllConstraints(); 844 845 // Keep constraints 846 for (Constraint c : _end.getConstraints()) { 847 if (c.getOppositeEnd(_end).equals(_start)) { 848 c.replaceEnd(_start, spot); 849 new Constraint(spot, _start, getParentOrCurrentFrame() 850 .getNextItemID(), c.getType()); 851 break; 852 } 853 } 846 854 847 855 // calculate nearest point on line from spot -
trunk/src/org/expeditee/items/Picture.java
r78 r80 19 19 import javax.swing.ImageIcon; 20 20 21 import org.expeditee.gui.FrameGraphics;22 21 import org.expeditee.io.Logger; 23 22 … … 41 40 public class Picture extends Item { 42 41 42 private static final int MINIMUM_WIDTH = 10; 43 43 44 public static final int WIDTH = 0; 44 45 45 46 public static final int RATIO = 1; 46 47 public static final int FRACTION = 2;48 47 49 48 protected Image _image = null; … … 54 53 protected Text _source = null; 55 54 56 private int _numerator = -1;57 58 private int _denominator = -1;59 60 private float _ratio = 1.0f;61 62 private int _width = -1;63 64 55 private int _scaleType = RATIO; 65 56 66 57 private float _scale = 1.0f; 67 58 59 // Start of the crop relative to START 68 60 private Point _cropStart = null; 69 61 62 // Start of the crop relative to END 70 63 private Point _cropEnd = null; 71 64 72 private Point _cropOrigin = null; 65 private Point _start = new Point(0, 0);; 66 67 private Point _end = new Point(0, 0);; 73 68 74 69 private boolean _showCropping = false; 75 70 76 71 private String _path = null; 72 73 private String _fileName = null; 77 74 78 75 // used to repaint animated GIF images, among other things. … … 91 88 * @param source 92 89 * The Text Item that was used to create this Picture 90 * @param fileName 91 * the name of the file as it should be displayed in the source 92 * text 93 93 * @param path 94 94 * The Path of the Image to load from disk. … … 97 97 * screen. 98 98 */ 99 public Picture(Text source, String path, String size, ImageObserver observer)100 throws IllegalArgumentException {99 public Picture(Text source, String fileName, String path, String size, 100 ImageObserver observer) throws IllegalArgumentException { 101 101 super(); 102 _fileName = fileName; 102 103 _path = path; 103 104 _source = source; … … 113 114 114 115 protected void parseSize(String size) { 116 // set the default values for start and end 117 _start = new Point(0, 0); 118 _end = new Point(_image.getWidth(null), _image.getHeight(null)); 119 size = size.trim(); 120 String[] values = size.split("\\s+"); 121 // Now get the cropping values if there are any 122 try { 123 if (values.length > 2) { 124 int startX = Integer.parseInt(values[1]); 125 int startY = Integer.parseInt(values[2]); 126 _start = new Point(startX, startY); 127 if (values.length > 4) { 128 int endX = Integer.parseInt(values[3]); 129 int endY = Integer.parseInt(values[4]); 130 _end = new Point(endX, endY); 131 } 132 } 133 } catch (Exception e) { 134 } 135 115 136 try { 116 137 if (size.length() == 0) { 117 138 size = "" + _image.getWidth(null); 118 _source.setText(_source.getFirstLine() + " " + size); 119 } 120 121 // parse size from text 122 if (size.contains("/")) { 123 // this is a fraction 124 _numerator = Integer.parseInt(size.substring(0, size 125 .indexOf("/"))); 126 _denominator = Integer.parseInt(size.substring(size 127 .indexOf("/") + 1)); 128 _scale = (_numerator * 1.0f) / _denominator; 129 _scaleType = FRACTION; 130 } else if (size.contains(".")) { 139 _source.setText(getTagText() + size); 140 return; 141 } 142 size = values[0]; 143 // parse width or ratio from text 144 if (size.contains(".")) { 131 145 // this is a ratio 132 _ ratio= Float.parseFloat(size);146 _scale = Float.parseFloat(size); 133 147 _scaleType = RATIO; 134 _scale = _ratio;135 148 } else if (size.length() > 0) { 136 149 // this is an absolute width 137 _width = Integer.parseInt(size);150 int width = Integer.parseInt(size); 138 151 _scaleType = WIDTH; 139 _scale = _width / (_image.getWidth(null) * 1.0f);152 setWidth(width); 140 153 } 141 154 } catch (Exception e) { 142 size = "" + _image.getWidth(null); 143 _source.setText("@f " + size); 144 FrameGraphics.ErrorMessage("Invalid argument for image tag"); 155 _scale = 1F; 145 156 } 146 157 } … … 148 159 public void setStartCrop(int x, int y) { 149 160 _cropStart = new Point(x - getX(), y - getY()); 150 _cropOrigin = new Point(getX(), getY());151 161 } 152 162 … … 155 165 } 156 166 167 public Point getTopLeftCrop() { 168 return new Point(Math.min(_cropStart.x, _cropEnd.x), Math.min( 169 _cropStart.y, _cropEnd.y)); 170 } 171 172 public Point getBottomRightCrop() { 173 return new Point(Math.max(_cropStart.x, _cropEnd.x), Math.max( 174 _cropStart.y, _cropEnd.y)); 175 } 176 157 177 public void setShowCrop(boolean value) { 158 178 _showCropping = value; 159 179 } 160 180 161 public int getCroppedSize() {181 public boolean isCropTooSmall() { 162 182 if (_cropStart == null || _cropEnd == null) 163 return 0; 164 165 int diff = (_cropEnd.x - _cropStart.x); 166 diff *= (_cropEnd.y - _cropStart.y); 167 return diff; 183 return true; 184 185 int cropWidth = Math.abs(_cropEnd.x - _cropStart.x); 186 int cropHeight = Math.abs(_cropEnd.y - _cropStart.y); 187 188 return cropWidth < MINIMUM_WIDTH || cropHeight < MINIMUM_WIDTH; 168 189 } 169 190 … … 181 202 182 203 if (_cropStart == null || _cropEnd == null) { 183 int width = _image.getWidth(null); 184 int height = _image.getHeight(null); 185 186 width *= _scale; 187 height *= _scale; 204 int width = getWidth(); 205 int height = getHeight(); 188 206 189 207 int xdiff = -getLeftMargin(); 190 208 191 209 // extra pixel around the image so the highlighting is visible 192 _poly.addPoint(_source.getX() + 1 + xdiff, _source.getY() - 1);210 _poly.addPoint(_source.getX() + 1 + xdiff, _source.getY() - 1); 193 211 _poly.addPoint(_source.getX() + width, _source.getY() - 1); 194 212 _poly.addPoint(_source.getX() + width, _source.getY() + height); 195 _poly.addPoint(_source.getX() + 1 + xdiff, _source.getY() + height);213 _poly.addPoint(_source.getX() + 1 + xdiff, _source.getY() + height); 196 214 } else { 197 Rectangle clip = new Rectangle(_source.getX() + _cropStart.x 198 + _cropOrigin.x, _source.getY() + _cropStart.y 199 + _cropOrigin.y, _cropEnd.x - _cropStart.x, _cropEnd.y 200 - _cropStart.y).getBounds(); 215 Point topLeft = getTopLeftCrop(); 216 Point bottomRight = getBottomRightCrop(); 217 Rectangle clip = new Rectangle(topLeft.x + _source.getX(), 218 topLeft.y + _source.getY(), bottomRight.x - topLeft.x, 219 bottomRight.y - topLeft.y).getBounds(); 201 220 _poly.addPoint((int) clip.getMinX() - 1, (int) clip.getMinY() - 1); 202 _poly.addPoint((int) clip.getMinX() - 1, (int) clip.getMaxY() + 1);203 _poly.addPoint((int) clip.getMaxX() + 1, (int) clip.getMaxY() + 1);204 _poly.addPoint((int) clip.getMaxX() + 1, (int) clip.getMinY() - 1);221 _poly.addPoint((int) clip.getMinX() - 1, (int) clip.getMaxY()); 222 _poly.addPoint((int) clip.getMaxX(), (int) clip.getMaxY()); 223 _poly.addPoint((int) clip.getMaxX(), (int) clip.getMinY() - 1); 205 224 206 225 } … … 282 301 283 302 @Override 303 public void setWidth(int width) { 304 _scale = width * 1F / (_end.x - _start.x); 305 } 306 307 /** 308 * Gets the width with which the picture is displayed on the screen. 309 */ 310 @Override 311 public int getWidth() { 312 return Math.round((_end.x - _start.x) * _scale); 313 } 314 315 /** 316 * Gets the height with which the picture is displayed on the screen. 317 */ 318 public int getHeight() { 319 return Math.round((_end.y - _start.y) * _scale); 320 } 321 322 @Override 284 323 public void paint(Graphics2D g) { 285 324 if (_image == null) 286 325 return; 287 326 288 int width = _image.getWidth(null); 289 int height = _image.getHeight(null); 290 291 width *= _scale; 292 height *= _scale; 327 int width = getWidth(); 328 int height = getHeight(); 293 329 294 330 paintLink(g); 295 331 296 i f (isHighlighted()) {297 g.setColor(getHighlightColor());298 g.drawPolygon(getPolygon());299 }332 int dX1 = _source.getX(); 333 int dY1 = _source.getY(); 334 int dX2 = _source.getX() + width; 335 int dY2 = _source.getY() + height; 300 336 301 337 // if we are showing the cropping, then show the original as transparent 302 if (_showCropping && _cropStart != null && _cropEnd != null) {338 if (_showCropping && !isCropTooSmall()) { 303 339 // show the full image as transparent 304 340 float alpha = .5f; 305 341 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 306 342 alpha)); 307 g.drawImage(_image, _source.getX(), _source.getY(), width, height,308 _ imageObserver);343 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x, 344 _end.y, _imageObserver); 309 345 310 346 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 311 347 1.0f)); 312 348 // show the cropped area normally 313 Shape clip = new Rectangle(_source.getX() + _cropStart.x, _source314 .getY()315 + _cropStart.y, _cropEnd.x - _cropStart.x, _cropEnd.y316 - _cropStart.y);349 Point topLeft = getTopLeftCrop(); 350 Point bottomRight = getBottomRightCrop(); 351 Shape clip = new Rectangle(dX1 + topLeft.x, dY1 + topLeft.y, 352 bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); 317 353 g.setColor(getPaintHighlightColor()); 318 354 g.draw(clip); 319 355 g.setClip(clip); 320 356 321 g.drawImage(_image, _source.getX(), _source.getY(), width, height,322 _ imageObserver);357 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x, 358 _end.y, _imageObserver); 323 359 g.draw(clip); 324 360 // if the image is cropped, but we are not showing the cropping 325 } else if (_cropStart != null && _cropEnd != null) {326 Shape clip = new Rectangle(_source.getX() + _cropStart.x327 + _cropOrigin.x, _source.getY() + _cropStart.y328 + _cropOrigin.y, _cropEnd.x - _cropStart.x, _cropEnd.y329 - _cropStart.y);330 g.setClip(clip);331 332 g.drawImage(_image, _source.getX(), _source.getY(), width, height,333 _imageObserver);334 335 361 // otherwise, paint normally 336 362 } else { 337 338 g.drawImage(_image, _source.getX(), _source.getY(), width, height, 339 _imageObserver); 363 g.drawImage(_image, dX1, dY1, dX2, dY2, _start.x, _start.y, _end.x, 364 _end.y, _imageObserver); 365 } 366 367 if (isHighlighted()) { 368 g.setColor(getHighlightColor()); 369 g.drawPolygon(getPolygon()); 340 370 } 341 371 } … … 365 395 public Picture copy() { 366 396 Picture p = createPicture(); 397 p._image = _image; 398 p._imageObserver = _imageObserver; 399 p._source = _source.copy(); 367 400 Item.DuplicateItem(this, p); 368 401 369 if (_cropStart != null) 370 p.setStartCrop(_cropStart.x, _cropStart.y); 371 372 if (_cropEnd != null) 373 p.setEndCrop(_cropEnd.x, _cropEnd.y); 402 if (_cropStart != null && _cropEnd != null) { 403 assert (_cropEnd != null); 404 // make the start be the top left 405 // make the end be the bottom right 406 Point topLeft = getTopLeftCrop(); 407 Point bottomRight = getBottomRightCrop(); 408 int startX = Math.round(topLeft.x / _scale) + _start.x; 409 int startY = Math.round(topLeft.y / _scale) + _start.y; 410 int endX = Math.round(bottomRight.x / _scale + _start.x); 411 int endY = Math.round(bottomRight.y / _scale + _start.y); 412 int width = _image.getWidth(null); 413 int height = _image.getHeight(null); 414 // adjust our start and end if the user has dragged outside of the 415 // shape 416 if (endX > width) { 417 endX = width; 418 } 419 if (endY > height) { 420 endY = height; 421 } 422 if (startX < 0) { 423 startX = 0; 424 } 425 if (startY < 0) { 426 startY = 0; 427 } 428 p._start = new Point(startX, startY); 429 p._end = new Point(endX, endY); 430 p.setPosition(topLeft.x + _source.getX(), topLeft.y + _source.getY()); 431 } else { 432 p._start = _start; 433 p._end = _end; 434 } 435 p._scale = _scale; 436 p._scaleType = _scaleType; 437 p._path = _path; 438 p._fileName = _fileName; 439 440 p.updateSource(); 441 p.updatePolygon(); 374 442 375 443 return p; … … 401 469 float oldScale = _scale; 402 470 403 int oldDenom = _denominator;404 int oldNumer = _numerator;405 float oldRatio = _ratio;406 int oldWidth = _width;407 408 471 switch (_scaleType) { 409 case (FRACTION):410 _numerator += diff;411 _scale = (_numerator * 1.0f) / _denominator;412 break;413 472 case (RATIO): 414 _ratio += (diff) * 0.05; 415 _scale = _ratio; 473 _scale += (diff) * 0.05; 416 474 break; 417 475 case (WIDTH): 418 _width += 10 * diff; 419 _scale = _width / (_image.getWidth(null) * 1.0f); 476 int width = getWidth(); 477 width += 10 * diff; 478 setWidth(width); 420 479 break; 421 480 } 422 481 423 // picture must still be at least 10pixels wide424 if ( (_scale * _image.getWidth(null)) <= 10) {482 // picture must still be at least XX pixels wide 483 if (getWidth() <= MINIMUM_WIDTH) { 425 484 _scale = oldScale; 426 427 _denominator = oldDenom; 428 _numerator = oldNumer; 429 _ratio = oldRatio; 430 _width = oldWidth; 431 } 432 433 // update source text item 434 String line = _source.getFirstLine(); 435 String oldString = ""; 436 String newString = ""; 437 switch (_scaleType) { 438 case (FRACTION): 439 oldString = oldNumer + "/" + oldDenom; 440 newString = _numerator + "/" + _denominator; 441 break; 442 case (RATIO): 443 DecimalFormat format = new DecimalFormat("0.00"); 444 oldString = format.format(oldRatio); 445 newString = format.format(_ratio); 446 break; 447 case (WIDTH): 448 oldString = "" + oldWidth; 449 newString = "" + _width; 450 break; 451 } 452 if (line.contains(oldString)) { 453 line = line.replace(oldString, newString); 454 } else { 455 line += " " + newString; 456 } 457 458 _source.setText(line); 485 } 486 487 updateSource(); 459 488 updatePolygon(); 460 489 } … … 495 524 Logger.Log(e); 496 525 _image = null; 526 return false; 497 527 } 498 528 } … … 524 554 return _source.getActionMark(); 525 555 } 556 557 @Override 558 public String getName() { 559 return _fileName; 560 } 561 562 protected String getTagText() { 563 return "@i: " + _fileName + " "; 564 } 565 566 /** 567 * Updates the source text for this item to match the current size of the 568 * image. 569 * 570 */ 571 private void updateSource() { 572 StringBuffer newText = new StringBuffer(getTagText()); 573 574 switch (_scaleType) { 575 case (RATIO): 576 DecimalFormat format = new DecimalFormat("0.00"); 577 newText.append(format.format(_scale)); 578 break; 579 case (WIDTH): 580 newText.append(getWidth()); 581 break; 582 } 583 584 // If the image is cropped add the position for the start and finish of 585 // the crop to the soure text 586 if (_start.x > 0 || _start.y > 0 || _end.x < _image.getWidth(null) 587 || _end.y < _image.getHeight(null)) { 588 newText.append(" ").append(_start.x).append(" ").append(_start.y); 589 newText.append(" ").append(_end.x).append(" ").append(_end.y); 590 } 591 592 _source.setText(newText.toString()); 593 } 526 594 } -
trunk/src/org/expeditee/items/Text.java
r78 r80 3 3 import java.awt.BasicStroke; 4 4 import java.awt.Color; 5 import java.awt.Dimension; 5 6 import java.awt.Font; 6 7 import java.awt.Graphics2D; … … 316 317 if (ch != '\t') 317 318 return insertText("" + ch, mouseX, mouseY); 318 return insertText(" " + ch, mouseX, mouseY); 319 // return new Point(mouseX, mouseY); 319 320 return insertText(" " + ch, mouseX, mouseY); 321 } 322 323 /** 324 * @param index 325 * @return 326 */ 327 private char getNextBullet(char bullet) { 328 switch (bullet) { 329 case '*': 330 return '>'; 331 case '>': 332 return '+'; 333 case '+': 334 return 'o'; 335 case 'o': 336 return '*'; 337 } 338 return bullet; 339 } 340 341 private char getPreviousBullet(char bullet) { 342 switch (bullet) { 343 case '*': 344 return 'o'; 345 case '>': 346 return '*'; 347 case '+': 348 return '>'; 349 case 'o': 350 return '+'; 351 } 352 return bullet; 320 353 } 321 354 … … 449 482 // if there is no text yet 450 483 if (_text == null || _text.length() == 0) { 451 if (text.equals("@")) {452 453 }454 455 484 _text = new StringBuffer().append(text); 456 485 // create the linebreaker and layouts 457 486 rebuild(true); 458 459 current = _textLayouts.get( _textLayouts.size() - 1);487 assert (_textLayouts.size() == 1); 488 current = _textLayouts.get(0); 460 489 hit = current.getNextRightHit(0); 461 490 line = 0; … … 475 504 pos++; 476 505 477 // compensate for newline character478 // if(line > 0 && hit.getInsertionIndex() == 0)479 // if(pos < (_text.length() - 1) && _text.charAt(pos) == '\n')480 // pos++;481 482 506 // if this is a backspace key 483 507 if (text.charAt(0) == KeyEvent.VK_BACK_SPACE) { 484 508 if (pos > 0) { 485 _text.delete(pos - 1, pos); 486 487 if (_text.length() > 0) { 488 AttributedString inserting = new AttributedString(_text 489 .toString()); 490 inserting.addAttribute(TextAttribute.FONT, 491 getPaintFont()); 492 _lineBreaker.deleteChar(inserting.getIterator(), 493 pos - 1); 494 } 509 deleteChar(pos - 1, false); 495 510 496 511 pos--; … … 499 514 } else if (text.charAt(0) == KeyEvent.VK_DELETE) { 500 515 if (pos < _text.length()) { 501 _text.delete(pos, pos + 1); 502 503 if (_text.length() > 0) { 504 AttributedString inserting = new AttributedString(_text 505 .toString()); 506 inserting.addAttribute(TextAttribute.FONT, 507 getPaintFont()); 508 _lineBreaker.deleteChar(inserting.getIterator(), pos); 516 deleteChar(pos, false); 517 } 518 // this is a tab 519 } else if (text.charAt(0) == KeyEvent.VK_TAB) { 520 // Text length greater than 1 signals a backwards tab 521 if (text.length() > 1) { 522 // Find the first non space char to see if its a bullet 523 int index = 0; 524 for (index = 0; index < _text.length(); index++) { 525 if (!Character.isSpaceChar(_text.charAt(index))) 526 break; 509 527 } 528 // Check if there is a space after the bullet 529 if (index < _text.length() - 1 && _text.charAt(index + 1) == ' ') { 530 // Change the bullet 531 _text.setCharAt(index, getPreviousBullet(_text.charAt(index))); 532 } 533 // Remove the spacing at the start 534 for (int i = 0; i < TAB_STRING.length(); i++) { 535 if (_text.length() > 0 && Character.isSpaceChar(_text.charAt(0))){ 536 deleteChar(0, false); 537 pos--; 538 } else 539 break; 540 } 541 _lineBreaker = null; 542 } else { 543 // / Find the first non space char to see if its a bullet 544 int index = 0; 545 for (index = 0; index < _text.length(); index++) { 546 if (!Character.isSpaceChar(_text.charAt(index))) 547 break; 548 } 549 // Check if there is a space after the bullet 550 if (index < _text.length() - 1 551 && _text.charAt(index + 1) == ' ') { 552 char nextBullet = getNextBullet(_text.charAt(index)); 553 // Change the bullet 554 _text.setCharAt(index, nextBullet); 555 } 556 // Insert the spacing at the start 557 insertString(TAB_STRING, 0); 558 pos += TAB_STRING.length(); 510 559 } 511 560 // this is a normal insert 512 561 } else { 513 _text.insert(pos, text); 514 if (text.length() < 2) { 515 AttributedString inserting = new AttributedString(_text 516 .toString()); 517 inserting.addAttribute(TextAttribute.FONT, getPaintFont()); 518 _lineBreaker.insertChar(inserting.getIterator(), pos); 519 } else 520 _lineBreaker = null; 521 562 insertString(text, pos); 522 563 pos += text.length(); 523 564 } … … 540 581 541 582 current = _textLayouts.get(newLine); 542 pos = pos -_lineOffsets.get(newLine);583 pos -= _lineOffsets.get(newLine); 543 584 544 585 if (newLine == line) { … … 807 848 * @return The String array with one element per line of text in this Item. 808 849 */ 809 public List<String> getText () {850 public List<String> getTextList() { 810 851 if (_text == null) 811 852 return null; … … 830 871 } 831 872 832 public String getText NoList() {873 public String getText() { 833 874 return _text.toString(); 834 875 } … … 1346 1387 @Override 1347 1388 public void setSize(int size) { 1348 if (size >= MINIMUM_FONT_SIZE) 1349 setFont(getPaintFont().deriveFont((float) size)); 1389 // Dont want to have size set when duplicating a point which has size 0 1390 if (size < 0) 1391 return; 1392 1393 if (size < MINIMUM_FONT_SIZE) 1394 size = MINIMUM_FONT_SIZE; 1395 setFont(getPaintFont().deriveFont((float) size)); 1350 1396 } 1351 1397 … … 1356 1402 if (isAnnotation()) 1357 1403 return; 1358 1359 _text.insert(0, "@"); 1360 1361 if (_lineBreaker != null) { 1362 AttributedString inserting = new AttributedString(_text 1363 .toString()); 1364 inserting.addAttribute(TextAttribute.FONT, getPaintFont()); 1365 _lineBreaker.insertChar(inserting.getIterator(), 0); 1404 if (_text.charAt(0) == '*') { 1405 deleteChar(0, true); 1406 if (_text.length() > 0 && _text.charAt(0) == ' ') 1407 deleteChar(0, true); 1408 } else { 1409 insertString("@", 0); 1366 1410 } 1367 1411 } else { … … 1370 1414 return; 1371 1415 1372 if (_text.length() == 1) { 1416 if (_text.charAt(0) == '@') { 1417 _text.setCharAt(0, ' '); 1418 insertString("*", 0); 1419 } else { 1420 deleteChar(0, true); 1421 } 1422 } 1423 rebuild(false); 1424 } 1425 1426 /** 1427 * 1428 */ 1429 private void insertString(String toInsert, int pos) { 1430 assert (toInsert.length() > 0); 1431 1432 _text.insert(pos, toInsert); 1433 1434 if (toInsert.length() > 1) { 1435 _lineBreaker = null; 1436 } 1437 1438 if (_lineBreaker != null) { 1439 AttributedString inserting = new AttributedString(_text.toString()); 1440 inserting.addAttribute(TextAttribute.FONT, getPaintFont()); 1441 _lineBreaker.insertChar(inserting.getIterator(), pos); 1442 } 1443 } 1444 1445 private void deleteChar(int pos, boolean replaceWithDot) { 1446 _text.deleteCharAt(pos); 1447 1448 if (_text.length() == 0) { 1449 if (replaceWithDot) { 1373 1450 // Remove and replace with a dot 1374 1451 FrameKeyboardActions.replaceText(this); 1375 1376 1452 DisplayIO.setCursorPosition(this.getPosition()); 1377 return;1378 1453 } 1379 1380 _text.deleteCharAt(0); 1381 1382 if (_lineBreaker != null) { 1383 AttributedString inserting = new AttributedString(_text 1384 .toString()); 1385 inserting.addAttribute(TextAttribute.FONT, getPaintFont()); 1386 _lineBreaker.deleteChar(inserting.getIterator(), 0); 1387 } 1388 } 1389 rebuild(false); 1454 return; 1455 } 1456 1457 if (_lineBreaker != null) { 1458 AttributedString inserting = new AttributedString(_text.toString()); 1459 inserting.addAttribute(TextAttribute.FONT, getPaintFont()); 1460 _lineBreaker.deleteChar(inserting.getIterator(), pos); 1461 } 1390 1462 } 1391 1463 … … 1418 1490 if (merger.isLineEnd()) { 1419 1491 if (merger instanceof Text) 1420 insertText(((Text) merger).getText NoList(), mouseX, mouseY);1492 insertText(((Text) merger).getText(), mouseX, mouseY); 1421 1493 1422 1494 // Set the position by moving the cursor before calling this … … 1464 1536 } 1465 1537 1538 /** 1539 * Removes the set of characters up to the first space in this text item. 1540 * 1541 * @return the string that was removed. 1542 */ 1466 1543 public String stripFirstWord() { 1467 1544 int firstSpace = _text.toString().indexOf(' '); … … 1475 1552 1476 1553 String firstWord = _text.toString().substring(0, firstSpace); 1477 1478 String text = _text.toString(); 1479 int secondWord; 1480 for (secondWord = firstSpace; secondWord < _text.length(); secondWord++) { 1481 if (!Character.isSpaceChar(text.charAt(secondWord))) { 1482 break; 1483 } 1484 } 1485 setText(_text.toString().substring(secondWord)); 1554 setText(_text.toString().substring(firstSpace).trim()); 1486 1555 1487 1556 return firstWord; … … 1492 1561 1493 1562 if (getParent() != null) 1494 return message + getParent().get FrameName();1563 return message + getParent().getName(); 1495 1564 return message + getDateCreated(); 1496 1565 } … … 1550 1619 1551 1620 public void resetFrameNamePosition() { 1552 setMaxSize(FrameGraphics.getMaxFrameSize()); 1553 setPosition(FrameGraphics.getMaxFrameSize().width - getBoundsWidth(), 1554 getBoundsHeight()); 1555 } 1556 1621 Dimension maxSize = FrameGraphics.getMaxFrameSize(); 1622 setMaxSize(maxSize); 1623 if (maxSize != null) { 1624 setPosition(maxSize.width - getBoundsWidth(), getBoundsHeight()); 1625 } 1626 } 1627 1557 1628 @Override 1558 protected int getLinkYOffset() {1629 protected int getLinkYOffset() { 1559 1630 return Math.round(-(_textLayouts.get(0).getAscent() / 2)); 1560 1631 } 1632 1633 @Override 1634 public String getName() { 1635 return getFirstLine(); 1636 } 1637 1638 public static final String TAB_STRING = " "; 1639 1640 public Point insertTab(char ch, int mouseX, int mouseY) { 1641 return insertText("" + ch, mouseX, mouseY); 1642 } 1643 1644 public Point removeTab(char ch, int mouseX, int mouseY) { 1645 // Insert a space as a flag that it is a backwards tab 1646 return insertText(ch + " ", mouseX, mouseY); 1647 } 1561 1648 } -
trunk/src/org/expeditee/simple/Pointers.java
r4 r80 4 4 5 5 private static final String[] prefixes = new String[] { 6 SPointer.itemPrefix, SPointer.framePrefix, SPointer.filePrefix }; 6 SPointer.itemPrefix, SPointer.framePrefix, SPointer.filePrefix, 7 SPointer.associationPrefix }; 7 8 8 9 public static boolean isPointer(String varName) { … … 49 50 // if it is an existing variable change the value 50 51 v = getVariable(name); 51 } catch ( Exception e) {52 } catch (VariableNotFoundException e) { 52 53 // If the first variable doesnt exist then add it 53 54 list_.add(new SPointer<T>(name, value)); … … 57 58 v.setValue(value); 58 59 } 60 61 /** 62 * Deletes a variable if it exists. 63 * @param variableName name of the variable to delete 64 */ 65 public void delete(String variableName) { 66 try { 67 list_.remove(getVariable(variableName)); 68 } catch (VariableNotFoundException e) { 69 70 } 71 } 59 72 } -
trunk/src/org/expeditee/simple/Primitives.java
r21 r80 157 157 } 158 158 159 /** 160 * Increments a variable. 161 * @param var the name of the variable to increment 162 * @throws Exception 163 */ 159 164 public void add(String var) throws Exception { 160 165 setValue(var, new SReal(getVariable(var).doubleValue() + 1)); 161 166 } 162 167 168 /** 169 * Decrements a variable. 170 * @param var the name of the variable to decrement 171 * @throws Exception 172 */ 163 173 public void subtract(String var) throws Exception { 164 174 setValue(var, new SReal(getVariable(var).doubleValue() - 1)); -
trunk/src/org/expeditee/simple/SCharacter.java
r21 r80 18 18 @Override 19 19 public void parse(String s) { 20 if (s == "")20 if (s.equals("")) 21 21 value_ = '\0'; 22 22 else -
trunk/src/org/expeditee/simple/SInteger.java
r21 r80 26 26 @Override 27 27 public void parse(String s) throws Exception { 28 if (s == "")28 if (s.equals("")) 29 29 value_ = 0L; 30 30 else -
trunk/src/org/expeditee/simple/SPointer.java
r4 r80 10 10 11 11 public static final String filePrefix = SVariable.prefix + "f" 12 + SVariable.separator; 13 14 public static final String associationPrefix = SVariable.prefix + "ap" 12 15 + SVariable.separator; 13 16 -
trunk/src/org/expeditee/simple/SReal.java
r21 r80 22 22 @Override 23 23 public void parse(String s) throws Exception { 24 if (s == "")24 if (s.equals("")) 25 25 value_ = 0.0; 26 26 else -
trunk/src/org/expeditee/simple/SString.java
r4 r80 28 28 @Override 29 29 public Long integerValue() { 30 if (value_ == "")30 if (value_.equals("")) 31 31 return 0L; 32 32 return (long) Double.parseDouble(value_); … … 35 35 @Override 36 36 public Double doubleValue() { 37 if (value_ == "")37 if (value_.equals("")) 38 38 return 0.0; 39 39 return Double.parseDouble(value_); -
trunk/src/org/expeditee/simple/Variables.java
r4 r80 27 27 } 28 28 29 public T getVariable(String name) throws Exception {29 public T getVariable(String name) throws VariableNotFoundException { 30 30 for (T v : list_) { 31 31 if (v.getName().equalsIgnoreCase(name)) { -
trunk/src/org/expeditee/stats/SessionStats.java
r72 r80 82 82 private static int _BackspaceCount; 83 83 84 private static Date _FrameAccessDarkTime = new Date(); 85 84 86 public static String getCurrentStats() { 85 87 StringBuffer stats = getSessionDateTime(); … … 134 136 private static String getFrameStats(boolean newline) { 135 137 StringBuffer stats = new StringBuffer(); 136 appendStat(stats, "FramesAccessed", _AccessedFrames, newline, false, DEFAULT_VALUE_WIDTH, 137 DEFAULT_RATE_WIDTH); 138 appendStat(stats, "FramesEdited", _SavedFrames, newline, false, DEFAULT_VALUE_WIDTH, DEFAULT_RATE_WIDTH); 138 appendStat(stats, "FramesAccessed", _AccessedFrames, newline, false, 139 DEFAULT_VALUE_WIDTH, DEFAULT_RATE_WIDTH); 140 appendStat(stats, "FramesEdited", _SavedFrames, newline, false, 141 DEFAULT_VALUE_WIDTH, DEFAULT_RATE_WIDTH); 139 142 return stats.toString(); 140 143 } … … 218 221 219 222 } 220 221 private static String getRate(int value) {223 224 private static String getRate(int value) { 222 225 return "" + Math.round(value * 60 / getMinutesUsed()); 223 226 } 224 227 225 228 private static void appendStat(StringBuffer stats, String name, int value) { 226 appendStat(stats, name, value, true, false, DEFAULT_VALUE_WIDTH, DEFAULT_RATE_WIDTH); 229 appendStat(stats, name, value, true, false, DEFAULT_VALUE_WIDTH, 230 DEFAULT_RATE_WIDTH); 227 231 } 228 232 … … 254 258 _FrameEvents.clear(); 255 259 _FrameAccessTime = new Date(); 260 _FrameAccessDarkTime = (Time) _DarkTime.clone(); 256 261 } 257 262 } … … 303 308 public static String getFrameEventList() { 304 309 StringBuilder eventList = new StringBuilder(); 310 // First put on the session and darkTime 311 Time darkTime = new Time(_DarkTime.getTime() 312 - _FrameAccessDarkTime.getTime()); 313 Time activeTime = new Time((new Date()).getTime() 314 - _FrameAccessTime.getTime() - darkTime.getTime()); 315 eventList.append("ActiveTime:").append( 316 Logger.EasyDateFormat("KK:mm:ss", activeTime)).append('\n'); 317 eventList.append("DarkTime:").append( 318 Logger.EasyDateFormat("KK:mm:ss", darkTime)).append('\n'); 305 319 for (String s : _FrameEvents) 306 eventList.append(s +'\n');320 eventList.append(s).append('\n'); 307 321 if (eventList.length() > 0) 308 322 eventList.deleteCharAt(eventList.length() - 1); … … 382 396 int maxWidthValue = ("" + max).length(); 383 397 int maxWidthRate = (getRate(max)).length(); 384 398 385 399 for (int i = 0; i < STAT_TYPES; i++) { 386 400 int total = 0; … … 398 412 // statType > 1 399 413 if (nonZeroItems > 1) 400 appendStat(stats, "Total" + statName, total, true, false, maxWidthValue , maxWidthRate); 414 appendStat(stats, "Total" + statName, total, true, false, 415 maxWidthValue, maxWidthRate); 401 416 } 402 417 stats.deleteCharAt(stats.length() - 1); … … 412 427 String upperBound = getFormattedTime(EVENT_INTERVALS[i]); 413 428 appendStat(stats, "<" + upperBound, _EventTimes[i], true, false, 414 maxWidthEvents, maxWidthRate);429 maxWidthEvents, maxWidthRate); 415 430 } 416 431 int lastIndex = EVENT_INTERVALS.length - 1; 417 432 appendStat(stats, "+" 418 433 + getFormattedTime(EVENT_INTERVALS[lastIndex - 1]), 419 _EventTimes[lastIndex], false, false, maxWidthEvents,maxWidthRate); 434 _EventTimes[lastIndex], false, false, maxWidthEvents, 435 maxWidthRate); 420 436 return stats.toString(); 421 437 } … … 424 440 * Gets the highest number in the list of numbers. 425 441 * 426 * @param nums list of numbers 442 * @param nums 443 * list of numbers 427 444 * @return highest number in the list 428 445 */
Note:
See TracChangeset
for help on using the changeset viewer.