org.pushingpixels.trident.Timeline Java Examples

The following examples show how to use org.pushingpixels.trident.Timeline. 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: AdrCapturePanel.java    From MercuryTrade with MIT License 6 votes vote down vote up
@Override
public void onViewInit() {
    this.setLayout(new GridLayout(1, 1));
    this.setPreferredSize(this.descriptor.getSize());
    this.captureLabel = new JLabel();
    this.setBackground(AppThemeColor.ADR_CAPTURE_BG);
    this.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1));
    this.progressTl = new Timeline(this);
    this.progressTl.addPropertyToInterpolate("captureCount", 0, this.descriptor.getFps());
    this.captureLabel.setIcon(new ImageIcon(Scalr.resize(getCapture(), descriptor.getSize().width, descriptor.getSize().height)));
    this.progressTl.addCallback(new TimelineCallbackAdapter() {
        @Override
        public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) {
            captureLabel.setIcon(new ImageIcon(Scalr.resize(getCapture(), descriptor.getSize().width, descriptor.getSize().height)));
        }
    });
    this.progressTl.setDuration(1000 / this.descriptor.getFps());

    this.add(this.captureLabel);
    MercuryStoreUI.adrRepaintSubject.onNext(true);
}
 
Example #2
Source File: AdrDurationCellPanel.java    From MercuryTrade with MIT License 6 votes vote down vote up
@Override
public void onViewInit() {
    this.setLayout(new GridLayout(1, 1));
    this.setPreferredSize(this.descriptor.getSize());
    this.tracker = new MercuryTracker(this.descriptor);
    this.add(this.tracker);
    this.tracker.addTimelineCallback(new TimelineCallbackAdapter() {
        @Override
        public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) {
            if (newState.equals(Timeline.TimelineState.IDLE) && !inSettings) {
                if (!descriptor.isAlwaysVisible()) {
                    setVisible(false);
                } else {
                    tracker.setStringPainted(!descriptor.isAlwaysVisible());
                    tracker.setMaskPainted(!descriptor.isAlwaysVisible());
                }
                MercuryStoreUI.adrRepaintSubject.onNext(true);
            } else if (newState.equals(Timeline.TimelineState.PLAYING_FORWARD)) {
                setVisible(true);
                JFrame parent = (JFrame) SwingUtilities.getWindowAncestor(AdrDurationCellPanel.this);
                parent.pack();
            }
        }
    });
    MercuryStoreUI.adrRepaintSubject.onNext(true);
}
 
Example #3
Source File: MercuryLoading.java    From MercuryTrade with MIT License 6 votes vote down vote up
public MercuryLoading() {
    this.setValue(0);
    this.setMaximum(3000);
    this.setForeground(AppThemeColor.TEXT_NICKNAME);
    this.setBackground(AppThemeColor.ADR_FOOTER_BG);

    this.setUI(new MercuryLoadingUi(this));

    this.progressTl = new Timeline(this);
    this.progressTl.setDuration(2400);
    this.progressTl.addPropertyToInterpolate("value", this.getMaximum(), 0);
    this.progressTl.setEase(new Spline(1));
    this.progressTl.addCallback(new TimelineCallbackAdapter() {
        @Override
        public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) {
            swapColors();
        }
    });
}
 
Example #4
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 #5
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 #6
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 #7
Source File: AbstractRadial.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public AbstractRadial() {
      super();
      lcdTimeline = new Timeline(this);
      lcdValue = 0;
      lcdUnitString = getUnitString();
      ledPosition = new Point2D.Double(0.6, 0.4);
      userLedPosition = new Point2D.Double(0.3, 0.4);
      INNER_BOUNDS = new Rectangle(200, 200);
      GAUGE_BOUNDS = new Rectangle(200, 200);
      FRAMELESS_BOUNDS = new Rectangle(200, 200);
      FRAMELESS_OFFSET = new Point2D.Double(0, 0);
      transparentSectionsEnabled = false;
      transparentAreasEnabled = false;
      expandedSectionsEnabled = false;
      tickmarkDirection = Direction.CLOCKWISE;
      timeline = new Timeline(this);
      STANDARD_EASING = new Spline(0.5f);
      RETURN_TO_ZERO_EASING = new Sine();
horizontalAlignment = SwingConstants.CENTER;
verticalAlignment = SwingConstants.CENTER;
      lcdTextVisible = true;
      LCD_BLINKING_TIMER = new Timer(500, this);
      addComponentListener(this);
  }
 
