| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.imgfmt.app.lbl; |
| 18 |
|
| 19 |
import uk.me.parabola.imgfmt.app.ImgFileWriter; |
| 20 |
import uk.me.parabola.imgfmt.app.Label; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public class ExitFacility { |
| 28 |
|
| 29 |
private final int index; |
| 30 |
private final Label description; |
| 31 |
private final int type; |
| 32 |
private final int direction; |
| 33 |
private final int facilities; |
| 34 |
private final boolean last; |
| 35 |
|
| 36 |
public ExitFacility(int type, char direction, int facilities, Label description, boolean last, int index) { |
| 37 |
this.type = type; |
| 38 |
this.direction = directionCode(direction); |
| 39 |
this.facilities = facilities; |
| 40 |
this.description = description; |
| 41 |
this.last = last; |
| 42 |
this.index = index; |
| 43 |
} |
| 44 |
|
| 45 |
void write(ImgFileWriter writer) { |
| 46 |
int word = 0; |
| 47 |
word |= description.getOffset(); |
| 48 |
|
| 49 |
if(last) |
| 50 |
word |= 1 << 23; |
| 51 |
word |= type << 24; |
| 52 |
|
| 53 |
word |= direction << 29; |
| 54 |
writer.put4(word); |
| 55 |
writer.put1u(facilities); |
| 56 |
} |
| 57 |
|
| 58 |
public int getIndex() { |
| 59 |
return index; |
| 60 |
} |
| 61 |
|
| 62 |
public boolean getOvernightParking() { |
| 63 |
return false; |
| 64 |
} |
| 65 |
|
| 66 |
private int directionCode(char direction) { |
| 67 |
int code = "NSEWIOB".indexOf(direction); |
| 68 |
if(code < 0) |
| 69 |
code = 7; |
| 70 |
return code; |
| 71 |
} |
| 72 |
} |