예제 #1
0
 public static String getStructureImageFilePath(Node node) {
   Graph2D graph = (Graph2D) node.getGraph();
   NodeRealizer nr = graph.getRealizer(node);
   String fileName = nr.getLabelText();
   fileName = fileName + ".png";
   return NUCLEOTIDE_DIRECTORY + System.getProperty("file.separator") + fileName;
 }
  private Node createNode(String label, Graph2D graph) {
    Node node = graph.createNode();

    NodeRealizer nodeRealizer = graph.getRealizer(node);
    nodeRealizer.getLabel().setText(label);

    return node;
  }
  private void realizeChemEdge(
      Graph2D graph, Edge newEdge, Attachment sourceAttachment, Attachment targetAttachment) {

    EdgeMap edgeTypeMap = (EdgeMap) graph.getDataProvider(EdgeMapKeys.EDGE_INFO);

    EdgeRealizer er = graph.getRealizer(newEdge);
    er.setLineColor(Color.BLACK);
    er.setLineType(LineType.LINE_1);
    edgeTypeMap.set(newEdge, new SViewEdgeInfo(EdgeType.CHEM, sourceAttachment, targetAttachment));
  }
  private Node createChemNode(String label, Graph2D graph) {
    Node chem = createNode(label, graph);
    NodeRealizer nodeRealizer = graph.getRealizer(chem);
    nodeRealizer.setTransparent(false);

    NodeLabel nl = nodeRealizer.getLabel(0);
    // nodeRealizer.setSize(_layoutMetrics.getChemNodeSize(),
    // _layoutMetrics.getChemNodeSize());
    nodeRealizer.setSize(nl.getBox().getWidth() + 10, nl.getBox().getHeight());
    nl.setFontSize(_layoutMetrics.getChemNodeFontSize());
    nl.setFontStyle(Font.BOLD);
    nl.setModel(NodeLabel.INTERNAL);
    nl.setPosition(NodeLabel.CENTER);
    nl.setAlignment(NodeLabel.ALIGN_CENTER);
    nl.setTextColor(Color.BLACK);

    return chem;
  }
  private Node createErrorNode(String label, Graph2D graph) {
    Node node = createNode(label, graph);

    NodeRealizer nodeRealizer = graph.getRealizer(node);
    nodeRealizer.setTransparent(true);
    nodeRealizer.setLineColor(Color.white);

    NodeLabel nl = nodeRealizer.getLabel(0);
    nl.setFontSize(_layoutMetrics.getLabelFontSize() + 15);
    nl.setFontStyle(Font.PLAIN);
    nl.setModel(NodeLabel.INTERNAL);
    nl.setPosition(NodeLabel.CENTER);
    nl.setAlignment(NodeLabel.ALIGN_LEFT);
    nl.setTextColor(Color.cyan);

    nodeRealizer.setSize(nl.getBox().getWidth(), nl.getBox().getHeight());

    return node;
  }
예제 #6
0
  /**
   * Create a standard graph. Each graph contains 3 nodes, base<-R->P where R and P are standard
   * monomers
   *
   * @param notation : the base monomer id. A, T, C, G, U
   * @return a graph that represents a notation
   */
  @Deprecated
  public static Graph2D createNucleictideNodeGraph(String notation)
      throws MonomerException, IOException, JDOMException {

    // a graph is used in here because we need to associate data with every nodes
    Graph2D graph = new Graph2D();
    graph.setDefaultNodeRealizer(new MonomerNodeRealizer());
    NodeMap nodePropertiesNodeMap = graph.createNodeMap();
    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodePropertiesNodeMap);

    EdgeMap edgeMap = graph.createEdgeMap();
    graph.addDataProvider(EdgeMapKeys.EDGE_INFO, edgeMap);

    GraphCopier copier = new GraphCopier(graph.getGraphCopyFactory());
    copier.setDataProviderContentCopying(true);
    copier.setEdgeMapCopying(true);
    copier.setNodeMapCopying(true);

    String baseMonomerID = notation.substring(notation.indexOf("(") + 1, notation.indexOf(")"));
    baseMonomerID = baseMonomerID.replace("[", "");
    baseMonomerID = baseMonomerID.replace("]", "");

    Node baseNode = copier.copy(createNucleicAcidBaseNode(baseMonomerID), graph).firstNode();
    NodeRealizer baseNodeRealizer = graph.getRealizer(baseNode);
    baseNodeRealizer.setCenter(centerX, centerY + size + distance);

    String r = notation.substring(0, notation.indexOf("("));
    r = r.replace("[", "");
    r = r.replace("]", "");

    Node rNode = copier.copy(createNucleicAcidBackboneNode(r, Monomer.ID_R), graph).firstNode();
    NodeRealizer rNodeRealizer = graph.getRealizer(rNode);
    rNodeRealizer.setCenter(centerX, centerY);

    String p = notation.substring(notation.indexOf(")") + 1);
    p = p.replace("[", "");
    p = p.replace("]", "");

    Node pNode = copier.copy(createNucleicAcidBackboneNode(p, Monomer.ID_P), graph).firstNode();
    NodeRealizer pNodeRealizer = graph.getRealizer(pNode);
    pNodeRealizer.setCenter(centerX + size + distance, centerY);

    MonomerInfo pKeys = (MonomerInfo) nodePropertiesNodeMap.get(pNode);
    MonomerInfo rKeys = (MonomerInfo) nodePropertiesNodeMap.get(rNode);
    MonomerInfo baseKeys = (MonomerInfo) nodePropertiesNodeMap.get(baseNode);

    // r->p
    Edge edge = graph.createEdge(rNode, pNode);
    Attachment sourceAttachment =
        rKeys.getAttachment(Attachment.BACKBONE_MONOMER_RIGHT_ATTACHEMENT);
    Attachment targetAttachment = pKeys.getAttachment(Attachment.BACKBONE_MONOMER_LEFT_ATTACHEMENT);
    rKeys.setConnection(sourceAttachment, true);
    pKeys.setConnection(targetAttachment, true);

    edgeMap.set(edge, new EditorEdgeInfoData(sourceAttachment, targetAttachment));

    // r->base
    edge = graph.createEdge(rNode, baseNode);

    sourceAttachment = rKeys.getAttachment(Attachment.BACKBONE_MONOMER_BRANCH_ATTACHEMENT);
    targetAttachment = baseKeys.getAttachment(Attachment.BRANCH_MONOMER_ATTACHEMENT);
    rKeys.setConnection(sourceAttachment, true);
    baseKeys.setConnection(targetAttachment, true);

    edgeMap.set(edge, new EditorEdgeInfoData(sourceAttachment, targetAttachment));

    return graph;
  }