Author: scooter
Date: 2012-03-20 22:35:46 -0700 (Tue, 20 Mar 2012)
New Revision: 28601
Added:
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupAggregationSettings.java
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupViewSettings.java
Modified:
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
Log:
Add support for group attributes and separate out settings into separate
classes.
Added:
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupAggregationSettings.java
===================================================================
---
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupAggregationSettings.java
(rev 0)
+++
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupAggregationSettings.java
2012-03-21 05:35:46 UTC (rev 28601)
@@ -0,0 +1,220 @@
+
+package org.cytoscape.group.data.internal;
+
+import org.cytoscape.model.CyColumn;
+
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.ContainsTunables;
+import org.cytoscape.work.util.ListSingleSelection;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.data.Aggregator;
+import org.cytoscape.group.data.AttributeHandlingType;
+import org.cytoscape.group.data.CyGroupSettings;
+import org.cytoscape.group.data.internal.aggregators.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CyGroupAggregationSettings {
+ Map<Class, Aggregator> allGroupDefaultMap;
+ Map<CyColumn, Aggregator> allGroupOverrideMap;
+ Map<CyGroup, GroupSpecificMaps> groupMap;
+
+ /**********************************
+ * Default aggregation attributes *
+ *********************************/
+ // Default aggregations
+
+ @Tunable(description="Enable attribute aggregation", groups={"Attribute
Aggregation Settings"})
+ public boolean enableAttributeAggregation = false;
+
+ // Integer
+ @Tunable(description="Integer column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"}, params="displayState=collapsed",
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> integerDefault;
+
+ // Long
+ @Tunable(description="Long column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> longDefault;
+
+ // Float
+ @Tunable(description="Float column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> floatDefault;
+
+ // Double
+ @Tunable(description="Double column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> doubleDefault;
+
+ // List
+ @Tunable(description="List column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> listDefault;
+
+ // String
+ @Tunable(description="String column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> stringDefault;
+
+ // Boolean
+ @Tunable(description="Boolean column aggregation default",
+ groups={"Attribute Aggregation Settings", "Default Aggregation
Settings"},
+ dependsOn="enableAttributeAggregation=true")
+ public ListSingleSelection<AttributeHandlingType> booleanDefault;
+
+
+ public CyGroupAggregationSettings() {
+ allGroupDefaultMap = new HashMap<Class,Aggregator>();
+ allGroupOverrideMap = new HashMap<CyColumn,Aggregator>();
+ groupMap = new HashMap<CyGroup,GroupSpecificMaps>();
+
+ initializeDefaults();
+ }
+
+ public boolean getEnableAttributeAggregation() {
+ return enableAttributeAggregation;
+ }
+
+ public void setEnableAttributeAggregation(boolean aggregate) {
+ this.enableAttributeAggregation = aggregate;
+ }
+
+ public Aggregator getAggregator(CyGroup group, CyColumn column) {
+ updateDefaults();
+ Class type = column.getType();
+ Map<Class, Aggregator> defaultMap = allGroupDefaultMap;
+ Map<CyColumn, Aggregator> overrideMap = allGroupOverrideMap;
+ if (groupMap.containsKey(group)) {
+ defaultMap = groupMap.get(group).getDefaults();
+ overrideMap = groupMap.get(group).getOverrides();
+ }
+ if (overrideMap.containsKey(column))
+ return overrideMap.get(column);
+ return defaultMap.get(column.getType());
+ }
+
+ public void setDefaultAggregation(CyGroup group, Class ovClass,
Aggregator agg) {
+ if (!groupMap.containsKey(group)) {
+ groupMap.put(group, new GroupSpecificMaps());
+ }
+ groupMap.get(group).setDefault(ovClass, agg);
+ }
+
+ public void setDefaultAggregation(Class ovClass, Aggregator agg) {
+ allGroupDefaultMap.put(ovClass, agg);
+ }
+
+ public void setOverrideAggregation(CyGroup group, CyColumn column,
Aggregator agg) {
+ if (!groupMap.containsKey(group)) {
+ groupMap.put(group, new GroupSpecificMaps());
+ }
+ groupMap.get(group).setOverride(column, agg);
+ }
+
+ public void setOverrideAggregation(CyColumn column, Aggregator agg) {
+ allGroupOverrideMap.put(column, agg);
+ }
+
+ public void groupAdded(CyGroup addedGroup) {
+ updateDefaults();
+ Map<Class,Aggregator> defMap = new HashMap<Class, Aggregator>();
+ for (Class cKey: allGroupDefaultMap.keySet())
+ defMap.put(cKey, allGroupDefaultMap.get(cKey));
+ Map<CyColumn,Aggregator> ovMap = new HashMap<CyColumn,
Aggregator>();
+ for (CyColumn cKey: allGroupOverrideMap.keySet())
+ ovMap.put(cKey, allGroupOverrideMap.get(cKey));
+ groupMap.put(addedGroup, new GroupSpecificMaps(defMap, ovMap));
+ }
+
+ private void updateDefaults() {
+ // Update our defaults first
+ allGroupDefaultMap.put(Boolean.class, new
BooleanAggregator(booleanDefault.getSelectedValue()));
+ allGroupDefaultMap.put(Integer.class, new
IntegerAggregator(integerDefault.getSelectedValue()));
+ allGroupDefaultMap.put(Float.class, new
FloatAggregator(floatDefault.getSelectedValue()));
+ allGroupDefaultMap.put(Long.class, new
LongAggregator(longDefault.getSelectedValue()));
+ allGroupDefaultMap.put(Double.class, new
DoubleAggregator(doubleDefault.getSelectedValue()));
+ allGroupDefaultMap.put(List.class, new
ListAggregator(listDefault.getSelectedValue()));
+ allGroupDefaultMap.put(String.class, new
StringAggregator(stringDefault.getSelectedValue()));
+ }
+
+ private void initializeDefaults() {
+ // Create the selection
+ integerDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(IntegerAggregator.getSupportedTypes()));
+ longDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(LongAggregator.getSupportedTypes()));
+ floatDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(FloatAggregator.getSupportedTypes()));
+ doubleDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(DoubleAggregator.getSupportedTypes()));
+ stringDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(StringAggregator.getSupportedTypes()));
+ listDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(ListAggregator.getSupportedTypes()));
+ booleanDefault =
+ new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(BooleanAggregator.getSupportedTypes()));
+
+ integerDefault.setSelectedValue(AttributeHandlingType.AVG);
+ longDefault.setSelectedValue(AttributeHandlingType.NONE);
+ floatDefault.setSelectedValue(AttributeHandlingType.AVG);
+ doubleDefault.setSelectedValue(AttributeHandlingType.AVG);
+ stringDefault.setSelectedValue(AttributeHandlingType.CSV);
+ listDefault.setSelectedValue(AttributeHandlingType.UNIQUE);
+ booleanDefault.setSelectedValue(AttributeHandlingType.NONE);
+
+ // Initialize the defaults
+ allGroupDefaultMap.put(Integer.class, new
IntegerAggregator(AttributeHandlingType.AVG));
+ allGroupDefaultMap.put(Long.class, new
LongAggregator(AttributeHandlingType.NONE));
+ allGroupDefaultMap.put(Float.class, new
FloatAggregator(AttributeHandlingType.AVG));
+ allGroupDefaultMap.put(Double.class, new
DoubleAggregator(AttributeHandlingType.AVG));
+ allGroupDefaultMap.put(String.class, new
StringAggregator(AttributeHandlingType.CSV));
+ allGroupDefaultMap.put(List.class, new
ListAggregator(AttributeHandlingType.UNIQUE));
+ allGroupDefaultMap.put(Boolean.class, new
BooleanAggregator(AttributeHandlingType.NONE));
+ }
+
+ class GroupSpecificMaps {
+ Map<Class, Aggregator> defMap;
+ Map<CyColumn, Aggregator> ovMap;
+
+ GroupSpecificMaps () {
+ this.defMap = null;
+ this.ovMap = null;
+ }
+
+ GroupSpecificMaps (Map<Class, Aggregator> defMap, Map<CyColumn,
Aggregator> ovMap) {
+ this.defMap = defMap;
+ this.ovMap = ovMap;
+ }
+
+ void setDefault(Class ovClass, Aggregator agg) {
+ if (defMap == null) defMap = new HashMap<Class,
Aggregator>();
+
+ defMap.put(ovClass, agg);
+ }
+
+ void setOverride(CyColumn column, Aggregator agg) {
+ if (ovMap == null) ovMap = new HashMap<CyColumn,
Aggregator>();
+
+ ovMap.put(column, agg);
+ }
+
+ Map<Class,Aggregator> getDefaults() {return defMap;}
+ Map<CyColumn,Aggregator> getOverrides() {return ovMap;}
+ }
+
+}
Modified:
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
===================================================================
---
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
2012-03-21 05:34:29 UTC (rev 28600)
+++
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
2012-03-21 05:35:46 UTC (rev 28601)
@@ -6,100 +6,27 @@
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
-import org.cytoscape.work.util.ListSingleSelection;
+import org.cytoscape.work.ContainsTunables;
import org.cytoscape.group.CyGroup;
import org.cytoscape.group.CyGroupManager;
import org.cytoscape.group.data.Aggregator;
import org.cytoscape.group.data.AttributeHandlingType;
import org.cytoscape.group.data.CyGroupSettings;
-import org.cytoscape.group.data.CyGroupSettings.DoubleClickAction;
-import org.cytoscape.group.data.internal.aggregators.*;
import org.cytoscape.group.events.GroupAddedEvent;
import org.cytoscape.group.events.GroupAddedListener;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class CyGroupSettingsImpl extends AbstractTask implements
CyGroupSettings, GroupAddedListener {
CyGroupManager cyGroupManager;
- Map<Class, Aggregator> allGroupDefaultMap;
- Map<CyColumn, Aggregator> allGroupOverrideMap;
- Map<CyGroup, GroupSpecificMaps> groupMap;
+ @ContainsTunables
+ public CyGroupViewSettings viewSettings = new CyGroupViewSettings();
- @Tunable(description="Double-Click action",
- groups={"User Action Settings"}/*,
params="displayState=collapse"*/)
- public ListSingleSelection<DoubleClickAction> doubleClickAction =
- new
ListSingleSelection<DoubleClickAction>(DoubleClickAction.None,DoubleClickAction.ExpandContract,
-
DoubleClickAction.Select);
+ @ContainsTunables
+ public CyGroupAggregationSettings aggregationSettings = new
CyGroupAggregationSettings();
-
- /**********************************
- * Default aggregation attributes *
- *********************************/
- // Default aggregations
-
- @Tunable(description="Enable attribute aggregation", groups={"Attribute
Aggregation Settings"})
- public boolean enableAttributeAggregation = false;
-
- // Integer
- @Tunable(description="Integer column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"}, params="displayState=collapsed",
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> integerDefault;
-
- // Long
- @Tunable(description="Long column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> longDefault;
-
- // Float
- @Tunable(description="Float column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> floatDefault;
-
- // Double
- @Tunable(description="Double column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> doubleDefault;
-
- // List
- @Tunable(description="List column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> listDefault;
-
- // String
- @Tunable(description="String column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> stringDefault;
-
- // Boolean
- @Tunable(description="Boolean column aggregation default",
- groups={"Attribute Aggregation Settings", "Default
Aggregation"},
- dependsOn="enableAttributeAggregation=true")
- public ListSingleSelection<AttributeHandlingType> booleanDefault;
-
-
public CyGroupSettingsImpl(CyGroupManager mgr) {
this.cyGroupManager = mgr;
- allGroupDefaultMap = new HashMap<Class,Aggregator>();
- allGroupOverrideMap = new HashMap<CyColumn,Aggregator>();
- groupMap = new HashMap<CyGroup,GroupSpecificMaps>();
-
- initializeDefaults();
-
- // Set some defaults
-
doubleClickAction.setSelectedValue(DoubleClickAction.ExpandContract);
-
}
// This is a little funky, but we don't really have a task, so we just
provide the run method
@@ -108,151 +35,51 @@
@Override
public boolean getEnableAttributeAggregation() {
- return enableAttributeAggregation;
+ return aggregationSettings.getEnableAttributeAggregation();
}
@Override
public void setEnableAttributeAggregation(boolean aggregate) {
- this.enableAttributeAggregation = aggregate;
+ aggregationSettings.setEnableAttributeAggregation(aggregate);
}
@Override
public DoubleClickAction getDoubleClickAction() {
- return doubleClickAction.getSelectedValue();
+ return viewSettings.getDoubleClickAction();
}
@Override
public void setDoubleClickAction(DoubleClickAction action) {
- doubleClickAction.setSelectedValue(action);
+ viewSettings.setDoubleClickAction(action);
}
@Override
public Aggregator getAggregator(CyGroup group, CyColumn column) {
- updateDefaults();
- Class type = column.getType();
- Map<Class, Aggregator> defaultMap = allGroupDefaultMap;
- Map<CyColumn, Aggregator> overrideMap = allGroupOverrideMap;
- if (groupMap.containsKey(group)) {
- defaultMap = groupMap.get(group).getDefaults();
- overrideMap = groupMap.get(group).getOverrides();
- }
- if (overrideMap.containsKey(column))
- return overrideMap.get(column);
- return defaultMap.get(column.getType());
+ return aggregationSettings.getAggregator(group, column);
}
@Override
public void setDefaultAggregation(CyGroup group, Class ovClass,
Aggregator agg) {
- if (!groupMap.containsKey(group)) {
- groupMap.put(group, new GroupSpecificMaps());
- }
- groupMap.get(group).setDefault(ovClass, agg);
+ aggregationSettings.setDefaultAggregation(group, ovClass, agg);
}
@Override
public void setDefaultAggregation(Class ovClass, Aggregator agg) {
- allGroupDefaultMap.put(ovClass, agg);
+ aggregationSettings.setDefaultAggregation(ovClass, agg);
}
@Override
public void setOverrideAggregation(CyGroup group, CyColumn column,
Aggregator agg) {
- if (!groupMap.containsKey(group)) {
- groupMap.put(group, new GroupSpecificMaps());
- }
- groupMap.get(group).setOverride(column, agg);
+ aggregationSettings.setOverrideAggregation(group, column, agg);
}
@Override
public void setOverrideAggregation(CyColumn column, Aggregator agg) {
- allGroupOverrideMap.put(column, agg);
+ aggregationSettings.setOverrideAggregation(column, agg);
}
public void handleEvent(GroupAddedEvent e) {
CyGroup addedGroup = e.getGroup();
- updateDefaults();
- Map<Class,Aggregator> defMap = new HashMap<Class, Aggregator>();
- for (Class cKey: allGroupDefaultMap.keySet())
- defMap.put(cKey, allGroupDefaultMap.get(cKey));
- Map<CyColumn,Aggregator> ovMap = new HashMap<CyColumn,
Aggregator>();
- for (CyColumn cKey: allGroupOverrideMap.keySet())
- ovMap.put(cKey, allGroupOverrideMap.get(cKey));
- groupMap.put(addedGroup, new GroupSpecificMaps(defMap, ovMap));
+ aggregationSettings.groupAdded(addedGroup);
}
-
- private void updateDefaults() {
- // Update our defaults first
- allGroupDefaultMap.put(Boolean.class, new
BooleanAggregator(booleanDefault.getSelectedValue()));
- allGroupDefaultMap.put(Integer.class, new
IntegerAggregator(integerDefault.getSelectedValue()));
- allGroupDefaultMap.put(Float.class, new
FloatAggregator(floatDefault.getSelectedValue()));
- allGroupDefaultMap.put(Long.class, new
LongAggregator(longDefault.getSelectedValue()));
- allGroupDefaultMap.put(Double.class, new
DoubleAggregator(doubleDefault.getSelectedValue()));
- allGroupDefaultMap.put(List.class, new
ListAggregator(listDefault.getSelectedValue()));
- allGroupDefaultMap.put(String.class, new
StringAggregator(stringDefault.getSelectedValue()));
- }
-
- private void initializeDefaults() {
- // Create the selection
- integerDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(IntegerAggregator.getSupportedTypes()));
- longDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(LongAggregator.getSupportedTypes()));
- floatDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(FloatAggregator.getSupportedTypes()));
- doubleDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(DoubleAggregator.getSupportedTypes()));
- stringDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(StringAggregator.getSupportedTypes()));
- listDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(ListAggregator.getSupportedTypes()));
- booleanDefault =
- new
ListSingleSelection<AttributeHandlingType>(Arrays.asList(BooleanAggregator.getSupportedTypes()));
-
- integerDefault.setSelectedValue(AttributeHandlingType.AVG);
- longDefault.setSelectedValue(AttributeHandlingType.NONE);
- floatDefault.setSelectedValue(AttributeHandlingType.AVG);
- doubleDefault.setSelectedValue(AttributeHandlingType.AVG);
- stringDefault.setSelectedValue(AttributeHandlingType.CSV);
- listDefault.setSelectedValue(AttributeHandlingType.UNIQUE);
- booleanDefault.setSelectedValue(AttributeHandlingType.NONE);
-
- // Initialize the defaults
- allGroupDefaultMap.put(Integer.class, new
IntegerAggregator(AttributeHandlingType.AVG));
- allGroupDefaultMap.put(Long.class, new
LongAggregator(AttributeHandlingType.NONE));
- allGroupDefaultMap.put(Float.class, new
FloatAggregator(AttributeHandlingType.AVG));
- allGroupDefaultMap.put(Double.class, new
DoubleAggregator(AttributeHandlingType.AVG));
- allGroupDefaultMap.put(String.class, new
StringAggregator(AttributeHandlingType.CSV));
- allGroupDefaultMap.put(List.class, new
ListAggregator(AttributeHandlingType.UNIQUE));
- allGroupDefaultMap.put(Boolean.class, new
BooleanAggregator(AttributeHandlingType.NONE));
- }
-
- class GroupSpecificMaps {
- Map<Class, Aggregator> defMap;
- Map<CyColumn, Aggregator> ovMap;
-
- GroupSpecificMaps () {
- this.defMap = null;
- this.ovMap = null;
- }
-
- GroupSpecificMaps (Map<Class, Aggregator> defMap, Map<CyColumn,
Aggregator> ovMap) {
- this.defMap = defMap;
- this.ovMap = ovMap;
- }
-
- void setDefault(Class ovClass, Aggregator agg) {
- if (defMap == null) defMap = new HashMap<Class,
Aggregator>();
-
- defMap.put(ovClass, agg);
- }
-
- void setOverride(CyColumn column, Aggregator agg) {
- if (ovMap == null) ovMap = new HashMap<CyColumn,
Aggregator>();
-
- ovMap.put(column, agg);
- }
-
- Map<Class,Aggregator> getDefaults() {return defMap;}
- Map<CyColumn,Aggregator> getOverrides() {return ovMap;}
- }
-
}
Added:
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupViewSettings.java
===================================================================
---
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupViewSettings.java
(rev 0)
+++
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupViewSettings.java
2012-03-21 05:35:46 UTC (rev 28601)
@@ -0,0 +1,48 @@
+
+package org.cytoscape.group.data.internal;
+
+import org.cytoscape.model.CyColumn;
+
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.util.ListSingleSelection;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.data.Aggregator;
+import org.cytoscape.group.data.AttributeHandlingType;
+import org.cytoscape.group.data.CyGroupSettings;
+import org.cytoscape.group.data.CyGroupSettings.DoubleClickAction;
+import org.cytoscape.group.data.internal.aggregators.*;
+import org.cytoscape.group.events.GroupAddedEvent;
+import org.cytoscape.group.events.GroupAddedListener;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CyGroupViewSettings {
+
+ @Tunable(description="Double-Click action",
+ groups={"User Action Settings"}/*,
params="displayState=collapse"*/)
+ public ListSingleSelection<DoubleClickAction> doubleClickAction =
+ new
ListSingleSelection<DoubleClickAction>(DoubleClickAction.None,DoubleClickAction.ExpandContract,
+
DoubleClickAction.Select);
+
+ public CyGroupViewSettings() {
+ // Set some defaults
+
doubleClickAction.setSelectedValue(DoubleClickAction.ExpandContract);
+
+ }
+
+ public DoubleClickAction getDoubleClickAction() {
+ return doubleClickAction.getSelectedValue();
+ }
+
+ public void setDoubleClickAction(DoubleClickAction action) {
+ doubleClickAction.setSelectedValue(action);
+ }
+}
Modified:
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
===================================================================
---
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-03-21 05:34:29 UTC (rev 28600)
+++
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-03-21 05:35:46 UTC (rev 28601)
@@ -45,8 +45,10 @@
import org.cytoscape.group.events.GroupAboutToCollapseEvent;
import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyColumn;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyRow;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.model.subnetwork.CyRootNetwork;
@@ -93,6 +95,7 @@
this.networkSet = new HashSet<CyNetwork>();
this.collapseSet = new HashSet<CyNetwork>();
+ networkSet.add(rootNetwork);
networkSet.add(network);
if (nodes == null)
@@ -139,8 +142,8 @@
updateMetaEdges(true);
// Initialize our attributes
- // TODO: updateCountAttributes();
- // TODO: setGroupStateAttribute(false);
+ updateCountAttributes(rootNetwork);
+ setGroupStateAttribute(network, false);
}
/**
@@ -194,7 +197,9 @@
if (!batchUpdate) {
updateMetaEdges(false);
- // TODO: updateCountAttributes();
+ for (CyNetwork net: collapseSet) {
+ updateCountAttributes(net);
+ }
cyEventHelper.fireEvent(new
GroupChangedEvent(CyGroupImpl.this, node,
GroupChangedEvent.ChangeType.NODE_ADDED));
}
}
@@ -247,7 +252,9 @@
}
}
updateMetaEdges(false);
- // TODO: updateCountAttributes();
+ for (CyNetwork net: collapseSet) {
+ updateCountAttributes(net);
+ }
batchUpdate = false;
cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
nodes, GroupChangedEvent.ChangeType.NODES_ADDED));
}
@@ -292,7 +299,9 @@
groupNet.removeNodes(nodes);
batchUpdate = false;
updateMetaEdges(false);
- // TODO: updateCountAttributes();
+ for (CyNetwork net: collapseSet) {
+ updateCountAttributes(net);
+ }
cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
nodes, GroupChangedEvent.ChangeType.NODES_REMOVED));
}
@@ -381,6 +390,15 @@
CySubNetwork subnet = (CySubNetwork) net;
+ // First collapse any children that are groups
+ for (CyNode node: getNodeList()) {
+ // Is this a group?
+ if (mgr.isGroup(node, net)) {
+ // Yes, collapse it
+ mgr.getGroup(node,net).collapse(net);
+ }
+ }
+
// Collapse it.
// Remove all of the nodes from the target network
subnet.removeNodes(getNodeList());
@@ -402,7 +420,8 @@
collapseSet.add(net);
cyEventHelper.fireEvent(new
GroupCollapsedEvent(CyGroupImpl.this, net, true));
// Update attributes?
- // TODO: setGroupStateAttribute(net, true);
+ setGroupStateAttribute(net, true);
+ updateCountAttributes(net);
}
/**
@@ -446,7 +465,7 @@
collapseSet.remove(net);
cyEventHelper.fireEvent(new
GroupCollapsedEvent(CyGroupImpl.this, net, false));
// Update attributes?
- // TODO: setGroupStateAttribute(net, false);
+ setGroupStateAttribute(net, false);
}
/**
@@ -695,4 +714,88 @@
return;
}
+ /**
+ * Set the state attribute for this group. The problem is that a group
might be in
+ * different states in different networks, so this is a list of the
form:
+ * [network1:state,network2:state,...]
+ */
+ private void setGroupStateAttribute(CyNetwork net, boolean collapsed) {
+ CyTable nodeTable = rootNetwork.getDefaultNodeTable();
+ CyColumn stateColumn = nodeTable.getColumn(GROUP_STATE_ATTR);
+ if
(!rootNetwork.getDefaultNetworkTable().rowExists(net.getSUID()))
+ return;
+
+ String netName = rootNetwork.getRow(net).get(net.NAME,
String.class);
+
+ if (!nodeTable.rowExists(groupNode.getSUID())) {
+ // Shouldn't happen!
+ return;
+ }
+
+ List<String> newList = new ArrayList<String>();
+ if (stateColumn == null) {
+ nodeTable.createListColumn(GROUP_STATE_ATTR,
String.class, true);
+ newList.add(netName+":"+collapsed);
+ } else {
+ List<String> stateList =
net.getRow(groupNode).getList(GROUP_STATE_ATTR, String.class);
+ for (String s: stateList) {
+ String[] tokens = s.split(":");
+ if (netName.equals(tokens[0])) {
+ newList.add(netName+":"+collapsed);
+ } else {
+ newList.add(s);
+ }
+ }
+ }
+ rootNetwork.getRow(groupNode).set(GROUP_STATE_ATTR, newList);
+ return;
+ }
+
+ private boolean getGroupStateAttribute(CyNetwork net) {
+ CyTable nodeTable = net.getDefaultNodeTable();
+ CyColumn stateColumn = nodeTable.getColumn(GROUP_STATE_ATTR);
+ String netName = net.getRow(net).get(net.NAME, String.class);
+ if (stateColumn == null ||
!nodeTable.rowExists(groupNode.getSUID())) {
+ return false;
+ }
+ List<String> stateList =
net.getRow(groupNode).getList(GROUP_STATE_ATTR, String.class);
+ for (String s: stateList) {
+ String[] tokens = s.split(":");
+ if (netName.equals(tokens[0])) {
+ return
Boolean.valueOf(tokens[1]).booleanValue();
+ }
+ }
+ return false;
+ }
+
+ private void updateCountAttributes(CyNetwork net) {
+ CyTable nodeTable = net.getDefaultNodeTable();
+ CyColumn childrenColumn = nodeTable.getColumn(CHILDREN_ATTR);
+ if (childrenColumn == null) {
+ nodeTable.createColumn(CHILDREN_ATTR, Integer.class,
true);
+ }
+
+ if (!nodeTable.rowExists(groupNode.getSUID())) {
+ // Shouldn't happen!
+ return;
+ }
+ CyRow groupRow = nodeTable.getRow(groupNode.getSUID());
+ groupRow.set(CHILDREN_ATTR, groupNet.getNodeCount());
+
+ CyColumn descendentsColumn =
nodeTable.getColumn(DESCENDENTS_ATTR);
+ if (descendentsColumn == null) {
+ nodeTable.createColumn(DESCENDENTS_ATTR, Integer.class,
true);
+ }
+
+ int nDescendents = groupNet.getNodeCount();
+ for (CyNode node: groupNet.getNodeList()) {
+ if (mgr.isGroup(node, rootNetwork)) {
+ Integer d =
nodeTable.getRow(node.getSUID()).get(DESCENDENTS_ATTR, Integer.class);
+ if (d != null)
+ nDescendents += d.intValue();
+ }
+ }
+ groupRow.set(DESCENDENTS_ATTR, nDescendents);
+ }
+
}
--
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.