Skip to content

Commit

Permalink
Merge remote-tracking branch 'Tainfante_origin/master' into poprawki_…
Browse files Browse the repository at this point in the history
…Agaty
  • Loading branch information
opetany93 committed Jan 24, 2018
2 parents c5e1d12 + fa6ac14 commit 1f3b623
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 130 deletions.
146 changes: 119 additions & 27 deletions src/mainwindow/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

Expand All @@ -21,9 +23,13 @@ public class Channel implements Initializable{
@FXML
private TextField unitText;
@FXML
private ChoiceBox channelBox;
private ChoiceBox<String> channelBox;
@FXML
private ColorPicker colorPicker;
private String channel;
private String name;
private String units;
private Color color=Color.RED;

@Override
public void initialize(URL location, ResourceBundle resources) {
Expand All @@ -37,36 +43,122 @@ public void initialize(URL location, ResourceBundle resources) {
channelBox.getItems().add("Channel 8");
}

public void onSetAction(ActionEvent actionEvent) {
String channel=new String();
String name=nameText.getText();
String units=unitText.getText();
Color color=colorPicker.getValue();
try{
channel=(String)channelBox.getSelectionModel().getSelectedItem();
if(channel.equals("Channel 1")){
Chart.getInstance().channelUpdate(1,name+" ["+units+"]",color);
}
else if(channel.equals("Channel 2")){
Chart.getInstance().channelUpdate(2,name+" ["+units+"]",color);
}
else if(channel.equals("Channel 3")){
Chart.getInstance().channelUpdate(3,name+" ["+units+"]", color);
public void onNameKeyPressed(KeyEvent keyEvent) {
if(keyEvent.getCode() == KeyCode.ENTER){
try{
name=nameText.getText();
channel=channelBox.getSelectionModel().getSelectedItem();
channel=channelBox.getSelectionModel().getSelectedItem();
switch (channel) {
case "Channel 1":
Chart.getInstance().channelUpdateWithoutColor(1, name, units);
break;
case "Channel 2":
Chart.getInstance().channelUpdateWithoutColor(2, name, units);
break;
case "Channel 3":
Chart.getInstance().channelUpdateWithoutColor(3, name,units);
break;
case "Channel 4":
Chart.getInstance().channelUpdateWithoutColor(4, name,units);
break;
case "Channel 5":
Chart.getInstance().channelUpdateWithoutColor(5, name,units);
break;
case "Channel 6":
Chart.getInstance().channelUpdateWithoutColor(6, name ,units);
break;
case "Channel 7":
Chart.getInstance().channelUpdateWithoutColor(7, name,units);
break;
case "Channel 8":
Chart.getInstance().channelUpdateWithoutColor(8, name,units);
break;
}
}
else if(channel.equals("Channel 4")){
Chart.getInstance().channelUpdate(4,name+" ["+units+"]", color);
catch(NullPointerException exe){
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Channel has not been chosen");
alert.setHeaderText("To submit channel settings you have to choose a channel");
alert.setContentText("Please, choose a channel");
alert.showAndWait();
}
else if(channel.equals("Channel 5")){
Chart.getInstance().channelUpdate(5,name+" ["+units+"]", color);
}
else if(channel.equals("Channel 6")){
Chart.getInstance().channelUpdate(6,name+" ["+units+"]", color);
}
}

public void onUnitKeyPressed(KeyEvent keyEvent) {
if(keyEvent.getCode() == KeyCode.ENTER){
try{
if(!unitText.getText().isEmpty()){
units="["+unitText.getText()+"]";
}
channel=channelBox.getSelectionModel().getSelectedItem();
switch (channel) {
case "Channel 1":
Chart.getInstance().channelUpdateWithoutColor(1, name, units);
break;
case "Channel 2":
Chart.getInstance().channelUpdateWithoutColor(2, name, units);
break;
case "Channel 3":
Chart.getInstance().channelUpdateWithoutColor(3, name,units);
break;
case "Channel 4":
Chart.getInstance().channelUpdateWithoutColor(4, name,units);
break;
case "Channel 5":
Chart.getInstance().channelUpdateWithoutColor(5, name,units);
break;
case "Channel 6":
Chart.getInstance().channelUpdateWithoutColor(6, name ,units);
break;
case "Channel 7":
Chart.getInstance().channelUpdateWithoutColor(7, name,units);
break;
case "Channel 8":
Chart.getInstance().channelUpdateWithoutColor(8, name,units);
break;
}
}
else if(channel.equals("Channel 7")){
Chart.getInstance().channelUpdate(7,name+" ["+units+"]", color);
catch(NullPointerException exe){
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Channel has not been chosen");
alert.setHeaderText("To submit channel settings you have to choose a channel");
alert.setContentText("Please, choose a channel");
alert.showAndWait();
}
else if(channel.equals("Channel 8")){
Chart.getInstance().channelUpdate(8,name+" ["+units+"]", color);
}
}

public void onPickColor(ActionEvent actionEvent) {
try{
color=colorPicker.getValue();
channel=channelBox.getSelectionModel().getSelectedItem();
switch (channel) {
case "Channel 1":
Chart.getInstance().channelUpdateColor(1, color);
break;
case "Channel 2":
Chart.getInstance().channelUpdateColor(2, color);
break;
case "Channel 3":
Chart.getInstance().channelUpdateColor(3, color);
break;
case "Channel 4":
Chart.getInstance().channelUpdateColor(4, color);
break;
case "Channel 5":
Chart.getInstance().channelUpdateColor(5, color);
break;
case "Channel 6":
Chart.getInstance().channelUpdateColor(6, color);
break;
case "Channel 7":
Chart.getInstance().channelUpdateColor(7, color);
break;
case "Channel 8":
Chart.getInstance().channelUpdateColor(8, color);
break;
}
}
catch(NullPointerException exe){
Expand Down
Loading

0 comments on commit 1f3b623

Please sign in to comment.