salut ,
j'ai utilisé le JGraph pour developpez un editeur graphique.
et je veux persister mon graph, j'ai lu le pdf "JGraph manuel", et j'ai trouv ce code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
XMLEncoder encoder;
try {
encoder = new XMLEncoder(outputStream);
// Better debugging output, in case you need it
encoder.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e) {
e.printStackTrace();
}
});
encoder.setPersistenceDelegate(DefaultGraphModel.class,
new DefaultPersistenceDelegate(new String[] { "roots",
"attributes" }));
encoder.setPersistenceDelegate(GraphLayoutCache.class,
new DefaultPersistenceDelegate(new String[] { "model",
"factory", "cellViews", "hiddenCellViews",
"partial" }));
encoder.setPersistenceDelegate(DefaultGraphCell.class,
new DefaultPersistenceDelegate(
new String[] { "userObject" }));
encoder.setPersistenceDelegate(DefaultEdge.class,
new DefaultPersistenceDelegate(
new String[] { "userObject" }));
encoder.setPersistenceDelegate(DefaultPort.class,
new DefaultPersistenceDelegate(
new String[] { "userObject" }));
encoder.setPersistenceDelegate(AbstractCellView.class,
new DefaultPersistenceDelegate(new String[] { "cell",
"attributes" }));
encoder.setPersistenceDelegate(
DefaultEdge.DefaultRouting.class,
new PersistenceDelegate() {
protected Expression instantiate(
Object oldInstance, Encoder out) {
return new Expression(oldInstance,
GraphConstants.class,
"getROUTING_SIMPLE", null);
}
});
encoder.setPersistenceDelegate(DefaultEdge.LoopRouting.class,
new PersistenceDelegate() {
protected Expression instantiate(
Object oldInstance, Encoder out) {
return new Expression(oldInstance,
GraphConstants.class,
"getROUTING_DEFAULT", null);
}
});
encoder.setPersistenceDelegate(ArrayList.class, encoder
.getPersistenceDelegate(List.class));
encoder.writeObject(graph.getGraphLayoutCache());
encoder.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(graph, e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
je l'ai essayé mais ca marche pas ds mon code, car j'ai definit le ObjectUser de la DefaultGraphCell:: cell=new DefaultGraphCell(new EtapeInitiale("04"));
aide moi SVP . qu'est ceque je dois faire pour enregister mon graph sous format XML.
merci d'avance