Java Multiple slide switching special effects (Classic)

Source: Internet
Author: User

Function implementation:

1. image loading ImageLoader implementation:

1) Use a blocking queue to store images: BlockingQueue images = new ArrayBlockingQueue <> (2 );

2) The Image queue ends with the Image eof: Image eof = new WritableImage (1, 1 );

3) read the specified image cyclically. Because the queue is blocked, the thread will automatically block when the queue is full.

Copy codeThe Code is as follows: 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 (! Canceled ){
Try {
Images. put (eof );
} Catch (InterruptedException e ){
}
}
}
}

2. The special effect is implemented using an arc switching image as an example. First, define the special effect of LengthTransition change: Set the change time, and the relationship between the number of radians and time.

Copy codeThe Code is as follows: 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 );
}
}

Then set the image stack effect:

Copy codeThe Code is as follows: group. setBlendMode (BlendMode. SRC_OVER );
Next. setBlendMode (BlendMode. SRC_ATOP );
And the fade-out effect of the previous image:

FadeTransition ft = new FadeTransition (Duration. seconds (0.2), mask2 );
Finally, execute these two effects at the same time:

ParallelTransition pt = new ParallelTransition (lt, ft );

:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.