Example #8
Source File: AbstractLinear.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public AbstractLinear() {
    super();
    INNER_BOUNDS = new Rectangle(120, 300);
    startingFromZero = false;
    transparentSectionsEnabled = false;
    transparentAreasEnabled = false;
    ledPosition = new Point2D.Double((getInnerBounds().width - 18.0 - 16.0) / getInnerBounds().width, 0.453271028);
    userLedPosition = new Point2D.Double(18.0 / getInnerBounds().width, 0.453271028);
    lcdValue = 0;
    lcdTimeline = new Timeline(this);
    lcdUnitString = getUnitString();
    lcdInfoString = "";
    timeline = new Timeline(this);
    STANDARD_EASING = new Spline(0.5f);
    RETURN_TO_ZERO_EASING = new Sine();
    lcdTextVisible = true;
    LCD_BLINKING_TIMER = new Timer(500, this);
    addComponentListener(this);
}
 
Example #9
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 #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: 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 #12
Source File: CardAnimation.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void doCancelAction() {
    if (viewTimeline.getState() == Timeline.TimelineState.PLAYING_FORWARD) {
        viewTimeline.cancel();
        shrinkTimeline.play();
    }
}
 
Example #13
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 #14
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 #15
Source File: CardFlowPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTimelineStateChanged(Timeline.TimelineState arg0, Timeline.TimelineState arg1, float arg2, float arg3) {
    if (arg0 == Timeline.TimelineState.DONE && arg1 == Timeline.TimelineState.IDLE) {
        onTimelinePulse(0, 1.0f);
        notifyOnNewActiveImage();
    }
}
 
Example #16
Source File: CardFlowPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public void doClickLeft() {
    if (timeline.getState() == Timeline.TimelineState.IDLE) {
        if (activeImageIndex > 0) {
            flowDirection = FlowDirection.RIGHT;
            activeImageIndex = activeImageIndex - 1;
            timelinePulse = 0.0f;
            if (settings.isAnimationEnabled()) {
                timeline.play();
            } else {
                onTimelinePulse(0, 1.0f);
                notifyOnNewActiveImage();
            }
        }
    }
}
 
Example #17
Source File: CardFlowPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public void doClickRight() {
    if (timeline.getState() == Timeline.TimelineState.IDLE) {
        if (activeImageIndex < getSourceSize() - 1) {
            flowDirection = FlowDirection.LEFT;
            activeImageIndex = activeImageIndex + 1;
            timelinePulse = 0.0f;
            if (settings.isAnimationEnabled()) {
                timeline.play();
            } else {
                onTimelinePulse(0, 1.0f);
                notifyOnNewActiveImage();
            }
        }
    }
}
 
Example #18
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 #19
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 #20
Source File: AbstractThrobber.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doOnShowingChanged(int spinPeriod) {
    if (isShowing()) {
        if (timeline.getState() == Timeline.TimelineState.IDLE) {
            startTimeline(spinPeriod);
        } else {
            timeline.resume();
        }
    } else {
        timeline.suspend();
    }
}
 
Example #21
Source File: AbstractThrobber.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void startTimeline(final int period) {
    timeline.abort();
    timeline.addPropertyToInterpolate(
            Timeline.property("angle")
            .on(this)
            .from(0)
            .to(356));
    timeline.setDuration(period);
    timeline.playLoop(RepeatBehavior.LOOP);
}
 
