25 |
|
|
26 |
directly, let us have a new API which is:: |
directly, let us have a new API which is:: |
27 |
|
|
28 |
anim.animate() , |
anim.animate() |
29 |
anim.switchVS() or |
anim.switchVS() |
30 |
anim.rerenderVS() |
anim.rerenderVS() |
31 |
|
|
32 |
where ``anim`` is an instance of ``AnimationAPI``. |
where ``anim`` is an instance of ``AnimationAPI``. |
77 |
'animation with time', '"animation" with very short time' or 'reuse |
'animation with time', '"animation" with very short time' or 'reuse |
78 |
VobScene'. |
VobScene'. |
79 |
|
|
80 |
|
ISSUE: What package should this interface be in? |
81 |
|
libvob.view doesn't feel right - this isn't a view. How about |
82 |
|
libvob proper? |
83 |
|
|
84 |
Current State |
RESOLVED: The author of this PEG doesn't want to overload |
85 |
============= |
the count of files in org.nongnu.libvob but is satisfied |
86 |
|
if the author of libvob wants the interface to be in there. |
87 |
|
|
88 |
|
|
89 |
|
Introduction |
90 |
|
============ |
91 |
|
|
92 |
We heavily use the ``demo framework`` in our applications, see |
We heavily use the ``demo framework`` in our applications, see |
93 |
vob.putil.demo. ``Demo framework`` basicly is libvob using one window. |
vob.putil.demo. ``Demo framework`` basicly is libvob using one window; |
94 |
|
including dynamic realoading of jython source and switching between demo scenes. |
95 |
One window is obivious to get more testing with irregular edge. |
One window is obivious to get more testing with irregular edge. |
96 |
|
|
97 |
Animation seen in window is made with one or two VobScenes. |
The animation seen in the window is made with one or two VobScenes. |
98 |
Although, VobScene is very sticky with *one* window we have no interfaces |
Although, VobScene is very close to *one* window we have no interfaces |
99 |
to handle them per *one* window. |
to handle them per *one* window. |
100 |
|
|
101 |
This PEG tries to be a solution to provide an interface |
This PEG tries to be a solution to provide an interface |
116 |
**No other objects are allowed to call the above named UpdateManager |
**No other objects are allowed to call the above named UpdateManager |
117 |
methods in the source tree, except small demos.** |
methods in the source tree, except small demos.** |
118 |
|
|
119 |
AnimationAPI should be implemented in ``demo framework``. |
WindowAnimation should be implemented with java and |
120 |
|
used in ``demo framework``. |
121 |
|
|
122 |
For safety of event handling, possibility to check if |
For safety of event handling, possibility to check if |
123 |
VobScene has changed is added into the animation layer. |
VobScene has changed, i.e. screen has updated, |
124 |
|
is added into the animation layer. |
125 |
For example if we need to wait until something draws |
For example if we need to wait until something draws |
126 |
on screen, all events before that needs to be passed trough. |
on screen, all events before we have the correct |
127 |
|
screen needs to be passed trough without handling. |
|
Debugging of animation API should use java's stacktrace to |
|
|
print correct lines and classes. |
|
128 |
|
|
129 |
|
Implementations of WindowAnimation should print out stack |
130 |
|
traces when debugging is enabled, to allow the programmer |
131 |
|
to see how the updates were initiated. |
132 |
|
|
133 |
Let's define the following interface: :: |
Let's define the following interface: :: |
134 |
|
|
135 |
package org.nongnu.libvob.view; |
package org.nongnu.libvob; |
136 |
import org.nongnu.libvob.VobScene; |
import org.nongnu.libvob.VobScene; |
137 |
|
|
138 |
/** An interface for providing common tool set for animation |
/** An interface for providing common tool set for animation |
142 |
* <p> |
* <p> |
143 |
* This interface sets strict policy for several routines: |
* This interface sets strict policy for several routines: |
144 |
* <OL><LI> |
* <OL><LI> |
145 |
* There must not be other place to get previous/last |
* The previously shown vobscene should not be stored |
146 |
* VobScene. If a VobScene is saved in other place than |
* anywhere else. If a VobScene is saved in other place than |
147 |
* here, it could prevent the GC to clean old VobScenes. |
* here, it could prevent the GC to clean old VobScenes. |
148 |
* By using only the correct 'previous' VobScene |
* By using only the correct 'previous' VobScene |
149 |
* program can not get the famous 'invalid coorsys' bug. |
* program can not get the famous 'invalid coorsys' bug. |
150 |
* </LI> |
* </LI> |
151 |
* <LI> |
* <LI> |
152 |
* There must not be objects that call low-level animation |
* No other objects should call the low-level animation |
153 |
* interface to change animation state. This could prevent |
* interface in AbstractUpdateManager. This could prevent |
154 |
* proper animation, e.g., by setting no animation even when |
* proper animation, e.g., by setting no animation even when |
155 |
* animation should be done. |
* animation should be done. |
156 |
* </LI></OL> |
* </LI></OL> |
157 |
*/ |
*/ |
158 |
public interface AnimationAPI { |
public interface WindowAnimation { |
159 |
|
|
160 |
|
|
161 |
/** Animate to next VobScene by creating a new VobScene. |
/** Animate to next VobScene by creating a new VobScene. |
162 |
|
* The interpolation time between current screen and VobScene |
163 |
|
* (screen after animations) in future is set via AbstractUpdateManager. |
164 |
|
* @see AbstractUpdateManager |
165 |
|
* <p> |
166 |
|
* Example: When you want to interpolate a red box from rigth to left |
167 |
|
* you could do it, like: |
168 |
|
* <pre> |
169 |
|
* class Scene: |
170 |
|
* """ Example scene to animate red box from left to rigth and backwards. |
171 |
|
* """ |
172 |
|
* def __init__(self, animation): |
173 |
|
* self.anim = animation |
174 |
|
* self.keyHit = 0 |
175 |
|
* self.left = 100 |
176 |
|
* self.right = 500 |
177 |
|
* def scene(self, vs): |
178 |
|
* if self.keyHit == 1: |
179 |
|
* cs = vs.orthoBoxCS(0, "RedBox", 0,self.left,50, 1,1, 100,100) |
180 |
|
* else: |
181 |
|
* cs = vs.orthoBoxCS(0, "RedBox", 0,self.right,50, 1,1, 100,100) |
182 |
|
* vs.put(vob.vobs.RectBgVob(java.awt.Color.red), cs) |
183 |
|
* def key(self, key): |
184 |
|
* self.keyHit = 1 - self.keyHit |
185 |
|
* self.anim.animate() |
186 |
|
* </pre> |
187 |
*/ |
*/ |
188 |
void animate(); |
void animate(); |
189 |
|
|
201 |
* so e.g., any drag actions should be implemented to use |
* so e.g., any drag actions should be implemented to use |
202 |
* this method. |
* this method. |
203 |
* <p> |
* <p> |
204 |
* Implementation notice: |
* Implementation note: |
205 |
* Even though new coordinate systems can be created, the current |
* Even though new coordinate systems can be created, the current |
206 |
* coorder implementation uses finite range of coordinate systems. |
* coorder implementation uses finite range of coordinate systems. |
207 |
* Creating too many new coordinate systems leads to |
* Creating too many new coordinate systems leads to |
213 |
|
|
214 |
/** Get the current visible vobscene. |
/** Get the current visible vobscene. |
215 |
* <p> |
* <p> |
216 |
* Prgogramming notice: When programming, you create vobscenes |
* Prgogramming note: When programming, you create vobscenes |
217 |
* for future usually, so this returns the obivious previous |
* for future usually, so this returns the current visible |
218 |
* vobscene, e.g., to set coordinate system parameters. |
* vobscene, e.g., to set coordinate system parameters or |
219 |
|
* use activated coordinate systems to catch mouse events. |
220 |
*/ |
*/ |
221 |
VobScene getCurrentVS(); |
VobScene getCurrentVS(); |
222 |
|
|
223 |
|
|
224 |
/** Returns true if VobScene has changed from previous |
/** Returns true if VobScene has changed since previous |
225 |
* <code>animate</code> or <code>switchVS</code> method. |
* <code>animate</code> or <code>switchVS</code> method. |
226 |
* <p> |
* <p> |
227 |
* Programming notice: |
* Programming note: |
228 |
* In some situations when handling the events the programmer |
* In some situations when handling the events the programmer |
229 |
* needs to know whether the VobScene is new or the still the old one, |
* needs to know whether the VobScene is new or the still the old one, |
230 |
* e.g., when waiting the screen to update to move some new vob you |
* e.g., when waiting the screen to update to move some new vob you |