• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ListenableGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createAndShowGui

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
private static void createAndShowGui(double threshold, boolean showEdgeLabels) {

		JFrame frame = new JFrame("NewGraph");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		ListenableGraph<String, MyEdge> g = buildGraph(threshold, showEdgeLabels);
		JGraphXAdapter<String, MyEdge> graphAdapter = 
				new JGraphXAdapter<String, MyEdge>(g);

		mxIGraphLayout layout = new mxCircleLayout(graphAdapter);
		layout.execute(graphAdapter.getDefaultParent());

		frame.add(new mxGraphComponent(graphAdapter));

		frame.pack();
		frame.setLocationByPlatform(true);
		frame.setVisible(true);
	}
 
开发者ID:biojava,项目名称:biojava-spark,代码行数:19,代码来源:ShowGraph.java


示例2: JGraphXAdapter

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Ctor: 	Generates an adapter between a GraphT as data model and a mxGraph for
 * 			visualization.
 * @param graphT	The listenable JGraphT that acts as data model
 */
public JGraphXAdapter(final ListenableGraph<V, E> graphT) {
	super();
	setDataSource(graphT);
	Map<String, Object> vS = getStylesheet().getDefaultVertexStyle();
	Map<String, Object> eS = getStylesheet().getDefaultEdgeStyle();
	
	if(Utility.presentationMode) {
		vS.put(mxConstants.STYLE_FONTSIZE, 16);
		vS.put(mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_BOLD);
	}
	vS.put(mxConstants.STYLE_FILLCOLOR, "FFFFFF");
	vS.put(mxConstants.STYLE_FONTCOLOR, "000000");
	
	eS.put(mxConstants.STYLE_NOLABEL, 1);
}
 
开发者ID:Angerona,项目名称:angerona-framework,代码行数:21,代码来源:JGraphXAdapter.java


示例3: buildGraph

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
public static ListenableGraph<String, MyEdge> buildGraph(double threshold, boolean showEdgeLabels) {

		ListenableDirectedWeightedGraph<String, MyEdge> g = 
				new ListenableDirectedWeightedGraph<String, MyEdge>(MyEdge.class);

		Graph<Integer, DefaultWeightedEdge> inGraph = getGraph();		
		Set<DefaultWeightedEdge> edgeSet = inGraph.edgeSet();

		for (DefaultWeightedEdge e : edgeSet) {

			int sourceV = inGraph.getEdgeSource(e);
			String v1 = names[sourceV];

			int targetV = inGraph.getEdgeTarget(e);
			String v2 = names[targetV];

			g.addVertex(v1);
			g.addVertex(v2);

			double w = inGraph.getEdgeWeight(e);
			if(w>threshold) {
				MyEdge edge = g.addEdge(v1, v2);
				if(showEdgeLabels){
					g.setEdgeWeight(edge, w);
				}
			}

		}

		return g;
	}
 
开发者ID:biojava,项目名称:biojava-spark,代码行数:32,代码来源:ShowGraph.java


