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);
}
}
}
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()));
}
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));
}
Aggregations