use of com.codename1.ui.animations.Timeline in project CodenameOne by codenameone.
the class TimelineEditor method pauseActionPerformed.
// GEN-LAST:event_playActionPerformed
private void pauseActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_pauseActionPerformed
Timeline t = (Timeline) renderer.getImage();
t.setPause(true);
play.setEnabled(true);
pause.setEnabled(false);
if (refreshTimeline != null) {
refreshTimeline.stop();
refreshTimeline = null;
}
}
use of com.codename1.ui.animations.Timeline in project CodenameOne by codenameone.
the class ResourceEditorView method isInUse.
/**
* Returns true if the given image is used by a theme or timeline animation,
* false otherwise.
*/
private boolean isInUse(String imageName) {
Object multi = loadedResources.getResourceObject(imageName);
if (multi instanceof EditableResources.MultiImage) {
EditableResources.MultiImage m = (EditableResources.MultiImage) multi;
for (com.codename1.ui.Image i : m.getInternalImages()) {
if (isInUse(i)) {
return true;
}
}
return false;
}
com.codename1.ui.Image resourceValue = loadedResources.getImage(imageName);
return isInUse(resourceValue);
}
use of com.codename1.ui.animations.Timeline in project CodenameOne by codenameone.
the class ResourceEditorView method initImagesComboBox.
/**
* Creates a sorted image combo box that includes image previews. The combo box
* can be searched by typing a letter even when images are used for the values...
*/
public static void initImagesComboBox(JComboBox cb, final EditableResources res, boolean asString, final boolean includeNull, boolean blockTimelines) {
String[] imgs = res.getImageResourceNames();
if (blockTimelines) {
List<String> nonT = new ArrayList<String>();
for (String c : imgs) {
if (!(res.getImage(c) instanceof Timeline)) {
nonT.add(c);
}
}
imgs = new String[nonT.size()];
nonT.toArray(imgs);
}
final String[] images = imgs;
Arrays.sort(images, String.CASE_INSENSITIVE_ORDER);
if (asString) {
if (includeNull) {
String[] n = new String[images.length + 1];
System.arraycopy(images, 0, n, 1, images.length);
cb.setModel(new DefaultComboBoxModel(n));
} else {
cb.setModel(new DefaultComboBoxModel(images));
}
cb.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
boolean n = false;
if (value == null) {
value = "[null]";
n = true;
}
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (!n) {
setIcon(new CodenameOneImageIcon(res.getImage((String) value), 24, 24));
} else {
setIcon(null);
}
return this;
}
});
} else {
int offset = 0;
com.codename1.ui.Image[] arr;
if (includeNull) {
arr = new com.codename1.ui.Image[images.length + 1];
offset++;
} else {
arr = new com.codename1.ui.Image[images.length];
}
for (String c : images) {
arr[offset] = res.getImage(c);
offset++;
}
cb.setModel(new DefaultComboBoxModel(arr));
cb.setKeySelectionManager(new JComboBox.KeySelectionManager() {
private String current;
private long lastPress;
public int selectionForKey(char aKey, ComboBoxModel aModel) {
long t = System.currentTimeMillis();
aKey = Character.toLowerCase(aKey);
if (t - lastPress < 800) {
current += aKey;
} else {
current = "" + aKey;
}
lastPress = t;
for (int iter = 0; iter < images.length; iter++) {
if (images[iter].toLowerCase().startsWith(current)) {
if (includeNull) {
return iter + 1;
}
return iter;
}
}
return -1;
}
});
cb.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
com.codename1.ui.Image i = (com.codename1.ui.Image) value;
if (value == null) {
value = "[null]";
} else {
value = res.findId(value);
}
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (i != null) {
setIcon(new CodenameOneImageIcon(i, 24, 24));
} else {
setIcon(null);
}
return this;
}
});
}
}
use of com.codename1.ui.animations.Timeline in project CodenameOne by codenameone.
the class CodenameOneImageRenderer method mouseClicked.
public void mouseClicked(MouseEvent e) {
Timeline t = (Timeline) image;
AnimationObject selection = t.getAnimationAt(e.getX(), e.getY());
// editing
if (selection == null) {
animationObjectList.clearSelection();
} else {
if (e.getClickCount() == 2) {
selectValue(selection);
MouseListener[] ls = animationObjectList.getListeners(MouseListener.class);
for (MouseListener l : ls) {
l.mouseClicked(e);
}
} else {
// selection
selectValue(selection);
}
}
repaint();
}
use of com.codename1.ui.animations.Timeline in project CodenameOne by codenameone.
the class CodenameOneImageRenderer method mouseReleased.
public void mouseReleased(MouseEvent e) {
Timeline t = (Timeline) image;
if (dragging != null && t.isPause()) {
// if this is a right mouse button update the source position
editor.updatePosition(e.getX(), e.getY(), dragging, BaseForm.isRightClick(e));
dragging = null;
}
repaint();
}
Aggregations