1 | /**
|
---|
2 | * DefaultFramesetWriter.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.io;
|
---|
20 |
|
---|
21 | import java.io.IOException;
|
---|
22 |
|
---|
23 | import org.expeditee.gui.Frame;
|
---|
24 | import org.expeditee.gui.FrameIO;
|
---|
25 | import org.expeditee.gui.MessageBay;
|
---|
26 |
|
---|
27 | public class DefaultFramesetWriter extends DefaultFrameWriter {
|
---|
28 | protected long _firstFrame = 1;
|
---|
29 | protected long _maxFrame = Long.MAX_VALUE;
|
---|
30 |
|
---|
31 | protected DefaultFramesetWriter(long firstFrame, long maxFrame){
|
---|
32 | _firstFrame = firstFrame;
|
---|
33 | _maxFrame = maxFrame;
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | protected void outputFrame(Frame toWrite) throws IOException {
|
---|
38 | String framesetName = toWrite.getFramesetName();
|
---|
39 |
|
---|
40 | _maxFrame = Math.min(_maxFrame, FrameIO.getLastNumber(framesetName));
|
---|
41 |
|
---|
42 | for (long i = _firstFrame; i <= _maxFrame; i++) {
|
---|
43 | if (_stop) {
|
---|
44 | break;
|
---|
45 | }
|
---|
46 | String frameName = framesetName + i;
|
---|
47 | Frame nextFrame = FrameIO.LoadFrame(frameName);
|
---|
48 | if (nextFrame != null) {
|
---|
49 | MessageBay.overwriteMessage("Processing " + frameName);
|
---|
50 | super.outputFrame(nextFrame);
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | protected String finaliseFrame() throws IOException {
|
---|
57 | return "Frameset" + finalise();
|
---|
58 | }
|
---|
59 | }
|
---|