Java Code Examples for org.jdesktop.animation.timing.Animator#setAcceleration()

The following examples show how to use org.jdesktop.animation.timing.Animator#setAcceleration() . 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: MotionDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void configureAnimations() {
    Animator leftAnimator = new Animator(200);
    leftAnimator.setAcceleration(0.3f);
    leftAnimator.setDeceleration(0.2f);
    leftAnimator.addTarget(new PropertySetter(
            saveButton, "location", new Point(16, 16)));
    leftAnimator.addTarget(new PropertySetter(
            openButton, "location", new Point(16, openButton.getY())));
    leftAnimator.addTarget(new PropertySetter(
            textArea, "location",
            new Point(16 + saveButton.getWidth() + 6, 16)));
    
    ActionTrigger.addTrigger(leftLayoutButton, leftAnimator);
    
    Animator rightAnimator = new Animator(200);
    rightAnimator.setAcceleration(0.3f);
    rightAnimator.setDeceleration(0.2f);
    rightAnimator.addTarget(new PropertySetter(
            saveButton, "location", saveButton.getLocation()));
    rightAnimator.addTarget(new PropertySetter(
            openButton, "location", openButton.getLocation()));
    rightAnimator.addTarget(new PropertySetter(
            textArea, "location", textArea.getLocation()));
    
    ActionTrigger.addTrigger(rightLayoutButton, rightAnimator);
}
 
Example 2
Source File: AnimatingSplitPane.java    From Darcula with Apache License 2.0 6 votes vote down vote up
public void setExpanded(boolean expanded) {
    if (expanded != firstExpanded) {
        
        if (!firstExpanded) {
            lastDividerLocation = getDividerLocation();
        }
        
        this.firstExpanded = expanded;

        Animator animator = new Animator(500, new PropertySetter(this, "dividerLocation",
               getDividerLocation(), (expanded? getHeight() : lastDividerLocation)));
        
        animator.setStartDelay(10);
        animator.setAcceleration(.2f);
        animator.setDeceleration(.3f);
        animator.start();            
    }
}
 
Example 3
Source File: AnimatingSplitPane.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public void setExpanded(boolean expanded) {
    if (expanded != firstExpanded) {
        
        if (!firstExpanded) {
            lastDividerLocation = getDividerLocation();
        }
        
        this.firstExpanded = expanded;

        Animator animator = new Animator(500, new PropertySetter(this, "dividerLocation",
               getDividerLocation(), (expanded? getHeight() : lastDividerLocation)));
        
        animator.setStartDelay(10);
        animator.setAcceleration(.2f);
        animator.setDeceleration(.3f);
        animator.start();            
    }
}
 
Example 4
Source File: Stacker.java    From Darcula with Apache License 2.0 6 votes vote down vote up
/**
 * Fades out and removes the current message component
 */
public void hideMessageLayer() {
    if (messageLayer != null && messageLayer.isShowing()) {
        Animator animator = new Animator(500,
                new PropertySetter(messageAlpha, "alpha", messageAlpha.getAlpha(), 0.0f) {
                    public void end() {
                        remove(messageLayer);
                        revalidate();
                    }
                });
        animator.setStartDelay(300);
        animator.setAcceleration(.2f);
        animator.setDeceleration(.5f);
        animator.start();
    }
}
 
Example 5
Source File: Stacker.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Fades out and removes the current message component
 */
public void hideMessageLayer() {
    if (messageLayer != null && messageLayer.isShowing()) {
        Animator animator = new Animator(500,
                new PropertySetter(messageAlpha, "alpha", messageAlpha.getAlpha(), 0.0f) {
                    public void end() {
                        remove(messageLayer);
                        revalidate();
                    }
                });
        animator.setStartDelay(300);
        animator.setAcceleration(.2f);
        animator.setDeceleration(.5f);
        animator.start();
    }
}
 
Example 6
Source File: Stacker.java    From littleluck with Apache License 2.0 6 votes vote down vote up
/**
 * Fades out and removes the current message component
 */
public void hideMessageLayer() {
    if (messageLayer != null && messageLayer.isShowing()) {
        Animator animator = new Animator(500,
                new PropertySetter(messageAlpha, "alpha", messageAlpha.getAlpha(), 0.0f) {
                    public void end() {
                        remove(messageLayer);
                        revalidate();
                    }
                });
        animator.setStartDelay(300);
        animator.setAcceleration(.2f);
        animator.setDeceleration(.5f);
        animator.start();
    }
}
 
