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();
}
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;
}
Aggregations