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


Java BasicVisualizationServer.setPreferredSize方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.BasicVisualizationServer.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java BasicVisualizationServer.setPreferredSize方法的具体用法?Java BasicVisualizationServer.setPreferredSize怎么用?Java BasicVisualizationServer.setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.BasicVisualizationServer的用法示例。


在下文中一共展示了BasicVisualizationServer.setPreferredSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testJUNG2

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的package包/类
@Test
public void testJUNG2() throws Exception {
	Graph<String, String> graph = new SparseMultigraph<String, String>();
	graph.addVertex("state 1");
	graph.addVertex("state 2");
	graph.addVertex("state 3");
	graph.addVertex("state 4");
	graph.addVertex("state 5");
	graph.addVertex("state 6");
	graph.addEdge("edge 1", "state 1", "state 2", EdgeType.DIRECTED);
	graph.addEdge("edge 2", "state 1", "state 3", EdgeType.DIRECTED);
	graph.addEdge("edge 3", "state 1", "state 4", EdgeType.DIRECTED);
	graph.addEdge("edge 4", "state 3", "state 4", EdgeType.DIRECTED);

	CircleLayout<String, String> layout = new CircleLayout<String, String>(graph);
	layout.setSize(new Dimension(300, 300));

	BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<String, String>(layout);
	visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
	visualization.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
	visualization.setPreferredSize(new Dimension(350, 350));

	JOptionPane.showMessageDialog(null, visualization);
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:25,代码来源:JGraphTest.java

示例2: main

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例3: main

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例4: run

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的package包/类
/**
 * This method runs the necessary calls to generate a JUNG visualizer with a GEXF file.
 * Uses a graph from <code>GexfReader(String filename)</code> and Transformers from <code>org.iqt.gexf2jung.transformers</code> to make a <code>BasicVisualizationServer</code>.
 * @param filename This must be acceptable by the constructor <code>File(filename)</code>
 * @param width The width of the window
 * @param height The height of the window
 * @param x the X coordinate of the window's position
 * @param y the Y coordinate of the window's position
 * @throws ParserConfigurationException see <code>GexfReader.read(String filename)</code>
 * @throws SAXException see <code>GexfReader.read(String filename)</code>
 * @throws IOException Called if the filename is not valid.
 * @see GexfReader
 */
public static void run(String filename, int width, int height, int x, int y) throws ParserConfigurationException, SAXException, IOException{
    Graph<Node, Edge> g = GexfReader.read(filename);
    Layout<Node, Edge> layout = new CircleLayout<Node, Edge>(g);
    layout.setSize(new Dimension(width, height)); // sets the initial size of the space
    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    BasicVisualizationServer<Node, Edge> vv
            = new BasicVisualizationServer<Node, Edge>(layout);
    vv.setPreferredSize(new Dimension(width, height)); //Sets the viewing area size
    vv.getRenderContext().setVertexFillPaintTransformer(new GexfNodePaintTransformer());
    vv.getRenderContext().setVertexShapeTransformer(new GexfNodeShapeTransformer());
    vv.getRenderContext().setEdgeStrokeTransformer(new GexfEdgeStrokeTransformer());
    vv.getRenderContext().setVertexLabelTransformer(new GexfNodeLabelTransformer());
    vv.getRenderContext().setEdgeLabelTransformer(new GexfEdgeLabelTransformer());
    vv.getRenderContext().setEdgeDrawPaintTransformer(new GexfEdgePaintTransformer());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.AUTO);

    JFrame frame = new JFrame("Graph View");
    frame.setLocation(x, y);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:ave4224,项目名称:gexf2jung,代码行数:37,代码来源:App.java

示例5: GraphPanel

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的package包/类
public GraphPanel(DirectedSparseMultigraph<V, E> graph) {
  // this.setLayout(new FlowLayout());
  DirectedSparseMultigraph<V, E> graphTemp = new DirectedSparseMultigraph<V, E>();
  for (V vertex : graph.getVertices()) {
    if (graph.inDegree(vertex) > 0 || graph.outDegree(vertex) > 0) {
      graphTemp.addVertex(vertex);
    }
  }
  for (E edge : graph.getEdges()) {
    if (graphTemp.containsVertex(graph.getSource(edge))
        && graphTemp.containsVertex(graph.getDest(edge))) {
      graphTemp.addEdge(edge, graph.getSource(edge), graph.getDest(edge));
    }
  }
  this.graph = graphTemp;
  layout = new KKLayout<V, E>(this.graph);
  layout.setSize(new Dimension(1000, 800)); // sets the initial size of the
                                            // space
  // The BasicVisualizationServer<V,E> is parameterized by the edge types
  BasicVisualizationServer<V, E> server = new BasicVisualizationServer<V, E>(
      layout);
  server.setPreferredSize(new Dimension(1000, 800));
  this.add(server);

}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:26,代码来源:GraphPanel.java

示例6: writeTo

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的package包/类
@Override
public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
    MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException {
  Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH));
  Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT));
  String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT);

  GraphJung<Graph> graph = new GraphJung<Graph>(data);
  AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName);
  layout.setSize(new Dimension(width, height));

  BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout);
  viz.setPreferredSize(new Dimension(width, height));
  viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer);
  viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
  viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer);

  BufferedImage bi = renderImage(viz);
  String imageType = null;
  if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) {
    imageType = "jpg";
  } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) {
    imageType = "png";
  }
  ImageIO.write(bi, imageType, out);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:27,代码来源:ImageWriter.java

示例7: main

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例8: plot

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例9: visualizeNetworkGraph

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例10: visualize

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例11: visualize

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的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

示例12: main

import edu.uci.ics.jung.visualization.BasicVisualizationServer; //导入方法依赖的package包/类
/**
	 * @param args
	 */
	public static void main(String[] args) {
		test();
		
		DirectedSparseMultigraph<String,String> dGraph = new DirectedSparseMultigraph<String, String>();;
		
//		SimpleGraphView sgv = new SimpleGraphView(); //We create our graph in here
		// The Layout<V, E> is parameterized by the vertex and edge types
		
		
		
		//Layout<Integer, String> layout = new CircleLayout<Integer,String>(g);
		
		
		Layout<String, String> layout = new KKLayout(g);
		layout.setSize(new Dimension(300,300)); // sets the initial size of the space
		 // The BasicVisualizationServer<V,E> is parameterized by the edge types
		 BasicVisualizationServer<String,String> vv =
		          new BasicVisualizationServer<String,String>(layout); 
		 
		 
		 
		 vv.setPreferredSize(new Dimension(350,350)); //Sets the viewing area size
		
		 
		 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		 

		 
		 JFrame frame = new JFrame("Simple Graph View");
		 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 frame.getContentPane().add(vv);
		

		 frame.pack();
		 frame.setVisible(true);
		 
		
		 frame.pack();
	//	
//		 g.addVertex((Integer)5);
//		 
//		 //layout.reset();
//		 
//		 Thread.sleep(2000);
//		 
	//g.addVertex((Integer)6);
//		frame.repaint(); 
	// //layout.reset();
//		 
	//g.addVertex((Integer)8);
		 
		// layout.reset();

	}
 
开发者ID:ag-csw,项目名称:SVoNt,代码行数:58,代码来源:JungTest.java


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