Example 7
Source File: RelayoutFunctionGraphJob.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected Animator createAnimator() {

	initializeVertexLocations();
	clearLocationCache();

	if (!useAnimation) {
		return null;
	}

	updateOpacity(0);

	Animator newAnimator =
		PropertySetter.createAnimator(duration, this, "percentComplete", 0.0, 1.0);
	newAnimator.setAcceleration(0f);
	newAnimator.setDeceleration(0.8f);

	return newAnimator;
}
 
Example 8
Source File: IntroPanel.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public void slideTextIn() {
    Animator animator = new Animator(800, 
            new PropertySetter(introText, "x", getWidth(), 30));
    animator.setStartDelay(800);
    animator.setAcceleration(.2f);
    animator.setDeceleration(.5f);
    animator.start();
}
 
Example 9
Source File: DemoPanel.java    From Darcula with Apache License 2.0 5 votes vote down vote up
public DemoPanel(Demo demo) {
    this.demo = demo;
    setLayout(new BorderLayout());
    // remind(aim): how to access resourceMap?
    //resourceMap = getContext().getResourceMap();

    LoadAnimationPanel loadAnimationPanel = new LoadAnimationPanel();

    add(loadAnimationPanel);
    loadAnimationPanel.setAnimating(true);

    LoadedDemoPanel demoPanel = new LoadedDemoPanel(demo);

    try {
        loadAnimationPanel.setAnimating(false);
        Animator fadeOutAnimator = new Animator(400,
                new FadeOut(DemoPanel.this,
                        loadAnimationPanel, demoPanel));
        fadeOutAnimator.setAcceleration(.2f);
        fadeOutAnimator.setDeceleration(.3f);
        Animator fadeInAnimator = new Animator(400,
                new PropertySetter(DemoPanel.this, "alpha", 0.3f, 1.0f));
        TimingTrigger.addTrigger(fadeOutAnimator, fadeInAnimator, TimingTriggerEvent.STOP);
        fadeOutAnimator.start();
    } catch (Exception ignore) {
        System.err.println(ignore);
        ignore.printStackTrace();
    }
}
 
Example 10
Source File: IntroPanel.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public void slideTextIn() {
    Animator animator = new Animator(800, 
            new PropertySetter(introText, "x", getWidth(), 30));
    animator.setStartDelay(800);
    animator.setAcceleration(.2f);
    animator.setDeceleration(.5f);
    animator.start();
}
 
Example 11
Source File: DemoPanel.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public DemoPanel(Demo demo) {
    this.demo = demo;
    setLayout(new BorderLayout());
    // remind(aim): how to access resourceMap?
    //resourceMap = getContext().getResourceMap();

    LoadAnimationPanel loadAnimationPanel = new LoadAnimationPanel();

    add(loadAnimationPanel);
    loadAnimationPanel.setAnimating(true);

    LoadedDemoPanel demoPanel = new LoadedDemoPanel(demo);

    try {
        loadAnimationPanel.setAnimating(false);
        Animator fadeOutAnimator = new Animator(400,
                new FadeOut(DemoPanel.this,
                        loadAnimationPanel, demoPanel));
        fadeOutAnimator.setAcceleration(.2f);
        fadeOutAnimator.setDeceleration(.3f);
        Animator fadeInAnimator = new Animator(400,
                new PropertySetter(DemoPanel.this, "alpha", 0.3f, 1.0f));
        TimingTrigger.addTrigger(fadeOutAnimator, fadeInAnimator, TimingTriggerEvent.STOP);
        fadeOutAnimator.start();
    } catch (Exception ignore) {
        System.err.println(ignore);
        ignore.printStackTrace();
    }
}
 
Example 12
Source File: MorphingDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void previous() {
    Animator animator = new Animator(500);
    animator.addTarget(new PropertySetter(this, "alpha", 0.0f));
    animator.setAcceleration(0.2f);
    animator.setDeceleration(0.4f);
    animator.start();
}
 
Example 13
Source File: IntroPanel.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public void slideTextOut() {
    Animator animator = new Animator(600, 
            new PropertySetter(introText, "x", introText.getX(), -introText.getWidth()));
    animator.setStartDelay(10);
    animator.setAcceleration(.5f);
    animator.setDeceleration(.2f);
    animator.start();        
}
 
