| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.imgfmt.app.trergn; |
| 18 |
|
| 19 |
import uk.me.parabola.imgfmt.app.ImgFileWriter; |
| 20 |
|
| 21 |
import java.util.ArrayList; |
| 22 |
import java.util.Iterator; |
| 23 |
import java.util.List; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class Zoom { |
| 38 |
private final int level; |
| 39 |
private boolean inherited; |
| 40 |
|
| 41 |
private final int resolution; |
| 42 |
|
| 43 |
private final List<Subdivision> subdivs = new ArrayList<>(); |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
Zoom(int zoom, int resolution) { |
| 52 |
this.level = zoom; |
| 53 |
this.resolution = resolution; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
public Iterator<Subdivision> subdivIterator() { |
| 58 |
return subdivs.iterator(); |
| 59 |
} |
| 60 |
|
| 61 |
public void setInherited(boolean inherited) { |
| 62 |
this.inherited = inherited; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
public int getLevel() { |
| 67 |
return level; |
| 68 |
} |
| 69 |
|
| 70 |
public int getResolution() { |
| 71 |
return resolution; |
| 72 |
} |
| 73 |
|
| 74 |
public int getShiftValue() { |
| 75 |
return 24 - resolution; |
| 76 |
} |
| 77 |
|
| 78 |
public void write(ImgFileWriter file) { |
| 79 |
file.put1u((level & 0xf) | (inherited ? 0x80 : 0)); |
| 80 |
file.put1u(resolution); |
| 81 |
file.put2u(subdivs.size()); |
| 82 |
} |
| 83 |
|
| 84 |
public String toString() { |
| 85 |
return "L " + level + ':' + resolution; |
| 86 |
} |
| 87 |
|
| 88 |
void addSubdivision(Subdivision div) { |
| 89 |
subdivs.add(div); |
| 90 |
} |
| 91 |
} |