1 import java
.util
.Observable
;
2 import java
.util
.Observer
;
11 final static long serialVersionUID
= 1L;
17 protected int XBORDER
;
18 protected int YBORDER
;
19 protected double dataRange
= 0.0;
21 protected Color
[][] POINTS
;
22 protected Double
[][] DATA
;
28 public AntView(int rect_dim
) {
29 this(rect_dim
, rect_dim
, 10*rect_dim
, 10*rect_dim
);
35 this(rect_dim
, rect_dim
, wsize
, wsize
);
45 POINTS
= new Color
[xdim
][ydim
];
46 DATA
= new Double
[xdim
][ydim
];
47 for (int x
= 0; x
< xdim
; x
++) {
48 for (int y
= 0; y
< ydim
; y
++) {
49 POINTS
[x
][y
] = new Color(255,255,255);
54 JFrame f
= new JFrame("Calendar");
56 f
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
58 Container cp
= f
.getContentPane();
59 cp
.setBackground(Color
.white
);
60 cp
.add("Center", this);
63 f
.setSize(new Dimension(wxsize
,wysize
));
68 public Color
getPOINT(int x
, int y
) {
69 if (x
< XDIM
&& y
< YDIM
&& x
>= 0 && y
>= 0)
70 return this.POINTS
[x
][y
];
75 public void setPOINT(int x
, int y
, Color color
) {
76 if (x
< XDIM
&& y
< YDIM
&& x
>= 0 && y
>= 0)
77 this.POINTS
[x
][y
] = color
;
82 public Double
getDATA(int x
, int y
) {
83 if (x
< XDIM
&& y
< YDIM
&& x
>= 0 && y
>= 0)
84 return this.DATA
[x
][y
];
89 public void setDATA(int x
, int y
, Double val
) {
90 if (x
< XDIM
&& y
< YDIM
&& x
>= 0 && y
>= 0)
91 this.DATA
[x
][y
] = val
;
96 public void paint(Graphics g
) {
97 this.setBackground(Color
.getColor("OPAQUE"));
101 public void update() {
102 this.update(this.getGraphics());
105 public void update(Graphics g
) {
106 Graphics2D g2
= (Graphics2D
)g
;
108 Dimension d
= getSize();
110 XPSIZE
= d
.width
/ XDIM
;
111 YPSIZE
= d
.height
/ YDIM
;
113 XBORDER
= XPSIZE
/10 + 1;
114 YBORDER
= YPSIZE
/10 + 1;
118 for (int x
= 0; x
< XDIM
; x
++) {
119 for (int y
= 0; y
< YDIM
; y
++) {
120 g2
.setColor(POINTS
[x
][y
]);
121 g2
.fillRect(x
* (XPSIZE
+ YBORDER
),
122 y
* (YPSIZE
+ YBORDER
), XPSIZE
, YPSIZE
);
127 public void calibrate() {
129 double min
= Double
.MAX_VALUE
, max
= Double
.MIN_VALUE
;
131 for (int x
= 0; x
< XDIM
; x
++) {
132 for (int y
= 0; y
< YDIM
; y
++) {
133 double dval
= getDATA(x
, y
);
141 this.dataRange
= max
- min
;
145 public void calibrate(double max
, double min
) {
146 this.dataRange
= max
- min
;
149 /* no @Override or x10c will complain! */
150 public void update(Observable o
, Object arg
) {
152 int[] Tour
= (int[])arg
;
154 this.setDATA(i
, i
, 1.0);
155 this.setPOINT(i
, i
, new Color( 0 ) );