Java Code Examples for org.pushingpixels.trident.Timeline#setEase()

The following examples show how to use org.pushingpixels.trident.Timeline#setEase() . 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: AnnotatedCardPanel.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
private void showPopup() {
    if (MagicAnimations.isOn(AnimationFx.CARD_FADEIN)) {
        if (opacity == 0f) {
            fadeInTimeline = new Timeline();
            fadeInTimeline.setDuration(200);
            fadeInTimeline.setEase(new Spline(0.8f));
            fadeInTimeline.addPropertyToInterpolate(
                Timeline.property("opacity")
                .on(this)
                .from(0.0f)
                .to(1.0f));
            fadeInTimeline.play();
        } else {
            opacity = 1.0f;
        }
    } else {
        opacity = 1.0f;
    }
    setVisible(true);
}
 
Example 2
Source File: MagicInfoWindow.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setVisible(boolean aFlag) {
    super.setVisible(aFlag);
    if (ImageHelper.isWindowTranslucencySupported()) {
        if (!aFlag) {
            setOpacity(0f);
        } else {
            fadeInTimeline = new Timeline();
            fadeInTimeline.setDuration(200);
            fadeInTimeline.setEase(new Spline(0.8f));
            fadeInTimeline.addPropertyToInterpolate(
                    Timeline.property("opacity")
                    .on(this)
                    .from(0.0f)
                    .to(1.0f));
            fadeInTimeline.play();
        }
    }
}
 
Example 3
Source File: TaskBarFrame.java    From MercuryTrade with MIT License 5 votes vote down vote up
private void initCollapseAnimations(String state) {
    collapseAnimation = new Timeline(this);
    switch (state) {
        case "expand": {
            collapseAnimation.addPropertyToInterpolate("width", this.getWidth(), MAX_WIDTH);
            break;
        }
        case "collapse": {
            collapseAnimation.addPropertyToInterpolate("width", this.getWidth(), MIN_WIDTH);
        }
    }
    collapseAnimation.setEase(new Spline(1f));
    collapseAnimation.setDuration(150);
}
 
Example 4
Source File: JLabelStatusObserver.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Override
public void updateStatus(String text, int level) {
  label.setText(text);
  if (level == LEVEL_NORMAL) {
    label.setBackground(colorNormal);
  } else {
    Color blinkColor = (level == LEVEL_WARNING) ? colorWarning : colorError;
    Timeline timeline = new Timeline(label);
    timeline.setDuration(200);
    timeline.setEase(new Sine());
    timeline.addPropertyToInterpolate("background", colorNormal, blinkColor);
    timeline.playLoop(8, RepeatBehavior.REVERSE);
  }
}
 
Example 5
Source File: MemoryUsedStatsUpdater.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  while (true) {
    long heapMaxSize = Runtime.getRuntime().maxMemory();
    long heapSize = Runtime.getRuntime().totalMemory();
    long free = Runtime.getRuntime().freeMemory();
    final float percentUsed = 100 * ((heapSize - free) / (float) heapSize);
    long percentOfTotalUsed = 100 * (heapSize - free) / heapMaxSize;
    Color newColor = Color.GREEN;
    if (percentOfTotalUsed > 93) {
      newColor = Color.RED;
    } else if (percentOfTotalUsed > 83) {
      newColor = Color.ORANGE;
    } else if (percentOfTotalUsed > 75) {
      newColor = Color.YELLOW;
    }
    final String message = String.format("Used %sMB of %sMB", nf.format((percentUsed * heapSize / (100 * 1024 * 1024))), nf.format(heapSize / (1024 * 1024)));
    final String toolTip = message
      + String.format(". Total available for VM %sMB. Double click to invoke System.gc()", nf.format(heapMaxSize / (1024 * 1024)));
    Timeline timeline = new Timeline(bar);
    timeline.addPropertyToInterpolate("value", bar.getValue(), (int) percentUsed);
    timeline.addPropertyToInterpolate("foreground", bar.getForeground(), newColor);
    timeline.setEase(new Sine());
    timeline.setDuration(1200);
    timeline.play();
    SwingUtilities.invokeLater(() -> {
      bar.setString(message);
      bar.setToolTipText(toolTip);
    });

    try {
      Thread.sleep(refreshTime);
    } catch (InterruptedException ignore) {
    }
  }
}
 
Example 6
Source File: MyWindowUtil.java    From gameserver with Apache License 2.0 5 votes vote down vote up
/**
 * Create an animation JComponent.
 * @param comp
 * @param to
 * @return
 */
public static Timeline createLocationTimeline(Component comp, Point to, int duration) {
	Timeline timeline = new Timeline(LoginDialog.getInstance());
	to.y = MainFrame.screenHeight;
	timeline.addPropertyToInterpolate("location", comp.getLocation(), to);
	timeline.setDuration(duration);
	timeline.setEase(new Sine());
	return timeline;
}
 
Example 7
Source File: CardAnimation.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private Timeline getGrowTimeline() {
    final Timeline timeline = new Timeline(this);
    timeline.addPropertyToInterpolate("GrowRectangle", getStart(), getPreviewRectangle());
    timeline.setDuration(GROW_DURATION);
    timeline.setEase(new Spline(0.8f));
    return timeline;
}
 
Example 8
Source File: CardAnimation.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private Timeline getShrinkTimeline() {
    final Timeline timeline = new Timeline(this);
    timeline.addPropertyToInterpolate("ShrinkRectangle", getPreviewRectangle(), getEnd());
    timeline.setDuration(SHRINK_DURATION);
    timeline.setEase(new Spline(0.8f));
    timeline.addCallback(new TimelineCallbackAdapter() {
        @Override
        public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) {
            if (newState == Timeline.TimelineState.DONE) {
                scenario.cancel();
            }
        }
    });
    return timeline;
}
 
Example 9
Source File: PlayerImagePanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doHealAnimation() {
    if (GeneralConfig.get(BooleanSetting.ANIMATE_GAMEPLAY)) {
        final Timeline timeline = new Timeline();
        timeline.setDuration(1000);
        timeline.setEase(new Spline(0.8f));
        timeline.addPropertyToInterpolate(
                Timeline.property("healColorOpacity").on(this).from(100).to(0));
        timeline.play();
    }
}