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


Java Layout.setSize方法代碼示例

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


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

示例1: getServer

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * @param args the command line arguments
 * @return
 */
public VisualizationImageServer<Integer, String> getServer() {
    // Layout<V, E>, VisualizationComponent<V,E>
    Layout<Integer, String> layout = new CircleLayout<>(
            this);
    layout.setSize(new Dimension(300, 300));
    VisualizationImageServer<Integer, String> vv = new VisualizationImageServer<>(
            layout, new Dimension(350, 350));
    // Setup up a new vertex to paint transformer...
    // Set up a new stroke Transformer for the edges
    float dash[] = {10.0f};
    final Stroke edgeStroke = new BasicStroke(1.0f,
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
            0.0f);
    vv.getRenderContext().setVertexFillPaintTransformer(i -> Color.GREEN);
    vv.getRenderContext().setEdgeStrokeTransformer(
            s -> edgeStroke);
    vv.getRenderContext().setVertexLabelTransformer(
            new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(
            new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer()
            .setPosition(Position.CNTR);

    return vv;
}
 
開發者ID:mstahv,項目名稱:svgexamples,代碼行數:30,代碼來源:JungExample.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: main

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public static void main(String [] args) {
	ProcletModel pmodel = new ProcletModel("visit");
	pmodel.buildFromDB();
	pmodel.persistProcletModel();
	ProcletBlock block1 = new ProcletBlock("b1",BlockType.PI,false,5);
	ProcletBlock block2 = new ProcletBlock("b2",BlockType.PI,false,5);
	pmodel.addBlock(block1);
	pmodel.addBlock(block2);
	ProcletPort port = new ProcletPort("p1",Direction.OUT,Signature.ONE,Signature.ONE);
	ProcletPort port2 = new ProcletPort("p2",Direction.OUT,Signature.ONE,Signature.ONE);
	pmodel.addProcletPort(port, block1);
	pmodel.addProcletPort(port2, block1);
	pmodel.getBlocks();
	pmodel.getPortsBlock(block1);
	// visualization
	Layout layout = new CircleLayout(pmodel);
	layout.setSize(new Dimension(300,300));
	BasicVisualizationServer vv = new BasicVisualizationServer(layout);
	vv.setPreferredSize(new Dimension(350,350));
	
	JFrame frame = new JFrame("simple");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(vv);
	frame.pack();
	frame.setVisible(true);
}
 
開發者ID:yawlfoundation,項目名稱:yawl,代碼行數:27,代碼來源:ProcletModel.java

示例4: main

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public static void main(String [] args) {
	JOptionPane.showMessageDialog(null,
		    "Block already exists!",
		    "Error",
		    JOptionPane.ERROR_MESSAGE);
	InteractionGraphs igraphs = InteractionGraphs.getInstance();
	igraphs.buildFromDB();
	InteractionGraph graph = igraphs.getGraph(new EntityMID("test"));
	Layout<Integer,String> layout = new CircleLayout(graph);
	layout.setSize(new Dimension(300,300));
	BasicVisualizationServer<Integer,String> vv = new BasicVisualizationServer<Integer,String>(layout);
	vv.setPreferredSize(new Dimension(350,350));
	vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	JFrame frame = new JFrame("simple");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(vv);
	frame.pack();
	frame.setVisible(true);
	System.out.println("done");
}
 
開發者ID:yawlfoundation,項目名稱:yawl,代碼行數:21,代碼來源:InteractionGraphs.java

示例5: main

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public static void main(String[] args) {
    File f = new File( "./data/DSPM_01.graphml" );
    
    SimpleGraphView sgv = new SimpleGraphView( f ); //We create our graph in here
    // The Layout<V, E> is parameterized by the vertex and edge types
    Layout<Integer, String> layout = new CircleLayout(sgv.g);
    layout.setSize(new Dimension(300,300)); // sets the initial size of the layout space
    // The BasicVisualizationServer<V,E> is parameterized by the vertex and edge types
    BasicVisualizationServer<Integer,String> vv = new BasicVisualizationServer<Integer,String>(layout);
    vv.setPreferredSize(new Dimension(350,350)); //Sets the viewing area size
    
    JFrame frame = new JFrame("Simple Graph View");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv); 
    frame.pack();
    frame.setVisible(true);       
}
 
開發者ID:kamir,項目名稱:MorphMiner,代碼行數:18,代碼來源:SimpleGraphView.java

示例6: GraphRenderer

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * Full constructor
 * 
 * @param graph
 *            The graph to render
 * @param layout
 *            The layout to use
 */
public GraphRenderer(Graph<V, E> graph, Layout<V, E> layout) {
	this.graph = graph;
	this.setBackground(Color.WHITE);
	layout.setSize(new Dimension(1680, 1050));

	final VisualizationViewer<V, E> viewer = new VisualizationViewer<V, E>(
			layout);
	viewer.setBackground(Color.WHITE);
	viewer.getRenderContext().setVertexDrawPaintTransformer(
			new BlackVertexDrawPaintFunction<V>());
	viewer.getRenderContext().setVertexFillPaintTransformer(
			new HighlightingVertexFillPaintFunction<V>());
	viewer.getRenderContext().setEdgeDrawPaintTransformer(
			new HighlightingEdgePaintFunction());
	viewer.getRenderContext().setEdgeStrokeTransformer(
			new HighlightingEdgeStrokeFunction());
	viewer.getRenderContext().setVertexLabelTransformer(
			new ToStringLabeller<V>());
	viewer.setGraphMouse(new DefaultModalGraphMouse<V, E>());

	this.setLayout(new BorderLayout());
	this.add(viewer, BorderLayout.CENTER);
}
 
開發者ID:markuskorbel,項目名稱:adt.reference,代碼行數:32,代碼來源:GraphRenderer.java

示例7: 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

示例8: 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

示例9: 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

示例10: plot

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void plot() {
		BNplot sgv = this; //We create our graph in here
		// The Layout<V, E> is parameterized by the vertex and edge types
		//		Layout<Integer, String> layout = new CircleLayout(sgv.g);
		//		Layout<String, String> layout = new ISOMLayout<String, String>(sgv.g);

		Layout<String, String> layout = new KKLayout<String, String>(sgv.g);

		layout.setSize(new Dimension(600,600)); // sets the initial size of the layout space
		// The BasicVisualizationServer<V,E> is parameterized by the vertex and edge types
		BasicVisualizationServer<String,String> vv = new BasicVisualizationServer<String,String>(layout);
		vv_global=vv;
		vv.setPreferredSize(new Dimension(650,650)); //Sets the viewing area size
//		vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		vv.setBackground(Color.white);

		//		vv.getRenderContext().setVertexShapeTransformer(vertexShape);

		JFrame frame = new JFrame("Behavior Network Graph View");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(vv); 
		frame.pack();
		frame.setVisible(true);       

//		vv.getRenderContext().setVertexFillPaintTransformer(vertexColor);

	}
 
開發者ID:CST-Group,項目名稱:cst,代碼行數:28,代碼來源:BNplot.java

示例11: 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

示例12: paintGraph

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
private void paintGraph(Collection<Planet> planets) {
	planetsInGraph = new HashMap<String, Planet>();
	graph = new SparseMultigraph<Planet, String>();

	for (Planet planet : planets) {
		graph.addVertex(planet);
		planetsInGraph.put(planet.getId(), planet);
	}

	paintEdges();
	locationTransformer = new LocationTransformer(
			Collections.unmodifiableCollection(planets), vm.getGameType());
	final Layout<Planet, String> layout = new StaticLayout<Planet, String>(graph,
			locationTransformer);
	layout.setSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));

	vv = new VisualizationViewer<Planet, String>(layout);
	vv.setPreferredSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));
	vv.setRenderer(new UglyHuckRenderer());
	vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
	vv.getRenderContext().setVertexShapeTransformer(vertexSize);
	// vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
	vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);

	vv.getRenderer().getVertexLabelRenderer()
			.setPosition(Renderer.VertexLabel.Position.CNTR);

	vv.getRenderContext().setEdgeShapeTransformer(
			new EdgeShape.Line<Planet, String>());			

	this.add(vv);
	updateUI();
	// this.validate();
	this.repaint();
}
 
