Package nl.nanoworks.nanograph.model

Examples of nl.nanoworks.nanograph.model.DefaultGraphModel


public class NanoGraphApplet extends JApplet {
 
  NanoGraph p = null;
 
  public void init() {
    DefaultGraphModel g = new DefaultGraphModel();
    p = new NanoGraph();
   
    p.addMouseListener(new MouseAdapter(){
     
      public void mouseClicked(MouseEvent e)
      {
        p.setLayout(new ForceDirectedLayoutAlgorithm(p));
      }
    }
    );
   
    p.setGraph(g);
   
    if (getParameter("nodes") != null)
    {
      // parse graph from parameters
      //
      StringTokenizer st = new StringTokenizer(
          this.getParameter("nodes"), ",");

      while (st.hasMoreElements())
        g.addNode(st.nextToken());

      st = new StringTokenizer(this.getParameter("edges"), ",-");

      while (st.hasMoreElements())
        g.addEdge("edge", st.nextToken(), st.nextToken());
    }
    else
    {
      // default graph
      g.addNode("Java");
      g.addNode("Python");
      g.addNode("C++");
      g.addNode("Perl");
      g.addNode("C#");
      g.addNode("Programming Language");

      g.addEdge("is a", "Java", "Programming Language");
      g.addEdge("is a", "Java", "Python");
      g.addEdge("is a", "C#", "Programming Language");
      g.addEdge("is a", "C++", "Programming Language");
      g.addEdge("is a", "Perl", "Programming Language");
      g.addEdge("is a", "Python", "Programming Language");
    }
   
    p.setLayout(new CircularLayoutAlgorithm(200));
    //p.setLayout(new ForceDirectedLayoutAlgorithm(p));
   
View Full Code Here


*/
public class NanoGraphTest {

  public static void main(String[] args)
  {
    DefaultGraphModel g = new DefaultGraphModel();
   
    g.addNode("Java");
    g.addNode("Python");
    g.addNode("C++");
    g.addNode("Perl");
    g.addNode("C#");
    g.addNode("Programming Language");

    g.addEdge("is a", "Java", "Programming Language");
    g.addEdge("is a", "Java", "Python");
    g.addEdge("is a", "C#", "Programming Language");
    g.addEdge("is a", "C++", "Programming Language");
    g.addEdge("is a", "Perl", "Programming Language");
    g.addEdge("is a", "Python", "Programming Language");
 
   
    NanoGraph gp = new NanoGraph();
   
    DebugGraphListener dgl = new DebugGraphListener(new OutputStreamWriter(System.out));
View Full Code Here

*/
public class NanoGraphTest {

  public static void main(String[] args)
  {
    DefaultGraphModel g = new DefaultGraphModel();
   
    g.addNode("Java");
    g.addNode("Python");
    g.addNode("C++");
    g.addNode("Perl");
    g.addNode("C#");
    g.addNode("Programming Language");

    g.addEdge("is a", "Java", "Programming Language");
    g.addEdge("is a", "Java", "Python");
    g.addEdge("is a", "C#", "Programming Language");
    g.addEdge("is a", "C++", "Programming Language");
    g.addEdge("is a", "Perl", "Programming Language");
    g.addEdge("is a", "Python", "Programming Language");
 
   
    NanoGraphPanel gp = new NanoGraphPanel();
   
    DebugGraphListener dgl = new DebugGraphListener(new OutputStreamWriter(System.out));
View Full Code Here

 
  NanoGraphPanel p = null;
 
  public void init() {
     
    DefaultGraphModel g = new DefaultGraphModel();
    p = new NanoGraphPanel();
    p.setBorder(new LineBorder(Color.darkGray, 1, true));
    p.addMouseListener(new MouseAdapter(){
     
      public void mouseClicked(MouseEvent e)
      {
        p.getNanoGraph().setLayout(new ForceDirectedLayoutAlgorithm(p));
      }
    }
    );
   
    p.setModel(g);
   
    if (getParameter("nodes") != null)
    {
      // parse graph from parameters
      //
      StringTokenizer st = new StringTokenizer(
          this.getParameter("nodes"), ",");

      while (st.hasMoreElements())
        g.addNode(st.nextToken());

      st = new StringTokenizer(this.getParameter("edges"), ",-");

      while (st.hasMoreElements())
        g.addEdge("edge", st.nextToken(), st.nextToken());
    }
    else
    {
      // default graph
      g.addNode("Java");
      g.addNode("Python");
      g.addNode("C++");
      g.addNode("Perl");
      g.addNode("C#");
      g.addNode("Programming Language");

      g.addEdge("is a", "Java", "Programming Language");
      g.addEdge("is a", "Java", "Python");
      g.addEdge("is a", "C#", "Programming Language");
      g.addEdge("is a", "C++", "Programming Language");
      g.addEdge("is a", "Perl", "Programming Language");
      g.addEdge("is a", "Python", "Programming Language");
    }
   
    p.getNanoGraph().setLayout(new CircularLayoutAlgorithm(200));
    DefaultNodeRenderer r = new DefaultNodeRenderer();
    r.setBodyColor(new GradientPaint(0,0,Color.YELLOW, 600, 600, Color.RED));
View Full Code Here

TOP

Related Classes of nl.nanoworks.nanograph.model.DefaultGraphModel

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.