corefx - added throughput display toggle
This commit is contained in:
parent
c45a0af088
commit
2a879ce0ba
5 changed files with 48 additions and 13 deletions
|
@ -42,6 +42,7 @@ import java.util.stream.Collectors;
|
|||
public class NetworkGraph {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final int EDGE_LABEL_OFFSET = -5;
|
||||
private static final int EDGE_WIDTH = 5;
|
||||
private Controller controller;
|
||||
private ObservableGraph<CoreNode, CoreLink> graph;
|
||||
private StaticLayout<CoreNode, CoreLink> graphLayout;
|
||||
|
@ -64,6 +65,8 @@ public class NetworkGraph {
|
|||
|
||||
// display options
|
||||
private boolean showThroughput = false;
|
||||
private Double throughputLimit = null;
|
||||
private int throughputWidth = 10;
|
||||
|
||||
public NetworkGraph(Controller controller) {
|
||||
this.controller = controller;
|
||||
|
@ -90,22 +93,28 @@ public class NetworkGraph {
|
|||
});
|
||||
|
||||
// link render properties
|
||||
renderContext.setEdgeLabelTransformer(link -> {
|
||||
if (!showThroughput || link == null) {
|
||||
renderContext.setEdgeLabelTransformer(edge -> {
|
||||
if (!showThroughput || edge == null) {
|
||||
return null;
|
||||
}
|
||||
double kbps = link.getThroughput() / 1000.0;
|
||||
double kbps = edge.getThroughput() / 1000.0;
|
||||
return String.format("%.2f kbps", kbps);
|
||||
});
|
||||
renderContext.setLabelOffset(EDGE_LABEL_OFFSET);
|
||||
renderContext.setEdgeStrokeTransformer(edge -> {
|
||||
// determine edge width
|
||||
int width = EDGE_WIDTH;
|
||||
if (throughputLimit != null && edge.getThroughput() > throughputLimit) {
|
||||
width = throughputWidth;
|
||||
}
|
||||
|
||||
LinkTypes linkType = LinkTypes.get(edge.getType());
|
||||
if (LinkTypes.WIRELESS == linkType) {
|
||||
float[] dash = {15.0f};
|
||||
return new BasicStroke(5, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND,
|
||||
return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND,
|
||||
0, dash, 0);
|
||||
} else {
|
||||
return new BasicStroke(5);
|
||||
return new BasicStroke(width);
|
||||
}
|
||||
});
|
||||
renderContext.setEdgeShapeTransformer(EdgeShape.line(graph));
|
||||
|
@ -204,6 +213,10 @@ public class NetworkGraph {
|
|||
Color nodeLabelColor = convertJfxColor(configuration.getNodeLabelColor());
|
||||
Color nodeLabelBackgroundColor = convertJfxColor(configuration.getNodeLabelBackgroundColor());
|
||||
nodeLabelRenderer.setColors(nodeLabelColor, nodeLabelBackgroundColor);
|
||||
throughputLimit = configuration.getThroughputLimit();
|
||||
if (configuration.getThroughputWidth() != null) {
|
||||
throughputWidth = configuration.getThroughputWidth();
|
||||
}
|
||||
graphViewer.repaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ public class GuiPreferencesDialog extends StageDialog {
|
|||
@FXML private JFXTextField iconPathTextField;
|
||||
@FXML private JFXColorPicker nodeLabelColorPicker;
|
||||
@FXML private JFXColorPicker nodeLabelBackgroundColorPicker;
|
||||
@FXML private JFXTextField throughputLimitTextField;
|
||||
@FXML private JFXTextField throughputWidthTextField;
|
||||
@FXML private JFXButton saveButton;
|
||||
|
||||
public GuiPreferencesDialog(Controller controller) {
|
||||
|
@ -42,6 +44,8 @@ public class GuiPreferencesDialog extends StageDialog {
|
|||
configuration.setIconPath(iconPathTextField.getText());
|
||||
configuration.setNodeLabelColor(nodeLabelColorPicker.getValue().toString());
|
||||
configuration.setNodeLabelBackgroundColor(nodeLabelBackgroundColorPicker.getValue().toString());
|
||||
configuration.setThroughputLimit(Double.parseDouble(throughputLimitTextField.getText()));
|
||||
configuration.setThroughputWidth(Integer.parseInt(throughputWidthTextField.getText()));
|
||||
getController().getNetworkGraph().updatePreferences(configuration);
|
||||
try {
|
||||
ConfigUtils.save(configuration);
|
||||
|
@ -60,6 +64,17 @@ public class GuiPreferencesDialog extends StageDialog {
|
|||
iconPathTextField.setText(configuration.getIconPath());
|
||||
nodeLabelColorPicker.setValue(Color.web(configuration.getNodeLabelColor()));
|
||||
nodeLabelBackgroundColorPicker.setValue(Color.web(configuration.getNodeLabelBackgroundColor()));
|
||||
String throughputLimit = null;
|
||||
if (configuration.getThroughputLimit() != null) {
|
||||
throughputLimit = configuration.getThroughputLimit().toString();
|
||||
}
|
||||
throughputLimitTextField.setText(throughputLimit);
|
||||
|
||||
String throughputWidth = null;
|
||||
if (configuration.getThroughputWidth() != null) {
|
||||
throughputWidth = configuration.getThroughputWidth().toString();
|
||||
}
|
||||
throughputWidthTextField.setText(throughputWidth);
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,6 @@ public class Configuration {
|
|||
private List<NodeTypeConfig> nodeTypeConfigs = new ArrayList<>();
|
||||
private String nodeLabelColor;
|
||||
private String nodeLabelBackgroundColor;
|
||||
private Double throughputLimit;
|
||||
private Integer throughputWidth;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
<?import com.jfoenix.controls.JFXColorPicker?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import javafx.scene.control.Accordion?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TitledPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<TitledPane animated="false" collapsible="false" text="File Paths">
|
||||
|
||||
<Accordion xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<panes>
|
||||
<TitledPane text="File Paths">
|
||||
<content>
|
||||
<VBox spacing="10.0">
|
||||
<children>
|
||||
|
@ -22,7 +24,7 @@
|
|||
</VBox>
|
||||
</content>
|
||||
</TitledPane>
|
||||
<TitledPane animated="false" collapsible="false" text="Graph">
|
||||
<TitledPane text="Graph">
|
||||
<content>
|
||||
<VBox spacing="10.0">
|
||||
<children>
|
||||
|
@ -30,11 +32,15 @@
|
|||
<JFXColorPicker fx:id="nodeLabelColorPicker" maxWidth="1.7976931348623157E308" />
|
||||
<Label text="Node Label Background" />
|
||||
<JFXColorPicker fx:id="nodeLabelBackgroundColorPicker" maxWidth="1.7976931348623157E308" />
|
||||
<Label text="Throughput Limit" />
|
||||
<JFXTextField fx:id="throughputLimitTextField" />
|
||||
<Label text="Throughput Width" />
|
||||
<JFXTextField fx:id="throughputWidthTextField" />
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</TitledPane>
|
||||
<TitledPane animated="false" collapsible="false" text="Programs">
|
||||
<TitledPane text="Programs">
|
||||
<content>
|
||||
<VBox spacing="10.0">
|
||||
<children>
|
||||
|
@ -44,5 +50,5 @@
|
|||
</VBox>
|
||||
</content>
|
||||
</TitledPane>
|
||||
</children>
|
||||
</VBox>
|
||||
</panes>
|
||||
</Accordion>
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
<Menu mnemonicParsing="false" text="Widgets">
|
||||
<items>
|
||||
<CheckMenuItem fx:id="throughputMenuItem" mnemonicParsing="false" text="Throughput" />
|
||||
<MenuItem mnemonicParsing="false" text="Throughput Config" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Help">
|
||||
|
|
Loading…
Reference in a new issue