Skip to content

Commit fe41d43

Browse files
Tom BrouwsTom Brouws
Tom Brouws
authored and
Tom Brouws
committed
Merge pull request #102 from ProgrammingLife3/feature/moreDetails
Feature/more details
2 parents 54835db + 193561a commit fe41d43

File tree

12 files changed

+84
-11
lines changed

12 files changed

+84
-11
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ public void makeGraphFromFolder() {
143143
Constants.EXTENSION_EDGE, Constants.EXTENSION_PHYLOTREE, Constants.EXTENSION_TEXT);
144144
makeGraph(files[0], files[1], files[2], files[3]);
145145
} catch (ArrayIndexOutOfBoundsException exception) {
146-
if (DialogUtil.confirm(Constants.DIALOG_TITLE_ERROR, "Some necessary files were not found. Want to select a new folder?")) {
146+
if (DialogUtil.confirm(Constants.DIALOG_TITLE_ERROR,
147+
"Some necessary files were not found. Want to select a new folder?")) {
147148
makeGraphFromFolder();
148149
}
149150
} catch (FileSelectorException exception) {
150-
if (DialogUtil.confirm(Constants.DIALOG_TITLE_ERROR, "You have not selected a folder, want to try again?")) {
151+
if (DialogUtil.confirm(Constants.DIALOG_TITLE_ERROR,
152+
"You have not selected a folder, want to try again?")) {
151153
makeGraphFromFolder();
152154
}
153155
}

src/main/java/tudelft/ti2806/pl3/data/graph/GraphDataRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public void parseGraph(File nodesFile, File edgesFile, GeneData geneData) throws
114114
* @throws FileNotFoundException
115115
* if the file is not found
116116
*/
117-
public void parseGraph(File nodesFile, File edgesFile, File metaFile, GeneData geneData) throws FileNotFoundException {
117+
public void parseGraph(File nodesFile, File edgesFile, File metaFile, GeneData geneData)
118+
throws FileNotFoundException {
118119
notifyLoadingObservers(true);
119120
geneToStartNodeMap = new HashMap<>(geneData.getGenes().size());
120121
genes = new ArrayList<>();

src/main/java/tudelft/ti2806/pl3/data/wrapper/CombineWrapper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,13 @@ public boolean contains(Wrapper object) {
9696
}
9797
return false;
9898
}
99+
100+
@Override
101+
public String getBasePairString() {
102+
String result = "";
103+
for (Wrapper wrapper : nodeList) {
104+
result += wrapper.getBasePairString();
105+
}
106+
return result;
107+
}
99108
}

src/main/java/tudelft/ti2806/pl3/data/wrapper/DataNodeWrapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ public void calculateX() {
110110
public int getWidth() {
111111
return 1;
112112
}
113-
113+
114+
@Override
115+
public String getBasePairString() {
116+
return node.getContent();
117+
}
118+
114119
@Override
115120
public boolean contains(Wrapper object) {
116121
return false;

src/main/java/tudelft/ti2806/pl3/data/wrapper/FixWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public int getWidth() {
6868
return 0;
6969
}
7070

71+
@Override
72+
public String getBasePairString() {
73+
return null;
74+
}
75+
7176
@Override
7277
public boolean contains(Wrapper object) {
7378
return false;

src/main/java/tudelft/ti2806/pl3/data/wrapper/SingleWrapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ public void calculateX() {
8484
public int getWidth() {
8585
return this.getNode().getWidth();
8686
}
87-
87+
88+
@Override
89+
public String getBasePairString() {
90+
return target.getBasePairString();
91+
}
92+
8893
@Override
8994
public boolean contains(Wrapper object) {
9095
return object == this.target || this.target.contains(object);

src/main/java/tudelft/ti2806/pl3/data/wrapper/Wrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public abstract class Wrapper implements Comparable<Wrapper> {
4242
* @return the distance between the start x and end x of this node.
4343
*/
4444
public abstract int getWidth();
45+
46+
public abstract String getBasePairString();
4547

4648
public int getPreviousNodesCount() {
4749
return previousNodesCount;

src/main/java/tudelft/ti2806/pl3/data/wrapper/WrapperClone.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ public void calculateX() {
9090
public int getWidth() {
9191
return originalNode.getWidth();
9292
}
93-
93+
94+
@Override
95+
public String getBasePairString() {
96+
return originalNode.getBasePairString();
97+
}
98+
9499
@Override
95100
public boolean contains(Wrapper object) {
96101
return this.originalNode.contains(object);

src/main/java/tudelft/ti2806/pl3/data/wrapper/WrapperPlaceholder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ public void calculateX() {
6060
public int getWidth() {
6161
return 0;
6262
}
63-
63+
64+
@Override
65+
public String getBasePairString() {
66+
return null;
67+
}
68+
6469
@Override
6570
public boolean contains(Wrapper object) {
6671
return false;

src/main/java/tudelft/ti2806/pl3/detailview/DetailView.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class DetailView extends JPanel {
2727
private static final int BORDER = 10;
2828
private static final int POSITION_OFFSET = 30;
2929
private static final String REF_GENOME = "REF";
30+
private static final int MAX_BASEPAIR_LENGTH = 10;
3031

3132
/**
3233
* Custom string comparator to prioritize the reference genome.
@@ -44,9 +45,9 @@ public class DetailView extends JPanel {
4445
* Constructs a DetailView and set a border and the preferred layout.
4546
*/
4647
public DetailView() {
47-
BoxLayout layout = new BoxLayout(this, BoxLayout.X_AXIS);
48+
BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
4849
setLayout(layout);
49-
setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));
50+
setBorder(BorderFactory.createEmptyBorder(0, BORDER, BORDER, BORDER));
5051
}
5152

5253
/**
@@ -61,13 +62,35 @@ public DetailView() {
6162
public void setNode(WrapperClone node, int x, int y) {
6263
removeAll();
6364

65+
addLabels(node);
6466
addList(node.getGenome(), Constants.DETAILVIEW_GENOMES);
6567
addList(node.getLabels(), Constants.DETAILVIEW_LABELS);
6668

6769
Dimension size = getPreferredSize();
6870
setBounds(x, y, size.width, size.height);
6971
}
7072

73+
/**
74+
* Adds labels for the node id and the base pair string if the node can not be unwrapped.
75+
* @param node
76+
* The node for which the id and base pair string should be added.
77+
*/
78+
public void addLabels(WrapperClone node) {
79+
if (!node.canUnwrap()) {
80+
JLabel label = new JLabel("Node id: " + node.getIdString());
81+
label.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0));
82+
add(label);
83+
String basePairString = node.getBasePairString();
84+
int length = basePairString.length();
85+
if (length > MAX_BASEPAIR_LENGTH) {
86+
basePairString = basePairString.substring(0, MAX_BASEPAIR_LENGTH / 2) + "..."
87+
+ basePairString.substring(length - MAX_BASEPAIR_LENGTH / 2);
88+
}
89+
add(new JLabel("Base pairs:"));
90+
add(new JLabel(basePairString));
91+
}
92+
}
93+
7194
/**
7295
* Adds a collection as a scrollable list to itself.
7396
* @param collection
@@ -93,6 +116,7 @@ private void addList(Collection collection, String title) {
93116
if (title != null) {
94117
listScroller.setColumnHeaderView(new JLabel(title));
95118
}
119+
listScroller.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, 0, 0));
96120
add(listScroller);
97121
}
98122

src/test/java/tudelft/ti2806/pl3/data/wrapper/TestWrapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ public long getBasePairCount() {
4242
public int getWidth() {
4343
return 1;
4444
}
45-
45+
46+
@Override
47+
public String getBasePairString() {
48+
return null;
49+
}
50+
4651
@Override
4752
public void calculateX() {
4853
}

src/test/java/tudelft/ti2806/pl3/util/OrderedListUtilTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ public void calculateX() {
179179
public int getWidth() {
180180
return 0;
181181
}
182-
182+
183+
@Override
184+
public String getBasePairString() {
185+
return null;
186+
}
187+
183188
@Override
184189
public boolean contains(Wrapper originalNode) {
185190
return false;

0 commit comments

Comments
 (0)