Author: scooter Date: 2011-09-14 16:36:49 -0700 (Wed, 14 Sep 2011) New Revision: 26804
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/visual/ui/VizMapperMainPanel.java
Log:
When we change the controlling attribute for a discrete mapper, we need to
make sure to recreate the mapping to avoid class cast problems.
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/visual/ui/VizMapperMainPanel.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/visual/ui/VizMapperMainPanel.java
2011-09-14 23:15:09 UTC (rev 26803)
+++
cytoscape/trunk/application/src/main/java/cytoscape/visual/ui/VizMapperMainPanel.java
2011-09-14 23:36:49 UTC (rev 26804)
@@ -1299,6 +1299,7 @@
private final void buildProperty(Calculator calc, VizMapperProperty
calculatorTypeProp,
String rootCategory) {
final VisualPropertyType type = calc.getVisualPropertyType();
+
/*
* Set one calculator
*/
@@ -1670,6 +1671,8 @@
Item selectedItem = (Item)
visualPropertySheetPanel.getTable().getValueAt(selected, 0);
VizMapperProperty prop = (VizMapperProperty)
selectedItem.getProperty();
+ if (prop == null)
+ return;
VisualPropertyType type = null;
String ctrAttrName = null;
@@ -1683,10 +1686,12 @@
typeRootProp = (VizMapperProperty) prop;
type = (VisualPropertyType) ((VizMapperProperty)
prop).getHiddenObject();
ctrAttrName = (String) e.getNewValue();
+ logger.debug("Controlling attribute for: " +
prop.getHiddenObject() + " changed to: "+ctrAttrName);
} else if ((prop.getParentProperty() == null) &&
(e.getNewValue() == null)) {
/*
* Empty cell selected. no need to change anything.
*/
+ logger.debug("Empty cell selected");
return;
} else {
typeRootProp = (VizMapperProperty)
prop.getParentProperty();
@@ -1694,8 +1699,7 @@
if (prop.getParentProperty() == null)
return;
- type = (VisualPropertyType) ((VizMapperProperty)
prop.getParentProperty())
-
!
!
.getHiddenObject();
+ type = (VisualPropertyType) ((VizMapperProperty)
prop.getParentProperty()).getHiddenObject();
}
/*
@@ -1793,6 +1797,7 @@
}
final Byte dataType = attrForTest.getType(ctrAttrName);
+ final Class dataClass =
CyAttributesUtils.getClass(ctrAttrName, attrForTest);
// This part is for Continuous Mapping.
if (mapping instanceof ContinuousMapping) {
@@ -1821,8 +1826,23 @@
final Map saved =
discMapBuffer.get(newMappingName);
if (saved == null) {
+ // Save the current mapping
discMapBuffer.put(curMappingName,
((DiscreteMapping) mapping).getAll());
-
mapping.setControllingAttributeName(ctrAttrName);
+ // Create a new mapping
+ if (type.isNodeProp()) {
+
vmm.getVisualStyle().getNodeAppearanceCalculator().removeCalculator(type);
+ } else {
+
vmm.getVisualStyle().getEdgeAppearanceCalculator().removeCalculator(type);
+ }
+
vmm.getCalculatorCatalog().removeCalculator(curCalc);
+
NewMappingBuilder.createNewCalculator(type, "Discrete Mapper",
curCalc.toString(), ctrAttrName);
+ Calculator newCalc =
vmm.getCalculatorCatalog().getCalculator(type, curCalc.toString());
+
newCalc.getMapping(0).setControllingAttributeName(ctrAttrName);
+ if (type.isNodeProp()) {
+
vmm.getVisualStyle().getNodeAppearanceCalculator().setCalculator(newCalc);
+ } else {
+
vmm.getVisualStyle().getEdgeAppearanceCalculator().setCalculator(newCalc);
+ }
} else if (saved != null) {
// Mapping exists
discMapBuffer.put(curMappingName,
((DiscreteMapping) mapping).getAll());
--
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.
