Examples of mxOrganicLayout


Examples of com.mxgraph.layout.mxOrganicLayout

      {
        layout = new mxEdgeLabelLayout(graph);
      }
      else if (ident.equals("organicLayout"))
      {
        layout = new mxOrganicLayout(graph);
      }
      if (ident.equals("verticalPartition"))
      {
        layout = new mxPartitionLayout(graph, false)
        {
View Full Code Here

Examples of com.mxgraph.layout.mxOrganicLayout

 
  private void init()
  {
    m_graph = new mxGraph();
    m_graph.setMinimumGraphSize(new mxRectangle(0,0,400,400));
    layout = new mxOrganicLayout (m_graph);
    m_graph.setCellsDeletable(false);
    m_graph.setCellsDisconnectable(false);
    m_graph.setCellsEditable(false);
    m_graph.setAutoOrigin(true);
    m_graph.setAutoSizeCells(true);
View Full Code Here

Examples of com.mxgraph.layout.mxOrganicLayout

      m_graph.getModel().endUpdate();
    }
    m_graph.setCellsDeletable(false);
    m_graphComponent = new mxGraphComponent(m_graph);
   
    layout = new mxOrganicLayout (m_graph);
    layout.execute(m_graph.getDefaultParent());
    m_graph = layout.getGraph();
   
  }
View Full Code Here

Examples of com.mxgraph.layout.mxOrganicLayout

      {
        layout = new mxEdgeLabelLayout(graph);
      }
      else if (ident.equals("organicLayout"))
      {
        layout = new mxOrganicLayout(graph);
      }
      if (ident.equals("verticalPartition"))
      {
        layout = new mxPartitionLayout(graph, false)
        {
View Full Code Here

Examples of com.mxgraph.layout.mxOrganicLayout

          graph.removeCells();

          generator.getSimpleRandomGraph(aGraph, nodeCount, edgeCount, allowSelfLoops, allowMultipleEdges, forceConnected);

          mxGraphStructure.setDefaultGraphStyle(aGraph, false);
          mxOrganicLayout layout = new mxOrganicLayout(graph);
          layout.execute(graph.getDefaultParent());
          graph.getModel().endUpdate();
          setVisible(false);
        }
      });
      closeButton.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          insertGraph = false;
          setVisible(false);
        }
      });

      getContentPane().add(panelBorder, BorderLayout.CENTER);
      getContentPane().add(buttonPanel, BorderLayout.SOUTH);
      pack();
      setResizable(false);
    }
    else if (graphType2 == GraphType.RESET_STYLE)
    {
      JPanel panel = new JPanel(new GridLayout(4, 2, 4, 4));
      panel.add(arrowsBox = new JCheckBox("Directed", false));
      panel.add(weightedBox = new JCheckBox("Weighted", false));
      panel.add(new JLabel("Min. weight"));
      panel.add(minWeightField);
      panel.add(new JLabel("Max. weight"));
      panel.add(maxWeightField);
      JPanel panelBorder = new JPanel();
      panelBorder.setBorder(new EmptyBorder(10, 10, 10, 10));
      panelBorder.add(panel);

      JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY),
          BorderFactory.createEmptyBorder(16, 8, 8, 8)));

      JButton applyButton = new JButton("Generate");
      JButton closeButton = new JButton("Cancel");
      buttonPanel.add(closeButton);
      buttonPanel.add(applyButton);
      getRootPane().setDefaultButton(applyButton);

      applyButton.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          applyValues();
          int minWeightParam = Integer.parseInt(minWeightField.getText());
          int maxWeightParam = Integer.parseInt(maxWeightField.getText());
          Map<String, Object> props = aGraph.getProperties();
          mxGraphProperties.setDirected(props, arrows);
          mxGraphGenerator generator = new mxGraphGenerator(mxGraphGenerator.getGeneratorFunction(graph, weighted,
              minWeightParam, maxWeightParam), new mxDoubleValCostFunction());
          configAnalysisGraph(graph, generator, props);
          graph.getModel().beginUpdate();

          mxGraphStructure.setDefaultGraphStyle(aGraph, true);

          graph.getModel().endUpdate();
          setVisible(false);
        }
      });
      closeButton.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          insertGraph = false;
          setVisible(false);
        }
      });

      getContentPane().add(panelBorder, BorderLayout.CENTER);
      getContentPane().add(buttonPanel, BorderLayout.SOUTH);
      pack();
      setResizable(false);
      // setLocationRelativeTo(parent);
    }
    else if ((graphType2 == GraphType.BFS_DIR) || (graphType2 == GraphType.DFS_DIR) || (graphType2 == GraphType.BFS_UNDIR)
        || (graphType2 == GraphType.DFS_UNDIR) || (graphType2 == GraphType.MAKE_TREE_DIRECTED)
        || (graphType2 == GraphType.INDEGREE) || (graphType2 == GraphType.OUTDEGREE) || (graphType2 == GraphType.IS_CUT_VERTEX))
    {
      JPanel panel = new JPanel(new GridLayout(1, 2, 4, 4));
      panel.add(new JLabel("Starting vertex"));
      panel.add(startVertexValueField);
      JPanel panelBorder = new JPanel();
      panelBorder.setBorder(new EmptyBorder(10, 10, 10, 10));
      panelBorder.add(panel);

      JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY),
          BorderFactory.createEmptyBorder(16, 8, 8, 8)));

      JButton applyButton = new JButton("Start");
      JButton closeButton = new JButton("Cancel");
      buttonPanel.add(closeButton);
      buttonPanel.add(applyButton);
      getRootPane().setDefaultButton(applyButton);

      applyButton.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          applyValues();
          int value = Integer.parseInt(startVertexValueField.getText());
          Object startVertex = mxGraphStructure.getVertexWithValue(aGraph, value);

          if(startVertex == null)
          {
            System.out.println("The specified vertex is not in the graph.");
          }
          else if (graphType2 == GraphType.BFS_DIR)
          {
            boolean oldDir = mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED);
            mxGraphProperties.setDirected(aGraph.getProperties(), true);
            System.out.println("BFS test");

            mxTraversal.bfs(aGraph, startVertex, new mxICellVisitor()
            {
              @Override
              // simple visitor that prints current vertex
              public boolean visit(Object vertex, Object edge)
              {
                mxCell v = (mxCell) vertex;
                mxCell e = (mxCell) edge;

                if (e != null)
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: " + e.getValue());
                }
                else
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: N/A");
                }

                return false;
              }
            });
           
            mxGraphProperties.setDirected(aGraph.getProperties(), oldDir);
          }
          else if (graphType2 == GraphType.DFS_DIR)
          {
            boolean oldDir = mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED);
            mxGraphProperties.setDirected(aGraph.getProperties(), true);
            System.out.println("DFS test");

            mxTraversal.dfs(aGraph, startVertex, new mxICellVisitor()
            {
              @Override
              // simple visitor that prints current vertex
              public boolean visit(Object vertex, Object edge)
              {
                mxCell v = (mxCell) vertex;
                mxCell e = (mxCell) edge;

                if (e != null)
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: " + e.getValue());
                }
                else
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: N/A");
                }

                return false;
              }
            });

            mxGraphProperties.setDirected(aGraph.getProperties(), oldDir);
          }
          else if (graphType2 == GraphType.BFS_UNDIR)
          {
            boolean oldDir = mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED);
            mxGraphProperties.setDirected(aGraph.getProperties(), false);
            System.out.println("BFS test");

            mxTraversal.bfs(aGraph, startVertex, new mxICellVisitor()
            {
              @Override
              // simple visitor that prints current vertex
              public boolean visit(Object vertex, Object edge)
              {
                mxCell v = (mxCell) vertex;
                mxCell e = (mxCell) edge;

                if (e != null)
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: " + e.getValue());
                }
                else
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: N/A");
                }

                return false;
              }
            });
           
            mxGraphProperties.setDirected(aGraph.getProperties(), oldDir);
          }
          else if (graphType2 == GraphType.DFS_UNDIR)
          {
            boolean oldDir = mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED);
            mxGraphProperties.setDirected(aGraph.getProperties(), false);
            System.out.println("DFS test");

            mxTraversal.dfs(aGraph, startVertex, new mxICellVisitor()
            {
              @Override
              // simple visitor that prints current vertex
              public boolean visit(Object vertex, Object edge)
              {
                mxCell v = (mxCell) vertex;
                mxCell e = (mxCell) edge;

                if (e != null)
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: " + e.getValue());
                }
                else
                {
                  System.out.println("Vertex: " + v.getValue() + " edge: N/A");
                }

                return false;
              }
            });

            mxGraphProperties.setDirected(aGraph.getProperties(), oldDir);
          }
          else if (graphType2 == GraphType.MAKE_TREE_DIRECTED)
          {
            try
            {
              graph.getModel().beginUpdate();
              mxGraphStructure.makeTreeDirected(aGraph, startVertex);
              graph.getModel().endUpdate();
              graph.getModel().beginUpdate();
              mxCompactTreeLayout layout = new mxCompactTreeLayout(graph);
              layout.setHorizontal(false);
              layout.execute(graph.getDefaultParent());
              graph.getModel().endUpdate();
            }
            catch (StructuralException e1)
            {
              System.out.println(e1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.