| 22 | |
| 23 | /* |
| 24 | Class to save out a canvas to a directory of .jpgs |
| 25 | */ |
| 26 | public class Saver { |
| 27 | |
| 28 | private final int numWorkers; |
| 29 | |
| 30 | public final int width; |
| 31 | public final int height; |
| 32 | |
| 33 | private final ExecutorService pool; |
| 34 | |
| 35 | private final String prefix; |
| 36 | |
| 37 | public Saver(int width, int height, int numWorkers, String prefix) { |
| 38 | this.width = width; |
| 39 | this.height = height; |
| 40 | this.numWorkers = numWorkers; |
| 41 | this.prefix = prefix; |
| 42 | |
| 43 | pool = Executors.newCachedThreadPool(); |
| 44 | } |
| 45 | |
| 46 | List<FutureTask<Pair<ByteBuffer, ByteBuffer>>> workers = new ArrayList<>(); |
| 47 | |
| 48 | public int frameNumber = 0; |
| 49 | |
| 50 | public int strobe = 1; |
| 51 | |
| 52 | @HiddenInAutocomplete |
| 53 | boolean on = false; |
| 54 | @HiddenInAutocomplete |
| 55 | boolean drip = false; |
| 56 | |
| 57 | private String lastFilename; |
| 58 | |
| 59 | |
| 60 | @HiddenInAutocomplete |
| 61 | public void setOn(boolean on) { |
| 62 | this.on = on; |
| 63 | drip = false; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * call to start streaming jpgs out to disk |
| 68 | */ |
| 69 | public String start() { |
| 70 | setOn(true); |
| 71 | return "Saving to '" + prefix + "'"; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * call to stop streaming jpgs out to disk |
| 76 | */ |
| 77 | public void stop() { |
| 78 | setOn(false); |
| 79 | } |
| 80 | |
| 81 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected