Author: Christian Lopes
Date: 2011-05-30 14:11:03 -0700 (Mon, 30 May 2011)
New Revision: 25590
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/VizmapPropertiesReader.java
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/converters/CalculatorConverter.java
Log:
The vizmap properties reader should now be able to read visual property
dependencies from the old vizmap.props format.
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/VizmapPropertiesReader.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/VizmapPropertiesReader.java
2011-05-30 21:06:54 UTC (rev 25589)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/VizmapPropertiesReader.java
2011-05-30 21:11:03 UTC (rev 25590)
@@ -43,6 +43,7 @@
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.view.vizmap.model.ContinuousMapping;
+import org.cytoscape.view.vizmap.model.Dependency;
import org.cytoscape.view.vizmap.model.DiscreteMapping;
import org.cytoscape.view.vizmap.model.Edges;
import org.cytoscape.view.vizmap.model.Network;
@@ -108,7 +109,9 @@
String key = p.getKey();
String value = p.getValue();
- if (isDefaultProperty(key)) {
+ if (isDependency(key)) {
+ setDependency(vs, key, value);
+ } else if (isDefaultProperty(key)) {
// e.g.
"globalAppearanceCalculator.MyStyle.defaultBackgroundColor"
setDefaultProperty(vs, key, value);
} else if (isMappingFunction(key)) {
@@ -186,19 +189,19 @@
} else if (dataType == CyEdge.class) {
vpList = vs.getEdges().getVisualProperty();
}
-
+
for (VisualProperty v : vpList) {
- if (v.getId().equalsIgnoreCase(vpId)) {
+ if (v.getName().equalsIgnoreCase(vpId)) {
// The Visual Property has already been created...
vp = v;
break;
}
}
-
+
if (vp == null) {
// The Visual Property has not been created yet...
vp = new VisualProperty();
- vp.setId(vpId);
+ vp.setName(vpId);
vpList.add(vp);
}
@@ -215,16 +218,40 @@
VisualProperty vp = getVisualProperty(vs, dataType, vpId);
Object mapping = c.getMappingFunction(props, value, vp);
-
+
if (mapping instanceof PassthroughMapping)
vp.setPassthroughMapping((PassthroughMapping) mapping);
else if (mapping instanceof ContinuousMapping)
vp.setContinuousMapping((ContinuousMapping) mapping);
- else if (mapping instanceof DiscreteMapping)
- vp.setDiscreteMapping((DiscreteMapping) mapping);
+ else if (mapping instanceof DiscreteMapping)
vp.setDiscreteMapping((DiscreteMapping) mapping);
}
}
+ private void setDependency(VisualStyle vs, String key, String value) {
+ String calcKey = key.split("\\.")[2];
+ CalculatorConverter[] convs =
calculatorConverterFactory.getConverters(calcKey);
+
+ for (CalculatorConverter c : convs) {
+ Class<? extends CyTableEntry> dataType = c.getTargetType();
+
+ if (dataType != CyNetwork.class) {
+ String vpId = c.getVisualPropertyId();
+
+ Dependency d = new Dependency();
+ d.setName(vpId);
+ d.setValue(new Boolean(value.trim()));
+
+ if (dataType == CyNetwork.class) {
+ vs.getNetwork().getDependency().add(d);
+ } else if (dataType == CyNode.class) {
+ vs.getNodes().getDependency().add(d);
+ } else if (dataType == CyEdge.class) {
+ vs.getEdges().getDependency().add(d);
+ }
+ }
+ }
+ }
+
private static boolean isDefaultProperty(String key) {
boolean b = false;
@@ -257,4 +284,15 @@
return b;
}
+
+ private static boolean isDependency(String vpId) {
+ boolean b = false;
+
+ if (vpId != null) {
+ b |= vpId
+
.matches("nodeSizeLocked|nodeLabelColorFromNodeColor|defaultNodeShowNestedNetwork|nodeCustomGraphicsSizeSync|arrowColorMatchesEdge");
+ }
+
+ return b;
+ }
}
Modified:
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/converters/CalculatorConverter.java
===================================================================
---
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/converters/CalculatorConverter.java
2011-05-30 21:06:54 UTC (rev 25589)
+++
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/vizmap/converters/CalculatorConverter.java
2011-05-30 21:11:03 UTC (rev 25590)
@@ -289,7 +289,6 @@
private static String getVisualPropertyId(String calcKey) {
if (calcKey != null) {
- // TODO: updateLegacyKey
return calcKey.replaceAll("(?i)default|calculator|uniform",
"").toLowerCase().trim();
}
--
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.