Search in sources :

Example 1 with VisualProperty

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());
}
Also used : VisualProperty(org.cytoscape.io.internal.util.vizmap.model.VisualProperty)

Example 2 with VisualProperty

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;
}
Also used : VisualProperty(org.cytoscape.io.internal.util.vizmap.model.VisualProperty) CyEdge(org.cytoscape.model.CyEdge)

Example 3 with VisualProperty

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);
}
Also used : ContinuousMapping(org.cytoscape.io.internal.util.vizmap.model.ContinuousMapping) VisualProperty(org.cytoscape.io.internal.util.vizmap.model.VisualProperty) PassthroughMapping(org.cytoscape.io.internal.util.vizmap.model.PassthroughMapping) DiscreteMapping(org.cytoscape.io.internal.util.vizmap.model.DiscreteMapping)

Example 4 with VisualProperty

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);
}
Also used : VisualProperty(org.cytoscape.io.internal.util.vizmap.model.VisualProperty)

Example 5 with VisualProperty

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;
}
Also used : VisualProperty(org.cytoscape.io.internal.util.vizmap.model.VisualProperty) CyNode(org.cytoscape.model.CyNode)

Aggregations

VisualProperty (org.cytoscape.io.internal.util.vizmap.model.VisualProperty)5 ContinuousMapping (org.cytoscape.io.internal.util.vizmap.model.ContinuousMapping)1 DiscreteMapping (org.cytoscape.io.internal.util.vizmap.model.DiscreteMapping)1 PassthroughMapping (org.cytoscape.io.internal.util.vizmap.model.PassthroughMapping)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNode (org.cytoscape.model.CyNode)1