Changeset 296
- Timestamp:
- 09/09/08 12:12:25 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r294 r296 13 13 import java.util.LinkedList; 14 14 import java.util.List; 15 import java.util.Set; 15 16 import java.util.jar.JarFile; 16 17 import java.util.zip.ZipEntry; … … 63 64 private static HashMap<String, String> _Fonts = new HashMap<String, String>(); 64 65 65 // maps lower case JAG class names to capitalized JAG names66 // maps lower case JAG class names to capitalized JAG full class names 66 67 private static HashMap<String, String> _JAGs = new HashMap<String, String>(); 67 68 … … 207 208 String name = classes[i].getSimpleName(); 208 209 // maps lower case name to correct capitalised name 209 _JAGs.put(name.toLowerCase(), name);210 _JAGs.put(name.toLowerCase(), classes[i].getName()); 210 211 } 211 212 … … 254 255 255 256 /** 257 * Temporary, if a plugin system is devised then this would porbably become redundant. 258 * For now this allows external agents to be included. 259 * 260 * @param fullClassNames 261 * A set of full class names, that is, the class package and name. For example" 262 * "org.myplugin.agents.SerializedSearch" 263 * 264 * @return 265 * A collection of classes their were omitted because either there was a name clash 266 * with existing agents or did not exist. 267 * i.e. is completely successful this will be empty. Never null. 268 * 269 * @throws NullPointerException 270 * If fullClassNames is null. 271 * 272 */ 273 public static Collection<String> addAgents(Set<String> fullClassNames) { 274 if (fullClassNames == null) throw new NullPointerException("fullClassNames"); 275 276 List<String> omittedAgents = new LinkedList<String>(); 277 278 for (String fullName : fullClassNames) { 279 280 if (fullName == null || fullName.length() == 0) continue; 281 282 boolean didAdd = false; 283 284 try { 285 // Does the class even exist? 286 Class c = Class.forName(fullName); 287 288 String name = c.getSimpleName().toLowerCase(); 289 290 if (!_JAGs.containsKey(name)) { 291 292 _JAGs.put(name, fullName); 293 didAdd = true; 294 295 } 296 297 } catch (ClassNotFoundException e) { // Nope it does not exist 298 e.printStackTrace(); 299 } 300 301 if (!didAdd) omittedAgents.add(fullName); 302 303 } 304 305 306 return omittedAgents; 307 } 308 309 /** 256 310 * Loads all the Methods that meet the requirements checked by MethodCheck 257 311 * into the hashtable. … … 413 467 String nameWithCorrectCase = name; 414 468 name = name.toLowerCase(); 469 470 String fullClassName = AGENTS_PACKAGE + name; 415 471 416 472 try { 417 473 // check for stored capitalisation 418 474 if (_JAGs.containsKey(name)) { 419 name = _JAGs.get(name);475 fullClassName = _JAGs.get(name); 420 476 } else if (name.endsWith("tree")) { 421 477 parameters = name.substring(0, name.length() - "tree".length()) 422 478 + " " + parameters; 423 name = "writetree"; 479 fullClassName = AGENTS_PACKAGE + "writetree"; 480 424 481 } else if (name.endsWith("frame")) { 425 482 parameters = name 426 483 .substring(0, name.length() - "frame".length()) 427 484 + " " + parameters; 428 name ="writeframe";485 fullClassName = AGENTS_PACKAGE + "writeframe"; 429 486 } 430 487 431 488 // load the JAG class 432 Class agentClass = Class.forName( AGENTS_PACKAGE + name);489 Class agentClass = Class.forName(fullClassName); 433 490 434 491 // get the constructor for the JAG class … … 491 548 492 549 // create the JAG 493 _Agent = (Agent) con.newInstance(params); 494 550 Agent toLaunch = (Agent) con.newInstance(params); 551 552 LaunchAgent(toLaunch, source, clicked); 553 554 } catch (ClassNotFoundException cnf) { 555 _Agent = null; 556 throw new RuntimeException(nameWithCorrectCase 557 + "' is not an action or agent."); 558 } 559 } 560 561 /** 562 * Launches an agent from a aleady instantiated object. 563 * 564 * @param agent 565 * The agent to launch. Must not be null. 566 * 567 * @param source 568 * The calling frame that launched it. Must not be null. 569 * 570 * @param itemParam 571 * The item paremeter for the agent. Must not be null. 572 * 573 * @throws NullPointerException 574 * if any of the arguments are null. 575 */ 576 public static void LaunchAgent( 577 Agent agent, 578 Frame source, 579 Item itemParam) { 580 581 if (agent == null) throw new NullPointerException("agent"); 582 if (source == null) throw new NullPointerException("source"); 583 if (itemParam == null) throw new NullPointerException("itemParam"); 584 585 String nameWithCorrectCase = agent.getClass().getSimpleName(); 586 587 try { 588 589 590 // create the JAG 591 _Agent = agent; 592 495 593 Thread t = new Thread(_Agent); 496 594 t.setPriority(Thread.MIN_PRIORITY); 497 595 498 Item itemParam = clicked;499 596 if (FreeItems.textOnlyAttachedToCursor()) { 500 597 itemParam = FreeItems.getItemAttachedToCursor(); 501 598 } 502 599 503 600 // check for errors during initialisation 504 601 if (!_Agent.initialise(source, itemParam)) { … … 507 604 + nameWithCorrectCase); 508 605 } 509 606 510 607 // save the current frame (if necesssary) 511 608 // TODO make this nicer... ie. make Format an action rather than an 512 609 // agent and save frames only before running agents 513 if (!name .equals("format") && !name.equals("sort")) {610 if (!nameWithCorrectCase.equalsIgnoreCase("format") && !nameWithCorrectCase.equalsIgnoreCase("sort")) { 514 611 FrameUtils.LeavingFrame(source); 515 612 } 516 613 517 614 if (_Agent.hasResultString()) { 518 615 // Just run the agent on this thread... dont run it in the … … 535 632 } 536 633 } 537 } catch (ClassNotFoundException cnf) {538 _Agent = null;539 throw new RuntimeException(nameWithCorrectCase540 + "' is not an action or agent.");541 634 } catch (Exception e) { 542 635 _Agent = null; … … 546 639 } 547 640 FrameGraphics.refresh(false); 548 549 return;550 641 } 551 642 -
trunk/src/org/expeditee/gui/FrameGraphics.java
r286 r296 38 38 39 39 // Final passes to renderering the current frame 40 private static LinkedList<F inalFrameRenderPass> _finalPasses = new LinkedList<FinalFrameRenderPass>();40 private static LinkedList<FrameRenderPass> _frameRenderPasses = new LinkedList<FrameRenderPass>(); 41 41 42 42 // modes … … 307 307 public static void paintFrame(Frame toPaint, Area clip, 308 308 boolean isActualFrame, boolean createVolitile, Graphics2D bg) { 309 310 // Prepare render passes 311 if (isActualFrame) { 312 currentClip = clip; 313 for (FrameRenderPass pass : _frameRenderPasses) { 314 currentClip = pass.paintStarted(currentClip); 315 clip = currentClip; 316 } 317 } 318 309 319 bg.setClip(clip); 310 320 … … 479 489 // Repaint popups / drags... As well as final passes 480 490 if (isActualFrame) { 491 for (FrameRenderPass pass : _frameRenderPasses) { 492 pass.paintPreLayeredPanePass(bg); 493 } 481 494 PopupManager.getInstance().paintLayeredPane(bg, clip); 482 for (F inalFrameRenderPass pass : _finalPasses) {483 pass.paint (bg);495 for (FrameRenderPass pass : _frameRenderPasses) { 496 pass.paintFinalPass(bg); 484 497 } 485 498 } … … 968 981 * If pass is null. 969 982 */ 970 public static void addF inalFrameRenderPass(FinalFrameRenderPass pass) {983 public static void addFrameRenderPass(FrameRenderPass pass) { 971 984 if (pass == null) 972 985 throw new NullPointerException("pass"); 973 986 974 if (!_f inalPasses.contains(pass))975 _f inalPasses.add(pass);987 if (!_frameRenderPasses.contains(pass)) 988 _frameRenderPasses.add(pass); 976 989 } 977 990 … … 986 999 * 987 1000 */ 988 public static void removeF inalFrameRenderPass(FinalFrameRenderPass pass) {989 _f inalPasses.remove(pass);1001 public static void removeFrameRenderPass(FrameRenderPass pass) { 1002 _frameRenderPasses.remove(pass); 990 1003 } 991 1004 … … 1001 1014 * frame painter then it is not garaunteed to be rendered very last. 1002 1015 * 1003 * @see FrameGraphics#addFinalFrameRenderPass(org.expeditee.gui.FrameGraphics.F inalFrameRenderPass)1004 * @see FrameGraphics#removeFinalFrameRenderPass(org.expeditee.gui.FrameGraphics.F inalFrameRenderPass)1016 * @see FrameGraphics#addFinalFrameRenderPass(org.expeditee.gui.FrameGraphics.FrameRenderPass) 1017 * @see FrameGraphics#removeFinalFrameRenderPass(org.expeditee.gui.FrameGraphics.FrameRenderPass) 1005 1018 * 1006 1019 * @author Brook Novak 1007 1020 */ 1008 public interface FinalFrameRenderPass { 1009 void paint(Graphics g); 1021 public interface FrameRenderPass { 1022 1023 /** 1024 * 1025 * @param currentClip 1026 * 1027 * @return 1028 * The clip that the pass should use instead. 1029 * i.e. if there are any effects that cannot invladate prior to paint call. 1030 */ 1031 Area paintStarted(Area currentClip); 1032 1033 void paintFinalPass(Graphics g); 1034 1035 void paintPreLayeredPanePass(Graphics g); 1010 1036 } 1011 1037 -
trunk/src/org/expeditee/items/widgets/InteractiveWidget.java
r294 r296 1261 1261 FrameGraphics.invalidateArea(dirty); 1262 1262 invalidateLink(); 1263 FrameGraphics.refresh(true);1263 //FrameGraphics.refresh(true); 1264 1264 } 1265 1265 … … 1454 1454 } 1455 1455 1456 protected void addDataIfCaseInsensitiveNotExists(String tag) { 1457 if (tag == null) throw new NullPointerException("tag"); 1458 1459 List<String> data = getCurrentRepresentation().getData(); 1460 1461 if (data == null) { 1462 data = new LinkedList<String>(); 1463 } 1464 1465 for (String s : data) { 1466 if (s != null && s.equalsIgnoreCase(tag)) { 1467 return; 1468 } 1469 } 1470 1471 data.add(tag); 1472 getCurrentRepresentation().setData(data); 1473 } 1474 1475 1456 1476 /** 1457 1477 * Updates the data with a given tag. All data is removed that is prefixed … … 1506 1526 } 1507 1527 } 1528 1529 public boolean containsData(String str) { 1530 assert(str != null); 1531 if (getCurrentRepresentation().getData() != null) 1532 return getCurrentRepresentation().getData().contains(str); 1533 return false; 1534 } 1535 1536 public boolean containsDataTrimmedIgnoreCase(String str) { 1537 assert(str != null); 1538 if (getCurrentRepresentation().getData() != null) { 1539 for (String data : getCurrentRepresentation().getData()) { 1540 if (data != null && data.trim().equalsIgnoreCase(str)) { 1541 return true; 1542 } 1543 } 1544 } 1545 1546 return false; 1547 } 1508 1548 1509 1549 /** … … 1555 1595 1556 1596 if (FrameIO.isPositiveInteger(link)) { // relative - convert to 1557 // absolute1597 // absolute 1558 1598 1559 1599 // Get the frameset of this item … … 1577 1617 return null; 1578 1618 } 1579 1580 /** 1581 * Sets the border color for the widget. That is, for the source (so it is 1582 * remembered) and also for all the corners/edges. 1619 1620 /** 1621 * Sets the border color for the widget. 1622 * That is, for the source (so it is remembered) and also for all the 1623 * corners/edges. 1583 1624 * 1584 1625 * @param c 1585 * 1626 * The color to set. 1586 1627 */ 1587 1628 public void setWidgetEdgeColor(Color c) { 1588 for (Item i : _expediteeItems) 1589 i.setColor(c); 1629 for (Item i : _expediteeItems) i.setColor(c); 1590 1630 // Above indirectly invokes setSourceBorderColor accordingly 1591 1631 } 1592 1632 1593 1633 /** 1594 1634 * Sets the thickness of the widget edge. … … 1597 1637 * 1598 1638 * @param thickness 1599 * 1639 * The new thickness to set. 1600 1640 */ 1601 1641 public void setWidgetEdgeThickness(float thickness) { 1602 for (Item i : _expediteeItems) 1603 i.setThickness(thickness); 1604 // Above indirectly invokes setSourceThickness accordingly 1605 } 1606 1607 // TODO: Maybe rename setSource* .. to update* ... These should actually be 1608 // friendly! 1642 for (Item i : _expediteeItems) i.setThickness(thickness); 1643 // Above indirectly invokes setSourceThickness accordingly 1644 } 1645 1646 // TODO: Maybe rename setSource* .. to update* ... These should actually be friendly! 1609 1647 public void setSourceColor(Color c) { 1610 1648 _textRepresentation.setColor(c); … … 1628 1666 1629 1667 protected Point getOrigin() { 1630 return _d1.getPosition(); // BROOK: This flips around ... the origin 1631 // can be any point 1668 return _d1.getPosition(); // BROOK: This flips around ... the origin can be any point 1632 1669 } 1633 1670
Note:
See TracChangeset
for help on using the changeset viewer.