本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.FRLayout2类的典型用法代码示例。如果您正苦于以下问题:Java FRLayout2类的具体用法?Java FRLayout2怎么用?Java FRLayout2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FRLayout2类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了FRLayout2类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLayout
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
private static AbstractLayout<Vertex, Edge> getLayout(GraphJung<Graph> graph, String layoutName) {
switch (layoutName) {
case "KKLayout":
return new KKLayout<>(graph);
case "CircleLayout":
return new CircleLayout<>(graph);
case "FRLayout":
return new FRLayout<>(graph);
case "FRLayout2":
return new FRLayout2<>(graph);
case "ISOMLayout":
return new ISOMLayout<>(graph);
case "SpringLayout":
return new SpringLayout<>(graph);
default:
return new KKLayout<>(graph);
}
}
示例2: LayoutSelection
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
public LayoutSelection(GraphViewer<V, E> graphViewer, Graph<V, E> graph) {
super();
this.graphViewer = graphViewer;
this.graph = graph;
this.layout = new ISOMLayout<V, E>(graph);
layoutMap = new java.util.LinkedHashMap<String, Class>();
if (graph instanceof Forest) {
layoutMap.put("Tree", ShapeBasedTreeLayout.class);
layoutMap.put("Tree (Tight)", TreeLayout.class);
layoutMap.put("Radial", RadialTreeLayout.class);
layoutMap.put("Balloon", BalloonLayout.class);
}
layoutMap.put("ISOM", ISOMLayout.class);
layoutMap.put("KKLayout", KKLayout.class);
layoutMap.put("FRLayout", FRLayout2.class);
layoutMap.put("Circle", CircleLayout.class);
layoutMap.put("Spring", SpringLayout2.class);
Iterator<String> it = layoutMap.keySet().iterator();
while (it.hasNext()) {
addItem(it.next());
}
addActionListener(this);
}
示例3: LayoutSelection
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
public LayoutSelection(GraphViewer<V, E> graphViewer, Graph<V, E> graph) {
super();
this.graphViewer = graphViewer;
this.graph = graph;
this.layout = new ISOMLayout<V, E>(graph);
layoutMap = new LinkedHashMap<>();
if (graph instanceof Forest) {
layoutMap.put("Tree", ShapeBasedTreeLayout.class);
layoutMap.put("Tree (Tight)", TreeLayout.class);
layoutMap.put("Radial", RadialTreeLayout.class);
layoutMap.put("Balloon", BalloonLayout.class);
}
layoutMap.put("ISOM", ISOMLayout.class);
layoutMap.put("KKLayout", KKLayout.class);
layoutMap.put("FRLayout", FRLayout2.class);
layoutMap.put("Circle", CircleLayout.class);
layoutMap.put("Spring", SpringLayout2.class);
Iterator<String> it = layoutMap.keySet().iterator();
while (it.hasNext()) {
addItem(it.next());
}
addActionListener(this);
}
示例4: buildJungLayout
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
@Override
protected Layout<GraphNode,GraphEdge> buildJungLayout(
DirectedGraph<GraphNode, GraphEdge> jungGraph,
Dimension layoutSize) {
FRLayout2<GraphNode, GraphEdge> result =
new FRLayout2<GraphNode, GraphEdge>(jungGraph, layoutSize);
if (attractMultiplier.isSet()) {
result.setAttractionMultiplier(attractMultiplier.getValue());
}
if (repulsionMultiplier.isSet()) {
result.setAttractionMultiplier(repulsionMultiplier.getValue());
}
return result;
}
示例5: LayoutSelection
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
public LayoutSelection(GraphViewer<V, E> graphViewer, Graph<V,E> graph) {
super();
this.graphViewer = graphViewer;
this.graph = graph;
this.layout = new ISOMLayout<V, E>(graph);
layoutMap = new java.util.LinkedHashMap<String, Class>();
if (graph instanceof Forest) {
layoutMap.put("Tree", ShapeBasedTreeLayout.class);
layoutMap.put("Tree (Tight)", TreeLayout.class);
layoutMap.put("Radial", RadialTreeLayout.class);
layoutMap.put("Balloon", BalloonLayout.class);
}
layoutMap.put("ISOM", ISOMLayout.class);
layoutMap.put("KKLayout", KKLayout.class);
layoutMap.put("FRLayout", FRLayout2.class);
layoutMap.put("Circle", CircleLayout.class);
layoutMap.put("Spring", SpringLayout2.class);
Iterator<String> it = layoutMap.keySet().iterator();
while (it.hasNext())
addItem(it.next());
addActionListener(this);
}
示例6: DependencyGraphScene
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
DependencyGraphScene(ObservableGraph<ArtifactGraphNode, ArtifactGraphEdge> graph, DelegateForest<ArtifactGraphNode, ArtifactGraphEdge> forest, MavenProject prj, Project nbProj, DependencyGraphTopComponent tc,
POMModel model) {
super(graph, new FRLayout<>(forest));
layoutModel = new DefaultComboBoxModel<>();
layoutModel.addElement(layout());
// These rarely work but look nice when they do
// layoutModel.addElement(new BalloonLayout<>(forest));
// layoutModel.addElement(new RadialTreeLayout<>(forest));
layoutModel.addElement(new CircleLayout<>(graph));
layoutModel.addElement(new FRLayout<>(graph));
layoutModel.addElement(new FRLayout2<>(graph));
layoutModel.addElement(new KKLayout<>(graph));
TreeLayout<ArtifactGraphNode, ArtifactGraphEdge> treeLayout = new TreeLayout<>(forest, 200, 90);
layoutModel.addElement(treeLayout);
layoutModel.addElement(new ISOMLayout<>(graph));
layoutModel.addElement(new SpringLayout<>(graph));
layoutModel.addElement(new SpringLayout2<>(graph));
layoutModel.setSelectedItem(layout());
moveAction = ActionFactory.createMoveAction(null, new MP());
this.forest = forest;
project = prj;
nbProject = nbProj;
this.tc = tc;
this.model = model;
mainLayer = new LayerWidget(this);
addChild(mainLayer);
connectionLayer = new LayerWidget(this);
addChild(connectionLayer);
//getActions().addAction(this.createObjectHoverAction());
getActions().addAction(hoverAction);
getActions().addAction(ActionFactory.createSelectAction(allActionsP));
getActions().addAction(zoomAction);
getActions().addAction(panAction);
getActions().addAction(editAction);
getActions().addAction(popupMenuAction);
getActions().addAction(new ScrollWheelZoomAction());
}
示例7: transform
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
@Override
public Layout<INode, IConnection> transform(Graph<INode, IConnection> networkGraph) {
// TODO change to concurrent FRLAyout2
return new FRLayout2<>(networkGraph);
}
示例8: init
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
@Override
public void init() {
//create a graph
Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number,Number>());
ObservableGraph<Number,Number> og = new ObservableGraph<Number,Number>(ig);
og.addGraphEventListener(new GraphEventListener<Number,Number>() {
public void handleGraphEvent(GraphEvent<Number, Number> evt) {
System.err.println("got "+evt);
}});
this.g = og;
//create a graphdraw
layout = new FRLayout2<Number,Number>(g);
// ((FRLayout)layout).setMaxIterations(200);
vv = new VisualizationViewer<Number,Number>(layout, new Dimension(600,600));
JRootPane rp = this.getRootPane();
rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
getContentPane().setLayout(new BorderLayout());
getContentPane().setBackground(java.awt.Color.lightGray);
getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));
vv.getModel().getRelaxer().setSleepTime(500);
vv.setGraphMouse(new DefaultModalGraphMouse<Number,Number>());
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
vv.setForeground(Color.white);
getContentPane().add(vv);
switchLayout = new JButton("Switch to SpringLayout");
switchLayout.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent ae) {
Dimension d = new Dimension(600,600);
if (switchLayout.getText().indexOf("Spring") > 0) {
switchLayout.setText("Switch to FRLayout");
layout = new SpringLayout<Number,Number>(g,
new ConstantTransformer(EDGE_LENGTH));
layout.setSize(d);
vv.getModel().setGraphLayout(layout, d);
} else {
switchLayout.setText("Switch to SpringLayout");
layout = new FRLayout<Number,Number>(g, d);
vv.getModel().setGraphLayout(layout, d);
}
}
});
getContentPane().add(switchLayout, BorderLayout.SOUTH);
timer = new Timer();
}
示例9: switchLayout
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的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);
}
}
示例10: init
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
@Override
public void init() {
//create a graph
Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number,Number>());
ObservableGraph<Number,Number> og = new ObservableGraph<Number,Number>(ig);
og.addGraphEventListener(new GraphEventListener<Number,Number>() {
public void handleGraphEvent(GraphEvent<Number, Number> evt) {
System.err.println("got "+evt);
}});
this.g = og;
//create a graphdraw
layout = new FRLayout2<Number,Number>(g);
// ((FRLayout)layout).setMaxIterations(200);
vv = new VisualizationViewer<Number,Number>(layout, new Dimension(600,600));
JRootPane rp = this.getRootPane();
rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
getContentPane().setLayout(new BorderLayout());
getContentPane().setBackground(java.awt.Color.lightGray);
getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));
vv.getModel().getRelaxer().setSleepTime(500);
vv.setGraphMouse(new DefaultModalGraphMouse<Number,Number>());
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
vv.setForeground(Color.white);
getContentPane().add(vv);
switchLayout = new JButton("Switch to SpringLayout");
switchLayout.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent ae) {
Dimension d = new Dimension(600,600);
if (switchLayout.getText().indexOf("Spring") > 0) {
switchLayout.setText("Switch to FRLayout");
layout = new SpringLayout<Number,Number>(g,
new ConstantTransformer(EDGE_LENGTH));
layout.setSize(d);
vv.getModel().setGraphLayout(layout, d);
} else {
switchLayout.setText("Switch to SpringLayout");
layout = new FRLayout<Number,Number>(g, d);
vv.getModel().setGraphLayout(layout, d);
}
}
});
getContentPane().add(switchLayout, BorderLayout.SOUTH);
timer = new Timer();
}
示例11: refreshLayout
import edu.uci.ics.jung.algorithms.layout.FRLayout2; //导入依赖的package包/类
synchronized
public void refreshLayout() {
// logger.debug("refresh");
final FRLayout2<INode, IConnection> l = new FRLayout2<>(this.layout.getObservableGraph());
l.setMaxIterations(layout.getGraph().getEdgeCount() * (int) (this.getWidth() / canvas.getScale()));
// l.setMaxIterations(700);
this.layout = new ObservableLayout<>(l);
//TODO make the dimension changeable from settings menu?
// logger.debug(canvas.getScale() + " " + this.getWidth() + " " + this.getHeight());
layout.setSize(new Dimension((int) (this.getWidth() / (2 * canvas.getScale())), (int) (this.getHeight() / (2 * canvas.getScale()))));
//layout.set
final Executor layouter = Executors.newSingleThreadExecutor();
layouter.execute(() -> {
while (!layout.done()) {
layout.step();
Platform.runLater(this::repaint);
}
});
}