Debian Codegraph @

src/uk/me/parabola/imgfmt/app/typ/TypPoint.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2011.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.typ;
14
15 import java.nio.charset.CharsetEncoder;
16
17 import uk.me.parabola.imgfmt.app.ImgFileWriter;
18
19 /**
20 * Represents a POI in the typ file.
21 *
22 * @author Steve Ratcliffe
23 */
24 public class TypPoint extends TypElement {
25 private Xpm nightXpm;
26 private static final byte F_BITMAP = 0x1;
27 private static final byte F_NIGHT_XPM = 0x2;
28 private static final byte F_LABEL = 0x4;
29 private static final byte F_EXTENDED_FONT = 0x8;
30
31 public void write(ImgFileWriter writer, CharsetEncoder encoder) {
32 offset = writer.position();
33
34 byte flags = F_BITMAP;
35
36 if (nightXpm != null)
37 flags |= F_NIGHT_XPM;
38
39 if (!labels.isEmpty())
40 flags |= F_LABEL;
41
42 if (fontStyle != 0 || dayFontColour != null || nightFontColour != null)
43 flags |= F_EXTENDED_FONT;
44
45 writer.put1u(flags);
46
47 // Width and height is the same for day and night images, so it is written once only.
48 ColourInfo colourInfo = xpm.getColourInfo();
49 writer.put1u(colourInfo.getWidth());
50 writer.put1u(colourInfo.getHeight());
51
52 // Day or only image
53 writeImage(writer, xpm);
54
55 if ((flags & F_NIGHT_XPM) != 0)
56 writeImage(writer, nightXpm);
57
58 if ((flags & F_LABEL) != 0)
59 writeLabelBlock(writer, encoder);
60
61 if ((flags & F_EXTENDED_FONT) != 0)
62 writeExtendedFontInfo(writer);
63 }
64
65 public void setNightXpm(Xpm nightXpm) {
66 this.nightXpm = nightXpm;
67 }
68
69 /**
70 * Points have full pixmaps with multiple colours, including 24 full colour images.
71 */
72 public boolean simpleBitmap() {
73 return false;
74 }
75 }