Search in sources :

Example 1 with SensorField

use of il.ac.technion.cs.smarthouse.simulator.model.SensorField in project Smartcity-Smarthouse by TechnionYP5777.

the class MessageViewController method buildStreamModePane.

void buildStreamModePane() {
    streamFieldMap = new HashMap<>();
    int currentRow = 0;
    streamMode.add(new Label("Name"), 0, currentRow);
    streamMode.add(new Label("From"), 1, currentRow);
    streamMode.add(new Label("To"), 2, currentRow++);
    for (final SensorField ¢ : currentSensor.getFields()) {
        streamMode.add(new Label(¢.getName()), 0, currentRow);
        final List<Node> nodes = new ArrayList<>();
        if (¢.getType() == Types.BOOLEAN) {
            final ComboBox<BooleanValues> b = new ComboBox<>();
            b.getItems().addAll(BooleanValues.values());
            streamMode.add(b, 1, currentRow);
            nodes.add(b);
        } else {
            final TextField t1 = new TextField(), t2 = new TextField();
            streamMode.add(t1, 1, currentRow);
            nodes.add(t1);
            if (¢.getType() != Types.STRING) {
                streamMode.add(t2, 2, currentRow);
                nodes.add(t2);
            }
        }
        streamFieldMap.put(¢, nodes);
        ++currentRow;
    }
    streamMode.add(new Label("Send Interval(integer only):"), 0, currentRow);
    final TextField t1 = new TextField(), t2 = new TextField();
    streamMode.add(t1, 1, currentRow);
    streamMode.add(t2, 2, currentRow);
    timeInput = new Pair<>(t1, t2);
}
Also used : SensorField(il.ac.technion.cs.smarthouse.simulator.model.SensorField) ComboBox(javafx.scene.control.ComboBox) Node(javafx.scene.Node) Label(javafx.scene.control.Label) ArrayList(java.util.ArrayList) TextField(javafx.scene.control.TextField)

Example 2 with SensorField

use of il.ac.technion.cs.smarthouse.simulator.model.SensorField in project Smartcity-Smarthouse by TechnionYP5777.

the class MessageViewController method buildMessage.

@SuppressWarnings("unchecked")
void buildMessage() {
    String message = "";
    for (final SensorField field : singleFieldMap.keySet()) {
        message += " " + field.getName() + " ";
        if (field.getType() == Types.BOOLEAN)
            message += ((ComboBox<BooleanValues>) singleFieldMap.get(field)).getValue();
        else {
            final String Input = ((TextField) singleFieldMap.get(field)).getText();
            if (!validateInput(Input, field.getType()))
                return;
            message += Input;
        }
    }
    message += "\n";
    showMessage(message);
}
Also used : SensorField(il.ac.technion.cs.smarthouse.simulator.model.SensorField) ComboBox(javafx.scene.control.ComboBox) TextField(javafx.scene.control.TextField)

Example 3 with SensorField

use of il.ac.technion.cs.smarthouse.simulator.model.SensorField in project Smartcity-Smarthouse by TechnionYP5777.

the class MessageViewController method buildSingleModePane.

void buildSingleModePane() {
    singleFieldMap = new HashMap<>();
    int currentRow = 0;
    singleMode.add(new Label("Name"), 0, currentRow);
    singleMode.add(new Label("Value"), 1, currentRow++);
    for (final SensorField ¢ : currentSensor.getFields()) {
        singleMode.add(new Label(¢.getName()), 0, currentRow);
        if (¢.getType() != Types.BOOLEAN) {
            final TextField t = new TextField();
            singleMode.add(t, 1, currentRow);
            singleFieldMap.put(¢, t);
        } else {
            final ComboBox<BooleanValues> b = new ComboBox<>();
            b.getItems().addAll(BooleanValues.values());
            singleMode.add(b, 1, currentRow);
            singleFieldMap.put(¢, b);
        }
        ++currentRow;
    }
}
Also used : SensorField(il.ac.technion.cs.smarthouse.simulator.model.SensorField) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField)

Aggregations

SensorField (il.ac.technion.cs.smarthouse.simulator.model.SensorField)3 ComboBox (javafx.scene.control.ComboBox)3 TextField (javafx.scene.control.TextField)3 Label (javafx.scene.control.Label)2 ArrayList (java.util.ArrayList)1 Node (javafx.scene.Node)1