How to modify a graph appearance in JUNG2019 Community Moderator ElectionHow do I efficiently iterate over each entry in a Java Map?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?How do you change the size of figures drawn with matplotlib?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?comparing open source java graph drawing frameworks(JUNG and Prefuse) for drawing network topologyHow do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?Jung, Layout for large vertices overlap and graph appears in strange location

Describing a chess game in a novel

How could an airship be repaired midflight?

How are passwords stolen from companies if they only store hashes?

What is the meaning of まっちろけ?

How to get the n-th line after a grepped one?

Explaining pyrokinesis powers

What favor did Moody owe Dumbledore?

Recruiter wants very extensive technical details about all of my previous work

What is the relationship between relativity and the Doppler effect?

If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?

I got the following comment from a reputed math journal. What does it mean?

Why is there is so much iron?

How to write cleanly even if my character uses expletive language?

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Why one should not leave fingerprints on bulbs and plugs?

Why is a white electrical wire connected to 2 black wires?

Knife as defense against stray dogs

Violin - Can double stops be played when the strings are not next to each other?

Print a physical multiplication table

As a new Ubuntu desktop 18.04 LTS user, do I need to use ufw for a firewall or is iptables sufficient?

What is a ^ b and (a & b) << 1?

Why do passenger jet manufacturers design their planes with stall prevention systems?

The meaning of 振り in 無茶振り

Could the Saturn V actually have launched astronauts around Venus?



How to modify a graph appearance in JUNG



2019 Community Moderator ElectionHow do I efficiently iterate over each entry in a Java Map?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?How do you change the size of figures drawn with matplotlib?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?comparing open source java graph drawing frameworks(JUNG and Prefuse) for drawing network topologyHow do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?Jung, Layout for large vertices overlap and graph appears in strange location










0















I'm trying to visualize a tree graph with the JUNG library.



The code I use is:



 JPanel base = new JPanel();

Graph<String, String> grafo = OntologyGraph.getGraph(ontology);

Layout<String, String> layout = new TreeLayout<String, String>((Forest<String, String>) grafo);
VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(layout);

vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

final DefaultModalGraphMouse<String, Number> graphMouse3 = new DefaultModalGraphMouse<>();
vv.setGraphMouse(graphMouse3);
graphMouse3.setMode(DefaultModalGraphMouse.Mode.PICKING);

base.add(vv);

return base;


It displays this
enter image description here



Now I want to change the circled verteces with a labelled JButton and to enlarge the space between them, but I can't find a tutorial on the web to achive this.










