本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.DAGLayout类的典型用法代码示例。如果您正苦于以下问题:Java DAGLayout类的具体用法?Java DAGLayout怎么用?Java DAGLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DAGLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了DAGLayout类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: factory
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的package包/类
public static <V, E> GraphVisualizationPanel<V, E> factory(Graph<V, E> graph) {
Layout<V, E> layout = null;
if (graph instanceof DelegateForest) {
layout = new TreeLayout<V, E>((Forest<V, E>) graph);
} else if (graph instanceof MarkovGraph){
layout = new FRLayout<V,E>(graph);
} else if (graph instanceof ConflictGraph){
layout = new KKLayout<V, E>(graph);
} else if (graph instanceof AbstractDirectedGraph) {
layout = new DAGLayout<V, E>(graph);
} else {
layout = new CircleLayout<V, E>(graph);
}
return (new GraphVisualizationPanel<V, E>(layout, graph));
}
示例2: setupGraph
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的package包/类
public static void setupGraph(DirectedSparseGraph g){
bg = g;
Layout<BooleanNode, TravelEdge> layout = new DAGLayout(bg);
layout.setSize(new Dimension(300,300)); // sets the initial size of the layout space
VisualizationViewer<BooleanNode,TravelEdge> vv = new VisualizationViewer<BooleanNode,TravelEdge>(layout);
vv.setPreferredSize(new Dimension(500,500)); //Sets the viewing area size
Transformer<BooleanNode,Paint> vertexPaint = new Transformer<BooleanNode,Paint>() {
public Paint transform(BooleanNode i) {
if (i.isCurrentNode()){
return Color.RED;
} else if (i.getObserved()){
return Color.BLUE;
} else if (i.isStartNode()) {
return Color.GREEN;
} else if (i.isEndNode()){
return Color.BLACK;
} else {
return Color.WHITE;
}
}
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
PluggableGraphMouse gm = new PluggableGraphMouse();
gm.add(new NetworkGameMousePlugin());
vv.setGraphMouse(gm);
frame = new JFrame("Simple Graph View");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
JMenuBar menuBar = new JMenuBar();
JMenu restartMenu = new JMenu();
restartMenu.setText("Restart");
menuBar.add(restartMenu);
JMenuItem restartItem = new JMenuItem("Restart level");
restartItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
restartLevel();
}
});
restartMenu.add(restartItem);
frame.setJMenuBar(menuBar);
frame.pack();
frame.setVisible(true);
}
示例3: displayBayesGraph
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的package包/类
private void displayBayesGraph(){
Layout<BayesNode, Pair<Integer,Integer>> layout = new DAGLayout<BayesNode, Pair<Integer, Integer>>(graph);
layout.setSize(new Dimension(700,700));
vv = new VisualizationViewer<BayesNode, Pair<Integer,Integer>>(layout);
Transformer<BayesNode,Paint> vertexPaint = new Transformer<BayesNode,Paint>() {
public Paint transform(BayesNode i) {
Boolean assumed = i.assumedValue();
if (i.isObserved()){
if (i.getProbability().doubleValue() == 1.0d){
return BayesGame.trueColor;
} else {
return BayesGame.falseColor;
}
}
if (assumed == null){
return BayesGame.unknownColor;
} else {
if (assumed){
return BayesGame.trueColor;
} else {
return BayesGame.falseColor;
}
}
}
};
Transformer<BayesNode,Shape> vertexShape = new Transformer<BayesNode,Shape>(){
public Shape transform(BayesNode b){
if (!b.isObserved()){
return new Ellipse2D.Double(-16, -16, 32, 32);
} else {
return new RoundRectangle2D.Double(-16, -16, 32, 32, 16, 16);
}
}
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexShapeTransformer(vertexShape);
// vv.getRenderContext().setVertexIconTransformer(new BayesNodeProbabilityToGridTransformer());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.setPreferredSize(new Dimension(800,800)); //Sets the viewing area size
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).rotate(-Math.PI, 350, 350);
graphPanel.add(vv);
frame.pack();
graphPanel.setVisible(true);
}
示例4: displayBayesGraph
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的package包/类
public void displayBayesGraph(BayesNet bayesNet){
DirectedSparseGraph<BayesNode, Pair<Integer,Integer>> graph = bayesNet.getGraph();
Layout<BayesNode, Pair<Integer,Integer>> layout = new DAGLayout<BayesNode, Pair<Integer, Integer>>(graph);
layout.setSize(BayesGame.getVVLayoutSize());
vv = new VisualizationViewer<BayesNode, Pair<Integer,Integer>>(layout);
Transformer<BayesNode,Paint> vertexPaint = new Transformer<BayesNode,Paint>() {
public Paint transform(BayesNode i) {
Boolean assumed = i.assumedValue();
if (i.isObserved()){
if (i.getProbability().doubleValue() == 1.0d){
return BayesGame.trueColor;
} else {
return BayesGame.falseColor;
}
}
if (assumed == null){
return BayesGame.unknownColor;
} else {
if (assumed){
return BayesGame.trueColor;
} else {
return BayesGame.falseColor;
}
}
}
};
Transformer<BayesNode,Shape> vertexShape = new Transformer<BayesNode,Shape>(){
public Shape transform(BayesNode b){
if (!b.isObserved()){
return new Ellipse2D.Double(-16, -16, 32, 32);
} else {
return new RoundRectangle2D.Double(-16, -16, 32, 32, 16, 16);
}
}
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexShapeTransformer(vertexShape);
vv.getRenderContext().setVertexIconTransformer(new BayesNodeProbabilityToGridTransformer(bayesNet));
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.setPreferredSize(new Dimension(BayesGame.getNewHeight(750),BayesGame.getNewWidth(750))); //Sets the viewing area size
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).rotate(-Math.PI, BayesGame.getNewHeight(350),BayesGame.getNewWidth(350));
this.add(vv);
this.setVisible(true);
}
示例5: visualize
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的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);
}
示例6: actionPerformed
import edu.uci.ics.jung.algorithms.layout.DAGLayout; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
final GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
DAGLayout dagLayout = new DAGLayout(viewerPanel.getCurrentGraph());
MyVisualizationViewer vv = (MyVisualizationViewer) viewerPanel.getVisualizationViewer();
vv.setGraphLayout(dagLayout);
vv.repaint();
}