Example #22
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 #23
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 #24
Source File: DependecyWPanel.java    From BART with MIT License 5 votes vote down vote up
private void initJXLabelDependency()   {
    fadeInTimeline = new Timeline(this); 
    labelDependency = new JXLabel();
    labelDependency.setOpaque(true);
    labelDependency.setMinimumSize(new Dimension(589, 200));
    labelDependency.setPreferredSize(new Dimension(589, 200));
    labelDependency.setLineWrap(false);
    labelDependency.setTextAlignment(JXLabel.TextAlignment.JUSTIFY);       
    labelDependency.setIcon(ImageUtilities.image2Icon(ImageUtilities.loadImage(R.IMAGE_NODE_DCS)));
    labelDependency.setIconTextGap(20);
}
 
Example #25
Source File: AdrCapturePanel.java    From MercuryTrade with MIT License 5 votes vote down vote up
@Override
protected void onUpdate() {
    this.setVisible(this.descriptor.isVisible());
    this.progressTl.abort();
    this.progressTl.setDuration(1000 / this.descriptor.getFps());
    this.progressTl.playLoop(Timeline.RepeatBehavior.LOOP);
}
 
Example #26
Source File: AbstractComponentFrame.java    From MercuryTrade with MIT License 5 votes vote down vote up
private void initAnimationTimers() {
    this.showAnimation = new Timeline(this);
    this.showAnimation.setDuration(SHOW_TIME);
    this.showAnimation.addPropertyToInterpolate("opacity", this.minOpacity, this.maxOpacity);

    this.hideAnimation = new Timeline(this);
    this.hideAnimation.setDuration(HIDE_TIME);
    this.hideAnimation.addPropertyToInterpolate("opacity", this.maxOpacity, this.minOpacity);
}
 
Example #27
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 #28
Source File: AirCompass.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public AirCompass() {
    super();
    rotateTickmarks = true;
    value = 0;
    rotationAngle = 0;
    CENTER = new Point2D.Double();
    timeline = new Timeline(this);
    init(getInnerBounds().width, getInnerBounds().height);
    setLcdVisible(true);
}
 
Example #29
Source File: DisplayMulti.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public DisplayMulti() {
    super();
    lcdValue = 0.0;
    oldValue = 0.0;
    lcdThreshold = 0.0;
    lcdThresholdVisible = false;
    lcdThresholdBehaviourInverted = false;
    lcdBackgroundVisible = true;
    lcdTextVisible = true;
    lcdBlinking = false;
    LCD_BLINKING_TIMER = new Timer(500, this);
    lcdDecimals = 1;
    lcdUnitString = "unit";
    lcdUnitStringVisible = true;
    lcdScientificFormat = false;
    digitalFont = false;
    useCustomLcdUnitFont = false;
    customLcdUnitFont = new Font("Verdana", 0, 24);
    LCD_STANDARD_FONT = new Font("Verdana", 0, 30);
    LCD_DIGITAL_FONT = Util.INSTANCE.getDigitalFont().deriveFont(24).deriveFont(Font.PLAIN);
    lcdInfoFont = new Font("Verdana", 0, 24);
    lcdInfoString = "";
    numberSystem = NumberSystem.DEC;
    DISABLED_COLOR = new Color(102, 102, 102, 178);
    timeline = new Timeline(this);
    EASING = new Linear();
    glowVisible = false;
    glowColor = new Color(51, 255, 255);
    glowing = false;
    init(128, 64);
    addComponentListener(COMPONENT_LISTENER);
}
 
Example #30
Source File: ChoiceBorderPanelButton.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void startPulsingBorderAnimation() {
    if (MagicAnimations.isOn(AnimationFx.AVATAR_PULSE)) {
        stopPulsingBorderAnimation();
        pulseBorderTimeline.setDuration(500);
        pulseBorderTimeline.setEase(new Spline(0.8f));
        pulseBorderTimeline.addPropertyToInterpolate(
                Timeline.property("ChoiceBorderOpacity").on(this)
                    .from(20).to(CHOICE_BORDER_MAX_OPACITY)
        );
        pulseBorderTimeline.playLoop(Timeline.RepeatBehavior.REVERSE);
    }
}