當前位置: 首頁>>代碼示例>>Java>>正文


Java Layout.setInitializer方法代碼示例

本文整理匯總了Java中edu.uci.ics.jung.algorithms.layout.Layout.setInitializer方法的典型用法代碼示例。如果您正苦於以下問題:Java Layout.setInitializer方法的具體用法?Java Layout.setInitializer怎麽用?Java Layout.setInitializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.uci.ics.jung.algorithms.layout.Layout的用法示例。


在下文中一共展示了Layout.setInitializer方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPrototypePreview

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
   * This method takes the GraphPrototype class name as string and creates a graph of the prototype and shows a preview in the visualizationViewer
   * @param graphPrototype
   */
  private void setPrototypePreview() {

  	String componentName = this.localComponentTypeListElement.getComponentName();
  	
  	// --- Create the graph of the NetworkComponent -------------
  	this.localNetworkModel = NetworkComponentFactory.getNetworkModel4NetworkComponent(this.graphController.getNetworkModel().getGeneralGraphSettings4MAS(), componentName, this.getVisualizationViewer().getSize());
  	this.localGraphElementPrototype = NetworkComponentFactory.getGraphElementPrototypeOfLastNetworkComponent();
if (this.localNetworkModel!=null && this.localGraphElementPrototype!=null) {

	// --- Set the graph to the layout ----------------------
   	Layout<GraphNode, GraphEdge> layout = new StaticLayout<GraphNode, GraphEdge>(this.localNetworkModel.getGraph());
	layout.setInitializer(new Transformer<GraphNode, Point2D>() {
		public Point2D transform(GraphNode node) {
			return node.getPosition(); 
		}
	});
	this.getVisualizationViewer().setGraphLayout(layout);
	this.getVisualizationViewer().repaint();
	
	// --- Pick first GraphNode --------------------
	this.pickFirstGraphNode();
    this.setSelectedGraphNode();
    
}
  }
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:30,代碼來源:AddComponentDialog.java

