Search in sources :

Example 36 with File

use of com.codename1.io.File in project CodenameOne by codenameone.

the class EditableResources method saveXMLFile.

private void saveXMLFile(File xml, File resourcesDir) throws IOException {
    // disable override for the duration of the save so stuff from the override doesn't
    // get into the main resource file
    File overrideFileBackup = overrideFile;
    EditableResources overrideResourceBackup = overrideResource;
    overrideResource = null;
    overrideFile = null;
    try {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(xml), "UTF-8"));
        String[] resourceNames = getResourceNames();
        Arrays.sort(resourceNames, String.CASE_INSENSITIVE_ORDER);
        bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
        bw.write("<resource majorVersion=\"" + MAJOR_VERSION + "\" minorVersion=\"" + MINOR_VERSION + "\" useXmlUI=\"" + xmlUI + "\">\n");
        for (int iter = 0; iter < resourceNames.length; iter++) {
            String xResourceName = xmlize(resourceNames[iter]);
            // write the magic number
            byte magic = getResourceType(resourceNames[iter]);
            switch(magic) {
                case MAGIC_TIMELINE:
                case MAGIC_ANIMATION_LEGACY:
                case MAGIC_IMAGE_LEGACY:
                case MAGIC_INDEXED_IMAGE_LEGACY:
                    magic = MAGIC_IMAGE;
                    break;
                case MAGIC_THEME_LEGACY:
                    magic = MAGIC_THEME;
                    break;
                case MAGIC_FONT_LEGACY:
                    magic = MAGIC_FONT;
                    break;
            }
            switch(magic) {
                case MAGIC_IMAGE:
                    Object o = getResourceObject(resourceNames[iter]);
                    if (!(o instanceof MultiImage)) {
                        o = null;
                    }
                    bw.write("    <image name=\"" + xResourceName + "\" ");
                    com.codename1.ui.Image image = getImage(resourceNames[iter]);
                    MultiImage mi = (MultiImage) o;
                    int rType = getImageType(image, mi);
                    switch(rType) {
                        // PNG file
                        case 0xf1:
                        // JPEG File
                        case 0xf2:
                            if (image instanceof EncodedImage) {
                                byte[] data = ((EncodedImage) image).getImageData();
                                writeToFile(data, new File(resourcesDir, normalizeFileName(resourceNames[iter])));
                            } else {
                                FileOutputStream fo = new FileOutputStream(new File(resourcesDir, normalizeFileName(resourceNames[iter])));
                                BufferedImage buffer = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
                                buffer.setRGB(0, 0, image.getWidth(), image.getHeight(), image.getRGB(), 0, image.getWidth());
                                ImageIO.write(buffer, "png", fo);
                                fo.close();
                            }
                            break;
                        // SVG
                        case 0xf5:
                        // multiimage with SVG
                        case 0xf7:
                            SVG s = (SVG) image.getSVGDocument();
                            writeToFile(s.getSvgData(), new File(resourcesDir, normalizeFileName(resourceNames[iter])));
                            if (s.getBaseURL() != null && s.getBaseURL().length() > 0) {
                                bw.write("baseUrl=\"" + s.getBaseURL() + "\" ");
                            }
                            bw.write("type=\"svg\" ");
                            break;
                        case 0xF6:
                            File multiImageDir = new File(resourcesDir, normalizeFileName(resourceNames[iter]));
                            multiImageDir.mkdirs();
                            for (int imageIter = 0; imageIter < mi.getDpi().length; imageIter++) {
                                File f = null;
                                switch(mi.getDpi()[imageIter]) {
                                    case Display.DENSITY_4K:
                                        f = new File(multiImageDir, "4k.png");
                                        break;
                                    case Display.DENSITY_2HD:
                                        f = new File(multiImageDir, "2hd.png");
                                        break;
                                    case Display.DENSITY_560:
                                        f = new File(multiImageDir, "560.png");
                                        break;
                                    case Display.DENSITY_HD:
                                        f = new File(multiImageDir, "hd.png");
                                        break;
                                    case Display.DENSITY_VERY_HIGH:
                                        f = new File(multiImageDir, "veryhigh.png");
                                        break;
                                    case Display.DENSITY_HIGH:
                                        f = new File(multiImageDir, "high.png");
                                        break;
                                    case Display.DENSITY_MEDIUM:
                                        f = new File(multiImageDir, "medium.png");
                                        break;
                                    case Display.DENSITY_LOW:
                                        f = new File(multiImageDir, "low.png");
                                        break;
                                    case Display.DENSITY_VERY_LOW:
                                        f = new File(multiImageDir, "verylow.png");
                                        break;
                                }
                                writeToFile(mi.getInternalImages()[imageIter].getImageData(), f);
                            }
                            bw.write("type=\"multi\" ");
                            break;
                        // Timeline
                        case MAGIC_TIMELINE:
                            File timeline = new File(resourcesDir, normalizeFileName(resourceNames[iter]));
                            DataOutputStream timelineOut = new DataOutputStream(new FileOutputStream(timeline));
                            writeTimeline(timelineOut, (Timeline) image);
                            timelineOut.close();
                            bw.write("type=\"timeline\" ");
                            break;
                        // Fail this is the wrong data type
                        default:
                            throw new IOException("Illegal type while creating image: " + Integer.toHexString(rType));
                    }
                    bw.write(" />\n");
                    continue;
                case MAGIC_THEME:
                    Hashtable<String, Object> theme = getTheme(resourceNames[iter]);
                    theme.remove("name");
                    bw.write("    <theme name=\"" + xResourceName + "\">\n");
                    ArrayList<String> setOfKeys = new ArrayList<String>(theme.keySet());
                    Collections.sort(setOfKeys);
                    for (String key : setOfKeys) {
                        if (key.startsWith("@")) {
                            if (key.endsWith("Image")) {
                                bw.write("        <val key=\"" + key + "\" value=\"" + findId(theme.get(key), true) + "\" />\n");
                            } else {
                                bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            }
                            continue;
                        }
                        // if this is a simple numeric value
                        if (key.endsWith("Color")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        if (key.endsWith("align") || key.endsWith("textDecoration")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + ((Number) theme.get(key)).shortValue() + "\" />\n");
                            continue;
                        }
                        // if this is a short numeric value
                        if (key.endsWith("transparency")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        if (key.endsWith("opacity")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        // if this is a padding or margin then we will have the 4 values as bytes
                        if (key.endsWith("padding") || key.endsWith("margin")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        // padding and or margin type
                        if (key.endsWith("Unit")) {
                            byte[] b = (byte[]) theme.get(key);
                            bw.write("        <val key=\"" + key + "\" value=\"" + b[0] + "," + b[1] + "," + b[2] + "," + b[3] + "\" />\n");
                            continue;
                        }
                        if (key.endsWith("border")) {
                            Border border = (Border) theme.get(key);
                            if (border instanceof RoundBorder) {
                                RoundBorder rb = (RoundBorder) border;
                                bw.write("        <border key=\"" + key + "\" type=\"round\" " + "roundBorderColor=\"" + rb.getColor() + "\" " + "opacity=\"" + rb.getOpacity() + "\" " + "strokeColor=\"" + rb.getStrokeColor() + "\" " + "strokeOpacity=\"" + rb.getStrokeOpacity() + "\" " + "strokeThickness=\"" + rb.getStrokeThickness() + "\" " + "strokeMM=\"" + rb.isStrokeMM() + "\" " + "shadowSpread=\"" + rb.getShadowSpread() + "\" " + "shadowOpacity=\"" + rb.getShadowOpacity() + "\" " + "shadowX=\"" + rb.getShadowX() + "\" " + "shadowY=\"" + rb.getShadowY() + "\" " + "shadowBlur=\"" + rb.getShadowBlur() + "\" " + "shadowMM=\"" + rb.isShadowMM() + "\" " + "rectangle=\"" + rb.isRectangle() + "\" />\n");
                                continue;
                            }
                            if (border instanceof CSSBorder) {
                                bw.write("        <border key=\"" + key + "\" type=\"css\" " + "css=\"" + encodeXML(((CSSBorder) border).toCSSString()) + "\"/>\n");
                                continue;
                            }
                            if (border instanceof RoundRectBorder) {
                                RoundRectBorder rb = (RoundRectBorder) border;
                                bw.write("        <border key=\"" + key + "\" type=\"roundRect\" " + "strokeColor=\"" + rb.getStrokeColor() + "\" " + "strokeOpacity=\"" + rb.getStrokeOpacity() + "\" " + "strokeThickness=\"" + rb.getStrokeThickness() + "\" " + "strokeMM=\"" + rb.isStrokeMM() + "\" " + "shadowSpread=\"" + rb.getShadowSpread() + "\" " + "shadowOpacity=\"" + rb.getShadowOpacity() + "\" " + "shadowX=\"" + rb.getShadowX() + "\" " + "shadowY=\"" + rb.getShadowY() + "\" " + "shadowBlur=\"" + rb.getShadowBlur() + "\" " + "topOnlyMode=\"" + rb.isTopOnlyMode() + "\" " + "bottomOnlyMode=\"" + rb.isBottomOnlyMode() + "\" " + "cornerRadius=\"" + rb.getCornerRadius() + "\" " + "bezierCorners=\"" + rb.isBezierCorners() + "\" />\n");
                                continue;
                            }
                            int type = Accessor.getType(border);
                            switch(type) {
                                case BORDER_TYPE_EMPTY:
                                    bw.write("        <border key=\"" + key + "\" type=\"empty\" />\n");
                                    continue;
                                case BORDER_TYPE_LINE:
                                    // use theme colors?
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"line\" millimeters=\"" + Accessor.isMillimeters(border) + "\" thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"line\" millimeters=\"" + Accessor.isMillimeters(border) + "\" thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_UNDERLINE:
                                    // use theme colors?
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"underline\" millimeters=\"" + Accessor.isMillimeters(border) + "\" thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"underline\"  millimeters=\"" + Accessor.isMillimeters(border) + "\" thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_ROUNDED:
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"rounded\" " + "thickness=\"" + Accessor.getThickness(border) + "\" arcW=\"" + Accessor.getArcWidth(border) + "\" arcH=\"" + Accessor.getArcHeight(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"rounded\" " + "thickness=\"" + Accessor.getThickness(border) + "\" arcW=\"" + Accessor.getArcWidth(border) + "\" arcH=\"" + Accessor.getArcHeight(border) + "\" color=\"" + Accessor.getColorA(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_ETCHED_RAISED:
                                    // use theme colors?
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"etchedRaised\" " + "thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"etchedRaised\" " + "thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" colorB=\"" + Accessor.getColorB(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_ETCHED_LOWERED:
                                    // use theme colors?
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"etchedLowered\" " + "thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"etchedLowered\" " + "thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" colorB=\"" + Accessor.getColorB(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_BEVEL_LOWERED:
                                    // use theme colors?
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"bevelLowered\" " + "thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"bevelLowered\" " + "thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" colorB=\"" + Accessor.getColorB(border) + "\" colorC=\"" + Accessor.getColorC(border) + "\" colorD=\"" + Accessor.getColorD(border) + "\" />\n");
                                    }
                                    continue;
                                case BORDER_TYPE_BEVEL_RAISED:
                                    if (Accessor.isThemeColors(border)) {
                                        bw.write("        <border key=\"" + key + "\" type=\"bevelRaised\" " + "thickness=\"" + Accessor.getThickness(border) + "\" />\n");
                                    } else {
                                        bw.write("        <border key=\"" + key + "\" type=\"bevelRaised\" " + "thickness=\"" + Accessor.getThickness(border) + "\" color=\"" + Accessor.getColorA(border) + "\" colorB=\"" + Accessor.getColorB(border) + "\" colorC=\"" + Accessor.getColorC(border) + "\" colorD=\"" + Accessor.getColorD(border) + "\" />\n");
                                    }
                                    continue;
                                // case BORDER_TYPE_IMAGE_SCALED:
                                case BORDER_TYPE_IMAGE:
                                    {
                                        Image[] images = Accessor.getImages(border);
                                        int resourceCount = 0;
                                        for (int counter = 0; counter < images.length; counter++) {
                                            if (images[counter] != null && findId(images[counter], true) != null) {
                                                resourceCount++;
                                            }
                                        }
                                        if (resourceCount != 2 && resourceCount != 3 && resourceCount != 8 && resourceCount != 9) {
                                            System.out.println("Odd resource count for image border: " + resourceCount);
                                            resourceCount = 2;
                                        }
                                        switch(resourceCount) {
                                            case 2:
                                                bw.write("        <border key=\"" + key + "\" type=\"image\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[4], true) + "\" />\n");
                                                break;
                                            case 3:
                                                bw.write("        <border key=\"" + key + "\" type=\"image\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[4], true) + "\" " + "i3=\"" + findId(images[8], true) + "\" />\n");
                                                break;
                                            case 8:
                                                bw.write("        <border key=\"" + key + "\" type=\"image\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[1], true) + "\" " + "i3=\"" + findId(images[2], true) + "\" " + "i4=\"" + findId(images[3], true) + "\" " + "i5=\"" + findId(images[4], true) + "\" " + "i6=\"" + findId(images[5], true) + "\" " + "i7=\"" + findId(images[6], true) + "\" " + "i8=\"" + findId(images[7], true) + "\" />\n");
                                                break;
                                            case 9:
                                                bw.write("        <border key=\"" + key + "\" type=\"image\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[1], true) + "\" " + "i3=\"" + findId(images[2], true) + "\" " + "i4=\"" + findId(images[3], true) + "\" " + "i5=\"" + findId(images[4], true) + "\" " + "i6=\"" + findId(images[5], true) + "\" " + "i7=\"" + findId(images[6], true) + "\" " + "i8=\"" + findId(images[7], true) + "\" " + "i9=\"" + findId(images[8], true) + "\" />\n");
                                                break;
                                        }
                                        continue;
                                    }
                                case BORDER_TYPE_IMAGE_HORIZONTAL:
                                    {
                                        Image[] images = Accessor.getImages(border);
                                        bw.write("        <border key=\"" + key + "\" type=\"imageH\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[1], true) + "\" " + "i3=\"" + findId(images[2], true) + "\" />\n");
                                        continue;
                                    }
                                case BORDER_TYPE_IMAGE_VERTICAL:
                                    {
                                        Image[] images = Accessor.getImages(border);
                                        bw.write("        <border key=\"" + key + "\" type=\"imageV\" " + "i1=\"" + findId(images[0], true) + "\" " + "i2=\"" + findId(images[1], true) + "\" " + "i3=\"" + findId(images[2], true) + "\" />\n");
                                        continue;
                                    }
                            }
                            continue;
                        }
                        // if this is a font
                        if (key.endsWith("font")) {
                            com.codename1.ui.Font f = (com.codename1.ui.Font) theme.get(key);
                            // is this a new font?
                            boolean newFont = f instanceof EditorFont;
                            if (newFont) {
                                bw.write("        <font key=\"" + key + "\" type=\"named\" " + "name=\"" + findId(f) + "\" />\n");
                            } else {
                                if (f instanceof EditorTTFFont && (((EditorTTFFont) f).getFontFile() != null || ((EditorTTFFont) f).getNativeFontName() != null)) {
                                    EditorTTFFont ed = (EditorTTFFont) f;
                                    String fname;
                                    String ffName;
                                    if (((EditorTTFFont) f).getNativeFontName() != null) {
                                        fname = ((EditorTTFFont) f).getNativeFontName();
                                        ffName = fname;
                                    } else {
                                        fname = ed.getFontFile().getName();
                                        ffName = ((java.awt.Font) ed.getNativeFont()).getPSName();
                                    }
                                    bw.write("        <font key=\"" + key + "\" type=\"ttf\" " + "face=\"" + f.getFace() + "\" " + "style=\"" + f.getStyle() + "\" " + "size=\"" + f.getSize() + "\" " + "name=\"" + fname + "\" " + "family=\"" + ffName + "\" " + "sizeSettings=\"" + ed.getSizeSetting() + "\" " + "actualSize=\"" + ed.getActualSize() + "\" />\n");
                                } else {
                                    bw.write("        <font key=\"" + key + "\" type=\"system\" " + "face=\"" + f.getFace() + "\" " + "style=\"" + f.getStyle() + "\" " + "size=\"" + f.getSize() + "\" />\n");
                                }
                            }
                            continue;
                        }
                        // if this is a background image
                        if (key.endsWith("bgImage")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + findId(theme.get(key), true) + "\" />\n");
                            continue;
                        }
                        if (key.endsWith("scaledImage")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        if (key.endsWith("derive")) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        // if this is a background gradient
                        if (key.endsWith("bgGradient")) {
                            Object[] gradient = (Object[]) theme.get(key);
                            bw.write("        <gradient key=\"" + key + "\" color1=\"" + gradient[0] + "\"" + " color2=\"" + gradient[1] + "\"" + " posX=\"" + gradient[2] + "\"" + " posY=\"" + gradient[3] + "\"" + " radius=\"" + gradient[4] + "\" />\n");
                            continue;
                        }
                        if (key.endsWith(Style.BACKGROUND_TYPE) || key.endsWith(Style.BACKGROUND_ALIGNMENT)) {
                            bw.write("        <val key=\"" + key + "\" value=\"" + theme.get(key) + "\" />\n");
                            continue;
                        }
                        // thow an exception no idea what this is
                        throw new IOException("Error while trying to read theme property: " + key);
                    }
                    bw.write("    </theme>\n");
                    continue;
                case MAGIC_FONT:
                    File legacyFont = new File(resourcesDir, normalizeFileName(resourceNames[iter]));
                    DataOutputStream legacyFontOut = new DataOutputStream(new FileOutputStream(legacyFont));
                    saveFont(legacyFontOut, false, resourceNames[iter]);
                    legacyFontOut.close();
                    bw.write("    <legacyFont name=\"" + xResourceName + "\" />\n");
                    continue;
                case MAGIC_DATA:
                    {
                        File dataFile = new File(resourcesDir, normalizeFileName(resourceNames[iter]));
                        DataOutputStream dataFileOut = new DataOutputStream(new FileOutputStream(dataFile));
                        InputStream i = getData(resourceNames[iter]);
                        ByteArrayOutputStream outArray = new ByteArrayOutputStream();
                        int val = i.read();
                        while (val != -1) {
                            outArray.write(val);
                            val = i.read();
                        }
                        byte[] data = outArray.toByteArray();
                        dataFileOut.write(data);
                        dataFileOut.close();
                        bw.write("    <data name=\"" + xResourceName + "\" />\n");
                        continue;
                    }
                case MAGIC_UI:
                    {
                        File uiXML = new File(resourcesDir, resourceNames[iter] + ".ui");
                        UIBuilderOverride u = new UIBuilderOverride();
                        com.codename1.ui.Container cnt = u.createContainer(this, resourceNames[iter]);
                        FileOutputStream fos = new FileOutputStream(uiXML);
                        writeUIXml(cnt, fos);
                        fos.close();
                        File ui = new File(resourcesDir, resourceNames[iter]);
                        DataOutputStream uiOut = new DataOutputStream(new FileOutputStream(ui));
                        InputStream i = getUi(resourceNames[iter]);
                        ByteArrayOutputStream outArray = new ByteArrayOutputStream();
                        int val = i.read();
                        while (val != -1) {
                            outArray.write(val);
                            val = i.read();
                        }
                        byte[] data = outArray.toByteArray();
                        uiOut.write(data);
                        uiOut.close();
                        bw.write("    <ui name=\"" + xResourceName + "\" />\n");
                        continue;
                    }
                case MAGIC_L10N:
                    // we are getting the theme which allows us to acces the l10n data
                    bw.write("    <l10n name=\"" + xResourceName + "\">\n");
                    Hashtable<String, Object> l10n = getTheme(resourceNames[iter]);
                    for (String locale : l10n.keySet()) {
                        bw.write("        <lang name=\"" + locale + "\">\n");
                        Hashtable<String, String> current = (Hashtable<String, String>) l10n.get(locale);
                        for (String key : current.keySet()) {
                            String val = current.get(key);
                            bw.write("            <entry key=\"" + xmlize(key) + "\" value=\"" + xmlize(val) + "\" />\n");
                        }
                        bw.write("        </lang>\n");
                    }
                    bw.write("    </l10n>\n");
                    continue;
                default:
                    throw new IOException("Corrupt theme file unrecognized magic number: " + Integer.toHexString(magic & 0xff));
            }
        }
        bw.write("</resource>\n");
        bw.close();
    } finally {
        overrideFile = overrideFileBackup;
        overrideResource = overrideResourceBackup;
    }
}
Also used : SVG(com.codename1.impl.javase.SVG) DataOutputStream(java.io.DataOutputStream) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage) LegacyFont(com.codename1.ui.util.xml.LegacyFont) EditorTTFFont(com.codename1.ui.EditorTTFFont) EditorFont(com.codename1.ui.EditorFont) BufferedWriter(java.io.BufferedWriter) EditorTTFFont(com.codename1.ui.EditorTTFFont) RoundRectBorder(com.codename1.ui.plaf.RoundRectBorder) Image(com.codename1.ui.Image) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Hashtable(java.util.Hashtable) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EncodedImage(com.codename1.ui.EncodedImage) CSSBorder(com.codename1.ui.plaf.CSSBorder) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) AnimationObject(com.codename1.ui.animations.AnimationObject) EditorFont(com.codename1.ui.EditorFont) RoundBorder(com.codename1.ui.plaf.RoundBorder) File(java.io.File) RoundRectBorder(com.codename1.ui.plaf.RoundRectBorder) CSSBorder(com.codename1.ui.plaf.CSSBorder) RoundBorder(com.codename1.ui.plaf.RoundBorder) Border(com.codename1.ui.plaf.Border)

Example 37 with File

use of com.codename1.io.File in project CodenameOne by codenameone.

the class CN1CSSInstallerCLI method install.

private static void install(String[] args) throws Exception {
    File cssFile = new File(args[1]);
    File resFile = new File(args[2]);
    EventQueue.invokeLater(() -> {
        try {
            JavaSEPort.setShowEDTViolationStacks(false);
            JavaSEPort.setShowEDTWarnings(false);
            JFrame frm = new JFrame("Placeholder");
            frm.setVisible(false);
            Display.init(frm.getContentPane());
            JavaSEPort.setBaseResourceDir(resFile.getParentFile());
            EditableResources res = new EditableResources();
            res.openFile(new FileInputStream(resFile));
            String mainTheme = res.getThemeResourceNames()[0];
            res.setThemeProperty(mainTheme, "@OverlayThemes", cssFile.getName());
            System.out.println("Setting @OverlayThemes constant in " + mainTheme + " theme of " + resFile.getPath() + " to " + cssFile.getName() + " so that the CSS styles will override styles in the default theme.");
            DataOutputStream dos = new DataOutputStream(new FileOutputStream(resFile));
            res.save(dos);
            dos.close();
            Display.getInstance().exitApplication();
        } catch (IOException ex) {
            Logger.getLogger(CN1CSSInstallerCLI.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
}
Also used : JFrame(javax.swing.JFrame) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) EditableResources(com.codename1.ui.util.EditableResources) FileInputStream(java.io.FileInputStream)

Example 38 with File

use of com.codename1.io.File in project CodenameOne by codenameone.

the class CSSTheme method getBackgroundImage.

public Image getBackgroundImage(Map<String, LexicalUnit> styles, ScaledUnit bgImage) {
    try {
        // ScaledUnit bgImage = (ScaledUnit)styles.get("background-image");
        if (bgImage == null) {
            return null;
        }
        String url = bgImage.getStringValue();
        String fileName = url;
        if (fileName.indexOf("/") != -1) {
            fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
        }
        if (loadedImages.containsKey(url)) {
            return loadedImages.get(url);
        }
        LexicalUnit imageId = styles.get("cn1-image-id");
        String imageIdStr = fileName;
        if (imageId != null) {
            imageIdStr = imageId.getStringValue();
        } else {
        /*
                int i=1;
                while (res.getImage(imageIdStr) != null) {
                    
                    if (i == 1) {
                        imageIdStr += "_"+(++i);
                    } else {
                        imageIdStr = imageIdStr.substring(0, imageIdStr.lastIndexOf("_")) + "_"+(++i);
                    }
                }
                */
        }
        Image resimg = res.getImage(imageIdStr);
        Integer defaultSourceDpi = null;
        if (constants.containsKey("defaultSourceDPIInt")) {
            Object v = constants.get("defaultSourceDPIInt");
            if (v instanceof String) {
                defaultSourceDpi = Integer.parseInt((String) v);
            } else if (v instanceof Number) {
                defaultSourceDpi = ((Number) v).intValue();
            } else if (v instanceof ScaledUnit) {
                ScaledUnit su = (ScaledUnit) v;
                defaultSourceDpi = su.getIntegerValue();
            } else {
                throw new IllegalArgumentException("defaultSourceDPIInt constant should be a String or a number but found " + v.getClass());
            }
        }
        if (resimg != null) {
            ImageMetadata md = imagesMetadata.get(imageIdStr);
            int srcDpi = (int) currentDpi;
            if (defaultSourceDpi != null) {
                srcDpi = defaultSourceDpi;
            }
            if (styles.containsKey("cn1-source-dpi")) {
                srcDpi = (int) ((ScaledUnit) styles.get("cn1-source-dpi")).getNumericValue();
            }
            if (refreshImages || (md != null && md.sourceDpi != srcDpi)) {
                // 
                res.remove(imageIdStr);
            } else {
                loadedImages.put(imageIdStr, resimg);
                return res.getImage(imageIdStr);
            }
        }
        URL imgURL = null;
        if (url.startsWith("http://") || url.startsWith("https://")) {
            imgURL = new URL(url);
        } else {
            imgURL = new URL(baseURL, url);
        }
        if (false && isFileURL(imgURL)) {
            // This section is switched off because loading multi-images via url()
            // will cause unexpected results in cases where image borders are generated.
            // In order for this approach to work, we need take into account multi-images when
            // producing snapshots in the webview so that the correct size of image is used.
            // You can still load multi-images as theme constants.
            // See https://github.com/codenameone/CodenameOne/issues/2569#issuecomment-426730539
            File imgDir = new File(imgURL.toURI());
            if (imgDir.isDirectory()) {
                try {
                    Image im = getResourceImage(imgDir.getName(), imgDir.getParentFile());
                    if (im != null) {
                        loadedImages.put(url, im);
                        return im;
                    }
                } catch (Throwable t) {
                    System.err.println("Failed to load Multi-image from " + imgURL);
                    t.printStackTrace();
                    throw t;
                }
            }
        }
        InputStream is = imgURL.openStream();
        EncodedImage encImg = EncodedImage.create(is);
        is.close();
        ResourcesMutator resm = new ResourcesMutator(res, com.codename1.ui.Display.DENSITY_VERY_HIGH, minDpi, maxDpi);
        int[] dpis = getDpi(encImg);
        int sourceDpi = (int) Math.round(currentDpi);
        if (styles.containsKey("cn1-source-dpi")) {
            double densityVal = ((ScaledUnit) styles.get("cn1-source-dpi")).getNumericValue();
            sourceDpi = (int) Math.round(densityVal);
            if (Math.abs(densityVal) < 0.5) {
                resm.targetDensity = 0;
            } else {
                resm.targetDensity = getDensityForDpi(densityVal);
            }
        } else if (defaultSourceDpi != null) {
            sourceDpi = defaultSourceDpi;
            if (Math.abs(sourceDpi) < 0.5) {
                resm.targetDensity = 0;
            } else {
                resm.targetDensity = getDensityForDpi(sourceDpi);
            }
        } else if (dpis[0] > 0) {
            resm.targetDensity = getImageDensity(encImg);
        } else {
            resm.targetDensity = getDensityForDpi(bgImage.dpi);
        }
        if (styles.containsKey("cn1-densities")) {
            ScaledUnit densities = (ScaledUnit) styles.get("cn1-densities");
            if (densities.getLexicalUnitType() == LexicalUnit.SAC_IDENT && "none".equals(densities.getStringValue())) {
                // Not a multi-image
                resm.setMultiImage(false);
            }
        } else if (sourceDpi == 0) {
            resm.setMultiImage(false);
        }
        Image im = resm.storeImage(encImg, imageIdStr, false);
        im.setImageName(imageIdStr);
        loadedImages.put(url, im);
        ImageMetadata md = new ImageMetadata(imageIdStr, sourceDpi);
        imagesMetadata.addImageMetadata(md);
        return im;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) EncodedImage(com.codename1.ui.EncodedImage) Image(com.codename1.ui.Image) EncodedImage(com.codename1.ui.EncodedImage) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) CSSParseException(org.w3c.css.sac.CSSParseException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.w3c.flute.parser.ParseException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CSSException(org.w3c.css.sac.CSSException) IOException(java.io.IOException) File(java.io.File) LexicalUnit(org.w3c.css.sac.LexicalUnit)

Example 39 with File

use of com.codename1.io.File in project CodenameOne by codenameone.

the class CSSTheme method load.

public static CSSTheme load(URL uri) throws IOException {
    try {
        System.setProperty("org.w3c.css.sac.parser", "org.w3c.flute.parser.Parser");
        InputSource source = new InputSource();
        InputStream stream = uri.openStream();
        String stringContents = Util.readToString(stream);
        // The flute parser chokes on properties beginning with -- so we need to replace these with cn1 prefix
        // for CSS variable support.
        stringContents = stringContents.replaceAll("([\\(\\W])(--[a-zA-Z0-9\\-]+)", "$1cn1$2");
        // Flute chokes on embedded var() functions inside an rgb or rgba function.  Hoping to support it by changing the
        // function name to cn1rgb() and cn1rgba() respectively.
        stringContents = stringContents.replaceAll("\\brgb\\(", "cn1rgb(");
        stringContents = stringContents.replaceAll("\\brgba\\(", "cn1rgba(");
        source.setCharacterStream(new CharArrayReader(stringContents.toCharArray()));
        source.setURI(uri.toString());
        source.setEncoding("UTF-8");
        ParserFactory parserFactory = new ParserFactory();
        Parser parser = parserFactory.makeParser();
        final CSSTheme theme = new CSSTheme();
        theme.baseURL = uri;
        parser.setErrorHandler(new ErrorHandler() {

            @Override
            public void warning(CSSParseException csspe) throws CSSException {
                System.out.println("CSS Warning: " + csspe.getLocalizedMessage() + " on line " + csspe.getLineNumber() + " col: " + csspe.getColumnNumber() + " of file " + csspe.getURI());
            }

            @Override
            public void error(CSSParseException csspe) throws CSSException {
                System.out.println("CSS Error: " + csspe.getLocalizedMessage() + " on line " + csspe.getLineNumber() + " col: " + csspe.getColumnNumber() + " of file " + csspe.getURI());
            }

            @Override
            public void fatalError(CSSParseException csspe) throws CSSException {
                System.out.println("CSS Fatal Error: " + csspe.getLocalizedMessage() + " on line " + csspe.getLineNumber() + " col: " + csspe.getColumnNumber() + " of file " + csspe.getURI());
            }
        });
        // parser.setLocale(Locale.getDefault());
        parser.setDocumentHandler(new DocumentHandler() {

            Map<String, LexicalUnit> variables = new LinkedHashMap<>();

            SelectorList currSelectors;

            FontFace currFontFace;

            SACMediaList currMediaList;

            // double currentTargetDpi = 320;
            // double currentMinDpi = 120;
            // double currentMaxDpi = 640;
            // int currentScreenWidth = 1280;
            // int currentScreenHeight = 1920;
            @Override
            public void startDocument(InputSource is) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void endDocument(InputSource is) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void comment(String string) throws CSSException {
            }

            @Override
            public void ignorableAtRule(String string) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void namespaceDeclaration(String string, String string1) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void importStyle(String string, SACMediaList sacml, String string1) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void startMedia(SACMediaList sacml) throws CSSException {
                currMediaList = sacml;
            }

            @Override
            public void endMedia(SACMediaList sacml) throws CSSException {
                currMediaList = null;
            }

            @Override
            public void startPage(String string, String string1) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void endPage(String string, String string1) throws CSSException {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void startFontFace() throws CSSException {
                currFontFace = theme.createFontFace();
            }

            @Override
            public void endFontFace() throws CSSException {
                currFontFace = null;
            }

            @Override
            public void startSelector(SelectorList sl) throws CSSException {
                // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                currSelectors = sl;
            }

            @Override
            public void endSelector(SelectorList sl) throws CSSException {
                currSelectors = null;
            }

            @Override
            public void property(String string, LexicalUnit lu, boolean bln) throws CSSException {
                try {
                    property_(string, lu, bln);
                } catch (Throwable t) {
                    if (t instanceof CSSException) {
                        throw (CSSException) t;
                    } else {
                        System.out.println("Exception occurred while parsing property " + string + " " + lu);
                        t.printStackTrace();
                        throw new ParseException(t.getMessage());
                    }
                }
            }

            private ScaledUnit last(LexicalUnit lu) {
                while (lu.getNextLexicalUnit() != null) {
                    lu = lu.getNextLexicalUnit();
                }
                return (lu instanceof ScaledUnit) ? (ScaledUnit) lu : new ScaledUnit(lu, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight());
            }

            /**
             * Evaluates a LexicalUnit in the current parser position.  This will expand any variables.  It will
             * continue to evaluate the next lexical unit, until it reaches the end of the current lexical unit chain.
             * @param lu The lexical unit to evaluate.
             * @return
             * @throws CSSException
             */
            private ScaledUnit evaluate(LexicalUnit lu) throws CSSException {
                if (lu.getLexicalUnitType() == LexicalUnit.SAC_FUNCTION && "var".equals(lu.getFunctionName())) {
                    LexicalUnit parameters = lu.getParameters();
                    String varname = parameters.getStringValue();
                    LexicalUnit varVal = variables.get(varname);
                    ScaledUnit su;
                    if (varVal == null && parameters.getNextLexicalUnit() != null) {
                        varVal = parameters.getNextLexicalUnit();
                        su = evaluate(new ScaledUnit(varVal, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight()));
                    } else if (varVal == null) {
                        su = new ScaledUnit(lu, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight());
                    } else {
                        su = evaluate(new ScaledUnit(varVal, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight()));
                    }
                    // Evaluate the variable value in case it also includes other variables that need to be evaluated.
                    // ScaledUnit su = evaluate(new ScaledUnit(varVal, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight()));
                    LexicalUnit toAppend = lu.getNextLexicalUnit();
                    ScaledUnit last = last(su);
                    if (toAppend != null) {
                        toAppend = evaluate(toAppend);
                        last.setNextLexicalUnit(toAppend);
                        ((ScaledUnit) toAppend).setPrevLexicalUnit(last);
                    } else {
                        last.setNextLexicalUnit(null);
                    }
                    return su;
                } else {
                    ScaledUnit su = new ScaledUnit(lu, theme.currentDpi, theme.getPreviewScreenWidth(), theme.getPreviewScreenHeight());
                    LexicalUnit nex = su.getNextLexicalUnit();
                    if (su.getParameters() != null) {
                        su.setParameters(evaluate(su.getParameters()));
                    }
                    if (nex != null) {
                        ScaledUnit snex = evaluate(nex);
                        su.setNextLexicalUnit(snex);
                        snex.setPrevLexicalUnit(su);
                    }
                    return su;
                }
            }

            private void property_(String string, LexicalUnit _lu, boolean bln) throws CSSException {
                if (string.startsWith("cn1--")) {
                    variables.put(string, _lu);
                    return;
                }
                ScaledUnit su = evaluate(_lu);
                if (currFontFace != null) {
                    switch(string) {
                        case "font-family":
                            currFontFace.fontFamily = su;
                            break;
                        case "font-style":
                            currFontFace.fontStyle = su;
                            break;
                        case "font-stretch":
                            currFontFace.fontStretch = su;
                            break;
                        case "src":
                            currFontFace.src = su;
                            break;
                        case "font-weight":
                            currFontFace.fontWeight = su;
                            break;
                    }
                } else {
                    int len = currSelectors.getLength();
                    for (int i = 0; i < len; i++) {
                        Selector sel = currSelectors.item(i);
                        if (currMediaList != null) {
                            for (String mediaPrefix : getMediaPrefixes(currMediaList)) {
                                theme.apply(mediaPrefix, sel, string, su);
                            }
                        } else {
                            theme.apply(null, sel, string, su);
                        }
                    }
                }
            }
        });
        parser.parseStyleSheet(source);
        stream.close();
        return theme;
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(CSSTheme.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(CSSTheme.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(CSSTheme.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NullPointerException ex) {
        if (ex.getMessage().contains("encoding properties")) {
        // This error always happens and there doesn't seem to be a way to fix it... so let's just hide
        // it .  Doesn't seem to hurt anything.
        } else {
        // Logger.getLogger(CSSTheme.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (ClassCastException ex) {
        Logger.getLogger(CSSTheme.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
Also used : InputSource(org.w3c.css.sac.InputSource) SACMediaList(org.w3c.css.sac.SACMediaList) ParserFactory(org.w3c.css.sac.helpers.ParserFactory) LinkedHashMap(java.util.LinkedHashMap) DocumentHandler(org.w3c.css.sac.DocumentHandler) CSSException(org.w3c.css.sac.CSSException) LexicalUnit(org.w3c.css.sac.LexicalUnit) ConditionalSelector(org.w3c.css.sac.ConditionalSelector) ElementSelector(org.w3c.css.sac.ElementSelector) Selector(org.w3c.css.sac.Selector) SimpleSelector(org.w3c.css.sac.SimpleSelector) ErrorHandler(org.w3c.css.sac.ErrorHandler) ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Parser(org.w3c.css.sac.Parser) JSONParser(com.codename1.io.JSONParser) CharArrayReader(java.io.CharArrayReader) CSSParseException(org.w3c.css.sac.CSSParseException) SelectorList(org.w3c.css.sac.SelectorList) CSSParseException(org.w3c.css.sac.CSSParseException) ParseException(org.w3c.flute.parser.ParseException)

Example 40 with File

use of com.codename1.io.File in project CodenameOne by codenameone.

the class CSSTheme method getResourceImage.

public Image getResourceImage(String imageName, File baseDir) {
    try {
        if (res.containsResource(imageName)) {
            return res.getImage(imageName);
        } else {
            File imageFolder = new File(baseDir, imageName);
            if (imageFolder.exists()) {
                EditableResources.MultiImage multi = new EditableResources.MultiImage();
                ArrayList<Integer> dpis = new ArrayList<Integer>();
                ArrayList<EncodedImage> encodedImages = new ArrayList<EncodedImage>();
                // long largestSize = 0;
                for (File f : imageFolder.listFiles()) {
                    int density = Display.DENSITY_MEDIUM;
                    switch(f.getName()) {
                        case "2hd.png":
                            density = Display.DENSITY_2HD;
                            break;
                        case "4k.png":
                            density = Display.DENSITY_4K;
                            break;
                        case "560.png":
                            density = Display.DENSITY_560;
                            break;
                        case "hd.png":
                            density = Display.DENSITY_HD;
                            break;
                        case "high.png":
                            density = Display.DENSITY_HIGH;
                            break;
                        case "low.png":
                            density = Display.DENSITY_LOW;
                            break;
                        case "medium.png":
                            density = Display.DENSITY_MEDIUM;
                            break;
                        case "veryhigh.png":
                            density = Display.DENSITY_VERY_HIGH;
                            break;
                        case "verylow.png":
                            density = Display.DENSITY_VERY_LOW;
                            break;
                    }
                    InputStream is = f.toURL().openStream();
                    EncodedImage encImg = EncodedImage.create(is);
                    is.close();
                    dpis.add(density);
                    encodedImages.add(encImg);
                }
                int[] iDpis = new int[dpis.size()];
                int ctr = 0;
                for (Integer i : dpis) {
                    iDpis[ctr++] = i;
                }
                multi.setDpi(iDpis);
                multi.setInternalImages(encodedImages.toArray(new EncodedImage[encodedImages.size()]));
                res.setMultiImage(imageName, multi);
                loadedImages.put(imageFolder.toURL().toString(), multi.getBest());
                return multi.getBest();
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return null;
}
Also used : ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) EncodedImage(com.codename1.ui.EncodedImage) URISyntaxException(java.net.URISyntaxException) CSSParseException(org.w3c.css.sac.CSSParseException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.w3c.flute.parser.ParseException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CSSException(org.w3c.css.sac.CSSException) IOException(java.io.IOException) File(java.io.File) EditableResources(com.codename1.ui.util.EditableResources)

Aggregations

IOException (java.io.IOException)76 File (java.io.File)61 FileInputStream (java.io.FileInputStream)43 InputStream (java.io.InputStream)33 EncodedImage (com.codename1.ui.EncodedImage)23 FileOutputStream (java.io.FileOutputStream)23 OutputStream (java.io.OutputStream)22 SortedProperties (com.codename1.ant.SortedProperties)18 FileSystemStorage (com.codename1.io.FileSystemStorage)17 BufferedInputStream (com.codename1.io.BufferedInputStream)15 Image (com.codename1.ui.Image)15 ByteArrayInputStream (java.io.ByteArrayInputStream)15 ActionEvent (com.codename1.ui.events.ActionEvent)14 RandomAccessFile (java.io.RandomAccessFile)14 ArrayList (java.util.ArrayList)14 EditableResources (com.codename1.ui.util.EditableResources)13 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 Properties (java.util.Properties)12 File (com.codename1.io.File)11 BufferedImage (java.awt.image.BufferedImage)11