<commit_before>/*
 * Copyright (c) 2017 by <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package eu.hansolo.tilesfx.chart;

import eu.hansolo.tilesfx.Tile;
import eu.hansolo.tilesfx.events.ChartDataEvent;
import eu.hansolo.tilesfx.events.ChartDataEvent.EventType;
import eu.hansolo.tilesfx.events.ChartDataEventListener;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.DoublePropertyBase;
import javafx.scene.paint.Color;
import javafx.util.Duration;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import static eu.hansolo.tilesfx.tools.Helper.clamp;


/**
 * Created by hansolo on 17.02.17.
 */
public class ChartData {
    private final ChartDataEvent         UPDATE_EVENT = new ChartDataEvent(EventType.UPDATE, ChartData.this);
    private final ChartDataEvent         FINISHED_EVENT = new ChartDataEvent(EventType.FINISHED, ChartData.this);
    private String                       name;
    private double                       value;
    private Color                        color;
    private Instant                      timestamp;
    private boolean                      animated;
    private long                         animationDuration;
    private List<ChartDataEventListener> listenerList = new CopyOnWriteArrayList<>();
    private DoubleProperty               currentValue;
    private Timeline                     timeline;


    // ******************** Constructors **************************************
    public ChartData() {
        this("", 0, Tile.BLUE, Instant.now());
    }
    public ChartData(double VALUE) {
        this("", VALUE, Tile.BLUE, Instant.now());
    }
    public ChartData(final double VALUE, final Instant TIMESTAMP) {
        this("", VALUE, Tile.BLUE, TIMESTAMP);
    }
    public ChartData(final String NAME, final double VALUE) {
        this(NAME, VALUE, Tile.BLUE, Instant.now());
    }
    public ChartData(final String NAME, final double VALUE, final Instant TIMESTAMP) {
        this(NAME, VALUE, Tile.BLUE, TIMESTAMP);
    }
    public ChartData(final String NAME, final double VALUE, final Color COLOR) {
        this(NAME, VALUE, COLOR, Instant.now());
    }
    public ChartData(final String NAME, final double VALUE, final Color COLOR, final Instant TIMESTAMP) {
        name              = NAME;
        value             = VALUE;
        color             = COLOR;
        timestamp         = TIMESTAMP;
        currentValue      = new DoublePropertyBase(value) {
            @Override protected void invalidated() {
                value = get();
                fireChartDataEvent(UPDATE_EVENT);
            }
            @Override public Object getBean() { return ChartData.this; }
            @Override public String getName() { return "currentValue"; }
        };
        timeline          = new Timeline();
        animated          = true;
        animationDuration = 800;

        timeline.setOnFinished(e -> fireChartDataEvent(FINISHED_EVENT));
    }


    // ******************** Methods *******************************************
    public String getName() { return name; }<commit_msg>Cosmetics<commit_after>/*
 * Copyright (c) 2017 by <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package eu.hansolo.tilesfx.chart;

import eu.hansolo.tilesfx.Tile;
import eu.hansolo.tilesfx.events.ChartDataEvent;
import eu.hansolo.tilesfx.events.ChartDataEvent.EventType;
import eu.hansolo.tilesfx.events.ChartDataEventListener;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.DoublePropertyBase;
import javafx.scene.paint.Color;
import javafx.util.Duration;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import static eu.hansolo.tilesfx.tools.Helper.clamp;


/**
 * Created by hansolo on 17.02.17.
 */
public class ChartData {
    private final ChartDataEvent         UPDATE_EVENT = new ChartDataEvent(EventType.UPDATE, ChartData.this);
    private final ChartDataEvent         FINISHED_EVENT = new ChartDataEvent(EventType.FINISHED, ChartData.this);
    private String                       name;
    private double                       value;
    private Color                        color;
    private Instant                      timestamp;
    private boolean                      animated;
    private long                         animationDuration;
    private List<ChartDataEventListener> listenerList = new CopyOnWriteArrayList<>();
    private DoubleProperty               currentValue;
    private Timeline                     timeline;


    // ******************** Constructors **************************************
    public ChartData() {
        this("", 0, Tile.BLUE, Instant.now());
    }
    public ChartData(double VALUE) {
        this("", VALUE, Tile.BLUE, Instant.now());
    }
    public ChartData(final double VALUE, final Instant TIMESTAMP) {
        this("", VALUE, Tile.BLUE, TIMESTAMP);
    }
    public ChartData(final String NAME, final double VALUE) {
        this(NAME, VALUE, Tile.BLUE, Instant.now());
    }
    public ChartData(final String NAME, final double VALUE, final Instant TIMESTAMP) {
        this(NAME, VALUE, Tile.BLUE, TIMESTAMP);
    }
    public ChartData(final String NAME, final double VALUE, final Color COLOR) {
        this(NAME, VALUE, COLOR, Instant.now());
    }
    public ChartData(final String NAME, final double VALUE, final Color COLOR, final Instant TIMESTAMP) {
        this(NAME, VALUE, COLOR, TIMESTAMP, true, 800);
    }
    public ChartData(final String NAME, final double VALUE, final Color COLOR, final Instant TIMESTAMP, final boolean ANIMATED, final long ANIMATION_DURATION) {
        name              = NAME;
        value             = VALUE;
        color             = COLOR;
        timestamp         = TIMESTAMP;
        currentValue      = new DoublePropertyBase(value) {
            @Override protected void invalidated() {
                value = get();
                fireChartDataEvent(UPDATE_EVENT);
            }
            @Override public Object getBean() { return ChartData.this; }
            @Override public String getName() { return "currentValue"; }
        };
        timeline          = new Timeline();
        animated          = ANIMATED;
        animationDuration = ANIMATION_DURATION;

        timeline.setOnFinished(e -> fireChartDataEvent(FINISHED_EVENT));
    }


    // ******************** Methods *******************************************
    public String getName() { return name; }
{'fraction_non_alphanumeric': 0.11369346733668342, 'fraction_numerical': 0.004522613065326633, 'mean_word_length': 2.7096924510717613, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2763748', 'n_tokens_mistral': 2178, 'n_tokens_neox': 2079, 'n_words': 617}