use of org.cytoscape.io.internal.util.vizmap.model.VisualProperty in project cytoscape-impl by cytoscape.
the class CalculatorConverterTest method testConvertDefaltValue.
private void testConvertDefaltValue(String key, String oldKey, Class<? extends CyIdentifiable> type, String value, String expected) {
CalculatorConverter c = new CalculatorConverter(key, oldKey);
c.convert(vs, value, props);
VisualProperty vp = getVisualProperty(c.getVisualPropertyId(), vs, type);
assertEquals(expected, vp.getDefault());
}
use of org.cytoscape.io.internal.util.vizmap.model.VisualProperty in project cytoscape-impl by cytoscape.
the class CalculatorConverterTest method getVisualProperty.
private VisualProperty getVisualProperty(String id, VisualStyle vs, Class<? extends CyIdentifiable> type) {
List<VisualProperty> list = null;
if (type == CyNode.class)
list = vs.getNode().getVisualProperty();
else if (type == CyEdge.class)
list = vs.getEdge().getVisualProperty();
else
list = vs.getNetwork().getVisualProperty();
for (VisualProperty vp : list) {
if (vp.getName().equalsIgnoreCase(id))
return vp;
}
return null;
}
use of org.cytoscape.io.internal.util.vizmap.model.VisualProperty in project cytoscape-impl by cytoscape.
the class CalculatorConverter method setMappingFunction.
private void setMappingFunction(VisualStyle vs, String sValue, Properties props) {
VisualProperty vp = getVisualProperty(vs);
Object mapping = getMappingFunction(props, sValue, 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);
}
use of org.cytoscape.io.internal.util.vizmap.model.VisualProperty in project cytoscape-impl by cytoscape.
the class CalculatorConverter method setDefaultProperty.
private void setDefaultProperty(VisualStyle vs, String sValue) {
VisualProperty vp = getVisualProperty(vs);
String value = getValue(sValue);
vp.setDefault(value);
}
use of org.cytoscape.io.internal.util.vizmap.model.VisualProperty in project cytoscape-impl by cytoscape.
the class CalculatorConverter method getVisualProperty.
/**
* Get or create a new Visual Property for the passed Visual Style.
* It checks if the property already exists in Network, Nodes or Edges, according to the dataType. If it does not
* exist, the property is created and added to the style.
* @param vs
* @return
*/
private VisualProperty getVisualProperty(VisualStyle vs) {
VisualProperty vp = null;
List<VisualProperty> vpList = null;
if (targetType == CyNetwork.class) {
vpList = vs.getNetwork().getVisualProperty();
} else if (targetType == CyNode.class) {
vpList = vs.getNode().getVisualProperty();
} else if (targetType == CyEdge.class) {
vpList = vs.getEdge().getVisualProperty();
}
for (VisualProperty v : vpList) {
if (v.getName().equalsIgnoreCase(visualPropertyId)) {
// 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.setName(visualPropertyId);
vpList.add(vp);
}
return vp;
}
Aggregations