Exemplo n.º 1
0
  /**
   * a dummy base node with no monomer attached to it
   *
   * @param monomerID
   * @return dummy nucleic acid base node graph
   */
  public static Graph2D createDummyNucleicAcidBaseNode(String monomerID) {

    Graph2D graph = new Graph2D();
    MonomerNodeRealizer baseNodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.DIAMOND);
    graph.setDefaultNodeRealizer(baseNodeRealizer);

    final int size = 30;
    baseNodeRealizer.setSize(size, size);

    MonomerInfo monomerKeys = new MonomerInfo(Monomer.NUCLIEC_ACID_POLYMER_TYPE, monomerID);

    Node baseNode = graph.createNode();

    Color fillColor = ColorMap.getNucleotidesColor("X");
    baseNodeRealizer.setFillColor(fillColor);

    Color textColor = new Color(23 - fillColor.getRGB());
    baseNodeRealizer.setLabelText(monomerID);
    baseNodeRealizer.getLabel().setTextColor(textColor);
    baseNodeRealizer.getLabel().setFontSize(14);

    graph.setRealizer(baseNode, baseNodeRealizer);

    NodeMap nodePropertiesNodeMap = graph.createNodeMap();
    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodePropertiesNodeMap);
    nodePropertiesNodeMap.set(baseNode, monomerKeys);

    NodeLabel anotationLabel = new NodeLabel("");
    anotationLabel.setModel(NodeLabel.FREE);
    anotationLabel.setFreeOffset(
        -baseNodeRealizer.getHeight() / 2, -baseNodeRealizer.getWidth() / 4);
    anotationLabel.setTextColor(ANOTATION_COLOR);
    anotationLabel.setFontSize(baseNodeRealizer.getLabel().getFontSize() + 2);

    baseNodeRealizer.addLabel(anotationLabel);

    return graph;
  }