/*
 * Copyright 2017 Matthieu Casanova
 *
 * 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 com.kpouer.eosphoros.ambient;

import com.kpouer.eosphoros.Eosphoros;
import com.kpouer.eosphoros.config.Konfig;
import com.kpouer.eosphoros.message.ChangeFrequencyMessage;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;

/**
 * @author Matthieu Casanova
 */
public class AmbientController
{
  public TextField frequency;
  public Button pauseButton;
  public CheckBox ignoreGrey;
  private ColorThread colorThread;
  private int currentFrequency;

  @FXML
  public void initialize()
  {
    colorThread = new ColorThread();
    colorThread.start();
    ignoreGrey.setSelected(colorThread.isIgnoreGrey());
    currentFrequency = Eosphoros.config.getFrequency();
    frequency.setText(Integer.toString(currentFrequency));
    frequency.focusedProperty().addListener((observable, oldValue, newValue) -> changeFrequency(null));
  }

  public void togglePause(ActionEvent actionEvent)
  {
    colorThread.togglePause();
    pauseButton.setText(colorThread.isPausing() ? "Unpause" : "Pause");
  }

  public void lightSelection(ActionEvent actionEvent)
  {
    colorThread.handleStopMessage(null);
    Eosphoros.instance.chooseLights();
  }

  public void off(ActionEvent actionEvent)
  {
    colorThread.pause();
    pauseButton.setText(colorThread.isPausing() ? "Unpause" : "Pause");
    colorThread.lightsOff();
  }

  public void changeFrequency(ActionEvent actionEvent)
  {
    int freq = Integer.parseInt(frequency.getText());
    if (freq < Konfig.MIN_FREQUENCY)
      freq = Konfig.MIN_FREQUENCY;
    if (currentFrequency != freq)
    {
      currentFrequency = freq;
      Eosphoros.eventBus.post(new ChangeFrequencyMessage(freq));
    }
  }

  public void toggleIgnoreGrey(ActionEvent actionEvent)
  {
    colorThread.setIgnoreGrey(ignoreGrey.isSelected());
  }
}

@@ -1019,22 +1019,31 @@
 ler%0A%7B%0A  
-public
+@FXML%0A  private
  TextFie
@@ -1058,22 +1058,31 @@
 ency;%0A  
-public
+@FXML%0A  private
  Button 
@@ -1096,22 +1096,31 @@
 tton;%0A  
-public
+@FXML%0A  private
  CheckBo
@@ -1574,32 +1574,40 @@
 cy(null));%0A  %7D%0A%0A
+  @FXML%0A
   public void to
@@ -1745,32 +1745,40 @@
  %22Pause%22);%0A  %7D%0A%0A
+  @FXML%0A
   public void li
@@ -1896,32 +1896,40 @@
 eLights();%0A  %7D%0A%0A
+  @FXML%0A
   public void of
@@ -2086,24 +2086,32 @@
 Off();%0A  %7D%0A%0A
+  @FXML%0A
   public voi
@@ -2430,16 +2430,24 @@
  %7D%0A  %7D%0A%0A
+  @FXML%0A
   public

Add @FXML annotations