Search in sources :

Example 6 with EditorFont

use of com.codename1.ui.EditorFont in project CodenameOne by codenameone.

the class AddResourceDialog method addResource.

public String addResource(EditableResources res, ResourceEditorView view) {
    // "Image", "Animation", "Font", "Theme", "Data", "Localization (L10N)"
    String newName = name.getText();
    for (String r : res.getResourceNames()) {
        if (r.equalsIgnoreCase(newName)) {
            JOptionPane.showMessageDialog(this, "A resource called: " + newName + " already exists\nYou must delete the resource first.", "Add Resource", JOptionPane.ERROR_MESSAGE);
            return null;
        }
    }
    switch(type.getSelectedIndex()) {
        case // image
        IMAGE:
            ImageRGBEditor imageEditor = new ImageRGBEditor(res, name.getText(), view);
            imageEditor.selectFile();
            view.setSelectedResource(name.getText());
            break;
        case MULTI_IMAGE:
            ImageMultiEditor multiImageEditor = new ImageMultiEditor(res, name.getText(), view);
            view.setSelectedResource(name.getText());
            break;
        case TIMELINE:
            new TimelineEditor(res, name.getText(), view);
            view.setSelectedResource(name.getText());
            break;
        case // animation
        ANIMATION:
            TimelineEditor.selectFile(view, res, name.getText());
            /*ImageEditor animationEditor = new ImageEditor(res, name.getText());
                animationEditor.setAnimation(true);
                animationEditor.selectFile(view);*/
            break;
        case // font
        FONT:
            new FontEditor(res, new EditorFont(com.codename1.ui.Font.createSystemFont(com.codename1.ui.Font.FACE_SYSTEM, com.codename1.ui.Font.STYLE_PLAIN, com.codename1.ui.Font.SIZE_MEDIUM), null, "Arial-plain-12", true, RenderingHints.VALUE_TEXT_ANTIALIAS_ON, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:!@/\\*()[]{}|#$%^&<>?'\"+- "), name.getText()).createFont();
            view.setSelectedResource(name.getText());
            break;
        case // theme
        THEME:
            res.setTheme(name.getText(), new Hashtable());
            view.setSelectedResource(name.getText());
            // ResourceEditorView.expandAndSelect(tree, name.getText());
            break;
        case // data
        DATA:
            DataEditor dataEditor = new DataEditor(res, name.getText());
            dataEditor.selectDataFile(view);
            view.setSelectedResource(name.getText());
            break;
        case // localization
        LOCALIZATION:
            Hashtable h = new Hashtable();
            Hashtable local = new Hashtable();
            local.put("cancel", "Cancel");
            local.put("ok", "OK");
            local.put("menu", "Menu");
            local.put("select", "Select");
            local.put("edit", "Edit");
            h.put("en", local);
            res.setL10N(name.getText(), h);
            view.setSelectedResource(name.getText());
            // ResourceEditorView.expandAndSelect(tree, name.getText());
            break;
        case UI:
            UserInterfaceEditor uiEditor = new UserInterfaceEditor(name.getText(), res, view.getProjectGeneratorSettings(), view);
            view.setSelectedResource(name.getText());
            break;
    }
    return name.getText();
}
Also used : Hashtable(java.util.Hashtable) EditorFont(com.codename1.ui.EditorFont)

Example 7 with EditorFont

use of com.codename1.ui.EditorFont in project CodenameOne by codenameone.

the class FontEditor method createFont.

/**
 * Creates a font instance based on the current state to place into the
 * undoable edit within the Editor.
 */
public EditorFont createFont() {
    if (!completedConstruction) {
        return null;
    }
    com.codename1.ui.Font systemFont = com.codename1.ui.Font.createSystemFont(FONT_FACE_VALUES[systemFontFace.getSelectedIndex()], FONT_STYLE_VALUES[systemFontStyle.getSelectedIndex()], FONT_SIZE_VALUES[systemFontSize.getSelectedIndex()]);
    java.awt.Font aFont = preview.getFont();
    String s = aFont.getFamily() + "-";
    if (aFont.isBold()) {
        s += aFont.isItalic() ? "bolditalic" : "bold";
    } else {
        s += aFont.isItalic() ? "italic" : "plain";
    }
    s += "-" + aFont.getSize();
    int selIndex = fontMainType.getSelectedIndex();
    EditorFont newFont = new EditorFont(systemFont, null, s + ";" + lookupString.getText(), selIndex == 1 || selIndex == 2, ANTI_ALIASING_VALUES[antiAliasing.getSelectedIndex()], charset.getText());
    if (!factoryCreation) {
        resources.setFont(fontName, newFont);
    }
    return newFont;
}
Also used : EditorFont(com.codename1.ui.EditorFont)

Aggregations

EditorFont (com.codename1.ui.EditorFont)7 EditorTTFFont (com.codename1.ui.EditorTTFFont)2 Image (com.codename1.ui.Image)2 AnimationObject (com.codename1.ui.animations.AnimationObject)2 Border (com.codename1.ui.plaf.Border)2 RoundBorder (com.codename1.ui.plaf.RoundBorder)2 RoundRectBorder (com.codename1.ui.plaf.RoundRectBorder)2 LegacyFont (com.codename1.ui.util.xml.LegacyFont)2 IOException (java.io.IOException)2 Hashtable (java.util.Hashtable)2 SVG (com.codename1.impl.javase.SVG)1 EncodedImage (com.codename1.ui.EncodedImage)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedWriter (java.io.BufferedWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1