Debian Codegraph @

src/uk/me/parabola/imgfmt/app/mdr/Mdr4.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009.
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.mdr;
14
15 import java.util.ArrayList;
16 import java.util.HashSet;
17 import java.util.List;
18 import java.util.Set;
19
20 import uk.me.parabola.imgfmt.app.ImgFileWriter;
21
22 /**
23 * POI types. A simple list of the types that are used?
24 * If you don't have this section, then the ability to select POI categories
25 * goes away.
26 *
27 * @author Steve Ratcliffe
28 */
29 public class Mdr4 extends MdrSection implements HasHeaderFlags {
30 private final Set<Mdr4Record> poiTypes = new HashSet<>();
31
32 public Mdr4(MdrConfig config) {
33 setConfig(config);
34 }
35
36
37 public void writeSectData(ImgFileWriter writer) {
38 List<Mdr4Record> list = new ArrayList<>(poiTypes);
39 list.sort(null);
40
41 for (Mdr4Record r : list) {
42 writer.put1u(r.getType());
43 writer.put1u(r.getUnknown());
44 writer.put1u(r.getSubtype());
45 }
46 }
47
48 public int getItemSize() {
49 return 3;
50 }
51
52 public void addType(int type) {
53 poiTypes.add(new Mdr4Record((type >> 8) & 0xff, type & 0xff));
54 }
55
56 /**
57 * The number of records in this section.
58 *
59 * @return The number of items in the section.
60 */
61 protected int numberOfItems() {
62 return poiTypes.size();
63 }
64
65
66 public int getExtraValue() {
67 return 0x00;
68 }
69 }