Package net.sourceforge.jpowergraph

Examples of net.sourceforge.jpowergraph.Node


 
  public static DefaultGraph createGraph(Concept concept){
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();      
    Node conceptNode = new ConceptNode(concept.getConceptDescription().getName());
    Node superClassRoot = new PrintNode( ApplicationResources.getString("superclasses.node.root"));
    Node subClassRoot = new PrintNode( ApplicationResources.getString("subclasses.node.root"));
    Node relationsRoot = new PrintNode( ApplicationResources.getString("relations.node.root"));
    Node instancesRoot = new PrintNode( ApplicationResources.getString("instances.node.root"));
    Node instancesOfRoot = new PrintNode( ApplicationResources.getString("instancesOf.node.root"));
    nodes.add(superClassRoot);
    nodes.add(subClassRoot);
    nodes.add(relationsRoot);
    nodes.add(instancesRoot);
    nodes.add(instancesOfRoot);
    edges.add(new LineEdge(conceptNode,superClassRoot));
    edges.add(new LineEdge(conceptNode,subClassRoot));
    edges.add(new LineEdge(conceptNode,instancesRoot));
    edges.add(new LineEdge(conceptNode,relationsRoot));
    edges.add(new LineEdge(conceptNode,instancesRoot));
    edges.add(new LineEdge(conceptNode,instancesOfRoot));
    Node relatedNode = null;
    for (Relation r : concept.getRelations().getRelations()) {
      //For each conceptDescription in relation
      for (ConceptDescription conceptDescription : r.getConceptDescriptions()) {
        final String objectConceptUri = conceptDescription.getUri();
        if(objectConceptUri!=null ){
View Full Code Here


    graph.addElements(nodes, edges);
    return graph;
  }

  private static void addNodes(List<ConceptDescription> descriptions, ArrayList<Node> nodes, ArrayList<Edge> edges, Node instancesRoot) {
    Node relatedNode;
    for (ConceptDescription description : descriptions) {
        relatedNode = new InstanceNode(description.getName());
        edges.add(new LineEdge(instancesRoot, relatedNode));
        nodes.add(relatedNode);
    }
View Full Code Here

  public static DefaultGraph createGraphFromOntoSpreadState(OntologyDAO ontologyDAO, OntoSpreadState ontoSpreadState) throws Exception{
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();
    //FIXME: Refactor, using relations and draw instances and concepts, equals
    Node root = new PrintNode( ApplicationResources.getString("info.node.root"));
    Node initialRoot = new PrintNode( ApplicationResources.getString("initial.node.root"));
    Map<String, Double> concepts = ontoSpreadState.getConcepts();
    for (ScoredConceptTO initialConcept : ontoSpreadState.getInitialConcepts()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(initialConcept.getConceptUri());
      Node node = new InitialNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new LineEdge(initialRoot,node));
      nodes.add(node);
    }

    Node spreadedRoot = new PrintNode( ApplicationResources.getString("initial.node.spreaded"));
    for (String currentSpread : ontoSpreadState.getSpreadedConcepts()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(currentSpread);
      Node currentNode = new SpreadNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new LineEdge(spreadedRoot,currentNode));
      nodes.add(currentNode);
    }

    Node activatedRoot = new PrintNode(ApplicationResources.getString("initial.node.activated") );
    for (UriDepthPair activated : ontoSpreadState.getSortedList()) {
      ConceptTO conceptTO = ontologyDAO.getConceptTO(activated.getUri())
      Node currentNode = new ActivateNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())),conceptTO.getUri());
      edges.add(new ArrowEdge(activatedRoot,currentNode));
      nodes.add(currentNode);
    }
    //Creating skeleton of graph
    edges.add(new LineEdge(root,initialRoot));
