@SuppressWarnings({"rawtypes", "unchecked"}) private final ContinuousMapping parseContinuous( String columnName, Class<?> type, VisualProperty<?> vp, VisualMappingFunctionFactory factory, JsonNode mappingNode) { final ContinuousMapping mapping = (ContinuousMapping) factory.createVisualMappingFunction(columnName, type, vp); for (JsonNode point : mappingNode.get("points")) { JsonNode val = point.get("value"); JsonNode lesser = point.get("lesser"); JsonNode equal = point.get("equal"); JsonNode greater = point.get("greater"); final BoundaryRangeValues newPoint = new BoundaryRangeValues( vp.parseSerializableString(lesser.asText()), vp.parseSerializableString(equal.asText()), vp.parseSerializableString(greater.asText())); mapping.addPoint(val.asDouble(), newPoint); } return mapping; }
@SuppressWarnings({"rawtypes", "unchecked"}) private final void parseDefaults( final JsonNode defaults, final VisualStyle style, final VisualLexicon lexicon) { for (final JsonNode vpNode : defaults) { String vpName = vpNode.get(MAPPING_VP).textValue(); final VisualProperty vp = getVisualProperty(vpName, lexicon); final JsonNode value = vpNode.get("value"); if (vp == null || value == null) { continue; } Object parsedValue = null; if (value.isTextual()) { parsedValue = vp.parseSerializableString(value.asText()); } else { parsedValue = vp.parseSerializableString(value.toString()); } style.setDefaultValue(vp, parsedValue); } }
/** * Directly update view object. * * @param view * @param rootNode * @param lexicon */ public Response updateView( final View<? extends CyIdentifiable> view, final JsonNode rootNode, final VisualLexicon lexicon) { for (final JsonNode vpNode : rootNode) { String vpName = vpNode.get(MAPPING_VP).textValue(); final VisualProperty<?> vp = getVisualProperty(vpName, lexicon); final JsonNode value = vpNode.get(MAPPING_DISCRETE_VALUE); if (vp == null || value == null) { continue; } Object parsedValue = null; if (value.isTextual()) { parsedValue = vp.parseSerializableString(value.asText()); } else { parsedValue = vp.parseSerializableString(value.toString()); } view.setVisualProperty(vp, parsedValue); } return Response.ok().build(); }
@SuppressWarnings({"rawtypes", "unchecked"}) private final DiscreteMapping parseDiscrete( String columnName, Class<?> type, VisualProperty<?> vp, VisualMappingFunctionFactory factory, JsonNode discreteMapping) { DiscreteMapping mapping = (DiscreteMapping) factory.createVisualMappingFunction(columnName, type, vp); final Map map = new HashMap(); for (JsonNode pair : discreteMapping) { final Object key = parseKeyValue(type, pair.get(MAPPING_DISCRETE_KEY).textValue()); if (key != null) { map.put(key, vp.parseSerializableString(pair.get(MAPPING_DISCRETE_VALUE).textValue())); } } mapping.putAll(map); return mapping; }