下面列出了javafx.scene.AmbientLight#javafx.animation.RotateTransition 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override protected void handleCurrentValue(final double VALUE) {
double deviation = calculateDeviation(VALUE);
updateState(deviation);
valueText.setText(String.format(locale, formatString, VALUE));
deviationText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation));
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), deviationText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
FillTransition fillReferenceUnitTransition = new FillTransition(Duration.millis(200), deviationUnitText);
fillReferenceUnitTransition.setFromValue((Color) triangle.getFill());
fillReferenceUnitTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition, fillReferenceUnitTransition);
parallelTransition.play();
}
public LoadingBar() {
Circle outer = new Circle(50);
outer.setFill(null);
outer.setStroke(Color.BLACK);
Circle inner = new Circle(5);
inner.setTranslateY(-50);
rt = new RotateTransition(Duration.seconds(2), this);
rt.setToAngle(360);
rt.setInterpolator(Interpolator.LINEAR);
rt.setCycleCount(RotateTransition.INDEFINITE);
getChildren().addAll(outer, inner);
setVisible(false);
}
public LoadingCircle() {
Circle circle = new Circle(20);
circle.setFill(null);
circle.setStroke(Color.WHITE);
circle.setStrokeWidth(2);
Rectangle rect = new Rectangle(20, 20);
Shape shape = Shape.subtract(circle, rect);
shape.setFill(Color.WHITE);
getChildren().add(shape);
animation = new RotateTransition(Duration.seconds(2.5), this);
animation.setByAngle(-360);
animation.setInterpolator(Interpolator.LINEAR);
animation.setCycleCount(Animation.INDEFINITE);
animation.play();
}
public void close() {
if (State.CLOSED == getState()) return;
setState(State.CLOSED);
RotateTransition rotate = new RotateTransition();
rotate.setNode(cross);
rotate.setToAngle(0);
rotate.setDuration(Duration.millis(200));
rotate.setInterpolator(Interpolator.EASE_BOTH);
rotate.play();
closeTimeLines[closeTimeLines.length - 1].setOnFinished(actionEvent -> {
FadeTransition buttonFadeOut = new FadeTransition();
buttonFadeOut.setNode(mainMenuButton);
buttonFadeOut.setDuration(Duration.millis(100));
buttonFadeOut.setToValue(options.getButtonAlpha());
buttonFadeOut.play();
buttonFadeOut.setOnFinished(event -> {
if (options.isButtonHideOnClose()) hide();
fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_FINISHED));
});
});
for (int i = 0 ; i < closeTimeLines.length ; i++) {
closeTimeLines[i].play();
}
fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_STARTED));
}
private static Pane getDemoPane() {
final Rectangle rect = new Rectangle(-130, -40, 80, 80);
rect.setFill(Color.BLUE);
final Circle circle = new Circle(0, 0, 40);
circle.setFill(Color.GREEN);
final Polygon triangle = new Polygon(60, -40, 120, 0, 50, 40);
triangle.setFill(Color.RED);
final Group group = new Group(rect, circle, triangle);
group.setTranslateX(300);
group.setTranslateY(200);
final RotateTransition rotateTransition = new RotateTransition(Duration.millis(4000), group);
rotateTransition.setByAngle(3.0 * 360);
rotateTransition.setCycleCount(Animation.INDEFINITE);
rotateTransition.setAutoReverse(true);
rotateTransition.play();
final RotateTransition rotateTransition1 = new RotateTransition(Duration.millis(1000), rect);
rotateTransition1.setByAngle(360);
rotateTransition1.setCycleCount(Animation.INDEFINITE);
rotateTransition1.setAutoReverse(false);
rotateTransition1.play();
final RotateTransition rotateTransition2 = new RotateTransition(Duration.millis(1000), triangle);
rotateTransition2.setByAngle(360);
rotateTransition2.setCycleCount(Animation.INDEFINITE);
rotateTransition2.setAutoReverse(false);
rotateTransition2.play();
group.setManaged(true);
HBox.setHgrow(group, Priority.ALWAYS);
final HBox box = new HBox(group);
VBox.setVgrow(box, Priority.ALWAYS);
box.setId("demoPane");
return box;
}
public static void makeRotateTransition(Node node, int mills, double byAngle) {
RotateTransition rt = new RotateTransition(Duration.millis(mills));
rt.setByAngle(byAngle);
rt.setCycleCount(Animation.INDEFINITE);
rt.setNode(node);
rt.play();
}
public static void makeRotateTransition(Node node, int mills, double fromAngle, double toAngle, boolean autoReverse) {
RotateTransition rt = new RotateTransition(Duration.millis(mills));
rt.setFromAngle(fromAngle);
rt.setToAngle(toAngle);
rt.setAutoReverse(autoReverse);
rt.setCycleCount(Animation.INDEFINITE);
rt.setNode(node);
rt.play();
}
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
RotateTransition transition = new RotateTransition(Duration.seconds(5), arc1);
transition.setAxis(new Point3D(50, 50, 0));
transition.setByAngle(200);
transition.play();
}
private void btnRotateHandler() {
btnRotate.setOnAction(e -> {
RotateTransition rt = new RotateTransition(Duration.millis(1000), resolveInternalWindow(mainPane));
rt.setByAngle(360);
rt.setCycleCount(1);
// rt.setAutoReverse(true);
rt.play();
});
}
@Override protected void handleCurrentValue(final double VALUE) {
double deviation = calculateDeviation(VALUE);
updateState(deviation);
if (tile.getCustomDecimalFormatEnabled()) {
valueText.setText(decimalFormat.format(VALUE));
} else {
valueText.setText(String.format(locale, formatString, VALUE));
}
deviationText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation));
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), deviationText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
FillTransition fillReferenceUnitTransition = new FillTransition(Duration.millis(200), deviationUnitText);
fillReferenceUnitTransition.setFromValue((Color) triangle.getFill());
fillReferenceUnitTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition, fillReferenceUnitTransition);
parallelTransition.play();
}
private static void setRotate(Shape s, boolean reverse, double angle, int duration) {
RotateTransition r = new RotateTransition(Duration.seconds(duration), s);
r.setAutoReverse(reverse);
r.setDelay(Duration.ZERO);
r.setRate(3.0);
r.setCycleCount(RotateTransition.INDEFINITE);
r.setByAngle(angle);
r.play();
}
public void rotateGlobe() {
rt = new RotateTransition(Duration.seconds(OrbitInfo.SOLAR_DAY/500D), globe.getWorld());
//rt.setByAngle(360);
rt.setInterpolator(Interpolator.LINEAR);
rt.setCycleCount(Animation.INDEFINITE);
rt.setAxis(Rotate.Y_AXIS);
rt.setFromAngle(360);
rt.setToAngle(0);
rt.play();
}
private RotateTransition rotateAroundYAxis(Node node) {
RotateTransition rotate = new RotateTransition(
Duration.seconds(ROTATE_SECS),
node
);
rotate.setAxis(Rotate.Y_AXIS);
rotate.setFromAngle(360);
rotate.setToAngle(0);
rotate.setInterpolator(Interpolator.LINEAR);
rotate.setCycleCount(RotateTransition.INDEFINITE);
return rotate;
}
public void roll() {
RotateTransition rt = new RotateTransition(Duration.seconds(1), this);
rt.setFromAngle(0);
rt.setToAngle(360);
rt.setOnFinished(event -> {
valueProperty.set((int)(Math.random() * (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE);
});
rt.play();
}
public void show() {
RotateTransition rt = new RotateTransition(Duration.seconds(1), bg);
rt.setAxis(Rotate.Y_AXIS);
rt.setToAngle(180);
rt.setOnFinished(event -> text.setVisible(true));
rt.play();
}
void notifyCloseAction() {
if (isMenuOpen) {
isMenuOpen = false;
RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
rotate.setToAngle(0);
rotate.play();
hideAction.run();
}
}
void notifyOpenAction() {
RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
rotate.setToAngle(90);
rotate.play();
openAction.run();
}
private void initGraphics() {
setPickOnBounds(false);
cross = new Region();
cross.getStyleClass().add("cross");
cross.setMouseTransparent(true);
crossRotate = new RotateTransition(Duration.millis(200), cross);
crossRotate.setInterpolator(Interpolator.EASE_BOTH);
// Add all nodes
getChildren().addAll(cross);
}
@Override protected void handleCurrentValue(final double VALUE) {
low = Statistics.getMin(dataList);
high = Statistics.getMax(dataList);
if (Helper.equals(low, high)) {
low = minValue;
high = maxValue;
}
range = high - low;
double minX = graphBounds.getX();
double maxX = minX + graphBounds.getWidth();
double minY = graphBounds.getY();
double maxY = minY + graphBounds.getHeight();
double stepX = graphBounds.getWidth() / (noOfDatapoints - 1);
double stepY = graphBounds.getHeight() / range;
double referenceValue = tile.getReferenceValue();
if(!dataList.isEmpty()) {
MoveTo begin = (MoveTo) pathElements.get(0);
begin.setX(minX);
begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
for (int i = 1; i < (noOfDatapoints - 1); i++) {
LineTo lineTo = (LineTo) pathElements.get(i);
lineTo.setX(minX + i * stepX);
lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
}
LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
end.setX(maxX);
end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);
dot.setCenterX(maxX);
dot.setCenterY(end.getY());
updateState(VALUE, referenceValue);
referenceLine.setStartY(maxY - Math.abs(low - referenceValue) * stepY);
referenceLine.setEndY(maxY - Math.abs(low - referenceValue) * stepY);
changeText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE - referenceValue)));
changePercentageText.setText(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE / referenceValue * 100.0) - 100.0)).append("\u0025").toString());
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), changePercentageText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition);
parallelTransition.play();
}
valueText.setText(String.format(locale, formatString, VALUE));
highText.setText(String.format(locale, formatString, high));
lowText.setText(String.format(locale, formatString, low));
if (!tile.isTextVisible() && null != movingAverage.getTimeSpan()) {
timeSpanText.setText(createTimeSpanText());
text.setText(timeFormatter.format(movingAverage.getLastEntry().getTimestampAsDateTime(tile.getZoneId())));
}
resizeDynamicText();
}
public StatusBar(TileMap tileMap) {
getStyleClass().add("status-bar");
grid.getStyleClass().add("status-bar-grid");
tileMap.setOnUpdate(this::update);
tileMap.setOnHover(this::update);
for (int i = 0; i < 6; i++) {
ColumnConstraints constraints = new ColumnConstraints();
constraints.setMinWidth(140);
constraints.setFillWidth(true);
grid.getColumnConstraints().add(constraints);
}
hoveredRegion.setTooltip(new Tooltip(Translation.STATUS_REGION_TOOLTIP.toString()));
hoveredChunk.setTooltip(new Tooltip(Translation.STATUS_CHUNK_TOOLTIP.toString()));
hoveredBlock.setTooltip(new Tooltip(Translation.STATUS_BLOCK_TOOLTIP.toString()));
selectedChunks.setTooltip(new Tooltip(Translation.STATUS_SELECTED_TOOLTIP.toString()));
visibleRegions.setTooltip(new Tooltip(Translation.STATUS_VISIBLE_TOOLTIP.toString()));
totalRegions.setTooltip(new Tooltip(Translation.STATUS_TOTAL_TOOLTIP.toString()));
grid.add(hoveredBlock, 0, 0, 1, 1);
grid.add(hoveredChunk, 1, 0, 1, 1);
grid.add(hoveredRegion, 2, 0, 1 ,1);
grid.add(selectedChunks, 3, 0, 1, 1);
grid.add(visibleRegions, 4, 0, 1, 1);
grid.add(totalRegions, 5, 0, 1, 1);
StackPane.setAlignment(grid, Pos.CENTER_LEFT);
getChildren().add(grid);
rt = new RotateTransition(Duration.millis(1000), loadIcon);
rt.setByAngle(360);
rt.setCycleCount(Animation.INDEFINITE);
rt.setInterpolator(Interpolator.LINEAR);
StackPane.setAlignment(bp, Pos.CENTER_LEFT);
getChildren().add(bp);
DataProperty<Boolean> b = new DataProperty<>(true);
DataProperty<Integer> before = new DataProperty<>(0);
Thread t = new Thread(() -> {
while (b.get()) {
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
return;
}
int activeJobs = MCAFilePipe.getActiveJobs();
if (before.get() == 0 && activeJobs != 0) {
Platform.runLater(() -> {
rt.play();
bp.setRight(loadIcon);
});
} else if (before.get() != 0 && activeJobs == 0) {
Platform.runLater(() -> {
rt.stop();
bp.setRight(null);
});
}
before.set(activeJobs);
}
});
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
b.set(false);
t.interrupt();
}));
t.start();
}
@Override protected void handleCurrentValue(final double VALUE) {
low = Statistics.getMin(dataList);
high = Statistics.getMax(dataList);
if (Helper.equals(low, high)) {
low = minValue;
high = maxValue;
}
range = high - low;
double minX = graphBounds.getX();
double maxX = minX + graphBounds.getWidth();
double minY = graphBounds.getY();
double maxY = minY + graphBounds.getHeight();
double stepX = graphBounds.getWidth() / (noOfDatapoints - 1);
double stepY = graphBounds.getHeight() / range;
double referenceValue = tile.getReferenceValue();
if(!dataList.isEmpty()) {
MoveTo begin = (MoveTo) pathElements.get(0);
begin.setX(minX);
begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
for (int i = 1; i < (noOfDatapoints - 1); i++) {
LineTo lineTo = (LineTo) pathElements.get(i);
lineTo.setX(minX + i * stepX);
lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
}
LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
end.setX(maxX);
end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);
dot.setCenterX(maxX);
dot.setCenterY(end.getY());
updateState(VALUE, referenceValue);
referenceLine.setStartY(maxY - Math.abs(low - referenceValue) * stepY);
referenceLine.setEndY(maxY - Math.abs(low - referenceValue) * stepY);
changeText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE - referenceValue)));
StringBuilder changePercentageTextBuilder = new StringBuilder();
if (Double.compare(tile.getReferenceValue(), 0.0) == 0) {
changePercentageTextBuilder.append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", 0.0));
} else {
changePercentageTextBuilder.append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE / tile.getReferenceValue() * 100.0) - 100.0));
}
changePercentageTextBuilder.append(Helper.PERCENTAGE);
changePercentageText.setText(changePercentageTextBuilder.toString());
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), changePercentageText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition);
parallelTransition.play();
}
if (tile.getCustomDecimalFormatEnabled()) {
valueText.setText(decimalFormat.format(VALUE));
} else {
valueText.setText(String.format(locale, formatString, VALUE));
}
highText.setText(String.format(locale, formatString, high));
lowText.setText(String.format(locale, formatString, low));
if (!tile.isTextVisible() && null != movingAverage.getTimeSpan()) {
timeSpanText.setText(createTimeSpanText());
text.setText(timeFormatter.format(movingAverage.getLastEntry().getTimestampAsDateTime(tile.getZoneId())));
}
resizeDynamicText();
}
private void initGraphics() {
double center = PREFERRED_WIDTH * 0.5;
double radius = PREFERRED_WIDTH * 0.45;
circle = new Circle();
circle.setCenterX(center);
circle.setCenterY(center);
circle.setRadius(radius);
circle.getStyleClass().add("indicator");
circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
circle.setStrokeDashOffset(dashOffset.get());
circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);
arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
arc.getStyleClass().add("indicator");
indeterminatePane = new StackPane(circle);
indeterminatePane.setVisible(false);
progressPane = new Pane(arc);
progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);
getChildren().setAll(progressPane, indeterminatePane);
// Setup timeline animation
KeyValue kvDashOffset_0 = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
KeyValue kvDashOffset_50 = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
KeyValue kvDashOffset_100 = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_0 = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_50 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
KeyValue kvRotate_0 = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
KeyValue kvRotate_100 = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);
KeyFrame kf0 = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
KeyFrame kf1 = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
KeyFrame kf2 = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().setAll(kf0, kf1, kf2);
// Setup additional pane rotation
indeterminatePaneRotation = new RotateTransition();
indeterminatePaneRotation.setNode(indeterminatePane);
indeterminatePaneRotation.setFromAngle(0);
indeterminatePaneRotation.setToAngle(-360);
indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
indeterminatePaneRotation.setDuration(new Duration(4500));
}
private void initGraphics() {
double center = PREFERRED_WIDTH * 0.5;
double radius = PREFERRED_WIDTH * 0.45;
circle = new Circle();
circle.setCenterX(center);
circle.setCenterY(center);
circle.setRadius(radius);
circle.getStyleClass().add("indicator");
circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
circle.setStrokeDashOffset(dashOffset.get());
circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);
arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
arc.getStyleClass().add("indicator");
indeterminatePane = new StackPane(circle);
indeterminatePane.setVisible(false);
progressPane = new Pane(arc);
progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);
getChildren().setAll(progressPane, indeterminatePane);
// Setup timeline animation
KeyValue kvDashOffset_0 = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
KeyValue kvDashOffset_50 = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
KeyValue kvDashOffset_100 = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_0 = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_50 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
KeyValue kvRotate_0 = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
KeyValue kvRotate_100 = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);
KeyFrame kf0 = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
KeyFrame kf1 = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
KeyFrame kf2 = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().setAll(kf0, kf1, kf2);
// Setup additional pane rotation
indeterminatePaneRotation = new RotateTransition();
indeterminatePaneRotation.setNode(indeterminatePane);
indeterminatePaneRotation.setFromAngle(0);
indeterminatePaneRotation.setToAngle(-360);
indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
indeterminatePaneRotation.setDuration(new Duration(4500));
}
public Parent createContent() throws Exception {
Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm());
Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm());
Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm());
Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm());
material = new PhongMaterial();
material.setDiffuseColor(Color.WHITE);
material.diffuseMapProperty().bind(
Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
material.setSpecularColor(Color.TRANSPARENT);
material.specularMapProperty().bind(
Bindings.when(specularMap).then(sImage).otherwise((Image) null));
material.bumpMapProperty().bind(
Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
material.selfIlluminationMapProperty().bind(
Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));
earth = new Sphere(5);
earth.setMaterial(material);
earth.setRotationAxis(Rotate.Y_AXIS);
// Create and position camera
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.getTransforms().addAll(
new Rotate(-20, Rotate.Y_AXIS),
new Rotate(-20, Rotate.X_AXIS),
new Translate(0, 0, -20));
sun = new PointLight(Color.rgb(255, 243, 234));
sun.translateXProperty().bind(sunDistance.multiply(-0.82));
sun.translateYProperty().bind(sunDistance.multiply(-0.41));
sun.translateZProperty().bind(sunDistance.multiply(-0.41));
sun.lightOnProperty().bind(sunLight);
AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1));
// Build the Scene Graph
Group root = new Group();
root.getChildren().add(camera);
root.getChildren().add(earth);
root.getChildren().add(sun);
root.getChildren().add(ambient);
RotateTransition rt = new RotateTransition(Duration.seconds(24), earth);
rt.setByAngle(360);
rt.setInterpolator(Interpolator.LINEAR);
rt.setCycleCount(Animation.INDEFINITE);
rt.play();
// Use a SubScene
SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED);
subScene.setFill(Color.TRANSPARENT);
subScene.setCamera(camera);
return new Group(subScene);
}
public void click(final MenuItem CLICKED_ITEM) {
List<Transition> transitions = new ArrayList<>(items.size() * 2);
for (Parent node : items.keySet()) {
if (items.get(node).equals(CLICKED_ITEM)) {
// Add enlarge transition to selected item
ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
enlargeItem.setToX(5.0);
enlargeItem.setToY(5.0);
transitions.add(enlargeItem);
} else {
// Add shrink transition to all other items
ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
shrinkItem.setToX(0.0);
shrinkItem.setToY(0.0);
transitions.add(shrinkItem);
}
// Add fade out transition to every node
FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
fadeOutItem.setToValue(0.0);
transitions.add(fadeOutItem);
}
// Add rotate and fade transition to main menu button
if (options.isButtonHideOnSelect()) {
RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
rotateMainButton.setToAngle(225);
transitions.add(rotateMainButton);
FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
fadeOutMainButton.setToValue(0.0);
transitions.add(fadeOutMainButton);
ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
shrinkMainButton.setToX(0.0);
shrinkMainButton.setToY(0.0);
transitions.add(shrinkMainButton);
} else {
RotateTransition rotateBackMainButton = new RotateTransition();
rotateBackMainButton.setNode(cross);
rotateBackMainButton.setToAngle(0);
rotateBackMainButton.setDuration(Duration.millis(200));
rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
transitions.add(rotateBackMainButton);
FadeTransition mainButtonFadeOut = new FadeTransition();
mainButtonFadeOut.setNode(mainMenuButton);
mainButtonFadeOut.setDuration(Duration.millis(100));
mainButtonFadeOut.setToValue(options.getButtonAlpha());
transitions.add(mainButtonFadeOut);
}
// Play all transitions in parallel
ParallelTransition selectTransition = new ParallelTransition();
selectTransition.getChildren().addAll(transitions);
selectTransition.play();
// Set menu state back to closed
setState(State.CLOSED);
mainMenuButton.setOpen(false);
}