Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/memoire/dja/DjaLayoutDiamond.java


1   /**
2    * @modification $Date: 2001/12/03 16:28:08 $
3    * @statut       unstable
4    * @file         DjaLayoutDiamond.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 DjaLayoutDiamond
18    implements DjaLayoutInterface
19  {
20    public DjaLayoutDiamond()
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      double r=20.+10.*n;
33  
34      for(int i=0;i<n;i++)
35      {
36        DjaForm f=(DjaForm)v.elementAt(i);
37        int x=0;
38        int y=0;
39        int k=(4*i)/n;
40        double z=4.*(double)(i-(k*n)/4)/(double)n;
41  
42        switch((4*i)/n)
43        {
44        case 0:
45      x=(int)(r+r*z);
46      y=(int)(r*z);
47      break;
48        case 1:
49      x=(int)(2.*r-r*z);
50      y=(int)(r+r*z);
51      break;
52        case 2:
53      x=(int)(r-r*z);
54      y=(int)(2.*r-r*z);
55      break;
56        case 3:
57      x=(int)(r*z);
58      y=(int)(r-r*z);
59      break;
60        }
61  
62        f.setX(x);
63        f.setY(y);
64      }
65    }
66  }