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

The following examples show how to use org.pushingpixels.trident.Timeline#play() . 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: MyWindowUtil.java    From gameserver with Apache License 2.0 6 votes vote down vote up
/**
   * @param window
   * @param fadeOutDuration
   */
  private static void fadeOutAndEnd(final Window window, int fadeOutDuration, 
          final boolean exit) {
      Timeline dispose = new Timeline(new WindowFader(window));
      dispose.addPropertyToInterpolate("opacity", 1.0f,
//              AWTUtilitiesWrapper.getWindowOpacity(window), 
              0.0f);
      dispose.addCallback(new UIThreadTimelineCallbackAdapter() {
          @Override
          public void onTimelineStateChanged(TimelineState oldState,
                  TimelineState newState, float durationFraction,
                  float timelinePosition) {
              if (newState == TimelineState.DONE) {
                  if (exit) {
                      Runtime.getRuntime().exit(0);
                  } else {
                      window.dispose();
                  }
              }
          }
      });
      dispose.setDuration(fadeOutDuration);
      dispose.play();
  }
 
Example 2
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 3
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 4
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 5
Source File: LoginService.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
protected void done() {
	final LoginDialog dialog = LoginDialog.getInstance();
	if ( !loginResult ) {
		dialog.getResultLabel().setText("登陆失败");
		dialog.getOKButton().setEnabled(true);
		dialog.getOKButton().setText("确定");
	} else {
		ConfigManager.saveConfigKeyValue(ConfigKey.adminUsername, username);
		ConfigManager.saveConfigKeyValue(ConfigKey.adminPassword, password);
		ConfigManager.saveConfigKeyValue(ConfigKey.adminDatabaseServer, mongoServer);
		
		Point to = dialog.getLocation();
		to.y = MainFrame.screenHeight;
		Timeline timeline = MyWindowUtil.createLocationTimeline(dialog, to, 200);
		timeline.addCallback(new TimelineCallbackAdapter() {

			/* (non-Javadoc)
			 * @see org.pushingpixels.trident.callback.TimelineCallbackAdapter#onTimelineStateChanged(org.pushingpixels.trident.Timeline.TimelineState, org.pushingpixels.trident.Timeline.TimelineState, float, float)
			 */
			@Override
			public void onTimelineStateChanged(TimelineState oldState,
					TimelineState newState, float durationFraction,
					float timelinePosition) {
				if ( newState == TimelineState.DONE ) {
					dialog.dispose();
				}
			}
			
		});
		timeline.play();
	}
}
 
Example 6
Source File: AboutContentPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doDropAnimation() {
    dropTimeline = new Timeline(this);
    dropTimeline.addCallback(this);
    dropTimeline.addPropertyToInterpolate("ImageScale", 6f, 1f);
    dropTimeline.setDuration(500);
    dropTimeline.play();
}
 
Example 7
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();
    }
}