Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

How to set the preview window to fixed dimensions?

Get help with your data

How to set the preview window to fixed dimensions?

Postby Epi111 » 05 Jun 2013 23:49

Hi,

I would like to use the Gephi-Toolkit to export PNGs while runing through the timeline and running ForceAtlas2 in autolayout-mode.

Everything in the script works fine so far: move on one step in timeline -> run layout for 50 ms -> write Preview to PNG-file.

The problem is, that the preview adjusts its size after each step to optimally fit the nodes in the frame. I don't want that. I would like to set the preview to fixed dimensions (even though this could lead to some nodes lying ouside the visible view, this would be okay). I digged until I found instructions in PreviewControllerImpl.java (public void updateDimensions) but am unable to make use of the code. I am not even shure, if I am on the right track

Does somebody know how to set the preview window properties to fixed values?

Cheers
Matthias
Epi111
 
Posts: 2
Joined: 26 May 2013 22:55
Location: Hamburg

Re: How to set the preview window to fixed dimensions?

Postby pegerp » 11 Jun 2013 14:05

Hi Matthias.

I believe the updateDimensions is not exactly what you need. The implementation goes through all nodeItems that are passed as parameter and finds the minx/miny/maxx/maxy (topLeftX, bottomRightX, bottomRightY, topLeftY) values of the nodes. Using that information the PreviewModel's dimensions and topLeftPosition are updated.

I got over this by just adding following in the PreviewModelImpl.java:
Code: Select all
    public void setDimensions(Dimension dimensions) {
        this.dimensions = dimensions;
    }

    public void setTopLeftPosition(Point topLeftPosition) {
        this.topLeftPosition = topLeftPosition;
    }

Then in my custom exporter I use model.setDimensions(width, height) and model.setTopLeftPosition(topLeftPositionX, topLeftPositionY) to adjust the area the preview is showing.

Also setDimensions() and setTopLeftPosition() in your exporter should be used after doing the refreshPreview() in PreviewController controller. For example for the exporter take a look at PNGExporter.java in PreviewExport module. refreshPreview method presets renderers for labels and edges and stuff like that which you probably want but it also changes the preview canvas adjustment to fit the nodes in the frame.
pegerp
 
Posts: 101
Joined: 21 Dec 2011 18:10


Return to Data Import / Export

Who is online

Users browsing this forum: No registered users and 1 guest