statusBarPanel.add(ledPanel, cl);
controller.add(statusBarPanel, BorderLayout.NORTH);
((JProgressMemory) statusBar).setLabels("CACHE", "HEAP", "");
applet.add(controller, BorderLayout.SOUTH); // config panel
panel = new JXTaskPane();
/*
* panel.setCollapsed(false);
*/
if (System.getProperty("os.name").startsWith("Linux")) {
try {
SpritesCacheManager.callback("setCollapsed", panel, new Object[]{false}, new Class[]{boolean.class});
} catch (Exception e) {
if (JXAenvUtils._debug) {
e.printStackTrace();
}
}
} else {
try {
SpritesCacheManager.callback("setExpanded", panel, new Object[]{true}, new Class[]{boolean.class});
} catch (Exception e) {
if (JXAenvUtils._debug) {
e.printStackTrace();
}
}
}
XContainer.add(panel);
// init data to config
// maps config panel
XContainer.add(modelPanel.panelMaps);
XContainer.add(modelPanel.panelFX);
// play panel
JPanel panelPlay = new JPanel(new GridLayout(2, 0), true);
final JXPanel paramFrame = new JXPanel(true);
paramFrame.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Parameters config.", TitledBorder.RIGHT, TitledBorder.TOP));
paramFrame.add(XContainer);
viewerPanel = new JPanel(new BorderLayout(), true);
viewerPanel.setPreferredSize(_iconSize);
viewerPanel.add(new JLabel(UIMessage._getIcon(UIMessage.DROPTARGET_TYPE, false)), BorderLayout.CENTER);
viewerPanel.validate();
viewerPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Let's drag'n'drop a Model here !", TitledBorder.LEFT, TitledBorder.TOP));
DnDHandler dnd = new DnDHandler(this);
dnd.addDropTarget(viewerPanel);
JScrollPane sp2 = new JScrollPane(paramFrame);
sp2.getHorizontalScrollBar().setUnitIncrement(30);
sp2.getVerticalScrollBar().setUnitIncrement(30);
splitAnimNCfg = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
splitAnimNCfg.setBottomComponent(viewerPanel);
splitAnimNCfg.setTopComponent(sp2);
splitCfgNModel.setLeftComponent(splitAnimNCfg);
splitAnimNCfg.setDividerLocation(500);
panelPlay.add(sw_state);
final AbstractAction action_play = new AbstractAction("(ALT+P)", UIMessage._getIcon(UIMessage.PLAYER_PLAY_TYPE, true)) {
public void actionPerformed(ActionEvent e) {
SortedMap<Integer, Animation> animations = character.accessSynchCache();
Animation anim = animations.get(modelPanel.currentRecordKey.get(ModelAnimBrowser.CURRENTRECORDKEY));
if (anim instanceof Animation) {
if (animator instanceof javax.swing.Timer) {
if (!animator.isRunning()) {
animator.start();
}
} else {
animator = new javax.swing.Timer((int) character.getFrameRate(), new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD) instanceof JComponent) {
JComponent comp = modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD);
comp.paintImmediately(0, 0, comp.getWidth(), comp.getHeight());
}
}
});
animator.start();
}
anim.play();
}
sw_state.setText(ModelAnimBrowser.animationState(anim instanceof Animation ? anim.getState() : -1));
}
};
panelPlay.add(new JButton(action_play));
panelPlay.add(new JButton(new AbstractAction("", UIMessage._getIcon(UIMessage.PLAYER_PAUSE_TYPE, true)) {
public void actionPerformed(ActionEvent e) {
SortedMap<Integer, Animation> animations = character.accessSynchCache();
Animation anim = animations.get(modelPanel.currentRecordKey.get(ModelAnimBrowser.CURRENTRECORDKEY));
if (anim instanceof Animation) {
anim.pause();
JComponent comp = modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD);
if (comp instanceof JComponent) {
comp.repaint();
}
if (animator instanceof javax.swing.Timer) {
if (animator.isRunning()) {
animator.stop();
}
}
}
sw_state.setText(ModelAnimBrowser.animationState(anim instanceof Animation ? anim.getState() : -1));
}
}));
panelPlay.add(new JButton(modelPanel.action_playSfx));
panelPlay.add(new JButton(new AbstractAction("", UIMessage._getIcon(UIMessage.PLAYER_PREVIOUS_TYPE, true)) {
public void actionPerformed(ActionEvent e) {
SortedMap<Integer, Animation> animations = character.accessSynchCache();
Animation anim = animations.get(modelPanel.currentRecordKey.get(ModelAnimBrowser.CURRENTRECORDKEY));
if (anim instanceof Animation) {
anim.stop();
anim.rewind();
JComponent comp = modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD);
if (comp instanceof JComponent) {
comp.repaint();
}
if (animator instanceof javax.swing.Timer) {
if (animator.isRunning()) {
animator.stop();
}
}
}
sw_state.setText(ModelAnimBrowser.animationState(anim instanceof Animation ? anim.getState() : -1));
sw_state.repaint();
}
}));
panelPlay.add(new JButton(new AbstractAction("", UIMessage._getIcon(UIMessage.PLAYER_FB_TYPE, true)) {
public void actionPerformed(ActionEvent e) {
SortedMap<Integer, Animation> animations = character.accessSynchCache();
Animation anim = animations.get(modelPanel.currentRecordKey.get(ModelAnimBrowser.CURRENTRECORDKEY));
if (anim instanceof Animation) {
anim.pause();
anim.position(Math.max(0, anim.getPosition() - 1));
JComponent comp = modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD);
if (comp instanceof JComponent) {
comp.repaint();
}
if (animator instanceof javax.swing.Timer) {
if (animator.isRunning()) {
animator.stop();
}
}
}
sw_state.setText(ModelAnimBrowser.animationState(anim instanceof Animation ? anim.getState() : -1));
sw_state.repaint();
}
}));
panelPlay.add(new JButton(new AbstractAction("", UIMessage._getIcon(UIMessage.PLAYER_FF_TYPE, true)) {
public void actionPerformed(ActionEvent e) {
SortedMap<Integer, Animation> animations = character.accessSynchCache();
Animation anim = animations.get(modelPanel.currentRecordKey.get(ModelAnimBrowser.CURRENTRECORDKEY));
if (anim instanceof Animation) {
anim.pause();
anim.position(Math.min(anim.length() - 1, anim.getPosition() + 1));
JComponent comp = modelPanel.currentRecord.get(ModelAnimBrowser.CURRENTRECORD);
if (comp instanceof JComponent) {
comp.repaint();
}
if (animator instanceof javax.swing.Timer) {
if (animator.isRunning()) {
animator.stop();
}
}
}
sw_state.setText(ModelAnimBrowser.animationState(anim instanceof Animation ? anim.getState() : -1));
}
}));
panelPlay.add(this.sw_refresh = new JButton("refresh", UIMessage._getIcon(UIMessage.REFRESH_TYPE, false)));
sw_refresh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent pe) {
final ActionEvent e = pe;
ThreadWorks.Swing.invokeLater(new Runnable() {
public void run() {
refreshSpot(e);
}
});
}
});
controller.add(panelPlay, BorderLayout.CENTER);
// character customization params
panel.add(action_switchResolution);
panel.add(modelPanel.action_setBgColor);
panel.add(new AbstractAction("load a demo/uncompleted model \n\r...") {
public void actionPerformed(ActionEvent actionEvent) {
Model s = getSpritesChar();
if (s instanceof Model) {
character = s;
action_customize.actionPerformed(actionEvent);
}
}
});
panel.add(new AbstractAction("load the cache") {
public void actionPerformed(ActionEvent e) {
Runnable r = new Runnable() {
public void run() {
SpritesCacheManager<Integer, Animation> spm = character.accessCache();
spm.addSpritesCacheListener(scl);
character.addAccessAnimationCacheListener(rLed.getSpritesCacheAdapter());
character.addAccessAnimationCacheListener(wLed.getSpritesCacheAdapter());
character.loadResource();
spm.removeSpritesCacheListener(scl);
character.removeAccessAnimationCacheListener(rLed.getSpritesCacheAdapter());
character.removeAccessAnimationCacheListener(wLed.getSpritesCacheAdapter());
}
};
works.doLater(r);
}
});
JXTaskPane panelCache = new JXTaskPane();
if (System.getProperty("os.name").startsWith("Linux")) {
try {
SpritesCacheManager.callback("setCollapsed", panelCache, new Object[]{false}, new Class[]{boolean.class});
} catch (Exception e) {
if (JXAenvUtils._debug) {
e.printStackTrace();
}
}
} else {
try {
SpritesCacheManager.callback("setExpanded", panelCache, new Object[]{true}, new Class[]{boolean.class});
} catch (Exception e) {
if (JXAenvUtils._debug) {
e.printStackTrace();
}
}
}
XContainer.add(panelCache);
panelCache.setTitle("Cache");
Action compressA;
panelCache.add(compressA = new AbstractAction("compressed sprites") {
public void actionPerformed(ActionEvent e) {
compress = (compress) ? false : true;
character.setCompressionEnabled(compress);
compress_str.setText((compress) ? "enabled" : "disabled");
}
});
refreshProps.add(new AbstractAction("compress") {
public void actionPerformed(ActionEvent e) {
character.setCompressionEnabled(compress);
}
});
panelCache.add(compress_str = new JLabel((compress) ? "enabled" : "disabled"));
panelCache.add(new AbstractAction("cache debugger") {
public void actionPerformed(ActionEvent e) {
DebugMap._getInstance().setDebuggerEnabled(!DebugMap._getInstance().isDebuggerEnabled(SpritesCacheManager.class), SpritesCacheManager.class);
debug_cache_str.setText(DebugMap._getInstance().isDebuggerEnabled(SpritesCacheManager.class) ? "enabled" : "disabled");
}
});
panelCache.add(debug_cache_str = new JLabel(DebugMap._getInstance().isDebuggerEnabled(SpritesCacheManager.class) ? "enabled" : "disabled"));
panelCache.add(new AbstractAction("render debugger") {
public void actionPerformed(ActionEvent e) {
DebugMap._getInstance().setDebugLevelEnabled(!DebugMap._getInstance().isDebugLevelEnabled(RenderingScene.DBUG_RENDER), RenderingScene.DBUG_RENDER);
debug_render_str.setText(DebugMap._getInstance().isDebugLevelEnabled(RenderingScene.DBUG_RENDER) ? "enabled" : "disabled");
}
});
panelCache.add(debug_render_str = new JLabel(DebugMap._getInstance().isDebugLevelEnabled(RenderingScene.DBUG_RENDER) ? "enabled" : "disabled"));
panel.add(modelPanel.action_openLog);
// customize frame dialog
customizeFrame = new JFrame("Customize your Model !");
customizePanel = new JPanel(new GridBagLayout(), true);