Debian Codegraph @

src/uk/me/parabola/imgfmt/app/typ/TypPolygon.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 * Holds the data for a polygon style.
21 *
22 * @author Steve Ratcliffe
23 */
24 public class TypPolygon extends TypElement {
25
26 private static final int F_LABEL = 0x10;
27 private static final int F_EXTENDED = 0x20;
28
29 public void write(ImgFileWriter writer, CharsetEncoder encoder) {
30 offset = writer.position();
31
32 ColourInfo colourInfo = xpm.getColourInfo();
33 int scheme = colourInfo.getColourScheme();
34 if (!labels.isEmpty())
35 scheme |= F_LABEL;
36 if (fontStyle != 0 || dayFontColour != null)
37 scheme |= F_EXTENDED;
38
39 writer.put1u(scheme);
40
41 colourInfo.write(writer);
42 if (xpm.hasImage())
43 xpm.writeImage(writer);
44
45 // The labels have a length byte to show the number of bytes following. There is
46 // also a flag in the length. The strings have a language number proceeding them.
47 // The strings themselves are null terminated.
48 if ((scheme & F_LABEL) != 0)
49 writeLabelBlock(writer, encoder);
50
51 // The extension section hold font style and colour information for the labels.
52 if ((scheme & F_EXTENDED) != 0) {
53 writeExtendedFontInfo(writer);
54 }
55 }
56 }