Ignore:
Timestamp:
07/10/08 15:50:20 (16 years ago)
Author:
ra33
Message:

Turned search actions into search agents so they are run on a different thread

Location:
trunk/src/org/expeditee/agents
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/Agent.java

    r4 r133  
    22
    33import org.expeditee.gui.Frame;
     4import org.expeditee.items.Item;
    45
    56/**
     
    2021         * @param toInit
    2122         *            The Frame that has any parameters that need to be set before
    22          *            processing begins. Typically this is the Frame the Item that
    23          *            invoked this Agent is on.
     23         *            processing begins. It is also the first frame for the agent.
     24         * @param launcher
     25         *            The item that was clicked on to launch this agent.
    2426         * @return True if the initialisation executed correctly, False if an error
    2527         *         occured.
    2628         */
    27         public boolean initialise(Frame toInit);
    28 
    29         /**
    30          * Sets the first Frame to process to the given Frame using any settings
    31          * previously set by a call to initialise(). Note that Tree based Agents
    32          * will use this Frame as the start Frame of the tree, and will then be
    33          * responsible for traversing the tree themselves.
    34          *
    35          * @param toProcess
    36          *            The Frame apply this Agent to, or the root of the Tree for
    37          *            Tree-based Agents.
    38          */
    39         public void setStartFrame(Frame start);
     29        public boolean initialise(Frame toInit, Item launcher);
    4030
    4131        /**
  • trunk/src/org/expeditee/agents/CopyTree.java

    r121 r133  
    3131
    3232        @Override
    33         public boolean initialise(Frame init) {
     33        public boolean initialise(Frame init, Item launcher) {
    3434                _nameFrom = init.getFramesetName().toLowerCase();
    3535
     
    5656                }
    5757
    58                 return super.initialise(init);
     58                return super.initialise(init, launcher);
    5959        }
    6060
  • trunk/src/org/expeditee/agents/DefaultAgent.java

    r121 r133  
    44import org.expeditee.gui.MessageBay;
    55import org.expeditee.gui.TimeKeeper;
     6import org.expeditee.items.Item;
    67import org.expeditee.stats.SessionStats;
    78
     
    1718public abstract class DefaultAgent implements Agent {
    1819        public static final String CLIPBOARD = "Clipboard";
    19        
     20
    2021        protected long _timeRemaining = 0;
    2122
    2223        // The shortest delay between frames
    2324        public static final long TIMER_RESOLUTION = 10;
     25
     26        protected Item _clicked = null;
    2427
    2528        protected Frame _start = null;
     
    8083         * @param start
    8184         */
    82         public boolean initialise(Frame init) {
     85        public boolean initialise(Frame init, Item launcher) {
     86                _start = init;
     87                _clicked = launcher;
    8388                message("Starting " + this.getClass().getSimpleName() + "...");
    8489                _timer = new TimeKeeper();
     
    8691        }
    8792
    88         public void setStartFrame(Frame start) {
    89                 _start = start;
    90         }
    91 
    9293        public void run() {
    93                 // init is now called by Actions.java
    94                 /*
    95                  * if(!initialise(_start)){ MessageBay.errorMessage("Error
    96                  * initialising agent."); _running = false; return; }
    97                  */
    98 
    9994                SessionStats.setEnabled(false);
    100                 _start.change();
     95                if (_start != null)
     96                        _start.change();
    10197                _end = process(_start);
    10298
  • trunk/src/org/expeditee/agents/DisplayTree.java

    r121 r133  
    3333
    3434        @Override
    35         public boolean initialise(Frame start) {
     35        public boolean initialise(Frame start, Item launcher) {
    3636
    3737                // push current frame on to back-stack
    3838                DisplayIO.addToBack(start);
    3939
    40                 return super.initialise(start);
     40                return super.initialise(start, launcher);
    4141        }
    4242
  • trunk/src/org/expeditee/agents/Format.java

    r80 r133  
    108108                        int maxX = 0;
    109109                        int maxY = 0;
    110                         for (Item item : list) {
    111                                 maxX = Math.max(maxX, item.getX() + item.getBoundsWidth());
    112                                 maxY = Math.max(maxY, item.getY() + item.getBoundsHeight());
     110                        for (Item it : list) {
     111                                maxX = Math.max(maxX, it.getX() + it.getBoundsWidth());
     112                                maxY = Math.max(maxY, it.getY() + it.getBoundsHeight());
    113113                        }
    114114
    115115                        int xCheck = maxX;
    116                         for (Item item : columns.get(i + 1))
     116                        for (Item it : columns.get(i + 1))
    117117                                xCheck = Math.max(xCheck, maxX
    118                                                 + /* item.getX() + */item.getBoundsWidth());
     118                                                + /* item.getX() + */it.getBoundsWidth());
    119119
    120120                        if (xCheck < FrameGraphics.getMaxSize().width) {
     
    123123                                        columnHeads.get(i + 1).setX(maxX);
    124124
    125                                 for (Item item : columns.get(i + 1))
    126                                         if (item.getX() < maxX && item.getY() < maxY)
    127                                                 item.setX(maxX);
     125                                for (Item it : columns.get(i + 1))
     126                                        if (it.getX() < maxX && it.getY() < maxY)
     127                                                it.setX(maxX);
    128128                        }
    129129
  • trunk/src/org/expeditee/agents/WriteTree.java

    r121 r133  
    1010import org.expeditee.io.Logger;
    1111import org.expeditee.io.TreeWriter;
     12import org.expeditee.items.Item;
    1213
    1314public class WriteTree extends DefaultAgent {
     
    6566        @SuppressWarnings("unchecked")
    6667        @Override
    67         public boolean initialise(Frame start) {
     68        public boolean initialise(Frame start, Item launcher) {
    6869                if (_outFile == null)
    6970                        _outFile = start.getExportFileName();
     
    123124                }
    124125
    125                 return super.initialise(start);
     126                return super.initialise(start, launcher);
    126127        }
    127128
Note: See TracChangeset for help on using the changeset viewer.