1
2
3 package org.catacomb.dataview.build;
4
5
6 import org.catacomb.dataview.DataPlotPainter;
7 import org.catacomb.druid.build.Context;
8 import org.catacomb.druid.gui.base.DruDataDisplay;
9 import org.catacomb.druid.gui.base.DruPanel;
10 import org.catacomb.interlish.structure.AddableTo;
11 import java.util.ArrayList;
12
13
14
15
16 public class DataPlot extends DVPanel implements AddableTo {
17
18 public ArrayList<Displayable> displayList;
19
20 public Axis xAxis;
21 public Axis yAxis;
22
23
24 public void add(Object obj) {
25 if (obj instanceof Displayable) {
26 if (displayList == null) {
27 displayList = new ArrayList<Displayable>();
28 }
29 displayList.add((Displayable)obj);
30
31 } else {
32 System.out.println("data view cant add " + obj);
33 }
34 }
35
36
37 public DruPanel makePanel(Context ctxt) {
38 DruDataDisplay ddp = new DruDataDisplay(width, height);
39
40 ddp.setXAxis(xAxis.label, xAxis.min, xAxis.max);
41 ddp.setYAxis(yAxis.label, yAxis.min, yAxis.max);
42
43
44 DataPlotPainter dpp = new DataPlotPainter(displayList);
45 ddp.attachGraphicsController(dpp);
46
47
48 ctxt.addToCache(ddp);
49 ctxt.addToCache(dpp);
50
51
52
53
54
55
56
57
58
59
60 return ddp;
61 }
62
63
64 }