当前位置: 首页>>代码示例>>Java>>正文


Java SpringLayout类代码示例

本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.SpringLayout的典型用法代码示例。如果您正苦于以下问题:Java SpringLayout类的具体用法?Java SpringLayout怎么用?Java SpringLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SpringLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了SpringLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildJungLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
@Override
protected Layout<GraphNode,GraphEdge> buildJungLayout(
        DirectedGraph<GraphNode, GraphEdge> jungGraph,
        Dimension layoutSize) {
  SpringLayout<GraphNode, GraphEdge> result =
          new SpringLayout<GraphNode, GraphEdge>(jungGraph);
  result.setSize(layoutSize);
  if (force.isSet()) {
    result.setForceMultiplier(force.getValue());
  }
  if (range.isSet()) {
    result.setRepulsionRange(range.getValue());
  }
  if (stretch.isSet()) {
    result.setStretch(stretch.getValue());
  }
  return result;
}
 
开发者ID:google,项目名称:depan,代码行数:19,代码来源:JungLayoutPlan.java

示例2: getLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
private static AbstractLayout<Vertex, Edge> getLayout(GraphJung<Graph> graph, String layoutName) {
  switch (layoutName) {
    case "KKLayout":
      return new KKLayout<>(graph);
    case "CircleLayout":
      return new CircleLayout<>(graph);
    case "FRLayout":
      return new FRLayout<>(graph);
    case "FRLayout2":
      return new FRLayout2<>(graph);
    case "ISOMLayout":
      return new ISOMLayout<>(graph);
    case "SpringLayout":
      return new SpringLayout<>(graph);
    default:
      return new KKLayout<>(graph);
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:19,代码来源:ImageWriter.java

示例3: doSpringLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
private void doSpringLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, int repulsion) {
	SpringLayout<VertexRef, EdgeRef> layout = new SpringLayout<VertexRef, EdgeRef>(jungGraph);
	layout.setInitializer(initializer(graphLayout));
	
	layout.setSize(size);
	layout.setRepulsionRange(repulsion);

	int count = 0;
	while(!layout.done() && count < 700) {
		layout.step();
		count++;
	}
	
	for(VertexRef v : jungGraph.getVertices()) {
		graphLayout.setLocation(v, (int)layout.getX(v), (int)layout.getY(v));
	}
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:RealUltimateLayoutAlgorithm.java

示例4: newLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
private Layout<Node, Edge> newLayout(final Diagram diagram) {
    final Layout<Node, Edge> diagramLayout;
    if (layout != null && layout.startsWith("spring")) {
        diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100"))));
    } else if (layout != null && layout.startsWith("kk")) {
        Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram);
        if (layout.endsWith("unweight")) {
            distance = new UnweightedShortestPath<Node, Edge>(diagram);
        }
        diagramLayout = new KKLayout<Node, Edge>(diagram, distance);
    } else if (layout != null && layout.equalsIgnoreCase("circle")) {
        diagramLayout = new CircleLayout<Node, Edge>(diagram);
    } else if (layout != null && layout.equalsIgnoreCase("fr")) {
        diagramLayout = new FRLayout<Node, Edge>(diagram);
    } else {
        final LevelLayout levelLayout = new LevelLayout(diagram);
        levelLayout.adjust = adjust;

        diagramLayout = levelLayout;
    }
    return diagramLayout;
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:23,代码来源:DiagramGenerator.java

示例5: getCombos

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
/**
 * @return
 */
@SuppressWarnings("unchecked")
private Class<? extends Layout>[] getCombos()
{
    List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
    layouts.add(KKLayout.class);
    layouts.add(FRLayout.class);
    layouts.add(CircleLayout.class);
    layouts.add(SpringLayout.class);
    layouts.add(SpringLayout2.class);
    layouts.add(ISOMLayout.class);
    return layouts.toArray(new Class[0]);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:16,代码来源:VertexCollapseDemoWithLayouts.java

示例6: getCombos

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
/**
 * @return
 */
@SuppressWarnings("unchecked")
private static Class<? extends Layout>[] getCombos()
{
    List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
    layouts.add(KKLayout.class);
    layouts.add(FRLayout.class);
    layouts.add(CircleLayout.class);
    layouts.add(SpringLayout.class);
    layouts.add(SpringLayout2.class);
    layouts.add(ISOMLayout.class);
    return layouts.toArray(new Class[0]);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:16,代码来源:ShowLayouts.java

示例7: updateLayoutGraph

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
private void updateLayoutGraph()
{
    Layout<Vertex,Edge> newlayout = null;
    if(((String)layoutChoiceComboBox.getSelectedItem()).equals("FRLayout"))
    {
        newlayout = new FRLayout<Vertex,Edge>(sequenceGraph);
        ((FRLayout<Vertex,Edge>)newlayout).setMaxIterations(200);
    }
    else if(((String)layoutChoiceComboBox.getSelectedItem()).equals("KKLayout"))
    {
        newlayout = new KKLayout<Vertex,Edge>(sequenceGraph);
        ((KKLayout<Vertex,Edge>)newlayout).setMaxIterations(200);
    }
    else if(((String)layoutChoiceComboBox.getSelectedItem()).equals("SpringLayout"))
    {
        newlayout = new SpringLayout<Vertex,Edge>(sequenceGraph);
    }
    else if(((String)layoutChoiceComboBox.getSelectedItem()).equals("ISOMLayout"))
    {
        newlayout = new ISOMLayout<Vertex,Edge>(sequenceGraph);
    }
    else
    {
        throw new Error("Error choice: wrong layout name");
    }
    newlayout.setInitializer(networkCanvas.getGraphLayout());
    newlayout.setSize(networkCanvas.getSize());
    
    LayoutTransition<Vertex,Edge> transition =
        new LayoutTransition<Vertex,Edge>(networkCanvas, networkCanvas.getGraphLayout(), newlayout);
    Animator animator = new Animator(transition);
    animator.start();
    
    networkCanvas.getRenderContext().getMultiLayerTransformer().setToIdentity(); // What is the use of those lines ?
    networkCanvas.repaint();
}
 
开发者ID:Conchylicultor,项目名称:NetworkVisualizer,代码行数:37,代码来源:VisualizerWindow.java

示例8: DependencyGraphScene

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
DependencyGraphScene(ObservableGraph<ArtifactGraphNode, ArtifactGraphEdge> graph, DelegateForest<ArtifactGraphNode, ArtifactGraphEdge> forest, MavenProject prj, Project nbProj, DependencyGraphTopComponent tc,
            POMModel model) {
        super(graph, new FRLayout<>(forest));
        layoutModel = new DefaultComboBoxModel<>();
        layoutModel.addElement(layout());
        // These rarely work but look nice when they do
//        layoutModel.addElement(new BalloonLayout<>(forest));
//        layoutModel.addElement(new RadialTreeLayout<>(forest));
        layoutModel.addElement(new CircleLayout<>(graph));
        layoutModel.addElement(new FRLayout<>(graph));
        layoutModel.addElement(new FRLayout2<>(graph));
        layoutModel.addElement(new KKLayout<>(graph));
        TreeLayout<ArtifactGraphNode, ArtifactGraphEdge> treeLayout = new TreeLayout<>(forest, 200, 90);
        layoutModel.addElement(treeLayout);
        layoutModel.addElement(new ISOMLayout<>(graph));
        layoutModel.addElement(new SpringLayout<>(graph));
        layoutModel.addElement(new SpringLayout2<>(graph));
        layoutModel.setSelectedItem(layout());

        moveAction = ActionFactory.createMoveAction(null, new MP());

        this.forest = forest;
        project = prj;
        nbProject = nbProj;
        this.tc = tc;
        this.model = model;
        mainLayer = new LayerWidget(this);
        addChild(mainLayer);
        connectionLayer = new LayerWidget(this);
        addChild(connectionLayer);
        //getActions().addAction(this.createObjectHoverAction());
        getActions().addAction(hoverAction);
        getActions().addAction(ActionFactory.createSelectAction(allActionsP));
        getActions().addAction(zoomAction);
        getActions().addAction(panAction);
        getActions().addAction(editAction);
        getActions().addAction(popupMenuAction);
        
        getActions().addAction(new ScrollWheelZoomAction());
    }
 
开发者ID:timboudreau,项目名称:vl-jung,代码行数:41,代码来源:DependencyGraphScene.java

示例9: TradeNetworkView

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
public TradeNetworkView(
		final TradeNetworkReport tradeNetwork) {
	
	this.tradeNetwork = tradeNetwork;
	myGraph = new DirectedSparseGraph<Agent, WeightedEdge>();
	layout = new SpringLayout<Agent, WeightedEdge>(myGraph);
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			intialiseGUI();
		}
	});
}
 
开发者ID:phelps-sg,项目名称:jasa,代码行数:13,代码来源:TradeNetworkView.java

示例10: LayoutSpring2D

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
public LayoutSpring2D(Graph2D graph){
	super(graph, false);

	mDimension = new Dimension(1000, 1000);
	mStretch = 0.7;
	mRepulsionRange = 100;
	mForceMultiplier = 1.0 / 3.0;

	mLayout = new SpringLayout<>(mGraph.getGraph(), mLengthFunction);
	mLayout.setStretch(mStretch);
	mLayout.setRepulsionRange(mRepulsionRange);
	mLayout.setForceMultiplier(mForceMultiplier);
	mLayout.setSize(mDimension);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:15,代码来源:LayoutSpring2D.java

示例11: createDefaultCombobox

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
public static CLayoutCombobox createDefaultCombobox() {
	CLayoutCombobox chooser = new CLayoutCombobox();
	chooser.addLayoutClass(KCircleLayout.class, "Circle");
	chooser.addLayoutClass(FRLayout.class, "Fruchterman-Reingold");
	chooser.addLayoutClass(KKLayout.class, "Kamada-Kawai");
	chooser.addLayoutClass(SpringLayout.class, "Spring");
	//chooser.addLayoutClass(SpringLayout2.class, "Spring2");
	//chooser.addLayoutClass(ISOMLayout.class, "Self-Organizing Map");
	return chooser;
}
 
开发者ID:macc704,项目名称:KBDeX,代码行数:11,代码来源:KGraphLayoutChooser.java

示例12: init

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
@Override
    public void init() {

        //create a graph
    	Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number,Number>());

        ObservableGraph<Number,Number> og = new ObservableGraph<Number,Number>(ig);
        og.addGraphEventListener(new GraphEventListener<Number,Number>() {

			public void handleGraphEvent(GraphEvent<Number, Number> evt) {
				System.err.println("got "+evt);

			}});
        
        this.g = og;
        //create a graphdraw
        layout = new FRLayout2<Number,Number>(g);
//        ((FRLayout)layout).setMaxIterations(200);

        vv = new VisualizationViewer<Number,Number>(layout, new Dimension(600,600));

        JRootPane rp = this.getRootPane();
        rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

        getContentPane().setLayout(new BorderLayout());
        getContentPane().setBackground(java.awt.Color.lightGray);
        getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));

        vv.getModel().getRelaxer().setSleepTime(500);
        vv.setGraphMouse(new DefaultModalGraphMouse<Number,Number>());

        vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
        vv.setForeground(Color.white);
        getContentPane().add(vv);
        switchLayout = new JButton("Switch to SpringLayout");
        switchLayout.addActionListener(new ActionListener() {

            @SuppressWarnings("unchecked")
            public void actionPerformed(ActionEvent ae) {
            	Dimension d = new Dimension(600,600);
                if (switchLayout.getText().indexOf("Spring") > 0) {
                    switchLayout.setText("Switch to FRLayout");
                    layout = new SpringLayout<Number,Number>(g,
                        new ConstantTransformer(EDGE_LENGTH));
                    layout.setSize(d);
                    vv.getModel().setGraphLayout(layout, d);
                } else {
                    switchLayout.setText("Switch to SpringLayout");
                    layout = new FRLayout<Number,Number>(g, d);
                    vv.getModel().setGraphLayout(layout, d);
                }
            }
        });

        getContentPane().add(switchLayout, BorderLayout.SOUTH);

        timer = new Timer();
    }
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:60,代码来源:AddNodeDemo.java

