Ignore:
Timestamp:
07/25/08 09:24:45 (16 years ago)
Author:
ra33
Message:

Added calculate action

File:
1 edited

Legend:

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

    r154 r156  
    2222import org.expeditee.gui.FrameIO;
    2323import org.expeditee.gui.FrameUtils;
     24import org.expeditee.gui.FreeItems;
    2425import org.expeditee.gui.MessageBay;
    2526import org.expeditee.io.Conversion;
     
    3839 * When adding an action to a class in the actions folder the following must be
    3940 * considered:
    40  * <li> If the first parameter is of type Frame or Item they will be called with
    41  * the current frame and the item used to execute the action.</li>
    42  * <li> If the second item is also of type Frame or Item it will be set to the
    43  * current frame or item.</li>
     41 * <li> If the first parameter is of type Frame, the current frame will be
     42 * passed as a parameter.
     43 * <li> If the next param is of type Item the item on the end of the cursor will
     44 * be passed or the item that was clicked to execute the action if nothing is on
     45 * the end of the cursor. current frame or item.</li>
    4446 * <li> If there are multiple overloads for the same method they should be
    4547 * declared in order of the methods with the most parameteres to least
     
    383385         *            The starting Frame that the JAG is being launched on
    384386         */
    385         private static void LaunchAgent(String name, String parameters, Frame source, Item clicked) {
     387        private static void LaunchAgent(String name, String parameters,
     388                        Frame source, Item clicked) {
    386389                // Use the correct case version for printing error messages
    387390                String nameWithCorrectCase = name;
     
    444447                        t.setPriority(Thread.MIN_PRIORITY);
    445448
     449                        Item itemParam = clicked;
     450                        if (FreeItems.textAttachedToCursor()) {
     451                                itemParam = FreeItems.getItemAttachedToCursor();
     452                        }
     453
    446454                        // check for errors during initialisation
    447                         if (!_Agent.initialise(source, clicked)) {
     455                        if (!_Agent.initialise(source, itemParam)) {
    448456                                MessageBay.errorMessage("Error initialising agent: "
    449457                                                + nameWithCorrectCase);
     
    521529                Class[] paramTypes = method.getParameterTypes();
    522530
     531                int paramCount = paramTypes.length;
    523532                // if the method has no parameters
    524                 if (paramTypes.length == 0)
     533                if (paramCount == 0)
    525534                        return new Object[0];
    526535
    527                 Object[] objects = new Object[paramTypes.length];
     536                Object[] objects = new Object[paramCount];
    528537                int ind = 0;
    529538
     
    531540                // or launcher
    532541                // length must be at least one if we are still running
    533                 if (paramTypes[0] == Frame.class) {
    534                         objects[0] = source;
    535                         ind = 1;
    536                 } else if (Item.class.isAssignableFrom(paramTypes[0])) {
    537                         objects[0] = launcher;
    538                         ind = 1;
    539                 }
    540 
    541                 // if the first class was a frame or item, the second class might be the
    542                 // other
    543                 if (paramTypes.length > 1 && objects[0] != null) {
    544                         if (paramTypes[1] == Frame.class) {
    545                                 objects[1] = source;
    546                                 ind = 2;
    547                         } else if (Item.class.isAssignableFrom(paramTypes[1])) {
    548                                 objects[1] = launcher;
    549                                 ind = 2;
    550                         }
     542                if (paramTypes[ind] == Frame.class) {
     543                        objects[ind] = source;
     544                        ind++;
     545                }
     546
     547                if (paramCount > ind && Item.class.isAssignableFrom(paramTypes[ind])) {
     548                        objects[ind] = launcher;
     549                        ind++;
    551550                }
    552551
     
    670669         */
    671670        public static String getCapitalizedFontName(String fontName) {
    672                 //Initialize the fonts if they have not already been loaded
     671                // Initialize the fonts if they have not already been loaded
    673672                initFonts();
    674673                return _Fonts.get(fontName.toLowerCase());
     
    688687                }
    689688        }
    690        
    691         public static HashMap<String, String> getFonts(){
     689
     690        public static HashMap<String, String> getFonts() {
    692691                initFonts();
    693692                return _Fonts;
Note: See TracChangeset for help on using the changeset viewer.