Search in sources :

Example 1 with FontEditor

use of com.codename1.designer.FontEditor in project CodenameOne by codenameone.

the class EditableResources method getResourceEditor.

public JComponent getResourceEditor(String name, ResourceEditorView view) {
    byte magic = getResourceType(name);
    switch(magic) {
        case MAGIC_IMAGE:
        case MAGIC_IMAGE_LEGACY:
            Image i = getImage(name);
            if (getResourceObject(name) instanceof MultiImage) {
                ImageMultiEditor tl = new ImageMultiEditor(this, name, view);
                tl.setImage((MultiImage) getResourceObject(name));
                return tl;
            }
            if (i instanceof Timeline) {
                TimelineEditor tl = new TimelineEditor(this, name, view);
                tl.setImage((Timeline) i);
                return tl;
            }
            if (i.isSVG()) {
                MultiImageSVGEditor img = new MultiImageSVGEditor(this, name);
                img.setImage(i);
                return img;
            }
            ImageRGBEditor img = new ImageRGBEditor(this, name, view);
            img.setImage(i);
            return img;
        case MAGIC_TIMELINE:
            TimelineEditor tl = new TimelineEditor(this, name, view);
            tl.setImage((Timeline) getImage(name));
            return tl;
        case MAGIC_THEME:
        case MAGIC_THEME_LEGACY:
            ThemeEditor theme = new ThemeEditor(this, name, getTheme(name), view);
            return theme;
        case MAGIC_FONT:
        case MAGIC_FONT_LEGACY:
        case MAGIC_INDEXED_FONT_LEGACY:
            FontEditor fonts = new FontEditor(this, getFont(name), name);
            return fonts;
        case MAGIC_DATA:
            DataEditor data = new DataEditor(this, name);
            return data;
        case MAGIC_UI:
            UserInterfaceEditor uie = new UserInterfaceEditor(name, this, view.getProjectGeneratorSettings(), view);
            return uie;
        case MAGIC_L10N:
            // we are cheating this isn't a theme but it should work since
            // this is a hashtable that will include the nested locales
            L10nEditor l10n = new L10nEditor(this, name);
            return l10n;
        default:
            throw new IllegalArgumentException("Unrecognized magic number: " + Integer.toHexString(magic & 0xff));
    }
}
Also used : BufferedImage(java.awt.image.BufferedImage) EncodedImage(com.codename1.ui.EncodedImage) Image(com.codename1.ui.Image) MultiImageSVGEditor(com.codename1.designer.MultiImageSVGEditor) L10nEditor(com.codename1.designer.L10nEditor) ThemeEditor(com.codename1.designer.ThemeEditor) UserInterfaceEditor(com.codename1.designer.UserInterfaceEditor) Timeline(com.codename1.ui.animations.Timeline) DataEditor(com.codename1.designer.DataEditor) ImageMultiEditor(com.codename1.designer.ImageMultiEditor) TimelineEditor(com.codename1.designer.TimelineEditor) FontEditor(com.codename1.designer.FontEditor) ImageRGBEditor(com.codename1.designer.ImageRGBEditor)

Example 2 with FontEditor

use of com.codename1.designer.FontEditor in project CodenameOne by codenameone.

the class ResourceEditorView method addNewFontWizard.

/**
 * Invoked by the "..." button in the add theme entry dialog, allows us to add
 * a font on the fly while working on a theme
 */
public void addNewFontWizard() {
    AddResourceDialog addResource = new AddResourceDialog(loadedResources, AddResourceDialog.FONT);
    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainPanel, addResource, "Add Font", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE)) {
        if (addResource.checkName(loadedResources)) {
            JOptionPane.showMessageDialog(mainPanel, "A resource with that name already exists", "Add Font", JOptionPane.ERROR_MESSAGE);
            addNewFontWizard();
            return;
        }
        // show the image editing dialog...
        FontEditor font = new FontEditor(loadedResources, 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.,;:!/\\*()[]{}|#$%^&<>?'\"+- "), addResource.getResourceName());
        font.setFactoryCreation(true);
        if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainPanel, font, "Add Font", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE)) {
            loadedResources.setFont(addResource.getResourceName(), font.createFont());
        }
    }
}
Also used : EditorFont(com.codename1.ui.EditorFont)

Example 3 with FontEditor

use of com.codename1.designer.FontEditor 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)

Aggregations

EditorFont (com.codename1.ui.EditorFont)2 DataEditor (com.codename1.designer.DataEditor)1 FontEditor (com.codename1.designer.FontEditor)1 ImageMultiEditor (com.codename1.designer.ImageMultiEditor)1 ImageRGBEditor (com.codename1.designer.ImageRGBEditor)1 L10nEditor (com.codename1.designer.L10nEditor)1 MultiImageSVGEditor (com.codename1.designer.MultiImageSVGEditor)1 ThemeEditor (com.codename1.designer.ThemeEditor)1 TimelineEditor (com.codename1.designer.TimelineEditor)1 UserInterfaceEditor (com.codename1.designer.UserInterfaceEditor)1 EncodedImage (com.codename1.ui.EncodedImage)1 Image (com.codename1.ui.Image)1 Timeline (com.codename1.ui.animations.Timeline)1 BufferedImage (java.awt.image.BufferedImage)1 Hashtable (java.util.Hashtable)1