Search in sources :

Example 1 with StyleInfo

use of uk.me.parabola.mkgmap.reader.osm.StyleInfo in project mkgmap by openstreetmap.

the class StyleImpl method readInfo.

/**
 * Read the info file.  This is just information about the style.
 */
private void readInfo() {
    try {
        Reader br = new BufferedReader(fileLoader.open(FILE_INFO));
        info = new StyleInfo();
        Options opts = new Options(new OptionProcessor() {

            public void processOption(Option opt) {
                String word = opt.getOption();
                String value = opt.getValue();
                if (word.equals("summary"))
                    info.setSummary(value);
                else if (word.equals("version")) {
                    info.setVersion(value);
                } else if (word.equals("base-style")) {
                    info.addBaseStyleName(value);
                } else if (word.equals("description")) {
                    info.setLongDescription(value);
                }
            }
        });
        opts.readOptionFile(br, FILE_INFO);
    } catch (FileNotFoundException e) {
        // optional file..
        log.debug("no info file");
    }
}
Also used : Options(uk.me.parabola.mkgmap.Options) BufferedReader(java.io.BufferedReader) StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Option(uk.me.parabola.mkgmap.Option) OptionProcessor(uk.me.parabola.mkgmap.OptionProcessor)

Example 2 with StyleInfo

use of uk.me.parabola.mkgmap.reader.osm.StyleInfo in project mkgmap by openstreetmap.

the class StyleImplTest method testGetInfo.

@Test
public void testGetInfo() throws FileNotFoundException {
    StyleImpl style = new StyleImpl(STYLE_LOC, "simple");
    printStyle(style);
    StyleInfo info = style.getInfo();
    assertEquals("version", "2.2", info.getVersion());
    assertEquals("version", "A simple test style with just one example of most things", info.getSummary());
    assertEquals("version", "This style is used for testing.", info.getLongDescription());
}
Also used : StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo) Test(org.junit.Test)

Example 3 with StyleInfo

use of uk.me.parabola.mkgmap.reader.osm.StyleInfo in project mkgmap by openstreetmap.

the class StylePrinter method dumpInfo.

private void dumpInfo(Formatter fmt) {
    fmt.format("<<<info>>>\n");
    StyleInfo styleInfo = style.getInfo();
    fmt.format("version %s\n", dumpInfoVal(styleInfo.getVersion()));
    fmt.format("summary %s\n", dumpInfoVal(styleInfo.getSummary()));
    // documentation/testing purposes.
    for (String name : styleInfo.baseStyles()) fmt.format("# base-style %s\n", dumpInfoVal(name));
    fmt.format("description %s\n", dumpInfoVal(styleInfo.getLongDescription()));
}
Also used : StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo)

Example 4 with StyleInfo

use of uk.me.parabola.mkgmap.reader.osm.StyleInfo in project mkgmap by openstreetmap.

the class Main method listStyles.

private void listStyles() {
    String[] names;
    try {
        StyleFileLoader loader = StyleFileLoader.createStyleLoader(styleFile, null);
        names = loader.list();
        loader.close();
    } catch (FileNotFoundException e) {
        log.debug("didn't find style file", e);
        throw new ExitException("Could not list style file " + styleFile);
    }
    Arrays.sort(names);
    System.out.println("The following styles are available:");
    for (String name : names) {
        Style style = readOneStyle(name, false);
        if (style == null)
            continue;
        StyleInfo info = style.getInfo();
        System.out.format("%-15s %6s: %s\n", searchedStyleName, info.getVersion(), info.getSummary());
        if (verbose) {
            for (String s : info.getLongDescription().split("\n")) System.out.printf("\t%s\n", s.trim());
        }
    }
}
Also used : StyleFileLoader(uk.me.parabola.mkgmap.osmstyle.StyleFileLoader) FileNotFoundException(java.io.FileNotFoundException) StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo) Style(uk.me.parabola.mkgmap.reader.osm.Style) ExitException(uk.me.parabola.imgfmt.ExitException)

Aggregations

StyleInfo (uk.me.parabola.mkgmap.reader.osm.StyleInfo)4 FileNotFoundException (java.io.FileNotFoundException)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Test (org.junit.Test)1 ExitException (uk.me.parabola.imgfmt.ExitException)1 Option (uk.me.parabola.mkgmap.Option)1 OptionProcessor (uk.me.parabola.mkgmap.OptionProcessor)1 Options (uk.me.parabola.mkgmap.Options)1 StyleFileLoader (uk.me.parabola.mkgmap.osmstyle.StyleFileLoader)1 Style (uk.me.parabola.mkgmap.reader.osm.Style)1