Search in sources :

Example 1 with Xpm

use of uk.me.parabola.imgfmt.app.typ.Xpm in project mkgmap by openstreetmap.

the class CommonSection method readXpm.

/**
 * Read an XMP image from the input scanner.
 *
 * Note that this is sometimes used just for colours so need to deal with
 * different cases.
 */
protected Xpm readXpm(TokenScanner scanner, String header, boolean simple) {
    ColourInfo colourInfo = readColourInfo(scanner, header);
    String msg = colourInfo.analyseColours(simple);
    if (msg != null)
        throw new SyntaxException(scanner, msg);
    Xpm xpm = new Xpm();
    xpm.setColourInfo(colourInfo);
    int height = colourInfo.getHeight();
    int width = colourInfo.getWidth();
    if (height > 0 && width > 0) {
        colourInfo.setHasBitmap(true);
        Image image;
        if (colourInfo.getNumberOfColours() == 0)
            image = readTrueImage(scanner, colourInfo);
        else
            image = readImage(scanner, colourInfo);
        xpm.setImage(image);
    }
    hasXpm = true;
    return xpm;
}
Also used : Xpm(uk.me.parabola.imgfmt.app.typ.Xpm) SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException) BitmapImage(uk.me.parabola.imgfmt.app.typ.BitmapImage) TrueImage(uk.me.parabola.imgfmt.app.typ.TrueImage) Image(uk.me.parabola.imgfmt.app.typ.Image) ColourInfo(uk.me.parabola.imgfmt.app.typ.ColourInfo)

Example 2 with Xpm

use of uk.me.parabola.imgfmt.app.typ.Xpm in project mkgmap by openstreetmap.

the class CommonSection method commonKey.

/**
 * Deal with all the keys that are common to the different element types.
 * Most tags are in fact the same for every element.
 *
 * @return True if this routine has processed the tag.
 */
protected boolean commonKey(TokenScanner scanner, TypElement current, String name, String value) {
    if (name.equalsIgnoreCase("Type")) {
        try {
            int ival = Integer.decode(value);
            if (ival >= 0x100) {
                current.setType(ival >>> 8);
                current.setSubType(ival & 0xff);
            } else {
                current.setType(ival & 0xff);
            }
        } catch (NumberFormatException e) {
            throw new SyntaxException(scanner, "Bad number " + value);
        }
    } else if (name.equalsIgnoreCase("SubType")) {
        try {
            int ival = Integer.decode(value);
            current.setSubType(ival);
        } catch (NumberFormatException e) {
            throw new SyntaxException(scanner, "Bad number for sub type " + value);
        }
    } else if (name.toLowerCase().startsWith("string")) {
        try {
            current.addLabel(value);
        } catch (NumberFormatException e) {
            throw new SyntaxException(scanner, "Bad number in " + value);
        }
    } else if (name.equalsIgnoreCase("Xpm")) {
        Xpm xpm = readXpm(scanner, value, current.simpleBitmap());
        current.setXpm(xpm);
    } else if (name.equalsIgnoreCase("FontStyle")) {
        int font = decodeFontStyle(value);
        current.setFontStyle(font);
    } else if (name.equalsIgnoreCase("CustomColor") || name.equals("ExtendedLabels")) {
    // These are just noise, the appropriate flag is set if any feature is used.
    } else if (name.equalsIgnoreCase("DaycustomColor")) {
        current.setDayFontColor(value);
    } else if (name.equalsIgnoreCase("NightcustomColor")) {
        current.setNightCustomColor(value);
    } else if (name.equalsIgnoreCase("Comment")) {
    // a comment that is ignored.
    } else {
        return false;
    }
    return true;
}
Also used : Xpm(uk.me.parabola.imgfmt.app.typ.Xpm) SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException)

Example 3 with Xpm

use of uk.me.parabola.imgfmt.app.typ.Xpm in project mkgmap by openstreetmap.

the class PointSection method processLine.

public void processLine(TokenScanner scanner, String name, String value) {
    if (commonKey(scanner, current, name, value))
        return;
    if (name.equalsIgnoreCase("DayXpm")) {
        Xpm xpm = readXpm(scanner, value, current.simpleBitmap());
        current.setXpm(xpm);
    } else if (name.equalsIgnoreCase("NightXpm")) {
        Xpm xpm = readXpm(scanner, value, current.simpleBitmap());
        current.setNightXpm(xpm);
    } else {
        warnUnknown(name);
    }
}
Also used : Xpm(uk.me.parabola.imgfmt.app.typ.Xpm)

Example 4 with Xpm

use of uk.me.parabola.imgfmt.app.typ.Xpm in project mkgmap by openstreetmap.

the class IconSection method processLine.

public void processLine(TokenScanner scanner, String name, String value) {
    if (name.equalsIgnoreCase("String")) {
        // There is only one string and it doesn't have a language prefix.
        // But if it does we will just ignore it.
        current.addLabel(value);
        return;
    }
    if (commonKey(scanner, current, name, value))
        return;
    if (name.equalsIgnoreCase("IconXpm")) {
        Xpm xpm = readXpm(scanner, value, current.simpleBitmap());
        current.addIcon(xpm);
    } else {
        warnUnknown(name);
    }
}
Also used : Xpm(uk.me.parabola.imgfmt.app.typ.Xpm)

Aggregations

Xpm (uk.me.parabola.imgfmt.app.typ.Xpm)4 SyntaxException (uk.me.parabola.mkgmap.scan.SyntaxException)2 BitmapImage (uk.me.parabola.imgfmt.app.typ.BitmapImage)1 ColourInfo (uk.me.parabola.imgfmt.app.typ.ColourInfo)1 Image (uk.me.parabola.imgfmt.app.typ.Image)1 TrueImage (uk.me.parabola.imgfmt.app.typ.TrueImage)1