本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.KKLayout类的典型用法代码示例。如果您正苦于以下问题:Java KKLayout类的具体用法?Java KKLayout怎么用?Java KKLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KKLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了KKLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpView
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
private void setUpView(Graph graph)
{
// layout = new SpringLayout2(graph);
layout = new KKLayout(graph);
//layout.setSize(new Dimension(700,700));
vv = new VisualizationViewer(layout);
vv.setPreferredSize(new Dimension(900,900));
vv.setBackground( Color.white );
// Tell the renderer to use our own customized label rendering
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
getContentPane().add(new GraphZoomScrollPane(vv), BorderLayout.CENTER);
/*Mouse controller plugins*/
PluggableGraphMouse gm = new PluggableGraphMouse();
gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON3_MASK));
gm.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 1.1f, 0.9f));
gm.add(new PickingGraphMousePlugin());
vv.setGraphMouse(gm);
}
示例2: StateVisualizer
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
public StateVisualizer() {
super("Model Visualizer");
graph = new DirectedSparseMultigraph<>();
graph.addVertex(current);
// Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
layout = new KKLayout<>(graph);
layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
vv = new VisualizationViewer<>(layout);
vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
// vv.getRenderContext().setVertexShapeTransformer(vlasr);
vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
// vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
vv.addKeyListener(gm.getModeKeyListener());
gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
getContentPane().add(vv);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
pack();
setVisible(true);
}
示例3: FSMBuildVisualizer
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
public FSMBuildVisualizer() {
super("Model Visualizer");
graph = new DirectedSparseMultigraph<>();
graph.addVertex(current);
// Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
layout = new KKLayout<>(graph);
layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
vv = new VisualizationViewer<>(layout);
vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
// vv.getRenderContext().setVertexShapeTransformer(vlasr);
vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
// vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
vv.addKeyListener(gm.getModeKeyListener());
gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
getContentPane().add(vv);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
pack();
setVisible(true);
}
示例4: visualizeGraphAndDumpToFile
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
void visualizeGraphAndDumpToFile(String fileName){
Layout<Integer,Integer> l = new KKLayout<Integer,Integer>( assocG);
VisualizationImageServer<Integer, Integer> vis =
new VisualizationImageServer<Integer, Integer>(l, new Dimension(1200,1200));
vis.setBackground(Color.WHITE);
// Create the buffered image
BufferedImage image = (BufferedImage) vis.getImage (
new Point2D.Double(l.getSize().getWidth() / 2,
l.getSize().getHeight() / 2),
new Dimension(l.getSize()));
// Write image to a png file
File outputfile = new File(fileName);
try {
ImageIO.write(image, "png", outputfile);
} catch (IOException e) {
// Exception handling
e.printStackTrace();
System.exit(1);
}
}
示例5: GraphPanel
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的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);
}
示例6: getLayout
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的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);
}
}
示例7: initLayoutBox
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
/**
* Initializes combobox for layout
*/
private void initLayoutBox(){
layoutBox.addItem("CircleLayout");
layoutBox.addItem("FRLayout");
layoutBox.addItem("FRLayout2");
layoutBox.addItem("ISOMLayout");
layoutBox.addItem("KKLayout");
layoutBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent a) {
JComboBox<String> lBox = (JComboBox<String>) a.getSource();
String name = (String) lBox.getSelectedItem();
for (EGPanel e : egPanels){
ExplanationGraph eg = e.getEG();
switch(name){
case "CircleLayout": layout = new CircleLayout<EGVertex, EGEdge>(eg); break;
case "FRLayout": layout = new FRLayout<EGVertex, EGEdge>(eg); break;
case "FRLayout2": layout = new FRLayout<EGVertex, EGEdge>(eg); break;
case "KKLayout": layout = new KKLayout<EGVertex, EGEdge>(eg); break;
default : layout = new ISOMLayout<EGVertex, EGEdge>(eg); break;
}
e.setLayout(layout);
}
}});
}
示例8: initLayoutBox
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
private void initLayoutBox(){
layoutBox.addItem("CircleLayout");
layoutBox.addItem("FRLayout");
layoutBox.addItem("FRLayout2");
layoutBox.addItem("ISOMLayout");
layoutBox.addItem("KKLayout");
layoutBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent a) {
JComboBox<String> lBox = (JComboBox<String>) a.getSource();
String name = (String) lBox.getSelectedItem();
switch(name){
case "CircleLayout": l = new CircleLayout<EDGVertex, EDGEdge>(edg); break;
case "FRLayout": l = new FRLayout<EDGVertex, EDGEdge>(edg); break;
case "FRLayout2": l = new FRLayout<EDGVertex, EDGEdge>(edg); break;
case "KKLayout": l = new KKLayout<EDGVertex, EDGEdge>(edg); break;
default : l = new ISOMLayout<EDGVertex, EDGEdge>(edg); break;
}
l.setSize(new Dimension(780,400));
visServer.setGraphLayout(l);
visServer.doLayout();
}
});
}
示例9: newLayout
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
private Layout<Node, Edge> newLayout(final Diagram diagram) {
final Layout<Node, Edge> diagramLayout;
if (layout != null && layout.startsWith("spring")) {
diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100"))));
} else if (layout != null && layout.startsWith("kk")) {
Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram);
if (layout.endsWith("unweight")) {
distance = new UnweightedShortestPath<Node, Edge>(diagram);
}
diagramLayout = new KKLayout<Node, Edge>(diagram, distance);
} else if (layout != null && layout.equalsIgnoreCase("circle")) {
diagramLayout = new CircleLayout<Node, Edge>(diagram);
} else if (layout != null && layout.equalsIgnoreCase("fr")) {
diagramLayout = new FRLayout<Node, Edge>(diagram);
} else {
final LevelLayout levelLayout = new LevelLayout(diagram);
levelLayout.adjust = adjust;
diagramLayout = levelLayout;
}
return diagramLayout;
}
示例10: LayoutSelection
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的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);
}
示例11: factory
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的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));
}
示例12: LayoutSelection
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的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);
}
示例13: getCombos
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
/**
* @return
*/
@SuppressWarnings("unchecked")
private Class<? extends Layout>[] getCombos()
{
List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
layouts.add(KKLayout.class);
layouts.add(FRLayout.class);
layouts.add(CircleLayout.class);
layouts.add(SpringLayout.class);
layouts.add(SpringLayout2.class);
layouts.add(ISOMLayout.class);
return layouts.toArray(new Class[0]);
}
示例14: VisualizationImageServerDemo
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
/**
*
*/
public VisualizationImageServerDemo() {
// create a simple graph for the demo
graph = new DirectedSparseMultigraph<String, Number>();
String[] v = createVertices(10);
createEdges(v);
vv = new VisualizationImageServer<String,Number>(new KKLayout<String,Number>(graph), new Dimension(600,600));
vv.getRenderer().setVertexRenderer(
new GradientVertexRenderer<String,Number>(
Color.white, Color.red,
Color.white, Color.blue,
vv.getPickedVertexState(),
false));
vv.getRenderContext().setEdgeDrawPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setArrowDrawPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPositioner(new InsidePositioner());
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO);
// create a frome to hold the graph
final JFrame frame = new JFrame();
Container content = frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Image im = vv.getImage(new Point2D.Double(300,300), new Dimension(600,600));
Icon icon = new ImageIcon(im);
JLabel label = new JLabel(icon);
content.add(label);
frame.pack();
frame.setVisible(true);
}
示例15: getCombos
import edu.uci.ics.jung.algorithms.layout.KKLayout; //导入依赖的package包/类
/**
* @return
*/
@SuppressWarnings("unchecked")
private static Class<? extends Layout>[] getCombos()
{
List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
layouts.add(KKLayout.class);
layouts.add(FRLayout.class);
layouts.add(CircleLayout.class);
layouts.add(SpringLayout.class);
layouts.add(SpringLayout2.class);
layouts.add(ISOMLayout.class);
return layouts.toArray(new Class[0]);
}