Source code: com/memoire/dja/DjaLayoutTree.java
1 /**
2 * @modification $Date: 2001/12/03 16:28:08 $
3 * @statut unstable
4 * @file DjaLayoutTree.java
5 * @version 0.36
6 * @author Guillaume Desnoix
7 * @email guillaume@desnoix.com
8 * @license GNU General Public License 2 (GPL2)
9 * @copyright 1998-2001 Guillaume Desnoix
10 */
11
12 package com.memoire.dja;
13
14 import com.memoire.dja.*;
15 import java.util.*;
16
17 public class DjaLayoutTree
18 implements DjaLayoutInterface
19 {
20 public DjaLayoutTree()
21 {
22 }
23
24 public void layout(DjaGrid _grid)
25 {
26 DjaVector v=new DjaVector();
27 for(Enumeration e=_grid.enumerate(DjaForm.class);
28 e.hasMoreElements(); )
29 v.addElement(e.nextElement());
30
31 int n=v.size();
32 int x=10;
33 int y=10;
34 int w=0;
35 for(int i=0;i<n;i++)
36 {
37 DjaForm f=(DjaForm)v.elementAt(i);
38
39 if((f.getEndConnections().length>0)||(f.getBeginConnections().length>0))
40 {
41 x+=w-10;
42 x+=10-x%10;
43 w=0;
44 }
45
46 w=Math.max(w,f.getWidth());
47
48 f.setX(x);
49 f.setY(y);
50 DjaLib.snap(f);
51
52 y+=f.getHeight()+5;
53 y+=10-y%10;
54 }
55 }
56 }