1 package org.catacomb.dataview;
2
3 import java.awt.Color;
4
5 import org.catacomb.datalish.Box;
6 import org.catacomb.graph.gui.Painter;
7
8
9 public class PointsPlotElement extends PlotElement {
10
11 double[] xpts;
12 double[] ypts;
13 int nx;
14 int ny;
15
16
17 public PointsPlotElement(double[] x, double[] y) {
18 this(x, y, Color.white);
19 }
20
21 public PointsPlotElement(double[] x, double[] y, Color c) {
22 this(x, y, c, 3);
23 }
24
25
26 public PointsPlotElement(double[] x, double[] y, Color c, int np) {
27 this(x, y, c, np, np);
28 }
29
30 public PointsPlotElement(double[] x, double[] y, Color c, int inx, int iny) {
31 xpts = x;
32 ypts = y;
33 col = c;
34 nx = inx;
35 ny = iny;
36 }
37
38
39
40 public void instruct(Painter p) {
41 p.setColor(col);
42 if (nx >= 3) {
43 for (int i = 0; i < xpts.length; i++) {
44 p.drawCenteredOval(xpts[i], ypts[i], nx, ny);
45 }
46
47 } else {
48 for (int i = 0; i < xpts.length; i++) {
49 p.drawFilledRectangle(xpts[i], ypts[i], nx, ny, col);
50 }
51 }
52 }
53
54
55
56 public void push(Box b) {
57 b.push(xpts, ypts);
58
59 }
60
61 }