示例4: init

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void init()
{
    // create a JGraphT graph
    ListenableGraph<String, DefaultEdge> g =
        new ListenableDirectedMultigraph<String, DefaultEdge>(
            DefaultEdge.class);

    // create a visualization using JGraph, via an adapter
    jgAdapter = new JGraphModelAdapter<String, DefaultEdge>(g);

    JGraph jgraph = new JGraph(jgAdapter);

    this.add(jgraph);
    resize(DEFAULT_SIZE);

    String v1 = "v1";
    String v2 = "v2";
    String v3 = "v3";
    String v4 = "v4";

    // add some sample data (graph manipulated via JGraphT)
    g.addVertex(v1);
    g.addVertex(v2);
    g.addVertex(v3);
    g.addVertex(v4);

    g.addEdge(v1, v2);
    g.addEdge(v2, v3);
    g.addEdge(v3, v1);
    g.addEdge(v4, v3);

    // position vertices nicely within JGraph component
    positionVertexAt(v1, 130, 40);
    positionVertexAt(v2, 60, 200);
    positionVertexAt(v3, 310, 230);
    positionVertexAt(v4, 380, 70);

    // that's all there is to it!...
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:43,代码来源:DrawPanel_old.java


示例5: createAndShowGui

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
private static <X,Y> void createAndShowGui(String title, ListenableGraph<X,Y> dw) {
    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    Map<String, Object> edgeStyle = new HashMap<String, Object>();
 
    edgeStyle.put(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL);
 edgeStyle.put(mxConstants.STYLE_SHAPE,    mxConstants.SHAPE_CONNECTOR);
 edgeStyle.put(mxConstants.STYLE_ENDARROW, mxConstants.ARROW_CLASSIC);
 edgeStyle.put(mxConstants.STYLE_STROKECOLOR, "#000000");
 edgeStyle.put(mxConstants.STYLE_FONTCOLOR, "#000000");
 edgeStyle.put(mxConstants.STYLE_NOLABEL, true);
 
 mxStylesheet stylesheet = new mxStylesheet();
  	stylesheet.setDefaultEdgeStyle(edgeStyle);
    
    JGraphXAdapter<X, Y> graphAdapter = new JGraphXAdapter<X, Y>(dw);
    graphAdapter.setStylesheet(stylesheet);
    mxCompactTreeLayout layout = new mxCompactTreeLayout(graphAdapter);
    layout.setNodeDistance(30);
    layout.setLevelDistance(60);
    layout.execute(graphAdapter.getDefaultParent());

    frame.add(new mxGraphComponent(graphAdapter));
    frame.pack();
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
}
 
开发者ID:everling,项目名称:PRECISE,代码行数:30,代码来源:MatchVisualizer.java


示例6: visualize

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Visualize a graph
 * @param title
 * @param dw
 */
public static void visualize(final String title,final ListenableGraph<Node,DefaultWeightedEdge> dw){
	 SwingUtilities.invokeLater(new Runnable() {
         public void run() {
             createAndShowGui(title,dw);
         }
     });
}
 
开发者ID:everling,项目名称:PRECISE,代码行数:13,代码来源:MatchVisualizer.java


示例7: NetGraphAdapter

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
public NetGraphAdapter(ListenableGraph<Node, Line> graphT, ApplicationModel model) {
    super(graphT);
    conv = new NetItemConversionUtil();
    appModel = model;
    this.refresh();
    this.setHtmlLabels(true);
}
 
开发者ID:jub77,项目名称:grafikon,代码行数:8,代码来源:NetGraphAdapter.java


示例8: JGraphTAdapter

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
public JGraphTAdapter(final ListenableGraph<V, E> graphT) {
    super();
    this.setGridEnabled(false);
    this.graphT = graphT;
    graphT.addGraphListener(this);
    insertJGraphT(graphT);
}
 
开发者ID:jub77,项目名称:grafikon,代码行数:8,代码来源:JGraphTAdapter.java


示例9: loadTest

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Tests the JGraphXAdapter with 1.000 nodes and 1.000 edges.
 */
@Test
public void loadTest() 
{
    final int maxVertices = 1000;
    final int maxEdges = 1000;

    ListenableGraph<Integer, DefaultEdge> jGraphT 
        = new ListenableDirectedGraph<Integer, DefaultEdge>(
                    DefaultEdge.class);

    for (int i = 0; i < maxVertices; i++) {
        jGraphT.addVertex(i);
    }

    for (int i = 0; i < maxEdges; i++) {
        jGraphT.addEdge(i, (i + 1) % jGraphT.vertexSet().size());
    }

    JGraphXAdapter<Integer, DefaultEdge> graphX = null;

    try {
        graphX = new JGraphXAdapter<Integer, DefaultEdge>(jGraphT);
    } catch (Exception e) {
        fail("Unexpected error while creating JgraphXAdapter with"
                + maxVertices + " vertices and " + maxEdges + " Edges");
    }

    testMapping(graphX);

}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:34,代码来源:JGraphXAdapterTest.java


示例10: setDataSource

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
public void setDataSource(final ListenableGraph<V, E> graphT) {
	if(this.graphT != null) {
		this.graphT.removeGraphListener(this);
		clearmxGraph();
	}
	this.graphT = graphT;
	if(this.graphT != null) {
		graphT.addGraphListener(this);
		insertJGraphT(graphT);
	}
}
 
开发者ID:Angerona,项目名称:angerona-framework,代码行数:12,代码来源:JGraphXAdapter.java


示例11: getjGraph

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
@Override
public ListenableGraph<String, GKAEdge> getjGraph() {
	return jGraph;
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:5,代码来源:GKAGraph.java


示例12: genericTest

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Test scenarios under normal conditions.
 */
@Test
public void genericTest() 
{
    ListenableGraph<String, DefaultEdge> jGraphT 
     = new ListenableDirectedGraph<String, DefaultEdge>(DefaultEdge.class);

    // fill graph with data
    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    final int expectedEdges = 5;
    jGraphT.addEdge(v1, v2);
    jGraphT.addEdge(v1, v3);
    jGraphT.addEdge(v1, v4);
    jGraphT.addEdge(v2, v3);
    jGraphT.addEdge(v3, v4);

    // Create jgraphx graph and test it
    JGraphXAdapter<String, DefaultEdge> graphX = 
            new JGraphXAdapter<String, DefaultEdge>(jGraphT);
    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:51,代码来源:JGraphXAdapterTest.java


示例13: listenerTest

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Tests the correct implementation of the GraphListener interface.
 */
@Test
public void listenerTest() 
{
    ListenableGraph<String, String> jGraphT 
        = new ListenableDirectedGraph<String, String>(String.class);
    
    JGraphXAdapter<String, String> graphX 
        = new JGraphXAdapter<String, String>(jGraphT);
    
    // add some data to the jgrapht graph - changes should be propagated
    // through jgraphxadapters graphlistener interface

    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    jGraphT.addEdge(v1, v2, "Edge 1");
    jGraphT.addEdge(v1, v3, "Edge 2");
    jGraphT.addEdge(v1, v4, "Edge 3");
    jGraphT.addEdge(v2, v3, "Edge 4");
    jGraphT.addEdge(v3, v4, "Edge 5");
    
    int expectedEdges = jGraphT.edgeSet().size();

    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    
    // remove some data from the jgraphT graph
   jGraphT.removeVertex(v4);
   jGraphT.removeVertex(v3);
   
   jGraphT.removeEdge(v1, v2);
   
   int expectedEdgesAfterRemove = jGraphT.edgeSet().size();
   
    // test if all values are in the jgraphx graph
    expectedArray = new Object[] {v1, v2};
    Arrays.sort(expectedArray);
    
    realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdgesAfterRemove, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdgesAfterRemove, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:81,代码来源:JGraphXAdapterTest.java


示例14: duplicateEntriesTest

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
/**
 * Test if duplicate Entries are saved only once.
 */
@Test
public void duplicateEntriesTest() 
{
    ListenableGraph<String, DefaultEdge> jGraphT 
     = new ListenableDirectedGraph<String, DefaultEdge>(DefaultEdge.class);
    
    JGraphXAdapter<String, DefaultEdge> graphX = 
            new JGraphXAdapter<String, DefaultEdge>(jGraphT);

    // fill graph with data
    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";
    DefaultEdge edge1 = new DefaultEdge();

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);
    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    /*
     * edge1 is added 3 times with different source/target vertices it
     * should only add it once. A new edge is added with source-target
     * combination already in the graph it should not be added to the graph.
     */
    final int expectedEdges = 3;
    jGraphT.addEdge(v1, v2, edge1);
    jGraphT.addEdge(v1, v2, new DefaultEdge());
    jGraphT.addEdge(v1, v3, edge1);
    jGraphT.addEdge(v1, v4, edge1);
    jGraphT.addEdge(v2, v3);
    jGraphT.addEdge(v3, v4);

    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:62,代码来源:JGraphXAdapterTest.java


示例15: getjGraph

import org.jgrapht.ListenableGraph; //导入依赖的package包/类
public abstract ListenableGraph<String, GKAEdge> getjGraph(); 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:2,代码来源:GKAGraphInterface.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Position类代码示例发布时间:2022-05-23
下一篇:
Java XSAttributeUseImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap