use of com.codename1.ui.animations.Timeline 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.animations.Timeline in project CodenameOne by codenameone.
the class CodenameOneImageRenderer method paintComponent.
@Override
public void paintComponent(Graphics g) {
g.setColor(new Color(CheckerBoardColorCalibration.getColorA()));
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(new Color(CheckerBoardColorCalibration.getColorB()));
int width = getWidth();
int height = getHeight();
for (int x = 0; x < width; x += 8) {
if (x % 16 == 0) {
for (int y = 0; y < height; y += 16) {
g.fillRect(x, y, 8, 8);
}
} else {
for (int y = 8; y < height; y += 16) {
g.fillRect(x, y, 8, 8);
}
}
}
if (drawBorder) {
g.setColor(Color.BLACK);
g.drawRect(0, 0, image.getWidth() + 1, image.getHeight() + 1);
}
if (zoom != 1) {
((Graphics2D) g).scale(zoom, zoom);
}
if (animationObjectList != null) {
if (((Timeline) image).isPause()) {
int selectedRow = animationObjectList.getSelectedRow();
AnimationObject sel = null;
if (selectedRow > -1) {
sel = ((TimelineEditor.AnimationObjectTableModel) animationObjectList.getModel()).getElementAt(selectedRow);
}
if (dragging != null) {
if (draggingImage == null) {
draggingImage = new BufferedImage(AnimationAccessor.getWidthInt(dragging), AnimationAccessor.getHeightInt(dragging), BufferedImage.TYPE_INT_ARGB);
draggingImage.setRGB(0, 0, draggingImage.getWidth(), draggingImage.getHeight(), AnimationAccessor.getImageMethod(dragging).modifyAlpha((byte) 110).getRGB(), 0, draggingImage.getWidth());
}
} else {
draggingImage = null;
}
if (sel != null) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.drawImage(buffer[currentFrame], 0, 0, this);
g2d.setColor(Color.BLUE);
g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2d.drawRect(AnimationAccessor.getX(sel), AnimationAccessor.getY(sel), AnimationAccessor.getWidthInt(sel), AnimationAccessor.getHeightInt(sel));
if (draggingImage != null) {
g2d.drawImage(draggingImage, dragX, dragY, null);
}
g2d.dispose();
return;
}
}
}
g.drawImage(buffer[currentFrame], 0, 0, this);
if (draggingImage != null) {
g.drawImage(draggingImage, dragX, dragY, null);
}
}
Aggregations