1 | package org.expeditee.agents;
|
---|
2 |
|
---|
3 | import java.util.Collection;
|
---|
4 |
|
---|
5 | import org.expeditee.gui.Frame;
|
---|
6 | import org.expeditee.gui.FrameGraphics;
|
---|
7 | import org.expeditee.gui.FrameIO;
|
---|
8 |
|
---|
9 | public class SearchFramesetFast extends SearchAgent {
|
---|
10 | private long _firstFrame = 1;
|
---|
11 |
|
---|
12 | private long _maxFrame = Integer.MAX_VALUE;
|
---|
13 |
|
---|
14 | public SearchFramesetFast(long firstFrame, long maxFrame) {
|
---|
15 | _firstFrame = firstFrame;
|
---|
16 | _maxFrame = maxFrame;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public SearchFramesetFast() {
|
---|
20 | super();
|
---|
21 | }
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | protected Frame process(Frame frame) {
|
---|
25 | if(frame == null) {
|
---|
26 | frame = FrameIO.LoadFrame(_startName + '0');
|
---|
27 | }
|
---|
28 | String path = frame.path;
|
---|
29 |
|
---|
30 | int count = FrameIO.getLastNumber(_startName);
|
---|
31 | for (long i = _firstFrame;i <= _maxFrame && i < count; i++) {
|
---|
32 | if (_stop) {
|
---|
33 | break;
|
---|
34 | }
|
---|
35 | String frameName = _startName + i;
|
---|
36 | overwriteMessage("Searching " + frameName);
|
---|
37 | Collection<String> found = FrameIO.searchFrame(frameName, _pattern, path);
|
---|
38 | int size = found == null? 0 :found.size();
|
---|
39 | // If the frame exists
|
---|
40 | if(found != null)
|
---|
41 | _frameCount++;
|
---|
42 | if(size > 0){
|
---|
43 | String repeats = size > 1? ("("+ size+ ")") : "";
|
---|
44 | _results.addText(frameName + repeats, null, frameName, null, false);
|
---|
45 | FrameGraphics.requestRefresh(true);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | _results.save();
|
---|
49 |
|
---|
50 | String resultFrameName = _results.getName();
|
---|
51 | if (_clicked != null)
|
---|
52 | _clicked.setLink(resultFrameName);
|
---|
53 |
|
---|
54 | return _results.getFirstFrame();
|
---|
55 | }
|
---|
56 | }
|
---|