View Full Code Here

    Map<String,PathTO[]> spreadPathTable = ontoSpreadState.getSpreadPathTable();
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();
    ConceptTO pathConceptTO = null;
    Node spreadedNode = new ActivateNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())), conceptTO.getUri());
    Node activatedRoot = new PrintNode(ApplicationResources.getString("initial.node.activated") );
    for (String conceptUri : spreadPathTable.keySet()) {
      PathTO[]path = spreadPathTable.get(conceptUri);
      if(path[path.length-1].getConceptUri().equals(conceptTO.getUri()) && !conceptUri.equals(conceptTO.getUri())){
        Node sonNode = spreadedNode;
        for (int i = path.length-1; i >=0 ; i--) {
          pathConceptTO = ontologyDAO.getConceptTO(path[i].getConceptUri());
          Node pathNode = new PathNode(
              formatActivation(pathConceptTO.getName(),
                  concepts.get(pathConceptTO.getUri())),path[i].getConceptUri());
//          for(String relation:path[i].getRelationsUri()){
//            if(relation == null) relation = "#INITIAL";
//            edges.add(new TextEdge(pathNode,sonNode,""+formatRelation(relation))); 
//          }
          edges.add(new LineEdge(pathNode,sonNode));
          nodes.add(pathNode);
          sonNode = pathNode;
        }
        pathConceptTO = ontologyDAO.getConceptTO(conceptUri);       
        Node activateNode =
          new ActivationNode(
              formatActivation(pathConceptTO.getName(),
                  concepts.get(pathConceptTO.getUri())),
                  pathConceptTO.getUri());
        for(String relation:path[path.length-1].getRelationsUri()){
View Full Code Here

    Map<String,PathTO[]> spreadPathTable = ontoSpreadState.getSpreadPathTable();
    DefaultGraph graph = new DefaultGraph();
    ArrayList <Node> nodes = new ArrayList <Node> ();
    ArrayList <Edge> edges = new ArrayList <Edge> ();
    ConceptTO pathConceptTO = null;
    Node spreadedNode = new SpreadingNode(formatActivation(conceptTO.getName(),concepts.get(conceptTO.getUri())), conceptTO.getUri());
    Node activatedRoot = new PrintNode(ApplicationResources.getString("initial.node.activated") );
    for (String conceptUri : spreadPathTable.keySet()) {
      PathTO[]path = spreadPathTable.get(conceptUri);
      if(path[path.length-1].getConceptUri().equals(conceptTO.getUri()) && !conceptUri.equals(conceptTO.getUri())){
        Node sonNode = spreadedNode;
        for (int i = path.length-1; i >=0 ; i--) {
          pathConceptTO = ontologyDAO.getConceptTO(path[i].getConceptUri());
          Node pathNode = new PathNode(
              formatActivation(pathConceptTO.getName(),
                  concepts.get(pathConceptTO.getUri())),path[i].getConceptUri());
//          for(String relation:path[i].getRelationsUri()){
//            if(relation == null) relation = "#INITIAL";
//            edges.add(new TextEdge(pathNode,sonNode,""+formatRelation(relation))); 
//          }
          edges.add(new LineEdge(pathNode,sonNode));
          nodes.add(pathNode);
          sonNode = pathNode;
        }
        pathConceptTO = ontologyDAO.getConceptTO(conceptUri);       
        Node activateNode =
          new ActivationNode(
              formatActivation(pathConceptTO.getName(),
                  concepts.get(pathConceptTO.getUri())),
                  pathConceptTO.getUri());
        for(String relation:path[path.length-1].getRelationsUri()){
View Full Code Here

   
  private void showPathNode(Node currentNode, String currentUri, String[] path, OntologyDAO ontologyDAO,  Map<String, Double> concepts ,  ArrayList <Node> nodes, ArrayList <Edge> edges) throws ConceptNotFoundException {
    for (String concept : path) {      
      if(!concept.equals(currentUri)){
        ConceptTO conceptPath = ontologyDAO.getConceptTO(concept);
        Node nodePath = new PathNode(conceptPath.getName()+" "+concepts.get(conceptPath.getUri()),conceptPath.getUri());             
        edges.add(new LineEdge(currentNode,nodePath));
        nodes.add(nodePath);
      }
    }
  }
View Full Code Here

        List <Node> nodesToRemove = new ArrayList <Node> ();
        List <Edge> edgesToRemove = new ArrayList <Edge> ();
       
        if (nodes != null) {
            for (Iterator i = m_nodes.iterator(); i.hasNext();) {
                Node cnode = (Node) i.next();
                if (nodes.contains(cnode)) {
                    nodes.remove(cnode);
                }
                else {
                    nodesToRemove.add(cnode);
View Full Code Here

        }
    }
   
    public void mouseUp(JPowerGraphMouseEvent e) {
        if (m_draggedNode!=null) {
            Node overChild = getGraphPane().getNodeAtPoint(e.getPoint());
            boolean canLinkHere = edgeCreatorListener.canCreateEdge(m_draggedNode, overChild);
            if (canLinkHere){
                edgeCreatorListener.createEdge(m_draggedNode, overChild);
            }
        }
View Full Code Here

    }

    public void mouseDoubleClick(JPowerGraphMouseEvent e) {
        if (getGraphPane().isEnabled() && e.getButton() == JPowerGraphMouseEvent.LEFT && doubleClickListener != null) {
            Legend legend = getGraphPane().getLegendAtPoint(e.getPoint());
            Node node = getGraphPane().getNodeAtPoint(e.getPoint());
            Edge edge = getGraphPane().getNearestEdge(e.getPoint());

            if (legend != null) {
                doubleClickListener.doubleClick(e, legend);
            }
View Full Code Here

    public DefaultGraph createGraph(){
        DefaultGraph graph = new DefaultGraph();
        ArrayList <Node> nodes = new ArrayList <Node> ();
        ArrayList <Edge> edges = new ArrayList <Edge> ();
       
        Node n1 = new NodeType1("Node 1");
        Node sn1 = new NodeType2("Node 2");
        Node sn2 = new NodeType2("Node 3");
        ClusterNode sn3 = new NodeType4("Node 4", 19);
        Node sn4 = new NodeType2("Node 5");
        Node sn5 = new NodeType2("Node 6");
        Node sn6 = new NodeType2("Multi Line\nNode Label");
        Node ssn1 = new NodeType3("Node 7");
        Node ssn2 = new NodeType3("Node 8");
       
        nodes.add(n1);
        nodes.add(sn1);
        nodes.add(sn2);
        nodes.add(sn3);
View Full Code Here

TOP

Related Classes of net.sourceforge.jpowergraph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.