<commit_before>/*
 * Notes: 
 * 
 */
package FanManager.model;

import FanManager.GaugeObject;
import FanManager.view.Section;
import FanManager.FreqInputField;
import FanManager.SpeedInputField;
import java.util.Random;
import javafx.animation.AnimationTimer;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

/**
 *
 * @author Reign & Felix
 */
public class FanPane extends FlowPane {

    private static final double WIDTH = 350, HEIGHT = 768;
    private static int nextId = 0;
    private int id;
    
    // Gauge
    private static final Random RND = new Random();
    private Section[]           sections;
    private long                lastTimerCall;
    private AnimationTimer      timer;
    private GaugeObject         gauge;

    // Speed Input Field
    private SpeedInputField     speedField;
    
    // Frequency Input Field
    private FreqInputField     freqField;

 
    // Slider
    private Slider speedKnob;
    private Slider freqKnob;

    // Label
    final private Label speedInputLabel = new Label();


    // Fan Object
    private Fan                 fan;

    // Temperature 
    TextField                   temperatureTF;

    public FanPane() {
        // Create an individual ID for Fan Pane
        id = ++nextId;

        // Create a maximum width and height for predictable columns
        setMaxWidth(WIDTH);
        setMaxHeight(HEIGHT);

        // Create fan object
        fan = new Fan();

        // Create gauge
        gauge = gauge();
        gauge.setTranslateX((int) (WIDTH / 24));
        gauge.setTranslateY((int) (HEIGHT / 32));
        gauge.setStyle("-fx-background-color: transparent");

        
        // Create input textfields
        speedField = SpeedInputField();
        freqField = FreqInputField();
        
    // Temperature
        // Create and style temperature label
        Label temperatureLabel = new Label("Temperature");
        temperatureLabel.setTranslateX((int) (WIDTH / 2) - 150);
        temperatureLabel.setTranslateY((int) (HEIGHT / 4) + 200);
        temperatureLabel.setStyle("-fx-background-color: green");

        // Create temperature text field
        temperatureTF = new TextField();
        temperatureTF.setTranslateX((int) (WIDTH / 2) - 70);
        temperatureTF.setTranslateY((int) (HEIGHT / 4) + 200);
        temperatureTF.setText("" + fan.getTemperature());

        
    // Speed
        // Create and style speed label
        Label speedLabel = new Label("Speed");
        speedLabel.setTranslateX((int) (WIDTH / 2) - 130);
        speedLabel.setTranslateY((int) (HEIGHT / 4) + 195);
        speedLabel.setStyle("-fx-text-fill: white;");
//        speedLabel.setStyle("-fx-background-color: green");

        // Create speed Knob
	speedKnob = new Slider(0,100,0);
	speedKnob.setBlockIncrement(0.1);
	speedKnob.setId("knob");
	speedKnob.getStyleClass().add("knobStyle");
        speedKnob.setTranslateX((int) (WIDTH / 2) - 90);
        speedKnob.setTranslateY((int) (HEIGHT / 4) + 170);

        // Locate speedField
        speedField.setTranslateX((int) (WIDTH / 16));
        speedField.setTranslateY((int) (HEIGHT / 32) + 390);
        speedField.valueProperty().bindBidirectional(gauge.valueProperty());
        speedField.valueProperty().bindBidirectional(speedKnob.valueProperty());
        speedField.setPrefWidth(75);
    
    // Speed Input Label
        // Create input label
        speedInputLabel.setStyle("-fx-color: white");    
        speedInputLabel.setStyle("-fx-font: 12 arial;"); 
        speedInputLabel.setStyle("-fx-background-color: grey");
        speedInputLabel.setTranslateX((int) (WIDTH / 16));
        speedInputLabel.setTranslateY((int) (HEIGHT / 32 + 300));
        speedInputLabel.setPrefWidth(50);        
        
    // Frequency        
        // Create and style frequency label
        Label freqLabel = new Label("Frequency");
        freqLabel.setTranslateX((int) (WIDTH / 2) - 150);
        freqLabel.setTranslateY((int) (HEIGHT / 4) + 410);
        freqLabel.setStyle("-fx-text-fill: white;");
//        freqLabel.setStyle("-fx-background-color: green");

        // Create frequency Knob
	freqKnob = new Slider(40,40000,40);
	freqKnob.setBlockIncrement(1);
	freqKnob.setId("knob");
	freqKnob.getStyleClass().add("knobStyle");
        freqKnob.setTranslateX((int) (WIDTH / 2) - 90);
        freqKnob.setTranslateY((int) (HEIGHT / 4) + 390);

        // Locate freqField
        freqField.setTranslateX((int) (WIDTH / 16));
        freqField.setTranslateY((int) (HEIGHT / 32) + 600);
        freqField.valueProperty().bindBidirectional(freqKnob.valueProperty());
        freqField.setPrefWidth(75);


        // Get values from speedKnob and the gauge to display in the input label
        speedInputLabel.setText(Math.round(speedKnob.getValue()) + "");
        speedInputLabel.setText(Math.round(gauge.getValue()) + "");
        gauge.valueProperty().addListener(new ChangeListener<Number>() {
            @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
            if (newValue == null) {
              speedLabel.setText("");
              return;
            }
        speedLabel.setText((newValue.doubleValue()) + "");<commit_msg>Fixed Frequency<commit_after>/*
 * Notes: 
 * 
 */
package FanManager.model;

import FanManager.GaugeObject;
import FanManager.view.Section;
import FanManager.FreqInputField;
import FanManager.SpeedInputField;
import java.util.Random;
import javafx.animation.AnimationTimer;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

/**
 *
 * @author Reign & Felix
 */
public class FanPane extends FlowPane {

    private static final double WIDTH = 350, HEIGHT = 768;
    private static int nextId = 0;
    private int id;
    
    // Gauge
    private static final Random RND = new Random();
    private Section[]           sections;
    private long                lastTimerCall;
    private AnimationTimer      timer;
    private GaugeObject         gauge;

    // Speed Input Field
    private SpeedInputField     speedField;
    
    // Frequency Input Field
    private FreqInputField     freqField;

 
    // Slider
    private Slider speedKnob;
    private Slider freqKnob;

    // Label
    final private Label speedInputLabel = new Label();


    // Fan Object
    private Fan                 fan;

    // Temperature 
    TextField                   temperatureTF;

    public FanPane() {
        // Create an individual ID for Fan Pane
        id = ++nextId;

        // Create a maximum width and height for predictable columns
        setMaxWidth(WIDTH);
        setMaxHeight(HEIGHT);

        // Create fan object
        fan = new Fan();

        // Create gauge
        gauge = gauge();
        gauge.setTranslateX((int) (WIDTH / 24));
        gauge.setTranslateY((int) (HEIGHT / 32));
        gauge.setStyle("-fx-background-color: transparent");

        
        // Create input textfields
        speedField = SpeedInputField();
        freqField = FreqInputField();
        
    // Temperature
        // Create and style temperature label
        Label temperatureLabel = new Label("Temperature");
        temperatureLabel.setTranslateX((int) (WIDTH / 2) - 150);
        temperatureLabel.setTranslateY((int) (HEIGHT / 4) + 200);
        temperatureLabel.setStyle("-fx-background-color: green");

        // Create temperature text field
        temperatureTF = new TextField();
        temperatureTF.setTranslateX((int) (WIDTH / 2) - 70);
        temperatureTF.setTranslateY((int) (HEIGHT / 4) + 200);
        temperatureTF.setText("" + fan.getTemperature());

        
    // Speed
        // Create and style speed label
        Label speedLabel = new Label("Speed");
        speedLabel.setTranslateX((int) (WIDTH / 2) - 130);
        speedLabel.setTranslateY((int) (HEIGHT / 4) + 195);
        speedLabel.setStyle("-fx-text-fill: white;");
//        speedLabel.setStyle("-fx-background-color: green");

        // Create speed Knob
	speedKnob = new Slider(0,100,0);
	speedKnob.setBlockIncrement(0.1);
	speedKnob.setId("knob");
	speedKnob.getStyleClass().add("knobStyle");
        speedKnob.setTranslateX((int) (WIDTH / 2) - 90);
        speedKnob.setTranslateY((int) (HEIGHT / 4) + 170);

        // Locate speedField
        speedField.setTranslateX((int) (WIDTH / 16));
        speedField.setTranslateY((int) (HEIGHT / 32) + 390);
        speedField.valueProperty().bindBidirectional(gauge.valueProperty());
        speedField.valueProperty().bindBidirectional(speedKnob.valueProperty());
        speedField.setPrefWidth(75);
    
    // Speed Input Label
        // Create input label
        speedInputLabel.setStyle("-fx-color: white");    
        speedInputLabel.setStyle("-fx-font: 12 arial;"); 
        speedInputLabel.setStyle("-fx-background-color: grey");
        speedInputLabel.setTranslateX((int) (WIDTH / 16));
        speedInputLabel.setTranslateY((int) (HEIGHT / 32 + 300));
        speedInputLabel.setPrefWidth(50);        
        
    // Frequency        
        // Create and style frequency label
        Label freqLabel = new Label("Frequency");
        freqLabel.setTranslateX((int) (WIDTH / 2) - 150);
        freqLabel.setTranslateY((int) (HEIGHT / 4) + 410);
        freqLabel.setStyle("-fx-text-fill: white;");
//        freqLabel.setStyle("-fx-background-color: green");

        // Create frequency Knob
	freqKnob = new Slider(0,40000,40);
	freqKnob.setBlockIncrement(1);
	freqKnob.setId("knob");
	freqKnob.getStyleClass().add("knobStyle");
        freqKnob.setTranslateX((int) (WIDTH / 2) - 90);
        freqKnob.setTranslateY((int) (HEIGHT / 4) + 390);

        // Locate freqField
        freqField.setTranslateX((int) (WIDTH / 16));
        freqField.setTranslateY((int) (HEIGHT / 32) + 600);
        freqField.valueProperty().bindBidirectional(freqKnob.valueProperty());
        freqField.setPrefWidth(75);


        // Get values from speedKnob and the gauge to display in the input label
        speedInputLabel.setText(Math.round(speedKnob.getValue()) + "");
        speedInputLabel.setText(Math.round(gauge.getValue()) + "");
        gauge.valueProperty().addListener(new ChangeListener<Number>() {
            @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
            if (newValue == null) {
              speedLabel.setText("");
              return;
            }
        speedLabel.setText((newValue.doubleValue()) + "");
{'fraction_non_alphanumeric': 0.11938482926405422, 'fraction_numerical': 0.017638369971326787, 'mean_word_length': 2.637800252844501, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3948595', 'n_tokens_mistral': 3542, 'n_tokens_neox': 3257, 'n_words': 729}