View Javadoc

1   
2   
3   package org.catacomb.graph.gui;
4   
5   import org.catacomb.be.Position;
6   import org.catacomb.datalish.Box;
7   
8   import javax.swing.JFrame;
9   
10  
11  
12  public class ZoneDemo implements BuildPaintInstructor, PickListener {
13  
14      PickablePoint[] points;
15  
16      public ZoneDemo() {
17          points = new PickablePoint[10];
18          for (int i = 0; i < points.length; i++) {
19              points[i] = new PickablePoint(10. * Math.random(),
20                                            10. * Math.random());
21          }
22  
23      }
24  
25  
26      public void init() {
27          JFrame f = new JFrame();
28          DataDisplay wc = new DataDisplay(500, 300);
29  
30          wc.setBuildPaintInstructor(this);
31  
32          wc.setPickListener(this);
33  
34          f.getContentPane().add(wc);
35          f.pack();
36          f.setVisible(true);
37      }
38  
39  
40  
41      public static void main(String[] argv) {
42          ZoneDemo zd = new ZoneDemo();
43  
44          zd.init();
45  
46      }
47  
48  
49  
50      public boolean antialias() {
51          return true;
52      }
53  
54  
55      // for BuildPaintInstructure
56      public void instruct(Painter p, Builder b) {
57          // do the painting...;
58          p.drawLine(0.5, 0.5, 1.5, 1.5);
59  
60          for (int i = 0; i < points.length; i++) {
61              b.addPickablePoint(points[i]);
62          }
63  
64      }
65  
66  
67      public void backgroundPressed(int i, int x, int y) {
68  
69      }
70  
71  
72      // for PickListener
73      public void pickPressed(Pickable pbl, int button, int ix, int iy) {
74  
75      }
76  
77      public void pickReleased(Pickable pbl, int button) {
78  
79      }
80  
81      public void pickDragged(Pickable pbl, Position pos, int button, int ix, int iy) {
82  
83          if (pbl instanceof PickablePoint) {
84              if (button == Mouse.LEFT) {
85                  ((PickablePoint)pbl).moveTo(pos);
86              }
87          }
88      }
89  
90      public void pickEnteredTrash(Pickable pbl) {
91      }
92  
93      public void pickLeftTrash(Pickable pbl) {
94      }
95  
96      public void pickTrashed(Pickable pbl) {
97      }
98  
99  
100     public void trashPressed() {
101         // TODO Auto-generated method stub
102 
103     }
104 
105 
106     public void pickHovered(Pickable hoverItem) {
107         // TODO Auto-generated method stub
108 
109     }
110 
111 
112     public Box getLimitBox() {
113         // TODO Auto-generated method stub
114         return null;
115     }
116 
117 
118     public Box getLimitBox(Painter p) {
119         // TODO Auto-generated method stub
120         return null;
121     }
122 
123 
124 
125 
126 
127 }