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);
 }
 protected void setVertexLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   renderContext.setVertexLabelTransformer(new ToStringLabeller<CallGraphNode>());
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicVertexLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicVertexLabelRenderer<CallGraphNode, CallGraphLink>();
   labelRenderer.setPosition(Renderer.VertexLabel.Position.CNTR);
   renderer.setVertexLabelRenderer(labelRenderer);
 }
 protected void setEdgeLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   ToStringLabeller<CallGraphLink> toStringLabeller = new ToStringLabeller<CallGraphLink>();
   renderContext.setEdgeLabelTransformer(toStringLabeller);
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink>();
   // labelRenderer.setPosition(Renderer.EdgeLabel.Position.CNTR);
   renderer.setEdgeLabelRenderer(labelRenderer);
 }
Example #4
0
  public MapViewer(String title) {
    super(title);
    setSize(800, 600);
    // setExtendedState(Frame.MAXIMIZED_BOTH);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    edgeCnt = 0;
    startMap();
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.setBackground(Color.lightGray);
    // vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer()
        .getVertexLabelRenderer()
        .setPosition(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);
    cp.add(vv, BorderLayout.CENTER);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));
    setVisible(true);
    JMenuBar jb = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    jb.add(fileMenu);
    JMenuItem exitMenu = new JMenuItem("Exit");
    fileMenu.add(exitMenu);
    exitMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MapViewer.this.dispose();
          }
        });
    JMenu helpMenu = new JMenu("Help");
    jb.add(helpMenu);
    JMenuItem aboutItem = new JMenuItem("About");
    helpMenu.add(aboutItem);
    aboutItem.addActionListener(new AboutActionListener());
    this.setJMenuBar(jb);
    setLocationRelativeTo(null);
  }