開發者ID:burningrain,項目名稱:planetBot,代碼行數:39,代碼來源:GraphWidget.java

示例13: visualizeNetworkGraph

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public static JFrame visualizeNetworkGraph(Graph<NetworkVertex, NetworkEdge> graph) {
    Layout<NetworkVertex, NetworkEdge> layout = new ISOMLayout<>(graph);

    layout.setSize(new Dimension(600, 600));
    BasicVisualizationServer<NetworkVertex, NetworkEdge> vv = new BasicVisualizationServer<>(layout);
    vv.setPreferredSize(new Dimension(700, 700));

    Transformer<NetworkVertex, Paint> vertexPaint = v -> {
        if (v instanceof Host) {
            Host host = (Host) v;
            return host.isFree() ? Color.GREEN : Color.RED;
        } else {
            return Color.GRAY;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

    Transformer<NetworkVertex, String> vertexLabel = v -> v.getId();
    vv.getRenderContext().setVertexLabelTransformer(vertexLabel);
    vv.getRenderer().getVertexLabelRenderer().setPosition(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position.AUTO);

    Transformer<NetworkEdge, String> edgeLabel = networkEdge -> networkEdge.getTailPort() + "->" + networkEdge.getHeadPort();
    vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);

    JFrame frame = new JFrame("Simple Graph View 2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    return frame;
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:31,代碼來源:StaticGraphUtils.java

示例14: 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

示例15: visualize

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void visualize(TinkerGraph graph) {
	GraphJung<TinkerGraph> graphJung = new GraphJung<TinkerGraph>(graph);
	Layout<Vertex, Edge> layout = new CircleLayout<Vertex, Edge>(graphJung);
	layout.setSize(new Dimension(400, 400));

	BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<Vertex, Edge>(
			layout);
	viz.setPreferredSize(new Dimension(550, 550));

	Transformer<Vertex, String> vertexLabelTransformer = new Transformer<Vertex, String>() {
		public String transform(Vertex vertex) {

			String vertexLabel = "";

			if (vertex
					.getProperty(NerdleGraphTransformer.PROPERTY_CLAUSE_TYPE) == NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE) {
				vertexLabel = ((String) vertex
						.getProperty(NerdleGraphTransformer.PROPERTY_VERBTEXT)
						+ " { " + (String) vertex
							.getProperty(NerdleGraphTransformer.PROPERTY_CLAUSE_TYPE))
						+ " } "
						+ vertex.getProperty(NerdleGraphTransformer.PROPERTY_SENTENCE);
			} else {
				vertexLabel = ((String) vertex
						.getProperty(NerdleGraphTransformer.PROPERTY_TEXT)
						+ " { " + (String) vertex
							.getProperty(NerdleGraphTransformer.PROPERTY_NER))
						+ ", "
						+ vertex.getProperty(NerdleGraphTransformer.PROPERTY_CLAUSE_TYPE)
						+ " } ";
			}

			return vertexLabel;
		}
	};

	Transformer<Edge, String> edgeLabelTransformer = new Transformer<Edge, String>() {
		public String transform(Edge edge) {
			return edge.getLabel();
		}
	};

	viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer);
	viz.getRenderContext()
			.setVertexLabelTransformer(vertexLabelTransformer);

	JFrame frame = new JFrame("Nerdle Graph Visualizer");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(viz);
	frame.pack();
	frame.setVisible(true);
}
 
開發者ID:impro3-nerdle,項目名稱:nerdle,代碼行數:53,代碼來源:JungGraphVisualizer.java


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