Author: mes
Date: 2012-01-12 16:44:37 -0800 (Thu, 12 Jan 2012)
New Revision: 28009
Modified:
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/tunables/JPanelTunableMutator.java
Log:
fix for tunable groups and tunable orientation
Modified:
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/tunables/JPanelTunableMutator.java
===================================================================
---
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/tunables/JPanelTunableMutator.java
2012-01-12 23:43:10 UTC (rev 28008)
+++
core3/impl/trunk/work-swing-impl/impl/src/main/java/org/cytoscape/work/internal/tunables/JPanelTunableMutator.java
2012-01-13 00:44:37 UTC (rev 28009)
@@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Arrays;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@@ -153,52 +154,15 @@
}
}
- // Get information about the Groups and
alignment from Tunables Annotations in order to create the proper GUI
- final Map<String, Boolean> groupToVerticalMap =
new HashMap<String, Boolean>();
- final Map<String, Boolean> groupToDisplayedMap
= new HashMap<String, Boolean>();
+ // Get information about the Groups and
alignment from Tunables Annotations
+ // in order to create the proper GUI
+ final Map<String, Boolean> groupToVerticalMap =
processGroupParams(gh,"alignments","vertical");
+ final Map<String, Boolean> groupToDisplayedMap
= processGroupParams(gh,"groupTitles","displayed");
- final String[] group = gh.getGroups();
- final String[] alignments =
gh.getParams().getProperty("alignments", "").split(",");
- final String[] groupTitles =
gh.getParams().getProperty("groupTitles", "").split(",");
-
- if (group.length <= alignments.length) {
- for (int i = 0; i < group.length; i++) {
- final boolean vertical =
groupTitles[i].equalsIgnoreCase("vertical");
-
groupToVerticalMap.put(group[i], vertical);
- }
- } else {
- for (int i = 0; i < alignments.length;
i++) {
- final boolean vertical =
groupTitles[i].equalsIgnoreCase("vertical");
-
groupToVerticalMap.put(group[i], vertical);
- }
-
- // Default alignment is "vertical."
- for (int i = alignments.length; i <
group.length; i++)
-
groupToVerticalMap.put(group[i], true);
- }
-
- if (group.length <= groupTitles.length) {
- for (int i = 0; i < group.length; i++) {
- final boolean displayed =
-
groupTitles[i].equalsIgnoreCase("displayed");
-
groupToDisplayedMap.put(group[i], displayed);
- }
- } else {
- for (int i = 0; i < groupTitles.length;
i++) {
- final boolean displayed =
-
groupTitles[i].equalsIgnoreCase("displayed");
-
groupToDisplayedMap.put(group[i], displayed);
- }
-
- // Default group setting is "displayed."
- for (int i = groupTitles.length; i <
group.length; i++)
-
groupToDisplayedMap.put(group[i], true);
- }
-
// find the proper group to put the handler
panel in given the Alignment/Group parameters
String lastGroup = MAIN;
- String groupNames = null;
- for (String g : group) {
+ String groupNames = "";
+ for (String g : gh.getGroups()) {
if (g.equals(""))
throw new
IllegalArgumentException("A group's name must not be \"\"!");
groupNames = groupNames + g;
@@ -367,4 +331,31 @@
}
return "Set Parameters";
}
+
+ // Get information about the Groups and parameters to create the proper
GUI
+ private Map<String, Boolean> processGroupParams(GUITunableHandler gh,
String paramName, String defaultValue) {
+ final Map<String, Boolean> groupMap = new HashMap<String,
Boolean>();
+
+ final String[] groups = gh.getGroups();
+ // empty string splits to single element array containing
string ""
+ final String[] params = gh.getParams().getProperty(paramName,
"").split(",");
+
+ if (groups.length <= params.length) {
+ for (int i = 0; i < groups.length; i++) {
+ final boolean vertical =
params[i].equalsIgnoreCase(defaultValue) || params[i].equals("");
+ groupMap.put(groups[i], vertical);
+ }
+ } else {
+ for (int i = 0; i < params.length; i++) {
+ final boolean vertical =
params[i].equalsIgnoreCase(defaultValue) || params[i].equals("");
+ groupMap.put(groups[i], vertical);
+ }
+
+ // Default
+ for (int i = params.length; i < groups.length; i++)
+ groupMap.put(groups[i], true);
+ }
+
+ return groupMap;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.