use of com.codename1.ui.util.EditableResources in project CodenameOne by codenameone.
the class PulsateEditor method pulsateWizard.
public void pulsateWizard(EditableResources res, JComponent parent) {
File[] f = ResourceEditorView.showOpenFileChooser("Image", ".png", ".jpg", ".jpeg", ".gif");
if (f != null && f.length > 0) {
try {
timelineName.setText(f[0].getName());
sourceImage = ImageIO.read(f[0]);
updateTimeline();
timer = new javax.swing.Timer(130, new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
if (previewLabel.animate()) {
previewLabel.repaint();
preview.repaint();
}
}
});
timer.setRepeats(true);
timer.setCoalesce(true);
timer.start();
int val = JOptionPane.showConfirmDialog(parent, this, "Edit Effect", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
timer.stop();
if (val == JOptionPane.OK_OPTION) {
store(res, currentImage, timelineName.getText() + ": TL ");
for (EncodedImage img : internalImages) {
store(res, img, timelineName.getText() + ": Fr ");
}
}
} catch (IOException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(parent, "Error in reading image file", "File Read Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of com.codename1.ui.util.EditableResources in project CodenameOne by codenameone.
the class ResourceEditorApp method importRes.
private static Hashtable importRes(EditableResources res, String file) {
InputStream is = ResourceEditorApp.class.getResourceAsStream("/templates/" + file + ".res");
Hashtable theme = new Hashtable();
if (is != null) {
try {
EditableResources r = new EditableResources();
r.openFile(is);
is.close();
if (r.getThemeResourceNames().length > 0) {
theme = r.getTheme(r.getThemeResourceNames()[0]);
}
ResourceEditorView.checkDuplicateResourcesLoop(r, res.getImageResourceNames(), r.getImageResourceNames(), "Rename Image", "Image ", true, null);
ResourceEditorView.checkDuplicateResourcesLoop(r, res.getL10NResourceNames(), r.getL10NResourceNames(), "Rename Localization", "Localization ", true, null);
ResourceEditorView.checkDuplicateResourcesLoop(r, res.getDataResourceNames(), r.getDataResourceNames(), "Rename Data", "Data ", true, null);
ResourceEditorView.checkDuplicateResourcesLoop(r, res.getUIResourceNames(), r.getUIResourceNames(), "Rename GUI", "GUI ", true, null);
ResourceEditorView.checkDuplicateResourcesLoop(r, res.getFontResourceNames(), r.getFontResourceNames(), "Rename Font", "Font ", true, null);
for (String s : r.getImageResourceNames()) {
if (r.isMultiImage(s)) {
res.setMultiImage(s, (EditableResources.MultiImage) r.getResourceObject(s));
} else {
res.setImage(s, r.getImage(s));
}
}
for (String s : r.getL10NResourceNames()) {
res.setL10N(s, (Hashtable) r.getResourceObject(s));
}
for (String s : r.getDataResourceNames()) {
res.setData(s, (byte[]) r.getResourceObject(s));
}
for (String s : r.getUIResourceNames()) {
res.setUi(s, (byte[]) r.getResourceObject(s));
}
for (String s : r.getFontResourceNames()) {
res.setFont(s, r.getFont(s));
}
} catch (IOException err) {
err.printStackTrace();
}
}
return theme;
}
use of com.codename1.ui.util.EditableResources in project CodenameOne by codenameone.
the class ImageTask method addToResources.
@Override
public void addToResources(EditableResources e) throws IOException {
Image i;
InputStream input = new FileInputStream(file);
i = EncodedImage.create(input);
input.close();
e.setImage(getName(), i);
}
use of com.codename1.ui.util.EditableResources 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.util.EditableResources in project CodenameOne by codenameone.
the class AddThemeResource method addResource.
// GEN-LAST:event_templateActionPerformed
public String addResource(EditableResources res, ResourceEditorView view) {
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;
}
}
Hashtable theme = new Hashtable();
InputStream is = getClass().getResourceAsStream("/templates/" + template.getSelectedItem().toString() + ".res");
if (is != null) {
try {
EditableResources r = new EditableResources();
r.openFile(is);
is.close();
theme = r.getTheme(r.getThemeResourceNames()[0]);
view.checkDuplicateResourcesLoop(r, res.getImageResourceNames(), r.getImageResourceNames(), "Rename Image", "Image ", true);
view.checkDuplicateResourcesLoop(r, res.getL10NResourceNames(), r.getL10NResourceNames(), "Rename Localization", "Localization ", true);
view.checkDuplicateResourcesLoop(r, res.getDataResourceNames(), r.getDataResourceNames(), "Rename Data", "Data ", true);
view.checkDuplicateResourcesLoop(r, res.getUIResourceNames(), r.getUIResourceNames(), "Rename GUI", "GUI ", true);
view.checkDuplicateResourcesLoop(r, res.getFontResourceNames(), r.getFontResourceNames(), "Rename Font", "Font ", true);
for (String s : r.getImageResourceNames()) {
if (r.isMultiImage(s)) {
res.setMultiImage(s, (EditableResources.MultiImage) r.getResourceObject(s));
} else {
res.setImage(s, r.getImage(s));
}
}
for (String s : r.getL10NResourceNames()) {
res.setL10N(s, (Hashtable) r.getResourceObject(s));
}
for (String s : r.getDataResourceNames()) {
res.setData(s, (byte[]) r.getResourceObject(s));
}
for (String s : r.getUIResourceNames()) {
res.setUi(s, (byte[]) r.getResourceObject(s));
}
for (String s : r.getFontResourceNames()) {
res.setFont(s, r.getFont(s));
}
} catch (IOException err) {
err.printStackTrace();
}
}
res.setTheme(name.getText(), theme);
view.setSelectedResource(name.getText());
return name.getText();
}
Aggregations