Skip to content

Commit 4838c8a

Browse files
committed
Unselect previously selected gene when selecting new gene.
1 parent 2cb1672 commit 4838c8a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

resources/stylesheet.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ node.BOX {
3030

3131
node.FixWrapper {
3232
visibility-mode: hidden;
33+
}
34+
35+
node.SELECTED {
36+
fill-color: red;
3337
}

src/main/java/tudelft/ti2806/pl3/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void makeGraphFromFiles() {
162162
try {
163163
File nodeFile = FileSelector.selectFile(Constants.DIALOG_SELECT_NODE_FILE, this, Constants.EXTENSION_NODE);
164164
File edgeFile = FileSelector.getOtherExtension(nodeFile,
165-
Constants.EXTENSION_EDGE, Constants.EXTENSION_NODE);
165+
Constants.EXTENSION_NODE, Constants.EXTENSION_EDGE);
166166
makeGraph(nodeFile, edgeFile, null, null);
167167
} catch (FileSelectorException exception) {
168168
if (DialogUtil.confirm(Constants.DIALOG_TITLE_ERROR, Constants.DIALOG_FILE_NOT_FOUND)) {

src/main/java/tudelft/ti2806/pl3/visualization/GraphView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import tudelft.ti2806.pl3.controls.MouseManager;
1313
import tudelft.ti2806.pl3.data.gene.Gene;
1414
import tudelft.ti2806.pl3.data.graph.DataNode;
15+
import tudelft.ti2806.pl3.data.wrapper.FixWrapper;
1516
import tudelft.ti2806.pl3.data.wrapper.Wrapper;
1617
import tudelft.ti2806.pl3.data.wrapper.WrapperClone;
1718
import tudelft.ti2806.pl3.exception.EdgeZeroWeightException;
@@ -285,13 +286,16 @@ public void centerOnNode(DataNode node, Gene selected) throws NodeNotFoundExcept
285286
*/
286287
private void colorGene() {
287288
if (selectedGene != null) {
289+
String fixWrapper = FixWrapper.class.getSimpleName();
288290
for (Node graphNode : graph.getNodeSet()) {
289-
graphNode.removeAttribute("ui.style");
291+
if (!fixWrapper.equals(graphNode.getAttribute("ui.class"))) {
292+
graphNode.removeAttribute("ui.class");
293+
}
290294
WrapperClone wrapper = graphNode.getAttribute("node", WrapperClone.class);
291295
wrapper.getLabels().stream()
292296
.filter(label -> label.getText().equals(selectedGene.getName()))
293-
.forEach(label -> graphNode.addAttribute("ui.style",
294-
"fill-color: red;"));
297+
.forEach(label -> graphNode.addAttribute("ui.class",
298+
"SELECTED"));
295299
}
296300
}
297301
}

0 commit comments

Comments
 (0)