@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(); }
/** * Highlights the shape to a red colour and back */ public void highlight(){ Platform.runLater(() -> { FillTransition ft = new FillTransition(Duration.millis(100), shape, Color.valueOf("#1e3c72"), Color.RED); ft.setCycleCount(2); ft.setAutoReverse(true); ft.play(); }); }
public void setOnAction(Runnable action) { setOnMouseClicked(e -> { FillTransition ft = new FillTransition(Duration.seconds(0.45), selection, Color.YELLOW, Colors.MENU_ITEM_SELECTION); ft.setOnFinished(e2 -> action.run()); ft.play(); }); }
@FXML private void startButtonPressed(ActionEvent event) { // transition that changes a shape's fill FillTransition fillTransition = new FillTransition(Duration.seconds(1)); fillTransition.setToValue(Color.CYAN); fillTransition.setCycleCount(2); // each even cycle plays transition in reverse to restore original fillTransition.setAutoReverse(true); // transition that changes a shape's stroke over time StrokeTransition strokeTransition = new StrokeTransition(Duration.seconds(1)); strokeTransition.setToValue(Color.BLUE); strokeTransition.setCycleCount(2); strokeTransition.setAutoReverse(true); // parallelizes multiple transitions ParallelTransition parallelTransition = new ParallelTransition(fillTransition, strokeTransition); // transition that changes a node's opacity over time FadeTransition fadeTransition = new FadeTransition(Duration.seconds(1)); fadeTransition.setFromValue(1.0); // opaque fadeTransition.setToValue(0.0); // transparent fadeTransition.setCycleCount(2); fadeTransition.setAutoReverse(true); // transition that rotates a node RotateTransition rotateTransition = new RotateTransition(Duration.seconds(1)); rotateTransition.setByAngle(360.0); rotateTransition.setCycleCount(2); rotateTransition.setInterpolator(Interpolator.EASE_BOTH); rotateTransition.setAutoReverse(true); // transition that moves a node along a Path Path path = new Path(new MoveTo(45, 45), new LineTo(45, 0), new LineTo(90, 0), new LineTo(90, 90), new LineTo(0, 90)); PathTransition translateTransition = new PathTransition(Duration.seconds(2), path); translateTransition.setCycleCount(2); translateTransition.setInterpolator(Interpolator.EASE_IN); translateTransition.setAutoReverse(true); // transition that scales a shape to make it larger or smaller ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(1)); scaleTransition.setByX(0.75); scaleTransition.setByY(0.75); scaleTransition.setCycleCount(2); scaleTransition.setInterpolator(Interpolator.EASE_OUT); scaleTransition.setAutoReverse(true); // transition that applies a sequence of transitions to a node SequentialTransition sequentialTransition = new SequentialTransition (rectangle, parallelTransition, fadeTransition, rotateTransition, translateTransition, scaleTransition); sequentialTransition.play(); // play the transition }
@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 static Transition fazerTransicao(Transicoes transicao, double duracaoSegundos, Node alvo) { Duration duracao = new Duration(duracaoSegundos * 1000); Transition t = null; switch (transicao) { case FADE: FadeTransition fadeTransition = new FadeTransition(); fadeTransition.setFromValue(1); fadeTransition.setToValue(0); fadeTransition.setDuration(duracao); fadeTransition.setNode(alvo); t = fadeTransition; break; case FILL: FillTransition fillTransition = new FillTransition(); fillTransition.setFromValue(Color.RED); fillTransition.setToValue(Color.DARKGREEN); fillTransition.setDuration(duracao); fillTransition.setShape((Shape) alvo); t = fillTransition; break; case ROTATE: RotateTransition rotateTransition = new RotateTransition(); rotateTransition.setByAngle(360); rotateTransition.setDuration(duracao); rotateTransition.setNode(alvo); t = rotateTransition; break; case SCALE: ScaleTransition scaleTransition = new ScaleTransition(); scaleTransition.setFromX(1); scaleTransition.setFromY(1); scaleTransition.setToX(4); scaleTransition.setToY(4); scaleTransition.setDuration(duracao); scaleTransition.setNode(alvo); t = scaleTransition; break; case TRANSLATE: TranslateTransition translateTransition = new TranslateTransition(); translateTransition.setToX(600); translateTransition.setToY(250); translateTransition.setDuration(duracao); translateTransition.setNode(alvo); t = translateTransition; break; default: break; } t.setAutoReverse(true); t.setCycleCount(2); return t; }
@Override public void start(Stage preloaderStage) throws IOException { final StackPane root = FXMLLoader.load(GripPreloader.class.getResource("Preloader.fxml")); // Animated hexagon grid background // wrap in runLater so we can get the size of the scene Platform.runLater(() -> { Random random = new Random(System.currentTimeMillis() ^ (System.currentTimeMillis() >> 16)); HexagonGrid hexagonGrid = new HexagonGrid( (int) (preloaderStage.getScene().getWidth() / HEXAGON_RADIUS), (int) (preloaderStage.getScene().getHeight() / HEXAGON_RADIUS), HEXAGON_RADIUS, 0); // animate the hexagons hexagonGrid.hexagons() .stream() .map(h -> new FillTransition( Duration.seconds( clamp(random.nextGaussian() + 1, 0, 2) * (maxTime - minTime) + minTime), h, primaryColor, secondaryColor)) .peek(t -> t.setCycleCount(Animation.INDEFINITE)) .peek(t -> t.setAutoReverse(true)) .forEach(t -> t.playFrom(Duration.seconds(random.nextDouble() * maxTime * 16))); Pane backgroundContainer = new Pane(hexagonGrid); // bring the hexagons to the top edge to avoid weird blank spots backgroundContainer.setTranslateY(-HEXAGON_RADIUS); root.getChildren().add(0, backgroundContainer); }); Scene scene = new Scene(root); System.setProperty("prism.lcdtext", "false"); if (getParameters().getRaw().contains("windowed")) { preloaderStage.initStyle(StageStyle.UNDECORATED); } else { preloaderStage.initStyle(StageStyle.TRANSPARENT); } preloaderStage.setScene(scene); preloaderStage.setAlwaysOnTop(true); preloaderStage.setResizable(false); preloaderStage.show(); this.preloaderStage = preloaderStage; }