use of com.exalttech.trex.ui.components.MultiplierOption 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));
}
use of com.exalttech.trex.ui.components.MultiplierOption in project trex-stateless-gui by cisco-system-traffic-generator.
the class MultiplierView method getPPSValue.
/**
* Return PPS value
*
* @return
*/
public double getPPSValue() {
MultiplierOption option = multiplierOptionMap.get(MultiplierType.pps);
validateSelectedMultiplierValue();
if (rate == null) {
return option.getMultiplierValue();
}
final double minRate = MultiplierType.pps.getMinRate(rate);
final double maxRate = MultiplierType.pps.getMaxRate(rate);
// force PPS value to 1 if it less than 1
if (option.getMultiplierValue() <= minRate && maxRate > minRate) {
option.setValue(minRate + 1.0);
updateAll(option);
}
return option.getMultiplierValue();
}
Aggregations