Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:23:00+00:00 2026-05-22T21:23:00+00:00

I build a graph using JUNG (Java Universal Network/Graph Framework) with the following code:

  • 0

I build a graph using JUNG (Java Universal Network/Graph Framework) with the following code:

g = new SparseMultigraph<BusStop, Travel>();

//add some Vertex and Edges

Layout<String, String> layout1 = new CircleLayout(g);
layout1.setSize(new Dimension(300,300)); // sets the initial size of the layout space

VisualizationViewer vv = new VisualizationViewer(layout1);
vv.setPreferredSize(new Dimension(350,350)); //Sets the viewing area size

Transformer<BusStop,Paint> vertexPaint = new Transformer<BusStop,Paint>() {
    public Paint transform(BusStop b) {
        return Color.GREEN;
    }
};

Transformer<BusStop,Shape> vertexShape = new Transformer<BusStop,Shape>() {
    public Shape transform(BusStop b) {
        return new Rectangle(-20, -10, 40, 20);
    }
};

vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexShapeTransformer(vertexShape);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

GraphViewerForm = new edu.uci.ics.jung.visualization.GraphZoomScrollPane(vv);

Now, I want to add more vertices and edges to the graph.. how can I do this? What instructions should I run for the graph to be redrawn? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:23:01+00:00Added an answer on May 22, 2026 at 9:23 pm

    If you are looking for redrawing the graph after user interaction, you have to add an EditingModalGraphMouse to your VisualizationViewer

        EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), 
                 vertexFactory, edgeFactory); 
        vv.setGraphMouse(gm);
    

    the constructor must be fed with vertexFactory and edgeFactory objects derived from

    Factory<E> and Factory<V>
    

    whose job is to create a new instance of edge/vertices class via the create() method

    Factory <BusStop> vertexFactory = new Factory<BusStop>() {
                public BusStop create() {
                    return new BusStop();
                }
            };
    

    same for the edgeFactory

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to build a control flow graph for a Java program using
I managed to build a basic IFrame application, using the Graph API. I wanted
i am trying to use an arraylist to build a graph using fusionfree however
I'm looking to perform some dependence analysis using a call-graph that I will build
Is there any Graph Builder for GStreamer? So to say you build graph you
I am trying to build a dependency graph of tables based on the foreign
I'm going to build a simple math graph for a browser application. Therefore all
Any one please help me to build a horizontal bar graph in my android
I'm trying to build my first fractal (Pythagoras Tree): alt text http://img13.imageshack.us/img13/926/lab6e.jpg in Java
Attempting to build an interface and generics based graph and getting an odd error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.