3)循环读取指定图片,由于是阻塞队列,所以当队列满的时候线程会自动阻塞.
public void run() {
int id = 0;
try {
while (true) {
String path = resources[id];
InputStream is = getClass().getResourceAsStream(path);
if (is != null) {
Image image = new Image(is, width, height, true, true);
if (!image.isError()) {
images.put(image);
}
}
id++;
if (id >= resources.length) {
id = 0;
}
}
} catch (Exception e) {
} finally {
if (!cancelled) {
try {
images.put(eof);
} catch (InterruptedException e) {
}
}
}
}
class LengthTransition extends Transition {
Arc arc;
public LengthTransition(Duration d, Arc arc) {
this.arc = arc;
setCycleDuration(d);
}
@Override
protected void interpolate(double d) {
arc.setLength(d * 360);
}
}
group.setBlendMode(BlendMode.SRC_OVER);
next.setBlendMode(BlendMode.SRC_ATOP);
以及之前那张图片的淡出特效:
FadeTransition ft = new FadeTransition(Duration.seconds(0.2), mask2);
最后同时执行这两个特效:
ParallelTransition pt = new ParallelTransition(lt, ft);