Author: ruschein
Date: 2010-06-28 08:01:19 -0700 (Mon, 28 Jun 2010)
New Revision: 20677
Modified:
cytoscape/trunk/lib/equations.jar
cytoscape/trunk/src/cytoscape/data/readers/CyAttributesReader.java
cytoscape/trunk/src/cytoscape/data/readers/XGMMLParser.java
Log:
Enabled "error equations" to have an arbitrary return type.
Modified: cytoscape/trunk/lib/equations.jar
===================================================================
(Binary files differ)
Modified: cytoscape/trunk/src/cytoscape/data/readers/CyAttributesReader.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/readers/CyAttributesReader.java
2010-06-28 15:00:55 UTC (rev 20676)
+++ cytoscape/trunk/src/cytoscape/data/readers/CyAttributesReader.java
2010-06-28 15:01:19 UTC (rev 20677)
@@ -92,6 +92,23 @@
ar.addEquations(cyAttrs);
}
+ private Class mapCytoscapeAttribTypeToEqnType(final byte attribType) {
+ switch (attribType) {
+ case CyAttributes.TYPE_BOOLEAN:
+ return Boolean.class;
+ case CyAttributes.TYPE_INTEGER:
+ return Long.class;
+ case CyAttributes.TYPE_FLOATING:
+ return Double.class;
+ case CyAttributes.TYPE_STRING:
+ return String.class;
+ case CyAttributes.TYPE_SIMPLE_LIST:
+ return List.class;
+ default:
+ throw new IllegalStateException("can't map Cytoscape
type " + attribType + " to equation return type!");
+ }
+ }
+
private void addEquations(final CyAttributes cyAttrs) {
final EqnCompiler compiler = new EqnCompiler();
final String[] allAttribNames = cyAttrs.getAttributeNames();
@@ -99,17 +116,7 @@
int index = 0;
for (final String attribName : allAttribNames) {
final byte type = cyAttrs.getType(attribName);
- if (type == CyAttributes.TYPE_BOOLEAN)
- allTypes[index] = Boolean.class;
- else if (type == CyAttributes.TYPE_INTEGER)
- allTypes[index] = Long.class;
- else if (type == CyAttributes.TYPE_FLOATING)
- allTypes[index] = Double.class;
- else if (type == CyAttributes.TYPE_STRING)
- allTypes[index] = String.class;
- else if (type == CyAttributes.TYPE_SIMPLE_LIST)
- allTypes[index] = List.class;
- ++index;
+ allTypes[index++] =
mapCytoscapeAttribTypeToEqnType(type);
}
for (final AttribEquation attribEquation : attribEquations) {
@@ -127,7 +134,9 @@
else {
final String errorMessage =
compiler.getLastErrorMsg();
logger.warn("bad equation on line " +
attribEquation.getLineNumber() + ": " + errorMessage);
- final Equation errorEquation =
Equation.getErrorEquation(attribEquation.getEquation(), errorMessage);
+ final Class eqnType =
mapCytoscapeAttribTypeToEqnType(attribEquation.getDataType());
+ final Equation errorEquation =
Equation.getErrorEquation(attribEquation.getEquation(),
+
eqnType, errorMessage);
cyAttrs.setAttribute(attribEquation.getID(),
attribEquation.getAttrName(), errorEquation,
attribEquation.getDataType());
}
Modified: cytoscape/trunk/src/cytoscape/data/readers/XGMMLParser.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/readers/XGMMLParser.java 2010-06-28
15:00:55 UTC (rev 20676)
+++ cytoscape/trunk/src/cytoscape/data/readers/XGMMLParser.java 2010-06-28
15:01:19 UTC (rev 20677)
@@ -630,6 +630,24 @@
}
+ private Class mapCytoscapeAttribTypeToEqnType(final byte attribType) {
+ switch (attribType) {
+ case CyAttributes.TYPE_BOOLEAN:
+ return Boolean.class;
+ case CyAttributes.TYPE_INTEGER:
+ return Long.class;
+ case CyAttributes.TYPE_FLOATING:
+ return Double.class;
+ case CyAttributes.TYPE_STRING:
+ return String.class;
+ case CyAttributes.TYPE_SIMPLE_LIST:
+ return List.class;
+ default:
+ throw new IllegalStateException("can't map Cytoscape
type " + attribType + " to equation return type!");
+ }
+ }
+
+
private void compileAndAddEquationAttribs(final List<AttribEquation>
attribEquations,
final Map<String, Class>
attribNameToTypeMap,
final CyAttributes attribs)
@@ -644,7 +662,10 @@
final String errorMessage =
compiler.getLastErrorMsg();
logger.warn("failed to compile an equation in
an XGMML input file ("
+ errorMessage + ")!");
- final Equation errorEquation =
Equation.getErrorEquation(attribEquation.getEquation(), errorMessage);
+ final Equation errorEquation =
+
Equation.getErrorEquation(attribEquation.getEquation(),
+
mapCytoscapeAttribTypeToEqnType(attribEquation.getDataType()),
+ errorMessage);
attribs.setAttribute(attribEquation.getID(),
attribEquation.getAttrName(),
errorEquation,
attribEquation.getDataType());
}
--
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.