Example 14
Source File: DemoPanel.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public DemoPanel(Demo demo) {
    this.demo = demo;
    setLayout(new BorderLayout());
    // remind(aim): how to access resourceMap?
    //resourceMap = getContext().getResourceMap();

    LoadAnimationPanel loadAnimationPanel = new LoadAnimationPanel();

    add(loadAnimationPanel);
    loadAnimationPanel.setAnimating(true);

    LoadedDemoPanel demoPanel = new LoadedDemoPanel(demo);

    try {
        loadAnimationPanel.setAnimating(false);
        Animator fadeOutAnimator = new Animator(400,
                new FadeOut(DemoPanel.this,
                        loadAnimationPanel, demoPanel));
        fadeOutAnimator.setAcceleration(.2f);
        fadeOutAnimator.setDeceleration(.3f);
        Animator fadeInAnimator = new Animator(400,
                new PropertySetter(DemoPanel.this, "alpha", 0.3f, 1.0f));
        TimingTrigger.addTrigger(fadeOutAnimator, fadeInAnimator, TimingTriggerEvent.STOP);
        fadeOutAnimator.start();
    } catch (Exception ignore) {
        System.err.println(ignore);
        ignore.printStackTrace();
    }
}
 
Example 15
Source File: CenterAnimation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public Animator createAnimator() {
	Animator newAnimator =
		PropertySetter.createAnimator(duration, this, "percentComplete", 0.0, 1.0);
	newAnimator.setAcceleration(0f);
	newAnimator.setDeceleration(0.8f);

	return newAnimator;
}
 
Example 16
Source File: MergeVertexFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Animator createAnimator() {
	initializeVertexLocations();

	if (!useAnimation) {
		return null;
	}

	Animator newAnimator =
		PropertySetter.createAnimator(DURATION, this, "percentComplete", 0.0, 1.0);
	newAnimator.setAcceleration(0f);
	newAnimator.setDeceleration(0.8f);
	return newAnimator;
}
 
Example 17
Source File: EdgeHoverAnimator.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Animator createAnimator() {
	if (!useAnimation) {
		return null;
	}

	Animator newAnimator =
		PropertySetter.createAnimator(DURATION, this, "nextPaint", 0, DURATION);
	newAnimator.setAcceleration(0.0f);
	newAnimator.setDeceleration(0.8f);
	return newAnimator;
}
 
Example 18
Source File: TwinkleVertexAnimator.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Animator createAnimator() {
	if (!useAnimation) {
		return null;
	}

	startEmphasis = vertex.getEmphasis();

	Animator newAnimator = PropertySetter.createAnimator(500, this, "currentEmphasis", 0.0, .5);
	newAnimator.setAcceleration(0.0f);
	newAnimator.setDeceleration(0.0f);
	newAnimator.setRepeatCount(4); // up and down twice
	newAnimator.setRepeatBehavior(RepeatBehavior.REVERSE); // emphasize the first pass, then de-emphasizes
	return newAnimator;
}
 
Example 19
Source File: FadingDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void previous() {
    Animator animator = new Animator(1000);
    animator.addTarget(new PropertySetter(this, "alpha", 0.0f));
    animator.setAcceleration(0.2f);
    animator.setDeceleration(0.4f);
    animator.start();
}
 
Example 20
Source File: MoveViewAnimatorFunctionGraphJob.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Animator createAnimator() {
	destination = createDestination();

	RenderContext<V, E> renderContext = viewer.getRenderContext();
	multiLayerTransformer = renderContext.getMultiLayerTransformer();

	if (!useAnimation) {
		return null;
	}

	double offsetX = destination.getX();
	double offsetY = destination.getY();
	double durationX = Math.abs(offsetX / PIXELS_PER_SECOND);
	double durationY = Math.abs(offsetY / PIXELS_PER_SECOND);

	int totalFramesX = (int) (durationX * FRAME_PER_SECOND);
	int totalFramesY = (int) (durationY * FRAME_PER_SECOND);

	int mostFrames = Math.max(totalFramesX, totalFramesY);
	mostFrames = Math.min(mostFrames, 15); // limit the time to something reasonable
	totalFrames = Math.max(1, mostFrames); // at least one frame

	double timeInSeconds = (double) totalFrames / (double) FRAME_PER_SECOND;
	int duration = (int) Math.round(timeInSeconds * 1000); // put into millis
	
	Point2D start = new Point2D.Double();
	Animator newAnimator =
		PropertySetter.createAnimator(duration, this, "offset", start, destination);
	newAnimator.setAcceleration(0.2f);
	newAnimator.setDeceleration(0.8f);

	return newAnimator;
}