Search in sources :

Example 1 with MultiplierType

use of com.exalttech.trex.ui.MultiplierType in project trex-stateless-gui by cisco-system-traffic-generator.

the class MultiplierView method updateOptionsValues.

/**
     * Update options values
     *
     * @param sliderValue
     * @param updateAll
     */
public void updateOptionsValues(double sliderValue, boolean updateAll) {
    for (MultiplierType type : MultiplierType.values()) {
        if (updateAll || type != notToUpdateField.getType()) {
            double val = calcTypeValue(sliderValue, type);
            getMultiplierOption(type).setValue(val);
        }
    }
}
Also used : MultiplierType(com.exalttech.trex.ui.MultiplierType)

Example 2 with MultiplierType

use of com.exalttech.trex.ui.MultiplierType in project trex-stateless-gui by cisco-system-traffic-generator.

the class MultiplierView method fillAssignedProfileValues.

/**
     * Fill assign profile value
     *
     * @param assigned
     */
public void fillAssignedProfileValues(AssignedProfile assigned) {
    rate = assigned.getRate();
    fireUpdateCommand = false;
    resetAllOption();
    MultiplierType type = MultiplierType.valueOf(assigned.getMultiplier().getType());
    setSelected(type);
    // define slider value according to the PPS type
    if (assigned != null && assigned.getRate() != null) {
        double value = assigned.getMultiplier().getValue();
        double sliderValue = getSliderValue(type, value);
        slider.setValue(sliderValue);
        fireUpdateCommand = true;
        // update selection
        MultiplierType selectedType = MultiplierType.valueOf(assigned.getMultiplier().getSelectedType());
        setSelected(selectedType);
    }
    // update duration
    durationCB.setSelected(assigned.isHasDuration());
    durationTF.setText(String.valueOf(assigned.getMultiplier().getDuration()));
}
Also used : MultiplierType(com.exalttech.trex.ui.MultiplierType)

Example 3 with MultiplierType

use of com.exalttech.trex.ui.MultiplierType in project trex-stateless-gui by cisco-system-traffic-generator.

the class MultiplierView method buildUI.

/**
     * Build UI
     */
private void buildUI() {
    // add slider area
    addLabel("Bandwidth", 7, 336);
    addLabel("0", 22, 287);
    addLabel("100", 22, 454);
    slider = new Slider(0, 100, 1);
    slider.setDisable(true);
    getChildren().add(slider);
    MultiplierView.setTopAnchor(slider, 22d);
    MultiplierView.setLeftAnchor(slider, 304d);
    slider.valueProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            // check min value for slider
            if ((double) newValue < MultiplierType.percentage.getMinRate(rate)) {
                slider.setValue(MultiplierType.percentage.getMinRate(rate));
            }
            updateOptionsValues(slider.getValue(), updateAll);
            if (fireUpdateCommand) {
                optionValueChangeHandler.optionValueChanged();
            }
        }
    });
    // add separator
    Separator separator = new Separator(Orientation.HORIZONTAL);
    separator.setPrefHeight(1);
    getChildren().add(separator);
    MultiplierView.setTopAnchor(separator, 50d);
    MultiplierView.setLeftAnchor(separator, 15d);
    MultiplierView.setRightAnchor(separator, 15d);
    group = new ToggleGroup();
    int index = 0;
    double prevComponentWidth = 0;
    AnchorPane optionContainer = new AnchorPane();
    getChildren().add(optionContainer);
    MultiplierView.setTopAnchor(optionContainer, 51d);
    MultiplierView.setLeftAnchor(optionContainer, 15d);
    MultiplierView.setRightAnchor(optionContainer, 150d);
    for (MultiplierType type : MultiplierType.values()) {
        MultiplierOption option = new MultiplierOption(type.getTitle(), group, type, this);
        option.setMultiplierSelectionEvent(this);
        optionContainer.getChildren().add(option);
        double leftSpace = prevComponentWidth + (index * 15);
        MultiplierView.setLeftAnchor(option, leftSpace);
        MultiplierView.setTopAnchor(option, 0d);
        MultiplierView.setBottomAnchor(option, 0d);
        multiplierOptionMap.put(type, option);
        index++;
        prevComponentWidth += option.getComponentWidth();
    }
    multiplierOptionMap.get(MultiplierType.pps).setSelected();
    // add suration
    Separator vSeparator = new Separator(Orientation.VERTICAL);
    vSeparator.setPrefWidth(1);
    getChildren().add(vSeparator);
    MultiplierView.setTopAnchor(vSeparator, 93d);
    MultiplierView.setLeftAnchor(vSeparator, 560d);
    MultiplierView.setBottomAnchor(vSeparator, 15d);
    addLabel("Duration", 70, 606);
    durationCB = new CheckBox();
    getChildren().add(durationCB);
    MultiplierView.setTopAnchor(durationCB, 94d);
    MultiplierView.setLeftAnchor(durationCB, 581d);
    MultiplierView.setBottomAnchor(durationCB, 20d);
    durationTF = new TextField("0");
    durationTF.setPrefSize(70, 22);
    durationTF.setDisable(true);
    getChildren().add(durationTF);
    MultiplierView.setTopAnchor(durationTF, 93d);
    MultiplierView.setLeftAnchor(durationTF, 606d);
    MultiplierView.setBottomAnchor(durationTF, 15d);
    durationTF.disableProperty().bind(durationCB.selectedProperty().not());
    durationTF.setTextFormatter(Util.getNumberFilter(4));
}
Also used : Slider(javafx.scene.control.Slider) MultiplierOption(com.exalttech.trex.ui.components.MultiplierOption) MultiplierType(com.exalttech.trex.ui.MultiplierType) CheckBox(javafx.scene.control.CheckBox) ToggleGroup(javafx.scene.control.ToggleGroup) TextField(javafx.scene.control.TextField) AnchorPane(javafx.scene.layout.AnchorPane) Separator(javafx.scene.control.Separator)

Aggregations

MultiplierType (com.exalttech.trex.ui.MultiplierType)3 MultiplierOption (com.exalttech.trex.ui.components.MultiplierOption)1 CheckBox (javafx.scene.control.CheckBox)1 Separator (javafx.scene.control.Separator)1 Slider (javafx.scene.control.Slider)1 TextField (javafx.scene.control.TextField)1 ToggleGroup (javafx.scene.control.ToggleGroup)1 AnchorPane (javafx.scene.layout.AnchorPane)1