- From: Stefan Balev <stefan.balev AT gmail.com>
- To: graphstream-users AT litislab.fr, guilhelm savin <guilhelm.savin AT gmail.com>
- Subject: Re: Viewer(Graph) - Erreur de compilation
- Date: Fri, 13 Jan 2012 11:01:45 +0100
Hi Zacharie,
You are right, there was an error in the tutorial. Thanks to you it is
fixed now.
Best,
--
Stefan
2012/1/13 guilhelm savin
<guilhelm.savin AT gmail.com>:
>
Hi Zacharie,
>
>
Welcome to our community.
>
>
If you look at the Javadoc, you will see that there is no
>
Viewer(Graph) constructor but Viewer(GraphicGraph).
>
>
To create a viewer, the easiest way is to use the display()
>
method of Graph :
>
|
>
| Graph g = ... ;
>
| Viewer v = g.display();
>
|
>
>
This will create a JFrame and display the graph in this frame.
>
If you need to get a swing component (to integrate it in your
>
own interface), you have to follow this way :
>
|
>
| Graph g = ... ;
>
| Viewer v = new Viewer(g, ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
>
| v.enableAutolayout(); // Optional
>
|
>
| JPanel graphPanel = v.addDefaultView(false);
>
|
>
>
Hope this helps !
>
Regards.
>
>
Guilhelm
>
>
Le 13 janvier 2012 10:41, Zacharie ALES
>
<zacharie.ales AT gmail.com>
>
a écrit :
>
>
> Bonjour,
>
>
>
> J'obtiens une erreur de compilation en essayant de compiler un code
>
> extrait de la documentation (le code permettant d'intégrer un graphe dans
>
> une GUI).
>
>
>
> Mon code est simplement le suivant :
>
>
>
>> import javax.swing.JFrame;
>
>>
>
>>
>
>>
>
>> import org.graphstream.graph.Graph;
>
>>
>
>> import org.graphstream.graph.implementations.MultiGraph;
>
>> import org.graphstream.ui.swingViewer.View;
>
>> import org.graphstream.ui.swingViewer.Viewer;
>
>>
>
>>
>
>>
>
>> public class main {
>
>> public static void main(String args[]){
>
>>
>
>> JFrame frame = new JFrame("Test");
>
>> Graph graph = new MultiGraph("embedded");
>
>>
>
>>
>
>>
>
>> /* Erreur a la ligne ci-dessous */
>
>>
>
>> Viewer viewer = new Viewer(graph);
>
>>
>
>>
>
>> View view = viewer.addDefaultView(false);
>
>>
>
>> frame.add(view);
>
>> frame.setVisible(true);
>
>> }
>
>> }
>
>
>
>
>
>
>
> J'obtiens l'erreur de compilation suivante à la ligne où je déclare le
>
> viewer : "The constructor Viewer(Graph) is undefined". J'utilise les
>
> librairies gs-core1.1.1 et gs-ui-1.1.1.
>
>
>
> Est-ce normal ? Comment puis-je faire pour intégrer mon graphe dans une
>
> JFrame ?
>
>
>
> Merci d'avance !
>
> --
>
> Zacharie ALES.
>
>
>
>
>
--
>
Guilhelm Savin
>
PhD Student of Computer Science
>
LITIS, University of Le Havre
>
\/\/\/\/\/\/
>
http://litis.univ-lehavre.fr/~savin
>
http://iscn.univ-lehavre.fr
>
http://graphstream-project.org
>
/\/\/\/\/\/\
>
Archives gérées par MHonArc 2.6.16.