Search in sources :

Example 1 with FillTransition

use of javafx.animation.FillTransition in project tilesfx by HanSolo.

the class StockTileSkin method handleCurrentValue.

@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();
}
Also used : MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) FillTransition(javafx.animation.FillTransition) RotateTransition(javafx.animation.RotateTransition) ParallelTransition(javafx.animation.ParallelTransition)

Example 2 with FillTransition

use of javafx.animation.FillTransition in project tilesfx by HanSolo.

the class HighLowTileSkin method handleCurrentValue.

@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();
}
Also used : FillTransition(javafx.animation.FillTransition) RotateTransition(javafx.animation.RotateTransition) ParallelTransition(javafx.animation.ParallelTransition)

Aggregations

FillTransition (javafx.animation.FillTransition)2 ParallelTransition (javafx.animation.ParallelTransition)2 RotateTransition (javafx.animation.RotateTransition)2 LineTo (javafx.scene.shape.LineTo)1 MoveTo (javafx.scene.shape.MoveTo)1