share|improve this question


























    0















    I'm trying to visualize a tree graph with the JUNG library.



    The code I use is:



     JPanel base = new JPanel();

    Graph<String, String> grafo = OntologyGraph.getGraph(ontology);

    Layout<String, String> layout = new TreeLayout<String, String>((Forest<String, String>) grafo);
    VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(layout);

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

    final DefaultModalGraphMouse<String, Number> graphMouse3 = new DefaultModalGraphMouse<>();
    vv.setGraphMouse(graphMouse3);
    graphMouse3.setMode(DefaultModalGraphMouse.Mode.PICKING);

    base.add(vv);

    return base;


    It displays this
    enter image description here



    Now I want to change the circled verteces with a labelled JButton and to enlarge the space between them, but I can't find a tutorial on the web to achive this.










    share|improve this question
























      0












      0








      0








      I'm trying to visualize a tree graph with the JUNG library.



      The code I use is:



       JPanel base = new JPanel();

      Graph<String, String> grafo = OntologyGraph.getGraph(ontology);

      Layout<String, String> layout = new TreeLayout<String, String>((Forest<String, String>) grafo);
      VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(layout);

      vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
      vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
      vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

      final DefaultModalGraphMouse<String, Number> graphMouse3 = new DefaultModalGraphMouse<>();
      vv.setGraphMouse(graphMouse3);
      graphMouse3.setMode(DefaultModalGraphMouse.Mode.PICKING);

      base.add(vv);

      return base;


      It displays this
      enter image description here



      Now I want to change the circled verteces with a labelled JButton and to enlarge the space between them, but I can't find a tutorial on the web to achive this.










      share|improve this question














      I'm trying to visualize a tree graph with the JUNG library.



      The code I use is:



       JPanel base = new JPanel();

      Graph<String, String> grafo = OntologyGraph.getGraph(ontology);

      Layout<String, String> layout = new TreeLayout<String, String>((Forest<String, String>) grafo);
      VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(layout);

      vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
      vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
      vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

      final DefaultModalGraphMouse<String, Number> graphMouse3 = new DefaultModalGraphMouse<>();
      vv.setGraphMouse(graphMouse3);
      graphMouse3.setMode(DefaultModalGraphMouse.Mode.PICKING);

      base.add(vv);

      return base;


      It displays this
      enter image description here



      Now I want to change the circled verteces with a labelled JButton and to enlarge the space between them, but I can't find a tutorial on the web to achive this.







      java graph jung






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 15:47









      Spalla DiegoSpalla Diego

      466




      466






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Changing the spacing between the nodes is easy enough; just use the TreeLayout constructor that accepts the distx and disty parameters.



          Providing a JButton for each node is not something that JUNG natively supports, although you could do some hacking to enable it.



          What problem are you trying to solve by using JButtons for nodes?






          share|improve this answer























          • I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

            – Spalla Diego
            Mar 11 at 22:33



















          0














          Here is some example code that you can use to open a JFrame with information about the node that was clicked (when you are in picking mode). If you want to have it respond to node clicks even when you are in the transforming mode, you'd have to change the graphmouseplugins a little to not remove the PickingGraphMousePlugin when in transforming mode.



           vv.getRenderContext().getPickedVertexState().addItemListener(new ItemListener()
          @Override
          public void itemStateChanged(ItemEvent e)
          if (e.getStateChange() == ItemEvent.SELECTED)
          JFrame frame = new JFrame("Vertex "+e.getItem()+" picked");
          frame.getContentPane().add(new JButton("hello from "+e.getItem()));
          frame.setSize(new Dimension(200,100));
          frame.setLocation(200, 200);
          frame.setVisible(true);


          );


          If you want the vertices to look more like rectangular buttons, the VertexLableAsShapeDemo may help. That demo uses JLabels to draw the vertices






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047779%2fhow-to-modify-a-graph-appearance-in-jung%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Changing the spacing between the nodes is easy enough; just use the TreeLayout constructor that accepts the distx and disty parameters.



            Providing a JButton for each node is not something that JUNG natively supports, although you could do some hacking to enable it.



            What problem are you trying to solve by using JButtons for nodes?






            share|improve this answer























            • I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

              – Spalla Diego
              Mar 11 at 22:33
















            0














            Changing the spacing between the nodes is easy enough; just use the TreeLayout constructor that accepts the distx and disty parameters.



            Providing a JButton for each node is not something that JUNG natively supports, although you could do some hacking to enable it.



            What problem are you trying to solve by using JButtons for nodes?






            share|improve this answer























            • I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

              – Spalla Diego
              Mar 11 at 22:33














            0












            0








            0







            Changing the spacing between the nodes is easy enough; just use the TreeLayout constructor that accepts the distx and disty parameters.



            Providing a JButton for each node is not something that JUNG natively supports, although you could do some hacking to enable it.



            What problem are you trying to solve by using JButtons for nodes?






            share|improve this answer













            Changing the spacing between the nodes is easy enough; just use the TreeLayout constructor that accepts the distx and disty parameters.



            Providing a JButton for each node is not something that JUNG natively supports, although you could do some hacking to enable it.



            What problem are you trying to solve by using JButtons for nodes?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 10 at 23:29









            Joshua O'MadadhainJoshua O'Madadhain

            2,5091916




            2,5091916












            • I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

              – Spalla Diego
              Mar 11 at 22:33


















            • I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

              – Spalla Diego
              Mar 11 at 22:33

















            I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

            – Spalla Diego
            Mar 11 at 22:33






            I nerd to visualize an onthology I converted to a graph, then when clicking on a node it should open a JFrame with some information

            – Spalla Diego
            Mar 11 at 22:33














            0














            Here is some example code that you can use to open a JFrame with information about the node that was clicked (when you are in picking mode). If you want to have it respond to node clicks even when you are in the transforming mode, you'd have to change the graphmouseplugins a little to not remove the PickingGraphMousePlugin when in transforming mode.



             vv.getRenderContext().getPickedVertexState().addItemListener(new ItemListener()
            @Override
            public void itemStateChanged(ItemEvent e)
            if (e.getStateChange() == ItemEvent.SELECTED)
            JFrame frame = new JFrame("Vertex "+e.getItem()+" picked");
            frame.getContentPane().add(new JButton("hello from "+e.getItem()));
            frame.setSize(new Dimension(200,100));
            frame.setLocation(200, 200);
            frame.setVisible(true);


            );


            If you want the vertices to look more like rectangular buttons, the VertexLableAsShapeDemo may help. That demo uses JLabels to draw the vertices






            share|improve this answer





























              0














              Here is some example code that you can use to open a JFrame with information about the node that was clicked (when you are in picking mode). If you want to have it respond to node clicks even when you are in the transforming mode, you'd have to change the graphmouseplugins a little to not remove the PickingGraphMousePlugin when in transforming mode.



               vv.getRenderContext().getPickedVertexState().addItemListener(new ItemListener()
              @Override
              public void itemStateChanged(ItemEvent e)
              if (e.getStateChange() == ItemEvent.SELECTED)
              JFrame frame = new JFrame("Vertex "+e.getItem()+" picked");
              frame.getContentPane().add(new JButton("hello from "+e.getItem()));
              frame.setSize(new Dimension(200,100));
              frame.setLocation(200, 200);
              frame.setVisible(true);


              );


              If you want the vertices to look more like rectangular buttons, the VertexLableAsShapeDemo may help. That demo uses JLabels to draw the vertices






              share|improve this answer



























                0












                0








                0







                Here is some example code that you can use to open a JFrame with information about the node that was clicked (when you are in picking mode). If you want to have it respond to node clicks even when you are in the transforming mode, you'd have to change the graphmouseplugins a little to not remove the PickingGraphMousePlugin when in transforming mode.



                 vv.getRenderContext().getPickedVertexState().addItemListener(new ItemListener()
                @Override
                public void itemStateChanged(ItemEvent e)
                if (e.getStateChange() == ItemEvent.SELECTED)
                JFrame frame = new JFrame("Vertex "+e.getItem()+" picked");
                frame.getContentPane().add(new JButton("hello from "+e.getItem()));
                frame.setSize(new Dimension(200,100));
                frame.setLocation(200, 200);
                frame.setVisible(true);


                );


                If you want the vertices to look more like rectangular buttons, the VertexLableAsShapeDemo may help. That demo uses JLabels to draw the vertices






                share|improve this answer















                Here is some example code that you can use to open a JFrame with information about the node that was clicked (when you are in picking mode). If you want to have it respond to node clicks even when you are in the transforming mode, you'd have to change the graphmouseplugins a little to not remove the PickingGraphMousePlugin when in transforming mode.



                 vv.getRenderContext().getPickedVertexState().addItemListener(new ItemListener()
                @Override
                public void itemStateChanged(ItemEvent e)
                if (e.getStateChange() == ItemEvent.SELECTED)
                JFrame frame = new JFrame("Vertex "+e.getItem()+" picked");
                frame.getContentPane().add(new JButton("hello from "+e.getItem()));
                frame.setSize(new Dimension(200,100));
                frame.setLocation(200, 200);
                frame.setVisible(true);


                );


                If you want the vertices to look more like rectangular buttons, the VertexLableAsShapeDemo may help. That demo uses JLabels to draw the vertices







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 12 at 16:41

























                answered Mar 12 at 8:49









                Tom NelsonTom Nelson

                1815




                1815



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047779%2fhow-to-modify-a-graph-appearance-in-jung%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived