From 670ed961670f9ff4707251950cf467b6299f66a9 Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Tue, 18 Sep 2018 13:52:02 -0700 Subject: [PATCH] gui - initial icon edit support --- corefx/src/main/java/com/core/Controller.java | 7 ++ .../src/main/java/com/core/data/CoreNode.java | 21 +++- .../src/main/java/com/core/data/NodeType.java | 6 +- .../java/com/core/graph/NetworkGraph.java | 4 +- .../main/java/com/core/ui/GraphToolbar.java | 24 +++- .../java/com/core/ui/NodeTypesDialog.java | 114 ++++++++++++++++++ .../main/java/com/core/utils/IconUtils.java | 27 ++++- corefx/src/main/resources/fxml/main.fxml | 5 + .../resources/fxml/node_types_dialog.fxml | 78 ++++++++++++ 9 files changed, 263 insertions(+), 23 deletions(-) create mode 100644 corefx/src/main/java/com/core/ui/NodeTypesDialog.java create mode 100644 corefx/src/main/resources/fxml/node_types_dialog.fxml diff --git a/corefx/src/main/java/com/core/Controller.java b/corefx/src/main/java/com/core/Controller.java index a7e001ab..5a424a34 100644 --- a/corefx/src/main/java/com/core/Controller.java +++ b/corefx/src/main/java/com/core/Controller.java @@ -76,6 +76,7 @@ public class Controller implements Initializable { private HooksDialog hooksDialog = new HooksDialog(this); private MobilityDialog mobilityDialog = new MobilityDialog(this); private ChartDialog chartDialog = new ChartDialog(this); + private NodeTypesDialog nodeTypesDialog = new NodeTypesDialog(this); public Controller() { // load configuration @@ -139,6 +140,12 @@ public class Controller implements Initializable { nodeEmaneDialog.setOwner(window); configDialog.setOwner(window); mobilityDialog.setOwner(window); + nodeTypesDialog.setOwner(window); + } + + @FXML + private void onOptionsMenuNodeTypes(ActionEvent event) { + nodeTypesDialog.showDialog(); } @FXML diff --git a/corefx/src/main/java/com/core/data/CoreNode.java b/corefx/src/main/java/com/core/data/CoreNode.java index 506d3c8f..c552aea2 100644 --- a/corefx/src/main/java/com/core/data/CoreNode.java +++ b/corefx/src/main/java/com/core/data/CoreNode.java @@ -42,13 +42,22 @@ public class CoreNode { this.loaded = false; } - public LayeredIcon getGraphIcon() { - if (graphIcon == null) { - graphIcon = IconUtils.getIcon(icon); - graphIcon.add(radioIcon); - } +// public void setExternalIcon(String iconPath) { +// icon = iconPath; +// graphIcon = IconUtils.getExternalLayeredIcon(icon); +// graphIcon.add(radioIcon); +// } - return graphIcon; + public void setNodeType(NodeType nodeType) { + type = nodeType.getValue(); + model = nodeType.getModel(); + icon = nodeType.getIcon(); + if (icon.startsWith("file:")) { + graphIcon = IconUtils.getExternalLayeredIcon(icon); + } else { + graphIcon = IconUtils.getLayeredIcon(icon); + } + graphIcon.add(radioIcon); } @JsonIgnore diff --git a/corefx/src/main/java/com/core/data/NodeType.java b/corefx/src/main/java/com/core/data/NodeType.java index bd0ccd2f..7d5bbbb9 100644 --- a/corefx/src/main/java/com/core/data/NodeType.java +++ b/corefx/src/main/java/com/core/data/NodeType.java @@ -19,9 +19,9 @@ public class NodeType { private static final Map LOOKUP = new HashMap<>(); private static final Map DISPLAY_MAP = new HashMap<>(); private final int value; - private final String display; - private final String model; - private final String icon; + private String display; + private String model; + private String icon; // PHYSICAL = 1 // RJ45 = 7 diff --git a/corefx/src/main/java/com/core/graph/NetworkGraph.java b/corefx/src/main/java/com/core/graph/NetworkGraph.java index 29351dbb..653087bc 100644 --- a/corefx/src/main/java/com/core/graph/NetworkGraph.java +++ b/corefx/src/main/java/com/core/graph/NetworkGraph.java @@ -305,9 +305,7 @@ public class NetworkGraph { private void handleVertexAdded(GraphEvent.Vertex vertexEvent) { CoreNode node = vertexEvent.getVertex(); if (!node.isLoaded()) { - node.setType(nodeType.getValue()); - node.setModel(nodeType.getModel()); - node.setIcon(nodeType.getIcon()); + node.setNodeType(nodeType); if (node.getType() == NodeType.EMANE) { String emaneModel = controller.getNodeEmaneDialog().getModels().get(0); node.setEmane(emaneModel); diff --git a/corefx/src/main/java/com/core/ui/GraphToolbar.java b/corefx/src/main/java/com/core/ui/GraphToolbar.java index 0d21a36e..fac97b1d 100644 --- a/corefx/src/main/java/com/core/ui/GraphToolbar.java +++ b/corefx/src/main/java/com/core/ui/GraphToolbar.java @@ -62,7 +62,8 @@ public class GraphToolbar extends VBox { private SVGGlyph stopIcon; private JFXListView