Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package entregable2;
- import java.net.URL;
- import java.lang.Number;
- import java.sql.JDBCType;
- import java.util.LinkedList;
- import java.util.ResourceBundle;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.chart.LineChart;
- import javafx.scene.chart.XYChart;
- import javafx.scene.control.Slider;
- /**
- * FXML Controller class
- *
- * @author arsamrei
- */
- public class FXMLStack3Controller implements Initializable {
- private static final int SEGUNDOSPORMINUTO = 10; // para pruebas
- private static XYChart.Series seriesTWD;
- private static XYChart.Series seriesTWS;
- @FXML
- private LineChart<String, Number> lineChartTWD;
- @FXML
- private LineChart<String, Number> lineChartTWS;
- @FXML
- private static Slider sliderSeleccion;
- private static int segundosTWD;
- private static int segundosTWS;
- private static int max;
- /**
- * Initializes the controller class.
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- //max = SEGUNDOSPORMINUTO;
- segundosTWD = 0;
- segundosTWS = 0;
- seriesTWD = new XYChart.Series();
- seriesTWS = new XYChart.Series();
- lineChartTWD.setCreateSymbols(false);
- lineChartTWS.setCreateSymbols(false);
- lineChartTWD.setLegendVisible(false);
- lineChartTWS.setLegendVisible(false);
- lineChartTWD.getData().add(seriesTWD);
- lineChartTWS.getData().add(seriesTWS);
- sliderSeleccion.valueProperty().addListener((obs, oldValue, newValue) -> {
- max = (int) sliderSeleccion.getValue() * SEGUNDOSPORMINUTO;
- while(seriesTWD.getData().size() > max) {
- seriesTWD.getData().remove(0, seriesTWD.getData().size() - max);
- }
- while(seriesTWS.getData().size() > max) {
- seriesTWS.getData().remove(0, seriesTWS.getData().size() - max);
- }
- });
- }
- public static void addTWD(Number x) {
- seriesTWD.getData().add(new XYChart.Data("" + segundosTWD++, x));
- //se asegura de que no se supere el maximo al insertar
- while(seriesTWD.getData().size() > max) {
- seriesTWD.getData().remove(0, seriesTWD.getData().size() - max);
- }
- }
- public static void addTWS(Number x) {
- seriesTWS.getData().add(new XYChart.Data("" + segundosTWS++, x));
- //se asegura de que no se supere el maximo al insertar
- while(seriesTWS.getData().size() > max) {
- seriesTWS.getData().remove(0, seriesTWS.getData().size() - max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement