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

  • SEARCH
  • Home
  • 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 6967029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:16:06+00:00 2026-05-27T16:16:06+00:00

In one of my projects I use JUNG2 to visualize a very large multiple-parent

  • 0

In one of my projects I use JUNG2 to visualize a very large multiple-parent hierarchy graph, displayed in an applet. I would need to export the whole/parts of the graph to high resolution still images, since screenshots look hideous when printed (especially if the graph has been zoomed out).

The code I use currently is as follows:

public void writeToDisk(File saveToFolder, String filename) {
    //Dimension loDims = getGraphLayout().getSize();
    Dimension vsDims = getSize();

    int width = vsDims.width;
    int height = vsDims.height;
    Color bg = getBackground();

    BufferedImage im = new BufferedImage(width,height,BufferedImage.TYPE_INT_BGR);
    Graphics2D graphics = im.createGraphics();
    graphics.setColor(bg);
    graphics.fillRect(0,0, width, height);
    paintComponent(graphics);

    try{
       ImageIO.write(im,"png",new File(saveToFolder,filename));
    }catch(Exception e){
        e.printStackTrace();
    }
}

This creates PNG images which are not particularly high resolution. So my questions are as follows:

  1. Is it possible to push up the PNG export resolution to 300 dpi?
  2. Is it possible to export the graph, or any swing component for that matter, to vector based formats such as EPS, PDF or SVG without too much hassle? I have found several libraries (VectorGraphics2D,FreeHEP) for managing vector based images in Java, however I am not sure if using them would mean that I have to “re-draw” each vertex and edge in the graph. That’s obviously not very desirable…
  3. Are there any other alternatives which I might have missed?

Thanks in advance,

  • 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-27T16:16:06+00:00Added an answer on May 27, 2026 at 4:16 pm

    Thanks for the suggestions but I have managed to get FreeHEP Vector Graphics library working the way I want to. I am sharing the code below in case anyone runs into the same questions.

    The above-named library has a very nice built-in export menu, which handles the export to a bunch of different formats. Code excerpt from the modified ´ModelGraphMouse´ class:

    protected void handlePopup(MouseEvent e) {
            final VisualizationViewer<MyNode, MyEdge> vv = (VisualizationViewer<MyNode, MyEdge>)e.getSource();
            Point2D p = e.getPoint();
            GraphElementAccessor<MyNode, MyEdge> pickSupport = vv.getPickSupport();
            if(pickSupport != null) {
                final MyNode v = pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
    
                // if clicked on a vertex -> show info popup
                // else show contexual menu
                if(v != null) {
                    JFrame popup = new JFrame("Node: " + v.getId());
                    popup.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    ...
                } else{
                    JPopupMenu menu = new JPopupMenu();
                    JMenuItem exportGraphMenuItem = new JMenuItem("Export graph to vector image...");
                    exportGraphMenuItem.addActionListener(new ExportActionListener((WritingVisualizationViewer<V, E>) vv));
                    menu.add(exportGraphMenuItem);
                    menu.show(e.getComponent(), e.getX(), e.getY());
                } 
            }
        }
    

    and the action listener:

        public class ExportActionListener implements ActionListener{
    
        private VisualizationViewer<V, E> wvv;
        public ExportActionListener(VisualizationViewer<V, E> vv) {
            this.wvv = vv;
        }
    
        @Override
        public void actionPerformed(ActionEvent e) {
            ExportDialog export = new ExportDialog();
            export.showExportDialog(wvv, "Export view as ...", wvv, "export");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In one of my Django projects that use MySQL as the database, I need
I want to use the Hibernate3 maven plugin in one of my projects. But,
Why would one use a functional language in an otherwise Imperative project?
One of my projects needs to use crystalreport,so i want some information about it.
In one of my latest projects I use Solr 1.4 for searching products.However I
I'm switching one of my projects over to use googles maps api v3 from
One of my projects is making use of Microsoft's supplied memory leak checker via
In one of my projects I use JQuery Tools Tooltip, and it works great.
In one of our projects we use a java webapp talking to a MongoDB
I would like to merge two php projects. Both projects use global variables so

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.