示例2: groupCluster

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
private void groupCluster(AggregateLayout<Number,Number> layout, Set<Number> vertices) {
	if(vertices.size() < layout.getGraph().getVertexCount()) {
		Point2D center = layout.transform(vertices.iterator().next());
		Graph<Number,Number> subGraph = SparseMultigraph.<Number,Number>getFactory().create();
		for(Number v : vertices) {
			subGraph.addVertex(v);
		}
		Layout<Number,Number> subLayout = 
			new CircleLayout<Number,Number>(subGraph);
		subLayout.setInitializer(vv.getGraphLayout());
		subLayout.setSize(new Dimension(40,40));

		layout.put(subLayout,center);
		vv.repaint();
	}
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:17,代碼來源:ClusteringDemo.java

示例3: actionPerformed

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent arg0)
        {
            Object[] constructorArgs =
                { collapsedGraph };

            Class<? extends Layout> layoutC = 
                (Class<? extends Layout>) jcb.getSelectedItem();
//            Class lay = layoutC;
            try
            {
                Constructor<? extends Layout> constructor = layoutC
                        .getConstructor(new Class[] {Graph.class});
                Object o = constructor.newInstance(constructorArgs);
                Layout l = (Layout) o;
                l.setInitializer(vv.getGraphLayout());
                l.setSize(vv.getSize());
                layout = l;
				LayoutTransition lt =
					new LayoutTransition(vv, vv.getGraphLayout(), l);
				Animator animator = new Animator(lt);
				animator.start();
				vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
				vv.repaint();
                
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:31,代碼來源:VertexCollapseDemoWithLayouts.java

示例4: actionPerformed

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent arg0)
        {
            Object[] constructorArgs =
                { g_array[graph_index]};

            Class<? extends Layout<Integer,Number>> layoutC = 
                (Class<? extends Layout<Integer,Number>>) jcb.getSelectedItem();
//            Class lay = layoutC;
            try
            {
                Constructor<? extends Layout<Integer, Number>> constructor = layoutC
                        .getConstructor(new Class[] {Graph.class});
                Object o = constructor.newInstance(constructorArgs);
                Layout<Integer,Number> l = (Layout<Integer,Number>) o;
                l.setInitializer(vv.getGraphLayout());
                l.setSize(vv.getSize());
                
				LayoutTransition<Integer,Number> lt =
					new LayoutTransition<Integer,Number>(vv, vv.getGraphLayout(), l);
				Animator animator = new Animator(lt);
				animator.start();
				vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
				vv.repaint();
                
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:31,代碼來源:ShowLayouts.java

示例5: groupCluster

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
private void groupCluster(AggregateLayout<NodeWrapper, EdgeWrapper> layout, Set<NodeWrapper> vertices,
		boolean circleClusters) {
	Point2D center = layout.transform(vertices.iterator().next());
	Graph<NodeWrapper, EdgeWrapper> subGraph = SparseMultigraph.<NodeWrapper, EdgeWrapper> getFactory().create();
	for (NodeWrapper v : vertices) {
		subGraph.addVertex(v);
	}
	Layout<NodeWrapper, EdgeWrapper> subLayout = null;

	if (circleClusters) {
		CircleLayout<NodeWrapper, EdgeWrapper> circleLayout = new CircleLayout<NodeWrapper, EdgeWrapper>(subGraph);
		circleLayout.setRadius(getGraph().getVertexCount() * 4);
		circleLayout.setSize(new Dimension(200, 400));
		circleLayout.setVertexOrder(new Comparator<NodeWrapper>() {

			@Override
			public int compare(NodeWrapper o1, NodeWrapper o2) {
				return o1.getId() < o2.getId() ? -1 : 1;
			}
		});
		subLayout = circleLayout;
	} else {
		subLayout = new KKLayout<NodeWrapper, EdgeWrapper>(subGraph);

		// UTIL: verificar o algoritmo e uso dessa classe: VoltageClusterer
		// subLayout = new VoltageClusterer<NodeWrapper,
		// EdgeWrapper>(subGraph, 2);
		// subLayout = new FRLayout2<NodeWrapper,
		// EdgeWrapper>(subGraph); //esse layout dá erro
	}
	subLayout.setInitializer(vv.getGraphLayout());
	subLayout.setSize(new Dimension((int) getSize().getWidth() / 2, (int) getSize().getHeight() / 2));

	layout.put(subLayout, center);
	vv.repaint();
}
 
開發者ID:rrocharoberto,項目名稱:GraphPartitionFramework,代碼行數:37,代碼來源:GraphPartitioningVisualization.java

示例6: updateLayoutGraph

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的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

示例7: rotateGraph

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * Rotates the current graph around itself.
 * @param rotateAngle the angle on which the graph should rotate 
 */
private void rotateGraph(double rotateAngle) {
	
	if (this.localNetworkModel!=null) {
		Graph<GraphNode, GraphEdge> graph = this.localNetworkModel.getGraph();
		if (graph!=null) {
			Vector<GraphNode> graphNodes = new Vector<GraphNode>(graph.getVertices());
			if (graphNodes.size()>1) {
				
    	    	double centerX = this.getVisualizationViewer().getCenter().getX();
    	    	double centerY = this.getVisualizationViewer().getCenter().getY();
    			
    			// --- Get all GraphNodes and rotate then around the center ---
    			for (GraphNode graphNode : graphNodes) {
    				
    				double newX = 0;
    				double newY = 0;
    				double oldX = graphNode.getPosition().getX() - centerX;
    				double oldY = graphNode.getPosition().getY() - centerY;
    				
    				double hypotenuse = Math.pow((Math.pow(oldX, 2) + Math.pow(oldY, 2)), 0.5);
    				hypotenuse = Math.round(hypotenuse*10)/10;
    				double oldAngle = Math.atan(oldY / oldX);
    				if (Double.isNaN(oldAngle)==false) {
    					if (oldX < 0 && oldY >= 0) {
        					oldAngle += Math.PI;
        				} else if (oldX < 0 && oldY < 0){
        					oldAngle += Math.PI;
        				}else if (oldX >= 0 && oldY < 0){
        					oldAngle += 2*Math.PI;
        				}
        				double newAngle = oldAngle + rotateAngle;
        				newX = Math.cos(newAngle) * hypotenuse;
        				newY = Math.sin(newAngle) * hypotenuse;
        				
    				}
    				Point2D newPosition = new Point2D.Double(centerX+newX, centerY+newY);
    				graphNode.setPosition(newPosition);
    				
    			}
    			
				Layout<GraphNode, GraphEdge> layout = new StaticLayout<GraphNode, GraphEdge>(graph);
				layout.setInitializer(new Transformer<GraphNode, Point2D>() {
					public Point2D transform(GraphNode node) {
						return node.getPosition(); // The position is specified in the GraphNode instance
					}
				});
				this.getVisualizationViewer().setGraphLayout(layout);
    			this.getVisualizationViewer().repaint();
    			
			}
		}
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:58,代碼來源:AddComponentDialog.java

示例8: switchLayout

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的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


注:本文中的edu.uci.ics.jung.algorithms.layout.Layout.setInitializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。