Java Code Examples for com.alee.utils.SwingUtils#frameRateDelay()

The following examples show how to use com.alee.utils.SwingUtils#frameRateDelay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShadeLayer.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setVisible ( final boolean visible )
{
    super.setVisible ( visible );
    if ( visible )
    {
        if ( animator != null )
        {
            animator.stop ();
        }
        if ( animate )
        {
            opacity = 0;
            animator = new WebTimer ( "ShadeLayer.fadeIn", SwingUtils.frameRateDelay ( 24 ), new ActionListener ()
            {
                @Override
                public void actionPerformed ( final ActionEvent e )
                {
                    if ( opacity < 100 )
                    {
                        opacity += 25;
                        ShadeLayer.this.repaint ();
                    }
                    else
                    {
                        animator.stop ();
                    }
                }
            } );
            animator.start ();
        }
        else
        {
            opacity = 100;
            ShadeLayer.this.repaint ();
        }
    }
}
 
Example 2
Source File: WebFilePlate.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
protected void performPlateRemoval ( final ActionEvent ae, final boolean animate )
{
    if ( animator != null && animator.isRunning () )
    {
        animator.stop ();
    }
    if ( animate )
    {
        animator = new WebTimer ( "WebFilePlate.fadeOutTimer", SwingUtils.frameRateDelay ( 24 ), new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                opacity -= 0.1f;
                if ( opacity > 0f )
                {
                    WebFilePlate.this.repaint ();
                }
                else
                {
                    // Remove file plate
                    removeFromParent ();

                    // Stopping animation
                    animator.stop ();
                }
            }
        } );
        animator.start ();
    }
    else
    {
        // Remove file plate
        removeFromParent ();
    }

    // Firing close listeners
    fireCloseActionPerformed ( ae );
}
 
Example 3
Source File: DefaultTransitionEffect.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default methods
 */

@Override
public long getAnimationDelay ()
{
    return SwingUtils.frameRateDelay ( 36 );
}
 
Example 4
Source File: WebFadeDialog.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
public WebFadeDialog ()
{
    super ();

    updater = new WebTimer ( "WebFadeDialog.updater", SwingUtils.frameRateDelay ( 48 ), this );
    addWindowFocusListener ( this );
    addWindowListener ( this );
}
 
Example 5
Source File: WebSwitch.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initializes switch animator.
 */
protected void createAnimator ()
{
    animator = new WebTimer ( "WebSwitch.animator", SwingUtils.frameRateDelay ( 60 ), new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            // Updating gripper location
            gripperLocation = gripperLocation + ( selected ? 0.1f : -0.1f );

            // Checking what to do
            if ( selected && gripperLocation >= 1f || !selected && gripperLocation <= 0f )
            {
                // Updating final gripper and view
                gripperLocation = selected ? 1f : 0f;
                revalidate ();

                // Finishing animation
                animating = false;
                animator.stop ();
            }
            else
            {
                // Updating view
                revalidate ();
            }
        }
    } );
}
 
Example 6
Source File: SlidingLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
public void slideIn ()
{
    if ( animator != null && animator.isRunning () )
    {
        animator.stop ();
    }

    slideY = 0;
    animator = new WebTimer ( "SlidingLayout.slideInTimer", SwingUtils.frameRateDelay ( 36 ), new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            if ( slideY < height )
            {
                slideY += slideSpeed;
                container.revalidate ();
            }
            else
            {
                slideY = height;
                animator.stop ();
            }
        }
    } );
    animator.start ();
}
 
Example 7
Source File: SlidingLayout.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
public void slideOut ()
{
    if ( animator != null && animator.isRunning () )
    {
        animator.stop ();
    }

    slideY = height;
    animator = new WebTimer ( "SlidingLayout.slideOutTimer", SwingUtils.frameRateDelay ( 36 ), new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            if ( slideY > 0 )
            {
                slideY -= slideSpeed;
                container.revalidate ();
            }
            else
            {
                slideY = 0;
                animator.stop ();
            }
        }
    } );
    animator.start ();
}
 
Example 8
Source File: ScrollBarPainter.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets whether scroll bar thumb is in rollover state or not.
 *
 * @param rollover whether scroll bar thumb is in rollover state or not
 */
public void setRollover ( final boolean rollover )
{
    if ( this.rollover != rollover )
    {
        this.rollover = rollover;
        if ( animated )
        {
            if ( rollover )
            {
                if ( rolloverAnimator != null )
                {
                    rolloverAnimator.stop ();
                }
                repaintThumb ();
            }
            else
            {
                if ( rolloverAnimator == null )
                {
                    rolloverAnimator = new WebTimer ( SwingUtils.frameRateDelay ( 36 ), new ActionListener ()
                    {
                        @Override
                        public void actionPerformed ( @NotNull final ActionEvent e )
                        {
                            if ( rolloverState > 0f )
                            {
                                rolloverState -= 0.1f;
                                repaintThumb ();
                            }
                            else
                            {
                                rolloverState = 0f;
                                rolloverAnimator.stop ();
                            }
                        }
                    } );
                }
                rolloverState = 1f;
                rolloverAnimator.start ();
            }
        }
        else
        {
            rolloverState = rollover ? 1f : 0f;
            repaintThumb ();
        }
    }
}