本文整理汇总了Java中org.jgrapht.ext.JGraphXAdapter类的典型用法代码示例。如果您正苦于以下问题:Java JGraphXAdapter类的具体用法?Java JGraphXAdapter怎么用?Java JGraphXAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JGraphXAdapter类属于org.jgrapht.ext包,在下文中一共展示了JGraphXAdapter类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createAndShowGui
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的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: GKAGraph
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
private GKAGraph(GraphType type){
this.type = type;
// Choose if it will be directed or undirected
if (isDirected()){
jGraph = new ListenableDirectedGraph<>(new DirectedPseudograph<>(GKAEdge.class));
}else{
jGraph = new ListenableUndirectedGraph<>(new Pseudograph<>(GKAEdge.class));
}
// JGXAdapter for showing the Graph in Swing
mxgraph = new JGraphXAdapter<>(getjGraph());
// Changing EdgeStyle when is undirected
if (!isDirected()){
getMxgraph().getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "none");
}
setGraphConfig();
}
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:20,代码来源:GKAGraph.java
示例3: createCFG
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
public void createCFG() {
ProgramASTNode progNode = new ProgramASTNode(roots.toArray(new ASTNode[0]));
CFG cfg = progNode.createCFG();
JGraphXAdapter jgxAdapter = new JGraphXAdapter(cfg.getGraph());
jgxAdapter.setAutoSizeCells(true);
jgxAdapter.setCellsResizable(true);
// jgxAdapter.alignCells(mxConstants.ALIGN_CENTER);
mxStylesheet stylesheet = jgxAdapter.getStylesheet();
Hashtable<String, Object> style = new Hashtable<String, Object>();
style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_RECTANGLE);
style.put(mxConstants.STYLE_OPACITY, 50);
style.put(mxConstants.STYLE_FONTCOLOR, "#774400");
stylesheet.putCellStyle("ROUNDED", style);
jgxAdapter.setStylesheet(stylesheet);
jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter);
graphComponent.setWheelScrollingEnabled(false);
mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel();
cfgPane.add(graphComponent);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapter);
layout.execute(jgxAdapter.getDefaultParent());
this.addMouseWheelListener(e -> {
mxGraphView view = graphComponent.getGraph().getView();
int notches = e.getWheelRotation();
double scale = view.getScale();
double newScale = view.getScale() - ((double) notches / 61.8033988272);
view.setScale(newScale);
});
cfgPane.revalidate();
cfgPane.repaint();
}
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:37,代码来源:DSLPanel.java
示例4: createAST
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
public void createAST() {
Logger.getAnonymousLogger().info(" Graph: " + graph);
ProgramASTNode progNode = new ProgramASTNode(roots.toArray(new ASTNode[0]));
JGraphXAdapter jgxAdapter = new JGraphXAdapter(progNode.getAST());
jgxAdapter.setAutoSizeCells(true);
jgxAdapter.setCellsResizable(true);
// jgxAdapter.alignCells(mxConstants.ALIGN_CENTER);
mxStylesheet stylesheet = jgxAdapter.getStylesheet();
Hashtable<String, Object> style = new Hashtable<String, Object>();
style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_RECTANGLE);
style.put(mxConstants.STYLE_OPACITY, 50);
style.put(mxConstants.STYLE_FONTCOLOR, "#774400");
stylesheet.putCellStyle("ROUNDED", style);
jgxAdapter.setStylesheet(stylesheet);
jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter);
graphComponent.setWheelScrollingEnabled(false);
mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel();
astPane.add(graphComponent);
mxGraphLayout layout = new mxCompactTreeLayout(jgxAdapter, false);
layout.execute(jgxAdapter.getDefaultParent());
this.addMouseWheelListener(e -> {
mxGraphView view = graphComponent.getGraph().getView();
int notches = e.getWheelRotation();
double scale = view.getScale();
double newScale = view.getScale() - ((double) notches / 61.8033988272);
view.setScale(newScale);
System.out.println(scale + " -> " + newScale);
});
astPane.revalidate();
astPane.repaint();
}
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:38,代码来源:DSLPanel.java
示例5: createAndShowGui
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的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: saveGraph
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
private void saveGraph(UndirectedGraph<TupleWithTable, DefaultEdge> instancesGraph) {
JGraphXAdapter<TupleWithTable, DefaultEdge> jgxAdapterContext = new JGraphXAdapter<TupleWithTable, DefaultEdge>(instancesGraph);
jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "0");
jgxAdapterContext.setCellsEditable(false);
jgxAdapterContext.setCellsMovable(false);
jgxAdapterContext.setEdgeLabelsMovable(false);
jgxAdapterContext.setCellsDeletable(false);
jgxAdapterContext.setCellsDisconnectable(false);
jgxAdapterContext.setCellsResizable(false);
jgxAdapterContext.setCellsBendable(false);
JFrame frame = new JFrame();
mxGraphComponent mxGraphComponent = new mxGraphComponent(jgxAdapterContext);
frame.getContentPane().add(mxGraphComponent, BorderLayout.CENTER);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapterContext);
layout.execute(jgxAdapterContext.getDefaultParent());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Graph");
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
try {
while (true) {
Thread.sleep(500);
}
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(ComputeInstanceSimilarityBlock.class.getName()).log(Level.SEVERE, null, ex);
}
// try {
// BufferedImage image = mxCellRenderer.createBufferedImage(jgxAdapterContext, null, 1, Color.WHITE, true, null);
// ImageIO.write(image, "PNG", new File("/Temp/bart/similarity/instances-graph.png"));
// } catch (IOException ex) {
// logger.error("Unable to save graph image: " + ex.getLocalizedMessage());
// }
}
开发者ID:dbunibas,项目名称:BART,代码行数:36,代码来源:ComputeInstanceSimilarityBlock.java
示例7: showTGDGraph
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
private void showTGDGraph(DirectedGraph<TGDStratum, DefaultEdge> strataGraph) {
JGraphXAdapter<TGDStratum, DefaultEdge> jgxAdapterContext = new JGraphXAdapter<TGDStratum, DefaultEdge>(strataGraph);
jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
// jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "0");
jgxAdapterContext.setCellsEditable(false);
jgxAdapterContext.setCellsMovable(false);
jgxAdapterContext.setEdgeLabelsMovable(false);
jgxAdapterContext.setCellsDeletable(false);
jgxAdapterContext.setCellsDisconnectable(false);
jgxAdapterContext.setCellsResizable(false);
jgxAdapterContext.setCellsBendable(false);
JFrame frame = new JFrame();
mxGraphComponent mxGraphComponent = new mxGraphComponent(jgxAdapterContext);
frame.getContentPane().add(mxGraphComponent, BorderLayout.CENTER);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapterContext);
layout.execute(jgxAdapterContext.getDefaultParent());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Graph");
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
try {
BufferedImage image = mxCellRenderer.createBufferedImage(jgxAdapterContext, null, 1, Color.WHITE, true, null);
ImageIO.write(image, "PNG", new File("/Temp/llunatic/tgd-graph.png"));
} catch (IOException ex) {
logger.error("Unable to save graph image: " + ex.getLocalizedMessage());
}
}
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:29,代码来源:TTGDStratification.java
示例8: showEGDGraph
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
private void showEGDGraph(DirectedGraph<EGDStratum, DefaultEdge> strataGraph) {
JGraphXAdapter<EGDStratum, DefaultEdge> jgxAdapterContext = new JGraphXAdapter<EGDStratum, DefaultEdge>(strataGraph);
jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
// jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "0");
jgxAdapterContext.setCellsEditable(false);
jgxAdapterContext.setCellsMovable(false);
jgxAdapterContext.setEdgeLabelsMovable(false);
jgxAdapterContext.setCellsDeletable(false);
jgxAdapterContext.setCellsDisconnectable(false);
jgxAdapterContext.setCellsResizable(false);
jgxAdapterContext.setCellsBendable(false);
JFrame frame = new JFrame();
mxGraphComponent mxGraphComponent = new mxGraphComponent(jgxAdapterContext);
frame.getContentPane().add(mxGraphComponent, BorderLayout.CENTER);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapterContext);
layout.execute(jgxAdapterContext.getDefaultParent());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Graph");
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
try {
BufferedImage image = mxCellRenderer.createBufferedImage(jgxAdapterContext, null, 1, Color.WHITE, true, null);
ImageIO.write(image, "PNG", new File("/Temp/llunatic/egd-graph.png"));
} catch (IOException ex) {
logger.error("Unable to save graph image: " + ex.getLocalizedMessage());
}
}
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:29,代码来源:TTGDStratification.java
示例9: init
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
@Override
public void init() {
graph = new ListenableDirectedGraph<>(DefaultEdge.class);
adapter = new JGraphModelAdapter(graph);
jgraph = new JGraph(adapter);
adjustDisplaySettings(jgraph);
getContentPane( ).add(jgraph );
resize( DEFAULT_SIZE );
Main.main(null);
ProgramASTNode progNode = new ProgramASTNode(roots.toArray(new ASTNode[0]));
CFG cfg = progNode.createCFG();
// System.out.println(cfg.reduce());
// JGraph cfgGraph = new JGraph(new JGraphXAdapter(cfg.getGraph()));
JGraphXAdapter jgxAdapter = new JGraphXAdapter(cfg.getGraph());
jgxAdapter.setAutoSizeCells(true);
jgxAdapter.setCellsResizable(true);
// jgxAdapter.alignCells(mxConstants.ALIGN_CENTER);
mxStylesheet stylesheet = jgxAdapter.getStylesheet();
Hashtable<String, Object> style = new Hashtable<String, Object>();
style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_RECTANGLE);
style.put(mxConstants.STYLE_OPACITY, 50);
style.put(mxConstants.STYLE_FONTCOLOR, "#774400");
stylesheet.putCellStyle("ROUNDED", style);
jgxAdapter.setStylesheet(stylesheet);
jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter);
graphComponent.setWheelScrollingEnabled(false);
mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel();
// Collection<Object> cells = graphModel.getCells().values();
// mxUtils.setCellStyles(graphComponent.getGraph().getModel(),
// cells.toArray(), mxConstants.STYLE_ENDARROW, mxConstants.NONE);
getContentPane().add(graphComponent);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapter);
layout.execute(jgxAdapter.getDefaultParent());
this.addMouseWheelListener(e -> {
mxGraphView view = graphComponent.getGraph().getView();
int notches = e.getWheelRotation();
double scale = view.getScale();
double newScale = view.getScale() - ((double) notches / 61.8033988272);
view.setScale(newScale);
});
// adjustDisplaySettings(cfgGraph);
// getContentPane().add(cfgGraph);
// final JGraphTreeLayout hir = new JGraphTreeLayout();
// final JGraphFacade graphFacade = new JGraphFacade(cfgGraph, new Object[] {cfg.start});
// graphFacade.setOrdered(true);
// hir.setPositionMultipleTrees(true);
// hir.setTreeDistance(50);
// hir.setLevelDistance(50);
// hir.run(graphFacade);
// final Map nestedMap = graphFacade.createNestedMap(true, true);
// cfgGraph.getGraphLayoutCache().edit(nestedMap);
// SwingUtilities.invokeLater(() -> {
// mxGraphView view = graphComponent.getGraph().getView();
// int compLen = graphComponent.getWidth();
// int viewLen = (int)view.getGraphBounds().getWidth();
// System.out.println("Complen: " + compLen + ", viewlen: " + viewLen);
// System.out.println("Scale: " + (double)compLen/viewLen * view.getScale());
// view.setScale(2);
// });
}
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:72,代码来源:ASTGraph.java
示例10: update
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
public void update() {
app.updating = true;
NARGraph g = new NARGraph();
g.add(nar, filter,
new NARGraph.DefaultGraphizer(true,true,false,false,showSyntax)
);
app.graph = g;
// create a visualization using JGraph, via an adapter
JGraphXAdapter layout = new JGraphXAdapter(g) {
};
app.layout = layout;
/*
mxCompactTreeLayout layout2 =
new mxCompactTreeLayout(jgxAdapter);
layout2.setUseBoundingBox(false);
layout2.setResizeParent(true);
layout2.setLevelDistance(30);
layout2.setNodeDistance(50);
layout2.execute(jgxAdapter.getDefaultParent());
*/
mxFastOrganicLayout l =
//new mxCompactTreeLayout(jgxAdapter);
new mxFastOrganicLayout(layout);
//new mxCircleLayout(jgxAdapter);
l.setForceConstant(edgeDistance*10f);
l.execute(layout.getDefaultParent());
/*
mxOrganicLayout layout =
//new mxCompactTreeLayout(jgxAdapter);
new mxOrganicLayout(jgxAdapter);
//new mxCircleLayout(jgxAdapter);
layout.setEdgeLengthCostFactor(0.001);*/
app.updating = false;
}
开发者ID:automenta,项目名称:opennars,代码行数:50,代码来源:ProcessingGraphPanel.java
示例11: JGraphXGraphPanel
import org.jgrapht.ext.JGraphXAdapter; //导入依赖的package包/类
public JGraphXGraphPanel(NAR n) {
super(new BorderLayout());
NARGraph g = new NARGraph();
g.add(n, IncludeEverything, new NARGraph.DefaultGraphizer(true,true,true,true,true));
// create a visualization using JGraph, via an adapter
jgxAdapter = new JGraphXAdapter(g) {
};
mxGraphComponent mxc = new mxGraphComponent(jgxAdapter) {
};
mxc.setAntiAlias(true);
mxc.setConnectable(false);
mxc.setExportEnabled(false);
mxc.setFoldingEnabled(false);
mxc.setPanning(true);
mxc.setTextAntiAlias(true);
add(new JScrollPane(mxc), BorderLayout.CENTER);
mxFastOrganicLayout layout =
//new mxCompactTreeLayout(jgxAdapter);
new mxFastOrganicLayout(jgxAdapter);
//new mxCircleLayout(jgxAdapter);
layout.setForceConstant(150);
layout.execute(jgxAdapter.getDefaultParent());
/*
mxOrganicLayout layout =
//new mxCompactTreeLayout(jgxAdapter);
new mxOrganicLayout(jgxAdapter);
//new mxCircleLayout(jgxAdapter);
layout.setEdgeLengthCostFactor(0.001);*/
/*
mxCompactTreeLayout layout =
new mxCompactTreeLayout(jgxAdapter);
layout.setLevelDistance(40);
layout.setNodeDistance(50);
layout.execute(jgxAdapter.getDefaultParent());*/
jgxAdapter.setConnectableEdges(false);
jgxAdapter.setCellsDisconnectable(false);
jgxAdapter.setEdgeLabelsMovable(false);
//jgxAdapter.setCellsLocked(true);
}
开发者ID:automenta,项目名称:opennars,代码行数:61,代码来源:JGraphXGraphPanel.java
注:本文中的org.jgrapht.ext.JGraphXAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论