Exemplo n.º 1
0
  @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;
  }
Exemplo n.º 2
0
  private void display() {

    CyServiceRegistrarImpl register = new CyServiceRegistrarImpl(bc);

    CyNetworkViewManager viewManager = register.getService(CyNetworkViewManager.class);
    CyNetworkViewFactory viewFactory = register.getService(CyNetworkViewFactory.class);
    CyNetworkView networkView = viewFactory.createNetworkView(network);
    viewManager.addNetworkView(networkView);

    VisualMappingFunctionFactory passthroughFactory =
        register.getService(VisualMappingFunctionFactory.class, "(mapping.type=passthrough)");
    VisualMappingFunctionFactory continuousFactory =
        register.getService(VisualMappingFunctionFactory.class, "(mapping.type=continuous)");
    VisualMappingManager vmManager = register.getService(VisualMappingManager.class);
    VisualStyleFactory vsFactory = register.getService(VisualStyleFactory.class);
    VisualStyle vs =
        vsFactory.createVisualStyle(
            network.getDefaultNetworkTable().getRow(network.getSUID()).get("name", String.class));

    PassthroughMapping pMapping =
        (PassthroughMapping)
            passthroughFactory.createVisualMappingFunction(
                "name", String.class, BasicVisualLexicon.NODE_LABEL);

    vs.addVisualMappingFunction(pMapping);
    vs.apply(networkView);

    ContinuousMapping mapping =
        (ContinuousMapping)
            continuousFactory.createVisualMappingFunction(
                "score", Double.class, BasicVisualLexicon.NODE_FILL_COLOR);

    Double val1 = getMinimum(network.getDefaultNodeTable().getColumn("score"));
    BoundaryRangeValues<Paint> brv1 =
        new BoundaryRangeValues<Paint>(Color.GREEN, Color.GREEN, Color.GREEN);

    Double val3 = getMaximum(network.getDefaultNodeTable().getColumn("score"));
    BoundaryRangeValues<Paint> brv3 =
        new BoundaryRangeValues<Paint>(Color.RED, Color.RED, Color.RED);

    Double val2 = (val1 + val3 + val1 + val1) / 4;
    BoundaryRangeValues<Paint> brv2 =
        new BoundaryRangeValues<Paint>(Color.YELLOW, Color.YELLOW, Color.YELLOW);

    mapping.addPoint(val1, brv1);
    mapping.addPoint(val2, brv2);
    mapping.addPoint(val3, brv3);

    vs.addVisualMappingFunction(mapping);
    vs.apply(networkView);

    vmManager.addVisualStyle(vs);
    vmManager.setVisualStyle(vs, networkView);
    networkView.updateView();
  }