示例13: switchLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
public void switchLayout(GraphLayout type) {
	Layout<N, EdgeWrapper<E>> layout = null;

	switch (type) {
	case KKLayout:
		layout = new KKLayout<N, EdgeWrapper<E>>(graph);
		break;
	case FRLayout:
		layout = new FRLayout<N, EdgeWrapper<E>>(graph);
		break;
	case ISOMLayout:
		layout = new ISOMLayout<N, EdgeWrapper<E>>(graph);
		break;
	case SpringLayout:
		layout = new SpringLayout<N, EdgeWrapper<E>>(graph);
		break;
	case CircleLayout:
		layout = new CircleLayout<N, EdgeWrapper<E>>(graph);
		break;
	case FRLayout2:
		layout = new FRLayout2<N, EdgeWrapper<E>>(graph);
		break;
	case SpringLayout2:
		layout = new SpringLayout2<N, EdgeWrapper<E>>(graph);
		break;
	default:
		break;
	}

	if (graph.getVertexCount() < 100) {
		layout.setInitializer(vv.getGraphLayout());
		layout.setSize(getSize());
		LayoutTransition<N, EdgeWrapper<E>> lt = new LayoutTransition<N, EdgeWrapper<E>>(vv, vv.getGraphLayout(),
				layout);
		Animator animator = new Animator(lt);
		animator.start();
		vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
		repaint(500);
	} else {
		vv.setModel(new DefaultVisualizationModel<N, EdgeWrapper<E>>(layout));
		repaint(500);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:44,代码来源:JungVisualizationViewer.java

示例14: createLayout

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
private Layout createLayout(G graph, String layout, double repultion , double attraction, int maxIterations, double nodeDensity) {
        PersistentLayout test = null;
        if (layout.equals("CircleLayout")) {
            CircleLayout circleLayoutLayout = new CircleLayout<String, String>(graph);

            test = new MyPersistentLayoutImpl(circleLayoutLayout);
        } else if (layout.equals("KKLayout")) {
            KKLayout kkLayout = new KKLayout<String, String>(graph);
            kkLayout.setMaxIterations(maxIterations);

            test = new MyPersistentLayoutImpl(kkLayout);
        } else if (layout.equals("SpringLayout")) {
            test = new MyPersistentLayoutImpl(new SpringLayout<String, String>(graph));
        } else if (layout.equals("SpringLayout2")) {
            test = new MyPersistentLayoutImpl(new SpringLayout2<String, String>(graph));
        } else if (layout.equals("ISOMLayout")) {
            test = new MyPersistentLayoutImpl(new ISOMLayout<String, String>(graph));
        } else if (layout.equals("FRLayout2")) {
            FRLayout2 frLayout2 = new FRLayout2<String, String>(graph);
            frLayout2.setRepulsionMultiplier(10);

            test = new MyPersistentLayoutImpl(frLayout2);

        }
        else {
            FRLayout frLayout = new FRLayout<String, String>(graph);
            frLayout.setRepulsionMultiplier(repultion);
            frLayout.setAttractionMultiplier(attraction);
            frLayout.setMaxIterations(maxIterations);
            test = new MyPersistentLayoutImpl(frLayout);
        }

        int vertexCount = currentGraph.getVertexCount();
        Dimension parent1 = parent.getSize();
        int x = (int) (Math.sqrt(vertexCount / nodeDensity));
        int y = (int) (Math.sqrt(vertexCount / nodeDensity));
        if (x < parent1.width) {
            x = parent1.width - 50;
        } else {
            x = x * (parent1.width - 50) / 1000;
        }

        if (y < parent1.height) {
            y = parent1.height - 150;
        } else {
            y = y * (parent1.height - 150) / 1000;
        }
        if (parent1.height*parent1.width > Integer.MAX_VALUE){
            x=7680;
            y=4320;
        }
//        i

        System.out.println("X: " + x + "Y: " + y + "width: " + parent1.width + "heigth: " + parent1.height);
        test.setSize(new Dimension(new Dimension(x, y)));

        return test;
    }
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:59,代码来源:GraphViewerPanel.java

示例15: visualize

import edu.uci.ics.jung.algorithms.layout.SpringLayout; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void visualize(JungNetwork graph, String title, int type)
{
	// The Layout<V, E> is parameterized by the vertex and edge types 
	Layout<JungVertex, JungEdge> layout	= null;
	
	switch (type)
	{
		case CIRCLE:
			layout = new CircleLayout<JungVertex, JungEdge>(graph); 
			break;
			
		case SPRING:
			layout = new SpringLayout<JungVertex, JungEdge>(graph); 
			break;
			
		case FR:
			layout = new FRLayout<JungVertex, JungEdge>(graph); 
			break;
			
		case ISOM:
			layout = new ISOMLayout<JungVertex, JungEdge>(graph); 
			break;
			
		case DAG:
			layout = new DAGLayout<JungVertex, JungEdge>(graph);
			break;

		case SPRING2:
			layout = new SpringLayout2<JungVertex, JungEdge>(graph);
			break;
			
		default:
			layout = new KKLayout<JungVertex, JungEdge>(graph); 
	}
	
	layout.setSize(new Dimension(800,800)); // sets the initial size of the space 
	
	// The BasicVisualizationServer<V,E> is parameterized by the edge types 
	BasicVisualizationServer<JungVertex,JungEdge> vv = 
		new BasicVisualizationServer<JungVertex,JungEdge>(layout);
	
	vv.setPreferredSize(new Dimension(900,900)); //Sets the viewing area size  
	vv.scaleToLayout(new LayoutScalingControl() );
       vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); 
       vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());        
       vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); 
       
	JFrame frame = new JFrame(title); 
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
	frame.getContentPane().add(vv); 
	frame.pack(); 
	frame.setVisible(true); 
}
 
开发者ID:Rees-Brad,项目名称:FastEgoClustering,代码行数:55,代码来源:Visualize.java


注:本文中的edu.uci.ics.jung.algorithms.layout.SpringLayout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。