Search in sources :

Example 41 with SyntaxException

use of uk.me.parabola.mkgmap.scan.SyntaxException in project mkgmap by openstreetmap.

the class CommonSection method readColourInfo.

/**
 * Read the colour lines from the XPM format image.
 */
protected ColourInfo readColourInfo(TokenScanner scanner, String header) {
    ColourInfo colourInfo = new ColourInfo();
    parseXpmHeader(scanner, colourInfo, header);
    for (int i = 0; i < colourInfo.getNumberOfColours(); i++) {
        scanner.validateNext("\"");
        int cpp = colourInfo.getCharsPerPixel();
        Token token = scanner.nextRawToken();
        String colourTag = token.getValue();
        while (colourTag.length() < cpp) colourTag += scanner.nextRawToken().getValue();
        colourTag = colourTag.substring(0, cpp);
        scanner.validateNext("c");
        String colour = scanner.nextValue();
        if (colour.charAt(0) == '#') {
            colour = scanner.nextValue();
            colourInfo.addColour(colourTag, new Rgb(colour));
        } else if (colour.equalsIgnoreCase("none")) {
            colourInfo.addTransparent(colourTag);
        } else {
            throw new SyntaxException(scanner, "Unrecognised colour: " + colour);
        }
        scanner.validateNext("\"");
        readExtraColourInfo(scanner, colourInfo);
    }
    return colourInfo;
}
Also used : SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException) Token(uk.me.parabola.mkgmap.scan.Token) Rgb(uk.me.parabola.imgfmt.app.typ.Rgb) ColourInfo(uk.me.parabola.imgfmt.app.typ.ColourInfo)

Example 42 with SyntaxException

use of uk.me.parabola.mkgmap.scan.SyntaxException in project mkgmap by openstreetmap.

the class LineSection method processLine.

public void processLine(TokenScanner scanner, String name, String value) {
    if (commonKey(scanner, current, name, value))
        return;
    if (name.equalsIgnoreCase("UseOrientation")) {
        current.setUseOrientation(value.charAt(0) == 'Y');
    } else if (name.equalsIgnoreCase("LineWidth")) {
        try {
            int ival = Integer.decode(value);
            current.setLineWidth(ival);
        } catch (NumberFormatException e) {
            throw new SyntaxException(scanner, "Bad number for line width: " + value);
        }
    } else if (name.equalsIgnoreCase("BorderWidth")) {
        try {
            int ival = Integer.decode(value);
            current.setBorderWidth(ival);
        } catch (NumberFormatException e) {
            throw new SyntaxException(scanner, "Bad number for line width: " + value);
        }
    } else
        warnUnknown(name);
}
Also used : SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException)

Aggregations

SyntaxException (uk.me.parabola.mkgmap.scan.SyntaxException)42 Token (uk.me.parabola.mkgmap.scan.Token)8 FileNotFoundException (java.io.FileNotFoundException)5 TokenScanner (uk.me.parabola.mkgmap.scan.TokenScanner)5 EqualsOp (uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp)4 Op (uk.me.parabola.mkgmap.osmstyle.eval.Op)4 ValueOp (uk.me.parabola.mkgmap.osmstyle.eval.ValueOp)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NotOp (uk.me.parabola.mkgmap.osmstyle.eval.NotOp)3 IOException (java.io.IOException)2 StringReader (java.io.StringReader)2 Matcher (java.util.regex.Matcher)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)2 BitmapImage (uk.me.parabola.imgfmt.app.typ.BitmapImage)2 ColourInfo (uk.me.parabola.imgfmt.app.typ.ColourInfo)2 TYPFile (uk.me.parabola.imgfmt.app.typ.TYPFile)2 TypData (uk.me.parabola.imgfmt.app.typ.TypData)2 Xpm (uk.me.parabola.imgfmt.app.typ.Xpm)2