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

The following examples show how to use org.pushingpixels.trident.Timeline#setDuration() . 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: 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 5
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 6
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 7
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 8
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 9
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 10
Source File: CardAnimation.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private Timeline getFlipTimeline() {
    if (MagicAnimations.isOff(AnimationFx.FLIP_CARD)) {
        return null;
    }
    final Timeline timeline = new Timeline(this);
    timeline.addPropertyToInterpolate("FlipPosition", 0.0f, 1.0f);
    timeline.setDuration(FLIP_DURATION);
    timeline.setInitialDelay(GROW_DURATION - FLIP_DURATION);
    flipPosition = 0f;
    return timeline;
}
 
Example 11
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 12
Source File: CardAnimation.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private Timeline getViewTimeline() {
    final Timeline timeline = new Timeline();
    timeline.setDuration(getViewDuration());
    timeline.addCallback(new TimelineCallbackAdapter() {
        @Override
        public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) {
            if (newState == Timeline.TimelineState.PLAYING_FORWARD) {
                // ensures arrow is painted correctly.
                getCanvas().repaint();
            }
        }
    });
    return timeline;
}
 
Example 13
Source File: PlayerImagePanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doDamageAnimation() {
    if (GeneralConfig.get(BooleanSetting.ANIMATE_GAMEPLAY)) {
        final Timeline timeline = new Timeline();
        timeline.setDuration(100);
        timeline.addPropertyToInterpolate(
                Timeline.property("damageColorOpacity").on(this).from(0).to(120));
        timeline.playLoop(6, Timeline.RepeatBehavior.REVERSE);
    }
}
 
Example 14
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();
    }
}
 
Example 15
Source File: ZoneToggleButton.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doAlertAnimation(int loopCount) {
    if (MagicAnimations.isOn(AnimationFx.ZBUTTON_PULSE)) {
        timeline1 = new Timeline();
        timeline1.setDuration(200);
        timeline1.addPropertyToInterpolate(
                Timeline.property("imageOffset").on(this).from(0).to(4));
        timeline1.playLoop(loopCount, Timeline.RepeatBehavior.REVERSE);
    }
}
 
Example 16
Source File: ItemResultPanel.java    From osrsclient with GNU General Public License v2.0 4 votes vote down vote up
private void setupAnimation() {
    rolloverTimeline = new Timeline(this);
    rolloverTimeline.addPropertyToInterpolate("background", this.getBackground(), new Color(91, 91, 91));
    rolloverTimeline.setDuration(150);
}
 
Example 17
Source File: LevelInfoPanel.java    From osrsclient with GNU General Public License v2.0 4 votes vote down vote up
private void setupAnimation() {
    rolloverTimeline = new Timeline(xpToLevelBar);
    rolloverTimeline.setDuration(70);

}
 
Example 18
Source File: GuiUtils.java    From otroslogviewer with Apache License 2.0 4 votes vote down vote up
public static void blinkComponent(JComponent component){
  final Timeline timeline = new Timeline(component);
  timeline.addPropertyToInterpolate("background", component.getBackground(), GuiUtils.getAverageColor(component.getBackground(), component.getForeground()));
  timeline.setDuration(150);
  timeline.playLoop(2, Timeline.RepeatBehavior.REVERSE);
}