Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Philipp Spohr
YoshikoWrapper
Commits
5e35c3c0
Commit
5e35c3c0
authored
Dec 11, 2017
by
Philipp Spohr
Browse files
changed many arrayLists to Hashmaps
parent
b784a509
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java
View file @
5e35c3c0
...
...
@@ -22,6 +22,8 @@
package
de.hhu.ba.yoshikoWrapper.graphModel
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
org.cytoscape.model.CyNetwork
;
...
...
@@ -36,21 +38,21 @@ public class YoshikoResult{
private
CyNetwork
originalGraph
;
private
ArrayList
<
YoshikoSolution
>
solutions
;
private
HashMap
<
Long
,
YoshikoSolution
>
solutions
;
private
SolutionFlags
flags
;
private
int
id
;
public
YoshikoResult
(
CyNetwork
net
,
SolutionFlags
flags
)
{
solutions
=
new
ArrayList
<
YoshikoSolution
>();
solutions
=
new
HashMap
<
Long
,
YoshikoSolution
>();
this
.
originalGraph
=
net
;
this
.
flags
=
flags
;
ResultList
.
add
(
this
);
}
public
void
delete
()
{
for
(
YoshikoSolution
s:
solutions
)
{
for
(
YoshikoSolution
s:
solutions
.
values
()
)
{
s
.
delete
();
}
ResultList
.
remove
(
this
.
id
);
...
...
@@ -59,7 +61,7 @@ public class YoshikoResult{
//___________SETTER GETTER_____________//
/**
* @return the flags ass
p
ciated with this result
* @return the flags ass
o
ciated with this result
*/
public
SolutionFlags
getFlags
()
{
return
flags
;
...
...
@@ -67,15 +69,13 @@ public class YoshikoResult{
public
void
addSolution
(
YoshikoSolution
solution
)
{
solutions
.
add
(
solution
);
solutions
.
put
(
solution
.
getId
(),
solution
);
}
public
ArrayList
<
YoshikoSolution
>
getSolutions
()
{
return
solutions
;
public
Collection
<
YoshikoSolution
>
getSolutions
()
{
return
solutions
.
values
();
}
public
CyNetwork
getOriginalGraph
()
{
return
originalGraph
;
}
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java
View file @
5e35c3c0
...
...
@@ -21,11 +21,11 @@
******************************************************************************/
package
de.hhu.ba.yoshikoWrapper.graphModel
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
javax.swing.JOptionPane
;
import
org.cytoscape.model.CyNetwork
;
import
org.cytoscape.model.CyNode
;
...
...
@@ -43,7 +43,7 @@ public class YoshikoSolution {
private
HashMap
<
YoshikoCluster
,
CyNode
>
metaGraphMap
;
p
ublic
ArrayList
<
YoshikoCluster
>
clusters
;
p
rivate
HashMap
<
Long
,
YoshikoCluster
>
clusters
;
private
final
long
id
;
...
...
@@ -51,15 +51,39 @@ public class YoshikoSolution {
public
YoshikoSolution
(
YoshikoResult
yoshikoResult
,
long
id
)
{
clusters
=
new
ArrayList
<
YoshikoCluster
>();
clusters
=
new
HashMap
<
Long
,
YoshikoCluster
>();
this
.
result
=
yoshikoResult
;
this
.
id
=
id
;
}
public
void
delete
()
{
for
(
YoshikoCluster
c:
clusters
.
values
())
{
c
.
delete
();
}
if
(
this
.
metaGraph
!=
null
)
{
CyCore
.
networkManager
.
destroyNetwork
(
metaGraph
);
}
}
public
void
highlightInMetaGraph
(
YoshikoCluster
yoshikoCluster
)
{
try
{
List
<
CyRow
>
allRows
=
metaGraph
.
getDefaultNodeTable
().
getAllRows
();
for
(
CyRow
r:
allRows
)
{
r
.
set
(
"selected"
,
false
);
}
metaGraph
.
getRow
(
metaGraphMap
.
get
(
yoshikoCluster
)).
set
(
"selected"
,
true
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"The graph doesn't exist anymore, can't highlight nodes!"
);
}
}
//_____________GETTER / SETTER ________________//
public
ArrayList
<
YoshikoCluster
>
getClusters
()
{
return
clusters
;
public
Collection
<
YoshikoCluster
>
getClusters
()
{
return
clusters
.
values
()
;
}
/**
...
...
@@ -73,15 +97,6 @@ public class YoshikoSolution {
return
result
.
getOriginalGraph
();
}
public
void
delete
()
{
for
(
YoshikoCluster
c:
clusters
)
{
c
.
delete
();
}
if
(
this
.
metaGraph
!=
null
)
{
CyCore
.
networkManager
.
destroyNetwork
(
metaGraph
);
}
}
public
void
setMetaGraph
(
CyNetwork
metaGraph
,
HashMap
<
YoshikoCluster
,
CyNode
>
map
)
{
this
.
metaGraph
=
metaGraph
;
this
.
metaGraphMap
=
map
;
...
...
@@ -91,19 +106,9 @@ public class YoshikoSolution {
return
metaGraph
;
}
public
void
highlightInMetaGraph
(
YoshikoCluster
yoshikoCluster
)
{
try
{
List
<
CyRow
>
allRows
=
metaGraph
.
getDefaultNodeTable
().
getAllRows
();
for
(
CyRow
r:
allRows
)
{
r
.
set
(
"selected"
,
false
);
}
metaGraph
.
getRow
(
metaGraphMap
.
get
(
yoshikoCluster
)).
set
(
"selected"
,
true
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"The graph doesn't exist anymore, can't highlight nodes!"
);
}
public
void
addCluster
(
YoshikoCluster
cluster
)
{
clusters
.
put
(
cluster
.
getID
(),
cluster
);
}
}
src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java
View file @
5e35c3c0
...
...
@@ -30,6 +30,7 @@ import java.awt.event.ActionListener;
import
java.awt.event.ItemEvent
;
import
java.awt.event.ItemListener
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.swing.GroupLayout
;
import
javax.swing.GroupLayout.Alignment
;
...
...
@@ -114,7 +115,9 @@ public class SolutionTab extends JPanel {
clusterViewList
=
new
ClusterViewList
();
//Build CV list
for
(
YoshikoCluster
c:
solution
.
clusters
)
{
List
<
YoshikoCluster
>
list
=
new
ArrayList
<
YoshikoCluster
>(
solution
.
getClusters
());
list
.
sort
(
YoshikoCluster
.
lessThanComparator
);
for
(
YoshikoCluster
c:
list
)
{
ClusterView
clusterView
=
new
ClusterView
(
c
);
clusterViewList
.
add
(
clusterView
);
}
...
...
@@ -124,7 +127,7 @@ public class SolutionTab extends JPanel {
scrollPane
=
new
JScrollPane
(
clusterViewList
);
clusterCount
=
new
JLabel
(
LocalizationManager
.
get
(
"clusterFound"
)+
" "
+
s
.
c
lusters
.
size
());
clusterCount
=
new
JLabel
(
LocalizationManager
.
get
(
"clusterFound"
)+
" "
+
s
.
getC
lusters
()
.
size
());
createClusterView
=
new
JButton
(
LocalizationManager
.
get
(
"createClusterView"
));
createMetaGraph
=
new
JButton
(
LocalizationManager
.
get
(
"createMetaGraph"
));
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java
View file @
5e35c3c0
...
...
@@ -219,10 +219,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
net
.
getRow
(
node
).
set
(
columnName
,
""
+(
k
+
1
));
//Add Cluster ID in table (Remove in final version?)
}
//Register clusters with solution for further reference
solution
.
c
luster
s
.
add
(
cluster
);
solution
.
addC
luster
(
cluster
);
}
//Sort clusters by size, descending as the biggest clusters are usually the most relevant
solution
.
c
lusters
.
sort
(
YoshikoCluster
.
lessThanComparator
);
//
solution.
sortC
lusters(YoshikoCluster.lessThanComparator);
//Register solution with c_result for further reference
result
.
addSolution
(
solution
);
}
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java
View file @
5e35c3c0
...
...
@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.tasks;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
org.cytoscape.model.CyEdge
;
import
org.cytoscape.model.CyNetwork
;
...
...
@@ -103,10 +104,13 @@ public class CreateMetaGraphTask extends AbstractTask{
taskMonitor
.
setStatusMessage
(
LocalizationManager
.
get
(
"metaGraph_edges"
));
for
(
int
x
=
0
;
x
<
solution
.
getClusters
().
size
();
x
++)
{
YoshikoCluster
c1
=
solution
.
getClusters
().
get
(
x
);
for
(
int
y
=
x
;
y
<
solution
.
getClusters
().
size
();
y
++)
{
YoshikoCluster
c2
=
solution
.
getClusters
().
get
(
y
);
Iterator
<
YoshikoCluster
>
it1
=
solution
.
getClusters
().
iterator
();
Iterator
<
YoshikoCluster
>
it2
=
solution
.
getClusters
().
iterator
();
while
(
it1
.
hasNext
())
{
YoshikoCluster
c1
=
it1
.
next
();
while
(
it2
.
hasNext
())
{
YoshikoCluster
c2
=
it2
.
next
();
if
(
isTerminated
)
{
throw
new
Exception
(
"Terminated by user!"
);
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java
0 → 100644
View file @
5e35c3c0
package
de.hhu.ba.yoshikoWrapper.tasks
;
import
java.util.ArrayList
;
import
org.cytoscape.work.ObservableTask
;
import
org.cytoscape.work.TaskMonitor
;
import
org.cytoscape.work.Tunable
;
import
de.hhu.ba.yoshikoWrapper.core.ResultList
;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster
;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult
;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution
;
public
class
GetClustersTask
implements
ObservableTask
{
@Tunable
(
description
=
"The result ID for which the solutions should be displayed"
,
context
=
"nogui"
)
public
int
resultID
=
-
1
;
@Tunable
(
description
=
"The solution ID for which the solutions should be displayed"
,
context
=
"nogui"
)
public
int
solutionID
=
-
1
;
private
ArrayList
<
YoshikoCluster
>
clusters
;
@Override
public
void
run
(
TaskMonitor
taskMonitor
)
throws
Exception
{
YoshikoResult
result
=
ResultList
.
get
(
resultID
);
if
(
result
==
null
)
{
throw
new
Exception
(
"No result with ID: "
+
resultID
+
" was found!"
);
//TODO: Localization
}
}
@Override
public
void
cancel
()
{
// TODO Auto-generated method stub
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
<
R
>
R
getResults
(
Class
<?
extends
R
>
type
)
{
if
(
type
.
equals
(
String
.
class
))
{
String
ret
=
""
;
return
(
R
)
ret
;
}
return
null
;
}
}
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java
View file @
5e35c3c0
package
de.hhu.ba.yoshikoWrapper.tasks
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
org.cytoscape.work.ObservableTask
;
import
org.cytoscape.work.TaskMonitor
;
...
...
@@ -15,7 +16,7 @@ public class GetSolutionsTask implements ObservableTask {
@Tunable
(
description
=
"The result ID for which the solutions should be displayed"
,
context
=
"nogui"
)
public
int
resultID
=
-
1
;
private
ArrayList
<
YoshikoSolution
>
solutions
;
private
Collection
<
YoshikoSolution
>
solutions
;
@Override
public
void
run
(
TaskMonitor
taskMonitor
)
throws
Exception
{
...
...
@@ -38,7 +39,7 @@ public class GetSolutionsTask implements ObservableTask {
if
(
type
.
equals
(
String
.
class
))
{
String
ret
=
""
;
for
(
YoshikoSolution
s:
solutions
)
{
ret
+=
"Solution
["
+
s
.
getId
()+
"]: "
+
s
.
getClusters
().
size
()+
" clusters\n"
;
ret
+=
"Solution[
ID=
"
+
s
.
getId
()+
"]: "
+
s
.
getClusters
().
size
()+
" clusters\n"
;
}
return
(
R
)
ret
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment