Java Code Examples for javafx.util.Duration#greaterThan()

The following examples show how to use javafx.util.Duration#greaterThan() . 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: PlayerController.java    From Simple-Media-Player with MIT License 6 votes vote down vote up
protected String formatTime(Duration elapsed,Duration duration){
    //将两个Duartion参数转化为 hh:mm:ss的形式后输出
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    int elapsedMinutes = (intElapsed - elapsedHours *60 *60)/ 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;
    if(duration.greaterThan(Duration.ZERO)){
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        int durationMinutes = (intDuration - durationHours *60 * 60) / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if(durationHours > 0){
            return String.format("%02d:%02d:%02d / %02d:%02d:%02d",elapsedHours,elapsedMinutes,elapsedSeconds,durationHours,durationMinutes,durationSeconds);
        }else{
            return String.format("%02d:%02d / %02d:%02d",elapsedMinutes,elapsedSeconds,durationMinutes,durationSeconds);
        }
    }else{
        if(elapsedHours > 0){
            return String.format("%02d:%02d:%02d / %02d:%02d:%02d",elapsedHours,elapsedMinutes,elapsedSeconds);
        }else{
            return String.format("%02d:%02d / %02d:%02d",elapsedMinutes,elapsedSeconds);
        }
    }
}
 
Example 2
Source File: PlayerPane.java    From oim-fx with MIT License 5 votes vote down vote up
private static String formatTime(Duration elapsed, Duration duration) {
	int intElapsed = (int) Math.floor(elapsed.toSeconds());
	int elapsedHours = intElapsed / (60 * 60);
	if (elapsedHours > 0) {
		intElapsed -= elapsedHours * 60 * 60;
	}
	int elapsedMinutes = intElapsed / 60;
	int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

	if (duration.greaterThan(Duration.ZERO)) {
		int intDuration = (int) Math.floor(duration.toSeconds());
		int durationHours = intDuration / (60 * 60);
		if (durationHours > 0) {
			intDuration -= durationHours * 60 * 60;
		}
		int durationMinutes = intDuration / 60;
		int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

		if (durationHours > 0) {
			return String.format("%d:%02d:%02d",elapsedHours, elapsedMinutes, elapsedSeconds);
		} else {
			return String.format("%02d:%02d",elapsedMinutes, elapsedSeconds);
		}
	} else {
		if (elapsedHours > 0) {
			return String.format("%d:%02d:%02d",elapsedHours, elapsedMinutes, elapsedSeconds);
		} else {
			return String.format("%02d:%02d",elapsedMinutes, elapsedSeconds);
		}
	}
}
 
Example 3
Source File: MediaView.java    From DashboardFx with GNU General Public License v3.0 5 votes vote down vote up
private String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d/%d:%02d:%02d",
                    elapsedHours, elapsedMinutes, elapsedSeconds,
                    durationHours, durationMinutes, durationSeconds);
        } else {
            return String.format("%02d:%02d/%02d:%02d",
                    elapsedMinutes, elapsedSeconds,
                    durationMinutes, durationSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                    elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                    elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 4
Source File: StreamingMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private static String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 5
Source File: OverlayMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private static String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 6
Source File: AdvancedMedia.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d/%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds,
                                 durationHours, durationMinutes, durationSeconds);
        } else {
            return String.format("%02d:%02d/%02d:%02d",
                                 elapsedMinutes, elapsedSeconds,
                                 durationMinutes, durationSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 7
Source File: StreamingMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private static String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 8
Source File: OverlayMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private static String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 9
Source File: AdvancedMedia.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d/%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds,
                                 durationHours, durationMinutes, durationSeconds);
        } else {
            return String.format("%02d:%02d/%02d:%02d",
                                 elapsedMinutes, elapsedSeconds,
                                 durationMinutes, durationSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 10
Source File: AdvancedMedia.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String formatTime(Duration elapsed, Duration duration) {
    int intElapsed = (int)Math.floor(elapsed.toSeconds());
    int elapsedHours = intElapsed / (60 * 60);
    if (elapsedHours > 0) {
        intElapsed -= elapsedHours * 60 * 60;
    }
    int elapsedMinutes = intElapsed / 60;
    int elapsedSeconds = intElapsed - elapsedHours * 60 * 60 - elapsedMinutes * 60;

    if (duration.greaterThan(Duration.ZERO)) {
        int intDuration = (int)Math.floor(duration.toSeconds());
        int durationHours = intDuration / (60 * 60);
        if (durationHours > 0) {
            intDuration -= durationHours * 60 * 60;
        }
        int durationMinutes = intDuration / 60;
        int durationSeconds = intDuration - durationHours * 60 * 60 - durationMinutes * 60;

        if (durationHours > 0) {
            return String.format("%d:%02d:%02d/%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds,
                                 durationHours, durationMinutes, durationSeconds);
        } else {
            return String.format("%02d:%02d/%02d:%02d",
                                 elapsedMinutes, elapsedSeconds,
                                 durationMinutes, durationSeconds);
        }
    } else {
        if (elapsedHours > 0) {
            return String.format("%d:%02d:%02d",
                                 elapsedHours, elapsedMinutes, elapsedSeconds);
        } else {
            return String.format("%02d:%02d",
                                 elapsedMinutes, elapsedSeconds);
        }
    }
}
 
Example 11
Source File: HelloIoTApp.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
private void doTimeout(Duration duration, EventHandler<ActionEvent> eventhandler) {
    if (duration.greaterThan(Duration.ZERO)) {
        new Timeline(new KeyFrame(duration, eventhandler)).play();
    } else {
        eventhandler.handle(new ActionEvent());
    }
}
 
Example 12
Source File: HeatControl.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private Duration clamp(final Duration MIN_VALUE, final Duration MAX_VALUE, final Duration VALUE) {
    if (VALUE.lessThan(MIN_VALUE)) return MIN_VALUE;
    if (VALUE.greaterThan(MAX_VALUE)) return MAX_VALUE;
    return VALUE;
}
 
Example 13
Source File: Gauge.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private Duration clamp(final Duration MIN_VALUE, final Duration MAX_VALUE, final Duration VALUE) {
    if (VALUE.lessThan(MIN_VALUE)) return MIN_VALUE;
    if (VALUE.greaterThan(MAX_VALUE)) return MAX_VALUE;
    return VALUE;
}
 
Example 14
Source File: RadialBargraph.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private Duration clamp(final Duration MIN_VALUE, final Duration MAX_VALUE, final Duration VALUE) {
    if (VALUE.lessThan(MIN_VALUE)) return MIN_VALUE;
    if (VALUE.greaterThan(MAX_VALUE)) return MAX_VALUE;
    return VALUE;
}
 
Example 15
Source File: SimpleGauge.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private Duration clamp(final Duration MIN_VALUE, final Duration MAX_VALUE, final Duration VALUE) {
    if (VALUE.lessThan(MIN_VALUE)) return MIN_VALUE;
    if (VALUE.greaterThan(MAX_VALUE)) return MAX_VALUE;
    return VALUE;
}