Search in sources :

Example 16 with com.codename1.ui

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

the class TimelineEditor method updatePosition.

public void updatePosition(int x, int y, AnimationObject o, boolean startingPoint) {
    AnimationObjectTableModel dl = (AnimationObjectTableModel) animationObjectList.getModel();
    int index = -1;
    for (int iter = 0; iter < animationObjectList.getModel().getRowCount(); iter++) {
        if (dl.getElementAt(iter) == o) {
            index = iter;
            break;
        }
    }
    Timeline t = (Timeline) TimelineEditor.this.res.getImage(TimelineEditor.this.name);
    AnimationObjectEditor editor = new AnimationObjectEditor(TimelineEditor.this.res, o, t.getDuration());
    if (x > -1) {
        editor.updatePosition(x, y, startingPoint);
    }
    int ok = JOptionPane.showConfirmDialog(TimelineEditor.this, editor, "Edit", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (ok == JOptionPane.OK_OPTION) {
        if (index < 0) {
            return;
        }
        dl.setElementAt(editor.getAnimationObject(), index);
        AnimationObject[] animations = new AnimationObject[t.getAnimationCount()];
        for (int iter = 0; iter < animations.length; iter++) {
            animations[iter] = t.getAnimation(iter);
        }
        animations[index] = editor.getAnimationObject();
        boolean paused = t.isPause();
        int oldTime = t.getTime();
        t = Timeline.createTimeline(getValue(duration), animations, new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
        t.setPause(paused);
        t.setTime(oldTime);
        setImage(t);
    }
}
Also used : Timeline(com.codename1.ui.animations.Timeline) AnimationObject(com.codename1.ui.animations.AnimationObject) Point(java.awt.Point)

Example 17 with com.codename1.ui

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

the class TimelineEditor method durationStateChanged.

private void durationStateChanged(javax.swing.event.ChangeEvent evt) {
    // GEN-FIRST:event_durationStateChanged
    int d = getValue(duration);
    if (d != ((Timeline) renderer.getImage()).getDuration()) {
        com.codename1.ui.animations.Timeline t = cloneCurrentTimeline();
        endTime.setText("" + d);
        timeline.setMaximum(d);
        res.setImage(name, t);
        setImage(t);
    }
}
Also used : Timeline(com.codename1.ui.animations.Timeline) Point(java.awt.Point)

Example 18 with com.codename1.ui

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

the class TimelineEditor method widthStateChanged.

// GEN-LAST:event_durationStateChanged
private void widthStateChanged(javax.swing.event.ChangeEvent evt) {
    // GEN-FIRST:event_widthStateChanged
    int w = getValue(width);
    if (w != renderer.getImage().getWidth()) {
        com.codename1.ui.animations.Timeline t = cloneCurrentTimeline();
        renderer.getImage().scaled(w, renderer.getImage().getHeight());
        res.setImage(name, t);
        setImage(t);
        renderer.revalidate();
        renderer.repaint();
    }
}
Also used : Timeline(com.codename1.ui.animations.Timeline) Point(java.awt.Point)

Example 19 with com.codename1.ui

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

the class TimelineEditor method moveDownActionPerformed.

// GEN-LAST:event_moveUpActionPerformed
private void moveDownActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_moveDownActionPerformed
    int i = animationObjectList.getSelectedRow();
    Timeline t = cloneCurrentTimeline();
    AnimationObject[] animations = new AnimationObject[t.getAnimationCount()];
    for (int iter = 0; iter < animations.length; iter++) {
        animations[iter] = t.getAnimation(iter);
    }
    AnimationObject o = animations[i + 1];
    animations[i + 1] = animations[i];
    animations[i] = o;
    Timeline nt = Timeline.createTimeline(getValue(duration), animations, new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
    nt.setPause(t.isPause());
    setImage(nt);
    moveDown.setEnabled(i < animations.length - 1);
    moveUp.setEnabled(true);
    animationObjectList.getSelectionModel().setSelectionInterval(i + 1, i + 1);
}
Also used : Timeline(com.codename1.ui.animations.Timeline) AnimationObject(com.codename1.ui.animations.AnimationObject) Point(java.awt.Point)

Example 20 with com.codename1.ui

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

the class TimelineEditor method heightStateChanged.

// GEN-LAST:event_widthStateChanged
private void heightStateChanged(javax.swing.event.ChangeEvent evt) {
    // GEN-FIRST:event_heightStateChanged
    int h = getValue(height);
    if (h != renderer.getImage().getHeight()) {
        com.codename1.ui.animations.Timeline t = cloneCurrentTimeline();
        renderer.getImage().scaled(renderer.getImage().getWidth(), h);
        res.setImage(name, t);
        setImage(t);
        renderer.revalidate();
        renderer.repaint();
    }
}
Also used : Timeline(com.codename1.ui.animations.Timeline) Point(java.awt.Point)

Aggregations

EncodedImage (com.codename1.ui.EncodedImage)26 Component (com.codename1.ui.Component)23 Point (java.awt.Point)23 IOException (java.io.IOException)23 AnimationObject (com.codename1.ui.animations.AnimationObject)22 ArrayList (java.util.ArrayList)22 BufferedImage (java.awt.image.BufferedImage)19 Hashtable (java.util.Hashtable)18 Form (com.codename1.ui.Form)15 Timeline (com.codename1.ui.animations.Timeline)15 Image (com.codename1.ui.Image)13 EditableResources (com.codename1.ui.util.EditableResources)13 File (java.io.File)13 Vector (java.util.Vector)13 TextArea (com.codename1.ui.TextArea)12 Border (com.codename1.ui.plaf.Border)12 Label (com.codename1.ui.Label)10 BorderLayout (com.codename1.ui.layouts.BorderLayout)10 UIBuilderOverride (com.codename1.ui.util.UIBuilderOverride)10 Container (com.codename1.ui.Container)9