[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
Gephi forums •Invisible Nodes with Gephi Toolkit 0.9.1
Page 1 of 1

Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 12 Jun 2016 17:15
by littleBobbyTables
Hello,

I am having an issue where I am trying to create an display a graph manually (i.e. not importing from an external file) but the nodes are not showing up. They seem just entirely invisible. I have tried changing the background color to see if they were just white on a white background, but that does not appear to be the issue. The edges show up just fine, but the nodes just don't seem to appear. My code, shown below, is mostly just pieces of the demo code from the toolkit being put together to get my desired output. Also attached is a screenshot of my display. Any help would be much appreciated. Thank you!

Code: Select all

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;

import org.gephi.graph.api.DirectedGraph;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.Node;
import org.gephi.preview.api.G2DTarget;
import org.gephi.preview.api.PreviewController;
import org.gephi.preview.api.PreviewModel;
import org.gephi.preview.api.PreviewProperty;
import org.gephi.preview.api.RenderTarget;
import org.gephi.preview.types.DependantColor;
import org.gephi.project.api.ProjectController;
import org.gephi.project.api.Workspace;
import org.gephi.toolkit.demos.plugins.preview.PreviewSketch;
import org.openide.util.Lookup;

/**
 *
 * @author JasonB
 *
 */
public class BasicGraphBuild {

	public static void main(String[] args) {
		BasicGraphBuild bscGraphBuild = new BasicGraphBuild();
		bscGraphBuild.script();
	}

	public void script() {
		ProjectController pc =
				Lookup.getDefault().lookup(ProjectController.class);
		pc.newProject();
		Workspace workspace = pc.getCurrentWorkspace();

		GraphModel graphModel = Lookup.getDefault()
				.lookup(GraphController.class).getGraphModel();

		Node n0 = graphModel.factory().newNode("n0");
		n0.setLabel("Node 0");
		n0.setX((float) ((0.01 + Math.random()) * 1000) - 500);
		n0.setY((float) ((0.01 + Math.random()) * 1000) - 500);
		Node n1 = graphModel.factory().newNode("n1");
		n1.setLabel("Node 1");
		n1.setX((float) ((0.01 + Math.random()) * 1000) - 500);
		n1.setY((float) ((0.01 + Math.random()) * 1000) - 500);
		Node n2 = graphModel.factory().newNode("n2");
		n2.setLabel("Node 2");
		n2.setX((float) ((0.01 + Math.random()) * 100) - 50);
		n2.setY((float) ((0.01 + Math.random()) * 100) - 50);

		Edge e1 = graphModel.factory().newEdge(n0, n1, 0, 1.0, true);
		Edge e2 = graphModel.factory().newEdge(n0, n2, 0, 1.0, true);

		DirectedGraph directedGraph = graphModel.getDirectedGraph();
		directedGraph.addNode(n0);
		directedGraph.addNode(n1);
		directedGraph.addNode(n2);
		directedGraph.addEdge(e1);
		directedGraph.addEdge(e2);

		// Preview configuration
		PreviewController previewController =
				Lookup.getDefault().lookup(PreviewController.class);
		PreviewModel previewModel = previewController.getModel();
		previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED,
				Boolean.FALSE);
		previewModel.getProperties().putValue(PreviewProperty.DIRECTED,
				Boolean.TRUE);
		previewModel.getProperties().putValue(PreviewProperty.NODE_BORDER_COLOR,
				new DependantColor(Color.BLACK));
		previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS,
				Boolean.TRUE);
		previewModel.getProperties().putValue(PreviewProperty.NODE_OPACITY,
				100);
		previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 50);
		previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 10f);
		previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR,
				Color.WHITE);

		// New Processing target, get the PApplet
		G2DTarget target = (G2DTarget) previewController
				.getRenderTarget(RenderTarget.G2D_TARGET);
		PreviewSketch previewSketch = new PreviewSketch(target);
		previewController.refreshPreview();
		previewSketch.resetZoom();

		// Add the applet to a JFrame and display
		JFrame frame = new JFrame("Test Preview");
		frame.setLayout(new BorderLayout());

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(previewSketch, BorderLayout.CENTER);

		frame.setSize(1024, 768);
		frame.setVisible(true);

	}

}

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 12 Jun 2016 20:01
by eduramiba
Hi,
Can you try to set node opacity as a float (100f)? Not sure this is the problem but might be.

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 12 Jun 2016 20:17
by littleBobbyTables
Thanks for your suggestion! I just tried that, but no luck. they still don't show up.

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 16 Jun 2016 20:01
by Node231
Today I had a relatively similar issue, using 0.8.2 though

my workaround was installing an older version of java, other than that I have no idea :(

I used:
http://www.oracle.com/technetwork/java/ ... 19409.html
jre-6u38-windows-x64

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 16 Jun 2016 20:08
by littleBobbyTables
Sadly, I can't do that. I need Java 8 for the rests of the project. Thanks, though!

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 11 Jul 2016 15:48
by littleBobbyTables
Sorry this has taken so long to update, but I have (sort of) fixed this problem with a rather strange workaround. Instead of building the graph the way I have done above, I instead used an ImportController and ImportContainer and with that used NodeDraftImpl objects and EdgeDraftImpl objects. I don't know why this solves the problem and makes nodes visible, but it worked for me. Most all of the methods that exist to modify the nodes and edges in the other method still exist in some regard with this method. The other thing to keep in mind is that you need to remember to process the container after building the graph in it (that's the point of the ImportController). That's how I solved this. I hope it helps anyone with a similar issue!

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 23 Nov 2016 15:36
by semen.kosyachenko
hi, I have same problem, and I don't know what to do with it.
I can see edges, but not nodes(((
so littleBobbyTables could you post the code how you make graph manualy using ImportController and ImportContainer?
thanks.

Re: Invisible Nodes with Gephi Toolkit 0.9.1

Posted: 09 Feb 2018 03:47
by khuatthanhson94
Dear sir,
I am a researcher at Department of Technology and Software Solutions - Institute of information technology - VietNam Academy of Science and Technology.
I am having a research paper on information diffusion of Twitter - a social networking and i watched your video for demo of same problem.

Can you tell me about source code which resolve this problem?

Problem: Currently, I am coding on java but i had one problem: I want to show all Edge when i clicked node. Like on Gephi app. Please help me.

Thanks for helpful,