Source code: com/arranger/jarl/shell/models/JarlAnimationContextModel.java
1 package com.arranger.jarl.shell.models;
2
3 import com.arranger.jarl.Jarl;
4 import com.arranger.jarl.shell.ShellConfig;
5 import com.arranger.jarl.base.IContext;
6
7 /**
8 * JarlAnimationContextModel created on Apr 21, 2003
9 */
10 public class JarlAnimationContextModel extends JarlContextModel {
11
12 public static final String SERIES_PREFIX = "seriesPrefix";
13
14 protected String m_seriesPrefix;
15
16 public void load(ShellConfig shellConfig) throws Exception {
17 super.load(shellConfig);
18 //m_seriesPrefix = shellConfig.getProperty(SERIES_PREFIX);
19 m_seriesPrefix = "image";
20 }
21
22 public void save(ShellConfig shellConfig) throws Exception {
23 super.save(shellConfig);
24 shellConfig.setProperty(SERIES_PREFIX, m_seriesPrefix);
25 }
26
27 public String getStatusText() {
28 StringBuffer buffer = new StringBuffer(super.getStatusText());
29 buffer.append(SERIES_PREFIX).append(": ").append(m_seriesPrefix).append(LINE_SEP);
30 return buffer.toString();
31 }
32
33 public String getSeriesPrefix() {
34 return m_seriesPrefix;
35 }
36
37 public void setSeriesPrefix(String seriesPrefix) {
38 m_seriesPrefix = seriesPrefix;
39 }
40
41 public void renderAnimation() {
42 m_lastThrowable = null;
43
44 new Thread() {
45 public void run() {
46 //raise event
47 raiseEvent(RENDER_PREPARING);
48
49 try {
50 m_jarl = new Jarl();
51 IContext context = m_jarl.getContext();
52 context.addStatusListener(m_statusListener);
53 raiseEvent(RENDER_PROCESSING_CONFIG);
54
55 //prior to init
56 m_jarl.init(m_currentConfig);
57
58 //fire initialized
59 raiseEvent(INITIALIZED);
60
61 //override dimensions
62 if (m_dimension != null) {
63 context.setWidth((int) m_dimension.getWidth());
64 context.setHeight((int) m_dimension.getHeight());
65 }
66
67 m_jarl.render(m_currentOutputDir, m_seriesPrefix);
68
69 //completed
70 raiseEvent(RENDER_COMPLETED);
71 } catch (Throwable t) {
72 m_lastThrowable = t;
73 raiseEvent(ERROR);
74 m_statusListener.onError(t);
75 }
76 }
77 }.start();
78 }
79 }